diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index ea0c27cd..f23b672b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,15 @@ + + + + + + + + + = 2.7.5) + - url_launcher_ios (0.0.1): + - Flutter - webview_flutter_wkwebview (0.0.1): - Flutter @@ -35,6 +37,7 @@ DEPENDENCIES: - sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`) - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`) + - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) SPEC REPOS: @@ -59,6 +62,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/shared_preferences_ios/ios" sqflite: :path: ".symlinks/plugins/sqflite/ios" + url_launcher_ios: + :path: ".symlinks/plugins/url_launcher_ios/ios" webview_flutter_wkwebview: :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" @@ -73,6 +78,7 @@ SPEC CHECKSUMS: sentry_flutter: 4cd99764f9fe01c9415790d1f3fb1c7fd3a5cbe9 shared_preferences_ios: aef470a42dc4675a1cdd50e3158b42e3d1232b32 sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 + url_launcher_ios: 02f1989d4e14e998335b02b67a7590fa34f971af webview_flutter_wkwebview: 005fbd90c888a42c5690919a1527ecc6649e1162 PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 68321b36..19d1d9ae 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -549,4 +549,4 @@ /* End XCConfigurationList section */ }; rootObject = 97C146E61CF9000F007C117D /* Project object */; -} \ No newline at end of file +} diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index d87861d4..a0627fa0 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -22,6 +22,11 @@ ???? CFBundleVersion $(FLUTTER_BUILD_NUMBER) + LSApplicationQueriesSchemes + + https + http + LSRequiresIPhoneOS UILaunchStoryboardName diff --git a/lib/models/irc_message.dart b/lib/models/irc_message.dart index db4d0476..1a8ae926 100644 --- a/lib/models/irc_message.dart +++ b/lib/models/irc_message.dart @@ -1,10 +1,12 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:collection/collection.dart'; +import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:frosty/models/badges.dart'; import 'package:frosty/models/emotes.dart'; import 'package:intl/intl.dart'; +import 'package:url_launcher/url_launcher.dart'; /// The object representation of a Twitch IRC message. class IRCMessage { @@ -407,6 +409,18 @@ class IRCMessage { TextSpan _createTextSpan({required String text, TextStyle? style}) { if (text.startsWith('@')) { return TextSpan(text: text, style: style?.copyWith(fontWeight: FontWeight.bold)); + } else if (RegExp(r'(?:(?:https?|ftp):\/\/)?[\w/\-?=%.]+\.[\w/\-?=%.]+').hasMatch(text)) { + // Regex above from https://stackoverflow.com/questions/59444837/flutter-dart-regex-to-extract-urls-from-a-string + final url = text.startsWith('http') ? text : 'https://' + text; + + return TextSpan( + text: text, + style: style?.copyWith(color: Colors.blue), + recognizer: TapGestureRecognizer() + ..onTap = () async { + if (await canLaunch(url)) launch(url); + }, + ); } else { return TextSpan(text: text, style: style); } diff --git a/pubspec.lock b/pubspec.lock index 3fc2275c..8cdedbeb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -882,6 +882,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.4" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.13" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.13" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.4" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" uuid: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4aa9bc4f..e7cb1c36 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,6 +49,7 @@ dependencies: sentry_flutter: ^6.2.2 tuple: ^2.0.0 flutter_svg: ^1.0.0 + url_launcher: ^6.0.17 dev_dependencies: flutter_test: