mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-23 18:58:29 +03:00
store lastUsedColor as int
This commit is contained in:
parent
2c4ac862fa
commit
d56166b6ca
@ -54,22 +54,6 @@ extension on Application {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
extension on String? {
|
|
||||||
Color? asColor() {
|
|
||||||
final hexValue = this;
|
|
||||||
if (hexValue == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final intValue = int.tryParse(hexValue, radix: 16);
|
|
||||||
if (intValue == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Color(intValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Application> Function(Ref) implementedApps(List<Application> apps) =>
|
List<Application> Function(Ref) implementedApps(List<Application> apps) =>
|
||||||
(ref) {
|
(ref) {
|
||||||
final hasFeature = ref.watch(featureProvider);
|
final hasFeature = ref.watch(featureProvider);
|
||||||
@ -198,9 +182,9 @@ class ThemeNotifier extends Notifier<ThemeData> {
|
|||||||
primaryColor = customization?.color ?? color;
|
primaryColor = customization?.color ?? color;
|
||||||
if (primaryColor != null) {
|
if (primaryColor != null) {
|
||||||
// remember the last used color
|
// remember the last used color
|
||||||
prefs.setString(
|
prefs.setInt(
|
||||||
prefLastUsedColor,
|
prefLastUsedColor,
|
||||||
primaryColor.value.toRadixString(16),
|
primaryColor.value,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// the current color is null -> remove the last used color preference
|
// the current color is null -> remove the last used color preference
|
||||||
@ -209,8 +193,10 @@ class ThemeNotifier extends Notifier<ThemeData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
primaryColor ??= prefs.getString(prefLastUsedColor).asColor();
|
final lastUsedColor = prefs.getInt(prefLastUsedColor);
|
||||||
primaryColor ??= ref.read(primaryColorProvider);
|
primaryColor ??= lastUsedColor != null
|
||||||
|
? Color(lastUsedColor)
|
||||||
|
: ref.read(primaryColorProvider);
|
||||||
|
|
||||||
return (primaryColor != null)
|
return (primaryColor != null)
|
||||||
? _getDefault(themeMode).copyWith(
|
? _getDefault(themeMode).copyWith(
|
||||||
|
Loading…
Reference in New Issue
Block a user