Added Talk chat hyperlink recognition and open browser on tap

This commit is contained in:
Elias Müller 2023-02-25 14:30:39 +01:00
parent 08a2d95882
commit 0a62207e4a
4 changed files with 59 additions and 1 deletions

View File

@ -240,6 +240,13 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="dio">
<value>
<list>
<option value="$USER_HOME$/.pub-cache/hosted/pub.dev/dio-4.0.6/lib" />
</list>
</value>
</entry>
<entry key="fake_async"> <entry key="fake_async">
<value> <value>
<list> <list>
@ -268,6 +275,13 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="flowder">
<value>
<list>
<option value="$USER_HOME$/.pub-cache/hosted/pub.dev/flowder-0.2.0/lib" />
</list>
</value>
</entry>
<entry key="flutter"> <entry key="flutter">
<value> <value>
<list> <list>
@ -296,6 +310,13 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="flutter_linkify">
<value>
<list>
<option value="$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_linkify-5.0.2/lib" />
</list>
</value>
</entry>
<entry key="flutter_lints"> <entry key="flutter_lints">
<value> <value>
<list> <list>
@ -436,6 +457,13 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="linkify">
<value>
<list>
<option value="$USER_HOME$/.pub-cache/hosted/pub.dev/linkify-4.1.0/lib" />
</list>
</value>
</entry>
<entry key="lints"> <entry key="lints">
<value> <value>
<list> <list>
@ -506,6 +534,13 @@
</list> </list>
</value> </value>
</entry> </entry>
<entry key="open_file">
<value>
<list>
<option value="$USER_HOME$/.pub-cache/hosted/pub.dev/open_file-2.1.1/lib" />
</list>
</value>
</entry>
<entry key="package_config"> <entry key="package_config">
<value> <value>
<list> <list>
@ -999,13 +1034,16 @@
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/csslib-0.17.2/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/csslib-0.17.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/cupertino_icons-1.0.5/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/cupertino_icons-1.0.5/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/dart_style-2.2.4/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/dart_style-2.2.4/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/dio-4.0.6/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/fake_async-1.3.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/fake_async-1.3.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/ffi-2.0.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/ffi-2.0.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/file-6.1.4/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/file-6.1.4/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/fixnum-1.1.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/fixnum-1.1.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flowder-0.2.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_blurhash-0.7.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_blurhash-0.7.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_cache_manager-3.3.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_cache_manager-3.3.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_launcher_icons-0.11.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_launcher_icons-0.11.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_linkify-5.0.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_lints-2.0.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_lints-2.0.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_login-4.1.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_login-4.1.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_native_splash-2.2.16/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/flutter_native_splash-2.2.16/lib" />
@ -1024,6 +1062,7 @@
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/js-0.6.5/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/js-0.6.5/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/json_annotation-4.8.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/json_annotation-4.8.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/json_serializable-6.6.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/json_serializable-6.6.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/linkify-4.1.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/lints-2.0.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/lints-2.0.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/localstore-1.3.4/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/localstore-1.3.4/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/logging-1.1.1/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/logging-1.1.1/lib" />
@ -1033,6 +1072,7 @@
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/mime-1.0.4/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/mime-1.0.4/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/nested-1.0.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/nested-1.0.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/octo_image-1.0.2/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/octo_image-1.0.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/open_file-2.1.1/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/package_config-2.1.0/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/package_config-2.1.0/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path-1.8.2/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path-1.8.2/lib" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider-2.0.13/lib" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider-2.0.13/lib" />

View File

@ -21,6 +21,7 @@
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider-2.0.13" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider-2.0.13" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.4" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.4" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/sqflite-2.2.4+1" /> <root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/sqflite-2.2.4+1" />
<root url="file://$USER_HOME$/.pub-cache/hosted/pub.dev/open_file-2.1.1" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />

View File

@ -2,8 +2,10 @@ import 'dart:convert';
import 'package:cached_network_image/cached_network_image.dart'; import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:marianum_mobile/api/marianumcloud/talk/chat/richObjectStringProcessor.dart'; import 'package:marianum_mobile/api/marianumcloud/talk/chat/richObjectStringProcessor.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher_string.dart';
import '../../../api/marianumcloud/talk/chat/getChatResponse.dart'; import '../../../api/marianumcloud/talk/chat/getChatResponse.dart';
@ -29,7 +31,10 @@ class ChatMessage {
SharedPreferences preferences = await SharedPreferences.getInstance(); SharedPreferences preferences = await SharedPreferences.getInstance();
if(file == null) { if(file == null) {
return SelectableText(content); return SelectableLinkify(
text: content,
onOpen: onOpen,
);
} }
return CachedNetworkImage( return CachedNetworkImage(
@ -47,4 +52,12 @@ class ChatMessage {
}, },
); );
} }
void onOpen(LinkableElement link) async {
if(await canLaunchUrlString(link.url)) {
await launchUrlString(link.url);
} else {
}
}
} }

View File

@ -54,6 +54,10 @@ dependencies:
flutter_launcher_icons: ^0.11.0 flutter_launcher_icons: ^0.11.0
pretty_json: ^2.0.0 pretty_json: ^2.0.0
cached_network_image: ^3.2.3 cached_network_image: ^3.2.3
open_file: ^2.1.1
flowder: ^0.2.0
url_launcher: ^6.1.10
flutter_linkify: ^5.0.2
dependency_overrides: dependency_overrides:
xml: ^6.2.2 xml: ^6.2.2