fixed countdown wrap, css rgba colors, stale create-link gate and wired up reply drafts in talk
This commit is contained in:
@@ -142,7 +142,7 @@ class _PmRichTextState extends State<PmRichText> {
|
||||
}
|
||||
|
||||
Color _highlightColor(dynamic color, ThemeData theme) {
|
||||
final parsed = color is String ? _parseCssColor(color) : null;
|
||||
final parsed = color is String ? parseCssColor(color) : null;
|
||||
final base = parsed ?? theme.colorScheme.tertiaryContainer;
|
||||
// Full-opacity highlights swamp the text in dark mode, so dial the alpha
|
||||
// down further there while keeping the accent readable in light mode.
|
||||
@@ -178,19 +178,22 @@ class _PmRichTextState extends State<PmRichText> {
|
||||
|
||||
/// Parses a CSS `#rgb`/`#rrggbb`/`#rrggbbaa` hex or a small set of named colors.
|
||||
/// Returns `null` for anything unrecognised so the caller can fall back.
|
||||
Color? _parseCssColor(String raw) {
|
||||
@visibleForTesting
|
||||
Color? parseCssColor(String raw) {
|
||||
final value = raw.trim().toLowerCase();
|
||||
if (value.startsWith('#')) {
|
||||
var hex = value.substring(1);
|
||||
if (hex.length == 3) {
|
||||
hex = hex.split('').map((c) => '$c$c').join();
|
||||
}
|
||||
if (hex.length == 6) hex = 'ff$hex';
|
||||
if (hex.length == 8) {
|
||||
final rgba = int.tryParse(hex, radix: 16);
|
||||
if (rgba != null) return Color(rgba);
|
||||
}
|
||||
return null;
|
||||
// CSS puts alpha last, Flutter's Color expects it first.
|
||||
final argb = switch (hex.length) {
|
||||
6 => 'ff$hex',
|
||||
8 => hex.substring(6) + hex.substring(0, 6),
|
||||
_ => null,
|
||||
};
|
||||
final parsed = argb == null ? null : int.tryParse(argb, radix: 16);
|
||||
return parsed == null ? null : Color(parsed);
|
||||
}
|
||||
return _namedColors[value];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user