use relative path for theme assets

This commit is contained in:
julian 2023-07-03 18:25:18 -06:00
parent fe8ad00b9b
commit 87ed25bd5b
37 changed files with 576 additions and 603 deletions

View file

@ -167,6 +167,8 @@ void main() async {
await Hive.openBox<dynamic>(DB.boxNamePrefs);
await Prefs.instance.init();
await StackFileSystem.initThemesDir();
// Desktop migrate handled elsewhere (currently desktop_login_view.dart)
if (!Util.isDesktop) {
int dbVersion = DB.instance.get<dynamic>(
@ -312,7 +314,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
}
ref.read(applicationThemesDirectoryPathProvider.notifier).state =
(await StackFileSystem.applicationThemesDirectory()).path;
StackFileSystem.themesDir!.path;
_notificationsService = ref.read(notificationsProvider);
_nodeService = ref.read(nodeServiceChangeNotifierProvider);
@ -407,7 +409,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
WidgetsBinding.instance.addPostFrameCallback((_) async {
//Add themes path to provider
ref.read(applicationThemesDirectoryPathProvider.notifier).state =
(await StackFileSystem.applicationThemesDirectory()).path;
StackFileSystem.themesDir!.path;
ref.read(themeProvider.state).state = ref.read(pThemeService).getTheme(
themeId: themeId,

View file

@ -17,6 +17,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/extensions/impl/box_shadow.dart';
import 'package:stackwallet/utilities/extensions/impl/gradient.dart';
import 'package:stackwallet/utilities/extensions/impl/string.dart';
import 'package:stackwallet/utilities/stack_file_system.dart';
part 'stack_theme.g.dart';
@ -1508,7 +1509,6 @@ class StackTheme {
factory StackTheme.fromJson({
required Map<String, dynamic> json,
required String applicationThemesDirectoryPath,
}) {
final version = json["version"] as int? ?? 1;
@ -1517,21 +1517,18 @@ class StackTheme {
..assetsV1 = version == 1
? ThemeAssets.fromJson(
json: Map<String, dynamic>.from(json["assets"] as Map),
applicationThemesDirectoryPath: applicationThemesDirectoryPath,
themeId: json["id"] as String,
)
: null
..assetsV2 = version == 2
? ThemeAssetsV2.fromJson(
json: Map<String, dynamic>.from(json["assets"] as Map),
applicationThemesDirectoryPath: applicationThemesDirectoryPath,
themeId: json["id"] as String,
)
: null
..assetsV3 = version >= 3
? ThemeAssetsV3.fromJson(
json: Map<String, dynamic>.from(json["assets"] as Map),
applicationThemesDirectoryPath: applicationThemesDirectoryPath,
themeId: json["id"] as String,
)
: null
@ -1954,117 +1951,81 @@ class ThemeAssets implements IThemeAssets {
factory ThemeAssets.fromJson({
required Map<String, dynamic> json,
required String applicationThemesDirectoryPath,
required String themeId,
}) {
return ThemeAssets()
..bellNew =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bell_new"] as String}"
..buy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["buy"] as String}"
..exchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["exchange"] as String}"
..bellNew = "$themeId/assets/${json["bell_new"] as String}"
..buy = "$themeId/assets/${json["buy"] as String}"
..exchange = "$themeId/assets/${json["exchange"] as String}"
..personaIncognito =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_easy"] as String}"
..stack =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack"] as String}"
..stackIcon =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack_icon"] as String}"
..receive =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive"] as String}"
..receivePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_pending"] as String}"
"$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy = "$themeId/assets/${json["persona_easy"] as String}"
..stack = "$themeId/assets/${json["stack"] as String}"
..stackIcon = "$themeId/assets/${json["stack_icon"] as String}"
..receive = "$themeId/assets/${json["receive"] as String}"
..receivePending = "$themeId/assets/${json["receive_pending"] as String}"
..receiveCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_cancelled"] as String}"
..send =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send"] as String}"
..sendPending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_pending"] as String}"
..sendCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_selector"] as String}"
..themePreview =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_preview"] as String}"
..txExchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange"] as String}"
"$themeId/assets/${json["receive_cancelled"] as String}"
..send = "$themeId/assets/${json["send"] as String}"
..sendPending = "$themeId/assets/${json["send_pending"] as String}"
..sendCancelled = "$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector = "$themeId/assets/${json["theme_selector"] as String}"
..themePreview = "$themeId/assets/${json["theme_preview"] as String}"
..txExchange = "$themeId/assets/${json["tx_exchange"] as String}"
..txExchangePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_pending"] as String}"
"$themeId/assets/${json["tx_exchange_pending"] as String}"
..txExchangeFailed =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_failed"] as String}"
..bitcoin =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoin"] as String}"
..litecoin =
"$applicationThemesDirectoryPath/$themeId/assets/${json["litecoin"] as String}"
..bitcoincash =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoincash"] as String}"
..dogecoin =
"$applicationThemesDirectoryPath/$themeId/assets/${json["dogecoin"] as String}"
..epicCash =
"$applicationThemesDirectoryPath/$themeId/assets/${json["epicCash"] as String}"
..ethereum =
"$applicationThemesDirectoryPath/$themeId/assets/${json["ethereum"] as String}"
..firo =
"$applicationThemesDirectoryPath/$themeId/assets/${json["firo"] as String}"
..monero =
"$applicationThemesDirectoryPath/$themeId/assets/${json["monero"] as String}"
..wownero =
"$applicationThemesDirectoryPath/$themeId/assets/${json["wownero"] as String}"
..namecoin =
"$applicationThemesDirectoryPath/$themeId/assets/${json["namecoin"] as String}"
..particl =
"$applicationThemesDirectoryPath/$themeId/assets/${json["particl"] as String}"
..bitcoinImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoin_image"] as String}"
"$themeId/assets/${json["tx_exchange_failed"] as String}"
..bitcoin = "$themeId/assets/${json["bitcoin"] as String}"
..litecoin = "$themeId/assets/${json["litecoin"] as String}"
..bitcoincash = "$themeId/assets/${json["bitcoincash"] as String}"
..dogecoin = "$themeId/assets/${json["dogecoin"] as String}"
..epicCash = "$themeId/assets/${json["epicCash"] as String}"
..ethereum = "$themeId/assets/${json["ethereum"] as String}"
..firo = "$themeId/assets/${json["firo"] as String}"
..monero = "$themeId/assets/${json["monero"] as String}"
..wownero = "$themeId/assets/${json["wownero"] as String}"
..namecoin = "$themeId/assets/${json["namecoin"] as String}"
..particl = "$themeId/assets/${json["particl"] as String}"
..bitcoinImage = "$themeId/assets/${json["bitcoin_image"] as String}"
..bitcoincashImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoincash_image"] as String}"
..dogecoinImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["dogecoin_image"] as String}"
..epicCashImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["epicCash_image"] as String}"
..ethereumImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["ethereum_image"] as String}"
..firoImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["firo_image"] as String}"
..litecoinImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["litecoin_image"] as String}"
..moneroImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["monero_image"] as String}"
..wowneroImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["wownero_image"] as String}"
..namecoinImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["namecoin_image"] as String}"
..particlImage =
"$applicationThemesDirectoryPath/$themeId/assets/${json["particl_image"] as String}"
"$themeId/assets/${json["bitcoincash_image"] as String}"
..dogecoinImage = "$themeId/assets/${json["dogecoin_image"] as String}"
..epicCashImage = "$themeId/assets/${json["epicCash_image"] as String}"
..ethereumImage = "$themeId/assets/${json["ethereum_image"] as String}"
..firoImage = "$themeId/assets/${json["firo_image"] as String}"
..litecoinImage = "$themeId/assets/${json["litecoin_image"] as String}"
..moneroImage = "$themeId/assets/${json["monero_image"] as String}"
..wowneroImage = "$themeId/assets/${json["wownero_image"] as String}"
..namecoinImage = "$themeId/assets/${json["namecoin_image"] as String}"
..particlImage = "$themeId/assets/${json["particl_image"] as String}"
..bitcoinImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoin_image_secondary"] as String}"
"$themeId/assets/${json["bitcoin_image_secondary"] as String}"
..bitcoincashImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bitcoincash_image_secondary"] as String}"
"$themeId/assets/${json["bitcoincash_image_secondary"] as String}"
..dogecoinImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["dogecoin_image_secondary"] as String}"
"$themeId/assets/${json["dogecoin_image_secondary"] as String}"
..epicCashImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["epicCash_image_secondary"] as String}"
"$themeId/assets/${json["epicCash_image_secondary"] as String}"
..ethereumImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["ethereum_image_secondary"] as String}"
"$themeId/assets/${json["ethereum_image_secondary"] as String}"
..firoImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["firo_image_secondary"] as String}"
"$themeId/assets/${json["firo_image_secondary"] as String}"
..litecoinImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["litecoin_image_secondary"] as String}"
"$themeId/assets/${json["litecoin_image_secondary"] as String}"
..moneroImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["monero_image_secondary"] as String}"
"$themeId/assets/${json["monero_image_secondary"] as String}"
..wowneroImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["wownero_image_secondary"] as String}"
"$themeId/assets/${json["wownero_image_secondary"] as String}"
..namecoinImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["namecoin_image_secondary"] as String}"
"$themeId/assets/${json["namecoin_image_secondary"] as String}"
..particlImageSecondary =
"$applicationThemesDirectoryPath/$themeId/assets/${json["particl_image_secondary"] as String}"
"$themeId/assets/${json["particl_image_secondary"] as String}"
..loadingGif = json["loading_gif"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}"
? "$themeId/assets/${json["loading_gif"] as String}"
: null
..background = json["background"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}"
? "$themeId/assets/${json["background"] as String}"
: null;
}
}
@ -2146,65 +2107,50 @@ class ThemeAssetsV2 implements IThemeAssets {
factory ThemeAssetsV2.fromJson({
required Map<String, dynamic> json,
required String applicationThemesDirectoryPath,
required String themeId,
}) {
return ThemeAssetsV2()
..bellNew =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bell_new"] as String}"
..buy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["buy"] as String}"
..exchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["exchange"] as String}"
..bellNew = "$themeId/assets/${json["bell_new"] as String}"
..buy = "$themeId/assets/${json["buy"] as String}"
..exchange = "$themeId/assets/${json["exchange"] as String}"
..personaIncognito =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_easy"] as String}"
..stack =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack"] as String}"
..stackIcon =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack_icon"] as String}"
..receive =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive"] as String}"
..receivePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_pending"] as String}"
"$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy = "$themeId/assets/${json["persona_easy"] as String}"
..stack = "$themeId/assets/${json["stack"] as String}"
..stackIcon = "$themeId/assets/${json["stack_icon"] as String}"
..receive = "$themeId/assets/${json["receive"] as String}"
..receivePending = "$themeId/assets/${json["receive_pending"] as String}"
..receiveCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_cancelled"] as String}"
..send =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send"] as String}"
..sendPending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_pending"] as String}"
..sendCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_selector"] as String}"
..themePreview =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_preview"] as String}"
..txExchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange"] as String}"
"$themeId/assets/${json["receive_cancelled"] as String}"
..send = "$themeId/assets/${json["send"] as String}"
..sendPending = "$themeId/assets/${json["send_pending"] as String}"
..sendCancelled = "$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector = "$themeId/assets/${json["theme_selector"] as String}"
..themePreview = "$themeId/assets/${json["theme_preview"] as String}"
..txExchange = "$themeId/assets/${json["tx_exchange"] as String}"
..txExchangePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_pending"] as String}"
"$themeId/assets/${json["tx_exchange_pending"] as String}"
..txExchangeFailed =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_failed"] as String}"
"$themeId/assets/${json["tx_exchange_failed"] as String}"
..coinPlaceholder =
"$applicationThemesDirectoryPath/$themeId/assets/${json["coin_placeholder"] as String}"
"$themeId/assets/${json["coin_placeholder"] as String}"
..coinIconsString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["icons"] as Map),
)
..coinImagesString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["images"] as Map),
)
..coinSecondaryImagesString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["secondaries"] as Map),
)
..loadingGif = json["loading_gif"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}"
? "$themeId/assets/${json["loading_gif"] as String}"
: null
..background = json["background"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}"
? "$themeId/assets/${json["background"] as String}"
: null;
}
@ -2265,48 +2211,132 @@ class ThemeAssetsV2 implements IThemeAssets {
@Embedded(inheritance: false)
class ThemeAssetsV3 implements IThemeAssets {
@Name("bellNew")
late final String bellNewRelative;
@override
late final String bellNew;
@override
late final String buy;
@override
late final String exchange;
@override
late final String personaIncognito;
@override
late final String personaEasy;
@override
late final String stack;
@override
late final String stackIcon;
@override
late final String receive;
@override
late final String receivePending;
@override
late final String receiveCancelled;
@override
late final String send;
@override
late final String sendPending;
@override
late final String sendCancelled;
@override
late final String themeSelector;
@override
late final String themePreview;
@override
late final String txExchange;
@override
late final String txExchangePending;
@override
late final String txExchangeFailed;
@override
late final String? loadingGif;
@override
late final String? background;
@ignore
String get bellNew => prependIfNeeded(bellNewRelative);
late final String coinPlaceholder;
@Name("buy")
late final String buyRelative;
@override
@ignore
String get buy => prependIfNeeded(buyRelative);
@Name("exchange")
late final String exchangeRelative;
@override
@ignore
String get exchange => prependIfNeeded(exchangeRelative);
@Name("personaIncognito")
late final String personaIncognitoRelative;
@override
@ignore
String get personaIncognito => prependIfNeeded(personaIncognitoRelative);
@Name("personaEasy")
late final String personaEasyRelative;
@override
@ignore
String get personaEasy => prependIfNeeded(personaEasyRelative);
@Name("stack")
late final String stackRelative;
@override
@ignore
String get stack => prependIfNeeded(stackRelative);
@Name("stackIcon")
late final String stackIconRelative;
@override
@ignore
String get stackIcon => prependIfNeeded(stackIconRelative);
@Name("receive")
late final String receiveRelative;
@override
@ignore
String get receive => prependIfNeeded(receiveRelative);
@Name("receivePending")
late final String receivePendingRelative;
@override
@ignore
String get receivePending => prependIfNeeded(receivePendingRelative);
@Name("receiveCancelled")
late final String receiveCancelledRelative;
@override
@ignore
String get receiveCancelled => prependIfNeeded(receiveCancelledRelative);
@Name("send")
late final String sendRelative;
@override
@ignore
String get send => prependIfNeeded(sendRelative);
@Name("sendPending")
late final String sendPendingRelative;
@override
@ignore
String get sendPending => prependIfNeeded(sendPendingRelative);
@Name("sendCancelled")
late final String sendCancelledRelative;
@override
@ignore
String get sendCancelled => prependIfNeeded(sendCancelledRelative);
@Name("themeSelector")
late final String themeSelectorRelative;
@override
@ignore
String get themeSelector => prependIfNeeded(themeSelectorRelative);
@Name("themePreview")
late final String themePreviewRelative;
@override
@ignore
String get themePreview => prependIfNeeded(themePreviewRelative);
@Name("txExchange")
late final String txExchangeRelative;
@override
@ignore
String get txExchange => prependIfNeeded(txExchangeRelative);
@Name("txExchangePending")
late final String txExchangePendingRelative;
@override
@ignore
String get txExchangePending => prependIfNeeded(txExchangePendingRelative);
@Name("txExchangeFailed")
late final String txExchangeFailedRelative;
@override
@ignore
String get txExchangeFailed => prependIfNeeded(txExchangeFailedRelative);
@Name("loadingGif")
late final String? loadingGifRelative;
@override
@ignore
String? get loadingGif =>
loadingGifRelative != null ? prependIfNeeded(loadingGifRelative!) : null;
@Name("background")
late final String? backgroundRelative;
@override
@ignore
String? get background =>
backgroundRelative != null ? prependIfNeeded(backgroundRelative!) : null;
@Name("coinPlaceholder")
late final String coinPlaceholderRelative;
@ignore
String get coinPlaceholder => prependIfNeeded(coinPlaceholderRelative);
// Added some future proof params in case we want to add anything else
// This should provide some buffer in stead of creating assetsV4 etc
@ -2361,77 +2391,77 @@ class ThemeAssetsV3 implements IThemeAssets {
factory ThemeAssetsV3.fromJson({
required Map<String, dynamic> json,
required String applicationThemesDirectoryPath,
required String themeId,
}) {
return ThemeAssetsV3()
..bellNew =
"$applicationThemesDirectoryPath/$themeId/assets/${json["bell_new"] as String}"
..buy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["buy"] as String}"
..exchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["exchange"] as String}"
..personaIncognito =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_incognito"] as String}"
..personaEasy =
"$applicationThemesDirectoryPath/$themeId/assets/${json["persona_easy"] as String}"
..stack =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack"] as String}"
..stackIcon =
"$applicationThemesDirectoryPath/$themeId/assets/${json["stack_icon"] as String}"
..receive =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive"] as String}"
..receivePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_pending"] as String}"
..receiveCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["receive_cancelled"] as String}"
..send =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send"] as String}"
..sendPending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_pending"] as String}"
..sendCancelled =
"$applicationThemesDirectoryPath/$themeId/assets/${json["send_cancelled"] as String}"
..themeSelector =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_selector"] as String}"
..themePreview =
"$applicationThemesDirectoryPath/$themeId/assets/${json["theme_preview"] as String}"
..txExchange =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange"] as String}"
..txExchangePending =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_pending"] as String}"
..txExchangeFailed =
"$applicationThemesDirectoryPath/$themeId/assets/${json["tx_exchange_failed"] as String}"
..coinPlaceholder =
"$applicationThemesDirectoryPath/$themeId/assets/${json["coin_placeholder"] as String}"
..bellNewRelative = "$themeId/assets/${json["bell_new"] as String}"
..buyRelative = "$themeId/assets/${json["buy"] as String}"
..exchangeRelative = "$themeId/assets/${json["exchange"] as String}"
..personaIncognitoRelative =
"$themeId/assets/${json["persona_incognito"] as String}"
..personaEasyRelative =
"$themeId/assets/${json["persona_easy"] as String}"
..stackRelative = "$themeId/assets/${json["stack"] as String}"
..stackIconRelative = "$themeId/assets/${json["stack_icon"] as String}"
..receiveRelative = "$themeId/assets/${json["receive"] as String}"
..receivePendingRelative =
"$themeId/assets/${json["receive_pending"] as String}"
..receiveCancelledRelative =
"$themeId/assets/${json["receive_cancelled"] as String}"
..sendRelative = "$themeId/assets/${json["send"] as String}"
..sendPendingRelative =
"$themeId/assets/${json["send_pending"] as String}"
..sendCancelledRelative =
"$themeId/assets/${json["send_cancelled"] as String}"
..themeSelectorRelative =
"$themeId/assets/${json["theme_selector"] as String}"
..themePreviewRelative =
"$themeId/assets/${json["theme_preview"] as String}"
..txExchangeRelative = "$themeId/assets/${json["tx_exchange"] as String}"
..txExchangePendingRelative =
"$themeId/assets/${json["tx_exchange_pending"] as String}"
..txExchangeFailedRelative =
"$themeId/assets/${json["tx_exchange_failed"] as String}"
..coinPlaceholderRelative =
"$themeId/assets/${json["coin_placeholder"] as String}"
..coinIconsString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["icons"] as Map),
)
..coinImagesString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["images"] as Map),
)
..coinSecondaryImagesString = createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["secondaries"] as Map),
)
..coinCardImagesString = json["coins"]["cards"] is Map
? createCoinAssetsString(
"$applicationThemesDirectoryPath/$themeId/assets",
"$themeId/assets",
Map<String, dynamic>.from(json["coins"]["cards"] as Map),
)
: null
..loadingGif = json["loading_gif"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["loading_gif"] as String}"
..loadingGifRelative = json["loading_gif"] is String
? "$themeId/assets/${json["loading_gif"] as String}"
: null
..background = json["background"] is String
? "$applicationThemesDirectoryPath/$themeId/assets/${json["background"] as String}"
..backgroundRelative = json["background"] is String
? "$themeId/assets/${json["background"] as String}"
: null
..dummy1 = null
..dummy2 = null
..dummy3 = null;
}
static String prependIfNeeded(String relativePath) {
final path = StackFileSystem.themesDir!.path;
if (relativePath.startsWith(path)) {
return relativePath;
} else {
return "$path/$relativePath";
}
}
static String createCoinAssetsString(String path, Map<String, dynamic> json) {
final Map<String, dynamic> map = {};
for (final entry in json.entries) {
@ -2451,6 +2481,8 @@ class ThemeAssetsV3 implements IThemeAssets {
for (final coin in Coin.values) {
result[coin] = map[coin.name] as String? ?? placeHolder;
result[coin] = prependIfNeeded(result[coin]!);
}
return result;

File diff suppressed because it is too large Load diff

View file

@ -126,7 +126,7 @@ class _StackThemeCardState extends ConsumerState<StackThemeCard> {
}
Future<String> getThemeDirectorySize() async {
final themesDir = await StackFileSystem.applicationThemesDirectory();
final themesDir = StackFileSystem.themesDir!;
final themeDir = Directory("${themesDir.path}/${widget.data.id}");
int bytes = 0;
if (await themeDir.exists()) {

View file

@ -40,7 +40,7 @@ class ThemeService {
void init(MainDB db) => _db ??= db;
Future<void> install({required Uint8List themeArchiveData}) async {
final themesDir = await StackFileSystem.applicationThemesDirectory();
final themesDir = StackFileSystem.themesDir!;
final archive = ZipDecoder().decodeBytes(themeArchiveData);
@ -55,7 +55,6 @@ class ThemeService {
final theme = StackTheme.fromJson(
json: Map<String, dynamic>.from(json),
applicationThemesDirectoryPath: themesDir.path,
);
try {
@ -88,7 +87,7 @@ class ThemeService {
}
Future<void> remove({required String themeId}) async {
final themesDir = await StackFileSystem.applicationThemesDirectory();
final themesDir = StackFileSystem.themesDir!;
final isarId = await db.isar.stackThemes
.where()
.themeIdEqualTo(themeId)
@ -187,7 +186,7 @@ class ThemeService {
return false;
}
final themesDir = await StackFileSystem.applicationThemesDirectory();
final themesDir = StackFileSystem.themesDir!;
final jsonFileExists =
await File("${themesDir.path}/$themeId/theme.json").exists();
final assetsDirExists =

View file

@ -73,16 +73,15 @@ abstract class StackFileSystem {
}
}
static Future<Directory> applicationThemesDirectory() async {
static Future<void> initThemesDir() async {
final root = await applicationRootDirectory();
// if (Util.isDesktop) {
final dir = Directory("${root.path}/themes");
if (!dir.existsSync()) {
await dir.create();
}
return dir;
// } else {
// return root;
// }
themesDir = dir;
}
static Directory? themesDir;
}

View file

@ -23,7 +23,6 @@ void main() {
final mockThemeService = MockThemeService();
final theme = StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
);
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(

View file

@ -59,7 +59,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(mockPrefs.currency).thenAnswer((_) => "USD");
@ -89,7 +88,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -143,7 +141,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -169,7 +166,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -56,8 +56,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath:
applicationThemesDirectoryPath,
),
),
],

View file

@ -28,7 +28,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -28,7 +28,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -24,7 +24,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -56,7 +55,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -93,7 +91,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -22,7 +22,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -37,7 +36,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -22,7 +22,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -37,7 +36,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -67,7 +67,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -99,7 +98,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -151,7 +149,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -187,7 +184,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -223,7 +219,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -264,7 +259,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -301,7 +295,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -333,7 +326,7 @@ void main() {
// StackColors.fromStackColorTheme(
// StackTheme.fromJson(
// json: lightThemeJsonMap,
// applicationThemesDirectoryPath: "test",
//
// ),
// ),
// ],
@ -385,7 +378,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -427,7 +419,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -469,7 +460,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -510,7 +500,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -17,7 +17,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -19,7 +19,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -24,7 +24,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -18,7 +18,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -21,7 +21,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
await widgetTester.pumpWidget(
@ -35,7 +34,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -57,7 +55,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -72,7 +69,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -97,7 +93,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -112,7 +107,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -20,7 +20,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -49,7 +48,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -21,7 +21,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -55,7 +55,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin).thenAnswer((_) => Coin.bitcoin);
@ -97,7 +96,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -126,7 +124,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin).thenAnswer((_) => Coin.bitcoin);
@ -186,7 +183,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -214,7 +210,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin).thenAnswer((_) => Coin.bitcoin);
@ -274,7 +269,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -57,7 +57,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -118,7 +117,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -180,7 +178,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -63,7 +63,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -136,7 +135,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -203,7 +201,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -10,7 +10,6 @@ void main() {
testWidgets("Widget build", (widgetTester) async {
final theme = StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
);
await widgetTester.pumpWidget(
MaterialApp(

View file

@ -15,23 +15,23 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
),
home: Material(
child: Shake(
animationRange: 10,
controller: ShakeController(),
animationDuration: const Duration(milliseconds: 200),
child: Column(
children: const [
Center(
child: Text("Enter Pin"),
)
],
)),
animationRange: 10,
controller: ShakeController(),
animationDuration: const Duration(milliseconds: 200),
child: const Column(
children: [
Center(
child: Text("Enter Pin"),
)
],
),
),
),
),
);

View file

@ -17,7 +17,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -39,7 +38,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -75,7 +73,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -16,7 +16,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -42,7 +42,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
@ -80,7 +79,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -17,7 +17,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -16,7 +16,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -21,7 +21,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
final trade = Trade(
@ -59,7 +58,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test/sample_data",
),
),
],

View file

@ -93,7 +93,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin.ticker).thenAnswer((_) => "FIRO");
@ -138,7 +137,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -224,7 +222,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin.ticker).thenAnswer((_) => "FIRO");
@ -268,7 +265,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -352,7 +348,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin.ticker).thenAnswer((_) => "FIRO");
@ -397,7 +392,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],
@ -474,7 +468,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin.ticker).thenAnswer((_) => "FIRO");
@ -524,7 +517,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -42,7 +42,6 @@ void main() {
mockito.when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
mockito.when(wallet.walletId).thenAnswer((realInvocation) => "wallet id");
@ -81,7 +80,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -64,7 +64,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],

View file

@ -41,7 +41,6 @@ void main() {
when(mockThemeService.getTheme(themeId: "light")).thenAnswer(
(_) => StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
);
when(wallet.coin).thenAnswer((_) => Coin.bitcoin);
@ -73,7 +72,6 @@ void main() {
StackColors.fromStackColorTheme(
StackTheme.fromJson(
json: lightThemeJsonMap,
applicationThemesDirectoryPath: "test",
),
),
],