Files
hash-wallet/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart
T
5eabdcdca1 Cw 604 integrate bitcoin ledger (#1407)
* CW-503 Prepare Ledger integration

* CW-503 Revert Tor ignore

* CW-503 Add Connect Device Page

* CW-503 Add createWalletFromDevice for monero

* CW-503 Add Connect Device Page

* CW-503 Add Connect Device Page

* CW-503 Add Debug Options

* CW-503 Add proper hardware wallet selection screen

* CW-503 Minor design changes on connect_device_page

* CW-503 Add Create Wallet from Ledger

* CW-503 Spent Ledger ETH Funds

* CW-503 Minor fixes

* CW-503 Fix Merge conflicts

* CW-503 Fix Merge conflicts

* CW-503 Fix Merge conflicts

* CW-503 Fix minor conflicts

* CW-503 Improve Ledger BLE Communication

* CW-503 Improve Ledger BLE Communication

* CW-503 Rollback Monero Test code

* CW-503 Fix Execution failed for task :app:checkReleaseDuplicateClasses

* CW-503 Better Error-Exceptions

* CW-503 Add SetPinScreen before restore from hardware-wallet

* CW-503 override web3dart to use cake's git hosted version

* CW-503 Implement ledger sign messages

* CW-503 Implement ledger sign messages and send erc20 tokens

* CW-503 Fix merge conflicts

* CW-503 Fix merge conflicts

* CW-503 Use dep override for ledger_flutter

* CW-503 Ledger ERC20 finalisation

* CW-503 More graceful error handling

* CW-503 Even more graceful error handling & remove debug code

* CW-503 Minor Changes for Vik

* CW-503 Fix USB connection

* CW-503 Maybe this overrides web3dart finally

* Indicate Loading on the first 5 Wallet Accounts

* Prepare Ledger Bitcoin

* Fix conflicts with main

* Add Bluetooth permission to iOS [skip ci]

* add privacyinfo for ios [skip ci]

* update PrivacyInfo.xcprivacy [scip ci]

* ios shit [skip ci]

* Improve bitcoin xpub

* Resolve open Todos regarding iOS Support

* Minor debug

* Remove erc20 dependency to have more granular control over the tx UX

* Create Bitcoin Wallets using xpub

* Create Bitcoin Wallets using xpub

* Better error handling

* Improve Ledger account handling

* Add Bitcoin Support for Ledger

* Add Bitcoin Support for Ledger

* Add Bitcoin Support for Ledger

* Implement requested Changes

* Implement requested Changes

* Minor fix

* Implement requested Changes

* Implement requested Changes

* Add comment to remind me

* Enable RBF for Bitcoin Ledger

* Fix merge conflicts

* Update wallet_info.dart

* Cw 503 ledger support (#1310)

* CW-503 Prepare Ledger integration

* CW-503 Revert Tor ignore

* CW-503 Add Connect Device Page

* CW-503 Add createWalletFromDevice for monero

* CW-503 Add Connect Device Page

* CW-503 Add Connect Device Page

* CW-503 Add Debug Options

* CW-503 Add proper hardware wallet selection screen

* CW-503 Minor design changes on connect_device_page

* CW-503 Add Create Wallet from Ledger

* CW-503 Spent Ledger ETH Funds

* CW-503 Minor fixes

* CW-503 Fix Merge conflicts

* CW-503 Fix Merge conflicts

* CW-503 Fix Merge conflicts

* CW-503 Fix minor conflicts

* CW-503 Improve Ledger BLE Communication

* CW-503 Improve Ledger BLE Communication

* CW-503 Rollback Monero Test code

* CW-503 Fix Execution failed for task :app:checkReleaseDuplicateClasses

* CW-503 Better Error-Exceptions

* CW-503 Add SetPinScreen before restore from hardware-wallet

* CW-503 override web3dart to use cake's git hosted version

* CW-503 Implement ledger sign messages

* CW-503 Implement ledger sign messages and send erc20 tokens

* CW-503 Fix merge conflicts

* CW-503 Fix merge conflicts

* CW-503 Use dep override for ledger_flutter

* CW-503 Ledger ERC20 finalisation

* CW-503 More graceful error handling

* CW-503 Even more graceful error handling & remove debug code

* CW-503 Minor Changes for Vik

* CW-503 Fix USB connection

* CW-503 Maybe this overrides web3dart finally

* Indicate Loading on the first 5 Wallet Accounts

* Fix conflicts with main

* Add Bluetooth permission to iOS [skip ci]

* add privacyinfo for ios [skip ci]

* update PrivacyInfo.xcprivacy [scip ci]

* ios shit [skip ci]

* Resolve open Todos regarding iOS Support

* Remove erc20 dependency to have more granular control over the tx UX

* Better error handling

* Improve Ledger account handling

* Implement requested Changes

* Implement requested Changes

* Implement requested Changes

* Implement requested Changes

* Fix merge conflicts

* Update wallet_info.dart

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>

* Fix merge conflicts

* Fix merge conflicts

* Minor Fix to derivations

* Update cw_bitcoin/lib/bitcoin_wallet.dart [skip ci]

* Update cw_bitcoin/lib/bitcoin_wallet.dart [skip ci]

* Update cw_bitcoin/lib/electrum_wallet.dart [skip ci]

* Fix backward compatibility issues

* Merge Tron

* Fix Tron with HW changes

* fix ble on iOS
fix tron address validation

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-05-05 04:44:50 +03:00

179 lines
7.3 KiB
Dart

import 'package:cake_wallet/core/wallet_connect/wc_bottom_sheet_service.dart';
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/base_page.dart';
import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_navbar.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/src/screens/wallet_connect/widgets/modals/bottom_sheet_listener.dart';
import 'package:cake_wallet/src/widgets/services_updates_widget.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/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cake_wallet/router.dart' as Router;
import 'package:mobx/mobx.dart';
class DesktopSidebarWrapper extends BasePage {
final BottomSheetService bottomSheetService;
final Widget child;
final DesktopSidebarViewModel desktopSidebarViewModel;
final DashboardViewModel dashboardViewModel;
final GlobalKey<NavigatorState> desktopNavigatorKey;
DesktopSidebarWrapper({
required this.child,
required this.bottomSheetService,
required this.desktopSidebarViewModel,
required this.dashboardViewModel,
required this.desktopNavigatorKey,
});
@override
ObstructingPreferredSizeWidget appBar(BuildContext context) => DesktopDashboardNavbar(
leading: Padding(
padding: EdgeInsets.only(left: sideMenuWidth),
child: getIt<DesktopWalletSelectionDropDown>(),
),
middle: SyncIndicator(
dashboardViewModel: dashboardViewModel,
onTap: () => Navigator.of(context, rootNavigator: true).pushNamed(Routes.connectionSync),
),
trailing: InkWell(
onTap: () {
Navigator.of(context).pushNamed(
Routes.unlock,
arguments: (bool isAuthenticatedSuccessfully, AuthPageState auth) {
if (isAuthenticatedSuccessfully) {
auth.close();
}
},
);
},
child: Icon(Icons.lock_outline),
),
);
@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
Widget body(BuildContext context) {
_setEffects();
return BottomSheetListener(
bottomSheetService: bottomSheetService,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Observer(builder: (_) {
return SideMenu(
width: sideMenuWidth,
topItems: [
SideMenuItem(
// imagePath: 'assets/images/wallet_outline.png',
icon: Icons.home,
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.dashboard,
onTap: () {
desktopSidebarViewModel.onPageChange(SidebarItem.dashboard);
desktopNavigatorKey.currentState
?.pushNamedAndRemoveUntil(Routes.desktop_actions, (route) => false);
},
),
SideMenuItem(
onTap: () {
if (desktopSidebarViewModel.currentPage == SidebarItem.transactions) {
desktopNavigatorKey.currentState
?.pushNamedAndRemoveUntil(Routes.desktop_actions, (route) => false);
desktopSidebarViewModel.resetSidebar();
} else {
desktopSidebarViewModel.onPageChange(SidebarItem.transactions);
desktopNavigatorKey.currentState?.pushNamed(Routes.transactionsPage);
}
},
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.transactions,
imagePath: desktopSidebarViewModel.currentPage == SidebarItem.transactions
? selectedIconPath
: unselectedIconPath,
),
SideMenuItem(
widget: ServicesUpdatesWidget(
dashboardViewModel.getServicesStatus(),
enabled: dashboardViewModel.isEnabledBulletinAction,
),
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.status,
onTap: () {},
),
],
bottomItems: [
SideMenuItem(
imagePath: 'assets/images/support_icon.png',
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.support,
onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.support),
),
SideMenuItem(
imagePath: 'assets/images/settings_outline.png',
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.settings,
onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.settings),
),
],
);
}),
Expanded(
child: PageView(
controller: pageController,
physics: NeverScrollableScrollPhysics(),
children: [
child,
Container(
color: Theme.of(context).colorScheme.background,
padding: EdgeInsets.all(20),
child: Navigator(
initialRoute: Routes.support,
onGenerateRoute: (settings) => Router.createRoute(settings),
onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) {
return [
navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!
];
},
),
),
Navigator(
initialRoute: Routes.desktop_settings_page,
onGenerateRoute: (settings) => Router.createRoute(settings),
onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) {
return [
navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!
];
},
),
],
),
),
],
),
);
}
void _setEffects() async {
reaction<SidebarItem>((_) => desktopSidebarViewModel.currentPage, (page) {
if (page == SidebarItem.dashboard) {
pageController.jumpToPage(0);
return;
}
pageController.jumpToPage(page.index - 1);
});
}
}