Fix dialog text color for dark theme with links

Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-31 18:43:22 +00:00
parent 57a77f01fe
commit bace6b918f

View File

@@ -1124,19 +1124,31 @@ class CustomAlertDialog extends StatelessWidget {
Widget createDialogContent(String text) {
final RegExp linkRegExp = RegExp(r'(https?://[^\s]+)');
bool hasLink = linkRegExp.hasMatch(text);
if (!hasLink) {
return SelectableText(text, style: const TextStyle(fontSize: 15));
}
return Builder(
builder: (context) {
final List<TextSpan> spans = [];
int start = 0;
bool hasLink = false;
// Get theme-aware colors
final textColor = Theme.of(context).textTheme.bodyMedium?.color;
final linkColor = Theme.of(context).brightness == Brightness.dark
? Colors.lightBlue
: Colors.blue;
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,
color: linkColor,
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
@@ -1153,16 +1165,17 @@ Widget createDialogContent(String text) {
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),
style: TextStyle(
color: textColor,
fontSize: 15,
),
children: spans,
),
);
},
);
}
void msgBox(SessionID sessionId, String type, String title, String text,