Merge pull request #802 from cake-tech/CW-321-lock-app-feature-on-mac

Add app lock feature on mac
This commit is contained in:
Omar Hatem 2023-02-24 15:38:35 +02:00 committed by GitHub
commit f0164db47f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 24 deletions

View file

@ -4,12 +4,14 @@ class SideMenuItem extends StatelessWidget {
const SideMenuItem({
Key? key,
required this.onTap,
required this.iconPath,
required this.isSelected,
}) : super(key: key);
this.imagePath,
this.icon,
this.isSelected = false,
}) : assert((icon != null && imagePath == null) || (icon == null && imagePath != null));
final void Function() onTap;
final String iconPath;
final String? imagePath;
final IconData? icon;
final bool isSelected;
Color _setColor(BuildContext context) {
@ -25,8 +27,13 @@ class SideMenuItem extends StatelessWidget {
return InkWell(
child: Padding(
padding: EdgeInsets.all(20),
child: Image.asset(
iconPath,
child: icon != null
? Icon(
icon,
color: _setColor(context),
)
: Image.asset(
imagePath ?? '',
fit: BoxFit.cover,
height: 30,
width: 30,

View file

@ -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) {
if (isAuthenticatedSuccessfully) {
auth.close();
}
},
);
},
)
],
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),
),

View file

@ -17,10 +17,8 @@ abstract class DesktopSidebarViewModelBase with Store {
@observable
SidebarItem currentPage = SidebarItem.dashboard;
@action
void onPageChange(SidebarItem item) {
if (currentPage == item) {
resetSidebar();