From 1831ebf435867c84b3252a4684f644052cf68b09 Mon Sep 17 00:00:00 2001 From: Godwin Asuquo Date: Thu, 9 Feb 2023 20:29:38 +0200 Subject: [PATCH 01/15] Remove drawer from mac os --- assets/images/desktop_menu.png | Bin 0 -> 663 bytes .../screens/dashboard/desktop_dashboard_page.dart | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) create mode 100644 assets/images/desktop_menu.png diff --git a/assets/images/desktop_menu.png b/assets/images/desktop_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..38fc3886664e5e6180383934c43a8676d2770eeb GIT binary patch literal 663 zcmV;I0%-k-P)kBO)7O z^5f5MbMWqkAD$9e-}zQ^96N#$NI4S02BRD2fEAb7cVsP~8F=bc`=5gGje@_YF4RC!VIL}2aySP!V4+?;Bti4p-3 zscBd;w=RS9fE*d4c{~ECyTcKc01@^uM7cozfyzO# z_A3S1@%E};rxMWlu-~%suRw{|T7A&V<_im?cZa*E_omjnzT4dW`b2O4>$d+Yvoo|H zDwU~+xIS8%R%^Q6=nh|^+ Date: Fri, 10 Feb 2023 19:45:48 +0200 Subject: [PATCH 02/15] Update trailing icon to open transaction page --- assets/images/solid_desktop_menu.png | Bin 0 -> 390 bytes lib/di.dart | 2 ++ lib/router.dart | 7 ++++++ lib/routes.dart | 1 + .../dashboard/desktop_dashboard_page.dart | 21 +++++++++++++++++- .../desktop_dashboard_view.dart | 3 +++ 6 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 assets/images/solid_desktop_menu.png diff --git a/assets/images/solid_desktop_menu.png b/assets/images/solid_desktop_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..d793803da134d885e089e6993a925df8f810d151 GIT binary patch literal 390 zcmV;10eSw3P)8w54%xz5D!itco$nZ&X_#N%xnF1EjA8S*9g8nEvF%yd$ z7=S4Z%p`x%;|DtuQUuxT@|HyWyO;Ck&rT2f(>pPWfa zJNR6%d%YU*_`Nfw-n+c!idh6&U;?{+>>M_VD|=(E4;lkR$OW_4&J-4MfMV0aoa@^I kY!IzdV$DO-9T;ij1priDa{-xuivR!s07*qoM6N<$f_A~1=l}o! literal 0 HcmV?d00001 diff --git a/lib/di.dart b/lib/di.dart index 067c2f19b..6180df576 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -8,6 +8,7 @@ import 'package:cake_wallet/ionia/ionia_gift_card.dart'; import 'package:cake_wallet/ionia/ionia_tip.dart'; import 'package:cake_wallet/src/screens/buy/onramper_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; +import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart'; import 'package:cake_wallet/src/screens/settings/display_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/other_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/privacy_page.dart'; @@ -367,6 +368,7 @@ Future setup( BalancePage(dashboardViewModel: getIt.get(), settingsStore: getIt.get())); getIt.registerFactory(() => DashboardPage( balancePage: getIt.get(), walletViewModel: getIt.get(), addressListViewModel: getIt.get())); + getIt.registerFactory(() => TransactionsPage(dashboardViewModel: getIt.get())); getIt.registerFactory(() => ReceivePage( addressListViewModel: getIt.get())); getIt.registerFactory(() => AddressPage( diff --git a/lib/router.dart b/lib/router.dart index 83d247e76..7a0f71e2d 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -6,6 +6,7 @@ import 'package:cake_wallet/src/screens/buy/buy_webview_page.dart'; import 'package:cake_wallet/src/screens/buy/onramper_page.dart'; import 'package:cake_wallet/src/screens/buy/pre_order_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_actions.dart'; +import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart'; import 'package:cake_wallet/src/screens/settings/desktop_settings/dashboard_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/display_settings_page.dart'; import 'package:cake_wallet/src/screens/settings/other_settings_page.dart'; @@ -526,6 +527,12 @@ Route createRoute(RouteSettings settings) { case Routes.empty_no_route: return MaterialPageRoute( builder: (_) => SizedBox.shrink()); + + case Routes.transactionsPage: + return CupertinoPageRoute( + settings: settings, + fullscreenDialog: true, + builder: (_) => getIt.get()); default: return MaterialPageRoute( diff --git a/lib/routes.dart b/lib/routes.dart index 26bc9b3bb..8bf5603e0 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -84,4 +84,5 @@ class Routes { static const otherSettingsPage = '/other_settings_page'; static const advancedPrivacySettings = '/advanced_privacy_settings'; static const desktop_actions = '/desktop_actions'; + static const transactionsPage = '/transactions_page'; } diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index 5d529c39b..4b8a4bb44 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -4,6 +4,7 @@ import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; +import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart'; import 'package:cake_wallet/src/screens/yat_emoji_id.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/themes/theme_base.dart'; @@ -57,7 +58,25 @@ class DesktopDashboardPage extends BasePage { @override Widget trailing(BuildContext context) { - return Image.asset('assets/images/desktop_menu.png', color: Theme.of(context).highlightColor); + final iconPath = Image.asset('assets/images/solid_desktop_menu.png', + color: Theme.of(context).accentTextTheme.headline2!.backgroundColor!); + return InkWell( + onTap: () { + String? currentPath; + + desktopKey.currentState?.popUntil((route) { + currentPath = route.settings.name; + return true; + }); + + if (currentPath == Routes.transactionsPage) { + return Navigator.pop(desktopKey.currentContext!); + } + + desktopKey.currentState!.pushNamed(Routes.transactionsPage); + }, + child: iconPath, + ); } final BalancePage balancePage; diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart index dccf6c441..7e2bba777 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart @@ -2,6 +2,8 @@ import 'package:cake_wallet/routes.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/router.dart' as Router; +GlobalKey desktopKey = GlobalKey(); + class DesktopDashboardView extends StatelessWidget { final Widget balancePage; @@ -19,6 +21,7 @@ class DesktopDashboardView extends StatelessWidget { Expanded( flex: 5, child: Navigator( + key: desktopKey, initialRoute: Routes.desktop_actions, onGenerateRoute: (settings) => Router.createRoute(settings), onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { From bdfe070f8dba385854063da56f9dfecbafcb3529 Mon Sep 17 00:00:00 2001 From: Godwin Asuquo Date: Sat, 11 Feb 2023 00:32:26 +0200 Subject: [PATCH 03/15] Refactor sidebar state management --- ... => desktop_transactions_outline_icon.png} | Bin ...ng => desktop_transactions_solid_icon.png} | Bin lib/di.dart | 4 + lib/src/screens/dashboard/dashboard_page.dart | 5 + .../dashboard/desktop_dashboard_page.dart | 27 +++-- .../desktop_sidebar/side_menu_controller.dart | 35 ------- .../desktop_sidebar/side_menu_item.dart | 65 +++--------- .../desktop_sidebar_wrapper.dart | 98 ++++++++++-------- .../dashboard/widgets/transactions_page.dart | 1 + .../dashboard_settings_page.dart | 18 ++-- .../dashboard/desktop_sidebar_view_model.dart | 33 ++++++ 11 files changed, 140 insertions(+), 146 deletions(-) rename assets/images/{desktop_menu.png => desktop_transactions_outline_icon.png} (100%) rename assets/images/{solid_desktop_menu.png => desktop_transactions_solid_icon.png} (100%) delete mode 100644 lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_controller.dart create mode 100644 lib/view_model/dashboard/desktop_sidebar_view_model.dart diff --git a/assets/images/desktop_menu.png b/assets/images/desktop_transactions_outline_icon.png similarity index 100% rename from assets/images/desktop_menu.png rename to assets/images/desktop_transactions_outline_icon.png diff --git a/assets/images/solid_desktop_menu.png b/assets/images/desktop_transactions_solid_icon.png similarity index 100% rename from assets/images/solid_desktop_menu.png rename to assets/images/desktop_transactions_solid_icon.png diff --git a/lib/di.dart b/lib/di.dart index 6180df576..c5bf8d0ea 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -19,6 +19,7 @@ import 'package:cake_wallet/src/screens/ionia/cards/ionia_more_options_page.dart import 'package:cake_wallet/src/screens/settings/connection_sync_page.dart'; import 'package:cake_wallet/themes/theme_list.dart'; import 'package:cake_wallet/utils/payment_request.dart'; +import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:cake_wallet/view_model/ionia/ionia_auth_view_model.dart'; import 'package:cake_wallet/view_model/ionia/ionia_buy_card_view_model.dart'; import 'package:cake_wallet/view_model/ionia/ionia_custom_tip_view_model.dart'; @@ -168,6 +169,7 @@ import 'package:cake_wallet/src/screens/receive/fullscreen_qr_page.dart'; import 'package:cake_wallet/core/wallet_loading_service.dart'; import 'package:cw_core/crypto_currency.dart'; + final getIt = GetIt.instance; var _isSetupFinished = false; @@ -832,6 +834,8 @@ Future setup( getIt.registerFactory(() => DesktopWalletSelectionDropDown(getIt.get())); + getIt.registerFactory(() => DesktopSidebarViewModel()); + getIt.registerFactoryParam( (IoniaAnyPayPaymentInfo paymentInfo, AnyPayPaymentCommittedInfo committedInfo) => IoniaPaymentStatusViewModel( diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 5e560cc01..4665751a7 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/entities/main_actions.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_dashboard_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart'; @@ -10,6 +11,7 @@ import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; +import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; @@ -37,6 +39,7 @@ class DashboardPage extends StatelessWidget { @override Widget build(BuildContext context) { + final desktopSidebarViewModel = getIt(); return Scaffold( body: ResponsiveLayoutUtil.instance.isMobile(context) ? _DashboardPageView( @@ -45,7 +48,9 @@ class DashboardPage extends StatelessWidget { addressListViewModel: addressListViewModel, ) : DesktopSidebarWrapper( + desktopSidebarViewModel: desktopSidebarViewModel, child: DesktopDashboardPage( + desktopSidebarViewModel: desktopSidebarViewModel, balancePage: balancePage, walletViewModel: walletViewModel, addressListViewModel: addressListViewModel, diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index 4b8a4bb44..ac5700af4 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -4,17 +4,18 @@ import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; -import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart'; import 'package:cake_wallet/src/screens/yat_emoji_id.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; +import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/balance_page.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator.dart'; import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart'; +import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/main.dart'; @@ -23,6 +24,7 @@ class DesktopDashboardPage extends BasePage { required this.balancePage, required this.walletViewModel, required this.addressListViewModel, + required this.desktopSidebarViewModel, }); @override @@ -58,8 +60,9 @@ class DesktopDashboardPage extends BasePage { @override Widget trailing(BuildContext context) { - final iconPath = Image.asset('assets/images/solid_desktop_menu.png', - color: Theme.of(context).accentTextTheme.headline2!.backgroundColor!); + final selectedIconPath = 'assets/images/desktop_transactions_solid_icon.png'; + final unselectedIconPath = 'assets/images/desktop_transactions_outline_icon.png'; + return InkWell( onTap: () { String? currentPath; @@ -70,18 +73,30 @@ class DesktopDashboardPage extends BasePage { }); if (currentPath == Routes.transactionsPage) { - return Navigator.pop(desktopKey.currentContext!); - } + desktopSidebarViewModel.resetSidebar(); + return; + } + desktopSidebarViewModel.onPageChange(SidebarItem.transactions); desktopKey.currentState!.pushNamed(Routes.transactionsPage); + }, - child: iconPath, + child: Observer( + builder: (_) { + return Image.asset( + desktopSidebarViewModel.currentPage == SidebarItem.transactions + ? selectedIconPath + : unselectedIconPath, + ); + }, + ), ); } final BalancePage balancePage; final DashboardViewModel walletViewModel; final WalletAddressListViewModel addressListViewModel; + final DesktopSidebarViewModel desktopSidebarViewModel; bool _isEffectsInstalled = false; StreamSubscription? _onInactiveSub; diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_controller.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_controller.dart deleted file mode 100644 index b56329966..000000000 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_controller.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'dart:async'; - -class SideMenuController { - late int _currentPage; - - int get currentPage => _currentPage; - - SideMenuController({int initialPage = 0}) { - _currentPage = initialPage; - } - final _streameController = StreamController.broadcast(); - - Stream get stream => _streameController.stream; - - void changePage(int index) { - _currentPage = index; - _streameController.sink.add(index); - } - - void dispose() { - _streameController.close(); - } - - void addListener(void Function(int) listener) { - _streameController.stream.listen(listener); - } - - void removeListener(void Function(int) listener) { - _streameController.stream.listen(listener).cancel(); - } -} - -class SideMenuGlobal { - static late SideMenuController controller; -} diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart index 5c3d0ea6b..f50cf6387 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart @@ -1,74 +1,39 @@ -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_controller.dart'; import 'package:flutter/material.dart'; -class SideMenuItem extends StatefulWidget { +class SideMenuItem extends StatelessWidget { const SideMenuItem({ Key? key, - this.onTap, + required this.onTap, required this.iconPath, - required this.priority, + required this.isSelected, }) : super(key: key); - final void Function(int, SideMenuController)? onTap; + final void Function() onTap; final String iconPath; - final int priority; - - @override - _SideMenuItemState createState() => _SideMenuItemState(); -} - -class _SideMenuItemState extends State { - late int currentPage = SideMenuGlobal.controller.currentPage; - - void _handleChange(int page) { - if (mounted) { - setState(() { - currentPage = page; - }); - } - } - - @override - void initState() { - super.initState(); - WidgetsBinding.instance.addPostFrameCallback((timeStamp) { - setState(() { - currentPage = SideMenuGlobal.controller.currentPage; - }); - if (mounted) { - SideMenuGlobal.controller.addListener(_handleChange); - } - }); - } - - @override - void dispose() { - SideMenuGlobal.controller.removeListener(_handleChange); - super.dispose(); - } - - Color _setColor() { - if (widget.priority == currentPage) { - return Theme.of(context).primaryTextTheme.headline6!.color!; - } else { - return Theme.of(context).highlightColor; - } - } + final bool isSelected; @override Widget build(BuildContext context) { + Color _setColor() { + if (isSelected) { + return Theme.of(context).primaryTextTheme.headline6!.color!; + } else { + return Theme.of(context).highlightColor; + } + } + return InkWell( child: Padding( padding: EdgeInsets.all(20), child: Image.asset( - widget.iconPath, + iconPath, fit: BoxFit.cover, height: 30, width: 30, color: _setColor(), ), ), - onTap: () => widget.onTap?.call(widget.priority, SideMenuGlobal.controller), + onTap: () => onTap.call(), highlightColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart index 84acd42a0..d93df1994 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart @@ -1,64 +1,76 @@ import 'package:cake_wallet/routes.dart'; +import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_controller.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart'; +import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/router.dart' as Router; +import 'package:flutter_mobx/flutter_mobx.dart'; +import 'package:mobx/mobx.dart'; -class DesktopSidebarWrapper extends StatefulWidget { +class DesktopSidebarWrapper extends StatelessWidget { final Widget child; + final DesktopSidebarViewModel desktopSidebarViewModel; - const DesktopSidebarWrapper({required this.child}); - - @override - State createState() => _DesktopSidebarWrapperState(); -} - -class _DesktopSidebarWrapperState extends State { - final page = PageController(); - final sideMenu = SideMenuController(); - - @override - void initState() { - SideMenuGlobal.controller = sideMenu; - sideMenu.addListener((p0) { - page.jumpToPage(p0); - }); - super.initState(); - } + const DesktopSidebarWrapper({required this.child, required this.desktopSidebarViewModel}); @override Widget build(BuildContext context) { + final pageController = PageController(); + + reaction((_) => desktopSidebarViewModel.currentPage, (page) { + String? currentPath; + + desktopKey.currentState?.popUntil((route) { + currentPath = route.settings.name; + return true; + }); + if (page == SidebarItem.transactions) { + return; + } + + if (currentPath == Routes.transactionsPage) { + Navigator.of(desktopKey.currentContext!).pop(); + } + + pageController.animateToPage( + page.index, + duration: Duration(milliseconds: 300), + curve: Curves.easeInOut, + ); + }); + return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SideMenu( - topItems: [ - SideMenuItem( - iconPath: 'assets/images/wallet_outline.png', - priority: 0, - onTap: (page, _) => sideMenu.changePage(page), - ), - ], - bottomItems: [ - SideMenuItem( - iconPath: 'assets/images/support_icon.png', - priority: 1, - onTap: (page, _) => sideMenu.changePage(page), - ), - SideMenuItem( - iconPath: 'assets/images/settings_outline.png', - priority: 2, - onTap: (page, _) => sideMenu.changePage(page), - ), - ], - ), + Observer(builder: (_) { + return SideMenu( + topItems: [ + SideMenuItem( + iconPath: 'assets/images/wallet_outline.png', + isSelected: desktopSidebarViewModel.currentPage == SidebarItem.dashboard, + onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.dashboard), + ), + ], + bottomItems: [ + SideMenuItem( + iconPath: 'assets/images/support_icon.png', + isSelected: desktopSidebarViewModel.currentPage == SidebarItem.support, + onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.support)), + SideMenuItem( + iconPath: 'assets/images/settings_outline.png', + isSelected: desktopSidebarViewModel.currentPage == SidebarItem.settings, + onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.settings), + ), + ], + ); + }), Expanded( child: PageView( - controller: page, + controller: pageController, physics: NeverScrollableScrollPhysics(), children: [ - widget.child, + child, Container( child: Navigator( initialRoute: Routes.support, diff --git a/lib/src/screens/dashboard/widgets/transactions_page.dart b/lib/src/screens/dashboard/widgets/transactions_page.dart index 64f02c73c..89149b3de 100644 --- a/lib/src/screens/dashboard/widgets/transactions_page.dart +++ b/lib/src/screens/dashboard/widgets/transactions_page.dart @@ -22,6 +22,7 @@ class TransactionsPage extends StatelessWidget { @override Widget build(BuildContext context) { return Container( + color: Theme.of(context).backgroundColor, padding: EdgeInsets.only( top: 24, bottom: 24 diff --git a/lib/src/screens/settings/desktop_settings/dashboard_settings_page.dart b/lib/src/screens/settings/desktop_settings/dashboard_settings_page.dart index c8ed24233..c8e32f16f 100644 --- a/lib/src/screens/settings/desktop_settings/dashboard_settings_page.dart +++ b/lib/src/screens/settings/desktop_settings/dashboard_settings_page.dart @@ -1,6 +1,5 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_controller.dart'; import 'package:cake_wallet/src/widgets/setting_action_button.dart'; import 'package:cake_wallet/src/widgets/setting_actions.dart'; import 'package:cake_wallet/typography.dart'; @@ -17,19 +16,14 @@ class DesktopSettingsPage extends StatefulWidget { } class _DesktopSettingsPageState extends State { - int itemCount = 0; - SideMenuController sideMenu = SideMenuController(); + int itemCount = SettingActions.all.length; int? currentPage; bool isTapped = false; - initState() { - super.initState(); - itemCount = SettingActions.all.length; - sideMenu.addListener((index) { - setState(() { - isTapped = true; - currentPage = index; - }); + void _onItemChange(int index) { + setState(() { + currentPage = index; + isTapped = true; }); } @@ -67,8 +61,8 @@ class _DesktopSettingsPageState extends State { if (currentPage != index) { final settingContext = _settingsNavigatorKey.currentState?.context ?? context; - sideMenu.changePage(index); item.onTap.call(settingContext); + _onItemChange(index); } }, image: item.image, diff --git a/lib/view_model/dashboard/desktop_sidebar_view_model.dart b/lib/view_model/dashboard/desktop_sidebar_view_model.dart new file mode 100644 index 000000000..516990d85 --- /dev/null +++ b/lib/view_model/dashboard/desktop_sidebar_view_model.dart @@ -0,0 +1,33 @@ +import 'package:mobx/mobx.dart'; + +part 'desktop_sidebar_view_model.g.dart'; + +enum SidebarItem { + dashboard(0), + support(1), + settings(2), + transactions(3); + + final int value; + const SidebarItem(this.value); +} + +class DesktopSidebarViewModel = DesktopSidebarViewModelBase with _$DesktopSidebarViewModel; + +abstract class DesktopSidebarViewModelBase with Store { + DesktopSidebarViewModelBase(); + + @observable + SidebarItem currentPage = SidebarItem.dashboard; + + + @action + void onPageChange(SidebarItem item) { + currentPage = item; + } + + @action + void resetSidebar() { + currentPage = SidebarItem.dashboard; + } +} From 107e136f523667e7e7f06bcb75e36b98a79c49fa Mon Sep 17 00:00:00 2001 From: Godwin Asuquo Date: Sat, 11 Feb 2023 00:35:11 +0200 Subject: [PATCH 04/15] remove empty line --- lib/di.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/di.dart b/lib/di.dart index c5bf8d0ea..0cce7abd3 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -169,7 +169,6 @@ import 'package:cake_wallet/src/screens/receive/fullscreen_qr_page.dart'; import 'package:cake_wallet/core/wallet_loading_service.dart'; import 'package:cw_core/crypto_currency.dart'; - final getIt = GetIt.instance; var _isSetupFinished = false; From bd04383b7c68ba055cf352bee458ea2f8280208b Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 14 Feb 2023 01:36:34 +0200 Subject: [PATCH 05/15] Change Exchange page UI depending on platform --- .../desktop_sidebar_wrapper.dart | 6 +- lib/src/screens/exchange/exchange_page.dart | 484 ++++++++---------- .../desktop_exchange_cards_section.dart | 28 + .../mobile_exchange_cards_section.dart | 58 +++ lib/src/widgets/nav_bar.dart | 52 +- macos/Runner.xcodeproj/project.pbxproj | 71 ++- macos/Runner/InfoBase.plist | 2 + scripts/macos/app_env.sh | 2 +- 8 files changed, 362 insertions(+), 341 deletions(-) create mode 100644 lib/src/screens/exchange/widgets/desktop_exchange_cards_section.dart create mode 100644 lib/src/screens/exchange/widgets/mobile_exchange_cards_section.dart diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart index d93df1994..19e417211 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart @@ -33,11 +33,7 @@ class DesktopSidebarWrapper extends StatelessWidget { Navigator.of(desktopKey.currentContext!).pop(); } - pageController.animateToPage( - page.index, - duration: Duration(milliseconds: 300), - curve: Curves.easeInOut, - ); + pageController.jumpToPage(page.index); }); return Row( diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 744848156..7952665b2 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -1,13 +1,14 @@ -import 'dart:ui'; import 'package:cake_wallet/di.dart'; +import 'package:cake_wallet/src/screens/exchange/widgets/desktop_exchange_cards_section.dart'; +import 'package:cake_wallet/src/screens/exchange/widgets/mobile_exchange_cards_section.dart'; import 'package:cake_wallet/utils/debounce.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cw_core/sync_status.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:cake_wallet/entities/parse_address_from_domain.dart'; import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed.dart'; import 'package:cake_wallet/src/widgets/standard_checkbox.dart'; import 'package:dotted_border/dotted_border.dart'; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:keyboard_actions/keyboard_actions.dart'; @@ -35,7 +36,14 @@ import 'package:cake_wallet/src/screens/exchange/widgets/present_provider_picker import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart'; class ExchangePage extends BasePage { - ExchangePage(this.exchangeViewModel); + ExchangePage(this.exchangeViewModel) { + depositWalletName = exchangeViewModel.depositCurrency == CryptoCurrency.xmr + ? exchangeViewModel.wallet.name + : null; + receiveWalletName = exchangeViewModel.receiveCurrency == CryptoCurrency.xmr + ? exchangeViewModel.wallet.name + : null; + } final ExchangeViewModel exchangeViewModel; final depositKey = GlobalKey(); @@ -50,6 +58,20 @@ class ExchangePage extends BasePage { final _depositAmountDebounce = Debounce(Duration(milliseconds: 500)); var _isReactionsSet = false; + final arrowBottomPurple = Image.asset( + 'assets/images/arrow_bottom_purple_icon.png', + color: Colors.white, + height: 8, + ); + final arrowBottomCakeGreen = Image.asset( + 'assets/images/arrow_bottom_cake_green.png', + color: Colors.white, + height: 8, + ); + + late final String? depositWalletName; + late final String? receiveWalletName; + @override String get title => S.current.exchange; @@ -88,26 +110,6 @@ class ExchangePage extends BasePage { @override Widget body(BuildContext context) { - final arrowBottomPurple = Image.asset( - 'assets/images/arrow_bottom_purple_icon.png', - color: Colors.white, - height: 8, - ); - final arrowBottomCakeGreen = Image.asset( - 'assets/images/arrow_bottom_cake_green.png', - color: Colors.white, - height: 8, - ); - - final depositWalletName = - exchangeViewModel.depositCurrency == CryptoCurrency.xmr - ? exchangeViewModel.wallet.name - : null; - final receiveWalletName = - exchangeViewModel.receiveCurrency == CryptoCurrency.xmr - ? exchangeViewModel.wallet.name - : null; - WidgetsBinding.instance .addPostFrameCallback((_) => _setReactions(context, exchangeViewModel)); @@ -138,201 +140,7 @@ class ExchangePage extends BasePage { contentPadding: EdgeInsets.only(bottom: 24), content: Observer(builder: (_) => Column( children: [ - Container( - padding: EdgeInsets.only(bottom: 32), - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(24), - bottomRight: Radius.circular(24)), - gradient: LinearGradient( - colors: [ - Theme.of(context).primaryTextTheme!.bodyText2!.color!, - Theme.of(context) - .primaryTextTheme! - .bodyText2! - .decorationColor!, - ], - stops: [ - 0.35, - 1.0 - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight), - ), - child: Column( - children: [ - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(24), - bottomRight: Radius.circular(24)), - gradient: LinearGradient( - colors: [ - Theme.of(context) - .primaryTextTheme! - .subtitle2! - .color!, - Theme.of(context) - .primaryTextTheme! - .subtitle2! - .decorationColor!, - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight), - ), - padding: EdgeInsets.fromLTRB(24, 100, 24, 32), - child: Observer( - builder: (_) => ExchangeCard( - onDispose: disposeBestRateSync, - hasAllAmount: exchangeViewModel.hasAllAmount, - allAmount: exchangeViewModel.hasAllAmount - ? () => exchangeViewModel - .calculateDepositAllAmount() - : null, - amountFocusNode: _depositAmountFocus, - addressFocusNode: _depositAddressFocus, - key: depositKey, - title: S.of(context).you_will_send, - initialCurrency: - exchangeViewModel.depositCurrency, - initialWalletName: depositWalletName ?? '', - initialAddress: - exchangeViewModel.depositCurrency == - exchangeViewModel.wallet.currency - ? exchangeViewModel.wallet.walletAddresses.address - : exchangeViewModel.depositAddress, - initialIsAmountEditable: true, - initialIsAddressEditable: - exchangeViewModel.isDepositAddressEnabled, - isAmountEstimated: false, - hasRefundAddress: true, - isMoneroWallet: exchangeViewModel.isMoneroWallet, - currencies: exchangeViewModel.depositCurrencies, - onCurrencySelected: (currency) { - // FIXME: need to move it into view model - if (currency == CryptoCurrency.xmr && - exchangeViewModel.wallet.type != - WalletType.monero) { - showPopUp( - context: context, - builder: (dialogContext) { - return AlertWithOneAction( - alertTitle: S.of(context).error, - alertContent: S - .of(context) - .exchange_incorrect_current_wallet_for_xmr, - buttonText: S.of(context).ok, - buttonAction: () => - Navigator.of(dialogContext) - .pop()); - }); - return; - } - - exchangeViewModel.changeDepositCurrency( - currency: currency); - }, - imageArrow: arrowBottomPurple, - currencyButtonColor: Colors.transparent, - addressButtonsColor: - Theme.of(context).focusColor!, - borderColor: Theme.of(context) - .primaryTextTheme! - .bodyText1! - .color!, - currencyValueValidator: AmountValidator( - type: exchangeViewModel.wallet.type), - addressTextFieldValidator: AddressValidator( - type: exchangeViewModel.depositCurrency), - onPushPasteButton: (context) async { - final domain = - exchangeViewModel.depositAddress; - final ticker = exchangeViewModel - .depositCurrency.title.toLowerCase(); - exchangeViewModel.depositAddress = - await fetchParsedAddress( - context, domain, ticker); - }, - onPushAddressBookButton: (context) async { - final domain = - exchangeViewModel.depositAddress; - final ticker = exchangeViewModel - .depositCurrency.title.toLowerCase(); - exchangeViewModel.depositAddress = - await fetchParsedAddress( - context, domain, ticker); - }, - ), - ), - ), - Padding( - padding: - EdgeInsets.only(top: 29, left: 24, right: 24), - child: Observer( - builder: (_) => ExchangeCard( - onDispose: disposeBestRateSync, - amountFocusNode: _receiveAmountFocus, - addressFocusNode: _receiveAddressFocus, - key: receiveKey, - title: S.of(context).you_will_get, - initialCurrency: - exchangeViewModel.receiveCurrency, - initialWalletName: receiveWalletName ?? '', - initialAddress: exchangeViewModel - .receiveCurrency == - exchangeViewModel.wallet.currency - ? exchangeViewModel.wallet.walletAddresses.address - : exchangeViewModel.receiveAddress, - initialIsAmountEditable: exchangeViewModel - .isReceiveAmountEditable, - initialIsAddressEditable: - exchangeViewModel - .isReceiveAddressEnabled, - isAmountEstimated: true, - isMoneroWallet: exchangeViewModel.isMoneroWallet, - currencies: - exchangeViewModel.receiveCurrencies, - onCurrencySelected: (currency) => - exchangeViewModel - .changeReceiveCurrency( - currency: currency), - imageArrow: arrowBottomCakeGreen, - currencyButtonColor: Colors.transparent, - addressButtonsColor: - Theme.of(context).focusColor!, - borderColor: Theme.of(context) - .primaryTextTheme! - .bodyText1! - .decorationColor!, - currencyValueValidator: AmountValidator( - type: exchangeViewModel.wallet.type), - addressTextFieldValidator: - AddressValidator( - type: exchangeViewModel - .receiveCurrency), - onPushPasteButton: (context) async { - final domain = - exchangeViewModel.receiveAddress; - final ticker = exchangeViewModel - .receiveCurrency.title.toLowerCase(); - exchangeViewModel.receiveAddress = - await fetchParsedAddress( - context, domain, ticker); - }, - onPushAddressBookButton: (context) async { - final domain = - exchangeViewModel.receiveAddress; - final ticker = exchangeViewModel - .receiveCurrency.title.toLowerCase(); - exchangeViewModel.receiveAddress = - await fetchParsedAddress( - context, domain, ticker); - }, - )), - ) - ], - ), - ), + _exchangeCardsSection(context), Padding( padding: EdgeInsets.only(top: 12, left: 24), child: Row( @@ -355,63 +163,67 @@ class ExchangePage extends BasePage { ), bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), - bottomSection: Column(children: [ - Padding( - padding: EdgeInsets.only(bottom: 15), - child: Observer(builder: (_) { - final description = exchangeViewModel.isFixedRateMode - ? exchangeViewModel.isAvailableInSelected - ? S.of(context).amount_is_guaranteed - : S.of(context).fixed_pair_not_supported - : exchangeViewModel.isAvailableInSelected - ? S.of(context).amount_is_estimate - : S.of(context).variable_pair_not_supported; - return Center( - child: Text( - description, - textAlign: TextAlign.center, - style: TextStyle( - color: Theme.of(context) - .primaryTextTheme! - .headline1! - .decorationColor!, - fontWeight: FontWeight.w500, - fontSize: 12), - ), - ); - }), - ), - Observer( - builder: (_) => LoadingPrimaryButton( - text: S.of(context).exchange, - onPressed: () { - if (_formKey.currentState != null && _formKey.currentState!.validate()) { - if ((exchangeViewModel.depositCurrency == - CryptoCurrency.xmr) && - (!(exchangeViewModel.status - is SyncedSyncStatus))) { - showPopUp( - context: context, - builder: (BuildContext context) { - return AlertWithOneAction( - alertTitle: S.of(context).exchange, - alertContent: S - .of(context) - .exchange_sync_alert_content, - buttonText: S.of(context).ok, - buttonAction: () => - Navigator.of(context).pop()); - }); - } else { - exchangeViewModel.createTrade(); + bottomSection: ConstrainedBox( + constraints: + BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), + child: Column(children: [ + Padding( + padding: EdgeInsets.only(bottom: 15), + child: Observer(builder: (_) { + final description = exchangeViewModel.isFixedRateMode + ? exchangeViewModel.isAvailableInSelected + ? S.of(context).amount_is_guaranteed + : S.of(context).fixed_pair_not_supported + : exchangeViewModel.isAvailableInSelected + ? S.of(context).amount_is_estimate + : S.of(context).variable_pair_not_supported; + return Center( + child: Text( + description, + textAlign: TextAlign.center, + style: TextStyle( + color: Theme.of(context) + .primaryTextTheme! + .headline1! + .decorationColor!, + fontWeight: FontWeight.w500, + fontSize: 12), + ), + ); + }), + ), + Observer( + builder: (_) => LoadingPrimaryButton( + text: S.of(context).exchange, + onPressed: () { + if (_formKey.currentState != null && _formKey.currentState!.validate()) { + if ((exchangeViewModel.depositCurrency == + CryptoCurrency.xmr) && + (!(exchangeViewModel.status + is SyncedSyncStatus))) { + showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithOneAction( + alertTitle: S.of(context).exchange, + alertContent: S + .of(context) + .exchange_sync_alert_content, + buttonText: S.of(context).ok, + buttonAction: () => + Navigator.of(context).pop()); + }); + } else { + exchangeViewModel.createTrade(); + } } - } - }, - color: Theme.of(context).accentTextTheme!.bodyText1!.color!, - textColor: Colors.white, - isDisabled: exchangeViewModel.selectedProviders.isEmpty, - isLoading: exchangeViewModel.tradeState is TradeIsCreating)), - ]), + }, + color: Theme.of(context).accentTextTheme!.bodyText1!.color!, + textColor: Colors.white, + isDisabled: exchangeViewModel.selectedProviders.isEmpty, + isLoading: exchangeViewModel.tradeState is TradeIsCreating)), + ]), + ), )), )); } @@ -445,7 +257,8 @@ class ExchangePage extends BasePage { radius: Radius.circular(20), child: Container( height: 34, - padding: EdgeInsets.only(left: 10, right: 10), + padding: EdgeInsets.symmetric( + horizontal: ResponsiveLayoutUtil.instance.isMobile(context) ? 10 : 30), alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(20)), @@ -816,5 +629,124 @@ class ExchangePage extends BasePage { } } - void disposeBestRateSync() => exchangeViewModel.bestRateSync?.cancel(); + void disposeBestRateSync() => exchangeViewModel.bestRateSync.cancel(); + + Widget _exchangeCardsSection(BuildContext context) { + final firstExchangeCard = Observer(builder: (_) => ExchangeCard( + onDispose: disposeBestRateSync, + hasAllAmount: exchangeViewModel.hasAllAmount, + allAmount: exchangeViewModel.hasAllAmount + ? () => exchangeViewModel.calculateDepositAllAmount() + : null, + amountFocusNode: _depositAmountFocus, + addressFocusNode: _depositAddressFocus, + key: depositKey, + title: S.of(context).you_will_send, + initialCurrency: exchangeViewModel.depositCurrency, + initialWalletName: depositWalletName ?? '', + initialAddress: + exchangeViewModel.depositCurrency == exchangeViewModel.wallet.currency + ? exchangeViewModel.wallet.walletAddresses.address + : exchangeViewModel.depositAddress, + initialIsAmountEditable: true, + initialIsAddressEditable: exchangeViewModel.isDepositAddressEnabled, + isAmountEstimated: false, + hasRefundAddress: true, + isMoneroWallet: exchangeViewModel.isMoneroWallet, + currencies: exchangeViewModel.depositCurrencies, + onCurrencySelected: (currency) { + // FIXME: need to move it into view model + if (currency == CryptoCurrency.xmr && + exchangeViewModel.wallet.type != WalletType.monero) { + showPopUp( + context: context, + builder: (dialogContext) { + return AlertWithOneAction( + alertTitle: S.of(context).error, + alertContent: + S.of(context).exchange_incorrect_current_wallet_for_xmr, + buttonText: S.of(context).ok, + buttonAction: () => Navigator.of(dialogContext).pop()); + }); + return; + } + + exchangeViewModel.changeDepositCurrency(currency: currency); + }, + imageArrow: arrowBottomPurple, + currencyButtonColor: Colors.transparent, + addressButtonsColor: Theme.of(context).focusColor!, + borderColor: Theme.of(context).primaryTextTheme!.bodyText1!.color!, + currencyValueValidator: + AmountValidator(type: exchangeViewModel.wallet.type), + addressTextFieldValidator: + AddressValidator(type: exchangeViewModel.depositCurrency), + onPushPasteButton: (context) async { + final domain = exchangeViewModel.depositAddress; + final ticker = exchangeViewModel.depositCurrency.title.toLowerCase(); + exchangeViewModel.depositAddress = + await fetchParsedAddress(context, domain, ticker); + }, + onPushAddressBookButton: (context) async { + final domain = exchangeViewModel.depositAddress; + final ticker = exchangeViewModel.depositCurrency.title.toLowerCase(); + exchangeViewModel.depositAddress = + await fetchParsedAddress(context, domain, ticker); + }, + )); + + final secondExchangeCard = Observer(builder: (_) => ExchangeCard( + onDispose: disposeBestRateSync, + amountFocusNode: _receiveAmountFocus, + addressFocusNode: _receiveAddressFocus, + key: receiveKey, + title: S.of(context).you_will_get, + initialCurrency: exchangeViewModel.receiveCurrency, + initialWalletName: receiveWalletName ?? '', + initialAddress: + exchangeViewModel.receiveCurrency == exchangeViewModel.wallet.currency + ? exchangeViewModel.wallet.walletAddresses.address + : exchangeViewModel.receiveAddress, + initialIsAmountEditable: exchangeViewModel.isReceiveAmountEditable, + initialIsAddressEditable: exchangeViewModel.isReceiveAddressEnabled, + isAmountEstimated: true, + isMoneroWallet: exchangeViewModel.isMoneroWallet, + currencies: exchangeViewModel.receiveCurrencies, + onCurrencySelected: (currency) => + exchangeViewModel.changeReceiveCurrency(currency: currency), + imageArrow: arrowBottomCakeGreen, + currencyButtonColor: Colors.transparent, + addressButtonsColor: Theme.of(context).focusColor!, + borderColor: + Theme.of(context).primaryTextTheme!.bodyText1!.decorationColor!, + currencyValueValidator: + AmountValidator(type: exchangeViewModel.wallet.type), + addressTextFieldValidator: + AddressValidator(type: exchangeViewModel.receiveCurrency), + onPushPasteButton: (context) async { + final domain = exchangeViewModel.receiveAddress; + final ticker = exchangeViewModel.receiveCurrency.title.toLowerCase(); + exchangeViewModel.receiveAddress = + await fetchParsedAddress(context, domain, ticker); + }, + onPushAddressBookButton: (context) async { + final domain = exchangeViewModel.receiveAddress; + final ticker = exchangeViewModel.receiveCurrency.title.toLowerCase(); + exchangeViewModel.receiveAddress = + await fetchParsedAddress(context, domain, ticker); + }, + )); + + if (ResponsiveLayoutUtil.instance.isMobile(context)) { + return MobileExchangeCardsSection( + firstExchangeCard: firstExchangeCard, + secondExchangeCard: secondExchangeCard, + ); + } + + return DesktopExchangeCardsSection( + firstExchangeCard: firstExchangeCard, + secondExchangeCard: secondExchangeCard, + ); + } } diff --git a/lib/src/screens/exchange/widgets/desktop_exchange_cards_section.dart b/lib/src/screens/exchange/widgets/desktop_exchange_cards_section.dart new file mode 100644 index 000000000..2dc91624d --- /dev/null +++ b/lib/src/screens/exchange/widgets/desktop_exchange_cards_section.dart @@ -0,0 +1,28 @@ +import 'package:flutter/material.dart'; + +class DesktopExchangeCardsSection extends StatelessWidget { + final Widget firstExchangeCard; + final Widget secondExchangeCard; + + const DesktopExchangeCardsSection({ + Key? key, + required this.firstExchangeCard, + required this.secondExchangeCard, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Column( + children: [ + Padding( + padding: EdgeInsets.only(top: 55, left: 24, right: 24), + child: firstExchangeCard, + ), + Padding( + padding: EdgeInsets.only(top: 29, left: 24, right: 24), + child: secondExchangeCard, + ), + ], + ); + } +} diff --git a/lib/src/screens/exchange/widgets/mobile_exchange_cards_section.dart b/lib/src/screens/exchange/widgets/mobile_exchange_cards_section.dart new file mode 100644 index 000000000..762c36a55 --- /dev/null +++ b/lib/src/screens/exchange/widgets/mobile_exchange_cards_section.dart @@ -0,0 +1,58 @@ +import 'package:flutter/material.dart'; + +class MobileExchangeCardsSection extends StatelessWidget { + final Widget firstExchangeCard; + final Widget secondExchangeCard; + + const MobileExchangeCardsSection({ + Key? key, + required this.firstExchangeCard, + required this.secondExchangeCard, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.only(bottom: 32), + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(24), + bottomRight: Radius.circular(24), + ), + gradient: LinearGradient( + colors: [ + Theme.of(context).primaryTextTheme.bodyText2!.color!, + Theme.of(context).primaryTextTheme.bodyText2!.decorationColor!, + ], + stops: [0.35, 1.0], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + ), + child: Column( + children: [ + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)), + gradient: LinearGradient( + colors: [ + Theme.of(context).primaryTextTheme.subtitle2!.color!, + Theme.of(context).primaryTextTheme.subtitle2!.decorationColor!, + ], + begin: Alignment.topLeft, + end: Alignment.bottomRight, + ), + ), + padding: EdgeInsets.fromLTRB(24, 100, 24, 32), + child: firstExchangeCard, + ), + Padding( + padding: EdgeInsets.only(top: 29, left: 24, right: 24), + child: secondExchangeCard, + ) + ], + ), + ); + } +} diff --git a/lib/src/widgets/nav_bar.dart b/lib/src/widgets/nav_bar.dart index fcea49656..517d0540f 100644 --- a/lib/src/widgets/nav_bar.dart +++ b/lib/src/widgets/nav_bar.dart @@ -2,12 +2,7 @@ import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:flutter/cupertino.dart'; class NavBar extends StatelessWidget implements ObstructingPreferredSizeWidget { - factory NavBar( - {Widget? leading, - Widget? middle, - Widget? trailing, - Color? backgroundColor}) { - + factory NavBar({Widget? leading, Widget? middle, Widget? trailing, Color? backgroundColor}) { return NavBar._internal( leading: leading, middle: middle, @@ -17,11 +12,7 @@ class NavBar extends StatelessWidget implements ObstructingPreferredSizeWidget { } factory NavBar.withShadow( - {Widget? leading, - Widget? middle, - Widget? trailing, - Color? backgroundColor}) { - + {Widget? leading, Widget? middle, Widget? trailing, Color? backgroundColor}) { return NavBar._internal( leading: leading, middle: middle, @@ -29,13 +20,15 @@ class NavBar extends StatelessWidget implements ObstructingPreferredSizeWidget { height: 80, backgroundColor: backgroundColor, decoration: BoxDecoration( - color: backgroundColor, - boxShadow: [ - BoxShadow( - color: Color.fromRGBO(132, 141, 198, 0.11), - blurRadius: 8, - offset: Offset(0, 2)) - ]), + color: backgroundColor, + boxShadow: [ + BoxShadow( + color: Color.fromRGBO(132, 141, 198, 0.11), + blurRadius: 8, + offset: Offset(0, 2), + ), + ], + ), ); } @@ -64,19 +57,16 @@ class NavBar extends StatelessWidget implements ObstructingPreferredSizeWidget { final _paddingBottom = (pad / 2); if (!ResponsiveLayoutUtil.instance.isMobile(context)) { - return PreferredSize( - preferredSize: Size.fromHeight(height), - child: Padding( - padding: const EdgeInsetsDirectional.only(end: 24), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - if (leading != null) Flexible(child: leading!), - if (middle != null) middle!, - trailing ?? const SizedBox(), - ], - ), + return Padding( + padding: const EdgeInsetsDirectional.only(end: 24, top: 8, bottom: 8), + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (leading != null) Flexible(child: leading!) else const SizedBox(), + if (middle != null) middle!, + trailing ?? const SizedBox(), + ], ), ); } diff --git a/macos/Runner.xcodeproj/project.pbxproj b/macos/Runner.xcodeproj/project.pbxproj index db962261a..a1baaa904 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/macos/Runner.xcodeproj/project.pbxproj @@ -21,14 +21,14 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 260A2F3C8557E98408EEF103 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E5FF9F6DDBDD4B4CF8CF6283 /* Pods_Runner.framework */; }; + 328F945957E1041662291EC5 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C84AA35EA80D710889C68D81 /* Pods_Runner.framework */; }; 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 5A1F888E2993FFF400619FD4 /* secRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1F888D2993FFF400619FD4 /* secRandom.swift */; }; - 5A1F88902994000F00619FD4 /* decrypt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A1F888F2994000F00619FD4 /* decrypt.swift */; }; + 9F565D5929954F53009A75FB /* secRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F565D5729954F53009A75FB /* secRandom.swift */; }; + 9F565D5A29954F53009A75FB /* decrypt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F565D5829954F53009A75FB /* decrypt.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -56,7 +56,7 @@ /* Begin PBXFileReference section */ 0C090639294D3AAC00954DC9 /* libiconv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libiconv.tbd; path = usr/lib/libiconv.tbd; sourceTree = SDKROOT; }; - 2A2C063A3322F546C19D07F5 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 135D3AD0276D31F62BBEDDBF /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; 33CC10ED2044A3C60003C045 /* Cake Wallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Cake Wallet.app"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -71,13 +71,13 @@ 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; - 4BBFB4E6C5ECED3763C70B52 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; - 5A1F888D2993FFF400619FD4 /* secRandom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = secRandom.swift; path = CakeWallet/secRandom.swift; sourceTree = ""; }; - 5A1F888F2994000F00619FD4 /* decrypt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = decrypt.swift; path = CakeWallet/decrypt.swift; sourceTree = ""; }; + 359F2F22842E234537DED5E3 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - D4FCC525D86B82897EAA2C70 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - E5FF9F6DDBDD4B4CF8CF6283 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 9F565D5729954F53009A75FB /* secRandom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = secRandom.swift; path = CakeWallet/secRandom.swift; sourceTree = ""; }; + 9F565D5829954F53009A75FB /* decrypt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = decrypt.swift; path = CakeWallet/decrypt.swift; sourceTree = ""; }; + C84AA35EA80D710889C68D81 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + FF499CFF131B036E3C5638D0 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -85,7 +85,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 260A2F3C8557E98408EEF103 /* Pods_Runner.framework in Frameworks */, + 328F945957E1041662291EC5 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -106,8 +106,8 @@ 33CC10E42044A3C60003C045 = { isa = PBXGroup; children = ( - 5A1F888F2994000F00619FD4 /* decrypt.swift */, - 5A1F888D2993FFF400619FD4 /* secRandom.swift */, + 9F565D5829954F53009A75FB /* decrypt.swift */, + 9F565D5729954F53009A75FB /* secRandom.swift */, 33FAB671232836740065AC1E /* Runner */, 33CEB47122A05771004F2AC0 /* Flutter */, 33CC10EE2044A3C60003C045 /* Products */, @@ -162,9 +162,9 @@ 9B6E7CA3983216A9E173F00F /* Pods */ = { isa = PBXGroup; children = ( - D4FCC525D86B82897EAA2C70 /* Pods-Runner.debug.xcconfig */, - 4BBFB4E6C5ECED3763C70B52 /* Pods-Runner.release.xcconfig */, - 2A2C063A3322F546C19D07F5 /* Pods-Runner.profile.xcconfig */, + 359F2F22842E234537DED5E3 /* Pods-Runner.debug.xcconfig */, + 135D3AD0276D31F62BBEDDBF /* Pods-Runner.release.xcconfig */, + FF499CFF131B036E3C5638D0 /* Pods-Runner.profile.xcconfig */, ); path = Pods; sourceTree = ""; @@ -173,7 +173,7 @@ isa = PBXGroup; children = ( 0C090639294D3AAC00954DC9 /* libiconv.tbd */, - E5FF9F6DDBDD4B4CF8CF6283 /* Pods_Runner.framework */, + C84AA35EA80D710889C68D81 /* Pods_Runner.framework */, ); name = Frameworks; sourceTree = ""; @@ -185,13 +185,13 @@ isa = PBXNativeTarget; buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 8E34FE8A171861D3E5428EEA /* [CP] Check Pods Manifest.lock */, + 8AB41FC42599228A92F51A44 /* [CP] Check Pods Manifest.lock */, 33CC10E92044A3C60003C045 /* Sources */, 33CC10EA2044A3C60003C045 /* Frameworks */, 33CC10EB2044A3C60003C045 /* Resources */, 33CC110E2044A8840003C045 /* Bundle Framework */, 3399D490228B24CF009A79C7 /* ShellScript */, - C20EA636086D5486C5C91CF2 /* [CP] Embed Pods Frameworks */, + F015812745AAC61FF550BB30 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -299,7 +299,7 @@ shellPath = /bin/sh; shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; }; - 8E34FE8A171861D3E5428EEA /* [CP] Check Pods Manifest.lock */ = { + 8AB41FC42599228A92F51A44 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -321,7 +321,7 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; - C20EA636086D5486C5C91CF2 /* [CP] Embed Pods Frameworks */ = { + F015812745AAC61FF550BB30 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -345,8 +345,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 5A1F88902994000F00619FD4 /* decrypt.swift in Sources */, - 5A1F888E2993FFF400619FD4 /* secRandom.swift in Sources */, + 9F565D5929954F53009A75FB /* secRandom.swift in Sources */, + 9F565D5A29954F53009A75FB /* decrypt.swift in Sources */, 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, @@ -414,7 +414,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -426,19 +426,24 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = x86_64; + ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 32J6BB6VUS; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Cake Wallet"; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 12; + MARKETING_VERSION = 1.0.0; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; @@ -496,7 +501,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -543,7 +548,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 12.0; + MACOSX_DEPLOYMENT_TARGET = 10.14; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -555,19 +560,24 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = x86_64; + ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 32J6BB6VUS; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Cake Wallet"; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 12; + MARKETING_VERSION = 1.0.0; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; @@ -578,19 +588,24 @@ isa = XCBuildConfiguration; baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; buildSettings = { - ARCHS = x86_64; + ARCHS = arm64; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 32J6BB6VUS; INFOPLIST_FILE = Runner/Info.plist; + INFOPLIST_KEY_CFBundleDisplayName = "Cake Wallet"; + INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.finance"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 12; + MARKETING_VERSION = 1.0.0; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_VERSION = 5.0; }; diff --git a/macos/Runner/InfoBase.plist b/macos/Runner/InfoBase.plist index 4789daa6a..98d0ea9ee 100644 --- a/macos/Runner/InfoBase.plist +++ b/macos/Runner/InfoBase.plist @@ -28,5 +28,7 @@ MainMenu NSPrincipalClass NSApplication + LSApplicationCategoryType + public.app-category.finance diff --git a/scripts/macos/app_env.sh b/scripts/macos/app_env.sh index 8b0329ba3..31a3efdf1 100755 --- a/scripts/macos/app_env.sh +++ b/scripts/macos/app_env.sh @@ -16,7 +16,7 @@ fi CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_VERSION="1.0.0" -CAKEWALLET_BUILD_NUMBER=1 +CAKEWALLET_BUILD_NUMBER=4 CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then From 8f762329370914070edcaf6ea11b3543fac471b6 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 14 Feb 2023 17:21:09 +0200 Subject: [PATCH 06/15] - Change design/paddings for Send page on desktop view - Make AddTemplateButton instead of having it duplicated in send/exchange --- lib/src/screens/exchange/exchange_page.dart | 53 +----- lib/src/screens/send/send_page.dart | 201 +++++++++----------- lib/src/screens/send/widgets/send_card.dart | 12 +- lib/src/widgets/add_template_button.dart | 52 +++++ 4 files changed, 152 insertions(+), 166 deletions(-) create mode 100644 lib/src/widgets/add_template_button.dart diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 7952665b2..0a1cd27e8 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -1,6 +1,7 @@ import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/src/screens/exchange/widgets/desktop_exchange_cards_section.dart'; import 'package:cake_wallet/src/screens/exchange/widgets/mobile_exchange_cards_section.dart'; +import 'package:cake_wallet/src/widgets/add_template_button.dart'; import 'package:cake_wallet/utils/debounce.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cw_core/sync_status.dart'; @@ -8,7 +9,6 @@ import 'package:cw_core/wallet_type.dart'; import 'package:cake_wallet/entities/parse_address_from_domain.dart'; import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed.dart'; import 'package:cake_wallet/src/widgets/standard_checkbox.dart'; -import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:keyboard_actions/keyboard_actions.dart'; @@ -164,8 +164,7 @@ class ExchangePage extends BasePage { bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), bottomSection: ConstrainedBox( - constraints: - BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), + constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), child: Column(children: [ Padding( padding: EdgeInsets.only(bottom: 15), @@ -241,51 +240,9 @@ class ExchangePage extends BasePage { return Row( children: [ - GestureDetector( - onTap: () => - Navigator.of(context).pushNamed(Routes.exchangeTemplate), - child: Container( - padding: EdgeInsets.only(left: 1, right: 10), - child: DottedBorder( - borderType: BorderType.RRect, - dashPattern: [6, 4], - color: Theme.of(context) - .primaryTextTheme! - .headline3! - .decorationColor!, - strokeWidth: 2, - radius: Radius.circular(20), - child: Container( - height: 34, - padding: EdgeInsets.symmetric( - horizontal: ResponsiveLayoutUtil.instance.isMobile(context) ? 10 : 30), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(20)), - color: Colors.transparent, - ), - child: templates.length >= 1 - ? Icon( - Icons.add, - color: Theme.of(context) - .primaryTextTheme! - .headline2! - .color!, - ) - : Text( - S.of(context).new_template, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme! - .headline2! - .color!, - ), - ), - ), - ), - ), + AddTemplateButton( + onTap: () => Navigator.of(context).pushNamed(Routes.exchangeTemplate), + currentTemplatesLength: templates.length, ), ListView.builder( scrollDirection: Axis.horizontal, diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 2cd849f34..0ddaaf83e 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -1,10 +1,12 @@ import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.dart'; import 'package:cake_wallet/src/screens/send/widgets/send_card.dart'; +import 'package:cake_wallet/src/widgets/add_template_button.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/src/widgets/picker.dart'; import 'package:cake_wallet/src/widgets/template_tile.dart'; import 'package:cake_wallet/utils/payment_request.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/view_model/send/output.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; @@ -19,7 +21,6 @@ import 'package:cake_wallet/src/widgets/trail_button.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/send/send_view_model_state.dart'; import 'package:cake_wallet/generated/i18n.dart'; -import 'package:dotted_border/dotted_border.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; @@ -53,6 +54,15 @@ class SendPage extends BasePage { @override AppBarStyle get appBarStyle => AppBarStyle.transparent; + double _sendCardHeight(BuildContext context) { + final double initialHeight = sendViewModel.isElectrumWallet ? 490 : 465; + + if (!ResponsiveLayoutUtil.instance.isMobile(context)) { + return initialHeight - 77; + } + return initialHeight; + } + @override void onClose(BuildContext context) { sendViewModel.onClose(); @@ -107,7 +117,7 @@ class SendPage extends BasePage { content: Column( children: [ Container( - height: sendViewModel.isElectrumWallet ? 490 : 465, + height: _sendCardHeight(context), child: Observer( builder: (_) { return PageView.builder( @@ -172,51 +182,9 @@ class SendPage extends BasePage { return Row( children: [ - GestureDetector( - onTap: () => Navigator.of(context) - .pushNamed(Routes.sendTemplate), - child: Container( - padding: EdgeInsets.only(left: 1, right: 10), - child: DottedBorder( - borderType: BorderType.RRect, - dashPattern: [6, 4], - color: Theme.of(context) - .primaryTextTheme! - .headline2! - .decorationColor!, - strokeWidth: 2, - radius: Radius.circular(20), - child: Container( - height: 34, - padding: EdgeInsets.only(left: 10, right: 10), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: - BorderRadius.all(Radius.circular(20)), - color: Colors.transparent, - ), - child: templates.length >= 1 - ? Icon( - Icons.add, - color: Theme.of(context) - .primaryTextTheme! - .headline2! - .color!, - ) - : Text( - S.of(context).new_template, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - color: Theme.of(context) - .primaryTextTheme! - .headline2! - .color!, - ), - ), - ), - ), - ), + AddTemplateButton( + onTap: () => Navigator.of(context).pushNamed(Routes.sendTemplate), + currentTemplatesLength: templates.length, ), ListView.builder( scrollDirection: Axis.horizontal, @@ -279,80 +247,83 @@ class SendPage extends BasePage { ), bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), - bottomSection: Column( - children: [ - if (sendViewModel.hasCurrecyChanger) - Observer(builder: (_) => - Padding( - padding: EdgeInsets.only(bottom: 12), - child: PrimaryButton( - onPressed: () => presentCurrencyPicker(context), - text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})', - color: Colors.transparent, - textColor: Theme.of(context) - .accentTextTheme! - .headline3! - .decorationColor!, + bottomSection: ConstrainedBox( + constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), + child: Column( + children: [ + if (sendViewModel.hasCurrecyChanger) + Observer(builder: (_) => + Padding( + padding: EdgeInsets.only(bottom: 12), + child: PrimaryButton( + onPressed: () => presentCurrencyPicker(context), + text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})', + color: Colors.transparent, + textColor: Theme.of(context) + .accentTextTheme! + .headline3! + .decorationColor!, + ) ) - ) - ), - if (sendViewModel.hasMultiRecipient) - Padding( - padding: EdgeInsets.only(bottom: 12), - child: PrimaryButton( - onPressed: () { - sendViewModel.addOutput(); - Future.delayed(const Duration(milliseconds: 250), () { - controller.jumpToPage(sendViewModel.outputs.length - 1); - }); - }, - text: S.of(context).add_receiver, - color: Colors.transparent, - textColor: Theme.of(context) - .accentTextTheme! - .headline3! - .decorationColor!, - isDottedBorder: true, - borderColor: Theme.of(context) - .primaryTextTheme! - .headline3! - .decorationColor!, - )), - Observer( - builder: (_) { - return LoadingPrimaryButton( - onPressed: () async { - if (_formKey.currentState != null && !_formKey.currentState!.validate()) { - if (sendViewModel.outputs.length > 1) { - showErrorValidationAlert(context); + ), + if (sendViewModel.hasMultiRecipient) + Padding( + padding: EdgeInsets.only(bottom: 12), + child: PrimaryButton( + onPressed: () { + sendViewModel.addOutput(); + Future.delayed(const Duration(milliseconds: 250), () { + controller.jumpToPage(sendViewModel.outputs.length - 1); + }); + }, + text: S.of(context).add_receiver, + color: Colors.transparent, + textColor: Theme.of(context) + .accentTextTheme! + .headline3! + .decorationColor!, + isDottedBorder: true, + borderColor: Theme.of(context) + .primaryTextTheme! + .headline3! + .decorationColor!, + )), + Observer( + builder: (_) { + return LoadingPrimaryButton( + onPressed: () async { + if (_formKey.currentState != null && !_formKey.currentState!.validate()) { + if (sendViewModel.outputs.length > 1) { + showErrorValidationAlert(context); + } + + return; } - return; - } + final notValidItems = sendViewModel.outputs + .where((item) => + item.address.isEmpty || item.cryptoAmount.isEmpty) + .toList(); - final notValidItems = sendViewModel.outputs - .where((item) => - item.address.isEmpty || item.cryptoAmount.isEmpty) - .toList(); + if (notValidItems?.isNotEmpty ?? false) { + showErrorValidationAlert(context); + return; + } - if (notValidItems?.isNotEmpty ?? false) { - showErrorValidationAlert(context); - return; - } - - await sendViewModel.createTransaction(); + await sendViewModel.createTransaction(); - }, - text: S.of(context).send, - color: Theme.of(context).accentTextTheme!.bodyText1!.color!, - textColor: Colors.white, - isLoading: sendViewModel.state is IsExecutingState || - sendViewModel.state is TransactionCommitting, - isDisabled: !sendViewModel.isReadyForSend, - ); - }, - ) - ], + }, + text: S.of(context).send, + color: Theme.of(context).accentTextTheme!.bodyText1!.color!, + textColor: Colors.white, + isLoading: sendViewModel.state is IsExecutingState || + sendViewModel.state is TransactionCommitting, + isDisabled: !sendViewModel.isReadyForSend, + ); + }, + ) + ], + ), )), ); } diff --git a/lib/src/screens/send/widgets/send_card.dart b/lib/src/screens/send/widgets/send_card.dart index 082067d95..cdae9a8df 100644 --- a/lib/src/screens/send/widgets/send_card.dart +++ b/lib/src/screens/send/widgets/send_card.dart @@ -1,6 +1,7 @@ import 'package:cake_wallet/entities/priority_for_wallet_type.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/utils/payment_request.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cw_core/transaction_priority.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/widgets/keyboard_done_button.dart'; @@ -119,7 +120,7 @@ class SendCardState extends State color: Colors.transparent, )), Container( - decoration: BoxDecoration( + decoration: ResponsiveLayoutUtil.instance.isMobile(context) ? BoxDecoration( borderRadius: BorderRadius.only( bottomLeft: Radius.circular(24), bottomRight: Radius.circular(24)), @@ -130,9 +131,14 @@ class SendCardState extends State .subtitle1! .decorationColor!, ], begin: Alignment.topLeft, end: Alignment.bottomRight), - ), + ) : null, child: Padding( - padding: EdgeInsets.fromLTRB(24, 100, 24, 32), + padding: EdgeInsets.fromLTRB( + 24, + ResponsiveLayoutUtil.instance.isMobile(context) ? 100 : 55, + 24, + ResponsiveLayoutUtil.instance.isMobile(context) ? 32 : 0, + ), child: SingleChildScrollView( child: Observer(builder: (_) => Column( mainAxisSize: MainAxisSize.min, diff --git a/lib/src/widgets/add_template_button.dart b/lib/src/widgets/add_template_button.dart new file mode 100644 index 000000000..249c493a6 --- /dev/null +++ b/lib/src/widgets/add_template_button.dart @@ -0,0 +1,52 @@ +import 'package:cake_wallet/generated/i18n.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; +import 'package:dotted_border/dotted_border.dart'; +import 'package:flutter/material.dart'; + +class AddTemplateButton extends StatelessWidget { + final Function() onTap; + final int currentTemplatesLength; + + const AddTemplateButton({Key? key, required this.onTap, required this.currentTemplatesLength}) + : super(key: key); + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTap: onTap, + child: Container( + padding: EdgeInsets.only(left: 1, right: 10), + child: DottedBorder( + borderType: BorderType.RRect, + dashPattern: [6, 4], + color: Theme.of(context).primaryTextTheme.headline3!.decorationColor!, + strokeWidth: 2, + radius: Radius.circular(20), + child: Container( + height: 34, + padding: EdgeInsets.symmetric( + horizontal: ResponsiveLayoutUtil.instance.isMobile(context) ? 10 : 30), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.all(Radius.circular(20)), + color: Colors.transparent, + ), + child: currentTemplatesLength >= 1 + ? Icon( + Icons.add, + color: Theme.of(context).primaryTextTheme.headline2!.color!, + ) + : Text( + S.of(context).new_template, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + color: Theme.of(context).primaryTextTheme.headline2!.color!, + ), + ), + ), + ), + ), + ); + } +} From fb5efc04295c48ded179e4eb638b1c98d2222d91 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 14 Feb 2023 18:01:24 +0200 Subject: [PATCH 07/15] Fix Desktop dashboard actions background color --- lib/router.dart | 6 ++-- .../dashboard/desktop_dashboard_page.dart | 32 +++++++++++++---- .../desktop_dashboard_view.dart | 35 ------------------- .../desktop_sidebar_wrapper.dart | 6 ++-- .../dashboard/widgets/balance_page.dart | 3 -- 5 files changed, 33 insertions(+), 49 deletions(-) delete mode 100644 lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart diff --git a/lib/router.dart b/lib/router.dart index a253eea22..91a5ac4e1 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -520,8 +520,10 @@ Route createRoute(RouteSettings settings) { )); case Routes.desktop_actions: - return CupertinoPageRoute( - builder: (_) => DesktopDashboardActions(getIt())); + return PageRouteBuilder( + opaque: false, + pageBuilder: (_, __, ___) => DesktopDashboardActions(getIt()), + ); case Routes.desktop_settings_page: return CupertinoPageRoute( diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index ac5700af4..1ab45fc7c 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/yat_emoji_id.dart'; @@ -18,6 +17,7 @@ import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_v import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/main.dart'; +import 'package:cake_wallet/router.dart' as Router; class DesktopDashboardPage extends BasePage { DesktopDashboardPage({ @@ -27,6 +27,8 @@ class DesktopDashboardPage extends BasePage { required this.desktopSidebarViewModel, }); + static final GlobalKey desktopKey = GlobalKey(); + @override Color get backgroundLightColor => currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; @@ -73,13 +75,12 @@ class DesktopDashboardPage extends BasePage { }); if (currentPath == Routes.transactionsPage) { - desktopSidebarViewModel.resetSidebar(); - return; - } + desktopSidebarViewModel.resetSidebar(); + return; + } desktopSidebarViewModel.onPageChange(SidebarItem.transactions); desktopKey.currentState!.pushNamed(Routes.transactionsPage); - }, child: Observer( builder: (_) { @@ -105,7 +106,26 @@ class DesktopDashboardPage extends BasePage { Widget body(BuildContext context) { _setEffects(context); - return DesktopDashboardView(balancePage); + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 3, + child: balancePage, + ), + Expanded( + flex: 5, + child: Navigator( + key: desktopKey, + initialRoute: Routes.desktop_actions, + onGenerateRoute: (settings) => Router.createRoute(settings), + onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { + return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!]; + }, + ), + ), + ], + ); } void _setEffects(BuildContext context) async { diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart deleted file mode 100644 index 7e2bba777..000000000 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:cake_wallet/routes.dart'; -import 'package:flutter/material.dart'; -import 'package:cake_wallet/router.dart' as Router; - -GlobalKey desktopKey = GlobalKey(); - -class DesktopDashboardView extends StatelessWidget { - final Widget balancePage; - - const DesktopDashboardView(this.balancePage, {Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 3, - child: balancePage, - ), - Expanded( - flex: 5, - child: Navigator( - key: desktopKey, - initialRoute: Routes.desktop_actions, - onGenerateRoute: (settings) => Router.createRoute(settings), - onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { - return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!]; - }, - ), - ), - ], - ); - } -} diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart index 19e417211..81dd8243f 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart @@ -1,5 +1,5 @@ import 'package:cake_wallet/routes.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; +import 'package:cake_wallet/src/screens/dashboard/desktop_dashboard_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart'; import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; @@ -21,7 +21,7 @@ class DesktopSidebarWrapper extends StatelessWidget { reaction((_) => desktopSidebarViewModel.currentPage, (page) { String? currentPath; - desktopKey.currentState?.popUntil((route) { + DesktopDashboardPage.desktopKey.currentState?.popUntil((route) { currentPath = route.settings.name; return true; }); @@ -30,7 +30,7 @@ class DesktopSidebarWrapper extends StatelessWidget { } if (currentPath == Routes.transactionsPage) { - Navigator.of(desktopKey.currentContext!).pop(); + Navigator.of(DesktopDashboardPage.desktopKey.currentContext!).pop(); } pageController.jumpToPage(page.index); diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index 48eaa0a3e..fe750538b 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -16,9 +16,6 @@ class BalancePage extends StatelessWidget{ final DashboardViewModel dashboardViewModel; final SettingsStore settingsStore; - - Color get backgroundLightColor => - settingsStore.currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; @override Widget build(BuildContext context) { From 02fe3c008f932a5f98a25c8febace2de4eb7e0e5 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Tue, 14 Feb 2023 18:05:44 +0200 Subject: [PATCH 08/15] Constrain primary Buttons width --- lib/src/screens/exchange/exchange_page.dart | 115 +++++----- lib/src/screens/send/send_page.dart | 147 ++++++------- lib/src/widgets/primary_button.dart | 229 +++++++++++--------- 3 files changed, 249 insertions(+), 242 deletions(-) diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 0a1cd27e8..8a6509a0d 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -163,66 +163,63 @@ class ExchangePage extends BasePage { ), bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), - bottomSection: ConstrainedBox( - constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), - child: Column(children: [ - Padding( - padding: EdgeInsets.only(bottom: 15), - child: Observer(builder: (_) { - final description = exchangeViewModel.isFixedRateMode - ? exchangeViewModel.isAvailableInSelected - ? S.of(context).amount_is_guaranteed - : S.of(context).fixed_pair_not_supported - : exchangeViewModel.isAvailableInSelected - ? S.of(context).amount_is_estimate - : S.of(context).variable_pair_not_supported; - return Center( - child: Text( - description, - textAlign: TextAlign.center, - style: TextStyle( - color: Theme.of(context) - .primaryTextTheme! - .headline1! - .decorationColor!, - fontWeight: FontWeight.w500, - fontSize: 12), - ), - ); - }), - ), - Observer( - builder: (_) => LoadingPrimaryButton( - text: S.of(context).exchange, - onPressed: () { - if (_formKey.currentState != null && _formKey.currentState!.validate()) { - if ((exchangeViewModel.depositCurrency == - CryptoCurrency.xmr) && - (!(exchangeViewModel.status - is SyncedSyncStatus))) { - showPopUp( - context: context, - builder: (BuildContext context) { - return AlertWithOneAction( - alertTitle: S.of(context).exchange, - alertContent: S - .of(context) - .exchange_sync_alert_content, - buttonText: S.of(context).ok, - buttonAction: () => - Navigator.of(context).pop()); - }); - } else { - exchangeViewModel.createTrade(); - } + bottomSection: Column(children: [ + Padding( + padding: EdgeInsets.only(bottom: 15), + child: Observer(builder: (_) { + final description = exchangeViewModel.isFixedRateMode + ? exchangeViewModel.isAvailableInSelected + ? S.of(context).amount_is_guaranteed + : S.of(context).fixed_pair_not_supported + : exchangeViewModel.isAvailableInSelected + ? S.of(context).amount_is_estimate + : S.of(context).variable_pair_not_supported; + return Center( + child: Text( + description, + textAlign: TextAlign.center, + style: TextStyle( + color: Theme.of(context) + .primaryTextTheme! + .headline1! + .decorationColor!, + fontWeight: FontWeight.w500, + fontSize: 12), + ), + ); + }), + ), + Observer( + builder: (_) => LoadingPrimaryButton( + text: S.of(context).exchange, + onPressed: () { + if (_formKey.currentState != null && _formKey.currentState!.validate()) { + if ((exchangeViewModel.depositCurrency == + CryptoCurrency.xmr) && + (!(exchangeViewModel.status + is SyncedSyncStatus))) { + showPopUp( + context: context, + builder: (BuildContext context) { + return AlertWithOneAction( + alertTitle: S.of(context).exchange, + alertContent: S + .of(context) + .exchange_sync_alert_content, + buttonText: S.of(context).ok, + buttonAction: () => + Navigator.of(context).pop()); + }); + } else { + exchangeViewModel.createTrade(); } - }, - color: Theme.of(context).accentTextTheme!.bodyText1!.color!, - textColor: Colors.white, - isDisabled: exchangeViewModel.selectedProviders.isEmpty, - isLoading: exchangeViewModel.tradeState is TradeIsCreating)), - ]), - ), + } + }, + color: Theme.of(context).accentTextTheme!.bodyText1!.color!, + textColor: Colors.white, + isDisabled: exchangeViewModel.selectedProviders.isEmpty, + isLoading: exchangeViewModel.tradeState is TradeIsCreating)), + ]), )), )); } diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 0ddaaf83e..5727c1e15 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -247,83 +247,80 @@ class SendPage extends BasePage { ), bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), - bottomSection: ConstrainedBox( - constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), - child: Column( - children: [ - if (sendViewModel.hasCurrecyChanger) - Observer(builder: (_) => - Padding( - padding: EdgeInsets.only(bottom: 12), - child: PrimaryButton( - onPressed: () => presentCurrencyPicker(context), - text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})', - color: Colors.transparent, - textColor: Theme.of(context) - .accentTextTheme! - .headline3! - .decorationColor!, - ) - ) - ), - if (sendViewModel.hasMultiRecipient) + bottomSection: Column( + children: [ + if (sendViewModel.hasCurrecyChanger) + Observer(builder: (_) => Padding( - padding: EdgeInsets.only(bottom: 12), - child: PrimaryButton( - onPressed: () { - sendViewModel.addOutput(); - Future.delayed(const Duration(milliseconds: 250), () { - controller.jumpToPage(sendViewModel.outputs.length - 1); - }); - }, - text: S.of(context).add_receiver, - color: Colors.transparent, - textColor: Theme.of(context) - .accentTextTheme! - .headline3! - .decorationColor!, - isDottedBorder: true, - borderColor: Theme.of(context) - .primaryTextTheme! - .headline3! - .decorationColor!, - )), - Observer( - builder: (_) { - return LoadingPrimaryButton( - onPressed: () async { - if (_formKey.currentState != null && !_formKey.currentState!.validate()) { - if (sendViewModel.outputs.length > 1) { - showErrorValidationAlert(context); - } - - return; - } - - final notValidItems = sendViewModel.outputs - .where((item) => - item.address.isEmpty || item.cryptoAmount.isEmpty) - .toList(); - - if (notValidItems?.isNotEmpty ?? false) { - showErrorValidationAlert(context); - return; - } - - await sendViewModel.createTransaction(); - + padding: EdgeInsets.only(bottom: 12), + child: PrimaryButton( + onPressed: () => presentCurrencyPicker(context), + text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})', + color: Colors.transparent, + textColor: Theme.of(context) + .accentTextTheme! + .headline3! + .decorationColor!, + ) + ) + ), + if (sendViewModel.hasMultiRecipient) + Padding( + padding: EdgeInsets.only(bottom: 12), + child: PrimaryButton( + onPressed: () { + sendViewModel.addOutput(); + Future.delayed(const Duration(milliseconds: 250), () { + controller.jumpToPage(sendViewModel.outputs.length - 1); + }); }, - text: S.of(context).send, - color: Theme.of(context).accentTextTheme!.bodyText1!.color!, - textColor: Colors.white, - isLoading: sendViewModel.state is IsExecutingState || - sendViewModel.state is TransactionCommitting, - isDisabled: !sendViewModel.isReadyForSend, - ); - }, - ) - ], - ), + text: S.of(context).add_receiver, + color: Colors.transparent, + textColor: Theme.of(context) + .accentTextTheme! + .headline3! + .decorationColor!, + isDottedBorder: true, + borderColor: Theme.of(context) + .primaryTextTheme! + .headline3! + .decorationColor!, + )), + Observer( + builder: (_) { + return LoadingPrimaryButton( + onPressed: () async { + if (_formKey.currentState != null && !_formKey.currentState!.validate()) { + if (sendViewModel.outputs.length > 1) { + showErrorValidationAlert(context); + } + + return; + } + + final notValidItems = sendViewModel.outputs + .where((item) => + item.address.isEmpty || item.cryptoAmount.isEmpty) + .toList(); + + if (notValidItems?.isNotEmpty ?? false) { + showErrorValidationAlert(context); + return; + } + + await sendViewModel.createTransaction(); + + }, + text: S.of(context).send, + color: Theme.of(context).accentTextTheme!.bodyText1!.color!, + textColor: Colors.white, + isLoading: sendViewModel.state is IsExecutingState || + sendViewModel.state is TransactionCommitting, + isDisabled: !sendViewModel.isReadyForSend, + ); + }, + ) + ], )), ); } diff --git a/lib/src/widgets/primary_button.dart b/lib/src/widgets/primary_button.dart index a563319c5..c27169894 100644 --- a/lib/src/widgets/primary_button.dart +++ b/lib/src/widgets/primary_button.dart @@ -1,3 +1,4 @@ +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:dotted_border/dotted_border.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -24,28 +25,31 @@ class PrimaryButton extends StatelessWidget { @override Widget build(BuildContext context) { - final content = SizedBox( - width: double.infinity, - height: 52.0, - child: TextButton( - onPressed: isDisabled - ? (onDisabledPressed != null ? onDisabledPressed : null) : onPressed, - style: ButtonStyle(backgroundColor: MaterialStateProperty.all(isDisabled ? color.withOpacity(0.5) : color), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(26.0), + final content = ConstrainedBox( + constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), + child: SizedBox( + width: double.infinity, + height: 52.0, + child: TextButton( + onPressed: isDisabled + ? (onDisabledPressed != null ? onDisabledPressed : null) : onPressed, + style: ButtonStyle(backgroundColor: MaterialStateProperty.all(isDisabled ? color.withOpacity(0.5) : color), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(26.0), + ), ), - ), - overlayColor: MaterialStateProperty.all(Colors.transparent)), - child: Text(text, - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.w600, - color: isDisabled - ? textColor.withOpacity(0.5) - : textColor)), - )); + overlayColor: MaterialStateProperty.all(Colors.transparent)), + child: Text(text, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.w600, + color: isDisabled + ? textColor.withOpacity(0.5) + : textColor)), + )), + ); return isDottedBorder ? DottedBorder( @@ -77,29 +81,32 @@ class LoadingPrimaryButton extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( - width: double.infinity, - height: 52.0, - child: TextButton( - onPressed: (isLoading || isDisabled) ? null : onPressed, - style: ButtonStyle(backgroundColor: MaterialStateProperty.all(isDisabled ? color.withOpacity(0.5) : color), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(26.0), - ), - )), - - child: isLoading - ? CupertinoActivityIndicator(animating: true) - : Text(text, - style: TextStyle( - fontSize: 15.0, - fontWeight: FontWeight.w600, - color: isDisabled - ? textColor.withOpacity(0.5) - : textColor + return ConstrainedBox( + constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), + child: SizedBox( + width: double.infinity, + height: 52.0, + child: TextButton( + onPressed: (isLoading || isDisabled) ? null : onPressed, + style: ButtonStyle(backgroundColor: MaterialStateProperty.all(isDisabled ? color.withOpacity(0.5) : color), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(26.0), + ), )), - )); + + child: isLoading + ? CupertinoActivityIndicator(animating: true) + : Text(text, + style: TextStyle( + fontSize: 15.0, + fontWeight: FontWeight.w600, + color: isDisabled + ? textColor.withOpacity(0.5) + : textColor + )), + )), + ); } } @@ -130,45 +137,48 @@ class PrimaryIconButton extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( - width: double.infinity, - height: 52.0, - child: TextButton( - onPressed: onPressed, - style: ButtonStyle(backgroundColor: MaterialStateProperty.all(color), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(radius), - ), - )), - child: Stack( - children: [ - Row( - mainAxisAlignment: mainAxisAlignment, - children: [ - Container( - width: 26.0, - height: 52.0, - decoration: BoxDecoration( - shape: BoxShape.circle, color: iconBackgroundColor), - child: Center( - child: Icon(iconData, color: iconColor, size: 22.0) - ), + return ConstrainedBox( + constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), + child: SizedBox( + width: double.infinity, + height: 52.0, + child: TextButton( + onPressed: onPressed, + style: ButtonStyle(backgroundColor: MaterialStateProperty.all(color), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(radius), ), - ], - ), - Container( - height: 52.0, - child: Center( - child: Text(text, - style: TextStyle( - fontSize: 16.0, - color: textColor)), + )), + child: Stack( + children: [ + Row( + mainAxisAlignment: mainAxisAlignment, + children: [ + Container( + width: 26.0, + height: 52.0, + decoration: BoxDecoration( + shape: BoxShape.circle, color: iconBackgroundColor), + child: Center( + child: Icon(iconData, color: iconColor, size: 22.0) + ), + ), + ], ), - ) - ], - ), - )); + Container( + height: 52.0, + child: Center( + child: Text(text, + style: TextStyle( + fontSize: 16.0, + color: textColor)), + ), + ) + ], + ), + )), + ); } } @@ -190,34 +200,37 @@ class PrimaryImageButton extends StatelessWidget { @override Widget build(BuildContext context) { - return SizedBox( - width: double.infinity, - height: 52.0, - child: TextButton( - onPressed: onPressed, - style: ButtonStyle(backgroundColor: MaterialStateProperty.all(color), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(26.0), - ), - )), - child:Center( - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - image, - SizedBox(width: 15), - Text( - text, - style: TextStyle( - fontSize: 15, - fontWeight: FontWeight.w600, - color: textColor + return ConstrainedBox( + constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), + child: SizedBox( + width: double.infinity, + height: 52.0, + child: TextButton( + onPressed: onPressed, + style: ButtonStyle(backgroundColor: MaterialStateProperty.all(color), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(26.0), ), - ) - ], - ), - ) - )); + )), + child:Center( + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + image, + SizedBox(width: 15), + Text( + text, + style: TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: textColor + ), + ) + ], + ), + ) + )), + ); } } From ea09bba0fb07c6f4fbbd8f00eb5775f78cd6a208 Mon Sep 17 00:00:00 2001 From: Godwin Asuquo Date: Tue, 14 Feb 2023 21:53:17 +0200 Subject: [PATCH 09/15] Make side menu items toggle back to dashboard --- lib/di.dart | 8 +- lib/src/screens/dashboard/dashboard_page.dart | 5 +- .../dashboard/desktop_dashboard_page.dart | 61 +--------- .../desktop_sidebar/side_menu.dart | 6 +- .../desktop_sidebar/side_menu_item.dart | 8 +- .../desktop_sidebar_wrapper.dart | 104 ++++++++++++++++-- .../dashboard_settings_page.dart | 6 +- .../dashboard/desktop_sidebar_view_model.dart | 17 +-- 8 files changed, 127 insertions(+), 88 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index 0cce7abd3..37e547b93 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -7,6 +7,7 @@ import 'package:cake_wallet/ionia/ionia_anypay.dart'; import 'package:cake_wallet/ionia/ionia_gift_card.dart'; import 'package:cake_wallet/ionia/ionia_tip.dart'; import 'package:cake_wallet/src/screens/buy/onramper_page.dart'; +import 'package:cake_wallet/src/screens/dashboard/desktop_dashboard_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart'; import 'package:cake_wallet/src/screens/settings/display_settings_page.dart'; @@ -368,7 +369,12 @@ Future setup( getIt.registerFactory(() => BalancePage(dashboardViewModel: getIt.get(), settingsStore: getIt.get())); - getIt.registerFactory(() => DashboardPage( balancePage: getIt.get(), walletViewModel: getIt.get(), addressListViewModel: getIt.get())); + getIt.registerFactory(() => DashboardPage( + balancePage: getIt.get(), + walletViewModel: getIt.get(), + addressListViewModel: getIt.get(), + desktopSidebarViewModel: getIt.get(), + )); getIt.registerFactory(() => TransactionsPage(dashboardViewModel: getIt.get())); getIt.registerFactory(() => ReceivePage( addressListViewModel: getIt.get())); diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 4665751a7..0557f0415 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -25,21 +25,23 @@ import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; import 'package:cake_wallet/main.dart'; +import 'package:cake_wallet/router.dart' as Router; class DashboardPage extends StatelessWidget { DashboardPage({ required this.balancePage, required this.walletViewModel, required this.addressListViewModel, + required this.desktopSidebarViewModel, }); final BalancePage balancePage; final DashboardViewModel walletViewModel; final WalletAddressListViewModel addressListViewModel; + final DesktopSidebarViewModel desktopSidebarViewModel; @override Widget build(BuildContext context) { - final desktopSidebarViewModel = getIt(); return Scaffold( body: ResponsiveLayoutUtil.instance.isMobile(context) ? _DashboardPageView( @@ -49,6 +51,7 @@ class DashboardPage extends StatelessWidget { ) : DesktopSidebarWrapper( desktopSidebarViewModel: desktopSidebarViewModel, + dashboardViewModel: walletViewModel, child: DesktopDashboardPage( desktopSidebarViewModel: desktopSidebarViewModel, balancePage: balancePage, diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index ac5700af4..ea4d458ba 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -1,9 +1,6 @@ import 'dart:async'; -import 'package:cake_wallet/di.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; import 'package:cake_wallet/generated/i18n.dart'; -import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/yat_emoji_id.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/themes/theme_base.dart'; @@ -13,9 +10,7 @@ import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/balance_page.dart'; -import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator.dart'; import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart'; -import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/main.dart'; @@ -34,64 +29,12 @@ class DesktopDashboardPage extends BasePage { @override Color get backgroundDarkColor => Colors.transparent; - @override - Widget Function(BuildContext, Widget) get rootWrapper => - (BuildContext context, Widget scaffold) => Container( - decoration: BoxDecoration( - gradient: LinearGradient(colors: [ - Theme.of(context).accentColor, - Theme.of(context).scaffoldBackgroundColor, - Theme.of(context).primaryColor, - ], begin: Alignment.topRight, end: Alignment.bottomLeft)), - child: scaffold); @override bool get resizeToAvoidBottomInset => false; - @override - Widget? leading(BuildContext context) => getIt(); - - @override - Widget middle(BuildContext context) { - return SyncIndicator( - dashboardViewModel: walletViewModel, - onTap: () => Navigator.of(context, rootNavigator: true).pushNamed(Routes.connectionSync)); - } - - @override - Widget trailing(BuildContext context) { - final selectedIconPath = 'assets/images/desktop_transactions_solid_icon.png'; - final unselectedIconPath = 'assets/images/desktop_transactions_outline_icon.png'; - - return InkWell( - onTap: () { - String? currentPath; - - desktopKey.currentState?.popUntil((route) { - currentPath = route.settings.name; - return true; - }); - - if (currentPath == Routes.transactionsPage) { - desktopSidebarViewModel.resetSidebar(); - return; - } - desktopSidebarViewModel.onPageChange(SidebarItem.transactions); - - desktopKey.currentState!.pushNamed(Routes.transactionsPage); - - }, - child: Observer( - builder: (_) { - return Image.asset( - desktopSidebarViewModel.currentPage == SidebarItem.transactions - ? selectedIconPath - : unselectedIconPath, - ); - }, - ), - ); - } + + final BalancePage balancePage; final DashboardViewModel walletViewModel; diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart index 569773bed..bc7c0af84 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart @@ -6,19 +6,21 @@ class SideMenu extends StatelessWidget { super.key, required this.topItems, required this.bottomItems, + required this.width, }); + final List topItems; final List bottomItems; + final double width; @override Widget build(BuildContext context) { return Container( color: Colors.black.withOpacity(0.1), - width: 76, + width: width, height: MediaQuery.of(context).size.height, child: Column( children: [ - SizedBox(height: 20), ...topItems, Spacer(), ...bottomItems, diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart index f50cf6387..c7f388a92 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart @@ -12,9 +12,7 @@ class SideMenuItem extends StatelessWidget { final String iconPath; final bool isSelected; - @override - Widget build(BuildContext context) { - Color _setColor() { + Color _setColor(BuildContext context) { if (isSelected) { return Theme.of(context).primaryTextTheme.headline6!.color!; } else { @@ -22,6 +20,8 @@ class SideMenuItem extends StatelessWidget { } } + @override + Widget build(BuildContext context) { return InkWell( child: Padding( padding: EdgeInsets.all(20), @@ -30,7 +30,7 @@ class SideMenuItem extends StatelessWidget { fit: BoxFit.cover, height: 30, width: 30, - color: _setColor(), + color: _setColor(context), ), ), onTap: () => onTap.call(), diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart index d93df1994..7635ea6d2 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart @@ -1,23 +1,110 @@ +import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/routes.dart'; +import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart'; +import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; +import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator.dart'; +import 'package:cake_wallet/themes/theme_base.dart'; +import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:flutter/material.dart'; -import 'package:cake_wallet/router.dart' as Router; import 'package:flutter_mobx/flutter_mobx.dart'; +import 'package:cake_wallet/router.dart' as Router; import 'package:mobx/mobx.dart'; -class DesktopSidebarWrapper extends StatelessWidget { +class DesktopSidebarWrapper extends BasePage { final Widget child; final DesktopSidebarViewModel desktopSidebarViewModel; + final DashboardViewModel dashboardViewModel; - const DesktopSidebarWrapper({required this.child, required this.desktopSidebarViewModel}); + DesktopSidebarWrapper({ + required this.child, + required this.desktopSidebarViewModel, + required this.dashboardViewModel, + }); @override - Widget build(BuildContext context) { - final pageController = PageController(); + Color get backgroundLightColor => + currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; + @override + Color get backgroundDarkColor => Colors.transparent; + + final pageController = PageController(); + + final selectedIconPath = 'assets/images/desktop_transactions_solid_icon.png'; + final unselectedIconPath = 'assets/images/desktop_transactions_outline_icon.png'; + double get sideMenuWidth => 76.0; + + @override + Widget Function(BuildContext, Widget) get rootWrapper => + (BuildContext context, Widget scaffold) => Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context).accentColor, + Theme.of(context).scaffoldBackgroundColor, + Theme.of(context).primaryColor, + ], + begin: Alignment.topRight, + end: Alignment.bottomLeft, + ), + ), + child: scaffold, + ); + + @override + Widget? leading(BuildContext context) => Padding( + padding: EdgeInsets.only(left: sideMenuWidth), + child: getIt(), + ); + + @override + Widget middle(BuildContext context) { + return SyncIndicator( + dashboardViewModel: dashboardViewModel, + onTap: () => Navigator.of(context, rootNavigator: true).pushNamed(Routes.connectionSync)); + } + + @override + Widget trailing(BuildContext context) { + return InkWell( + onTap: () { + String? currentPath; + + desktopKey.currentState?.popUntil((route) { + currentPath = route.settings.name; + return true; + }); + + switch (currentPath) { + case Routes.transactionsPage: + desktopSidebarViewModel.resetSidebar(); + break; + default: + desktopSidebarViewModel.resetSidebar(); + Future.delayed(Duration(milliseconds: 10), () { + desktopSidebarViewModel.onPageChange(SidebarItem.transactions); + desktopKey.currentState?.pushNamed(Routes.transactionsPage); + }); + } + }, + child: Observer( + builder: (_) { + return Image.asset( + desktopSidebarViewModel.currentPage == SidebarItem.transactions + ? selectedIconPath + : unselectedIconPath, + ); + }, + ), + ); + } + + @override + Widget body(BuildContext context) { reaction((_) => desktopSidebarViewModel.currentPage, (page) { String? currentPath; @@ -33,11 +120,7 @@ class DesktopSidebarWrapper extends StatelessWidget { Navigator.of(desktopKey.currentContext!).pop(); } - pageController.animateToPage( - page.index, - duration: Duration(milliseconds: 300), - curve: Curves.easeInOut, - ); + pageController.jumpToPage(page.index); }); return Row( @@ -45,6 +128,7 @@ class DesktopSidebarWrapper extends StatelessWidget { children: [ Observer(builder: (_) { return SideMenu( + width: sideMenuWidth, topItems: [ SideMenuItem( iconPath: 'assets/images/wallet_outline.png', diff --git a/lib/src/screens/settings/desktop_settings/dashboard_settings_page.dart b/lib/src/screens/settings/desktop_settings/dashboard_settings_page.dart index c8e32f16f..69cd2ad27 100644 --- a/lib/src/screens/settings/desktop_settings/dashboard_settings_page.dart +++ b/lib/src/screens/settings/desktop_settings/dashboard_settings_page.dart @@ -16,14 +16,12 @@ class DesktopSettingsPage extends StatefulWidget { } class _DesktopSettingsPageState extends State { - int itemCount = SettingActions.all.length; + final int itemCount = SettingActions.all.length; int? currentPage; - bool isTapped = false; void _onItemChange(int index) { setState(() { currentPage = index; - isTapped = true; }); } @@ -54,7 +52,7 @@ class _DesktopSettingsPageState extends State { final isLastTile = index == itemCount; return SettingActionButton( isLastTile: isLastTile, - selectionActive: isTapped, + selectionActive: currentPage != null, isSelected: currentPage == index, isArrowVisible: true, onTap: () { diff --git a/lib/view_model/dashboard/desktop_sidebar_view_model.dart b/lib/view_model/dashboard/desktop_sidebar_view_model.dart index 516990d85..41a6881f7 100644 --- a/lib/view_model/dashboard/desktop_sidebar_view_model.dart +++ b/lib/view_model/dashboard/desktop_sidebar_view_model.dart @@ -3,13 +3,10 @@ import 'package:mobx/mobx.dart'; part 'desktop_sidebar_view_model.g.dart'; enum SidebarItem { - dashboard(0), - support(1), - settings(2), - transactions(3); - - final int value; - const SidebarItem(this.value); + dashboard, + support, + settings, + transactions; } class DesktopSidebarViewModel = DesktopSidebarViewModelBase with _$DesktopSidebarViewModel; @@ -23,6 +20,12 @@ abstract class DesktopSidebarViewModelBase with Store { @action void onPageChange(SidebarItem item) { + + if(currentPage == item){ + resetSidebar(); + + return; + } currentPage = item; } From 6caeae2817fc576cba754b3ca6b936f46db57e87 Mon Sep 17 00:00:00 2001 From: Godwin Asuquo Date: Tue, 14 Feb 2023 21:55:13 +0200 Subject: [PATCH 10/15] Add padding to support page --- .../dashboard/desktop_widgets/desktop_sidebar_wrapper.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart index 7635ea6d2..5d26f88f2 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart @@ -156,6 +156,7 @@ class DesktopSidebarWrapper extends BasePage { children: [ child, Container( + padding: EdgeInsets.all(20), child: Navigator( initialRoute: Routes.support, onGenerateRoute: (settings) => Router.createRoute(settings), From 843db65603337a51056548b1ea414ea2e39fc2d5 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 15 Feb 2023 01:28:10 +0200 Subject: [PATCH 11/15] Add width constraints to desktop dashboard --- .../dashboard/desktop_dashboard_page.dart | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index 1ab45fc7c..a5b5470e2 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -109,19 +109,24 @@ class DesktopDashboardPage extends BasePage { return Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Expanded( - flex: 3, + Container( + width: 400, child: balancePage, ), Expanded( - flex: 5, - child: Navigator( - key: desktopKey, - initialRoute: Routes.desktop_actions, - onGenerateRoute: (settings) => Router.createRoute(settings), - onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { - return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!]; - }, + flex: 4, + child: Center( + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: 500), + child: Navigator( + key: desktopKey, + initialRoute: Routes.desktop_actions, + onGenerateRoute: (settings) => Router.createRoute(settings), + onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { + return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!]; + }, + ), + ), ), ), ], From f8d70e7ce6c4e6eb06bf3c4a3ef33fda01a525f9 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 15 Feb 2023 16:07:46 +0200 Subject: [PATCH 12/15] Fix UI issues, paddings and alignments --- .../dashboard/desktop_dashboard_page.dart | 54 +++++++------------ .../desktop_sidebar_wrapper.dart | 11 ++-- .../dashboard/widgets/balance_page.dart | 6 +-- lib/src/widgets/nav_bar.dart | 27 ++++++---- 4 files changed, 44 insertions(+), 54 deletions(-) diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index eb307e9ac..5b957ba19 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -1,23 +1,19 @@ import 'dart:async'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; -import 'package:cake_wallet/di.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; import 'package:cake_wallet/generated/i18n.dart'; +import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/yat_emoji_id.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; -import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; -import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/balance_page.dart'; import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/main.dart'; import 'package:cake_wallet/router.dart' as Router; -class DesktopDashboardPage extends BasePage { +class DesktopDashboardPage extends StatelessWidget { DesktopDashboardPage({ required this.balancePage, required this.walletViewModel, @@ -25,32 +21,18 @@ class DesktopDashboardPage extends BasePage { required this.desktopSidebarViewModel, }); - static final GlobalKey desktopKey = GlobalKey(); - - @override - Color get backgroundLightColor => - currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; - - @override - Color get backgroundDarkColor => Colors.transparent; - - - @override - bool get resizeToAvoidBottomInset => false; - - - - final BalancePage balancePage; final DashboardViewModel walletViewModel; final WalletAddressListViewModel addressListViewModel; final DesktopSidebarViewModel desktopSidebarViewModel; + static final GlobalKey desktopKey = GlobalKey(); + bool _isEffectsInstalled = false; StreamSubscription? _onInactiveSub; @override - Widget body(BuildContext context) { + Widget build(BuildContext context) { _setEffects(context); return Row( @@ -60,19 +42,18 @@ class DesktopDashboardPage extends BasePage { width: 400, child: balancePage, ), - Expanded( - flex: 4, - child: Center( - child: ConstrainedBox( - constraints: BoxConstraints(maxWidth: 500), - child: Navigator( - key: desktopKey, - initialRoute: Routes.desktop_actions, - onGenerateRoute: (settings) => Router.createRoute(settings), - onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { - return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!]; - }, - ), + Flexible( + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: 500), + child: Navigator( + key: desktopKey, + initialRoute: Routes.desktop_actions, + onGenerateRoute: (settings) => Router.createRoute(settings), + onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { + return [ + navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))! + ]; + }, ), ), ), @@ -128,3 +109,4 @@ class DesktopDashboardPage extends BasePage { }); } } + diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart index 02b8ef62b..ec6ff1a32 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart @@ -2,7 +2,6 @@ import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_dashboard_page.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; @@ -31,12 +30,16 @@ class DesktopSidebarWrapper extends BasePage { currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; @override - Color get backgroundDarkColor => Colors.transparent; + Color get backgroundDarkColor => Colors.black.withOpacity(0.1); + + @override + bool get resizeToAvoidBottomInset => false; final pageController = PageController(); final selectedIconPath = 'assets/images/desktop_transactions_solid_icon.png'; final unselectedIconPath = 'assets/images/desktop_transactions_outline_icon.png'; + double get sideMenuWidth => 76.0; @override @@ -75,7 +78,7 @@ class DesktopSidebarWrapper extends BasePage { onTap: () { String? currentPath; - desktopKey.currentState?.popUntil((route) { + DesktopDashboardPage.desktopKey.currentState?.popUntil((route) { currentPath = route.settings.name; return true; }); @@ -88,7 +91,7 @@ class DesktopSidebarWrapper extends BasePage { desktopSidebarViewModel.resetSidebar(); Future.delayed(Duration(milliseconds: 10), () { desktopSidebarViewModel.onPageChange(SidebarItem.transactions); - desktopKey.currentState?.pushNamed(Routes.transactionsPage); + DesktopDashboardPage.desktopKey.currentState?.pushNamed(Routes.transactionsPage); }); } }, diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index fe750538b..bf8b1ae17 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -1,10 +1,8 @@ -import 'package:cake_wallet/di.dart'; -import 'package:cake_wallet/src/widgets/standard_list.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/themes/theme_base.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; -import 'package:flutter/scheduler.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:auto_size_text/auto_size_text.dart'; import 'package:cake_wallet/src/widgets/introducing_card.dart'; @@ -26,7 +24,7 @@ class BalancePage extends StatelessWidget{ child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 56), + SizedBox(height: ResponsiveLayoutUtil.instance.isMobile(context) ? 56 : 16), Container( margin: const EdgeInsets.only(left: 24, bottom: 16), child: Observer(builder: (_) { diff --git a/lib/src/widgets/nav_bar.dart b/lib/src/widgets/nav_bar.dart index 517d0540f..230e0caad 100644 --- a/lib/src/widgets/nav_bar.dart +++ b/lib/src/widgets/nav_bar.dart @@ -52,21 +52,28 @@ class NavBar extends StatelessWidget implements ObstructingPreferredSizeWidget { @override Widget build(BuildContext context) { + if (leading == null && middle == null && trailing == null) { + return const SizedBox(); + } + final pad = height - _originalHeight; final paddingTop = pad / 2; final _paddingBottom = (pad / 2); if (!ResponsiveLayoutUtil.instance.isMobile(context)) { - return Padding( - padding: const EdgeInsetsDirectional.only(end: 24, top: 8, bottom: 8), - child: Row( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - if (leading != null) Flexible(child: leading!) else const SizedBox(), - if (middle != null) middle!, - trailing ?? const SizedBox(), - ], + return Container( + padding: const EdgeInsetsDirectional.only(end: 24), + color: backgroundColor, + child: Center( + child: Row( + mainAxisSize: MainAxisSize.max, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (leading != null) Flexible(child: leading!) else const SizedBox(), + if (middle != null) middle!, + trailing ?? const SizedBox(), + ], + ), ), ); } From 8de9c80fe1f13668d21e781801c05c073746cede Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 15 Feb 2023 20:55:06 +0200 Subject: [PATCH 13/15] Rename misleading variable Change initial mac window size --- lib/di.dart | 2 +- lib/src/screens/dashboard/dashboard_page.dart | 11 +++++------ lib/src/screens/dashboard/desktop_dashboard_page.dart | 10 +++++----- macos/Runner/Base.lproj/MainMenu.xib | 10 +++++----- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index 37e547b93..fd397cb40 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -371,7 +371,7 @@ Future setup( getIt.registerFactory(() => DashboardPage( balancePage: getIt.get(), - walletViewModel: getIt.get(), + dashboardViewModel: getIt.get(), addressListViewModel: getIt.get(), desktopSidebarViewModel: getIt.get(), )); diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 0557f0415..59e7ca313 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/entities/main_actions.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_dashboard_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart'; @@ -30,13 +29,13 @@ import 'package:cake_wallet/router.dart' as Router; class DashboardPage extends StatelessWidget { DashboardPage({ required this.balancePage, - required this.walletViewModel, + required this.dashboardViewModel, required this.addressListViewModel, required this.desktopSidebarViewModel, }); final BalancePage balancePage; - final DashboardViewModel walletViewModel; + final DashboardViewModel dashboardViewModel; final WalletAddressListViewModel addressListViewModel; final DesktopSidebarViewModel desktopSidebarViewModel; @@ -46,16 +45,16 @@ class DashboardPage extends StatelessWidget { body: ResponsiveLayoutUtil.instance.isMobile(context) ? _DashboardPageView( balancePage: balancePage, - walletViewModel: walletViewModel, + walletViewModel: dashboardViewModel, addressListViewModel: addressListViewModel, ) : DesktopSidebarWrapper( desktopSidebarViewModel: desktopSidebarViewModel, - dashboardViewModel: walletViewModel, + dashboardViewModel: dashboardViewModel, child: DesktopDashboardPage( desktopSidebarViewModel: desktopSidebarViewModel, balancePage: balancePage, - walletViewModel: walletViewModel, + dashboardViewModel: dashboardViewModel, addressListViewModel: addressListViewModel, ), ), diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index 5b957ba19..382a7be90 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -16,13 +16,13 @@ import 'package:cake_wallet/router.dart' as Router; class DesktopDashboardPage extends StatelessWidget { DesktopDashboardPage({ required this.balancePage, - required this.walletViewModel, + required this.dashboardViewModel, required this.addressListViewModel, required this.desktopSidebarViewModel, }); final BalancePage balancePage; - final DashboardViewModel walletViewModel; + final DashboardViewModel dashboardViewModel; final WalletAddressListViewModel addressListViewModel; final DesktopSidebarViewModel desktopSidebarViewModel; @@ -68,7 +68,7 @@ class DesktopDashboardPage extends StatelessWidget { _isEffectsInstalled = true; autorun((_) async { - if (!walletViewModel.isOutdatedElectrumWallet) { + if (!dashboardViewModel.isOutdatedElectrumWallet) { return; } @@ -94,13 +94,13 @@ class DesktopDashboardPage extends StatelessWidget { Future.delayed(Duration(milliseconds: 500)).then((_) { showPopUp( context: navigatorKey.currentContext!, - builder: (_) => YatEmojiId(walletViewModel.yatStore.emoji)); + builder: (_) => YatEmojiId(dashboardViewModel.yatStore.emoji)); needToPresentYat = false; }); } }); - walletViewModel.yatStore.emojiIncommingStream.listen((String emoji) { + dashboardViewModel.yatStore.emojiIncommingStream.listen((String emoji) { if (!_isEffectsInstalled || emoji.isEmpty) { return; } diff --git a/macos/Runner/Base.lproj/MainMenu.xib b/macos/Runner/Base.lproj/MainMenu.xib index 871d31ce7..a6981c270 100644 --- a/macos/Runner/Base.lproj/MainMenu.xib +++ b/macos/Runner/Base.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - + @@ -332,13 +332,13 @@ - + - + - + From 5296a2118a6a72861a7af119085567ad88a87de6 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Wed, 15 Feb 2023 23:50:15 +0200 Subject: [PATCH 14/15] Remove duplicated constrains --- .../screens/new_wallet/new_wallet_page.dart | 52 +++++++++---------- .../new_wallet/new_wallet_type_page.dart | 15 +++--- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/lib/src/screens/new_wallet/new_wallet_page.dart b/lib/src/screens/new_wallet/new_wallet_page.dart index 054961c44..44d0ed3f8 100644 --- a/lib/src/screens/new_wallet/new_wallet_page.dart +++ b/lib/src/screens/new_wallet/new_wallet_page.dart @@ -91,8 +91,7 @@ class _WalletNameFormState extends State { contentPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), content: Center( child: ConstrainedBox( - constraints: - BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), + constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -197,32 +196,29 @@ class _WalletNameFormState extends State { ), ), bottomSectionPadding: EdgeInsets.all(24), - bottomSection: ConstrainedBox( - constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), - child: Column( - children: [ - Observer( - builder: (context) { - return LoadingPrimaryButton( - onPressed: _confirmForm, - text: S.of(context).seed_language_next, - color: Colors.green, - textColor: Colors.white, - isLoading: _walletNewVM.state is IsExecutingState, - isDisabled: _walletNewVM.name.isEmpty, - ); - }, - ), - const SizedBox(height: 25), - GestureDetector( - onTap: () { - Navigator.of(context) - .pushNamed(Routes.advancedPrivacySettings, arguments: _walletNewVM.type); - }, - child: Text(S.of(context).advanced_privacy_settings), - ), - ], - ), + bottomSection: Column( + children: [ + Observer( + builder: (context) { + return LoadingPrimaryButton( + onPressed: _confirmForm, + text: S.of(context).seed_language_next, + color: Colors.green, + textColor: Colors.white, + isLoading: _walletNewVM.state is IsExecutingState, + isDisabled: _walletNewVM.name.isEmpty, + ); + }, + ), + const SizedBox(height: 25), + GestureDetector( + onTap: () { + Navigator.of(context) + .pushNamed(Routes.advancedPrivacySettings, arguments: _walletNewVM.type); + }, + child: Text(S.of(context).advanced_privacy_settings), + ), + ], )), ); } diff --git a/lib/src/screens/new_wallet/new_wallet_type_page.dart b/lib/src/screens/new_wallet/new_wallet_type_page.dart index 3493f60e0..407582923 100644 --- a/lib/src/screens/new_wallet/new_wallet_type_page.dart +++ b/lib/src/screens/new_wallet/new_wallet_type_page.dart @@ -96,15 +96,12 @@ class WalletTypeFormState extends State { ), ), bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24), - bottomSection: ConstrainedBox( - constraints: BoxConstraints(maxWidth: ResponsiveLayoutUtil.kDesktopMaxWidthConstraint), - child: PrimaryButton( - onPressed: () => onTypeSelected(), - text: S.of(context).seed_language_next, - color: Theme.of(context).accentTextTheme.bodyText1!.color!, - textColor: Colors.white, - isDisabled: selected == null, - ), + bottomSection: PrimaryButton( + onPressed: () => onTypeSelected(), + text: S.of(context).seed_language_next, + color: Theme.of(context).accentTextTheme.bodyText1!.color!, + textColor: Colors.white, + isDisabled: selected == null, ), ); } From 55bf964a27bb102670cb12b91f9941afe763f495 Mon Sep 17 00:00:00 2001 From: OmarHatem Date: Thu, 16 Feb 2023 17:51:52 +0200 Subject: [PATCH 15/15] - Use close icon on main screens - Minor UI fixes --- lib/di.dart | 1 - lib/src/screens/base_page.dart | 23 +++++++++++-------- lib/src/screens/dashboard/dashboard_page.dart | 2 -- .../dashboard/desktop_dashboard_page.dart | 3 --- .../dashboard/widgets/address_page.dart | 22 +++--------------- lib/src/screens/exchange/exchange_page.dart | 3 +++ lib/src/screens/send/send_page.dart | 5 +++- 7 files changed, 24 insertions(+), 35 deletions(-) diff --git a/lib/di.dart b/lib/di.dart index fd397cb40..a520c9b4c 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -7,7 +7,6 @@ import 'package:cake_wallet/ionia/ionia_anypay.dart'; import 'package:cake_wallet/ionia/ionia_gift_card.dart'; import 'package:cake_wallet/ionia/ionia_tip.dart'; import 'package:cake_wallet/src/screens/buy/onramper_page.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_dashboard_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart'; import 'package:cake_wallet/src/screens/settings/display_settings_page.dart'; diff --git a/lib/src/screens/base_page.dart b/lib/src/screens/base_page.dart index 92bf56eaf..4dd065d37 100644 --- a/lib/src/screens/base_page.dart +++ b/lib/src/screens/base_page.dart @@ -1,4 +1,5 @@ import 'package:cake_wallet/themes/theme_base.dart'; +import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/palette.dart'; @@ -20,7 +21,7 @@ abstract class BasePage extends StatelessWidget { String? get title => null; - bool get isModalBackButton => false; + bool get canUseCloseIcon => false; Color get backgroundLightColor => Colors.white; @@ -50,23 +51,27 @@ abstract class BasePage extends StatelessWidget { } final _backButton = Icon(Icons.arrow_back_ios, - color: titleColor ?? Theme.of(context).primaryTextTheme!.headline6!.color!, + color: titleColor ?? Theme.of(context).primaryTextTheme.headline6!.color!, size: 16,); final _closeButton = currentTheme.type == ThemeType.dark ? closeButtonImageDarkTheme : closeButtonImage; + bool isMobileView = ResponsiveLayoutUtil.instance.isMobile(context); + return SizedBox( - height: 37, - width: 37, + height: isMobileView ? 37 : 45, + width: isMobileView ? 37 : 45, child: ButtonTheme( minWidth: double.minPositive, child: TextButton( - // FIX-ME: Style - //highlightColor: Colors.transparent, - //splashColor: Colors.transparent, - //padding: EdgeInsets.all(0), + style: ButtonStyle( + overlayColor: MaterialStateColor.resolveWith((states) => Colors.transparent), + ), onPressed: () => onClose(context), - child: isModalBackButton ? _closeButton : _backButton), + child: canUseCloseIcon && !isMobileView + ? _closeButton + : _backButton, + ), ), ); } diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 59e7ca313..cd0c7d06a 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -24,7 +24,6 @@ import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:smooth_page_indicator/smooth_page_indicator.dart'; import 'package:cake_wallet/main.dart'; -import 'package:cake_wallet/router.dart' as Router; class DashboardPage extends StatelessWidget { DashboardPage({ @@ -52,7 +51,6 @@ class DashboardPage extends StatelessWidget { desktopSidebarViewModel: desktopSidebarViewModel, dashboardViewModel: dashboardViewModel, child: DesktopDashboardPage( - desktopSidebarViewModel: desktopSidebarViewModel, balancePage: balancePage, dashboardViewModel: dashboardViewModel, addressListViewModel: addressListViewModel, diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index 382a7be90..f79d2f9e2 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -4,7 +4,6 @@ import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/yat_emoji_id.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; -import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/balance_page.dart'; @@ -18,13 +17,11 @@ class DesktopDashboardPage extends StatelessWidget { required this.balancePage, required this.dashboardViewModel, required this.addressListViewModel, - required this.desktopSidebarViewModel, }); final BalancePage balancePage; final DashboardViewModel dashboardViewModel; final WalletAddressListViewModel addressListViewModel; - final DesktopSidebarViewModel desktopSidebarViewModel; static final GlobalKey desktopKey = GlobalKey(); diff --git a/lib/src/screens/dashboard/widgets/address_page.dart b/lib/src/screens/dashboard/widgets/address_page.dart index 9a06dc39d..9183ad156 100644 --- a/lib/src/screens/dashboard/widgets/address_page.dart +++ b/lib/src/screens/dashboard/widgets/address_page.dart @@ -42,26 +42,10 @@ class AddressPage extends BasePage { bool get resizeToAvoidBottomInset => false; @override - Widget leading(BuildContext context) { - final _backButton = Icon(Icons.arrow_back_ios, - color: Theme.of(context).accentTextTheme!.headline2!.backgroundColor!, - size: 16,); + Color get titleColor => Colors.white; - return SizedBox( - height: 37, - width: 37, - child: ButtonTheme( - minWidth: double.minPositive, - child: TextButton( - // FIX-ME: Style - //highlightColor: Colors.transparent, - //splashColor: Colors.transparent, - //padding: EdgeInsets.all(0), - onPressed: () => onClose(context), - child: _backButton), - ), - ); - } + @override + bool get canUseCloseIcon => true; @override Widget middle(BuildContext context) { diff --git a/lib/src/screens/exchange/exchange_page.dart b/lib/src/screens/exchange/exchange_page.dart index 8a6509a0d..288d3d632 100644 --- a/lib/src/screens/exchange/exchange_page.dart +++ b/lib/src/screens/exchange/exchange_page.dart @@ -108,6 +108,9 @@ class ExchangePage extends BasePage { exchangeViewModel.reset(); }); + @override + bool get canUseCloseIcon => true; + @override Widget body(BuildContext context) { WidgetsBinding.instance diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 5727c1e15..5d1f378d1 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -51,6 +51,9 @@ class SendPage extends BasePage { @override bool get extendBodyBehindAppBar => true; + @override + bool get canUseCloseIcon => true; + @override AppBarStyle get appBarStyle => AppBarStyle.transparent; @@ -58,7 +61,7 @@ class SendPage extends BasePage { final double initialHeight = sendViewModel.isElectrumWallet ? 490 : 465; if (!ResponsiveLayoutUtil.instance.isMobile(context)) { - return initialHeight - 77; + return initialHeight - 66; } return initialHeight; }