diff --git a/lib/main.dart b/lib/main.dart index aa47efc78..6aba81d41 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -24,6 +24,7 @@ import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; +import 'package:stackwallet/models/isar/sw_theme.dart'; import 'package:stackwallet/models/models.dart'; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/notification_model.dart'; @@ -41,7 +42,6 @@ import 'package:stackwallet/providers/global/base_currencies_provider.dart'; // import 'package:stackwallet/providers/global/has_authenticated_start_state_provider.dart'; import 'package:stackwallet/providers/global/trades_service_provider.dart'; import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/route_generator.dart'; // import 'package:stackwallet/services/buy/buy_data_loading_service.dart'; import 'package:stackwallet/services/debug_service.dart'; @@ -51,6 +51,7 @@ import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/notifications_api.dart'; import 'package:stackwallet/services/notifications_service.dart'; import 'package:stackwallet/services/trade_service.dart'; +import 'package:stackwallet/themes/defaults/dark.dart'; import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/db_version_migration.dart'; @@ -60,14 +61,12 @@ import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; import 'package:stackwallet/utilities/stack_file_system.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; -import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:window_size/window_size.dart'; final openedFromSWBFileStringStateProvider = StateProvider((ref) => null); -String? themeDirectory; // main() is the entry point to the app. It initializes Hive (local database), // runs the MyApp widget and checks for new users, caching the value in the // miscellaneous box for later use @@ -275,9 +274,8 @@ class _MaterialAppWithThemeState extends ConsumerState await loadShared(); } - themeDirectory = ref - .read(applicationThemesDirectoryPathProvider.notifier) - .state = (await StackFileSystem.applicationThemesDirectory()).path; + ref.read(applicationThemesDirectoryPathProvider.notifier).state = + (await StackFileSystem.applicationThemesDirectory()).path; _notificationsService = ref.read(notificationsProvider); _nodeService = ref.read(nodeServiceChangeNotifierProvider); @@ -372,8 +370,12 @@ class _MaterialAppWithThemeState extends ConsumerState .loadLocale(notify: false); WidgetsBinding.instance.addPostFrameCallback((_) async { - ref.read(colorThemeProvider.state).state = - StackColors.fromStackColorTheme(colorTheme); + ref.read(themeProvider.state).state = StackTheme.fromJson( + json: darkJson, + applicationThemesDirectoryPath: ref.read( + applicationThemesDirectoryPathProvider, + ), + ); if (Platform.isAndroid) { // fetch open file if it exists @@ -411,8 +413,12 @@ class _MaterialAppWithThemeState extends ConsumerState WidgetsBinding.instance.addPostFrameCallback((_) { if (ref.read(prefsChangeNotifierProvider).enableSystemBrightness) { - ref.read(colorThemeProvider.notifier).state = - StackColors.fromStackColorTheme(colorTheme); + ref.read(themeProvider.state).state = StackTheme.fromJson( + json: darkJson, + applicationThemesDirectoryPath: ref.read( + applicationThemesDirectoryPathProvider, + ), + ); } }); }; @@ -547,7 +553,7 @@ class _MaterialAppWithThemeState extends ConsumerState // addToDebugMessagesDB: false); // }); - final colorScheme = ref.watch(colorThemeProvider.state).state; + final colorScheme = ref.watch(colorProvider.state).state; return MaterialApp( key: GlobalKey(), diff --git a/lib/models/isar/sw_theme.dart b/lib/models/isar/sw_theme.dart index 6e2e2c44c..35e977573 100644 --- a/lib/models/isar/sw_theme.dart +++ b/lib/models/isar/sw_theme.dart @@ -72,14 +72,34 @@ class StackTheme { // ==== boxShadows ===================================================== @ignore - BoxShadow get boxShadows => _boxShadows ??= BoxShadowExt.fromJson( + BoxShadow get standardBoxShadow => + _standardBoxShadow ??= BoxShadowExt.fromJson( Map.from( - jsonDecode(boxShadowsString) as Map, + jsonDecode(standardBoxShadowString) as Map, ), ); @ignore - BoxShadow? _boxShadows; - final String boxShadowsString; + BoxShadow? _standardBoxShadow; + final String standardBoxShadowString; + + @ignore + BoxShadow? get homeViewButtonBarBoxShadow { + if (homeViewButtonBarBoxShadowString == null) { + _homeViewButtonBarBoxShadow = null; + } else { + _homeViewButtonBarBoxShadow ??= BoxShadowExt.fromJson( + Map.from( + jsonDecode(homeViewButtonBarBoxShadowString!) as Map, + ), + ); + } + + return _homeViewButtonBarBoxShadow; + } + + @ignore + BoxShadow? _homeViewButtonBarBoxShadow; + final String? homeViewButtonBarBoxShadowString; // ==== overlay ===================================================== @@ -1456,7 +1476,8 @@ class StackTheme { required this.backgroundInt, required this.backgroundAppBarInt, required this.gradientBackgroundString, - required this.boxShadowsString, + required this.standardBoxShadowString, + required this.homeViewButtonBarBoxShadowString, required this.overlayInt, required this.accentColorBlueInt, required this.accentColorGreenInt, @@ -1624,7 +1645,12 @@ class StackTheme { json["colors"]["background_colors"]["backgroundAppBar"] as String), gradientBackgroundString: jsonEncode(json["gradients"]["background"] as Map), - boxShadowsString: jsonEncode(json["box_shadows"] as Map), + standardBoxShadowString: + jsonEncode(json["box_shadows"]["standard"] as Map), + homeViewButtonBarBoxShadowString: + json["box_shadows"]["home_view_button_bar"] == null + ? null + : jsonEncode(json["box_shadows"]["home_view_button_bar"] as Map), coinColorsJsonString: jsonEncode(json["coinColors"] as Map), assets: ThemeAssets.fromJson( json: json, diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart index a83fa5bd2..badf032cc 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart @@ -12,8 +12,8 @@ import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_o import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart'; import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart'; import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -67,7 +67,7 @@ class _RestoreOptionsViewState extends ConsumerState { @override void initState() { - baseColor = ref.read(colorThemeProvider.state).state.textSubtitle2; + baseColor = ref.read(themeProvider.state).state.textSubtitle2; walletName = widget.walletName; coin = widget.coin; isDesktop = Util.isDesktop; diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart index 8c9334ef3..75b8e265d 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart @@ -3,7 +3,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart'; import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -51,10 +50,12 @@ class _ThemeOptionsWidgetState extends ConsumerState { } // apply theme - ref.read(colorThemeProvider.notifier).state = - StackColors.fromStackColorTheme( - theme.colorTheme, - ); + + throw Exception("bbbbbbbbbbbbbbbbb"); + // ref.read(colorThemeProvider.notifier).state = + // StackColors.fromStackColorTheme( + // theme.colorTheme, + // ); Assets.precache(context); } else { @@ -73,11 +74,12 @@ class _ThemeOptionsWidgetState extends ConsumerState { ref.read(prefsChangeNotifierProvider.notifier).theme = theme; // apply theme - ref.read(colorThemeProvider.notifier).state = - StackColors.fromStackColorTheme( - theme.colorTheme, - ); + // ref.read(colorThemeProvider.notifier).state = + // StackColors.fromStackColorTheme( + // theme.colorTheme, + // ); + throw Exception("bbbbbbbbbbbbbbbbb"); Assets.precache(context); } } diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart index 40d939863..6a6a2f7fd 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -27,18 +26,20 @@ class SystemBrightnessThemeSelectionView extends ConsumerWidget { if (isDark) { ref.read(prefsChangeNotifierProvider).systemBrightnessDarkTheme = type; if (brightness == Brightness.dark) { - ref.read(colorThemeProvider.notifier).state = - StackColors.fromStackColorTheme( - type.colorTheme, - ); + throw Exception("aaaaaaaaaaaaaaaa"); + // ref.read(themeProvider.notifier).state = + // StackColors.fromStackColorTheme( + // type.colorTheme, + // ); } } else { ref.read(prefsChangeNotifierProvider).systemBrightnessLightTheme = type; if (brightness == Brightness.light) { - ref.read(colorThemeProvider.notifier).state = - StackColors.fromStackColorTheme( - type.colorTheme, - ); + throw Exception("aaaaaaaaaaaaaaaa"); + // ref.read(colorThemeProvider.notifier).state = + // StackColors.fromStackColorTheme( + // type.colorTheme, + // ); } } } diff --git a/lib/pages/stack_privacy_calls.dart b/lib/pages/stack_privacy_calls.dart index 7795b107a..b43ea2cd3 100644 --- a/lib/pages/stack_privacy_calls.dart +++ b/lib/pages/stack_privacy_calls.dart @@ -8,8 +8,8 @@ import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; import 'package:stackwallet/pages_desktop_specific/password/create_password_view.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -311,9 +311,9 @@ class _PrivacyToggleState extends ConsumerState { @override Widget build(BuildContext context) { final bool lightChan = - ref.read(colorThemeProvider.state).state.themeType == ThemeType.chan; - final bool darkChan = ref.read(colorThemeProvider.state).state.themeType == - ThemeType.darkChans; + ref.read(themeProvider.state).state.themeType == ThemeType.chan; + final bool darkChan = + ref.read(themeProvider.state).state.themeType == ThemeType.darkChans; return Row( children: [ Expanded( diff --git a/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart b/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart index ac1295f55..9c89d7067 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart @@ -6,8 +6,8 @@ import 'package:flutter_rounded_date_picker/flutter_rounded_date_picker.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/transaction_filter.dart'; import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; @@ -61,7 +61,7 @@ class _TransactionSearchViewState @override initState() { - baseColor = ref.read(colorThemeProvider.state).state.textSubtitle2; + baseColor = ref.read(themeProvider.state).state.textSubtitle2; final filterState = ref.read(transactionFilterProvider.state).state; if (filterState != null) { _isActiveReceivedCheckbox = filterState.received; diff --git a/lib/pages/wallets_view/sub_widgets/empty_wallets.dart b/lib/pages/wallets_view/sub_widgets/empty_wallets.dart index 4db5ce741..4cc92ca89 100644 --- a/lib/pages/wallets_view/sub_widgets/empty_wallets.dart +++ b/lib/pages/wallets_view/sub_widgets/empty_wallets.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; @@ -17,12 +17,12 @@ class EmptyWallets extends ConsumerWidget { debugPrint("BUILD: $runtimeType"); final isDesktop = Util.isDesktop; - final bool isSorbet = ref.read(colorThemeProvider.state).state.themeType == - ThemeType.fruitSorbet; + final bool isSorbet = + ref.read(themeProvider.state).state.themeType == ThemeType.fruitSorbet; final bool isForest = - ref.read(colorThemeProvider.state).state.themeType == ThemeType.forest; - final bool isOcean = ref.read(colorThemeProvider.state).state.themeType == - ThemeType.oceanBreeze; + ref.read(themeProvider.state).state.themeType == ThemeType.forest; + final bool isOcean = + ref.read(themeProvider.state).state.themeType == ThemeType.oceanBreeze; return SafeArea( child: Padding( @@ -98,8 +98,8 @@ class AddWalletButton extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - final bool isOLED = ref.read(colorThemeProvider.state).state.themeType == - ThemeType.oledBlack; + final bool isOLED = + ref.read(themeProvider.state).state.themeType == ThemeType.oledBlack; return TextButton( style: Theme.of(context) .extension()! diff --git a/lib/pages/wallets_view/wallets_view.dart b/lib/pages/wallets_view/wallets_view.dart index 1c7f99e4f..62d7ab6ed 100644 --- a/lib/pages/wallets_view/wallets_view.dart +++ b/lib/pages/wallets_view/wallets_view.dart @@ -5,7 +5,7 @@ import 'package:stackwallet/pages/wallets_view/sub_widgets/all_wallets.dart'; import 'package:stackwallet/pages/wallets_view/sub_widgets/empty_wallets.dart'; import 'package:stackwallet/pages/wallets_view/sub_widgets/favorite_wallets.dart'; import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; class WalletsView extends ConsumerWidget { @@ -25,8 +25,7 @@ class WalletsView extends ConsumerWidget { child: hasWallets ? Padding( padding: EdgeInsets.only( - top: ref.watch(colorThemeProvider).themeType == - ThemeType.fruitSorbet + top: ref.watch(themeProvider).themeType == ThemeType.fruitSorbet ? 6 : 20, ), diff --git a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart index c86e9812c..58e843108 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart @@ -6,8 +6,8 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -227,9 +227,9 @@ class _PrivacyToggleState extends ConsumerState { @override Widget build(BuildContext context) { final bool lightChan = - ref.read(colorThemeProvider.state).state.themeType == ThemeType.chan; - final bool darkChan = ref.read(colorThemeProvider.state).state.themeType == - ThemeType.darkChans; + ref.read(themeProvider.state).state.themeType == ThemeType.chan; + final bool darkChan = + ref.read(themeProvider.state).state.themeType == ThemeType.darkChans; return Row( children: [ Expanded( diff --git a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings.dart index 03be95a6c..d974c223a 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -233,14 +233,16 @@ class _ThemeToggle extends ConsumerState { cursor: SystemMouseCursors.click, child: GestureDetector( onTap: () { - if (ref.read(colorThemeProvider.notifier).state.themeType != + if (ref.read(themeProvider.notifier).state.themeType != ThemeType.values[i]) { ref.read(prefsChangeNotifierProvider.notifier).theme = ThemeType.values[i]; - ref.read(colorThemeProvider.notifier).state = - StackColors.fromStackColorTheme( - ThemeType.values[i].colorTheme); + throw Exception( + "TODO: set theme here properly once implemented"); + // ref.read(themeProvider.notifier).state = + // StackColors.fromStackColorTheme( + // ThemeType.values[i].colorTheme); } }, child: Container( @@ -254,7 +256,7 @@ class _ThemeToggle extends ConsumerState { border: Border.all( width: 2.5, color: ref - .read(colorThemeProvider.notifier) + .read(themeProvider.notifier) .state .themeType == ThemeType.values[i] @@ -288,10 +290,8 @@ class _ThemeToggle extends ConsumerState { .extension()! .radioButtonIconEnabled, value: ThemeType.values[i], - groupValue: ref - .read(colorThemeProvider.state) - .state - .themeType, + groupValue: + ref.read(themeProvider.state).state.themeType, onChanged: (_) {}, ), ), diff --git a/lib/providers/ui/color_theme_provider.dart b/lib/providers/ui/color_theme_provider.dart deleted file mode 100644 index 9843f0f9c..000000000 --- a/lib/providers/ui/color_theme_provider.dart +++ /dev/null @@ -1,6 +0,0 @@ -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/utilities/theme/light_colors.dart'; -import 'package:stackwallet/utilities/theme/stack_colors.dart'; - -final colorThemeProvider = StateProvider( - (ref) => StackColors.fromStackColorTheme(LightColors())); diff --git a/lib/themes/defaults/dark.dart b/lib/themes/defaults/dark.dart index daa00cb6a..4f17bac07 100644 --- a/lib/themes/defaults/dark.dart +++ b/lib/themes/defaults/dark.dart @@ -189,18 +189,16 @@ final Map darkJson = { "token_summary_button_bg": "0xFFC9D0FF", "token_summary_icon": "0xFF252C78" }, - "box_shadows": [ - { - "type": "standard", + "box_shadows": { + "standard": { "color": "0x0F2D3132", "spread_radius": 3.0, "blur_radius": 4.0 }, - { - "type": "home_view_button_bar", + "home_view_button_bar": { "color": "0x0F2D3132", "spread_radius": 3.0, "blur_radius": 4.0 } - ] + } }; diff --git a/lib/themes/theme_providers.dart b/lib/themes/theme_providers.dart index 38f9b82be..41b80c8a6 100644 --- a/lib/themes/theme_providers.dart +++ b/lib/themes/theme_providers.dart @@ -5,9 +5,16 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stackwallet/models/isar/sw_theme.dart'; import 'package:stackwallet/themes/defaults/dark.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; final applicationThemesDirectoryPathProvider = StateProvider((ref) => ""); +final colorProvider = StateProvider( + (ref) => StackColors.fromStackColorTheme( + ref.watch(themeProvider.state).state, + ), +); + final themeProvider = StateProvider((ref) { // Return default if no theme was properly loaded on startup. This should // technically never actually be read but we don't want an optional. diff --git a/lib/utilities/assets.dart b/lib/utilities/assets.dart index 5f6f7cfbb..91b07c325 100644 --- a/lib/utilities/assets.dart +++ b/lib/utilities/assets.dart @@ -1,11 +1,6 @@ -import 'dart:io'; - -import 'package:cw_core/pathForWallet.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/main.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -113,9 +108,9 @@ class _SVG { case ThemeType.darkChans: // print("THIS THEMES DIRECTORY IS $themeDirectory"); // final themesPath = themesDirectory(); - // return "assets/svg/themed/${ThemeType.dark.name}"; - //TODO - remove, this will be accesses from js - return "$themeDirectory/dark"; + return "assets/svg/themed/${ThemeType.dark.name}"; + // //TODO - remove, this will be accesses from js + // return "$themeDirectory/dark"; default: return "assets/svg/themed/${Theme.of(context).extension()!.themeType.name}"; diff --git a/lib/utilities/extensions/impl/box_shadow.dart b/lib/utilities/extensions/impl/box_shadow.dart index ea0e8c177..c5c53794d 100644 --- a/lib/utilities/extensions/impl/box_shadow.dart +++ b/lib/utilities/extensions/impl/box_shadow.dart @@ -30,28 +30,9 @@ final map = { }; extension BoxShadowExt on BoxShadow { - static BoxShadow fromJson(Map json) { - switch (json["boxShadowType"] as String) { - case "standard": - final colorStrings = (json["colors"]); - return BoxShadow( - color: Color( - colorStrings as int, - ), - spreadRadius: json["spread_radius"] as double, - blurRadius: json["blur_radius"] as double, - ); - case "home_view_button_bar": - final colorStrings = (json["colors"]); - return BoxShadow( - color: Color( - colorStrings as int, - ), - spreadRadius: json["spread_radius"] as double, - blurRadius: json["blur_radius"] as double, - ); - default: - throw ArgumentError("Invalid json box shadow: $json"); - } - } + static BoxShadow fromJson(Map json) => BoxShadow( + color: Color(int.parse(json["color"] as String)), + spreadRadius: json["spread_radius"] as double, + blurRadius: json["blur_radius"] as double, + ); } diff --git a/lib/utilities/theme/stack_colors.dart b/lib/utilities/theme/stack_colors.dart index 193052de3..6316d1401 100644 --- a/lib/utilities/theme/stack_colors.dart +++ b/lib/utilities/theme/stack_colors.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:stackwallet/models/isar/sw_theme.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; @@ -359,7 +360,7 @@ class StackColors extends ThemeExtension { required this.tokenSummaryIcon, }); - factory StackColors.fromStackColorTheme(StackColorTheme colorTheme) { + factory StackColors.fromStackColorTheme(StackTheme colorTheme) { return StackColors( themeType: colorTheme.themeType, brightness: colorTheme.brightness, diff --git a/lib/widgets/custom_buttons/favorite_toggle.dart b/lib/widgets/custom_buttons/favorite_toggle.dart index 83834a3ee..8f7de6804 100644 --- a/lib/widgets/custom_buttons/favorite_toggle.dart +++ b/lib/widgets/custom_buttons/favorite_toggle.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/ui/color_theme_provider.dart'; +import 'package:stackwallet/themes/theme_providers.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -37,10 +37,9 @@ class _FavoriteToggleState extends ConsumerState { @override void initState() { - on = widget.on ?? - ref.read(colorThemeProvider.state).state.favoriteStarActive; - off = widget.off ?? - ref.read(colorThemeProvider.state).state.favoriteStarInactive; + on = widget.on ?? ref.read(themeProvider.state).state.favoriteStarActive; + off = + widget.off ?? ref.read(themeProvider.state).state.favoriteStarInactive; _isActive = widget.initialState; _color = _isActive ? on : off; _onChanged = widget.onChanged;