Skip to content

Commit a7a8d2d

Browse files
authored
Merge pull request #55 from rohanjsh/feat/link-recognizer
feat: link recognizer and remove url_launcher dependency
2 parents d515712 + c90dc08 commit a7a8d2d

18 files changed

+114
-97
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11

22
# Changelog
33

4+
# 2.2.0
5+
### New
6+
- Recognize individual links and apply desired actions on tap.
7+
8+
### Breaking
9+
- `recognizer` is now `linkGestureRecognizer` callback
10+
- Removed `url_launcher` dependency
11+
412
# 2.1.2
513
### Chore
614
- Dependency updates

README.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ TypeSet('Hello #World!#'); // Renders 'World!' underlined
5555
TypeSet('Hello, `World!`'); // Renders 'World!' in monospace
5656

5757
// Hyperlink Text Example
58-
TypeSet('§google.com|https://google.com§'); // Renders 'google.com' as a clickable link
58+
TypeSet('§google.com|https://google.com§',
59+
linkRecognizerBuilder: (linkText, url) =>
60+
TapGestureRecognizer()
61+
..onTap = () {
62+
// your desired action
63+
},
64+
); // Renders 'google.com' as a link
5965

6066
// Dynamic Font Size Example
6167
TypeSet('Hey, *Hello world<30>*'); // Renders 'Hello world' with font size 30

example/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
*.swp
66
.DS_Store
77
.atom/
8+
.build/
89
.buildlog/
910
.history
1011
.svn/
12+
.swiftpm/
1113
migrate_working_dir/
1214

1315
# IntelliJ related

example/ios/Flutter/AppFrameworkInfo.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>11.0</string>
24+
<string>12.0</string>
2525
</dict>
2626
</plist>

example/ios/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '11.0'
2+
# platform :ios, '12.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Podfile.lock

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
PODS:
22
- Flutter (1.0.0)
3-
- path_provider_foundation (0.0.1):
4-
- Flutter
5-
- FlutterMacOS
63
- url_launcher_ios (0.0.1):
74
- Flutter
85

96
DEPENDENCIES:
107
- Flutter (from `Flutter`)
11-
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
128
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
139

1410
EXTERNAL SOURCES:
1511
Flutter:
1612
:path: Flutter
17-
path_provider_foundation:
18-
:path: ".symlinks/plugins/path_provider_foundation/darwin"
1913
url_launcher_ios:
2014
:path: ".symlinks/plugins/url_launcher_ios/ios"
2115

2216
SPEC CHECKSUMS:
23-
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
24-
path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9
25-
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
17+
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
18+
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
2619

27-
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
20+
PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011
2821

29-
COCOAPODS: 1.11.3
22+
COCOAPODS: 1.15.2

example/ios/Runner.xcodeproj/project.pbxproj

+7-8
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@
113113
B6F4CE0C58C796581DF0844C /* Pods-Runner.release.xcconfig */,
114114
F3947AF51B8B596DF7892175 /* Pods-Runner.profile.xcconfig */,
115115
);
116-
name = Pods;
117116
path = Pods;
118117
sourceTree = "<group>";
119118
};
@@ -156,7 +155,7 @@
156155
97C146E61CF9000F007C117D /* Project object */ = {
157156
isa = PBXProject;
158157
attributes = {
159-
LastUpgradeCheck = 1430;
158+
LastUpgradeCheck = 1510;
160159
ORGANIZATIONNAME = "";
161160
TargetAttributes = {
162161
97C146ED1CF9000F007C117D = {
@@ -343,7 +342,7 @@
343342
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
344343
GCC_WARN_UNUSED_FUNCTION = YES;
345344
GCC_WARN_UNUSED_VARIABLE = YES;
346-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
345+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
347346
MTL_ENABLE_DEBUG_INFO = NO;
348347
SDKROOT = iphoneos;
349348
SUPPORTED_PLATFORMS = iphoneos;
@@ -359,7 +358,7 @@
359358
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
360359
CLANG_ENABLE_MODULES = YES;
361360
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
362-
DEVELOPMENT_TEAM = FV94K6TFFS;
361+
DEVELOPMENT_TEAM = 8D5Y6FBA43;
363362
ENABLE_BITCODE = NO;
364363
INFOPLIST_FILE = Runner/Info.plist;
365364
LD_RUNPATH_SEARCH_PATHS = (
@@ -421,7 +420,7 @@
421420
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
422421
GCC_WARN_UNUSED_FUNCTION = YES;
423422
GCC_WARN_UNUSED_VARIABLE = YES;
424-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
423+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
425424
MTL_ENABLE_DEBUG_INFO = YES;
426425
ONLY_ACTIVE_ARCH = YES;
427426
SDKROOT = iphoneos;
@@ -470,7 +469,7 @@
470469
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
471470
GCC_WARN_UNUSED_FUNCTION = YES;
472471
GCC_WARN_UNUSED_VARIABLE = YES;
473-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
472+
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
474473
MTL_ENABLE_DEBUG_INFO = NO;
475474
SDKROOT = iphoneos;
476475
SUPPORTED_PLATFORMS = iphoneos;
@@ -488,7 +487,7 @@
488487
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
489488
CLANG_ENABLE_MODULES = YES;
490489
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
491-
DEVELOPMENT_TEAM = FV94K6TFFS;
490+
DEVELOPMENT_TEAM = 8D5Y6FBA43;
492491
ENABLE_BITCODE = NO;
493492
INFOPLIST_FILE = Runner/Info.plist;
494493
LD_RUNPATH_SEARCH_PATHS = (
@@ -511,7 +510,7 @@
511510
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
512511
CLANG_ENABLE_MODULES = YES;
513512
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
514-
DEVELOPMENT_TEAM = FV94K6TFFS;
513+
DEVELOPMENT_TEAM = 8D5Y6FBA43;
515514
ENABLE_BITCODE = NO;
516515
INFOPLIST_FILE = Runner/Info.plist;
517516
LD_RUNPATH_SEARCH_PATHS = (

example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1430"
3+
LastUpgradeVersion = "1510"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -48,6 +48,7 @@
4848
ignoresPersistentStateOnLaunch = "NO"
4949
debugDocumentVersioning = "YES"
5050
debugServiceExtension = "internal"
51+
enableGPUValidationMode = "1"
5152
allowLocationSimulation = "YES">
5253
<BuildableProductRunnable
5354
runnableDebuggingMode = "0">

example/ios/Runner/AppDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import UIKit
22
import Flutter
33

4-
@UIApplicationMain
4+
@main
55
@objc class AppDelegate: FlutterAppDelegate {
66
override func application(
77
_ application: UIApplication,

example/lib/main.dart

+46-33
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/gestures.dart' show TapGestureRecognizer;
12
import 'package:flutter/material.dart';
23
import 'package:typeset/typeset.dart';
34

@@ -31,26 +32,26 @@ class TypeSetExample extends StatelessWidget {
3132
),
3233
body: Center(
3334
child: ListView(
34-
children: const [
35+
children: [
3536
Padding(
36-
padding: EdgeInsets.symmetric(
37+
padding: const EdgeInsets.symmetric(
3738
horizontal: 22,
3839
),
3940
child: Column(
4041
crossAxisAlignment: CrossAxisAlignment.start,
4142
children: [
42-
Divider(),
43-
Text(
43+
const Divider(),
44+
const Text(
4445
'Usage',
4546
style: TextStyle(
4647
fontSize: 20,
4748
),
4849
),
49-
Divider(),
50-
SizedBox(
50+
const Divider(),
51+
const SizedBox(
5152
height: 12,
5253
),
53-
Text(
54+
const Text(
5455
'''
5556
Bold
5657
→ Hello, *World!*
@@ -75,96 +76,108 @@ Link
7576
),
7677
),
7778

78-
Divider(),
79-
Text(
79+
const Divider(),
80+
const Text(
8081
'Samples',
8182
style: TextStyle(
8283
fontSize: 20,
8384
),
8485
),
85-
Divider(),
86+
const Divider(),
8687

87-
SizedBox(
88+
const SizedBox(
8889
height: 12,
8990
),
9091
TypeSet(
9192
'→ *TypeSet* _can_ #style# ~everything~ `you need` §with|https://rohanjsh.dev/§ _dynamic<18>_ _font<28>_ _size<25>_',
92-
style: TextStyle(
93+
style: const TextStyle(
9394
fontSize: 18,
9495
),
95-
),
96-
SizedBox(
96+
linkRecognizerBuilder: (linkText, url) {
97+
return TapGestureRecognizer()
98+
..onTap = () {
99+
debugPrint('URL: $url and Text: $linkText');
100+
};
101+
},
102+
),
103+
const SizedBox(
97104
height: 24,
98105
),
99-
Divider(),
100-
Text(
106+
const Divider(),
107+
const Text(
101108
'Supported Stylings',
102109
style: TextStyle(
103110
fontSize: 20,
104111
),
105112
),
106-
Divider(),
113+
const Divider(),
107114

108-
SizedBox(
115+
const SizedBox(
109116
height: 12,
110117
),
111-
TypeSet(
112-
'Bold:\n*Bold Text*',
118+
const TypeSet(
119+
'Bold:\nHello<20> world',
113120
style: TextStyle(
114121
fontSize: 24,
115122
),
116123
),
117-
SizedBox(
124+
const SizedBox(
118125
height: 20,
119126
),
120-
TypeSet(
127+
const TypeSet(
121128
'Italic:\n→ _Italic Text_ ',
122129
style: TextStyle(
123130
fontSize: 24,
124131
),
125132
),
126-
SizedBox(
133+
const SizedBox(
127134
height: 20,
128135
),
129-
TypeSet(
136+
const TypeSet(
130137
'Underline:\n→ #Underline Text#',
131138
style: TextStyle(
132139
fontSize: 24,
133140
),
134141
),
135-
SizedBox(
142+
const SizedBox(
136143
height: 20,
137144
),
138-
TypeSet(
145+
const TypeSet(
139146
'Strikethrough:\n→ ~Strikethrough Text~',
140147
style: TextStyle(
141148
fontSize: 24,
142149
),
143150
),
144-
SizedBox(
151+
const SizedBox(
145152
height: 20,
146153
),
147-
TypeSet(
154+
const TypeSet(
148155
'Monospace:\n→ `monospace text`',
149156
style: TextStyle(
150157
fontSize: 24,
151158
),
152159
),
153-
SizedBox(
160+
const SizedBox(
154161
height: 20,
155162
),
156163

157164
//customized link textstyle and recognizer (tap recognizer)
158165
TypeSet(
159166
'Link:\n→ §google.com|https://google.com§',
160-
style: TextStyle(
167+
style: const TextStyle(
161168
fontSize: 24,
162169
),
163-
),
164-
SizedBox(
170+
linkRecognizerBuilder: (linkText, url) {
171+
return TapGestureRecognizer()
172+
..onTap = () {
173+
debugPrint('URL: $url and Text: $linkText');
174+
};
175+
},
176+
),
177+
const SizedBox(
165178
height: 20,
166179
),
167-
Divider(),
180+
const Divider(),
168181
],
169182
),
170183
)

lib/src/core/typeset_controller.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ import 'package:typeset/src/models/style_type_value_model.dart';
4242
/// 9. Return the `list` of `TypeValueModel` objects.
4343
///
4444
/// Outputs:
45-
/// - `list` (List<TypeValueModel>): A list of `TypeValueModel` objects
46-
/// representing the manipulated string. Each object contains a style type
47-
/// and the corresponding text segment.
45+
/// - `list` : A list of `StyleTypeValueModel`
46+
/// objects representing the manipulated string.
47+
/// Each object contains a style type and the corresponding text segment.
4848
class TypesetController {
4949
/// The constructor for the TypesetController class.
5050
TypesetController({

0 commit comments

Comments
 (0)