diff --git a/lib/hive/db.dart b/lib/hive/db.dart index 3aae3096a..c8e148923 100644 --- a/lib/hive/db.dart +++ b/lib/hive/db.dart @@ -9,7 +9,6 @@ import 'package:stackwallet/models/notification_model.dart'; import 'package:stackwallet/models/trade_wallet_lookup.dart'; import 'package:stackwallet/services/wallets_service.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; - import 'package:stackwallet/utilities/logger.dart'; class DB { @@ -30,6 +29,7 @@ class DB { static const String boxNameWalletsToDeleteOnStart = "walletsToDeleteOnStart"; static const String boxNamePriceCache = "priceAPIPrice24hCache"; static const String boxNameDBInfo = "dbInfo"; + static const String boxNameTheme = "theme"; String boxNameTxCache({required Coin coin}) => "${coin.name}_txCache"; String boxNameSetCache({required Coin coin}) => diff --git a/lib/main.dart b/lib/main.dart index 843e348c2..89d7bf3c6 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -141,6 +141,19 @@ void main() async { monero.onStartup(); + await Hive.openBox(DB.boxNameTheme); + final colorScheme = + DB.instance.get(boxName: DB.boxNameTheme, key: "colorScheme") as String?; + + switch (colorScheme) { + case "dark": + StackTheme.instance.setTheme(ThemeType.dark); + break; + case "light": + default: + StackTheme.instance.setTheme(ThemeType.light); + } + // SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, // overlays: [SystemUiOverlay.bottom]); await NotificationApi.init(); @@ -157,8 +170,6 @@ class MyApp extends StatelessWidget { final localeService = LocaleService(); localeService.loadLocale(); - StackTheme.instance.setTheme(ThemeType.dark); - return const KeyboardDismisser( child: MaterialAppWithTheme(), ); diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings_view.dart b/lib/pages/settings_views/global_settings_view/appearance_settings_view.dart index 8b1c95da8..9e5c6f114 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings_view.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -89,6 +90,74 @@ class AppearanceSettingsView extends ConsumerWidget { }, ), ), + const SizedBox( + height: 10, + ), + RoundedWhiteContainer( + child: Consumer( + builder: (_, ref, __) { + return RawMaterialButton( + splashColor: StackTheme.instance.color.highlight, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, + ), + ), + onPressed: null, + child: Padding( + padding: + const EdgeInsets.symmetric(vertical: 2), + child: Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Enabled dark mode", + style: STextStyles.titleBold12, + textAlign: TextAlign.left, + ), + Text( + "Requires restart", + style: STextStyles.itemSubtitle, + textAlign: TextAlign.left, + ), + ], + ), + SizedBox( + height: 20, + width: 40, + child: DraggableSwitchButton( + isOn: (DB.instance.get( + boxName: DB.boxNameTheme, + key: "colorScheme") + as String?) == + "dark", + onValueChanged: (newValue) { + // StackTheme.instance.setTheme(newValue + // ? ThemeType.dark + // : ThemeType.light); + DB.instance.put( + boxName: DB.boxNameTheme, + key: "colorScheme", + value: + StackTheme.instance.theme.name, + ); + }, + ), + ) + ], + ), + ), + ); + }, + ), + ), ], ), ), diff --git a/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart b/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart index c916226c8..806a5861c 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart @@ -123,7 +123,7 @@ class _RefreshButtonState extends ConsumerState Assets.svg.arrowRotate, width: 24, height: 24, - color: StackTheme.instance.color.accentColorDark, + color: StackTheme.instance.color.textFavoriteCard, ), ), ), diff --git a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart index 7e261fbe9..a175d38f8 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart @@ -130,6 +130,8 @@ class _WalletSummaryInfoState extends State { "${_showAvailable ? "Private" : "Public"} Balance", style: STextStyles.subtitle.copyWith( fontWeight: FontWeight.w500, + color: StackTheme + .instance.color.textFavoriteCard, ), ), if (coin != Coin.firo && coin != Coin.firoTestNet) @@ -137,6 +139,8 @@ class _WalletSummaryInfoState extends State { "${_showAvailable ? "Available" : "Full"} Balance", style: STextStyles.subtitle.copyWith( fontWeight: FontWeight.w500, + color: StackTheme + .instance.color.textFavoriteCard, ), ), const SizedBox( @@ -145,7 +149,7 @@ class _WalletSummaryInfoState extends State { SvgPicture.asset( Assets.svg.chevronDown, color: - StackTheme.instance.color.accentColorDark, + StackTheme.instance.color.textFavoriteCard, width: 8, height: 4, ), @@ -163,6 +167,7 @@ class _WalletSummaryInfoState extends State { )} ${coin.ticker}", style: STextStyles.pageTitleH1.copyWith( fontSize: 24, + color: StackTheme.instance.color.textFavoriteCard, ), ), ), @@ -174,6 +179,7 @@ class _WalletSummaryInfoState extends State { )} $baseCurrency", style: STextStyles.subtitle.copyWith( fontWeight: FontWeight.w500, + color: StackTheme.instance.color.textFavoriteCard, ), ), ], @@ -191,6 +197,8 @@ class _WalletSummaryInfoState extends State { "${_showAvailable ? "Private" : "Public"} Balance", style: STextStyles.subtitle.copyWith( fontWeight: FontWeight.w500, + color: StackTheme + .instance.color.textFavoriteCard, ), ), if (coin != Coin.firo && coin != Coin.firoTestNet) @@ -198,6 +206,8 @@ class _WalletSummaryInfoState extends State { "${_showAvailable ? "Available" : "Full"} Balance", style: STextStyles.subtitle.copyWith( fontWeight: FontWeight.w500, + color: StackTheme + .instance.color.textFavoriteCard, ), ), const SizedBox( @@ -205,10 +215,10 @@ class _WalletSummaryInfoState extends State { ), SvgPicture.asset( Assets.svg.chevronDown, - color: - StackTheme.instance.color.accentColorDark, width: 8, height: 4, + color: + StackTheme.instance.color.textFavoriteCard, ), ], ), @@ -223,6 +233,7 @@ class _WalletSummaryInfoState extends State { ], style: STextStyles.pageTitleH1.copyWith( fontSize: 24, + color: StackTheme.instance.color.textFavoriteCard, ), ), AnimatedText( @@ -234,6 +245,7 @@ class _WalletSummaryInfoState extends State { ], style: STextStyles.subtitle.copyWith( fontWeight: FontWeight.w500, + color: StackTheme.instance.color.textFavoriteCard, ), ), ], diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 91ce1ac12..51ee4d075 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -440,6 +440,10 @@ class _WalletViewState extends ConsumerState { : Assets.svg.bell, width: 20, height: 20, + color: ref.watch(notificationsProvider.select((value) => + value.hasUnreadNotificationsFor(walletId))) + ? null + : StackTheme.instance.color.topNavIconPrimary, ), onPressed: () { // reset unread state @@ -544,6 +548,8 @@ class _WalletViewState extends ConsumerState { children: [ Expanded( child: TextButton( + style: StackTheme.instance + .getSecondaryEnabledButtonColor(context), onPressed: () async { await showDialog( context: context, @@ -558,8 +564,9 @@ class _WalletViewState extends ConsumerState { child: Text( "Cancel", style: STextStyles.button.copyWith( - color: StackTheme - .instance.color.accentColorDark), + color: StackTheme + .instance.color.accentColorDark, + ), ), ), rightButton: TextButton( @@ -581,8 +588,9 @@ class _WalletViewState extends ConsumerState { child: Text( "Anonymize funds", style: STextStyles.button.copyWith( - color: StackTheme - .instance.color.accentColorDark), + color: StackTheme + .instance.color.buttonTextSecondary, + ), ), ), ), diff --git a/lib/pages/wallets_view/sub_widgets/favorite_card.dart b/lib/pages/wallets_view/sub_widgets/favorite_card.dart index ecfe06b18..5f4176601 100644 --- a/lib/pages/wallets_view/sub_widgets/favorite_card.dart +++ b/lib/pages/wallets_view/sub_widgets/favorite_card.dart @@ -128,25 +128,29 @@ class _FavoriteCardState extends ConsumerState { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - ref.watch( - managerProvider.select((value) => value.walletName)), - style: STextStyles.itemSubtitle12.copyWith( - color: StackTheme.instance.color.textFavoriteCard, + Expanded( + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + child: Text( + ref.watch(managerProvider + .select((value) => value.walletName)), + style: STextStyles.itemSubtitle12.copyWith( + color: StackTheme.instance.color.textFavoriteCard, + ), + overflow: TextOverflow.fade, + ), ), - ), - const Spacer(), - SvgPicture.asset( - Assets.svg.iconFor(coin: coin), - width: 24, - height: 24, - ), - ], + SvgPicture.asset( + Assets.svg.iconFor(coin: coin), + width: 24, + height: 24, + ), + ], + ), ), - const Spacer(), FutureBuilder( future: ref.watch( managerProvider.select((value) => value.totalBalance)),