update default themes

This commit is contained in:
Julian 2025-03-17 17:14:05 -06:00
parent 8e703f128c
commit 564c3ba715
3 changed files with 35 additions and 28 deletions
asset_sources/default_themes/stack_wallet
lib/themes

View file

@ -31,9 +31,7 @@ final pThemeService = Provider<ThemeService>((ref) {
});
class ThemeService {
// dumb quick conditional based on name. Should really be done better
static const _currentDefaultThemeVersion =
AppConfig.appName == "Campfire" ? 17 : 16;
static const _currentDefaultThemeVersion = 17;
ThemeService._();
static ThemeService? _instance;
static ThemeService get instance => _instance ??= ThemeService._();
@ -61,9 +59,7 @@ class ThemeService {
final jsonString = utf8.decode(themeJsonFiles.first.content as List<int>);
final json = jsonDecode(jsonString) as Map;
final theme = StackTheme.fromJson(
json: Map<String, dynamic>.from(json),
);
final theme = StackTheme.fromJson(json: Map<String, dynamic>.from(json));
try {
theme.assets;
@ -96,11 +92,12 @@ class ThemeService {
Future<void> remove({required String themeId}) async {
final themesDir = StackFileSystem.themesDir!;
final isarId = await db.isar.stackThemes
.where()
.themeIdEqualTo(themeId)
.idProperty()
.findFirst();
final isarId =
await db.isar.stackThemes
.where()
.themeIdEqualTo(themeId)
.idProperty()
.findFirst();
if (isarId != null) {
await db.isar.writeTxn(() async {
await db.isar.stackThemes.delete(isarId);
@ -184,22 +181,27 @@ class ThemeService {
try {
final response = await client.get(
url: Uri.parse("$baseServerUrl/themes"),
proxyInfo: Prefs.instance.useTor
? TorService.sharedInstance.getProxyInfo()
: null,
proxyInfo:
Prefs.instance.useTor
? TorService.sharedInstance.getProxyInfo()
: null,
);
final jsonList = jsonDecode(response.body) as List;
final result = List<Map<String, dynamic>>.from(jsonList)
.map((e) => StackThemeMetaData.fromMap(e))
.where((e) => e.id != "light" && e.id != "dark")
.toList();
final result =
List<Map<String, dynamic>>.from(jsonList)
.map((e) => StackThemeMetaData.fromMap(e))
.where((e) => e.id != "light" && e.id != "dark")
.toList();
return result;
} catch (e, s) {
Logging.instance
.w("Failed to fetch themes list: ", error: e, stackTrace: s);
Logging.instance.w(
"Failed to fetch themes list: ",
error: e,
stackTrace: s,
);
rethrow;
}
}
@ -210,9 +212,10 @@ class ThemeService {
try {
final response = await client.get(
url: Uri.parse("$baseServerUrl/theme/${themeMetaData.id}"),
proxyInfo: Prefs.instance.useTor
? TorService.sharedInstance.getProxyInfo()
: null,
proxyInfo:
Prefs.instance.useTor
? TorService.sharedInstance.getProxyInfo()
: null,
);
final bytes = Uint8List.fromList(response.bodyBytes);
@ -228,8 +231,11 @@ class ThemeService {
);
}
} catch (e, s) {
Logging.instance
.w("Failed to fetch themes list: ", error: e, stackTrace: s);
Logging.instance.w(
"Failed to fetch themes list: ",
error: e,
stackTrace: s,
);
rethrow;
}
}
@ -270,9 +276,10 @@ class StackThemeMetaData {
);
} catch (e, s) {
Logging.instance.f(
"Failed to create instance of StackThemeMetaData using $map",
error: e,
stackTrace: s);
"Failed to create instance of StackThemeMetaData using $map",
error: e,
stackTrace: s,
);
rethrow;
}
}