feat: tweak dark mode contribution color
This commit is contained in:
parent
08511fb8fb
commit
6036849e9b
|
@ -122,18 +122,7 @@ class GhUserScreen extends StatelessWidget {
|
||||||
[
|
[
|
||||||
// https://github.com/git-touch/git-touch/issues/122
|
// https://github.com/git-touch/git-touch/issues/122
|
||||||
for (final day in week.contributionDays)
|
for (final day in week.contributionDays)
|
||||||
if (day.color.startsWith('#'))
|
ContributionDay(hexColor: day.color)
|
||||||
ContributionDay(hexColor: day.color)
|
|
||||||
else if (day.color.contains('L1'))
|
|
||||||
ContributionDay(hexColor: contributionColors[0])
|
|
||||||
else if (day.color.contains('L2'))
|
|
||||||
ContributionDay(hexColor: contributionColors[1])
|
|
||||||
else if (day.color.contains('L3'))
|
|
||||||
ContributionDay(hexColor: contributionColors[2])
|
|
||||||
else if (day.color.contains('L4'))
|
|
||||||
ContributionDay(hexColor: contributionColors[3])
|
|
||||||
else
|
|
||||||
ContributionDay(hexColor: contributionEmptyColor)
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -8,12 +8,19 @@ import 'package:provider/provider.dart';
|
||||||
const contributionEmptyColor = '#ebedf0';
|
const contributionEmptyColor = '#ebedf0';
|
||||||
const contributionColors = ['#9be9a8', '#40c463', '#30a14e', '#216e39'];
|
const contributionColors = ['#9be9a8', '#40c463', '#30a14e', '#216e39'];
|
||||||
|
|
||||||
|
const darkMapper = {
|
||||||
|
'#ebedf0': '#161b22',
|
||||||
|
'#9be9a8': '#01311f',
|
||||||
|
'#40c463': '#034525',
|
||||||
|
'#30a14e': '#0f6d31',
|
||||||
|
'#216e39': '#00c647'
|
||||||
|
};
|
||||||
|
|
||||||
class ContributionDay {
|
class ContributionDay {
|
||||||
String hexColor;
|
String hexColor;
|
||||||
int count;
|
int count;
|
||||||
Color color;
|
ContributionDay({this.hexColor, this.count})
|
||||||
ContributionDay({this.hexColor, this.count, this.color})
|
: assert(hexColor != null || count != null);
|
||||||
: assert(hexColor != null || count != null || color != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContributionWidget extends StatelessWidget {
|
class ContributionWidget extends StatelessWidget {
|
||||||
|
@ -33,22 +40,15 @@ class ContributionWidget extends StatelessWidget {
|
||||||
if (day.count == 0) {
|
if (day.count == 0) {
|
||||||
day.hexColor = contributionEmptyColor;
|
day.hexColor = contributionEmptyColor;
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: algorithm
|
||||||
final level = (day.count * 4) ~/ (maxCount + 1);
|
final level = (day.count * 4) ~/ (maxCount + 1);
|
||||||
day.hexColor = contributionColors[level];
|
day.hexColor = contributionColors[level];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (day.hexColor != null) {
|
|
||||||
day.color = convertColor(day.hexColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color _revert(Color color) {
|
|
||||||
return Color.fromRGBO(
|
|
||||||
0xff - color.red, 0xff - color.green, 0xff - color.blue, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = context.watch<ThemeModel>();
|
final theme = context.watch<ThemeModel>();
|
||||||
|
@ -72,9 +72,12 @@ class ContributionWidget extends StatelessWidget {
|
||||||
height: 10,
|
height: 10,
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: theme.brightness == Brightness.dark
|
color: convertColor(
|
||||||
? _revert(day.color)
|
theme.brightness == Brightness.dark
|
||||||
: day.color),
|
? darkMapper[day.hexColor]
|
||||||
|
: day.hexColor,
|
||||||
|
),
|
||||||
|
borderRadius: BorderRadius.circular(2)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
|
@ -31,6 +31,7 @@ dependencies:
|
||||||
http: ^0.12.0
|
http: ^0.12.0
|
||||||
in_app_review: ^1.0.4
|
in_app_review: ^1.0.4
|
||||||
intl: ^0.16.0
|
intl: ^0.16.0
|
||||||
|
json_annotation: ^3.1.1
|
||||||
launch_review: ^2.0.0
|
launch_review: ^2.0.0
|
||||||
nanoid: ^0.1.0
|
nanoid: ^0.1.0
|
||||||
package_info: ^0.4.0
|
package_info: ^0.4.0
|
||||||
|
@ -50,7 +51,7 @@ dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
build_runner: ^1.10.3
|
build_runner: ^1.10.3
|
||||||
json_serializable: ^3.5.0
|
json_serializable: ^3.5.1
|
||||||
|
|
||||||
# dependencies_overrides:
|
# dependencies_overrides:
|
||||||
# flutter_highlight:
|
# flutter_highlight:
|
||||||
|
|
Loading…
Reference in New Issue