From f26bd5a81365b00cf1126e3f2f4d238830ff6cc8 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 22 Sep 2022 18:12:39 -0600 Subject: [PATCH 1/9] no submit pin button --- lib/widgets/custom_pin_put/pin_keyboard.dart | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/widgets/custom_pin_put/pin_keyboard.dart b/lib/widgets/custom_pin_put/pin_keyboard.dart index 5b52460aa..6c1f50d78 100644 --- a/lib/widgets/custom_pin_put/pin_keyboard.dart +++ b/lib/widgets/custom_pin_put/pin_keyboard.dart @@ -312,8 +312,9 @@ class PinKeyboard extends StatelessWidget { ), Row( children: [ - BackspaceKey( - onPressed: _backHandler, + const SizedBox( + height: 72, + width: 72, ), const SizedBox( width: 24, @@ -325,9 +326,12 @@ class PinKeyboard extends StatelessWidget { const SizedBox( width: 24, ), - SubmitKey( - onPressed: _submitHandler, + BackspaceKey( + onPressed: _backHandler, ), + // SubmitKey( + // onPressed: _submitHandler, + // ), ], ) ], From a8d656338ac09fe3afce912a4f008182613ddea2 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 22 Sep 2022 18:18:24 -0600 Subject: [PATCH 2/9] theme context initState fix --- lib/widgets/custom_buttons/favorite_toggle.dart | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/widgets/custom_buttons/favorite_toggle.dart b/lib/widgets/custom_buttons/favorite_toggle.dart index 2d25d0674..83834a3ee 100644 --- a/lib/widgets/custom_buttons/favorite_toggle.dart +++ b/lib/widgets/custom_buttons/favorite_toggle.dart @@ -1,9 +1,11 @@ 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/utilities/assets.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; -class FavoriteToggle extends StatefulWidget { +class FavoriteToggle extends ConsumerStatefulWidget { const FavoriteToggle({ Key? key, this.backGround, @@ -22,10 +24,10 @@ class FavoriteToggle extends StatefulWidget { final void Function(bool)? onChanged; @override - State createState() => _FavoriteToggleState(); + ConsumerState createState() => _FavoriteToggleState(); } -class _FavoriteToggleState extends State { +class _FavoriteToggleState extends ConsumerState { late bool _isActive; late Color _color; late void Function(bool)? _onChanged; @@ -36,9 +38,9 @@ class _FavoriteToggleState extends State { @override void initState() { on = widget.on ?? - Theme.of(context).extension()!.favoriteStarActive; + ref.read(colorThemeProvider.state).state.favoriteStarActive; off = widget.off ?? - Theme.of(context).extension()!.favoriteStarInactive; + ref.read(colorThemeProvider.state).state.favoriteStarInactive; _isActive = widget.initialState; _color = _isActive ? on : off; _onChanged = widget.onChanged; From 13ec6fdb8ef77f35e9277f51116cd6b429e56f2a Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 23 Sep 2022 07:46:57 -0600 Subject: [PATCH 3/9] text layout fix --- .../startup_wallet_selection_view.dart | 95 ++++++++++--------- 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart index 54e2d3c76..5d9f2edb1 100644 --- a/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart +++ b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart @@ -111,54 +111,55 @@ class _StartupWalletSelectionViewState const SizedBox( width: 12, ), - Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - manager.walletName, - style: - STextStyles.titleBold12(context), - ), - // const SizedBox( - // height: 2, - // ), - // FutureBuilder( - // future: manager.totalBalance, - // builder: (builderContext, - // AsyncSnapshot snapshot) { - // if (snapshot.connectionState == - // ConnectionState.done && - // snapshot.hasData) { - // return Text( - // "${Format.localizedStringAsFixed( - // value: snapshot.data!, - // locale: ref.watch( - // localeServiceChangeNotifierProvider - // .select((value) => - // value.locale)), - // decimalPlaces: 8, - // )} ${manager.coin.ticker}", - // style: STextStyles.itemSubtitle(context), - // ); - // } else { - // return AnimatedText( - // stringsToLoopThrough: const [ - // "Loading balance", - // "Loading balance.", - // "Loading balance..", - // "Loading balance..." - // ], - // style: STextStyles.itemSubtitle(context), - // ); - // } - // }, - // ), - ], + Expanded( + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + manager.walletName, + style: STextStyles.titleBold12( + context), + ), + // const SizedBox( + // height: 2, + // ), + // FutureBuilder( + // future: manager.totalBalance, + // builder: (builderContext, + // AsyncSnapshot snapshot) { + // if (snapshot.connectionState == + // ConnectionState.done && + // snapshot.hasData) { + // return Text( + // "${Format.localizedStringAsFixed( + // value: snapshot.data!, + // locale: ref.watch( + // localeServiceChangeNotifierProvider + // .select((value) => + // value.locale)), + // decimalPlaces: 8, + // )} ${manager.coin.ticker}", + // style: STextStyles.itemSubtitle(context), + // ); + // } else { + // return AnimatedText( + // stringsToLoopThrough: const [ + // "Loading balance", + // "Loading balance.", + // "Loading balance..", + // "Loading balance..." + // ], + // style: STextStyles.itemSubtitle(context), + // ); + // } + // }, + // ), + ], + ), ), - const Spacer(), SizedBox( height: 20, width: 20, From 3bf94578e60f676a98599a486155277550765340 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 23 Sep 2022 08:04:21 -0600 Subject: [PATCH 4/9] widget tests fix for updated color themes --- .../app_bar_icon_button_test.dart | 10 +++-- .../draggable_switch_button_test.dart | 20 ++++++++-- test/widget_tests/custom_pin_put_test.dart | 39 ++++++++++++++++--- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/test/widget_tests/custom_buttons/app_bar_icon_button_test.dart b/test/widget_tests/custom_buttons/app_bar_icon_button_test.dart index 756547206..36179deaf 100644 --- a/test/widget_tests/custom_buttons/app_bar_icon_button_test.dart +++ b/test/widget_tests/custom_buttons/app_bar_icon_button_test.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:stackwallet/utilities/theme/color_theme.dart'; -import 'package:stackwallet/utilities/theme/stack_theme.dart'; +import 'package:stackwallet/utilities/theme/light_colors.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; void main() { - StackTheme.instance.setTheme(ThemeType.light); testWidgets("AppBarIconButton test", (tester) async { int buttonPressedCount = 0; final button = AppBarIconButton( @@ -22,6 +21,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: Material( child: button, ), diff --git a/test/widget_tests/custom_buttons/draggable_switch_button_test.dart b/test/widget_tests/custom_buttons/draggable_switch_button_test.dart index def9296f4..d8366a1f0 100644 --- a/test/widget_tests/custom_buttons/draggable_switch_button_test.dart +++ b/test/widget_tests/custom_buttons/draggable_switch_button_test.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:stackwallet/utilities/theme/color_theme.dart'; -import 'package:stackwallet/utilities/theme/stack_theme.dart'; +import 'package:stackwallet/utilities/theme/light_colors.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; void main() { - StackTheme.instance.setTheme(ThemeType.light); testWidgets("DraggableSwitchButton tapped", (tester) async { bool? isButtonOn = false; final button = DraggableSwitchButton( @@ -18,6 +17,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: button, ), ); @@ -40,6 +44,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: SizedBox( width: 200, height: 60, @@ -67,6 +76,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: SizedBox( width: 200, height: 60, diff --git a/test/widget_tests/custom_pin_put_test.dart b/test/widget_tests/custom_pin_put_test.dart index 6d30bd323..d3a449865 100644 --- a/test/widget_tests/custom_pin_put_test.dart +++ b/test/widget_tests/custom_pin_put_test.dart @@ -1,20 +1,24 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:stackwallet/utilities/theme/color_theme.dart'; -import 'package:stackwallet/utilities/theme/stack_theme.dart'; +import 'package:stackwallet/utilities/theme/light_colors.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart'; import 'package:stackwallet/widgets/custom_pin_put/pin_keyboard.dart'; void main() { - StackTheme.instance.setTheme(ThemeType.light); group("CustomPinPut tests", () { testWidgets("CustomPinPut with 4 fields builds correctly", (tester) async { const pinPut = CustomPinPut(fieldsCount: 4); await tester.pumpWidget( - const MaterialApp( - home: Material( + MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), + home: const Material( child: pinPut, ), ), @@ -37,6 +41,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: Material( child: pinPut, ), @@ -74,6 +83,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: Material( child: pinPut, ), @@ -100,6 +114,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: Material( child: pinPut, ), @@ -126,6 +145,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: Material( child: pinPut, ), @@ -152,6 +176,11 @@ void main() { await tester.pumpWidget( MaterialApp( + theme: ThemeData( + extensions: [ + StackColors.fromStackColorTheme(LightColors()), + ], + ), home: Material( child: keyboard, ), From 4e0c99c6f721666a45e9e2a09cdd83906f492c55 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 23 Sep 2022 08:33:44 -0600 Subject: [PATCH 5/9] dynamic themed icons --- lib/main.dart | 26 ++++----- .../subviews/contact_popup.dart | 2 +- .../exchange_view/trade_details_view.dart | 6 +- lib/pages/home_view/home_view.dart | 4 +- lib/pages/intro_view.dart | 2 +- .../wallet_view/sub_widgets/tx_icon.dart | 16 +++--- .../sub_widgets/wallet_navigation_bar.dart | 2 +- lib/pages/wallet_view/wallet_view.dart | 2 +- .../home/desktop_menu.dart | 2 +- .../home/my_stack_view/my_stack_view.dart | 2 +- lib/utilities/assets.dart | 57 +++++++++++-------- lib/utilities/theme/color_theme.dart | 2 + lib/utilities/theme/dark_colors.dart | 3 + lib/utilities/theme/light_colors.dart | 3 + lib/utilities/theme/stack_colors.dart | 7 +++ lib/widgets/address_book_card.dart | 2 +- lib/widgets/trade_card.dart | 12 ++-- 17 files changed, 88 insertions(+), 62 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 9075a5343..914fe59c2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -51,7 +51,6 @@ import 'package:stackwallet/services/notifications_api.dart'; import 'package:stackwallet/services/notifications_service.dart'; import 'package:stackwallet/services/trade_service.dart'; import 'package:stackwallet/services/wallets.dart'; -import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/db_version_migration.dart'; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; @@ -145,17 +144,6 @@ 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": - Assets.theme = ThemeType.dark; - break; - case "light": - default: - Assets.theme = ThemeType.light; - } // SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, // overlays: [SystemUiOverlay.bottom]); @@ -360,6 +348,18 @@ class _MaterialAppWithThemeState extends ConsumerState @override void initState() { + final colorScheme = DB.instance + .get(boxName: DB.boxNameTheme, key: "colorScheme") as String?; + + ThemeType themeType; + switch (colorScheme) { + case "dark": + themeType = ThemeType.dark; + break; + case "light": + default: + themeType = ThemeType.light; + } loadingCompleter = Completer(); WidgetsBinding.instance.addObserver(this); // load locale and prefs @@ -373,7 +373,7 @@ class _MaterialAppWithThemeState extends ConsumerState WidgetsBinding.instance.addPostFrameCallback((_) async { ref.read(colorThemeProvider.state).state = StackColors.fromStackColorTheme( - Assets.theme! == ThemeType.dark ? DarkColors() : LightColors()); + themeType == ThemeType.dark ? DarkColors() : LightColors()); if (Platform.isAndroid) { // fetch open file if it exists diff --git a/lib/pages/address_book_views/subviews/contact_popup.dart b/lib/pages/address_book_views/subviews/contact_popup.dart index 2cffe50e9..a14581c0a 100644 --- a/lib/pages/address_book_views/subviews/contact_popup.dart +++ b/lib/pages/address_book_views/subviews/contact_popup.dart @@ -107,7 +107,7 @@ class ContactPopUp extends ConsumerWidget { child: contact.id == "default" ? Center( child: SvgPicture.asset( - Assets.svg.stackIcon, + Assets.svg.stackIcon(context), width: 20, ), ) diff --git a/lib/pages/exchange_view/trade_details_view.dart b/lib/pages/exchange_view/trade_details_view.dart index 6405d6c43..439b0f659 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -108,11 +108,11 @@ class _TradeDetailsViewState extends ConsumerState { case ChangeNowTransactionStatus.Sending: case ChangeNowTransactionStatus.Refunded: case ChangeNowTransactionStatus.Verifying: - return Assets.svg.txExchangePending; + return Assets.svg.txExchangePending(context); case ChangeNowTransactionStatus.Finished: - return Assets.svg.txExchange; + return Assets.svg.txExchange(context); case ChangeNowTransactionStatus.Failed: - return Assets.svg.txExchangeFailed; + return Assets.svg.txExchangeFailed(context); } } diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index 07e2199af..b561207ab 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -143,7 +143,7 @@ class _HomeViewState extends ConsumerState { GestureDetector( onTap: _hiddenOptions, child: SvgPicture.asset( - Assets.svg.stackIcon, + Assets.svg.stackIcon(context), width: 24, height: 24, ), @@ -174,7 +174,7 @@ class _HomeViewState extends ConsumerState { icon: SvgPicture.asset( ref.watch(notificationsProvider .select((value) => value.hasUnreadNotifications)) - ? Assets.svg.bellNew + ? Assets.svg.bellNew(context) : Assets.svg.bell, width: 20, height: 20, diff --git a/lib/pages/intro_view.dart b/lib/pages/intro_view.dart index fa2ef0e64..ca8725886 100644 --- a/lib/pages/intro_view.dart +++ b/lib/pages/intro_view.dart @@ -110,7 +110,7 @@ class _IntroViewState extends State { width: 130, height: 130, child: SvgPicture.asset( - Assets.svg.stackIcon, + Assets.svg.stackIcon(context), ), ), const Spacer( diff --git a/lib/pages/wallet_view/sub_widgets/tx_icon.dart b/lib/pages/wallet_view/sub_widgets/tx_icon.dart index 45b4e610d..6222301a6 100644 --- a/lib/pages/wallet_view/sub_widgets/tx_icon.dart +++ b/lib/pages/wallet_view/sub_widgets/tx_icon.dart @@ -9,7 +9,8 @@ class TxIcon extends StatelessWidget { static const Size size = Size(32, 32); - String _getAssetName(bool isCancelled, bool isReceived, bool isPending) { + String _getAssetName( + bool isCancelled, bool isReceived, bool isPending, BuildContext context) { if (!isReceived && transaction.subType == "mint") { if (isCancelled) { return Assets.svg.anonymizeFailed; @@ -22,20 +23,20 @@ class TxIcon extends StatelessWidget { if (isReceived) { if (isCancelled) { - return Assets.svg.receiveCancelled; + return Assets.svg.receiveCancelled(context); } if (isPending) { - return Assets.svg.receivePending; + return Assets.svg.receivePending(context); } - return Assets.svg.receive; + return Assets.svg.receive(context); } else { if (isCancelled) { - return Assets.svg.sendCancelled; + return Assets.svg.sendCancelled(context); } if (isPending) { - return Assets.svg.sendPending; + return Assets.svg.sendPending(context); } - return Assets.svg.send; + return Assets.svg.send(context); } } @@ -52,6 +53,7 @@ class TxIcon extends StatelessWidget { transaction.isCancelled, txIsReceived, !transaction.confirmedStatus, + context, ), width: size.width, height: size.height, diff --git a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart index 82375fc41..b82992673 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart @@ -178,7 +178,7 @@ class WalletNavigationBar extends StatelessWidget { children: [ const Spacer(), SvgPicture.asset( - Assets.svg.exchange, + Assets.svg.exchange(context), width: 24, height: 24, ), diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index b2069712d..95dfc4a98 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -436,7 +436,7 @@ class _WalletViewState extends ConsumerState { icon: SvgPicture.asset( ref.watch(notificationsProvider.select((value) => value.hasUnreadNotificationsFor(walletId))) - ? Assets.svg.bellNew + ? Assets.svg.bellNew(context) : Assets.svg.bell, width: 20, height: 20, diff --git a/lib/pages_desktop_specific/home/desktop_menu.dart b/lib/pages_desktop_specific/home/desktop_menu.dart index 81ba00a16..b71c20f6e 100644 --- a/lib/pages_desktop_specific/home/desktop_menu.dart +++ b/lib/pages_desktop_specific/home/desktop_menu.dart @@ -54,7 +54,7 @@ class _DesktopMenuState extends ConsumerState { width: _width == expandedWidth ? 70 : 32, height: _width == expandedWidth ? 70 : 32, child: SvgPicture.asset( - Assets.svg.stackIcon, + Assets.svg.stackIcon(context), ), ), const SizedBox( diff --git a/lib/pages_desktop_specific/home/my_stack_view/my_stack_view.dart b/lib/pages_desktop_specific/home/my_stack_view/my_stack_view.dart index 4853339d5..b7860542a 100644 --- a/lib/pages_desktop_specific/home/my_stack_view/my_stack_view.dart +++ b/lib/pages_desktop_specific/home/my_stack_view/my_stack_view.dart @@ -40,7 +40,7 @@ class _MyStackViewState extends ConsumerState { width: 32, height: 32, child: SvgPicture.asset( - Assets.svg.stackIcon, + Assets.svg.stackIcon(context), ), ), const SizedBox( diff --git a/lib/utilities/assets.dart b/lib/utilities/assets.dart index 635bc91f4..525513f52 100644 --- a/lib/utilities/assets.dart +++ b/lib/utilities/assets.dart @@ -1,12 +1,12 @@ +import 'package:flutter/material.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/theme/color_theme.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; abstract class Assets { static const svg = _SVG(); static const png = _PNG(); static const lottie = _ANIMATIONS(); static const socials = _SOCIALS(); - static ThemeType? theme; } class _SOCIALS { @@ -21,11 +21,39 @@ class _SOCIALS { class _SVG { const _SVG(); + String bellNew(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/bell-new.svg"; + String stackIcon(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/stack-icon1.svg"; + String exchange(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/exchange-2.svg"; + String buy(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/buy-coins-icon.svg"; + + String receive(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-icon-receive.svg"; + String receivePending(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-icon-receive-pending.svg"; + String receiveCancelled(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-icon-receive-failed.svg"; + + String send(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-icon-send.svg"; + String sendPending(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-icon-send-pending.svg"; + String sendCancelled(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-icon-send-failed.svg"; + + String txExchange(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-exchange-icon.svg"; + String txExchangePending(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-exchange-icon-pending.svg"; + String txExchangeFailed(BuildContext context) => + "assets/svg/${Theme.of(context).extension()!.themeType.name}/tx-exchange-icon-failed.svg"; + String get plus => "assets/svg/plus.svg"; String get gear => "assets/svg/gear.svg"; String get bell => "assets/svg/bell.svg"; - String get bellNew => "assets/svg/${Assets.theme!.name}/bell-new.svg"; - String get stackIcon => "assets/svg/${Assets.theme!.name}/stack-icon1.svg"; String get arrowLeft => "assets/svg/arrow-left-fa.svg"; String get star => "assets/svg/star.svg"; String get copy => "assets/svg/copy-fa.svg"; @@ -37,8 +65,6 @@ class _SVG { String get bars => "assets/svg/bars.svg"; String get filter => "assets/svg/filter.svg"; String get pending => "assets/svg/pending.svg"; - String get exchange => "assets/svg/${Assets.theme!.name}/exchange-2.svg"; - String get buy => "assets/svg/${Assets.theme!.name}/buy-coins-icon.svg"; String get radio => "assets/svg/signal-stream.svg"; String get arrowRotate => "assets/svg/arrow-rotate.svg"; String get arrowRotate2 => "assets/svg/arrow-rotate2.svg"; @@ -92,28 +118,9 @@ class _SVG { String get anonymizePending => "assets/svg/tx-icon-anonymize-pending.svg"; String get anonymizeFailed => "assets/svg/tx-icon-anonymize-failed.svg"; - String get receive => "assets/svg/${Assets.theme!.name}/tx-icon-receive.svg"; - String get receivePending => - "assets/svg/${Assets.theme!.name}/tx-icon-receive-pending.svg"; - String get receiveCancelled => - "assets/svg/${Assets.theme!.name}/tx-icon-receive-failed.svg"; - - String get send => "assets/svg/${Assets.theme!.name}/tx-icon-send.svg"; - String get sendPending => - "assets/svg/${Assets.theme!.name}/tx-icon-send-pending.svg"; - String get sendCancelled => - "assets/svg/${Assets.theme!.name}/tx-icon-send-failed.svg"; - String get ellipse1 => "assets/svg/Ellipse-43.svg"; String get ellipse2 => "assets/svg/Ellipse-42.svg"; - String get txExchange => - "assets/svg/${Assets.theme!.name}/tx-exchange-icon.svg"; - String get txExchangePending => - "assets/svg/${Assets.theme!.name}/tx-exchange-icon-pending.svg"; - String get txExchangeFailed => - "assets/svg/${Assets.theme!.name}/tx-exchange-icon-failed.svg"; - String get bitcoin => "assets/svg/coin_icons/Bitcoin.svg"; String get bitcoincash => "assets/svg/coin_icons/Bitcoincash.svg"; String get dogecoin => "assets/svg/coin_icons/Dogecoin.svg"; diff --git a/lib/utilities/theme/color_theme.dart b/lib/utilities/theme/color_theme.dart index 4e0c82ad4..32a462f9e 100644 --- a/lib/utilities/theme/color_theme.dart +++ b/lib/utilities/theme/color_theme.dart @@ -8,6 +8,8 @@ enum ThemeType { } abstract class StackColorTheme { + ThemeType get themeType; + Color get background; Color get overlay; diff --git a/lib/utilities/theme/dark_colors.dart b/lib/utilities/theme/dark_colors.dart index 7b8007e17..ee7551a27 100644 --- a/lib/utilities/theme/dark_colors.dart +++ b/lib/utilities/theme/dark_colors.dart @@ -2,6 +2,9 @@ import 'package:flutter/material.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; class DarkColors extends StackColorTheme { + @override + ThemeType get themeType => ThemeType.dark; + @override Color get background => const Color(0xFF2A2D34); @override diff --git a/lib/utilities/theme/light_colors.dart b/lib/utilities/theme/light_colors.dart index 8e835164d..994a876d8 100644 --- a/lib/utilities/theme/light_colors.dart +++ b/lib/utilities/theme/light_colors.dart @@ -2,6 +2,9 @@ import 'package:flutter/material.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; class LightColors extends StackColorTheme { + @override + ThemeType get themeType => ThemeType.light; + @override Color get background => const Color(0xFFF7F7F7); @override diff --git a/lib/utilities/theme/stack_colors.dart b/lib/utilities/theme/stack_colors.dart index a2e59052c..134439f51 100644 --- a/lib/utilities/theme/stack_colors.dart +++ b/lib/utilities/theme/stack_colors.dart @@ -4,6 +4,8 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; class StackColors extends ThemeExtension { + final ThemeType themeType; + final Color background; final Color overlay; @@ -168,6 +170,7 @@ class StackColors extends ThemeExtension { final Color myStackContactIconBG; StackColors({ + required this.themeType, required this.background, required this.overlay, required this.accentColorBlue, @@ -299,6 +302,7 @@ class StackColors extends ThemeExtension { factory StackColors.fromStackColorTheme(StackColorTheme colorTheme) { return StackColors( + themeType: colorTheme.themeType, background: colorTheme.background, overlay: colorTheme.overlay, accentColorBlue: colorTheme.accentColorBlue, @@ -433,6 +437,7 @@ class StackColors extends ThemeExtension { @override ThemeExtension copyWith({ + ThemeType? themeType, Color? background, Color? overlay, Color? accentColorBlue, @@ -562,6 +567,7 @@ class StackColors extends ThemeExtension { Color? myStackContactIconBG, }) { return StackColors( + themeType: themeType ?? this.themeType, background: background ?? this.background, overlay: overlay ?? this.overlay, accentColorBlue: accentColorBlue ?? this.accentColorBlue, @@ -737,6 +743,7 @@ class StackColors extends ThemeExtension { } return StackColors( + themeType: other.themeType, background: Color.lerp( background, other.background, diff --git a/lib/widgets/address_book_card.dart b/lib/widgets/address_book_card.dart index 5368310fa..7a2fca19f 100644 --- a/lib/widgets/address_book_card.dart +++ b/lib/widgets/address_book_card.dart @@ -92,7 +92,7 @@ class _AddressBookCardState extends ConsumerState { child: contact.id == "default" ? Center( child: SvgPicture.asset( - Assets.svg.stackIcon, + Assets.svg.stackIcon(context), width: 20, ), ) diff --git a/lib/widgets/trade_card.dart b/lib/widgets/trade_card.dart index 9038f6d21..ab58e2293 100644 --- a/lib/widgets/trade_card.dart +++ b/lib/widgets/trade_card.dart @@ -19,7 +19,7 @@ class TradeCard extends ConsumerWidget { final ExchangeTransaction trade; final VoidCallback onTap; - String _fetchIconAssetForStatus(String statusString) { + String _fetchIconAssetForStatus(String statusString, BuildContext context) { ChangeNowTransactionStatus? status; try { if (statusString.toLowerCase().startsWith("waiting")) { @@ -38,11 +38,11 @@ class TradeCard extends ConsumerWidget { case ChangeNowTransactionStatus.Sending: case ChangeNowTransactionStatus.Refunded: case ChangeNowTransactionStatus.Verifying: - return Assets.svg.txExchangePending; + return Assets.svg.txExchangePending(context); case ChangeNowTransactionStatus.Finished: - return Assets.svg.txExchange; + return Assets.svg.txExchange(context); case ChangeNowTransactionStatus.Failed: - return Assets.svg.txExchangeFailed; + return Assets.svg.txExchangeFailed(context); } } @@ -62,7 +62,9 @@ class TradeCard extends ConsumerWidget { child: Center( child: SvgPicture.asset( _fetchIconAssetForStatus( - trade.statusObject?.status.name ?? trade.statusString), + trade.statusObject?.status.name ?? trade.statusString, + context, + ), width: 32, height: 32, ), From ef7881b4d0149090ee22ac891ae7e3a9f8b2adf6 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 23 Sep 2022 08:45:16 -0600 Subject: [PATCH 6/9] remove old unused file --- lib/utilities/theme/stack_theme.dart | 120 --------------------------- 1 file changed, 120 deletions(-) delete mode 100644 lib/utilities/theme/stack_theme.dart diff --git a/lib/utilities/theme/stack_theme.dart b/lib/utilities/theme/stack_theme.dart deleted file mode 100644 index 5aa9d96ad..000000000 --- a/lib/utilities/theme/stack_theme.dart +++ /dev/null @@ -1,120 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/theme/color_theme.dart'; -import 'package:stackwallet/utilities/theme/dark_colors.dart'; -import 'package:stackwallet/utilities/theme/light_colors.dart'; - -class StackTheme { - StackTheme._(); - static final StackTheme _instance = StackTheme._(); - static StackTheme get instance => _instance; - - late StackColorTheme color; - late ThemeType theme; - - void setTheme(ThemeType theme) { - this.theme = theme; - switch (theme) { - case ThemeType.light: - color = LightColors(); - break; - case ThemeType.dark: - color = DarkColors(); - break; - } - } - - BoxShadow get standardBoxShadow => BoxShadow( - color: color.shadow, - spreadRadius: 3, - blurRadius: 4, - ); - - Color colorForCoin(Coin coin) { - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinTestNet: - return _coin.bitcoin; - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - return _coin.bitcoincash; - case Coin.dogecoin: - case Coin.dogecoinTestNet: - return _coin.dogecoin; - case Coin.epicCash: - return _coin.epicCash; - case Coin.firo: - case Coin.firoTestNet: - return _coin.firo; - case Coin.monero: - return _coin.monero; - case Coin.namecoin: - return _coin.namecoin; - // case Coin.wownero: - // return wownero; - } - } - - Color colorForStatus(ChangeNowTransactionStatus status) { - switch (status) { - case ChangeNowTransactionStatus.New: - case ChangeNowTransactionStatus.Waiting: - case ChangeNowTransactionStatus.Confirming: - case ChangeNowTransactionStatus.Exchanging: - case ChangeNowTransactionStatus.Sending: - case ChangeNowTransactionStatus.Verifying: - return const Color(0xFFD3A90F); - case ChangeNowTransactionStatus.Finished: - return color.accentColorGreen; - case ChangeNowTransactionStatus.Failed: - return color.accentColorRed; - case ChangeNowTransactionStatus.Refunded: - return color.textSubtitle2; - } - } - - ButtonStyle? getPrimaryEnabledButtonColor(BuildContext context) => - Theme.of(context).textButtonTheme.style?.copyWith( - backgroundColor: MaterialStateProperty.all( - color.buttonBackPrimary, - ), - ); - - ButtonStyle? getPrimaryDisabledButtonColor(BuildContext context) => - Theme.of(context).textButtonTheme.style?.copyWith( - backgroundColor: MaterialStateProperty.all( - color.buttonBackPrimaryDisabled, - ), - ); - - ButtonStyle? getSecondaryEnabledButtonColor(BuildContext context) => - Theme.of(context).textButtonTheme.style?.copyWith( - backgroundColor: MaterialStateProperty.all( - color.buttonBackSecondary, - ), - ); - - ButtonStyle? getSmallSecondaryEnabledButtonColor(BuildContext context) => - Theme.of(context).textButtonTheme.style?.copyWith( - backgroundColor: MaterialStateProperty.all( - color.textFieldDefaultBG, - ), - ); - - ButtonStyle? getDesktopMenuButtonColor(BuildContext context) => - Theme.of(context).textButtonTheme.style?.copyWith( - backgroundColor: MaterialStateProperty.all( - color.popupBG, - ), - ); - - ButtonStyle? getDesktopMenuButtonColorSelected(BuildContext context) => - Theme.of(context).textButtonTheme.style?.copyWith( - backgroundColor: MaterialStateProperty.all( - color.textFieldDefaultBG, - ), - ); - - static const _coin = CoinThemeColor(); -} From befeb55d13a4b45db41973ec99d846b24b5f81c9 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 23 Sep 2022 10:48:27 -0600 Subject: [PATCH 7/9] namecoin validate address bugfix --- lib/utilities/address_utils.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utilities/address_utils.dart b/lib/utilities/address_utils.dart index dcdee319b..5dd805941 100644 --- a/lib/utilities/address_utils.dart +++ b/lib/utilities/address_utils.dart @@ -3,9 +3,9 @@ import 'dart:convert'; import 'package:bitcoindart/bitcoindart.dart'; import 'package:crypto/crypto.dart'; import 'package:flutter_libepiccash/epic_cash.dart'; +import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; -import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'; import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; @@ -54,7 +54,7 @@ class AddressUtils { return RegExp("[a-zA-Z0-9]{95}").hasMatch(address) || RegExp("[a-zA-Z0-9]{106}").hasMatch(address); case Coin.namecoin: - return Address.validateAddress(address, namecoin); + return Address.validateAddress(address, namecoin, namecoin.bech32!); case Coin.bitcoinTestNet: return Address.validateAddress(address, testnet); case Coin.bitcoincashTestnet: From 5baeb8db7738a1815937c2afe39d8eb63fcca8ca Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Fri, 23 Sep 2022 16:38:05 -0600 Subject: [PATCH 8/9] change build --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index cd236669b..e7d138729 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,7 @@ description: Stack Wallet # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.4.47+62 +version: 1.4.48+63 environment: sdk: ">=2.17.0 <3.0.0" From 6f11f5c6efc78aadebbfea5c51debcacd90f8b27 Mon Sep 17 00:00:00 2001 From: ryleedavis Date: Fri, 23 Sep 2022 19:26:09 -0600 Subject: [PATCH 9/9] commented out bch --- lib/utilities/address_utils.dart | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/utilities/address_utils.dart b/lib/utilities/address_utils.dart index 5dd805941..6acee305d 100644 --- a/lib/utilities/address_utils.dart +++ b/lib/utilities/address_utils.dart @@ -3,7 +3,7 @@ import 'dart:convert'; import 'package:bitcoindart/bitcoindart.dart'; import 'package:crypto/crypto.dart'; import 'package:flutter_libepiccash/epic_cash.dart'; -import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'; +// import 'package:stackwallet/services/coins/bitcoincash/bitcoincash_wallet.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/firo/firo_wallet.dart'; import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart'; @@ -42,8 +42,8 @@ class AddressUtils { switch (coin) { case Coin.bitcoin: return Address.validateAddress(address, bitcoin); - case Coin.bitcoincash: - return Address.validateAddress(address, bitcoincash); + // case Coin.bitcoincash: + // return Address.validateAddress(address, bitcoincash); case Coin.dogecoin: return Address.validateAddress(address, dogecoin); case Coin.epicCash: @@ -57,8 +57,8 @@ class AddressUtils { return Address.validateAddress(address, namecoin, namecoin.bech32!); case Coin.bitcoinTestNet: return Address.validateAddress(address, testnet); - case Coin.bitcoincashTestnet: - return Address.validateAddress(address, bitcoincashtestnet); + // case Coin.bitcoincashTestnet: + // return Address.validateAddress(address, bitcoincashtestnet); case Coin.firoTestNet: return Address.validateAddress(address, firoTestNetwork); case Coin.dogecoinTestNet: