mirror of
https://github.com/git-touch/git-touch
synced 2024-12-17 02:38:39 +01:00
fix: label color
This commit is contained in:
parent
68dacabfbd
commit
eb9de95efc
@ -133,7 +133,7 @@ class IssuesScreen extends StatelessWidget {
|
||||
label['name'],
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: PrimerColors.gray900, // FIXME:
|
||||
color: getFontColorByBrightness(color),
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
|
@ -28,6 +28,14 @@ Color convertColor(String cssHex) {
|
||||
return Color(int.parse('ff' + cssHex, radix: 16));
|
||||
}
|
||||
|
||||
Color getFontColorByBrightness(Color color) {
|
||||
var grayscale = color.red * 0.3 + color.green * 0.59 + color.blue * 0.11;
|
||||
// print('color: $color, $grayscale');
|
||||
|
||||
var showWhite = grayscale < 128;
|
||||
return showWhite ? Colors.white : Colors.black;
|
||||
}
|
||||
|
||||
void nextTick(Function callback, [int milliseconds = 0]) {
|
||||
// FIXME:
|
||||
Future.delayed(Duration(milliseconds: 0)).then((_) {
|
||||
|
@ -61,19 +61,13 @@ class TimelineItem extends StatelessWidget {
|
||||
}
|
||||
|
||||
TextSpan _buildLabel(item) {
|
||||
// FIXME:
|
||||
var color = convertColor(item['label']['color']);
|
||||
var grayscale = color.red * 0.3 + color.green * 0.59 + color.blue * 0.11;
|
||||
// print('color: $color, $grayscale');
|
||||
|
||||
var showWhite = grayscale < 128;
|
||||
var textColor = showWhite ? Colors.white : Colors.black;
|
||||
|
||||
return TextSpan(
|
||||
text: item['label']['name'],
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
// https://github.com/flutter/flutter/issues/20430
|
||||
background: Paint()..color = color,
|
||||
color: getFontColorByBrightness(color),
|
||||
backgroundColor: color,
|
||||
// https://stackoverflow.com/a/52592679
|
||||
// ..strokeWidth = 16.5
|
||||
// ..style = PaintingStyle.stroke
|
||||
|
Loading…
Reference in New Issue
Block a user