fixed dark mode issue
This commit is contained in:
parent
7ac8c55b17
commit
d3cd22ec7c
@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:refilc/models/settings.dart';
|
||||||
|
|
||||||
class ColorsUtils {
|
class ColorsUtils {
|
||||||
Color darken(Color color, {double amount = .1}) {
|
Color darken(Color color, {double amount = .1}) {
|
||||||
@ -19,4 +21,21 @@ class ColorsUtils {
|
|||||||
|
|
||||||
return hslLight.toColor();
|
return hslLight.toColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Color fade(BuildContext context, Color color,
|
||||||
|
{double darkenAmount = .1, double lightenAmount = .1}) {
|
||||||
|
ThemeMode themeMode =
|
||||||
|
Provider.of<SettingsProvider>(context, listen: false).theme;
|
||||||
|
if (themeMode == ThemeMode.system) {
|
||||||
|
if (MediaQuery.of(context).platformBrightness == Brightness.dark) {
|
||||||
|
return lighten(color, amount: lightenAmount);
|
||||||
|
} else {
|
||||||
|
return darken(color, amount: darkenAmount);
|
||||||
|
}
|
||||||
|
} else if (themeMode == ThemeMode.dark) {
|
||||||
|
return lighten(color, amount: lightenAmount);
|
||||||
|
} else {
|
||||||
|
return darken(color, amount: darkenAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -507,9 +507,11 @@ class AbsencesPageState extends State<AbsencesPage>
|
|||||||
fontSize: 16.0,
|
fontSize: 16.0,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
height: 1.1,
|
height: 1.1,
|
||||||
color: ColorsUtils().darken(
|
color: ColorsUtils().fade(
|
||||||
|
context,
|
||||||
AppColors.of(context).green,
|
AppColors.of(context).green,
|
||||||
amount: 0.5,
|
darkenAmount: 0.5,
|
||||||
|
lightenAmount: 0.4,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -536,9 +538,11 @@ class AbsencesPageState extends State<AbsencesPage>
|
|||||||
fontSize: 16.0,
|
fontSize: 16.0,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
height: 1.1,
|
height: 1.1,
|
||||||
color: ColorsUtils().darken(
|
color: ColorsUtils().fade(
|
||||||
|
context,
|
||||||
AppColors.of(context).red,
|
AppColors.of(context).red,
|
||||||
amount: 0.4,
|
darkenAmount: 0.4,
|
||||||
|
lightenAmount: 0.2,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user