mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-22 04:13:18 +03:00
Fix non-link text color in dialogs with links for dark theme (#14220)
* Initial plan * Fix dialog text color for dark theme with links Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com> * Keep original link color (blue), only fix non-link text color Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com> * fix: dialog text color in dark theme Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com> Co-authored-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -1124,18 +1124,23 @@ class CustomAlertDialog extends StatelessWidget {
|
|||||||
|
|
||||||
Widget createDialogContent(String text) {
|
Widget createDialogContent(String text) {
|
||||||
final RegExp linkRegExp = RegExp(r'(https?://[^\s]+)');
|
final RegExp linkRegExp = RegExp(r'(https?://[^\s]+)');
|
||||||
|
bool hasLink = linkRegExp.hasMatch(text);
|
||||||
|
|
||||||
|
// Early return: no link, use default theme color
|
||||||
|
if (!hasLink) {
|
||||||
|
return SelectableText(text, style: const TextStyle(fontSize: 15));
|
||||||
|
}
|
||||||
|
|
||||||
final List<TextSpan> spans = [];
|
final List<TextSpan> spans = [];
|
||||||
int start = 0;
|
int start = 0;
|
||||||
bool hasLink = false;
|
|
||||||
|
|
||||||
linkRegExp.allMatches(text).forEach((match) {
|
linkRegExp.allMatches(text).forEach((match) {
|
||||||
hasLink = true;
|
|
||||||
if (match.start > start) {
|
if (match.start > start) {
|
||||||
spans.add(TextSpan(text: text.substring(start, match.start)));
|
spans.add(TextSpan(text: text.substring(start, match.start)));
|
||||||
}
|
}
|
||||||
spans.add(TextSpan(
|
spans.add(TextSpan(
|
||||||
text: match.group(0) ?? '',
|
text: match.group(0) ?? '',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.blue,
|
color: Colors.blue,
|
||||||
decoration: TextDecoration.underline,
|
decoration: TextDecoration.underline,
|
||||||
),
|
),
|
||||||
@@ -1153,13 +1158,9 @@ Widget createDialogContent(String text) {
|
|||||||
spans.add(TextSpan(text: text.substring(start)));
|
spans.add(TextSpan(text: text.substring(start)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasLink) {
|
|
||||||
return SelectableText(text, style: const TextStyle(fontSize: 15));
|
|
||||||
}
|
|
||||||
|
|
||||||
return SelectableText.rich(
|
return SelectableText.rich(
|
||||||
TextSpan(
|
TextSpan(
|
||||||
style: TextStyle(color: Colors.black, fontSize: 15),
|
style: const TextStyle(fontSize: 15),
|
||||||
children: spans,
|
children: spans,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user