mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-05-11 02:16:00 +02:00
tooltip for https://github.com/rustdesk/rustdesk/issues/8600, and change
dialog error to richtext with link support
This commit is contained in:
parent
8ced4ddaa2
commit
cba8aaa410
2 changed files with 45 additions and 3 deletions
|
@ -1057,6 +1057,49 @@ class CustomAlertDialog extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
Widget createDialogContent(String text) {
|
||||
final RegExp linkRegExp = RegExp(r'(https?://[^\s]+)');
|
||||
final List<TextSpan> spans = [];
|
||||
int start = 0;
|
||||
bool hasLink = false;
|
||||
|
||||
linkRegExp.allMatches(text).forEach((match) {
|
||||
hasLink = true;
|
||||
if (match.start > start) {
|
||||
spans.add(TextSpan(text: text.substring(start, match.start)));
|
||||
}
|
||||
spans.add(TextSpan(
|
||||
text: match.group(0) ?? '',
|
||||
style: TextStyle(
|
||||
color: Colors.blue,
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
recognizer: TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
String linkText = match.group(0) ?? '';
|
||||
linkText = linkText.replaceAll(RegExp(r'[.,;!?]+$'), '');
|
||||
launchUrl(Uri.parse(linkText));
|
||||
},
|
||||
));
|
||||
start = match.end;
|
||||
});
|
||||
|
||||
if (start < text.length) {
|
||||
spans.add(TextSpan(text: text.substring(start)));
|
||||
}
|
||||
|
||||
if (!hasLink) {
|
||||
return SelectableText(text, style: const TextStyle(fontSize: 15));
|
||||
}
|
||||
|
||||
return SelectableText.rich(
|
||||
TextSpan(
|
||||
style: TextStyle(color: Colors.black, fontSize: 15),
|
||||
children: spans,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void msgBox(SessionID sessionId, String type, String title, String text,
|
||||
String link, OverlayDialogManager dialogManager,
|
||||
{bool? hasCancel, ReconnectHandle? reconnect, int? reconnectTimeout}) {
|
||||
|
@ -1214,8 +1257,7 @@ Widget msgboxContent(String type, String title, String text) {
|
|||
translate(title),
|
||||
style: TextStyle(fontSize: 21),
|
||||
).marginOnly(bottom: 10),
|
||||
SelectableText(translateText(text),
|
||||
style: const TextStyle(fontSize: 15)),
|
||||
createDialogContent(translateText(text)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue