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 c7f388a92..d84c864d7 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 @@ -4,34 +4,41 @@ class SideMenuItem extends StatelessWidget { const SideMenuItem({ Key? key, required this.onTap, - required this.iconPath, - required this.isSelected, + this.imagePath, + this.icon, + this.isSelected = false, }) : super(key: key); final void Function() onTap; - final String iconPath; + final String? imagePath; + final IconData? icon; final bool isSelected; - Color _setColor(BuildContext context) { - if (isSelected) { - return Theme.of(context).primaryTextTheme.headline6!.color!; - } else { - return Theme.of(context).highlightColor; - } + Color _setColor(BuildContext context) { + if (isSelected) { + return Theme.of(context).primaryTextTheme.headline6!.color!; + } else { + return Theme.of(context).highlightColor; } + } @override Widget build(BuildContext context) { return InkWell( child: Padding( padding: EdgeInsets.all(20), - child: Image.asset( - iconPath, - fit: BoxFit.cover, - height: 30, - width: 30, - color: _setColor(context), - ), + child: icon != null + ? Icon( + icon, + color: _setColor(context), + ) + : Image.asset( + imagePath ?? '', + fit: BoxFit.cover, + height: 30, + width: 30, + color: _setColor(context), + ), ), onTap: () => onTap.call(), highlightColor: 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 a411c0243..6f5b2287e 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,6 @@ import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/routes.dart'; +import 'package:cake_wallet/src/screens/auth/auth_page.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_navbar.dart'; @@ -93,18 +94,31 @@ class DesktopSidebarWrapper extends BasePage { width: sideMenuWidth, topItems: [ SideMenuItem( - iconPath: 'assets/images/wallet_outline.png', + imagePath: 'assets/images/wallet_outline.png', isSelected: desktopSidebarViewModel.currentPage == SidebarItem.dashboard, onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.dashboard), ), + SideMenuItem( + icon: Icons.lock_outline, + onTap: () { + Navigator.of(context).pushNamed( + Routes.unlock, + arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) { + auth.close( + route: isAuthenticatedSuccessfully ? Routes.dashboard : null, + ); + }, + ); + }, + ) ], bottomItems: [ SideMenuItem( - iconPath: 'assets/images/support_icon.png', + imagePath: 'assets/images/support_icon.png', isSelected: desktopSidebarViewModel.currentPage == SidebarItem.support, onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.support)), SideMenuItem( - iconPath: 'assets/images/settings_outline.png', + imagePath: 'assets/images/settings_outline.png', isSelected: desktopSidebarViewModel.currentPage == SidebarItem.settings, onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.settings), ), diff --git a/lib/view_model/dashboard/desktop_sidebar_view_model.dart b/lib/view_model/dashboard/desktop_sidebar_view_model.dart index 41a6881f7..d0320c05f 100644 --- a/lib/view_model/dashboard/desktop_sidebar_view_model.dart +++ b/lib/view_model/dashboard/desktop_sidebar_view_model.dart @@ -17,13 +17,11 @@ abstract class DesktopSidebarViewModelBase with Store { @observable SidebarItem currentPage = SidebarItem.dashboard; - @action void onPageChange(SidebarItem item) { - - if(currentPage == item){ + if (currentPage == item) { resetSidebar(); - + return; } currentPage = item;