mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-12 09:27:01 +00:00
extra theme verification
This commit is contained in:
parent
59cf12149f
commit
e7ed01aad5
2 changed files with 36 additions and 3 deletions
|
@ -205,6 +205,27 @@ void main() async {
|
|||
// check and update or install default themes
|
||||
await ThemeService.instance.checkDefaultThemesOnStartup();
|
||||
|
||||
// verify current user preference theme and revert to default
|
||||
// if problems are found to prevent app being unusable
|
||||
if (!(await ThemeService.instance
|
||||
.verifyInstalled(themeId: Prefs.instance.themeId))) {
|
||||
Prefs.instance.themeId = "light";
|
||||
}
|
||||
|
||||
// verify current user preference light brightness theme and revert to default
|
||||
// if problems are found to prevent app being unusable
|
||||
if (!(await ThemeService.instance
|
||||
.verifyInstalled(themeId: Prefs.instance.systemBrightnessLightThemeId))) {
|
||||
Prefs.instance.systemBrightnessLightThemeId = "light";
|
||||
}
|
||||
|
||||
// verify current user preference dark brightness theme and revert to default
|
||||
// if problems are found to prevent app being unusable
|
||||
if (!(await ThemeService.instance
|
||||
.verifyInstalled(themeId: Prefs.instance.systemBrightnessDarkThemeId))) {
|
||||
Prefs.instance.systemBrightnessDarkThemeId = "dark";
|
||||
}
|
||||
|
||||
runApp(const ProviderScope(child: MyApp()));
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,12 @@ class ThemeService {
|
|||
applicationThemesDirectoryPath: themesDir.path,
|
||||
);
|
||||
|
||||
try {
|
||||
theme.assets;
|
||||
} catch (_) {
|
||||
throw Exception("Invalid theme: Failed to create assets object");
|
||||
}
|
||||
|
||||
final String assetsPath = "${themesDir.path}/${theme.themeId}";
|
||||
|
||||
for (final file in archive.files) {
|
||||
|
@ -167,9 +173,15 @@ class ThemeService {
|
|||
|
||||
// TODO more thorough check/verification of theme
|
||||
Future<bool> verifyInstalled({required String themeId}) async {
|
||||
final dbHasTheme =
|
||||
await db.isar.stackThemes.where().themeIdEqualTo(themeId).count() > 0;
|
||||
if (dbHasTheme) {
|
||||
final theme =
|
||||
await db.isar.stackThemes.where().themeIdEqualTo(themeId).findFirst();
|
||||
if (theme != null) {
|
||||
try {
|
||||
theme.assets;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final themesDir = await StackFileSystem.applicationThemesDirectory();
|
||||
final jsonFileExists =
|
||||
await File("${themesDir.path}/$themeId/theme.json").exists();
|
||||
|
|
Loading…
Reference in a new issue