fix: hex color parse

This commit is contained in:
Rongjian Zhang
2022-10-01 02:54:09 +08:00
parent a30385a414
commit d5f3bd9f24
6 changed files with 17 additions and 19 deletions

View File

@@ -3,7 +3,6 @@ import 'package:flutter/widgets.dart';
import 'package:from_css_color/from_css_color.dart';
class HexColorTag extends StatelessWidget {
const HexColorTag({
super.key,
required this.name,
@@ -14,10 +13,20 @@ class HexColorTag extends StatelessWidget {
@override
Widget build(BuildContext context) {
final c = fromCssColor('#$color');
final theme = AntTheme.of(context);
return AntTag(
round: true,
color: fromCssColor(color),
child: Text(name),
color: c,
child: Text(
name,
style: TextStyle(
color: c.computeLuminance() > 0.5
? theme.colorText
: theme.colorBackground,
),
),
);
}
}

View File

@@ -205,8 +205,7 @@ class TimelineItem extends StatelessWidget {
textSpan: TextSpan(children: [
TextSpan(text: ' ${AppLocalizations.of(context)!.added} '),
WidgetSpan(
child: HexColorTag(
name: p.label.name, color: '#${p.label.color}')),
child: HexColorTag(name: p.label.name, color: p.label.color)),
TextSpan(text: ' ${AppLocalizations.of(context)!.label}'),
]),
);
@@ -218,8 +217,7 @@ class TimelineItem extends StatelessWidget {
textSpan: TextSpan(children: [
TextSpan(text: ' ${AppLocalizations.of(context)!.removed} '),
WidgetSpan(
child: HexColorTag(
name: p.label.name, color: '#${p.label.color}')),
child: HexColorTag(name: p.label.name, color: p.label.color)),
TextSpan(text: ' ${AppLocalizations.of(context)!.label}'),
]),
);