Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: link recognizer and remove url_launcher dependency #55

Merged
merged 7 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@

# Changelog

# 2.2.0
### New
- Recognize individual links and apply desired actions on tap.

### Breaking
- `recognizer` is now `linkGestureRecognizer` callback
- Removed `url_launcher` dependency

# 2.1.2
### Chore
- Dependency updates
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ TypeSet('Hello #World!#'); // Renders 'World!' underlined
TypeSet('Hello, `World!`'); // Renders 'World!' in monospace

// Hyperlink Text Example
TypeSet('§google.com|https://google.com§'); // Renders 'google.com' as a clickable link
TypeSet('§google.com|https://google.com§',
linkRecognizerBuilder: (linkText, url) =>
TapGestureRecognizer()
..onTap = () {
// your desired action
},
); // Renders 'google.com' as a link

// Dynamic Font Size Example
TypeSet('Hey, *Hello world<30>*'); // Renders 'Hello world' with font size 30
Expand Down
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
15 changes: 4 additions & 11 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
PODS:
- Flutter (1.0.0)
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- url_launcher_ios (0.0.1):
- Flutter

DEPENDENCIES:
- Flutter (from `Flutter`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)

EXTERNAL SOURCES:
Flutter:
:path: Flutter
path_provider_foundation:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios"

SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
path_provider_foundation: c68054786f1b4f3343858c1e1d0caaded73f0be9
url_launcher_ios: bf5ce03e0e2088bad9cc378ea97fa0ed5b49673b
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe

PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011

COCOAPODS: 1.11.3
COCOAPODS: 1.15.2
15 changes: 7 additions & 8 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
B6F4CE0C58C796581DF0844C /* Pods-Runner.release.xcconfig */,
F3947AF51B8B596DF7892175 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -156,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -343,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -359,7 +358,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = FV94K6TFFS;
DEVELOPMENT_TEAM = 8D5Y6FBA43;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -421,7 +420,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -470,7 +469,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -488,7 +487,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = FV94K6TFFS;
DEVELOPMENT_TEAM = 8D5Y6FBA43;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -511,7 +510,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = FV94K6TFFS;
DEVELOPMENT_TEAM = 8D5Y6FBA43;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down Expand Up @@ -48,6 +48,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
79 changes: 46 additions & 33 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/gestures.dart' show TapGestureRecognizer;
import 'package:flutter/material.dart';
import 'package:typeset/typeset.dart';

Expand Down Expand Up @@ -31,26 +32,26 @@ class TypeSetExample extends StatelessWidget {
),
body: Center(
child: ListView(
children: const [
children: [
Padding(
padding: EdgeInsets.symmetric(
padding: const EdgeInsets.symmetric(
horizontal: 22,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Divider(),
Text(
const Divider(),
const Text(
'Usage',
style: TextStyle(
fontSize: 20,
),
),
Divider(),
SizedBox(
const Divider(),
const SizedBox(
height: 12,
),
Text(
const Text(
'''
Bold
→ Hello, *World!*
Expand All @@ -75,96 +76,108 @@ Link
),
),

Divider(),
Text(
const Divider(),
const Text(
'Samples',
style: TextStyle(
fontSize: 20,
),
),
Divider(),
const Divider(),

SizedBox(
const SizedBox(
height: 12,
),
TypeSet(
'→ *TypeSet* _can_ #style# ~everything~ `you need` §with|https://rohanjsh.dev/§ _dynamic<18>_ _font<28>_ _size<25>_',
style: TextStyle(
style: const TextStyle(
fontSize: 18,
),
),
SizedBox(
linkRecognizerBuilder: (linkText, url) {
return TapGestureRecognizer()
..onTap = () {
debugPrint('URL: $url and Text: $linkText');
};
},
),
const SizedBox(
height: 24,
),
Divider(),
Text(
const Divider(),
const Text(
'Supported Stylings',
style: TextStyle(
fontSize: 20,
),
),
Divider(),
const Divider(),

SizedBox(
const SizedBox(
height: 12,
),
TypeSet(
'Bold:\n→ *Bold Text*',
const TypeSet(
'Bold:\n→ Hello<20> world',
style: TextStyle(
fontSize: 24,
),
),
SizedBox(
const SizedBox(
height: 20,
),
TypeSet(
const TypeSet(
'Italic:\n→ _Italic Text_ ',
style: TextStyle(
fontSize: 24,
),
),
SizedBox(
const SizedBox(
height: 20,
),
TypeSet(
const TypeSet(
'Underline:\n→ #Underline Text#',
style: TextStyle(
fontSize: 24,
),
),
SizedBox(
const SizedBox(
height: 20,
),
TypeSet(
const TypeSet(
'Strikethrough:\n→ ~Strikethrough Text~',
style: TextStyle(
fontSize: 24,
),
),
SizedBox(
const SizedBox(
height: 20,
),
TypeSet(
const TypeSet(
'Monospace:\n→ `monospace text`',
style: TextStyle(
fontSize: 24,
),
),
SizedBox(
const SizedBox(
height: 20,
),

//customized link textstyle and recognizer (tap recognizer)
TypeSet(
'Link:\n→ §google.com|https://google.com§',
style: TextStyle(
style: const TextStyle(
fontSize: 24,
),
),
SizedBox(
linkRecognizerBuilder: (linkText, url) {
return TapGestureRecognizer()
..onTap = () {
debugPrint('URL: $url and Text: $linkText');
};
},
),
const SizedBox(
height: 20,
),
Divider(),
const Divider(),
],
),
)
Expand Down
6 changes: 3 additions & 3 deletions lib/src/core/typeset_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ import 'package:typeset/src/models/style_type_value_model.dart';
/// 9. Return the `list` of `TypeValueModel` objects.
///
/// Outputs:
/// - `list` (List<TypeValueModel>): A list of `TypeValueModel` objects
/// representing the manipulated string. Each object contains a style type
/// and the corresponding text segment.
/// - `list` : A list of `StyleTypeValueModel`
/// objects representing the manipulated string.
/// Each object contains a style type and the corresponding text segment.
class TypesetController {
/// The constructor for the TypesetController class.
TypesetController({
Expand Down
Loading