mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-22 19:39:22 +00:00
modify default themes install/loading/checks. Should fix missing ada (or sol?) icon
This commit is contained in:
parent
2431d5f300
commit
537e44f1f8
1 changed files with 23 additions and 51 deletions
|
@ -33,7 +33,7 @@ final pThemeService = Provider<ThemeService>((ref) {
|
||||||
class ThemeService {
|
class ThemeService {
|
||||||
// dumb quick conditional based on name. Should really be done better
|
// dumb quick conditional based on name. Should really be done better
|
||||||
static const _currentDefaultThemeVersion =
|
static const _currentDefaultThemeVersion =
|
||||||
AppConfig.appName == "Campfire" ? 17 : 15;
|
AppConfig.appName == "Campfire" ? 17 : 16;
|
||||||
ThemeService._();
|
ThemeService._();
|
||||||
static ThemeService? _instance;
|
static ThemeService? _instance;
|
||||||
static ThemeService get instance => _instance ??= ThemeService._();
|
static ThemeService get instance => _instance ??= ThemeService._();
|
||||||
|
@ -120,69 +120,41 @@ class ThemeService {
|
||||||
Future<void> checkDefaultThemesOnStartup() async {
|
Future<void> checkDefaultThemesOnStartup() async {
|
||||||
// install default themes
|
// install default themes
|
||||||
if (!(await ThemeService.instance.verifyInstalled(themeId: "light"))) {
|
if (!(await ThemeService.instance.verifyInstalled(themeId: "light"))) {
|
||||||
Logging.instance.log(
|
await _updateDefaultTheme("light");
|
||||||
"Installing default light theme...",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
final lightZip = await rootBundle.load("assets/default_themes/light.zip");
|
|
||||||
await ThemeService.instance
|
|
||||||
.install(themeArchiveData: lightZip.buffer.asUint8List());
|
|
||||||
Logging.instance.log(
|
|
||||||
"Installing default light theme... finished",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// check installed version
|
// check installed version
|
||||||
final theme = ThemeService.instance.getTheme(themeId: "light");
|
final theme = ThemeService.instance.getTheme(themeId: "light");
|
||||||
if ((theme?.version ?? 1) < _currentDefaultThemeVersion) {
|
if ((theme?.version ?? 1) < _currentDefaultThemeVersion) {
|
||||||
Logging.instance.log(
|
await _updateDefaultTheme("light");
|
||||||
"Updating default light theme...",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
final lightZip =
|
|
||||||
await rootBundle.load("assets/default_themes/light.zip");
|
|
||||||
await ThemeService.instance
|
|
||||||
.install(themeArchiveData: lightZip.buffer.asUint8List());
|
|
||||||
Logging.instance.log(
|
|
||||||
"Updating default light theme... finished",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (AppConfig.hasFeature(AppFeature.themeSelection)) {
|
if (AppConfig.hasFeature(AppFeature.themeSelection)) {
|
||||||
if (!(await ThemeService.instance.verifyInstalled(themeId: "dark"))) {
|
if (!(await ThemeService.instance.verifyInstalled(themeId: "dark"))) {
|
||||||
Logging.instance.log(
|
await _updateDefaultTheme("dark");
|
||||||
"Installing default dark theme... ",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
final darkZip = await rootBundle.load("assets/default_themes/dark.zip");
|
|
||||||
await ThemeService.instance
|
|
||||||
.install(themeArchiveData: darkZip.buffer.asUint8List());
|
|
||||||
Logging.instance.log(
|
|
||||||
"Installing default dark theme... finished",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// check installed version
|
// check installed version
|
||||||
// final theme = ThemeService.instance.getTheme(themeId: "dark");
|
final theme = ThemeService.instance.getTheme(themeId: "dark");
|
||||||
// Force update theme to add missing icons for now
|
if ((theme?.version ?? 1) < _currentDefaultThemeVersion) {
|
||||||
// TODO: uncomment if statement in future when themes are version 4 or above
|
await _updateDefaultTheme("dark");
|
||||||
// if ((theme?.version ?? 1) < _currentDefaultThemeVersion) {
|
|
||||||
Logging.instance.log(
|
|
||||||
"Updating default dark theme...",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
final darkZip = await rootBundle.load("assets/default_themes/dark.zip");
|
|
||||||
await ThemeService.instance
|
|
||||||
.install(themeArchiveData: darkZip.buffer.asUint8List());
|
|
||||||
Logging.instance.log(
|
|
||||||
"Updating default dark theme... finished",
|
|
||||||
level: LogLevel.Info,
|
|
||||||
);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _updateDefaultTheme(String name) async {
|
||||||
|
Logging.instance.log(
|
||||||
|
"Updating default $name theme...",
|
||||||
|
level: LogLevel.Info,
|
||||||
|
);
|
||||||
|
final zip = await rootBundle.load("assets/default_themes/$name.zip");
|
||||||
|
await ThemeService.instance.install(
|
||||||
|
themeArchiveData: zip.buffer.asUint8List(),
|
||||||
|
);
|
||||||
|
Logging.instance.log(
|
||||||
|
"Updating default $name theme... finished",
|
||||||
|
level: LogLevel.Info,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO more thorough check/verification of theme
|
// TODO more thorough check/verification of theme
|
||||||
Future<bool> verifyInstalled({required String themeId}) async {
|
Future<bool> verifyInstalled({required String themeId}) async {
|
||||||
|
|
Loading…
Reference in a new issue