Added Talk chat hyperlink recognition and open browser on tap
This commit is contained in:
@ -2,8 +2,10 @@ import 'dart:convert';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.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:shared_preferences/shared_preferences.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import '../../../api/marianumcloud/talk/chat/getChatResponse.dart';
|
||||
|
||||
@ -29,7 +31,10 @@ class ChatMessage {
|
||||
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||
|
||||
if(file == null) {
|
||||
return SelectableText(content);
|
||||
return SelectableLinkify(
|
||||
text: content,
|
||||
onOpen: onOpen,
|
||||
);
|
||||
}
|
||||
|
||||
return CachedNetworkImage(
|
||||
@ -47,4 +52,12 @@ class ChatMessage {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void onOpen(LinkableElement link) async {
|
||||
if(await canLaunchUrlString(link.url)) {
|
||||
await launchUrlString(link.url);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user