mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
Fix issues from code review
This commit is contained in:
parent
a1abdc849a
commit
b1b8193043
7 changed files with 122 additions and 222 deletions
|
@ -3,9 +3,6 @@ import 'package:cake_wallet/di.dart';
|
|||
import 'package:cake_wallet/entities/main_actions.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/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/src/screens/dashboard/widgets/market_place_page.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
|
@ -27,126 +24,14 @@ 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 StatefulWidget {
|
||||
class DashboardPage extends BasePage {
|
||||
DashboardPage({
|
||||
required this.balancePage,
|
||||
required this.walletViewModel,
|
||||
required this.addressListViewModel,
|
||||
});
|
||||
|
||||
final BalancePage balancePage;
|
||||
final DashboardViewModel walletViewModel;
|
||||
final WalletAddressListViewModel addressListViewModel;
|
||||
|
||||
@override
|
||||
State<DashboardPage> createState() => _DashboardPageState();
|
||||
}
|
||||
|
||||
class _DashboardPageState extends State<DashboardPage> {
|
||||
final page = PageController();
|
||||
final sideMenu = SideMenuController();
|
||||
@override
|
||||
void initState() {
|
||||
SideMenuGlobal.controller = sideMenu;
|
||||
sideMenu.addListener((p0) {
|
||||
page.jumpToPage(p0);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (ResponsiveLayoutUtil.instance.isMobile(context)) {
|
||||
return Scaffold(
|
||||
body: _DashboardPage(
|
||||
balancePage: widget.balancePage,
|
||||
walletViewModel: widget.walletViewModel,
|
||||
addressListViewModel: widget.addressListViewModel,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
body: Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: PageView(
|
||||
controller: page,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
_DashboardPage(
|
||||
balancePage: widget.balancePage,
|
||||
walletViewModel: widget.walletViewModel,
|
||||
addressListViewModel: widget.addressListViewModel,
|
||||
),
|
||||
Container(
|
||||
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))!
|
||||
];
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DashboardPage extends BasePage {
|
||||
_DashboardPage({
|
||||
required this.balancePage,
|
||||
required this.walletViewModel,
|
||||
required this.addressListViewModel,
|
||||
});
|
||||
|
||||
final BalancePage balancePage;
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,31 +1,123 @@
|
|||
import 'package:cake_wallet/routes.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:flutter/material.dart';
|
||||
import 'package:cake_wallet/router.dart' as Router;
|
||||
|
||||
class DesktopDashboardView extends StatelessWidget {
|
||||
class DesktopDashboardView extends StatefulWidget {
|
||||
final Widget balancePage;
|
||||
|
||||
const DesktopDashboardView(this.balancePage, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<DesktopDashboardView> createState() => _DesktopDashboardViewState();
|
||||
}
|
||||
|
||||
class _DesktopDashboardViewState extends State<DesktopDashboardView> {
|
||||
|
||||
final page = PageController();
|
||||
final sideMenu = SideMenuController();
|
||||
@override
|
||||
void initState() {
|
||||
SideMenuGlobal.controller = sideMenu;
|
||||
sideMenu.addListener((p0) {
|
||||
page.jumpToPage(p0);
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
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)
|
||||
,
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(
|
||||
child: PageView(
|
||||
controller: page,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
children: [
|
||||
_DashboardPage(
|
||||
balancePage: widget.balancePage,
|
||||
),
|
||||
Container(
|
||||
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))!
|
||||
];
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _DashboardPage extends StatelessWidget {
|
||||
final Widget balancePage;
|
||||
|
||||
const _DashboardPage({Key? key, required this.balancePage}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: balancePage,
|
||||
),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Navigator(
|
||||
initialRoute: Routes.desktop_actions,
|
||||
onGenerateRoute: (settings) => Router.createRoute(settings),
|
||||
onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) {
|
||||
return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!];
|
||||
},
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: balancePage),
|
||||
Expanded(
|
||||
flex: 5,
|
||||
child: Navigator(
|
||||
initialRoute: Routes.desktop_actions,
|
||||
onGenerateRoute: (settings) => Router.createRoute(settings),
|
||||
onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) {
|
||||
return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!];
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
import 'package:cake_wallet/src/screens/dashboard/wallet_menu_item.dart';
|
||||
import 'package:cake_wallet/src/widgets/setting_actions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
// FIXME: terrible design
|
||||
|
||||
class WalletMenu {
|
||||
WalletMenu._();
|
||||
|
||||
static List<WalletMenuItem> items = [
|
||||
WalletMenuItem(
|
||||
title: SettingActions.connectionSettingAction.name,
|
||||
image: SettingActions.connectionSettingAction.image,
|
||||
handler: (BuildContext context) => SettingActions.connectionSettingAction.onTap(context),
|
||||
),
|
||||
WalletMenuItem(
|
||||
title: SettingActions.walletSettingAction.name,
|
||||
image: SettingActions.walletSettingAction.image,
|
||||
handler: (BuildContext context) => SettingActions.walletSettingAction.onTap(context),
|
||||
),
|
||||
WalletMenuItem(
|
||||
title: SettingActions.addressBookSettingAction.name,
|
||||
image: SettingActions.addressBookSettingAction.image,
|
||||
handler: (BuildContext context) => SettingActions.addressBookSettingAction.onTap(context),
|
||||
),
|
||||
WalletMenuItem(
|
||||
title: SettingActions.securityBackupSettingAction.name,
|
||||
image: SettingActions.securityBackupSettingAction.image,
|
||||
handler: (BuildContext context) => SettingActions.securityBackupSettingAction.onTap(context),
|
||||
),
|
||||
WalletMenuItem(
|
||||
title: SettingActions.privacySettingAction.name,
|
||||
image: SettingActions.privacySettingAction.image,
|
||||
handler: (BuildContext context) => SettingActions.privacySettingAction.onTap(context),
|
||||
),
|
||||
WalletMenuItem(
|
||||
title: SettingActions.displaySettingAction.name,
|
||||
image: SettingActions.displaySettingAction.image,
|
||||
handler: (BuildContext context) => SettingActions.displaySettingAction.onTap(context),
|
||||
),
|
||||
WalletMenuItem(
|
||||
title: SettingActions.otherSettingAction.name,
|
||||
image: SettingActions.otherSettingAction.image,
|
||||
handler: (BuildContext context) => SettingActions.otherSettingAction.onTap(context),
|
||||
),
|
||||
WalletMenuItem(
|
||||
title: SettingActions.supportSettingAction.name,
|
||||
image: SettingActions.supportSettingAction.image,
|
||||
handler: (BuildContext context) => SettingActions.supportSettingAction.onTap(context),
|
||||
),
|
||||
];
|
||||
|
||||
static void action(int index, BuildContext context) {
|
||||
final item = items[index];
|
||||
item.handler(context);
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class WalletMenuItem {
|
||||
WalletMenuItem({
|
||||
required this.title,
|
||||
required this.image,
|
||||
required this.handler,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String image;
|
||||
final void Function(BuildContext) handler;
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
import 'package:cake_wallet/src/widgets/setting_action_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/setting_actions.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/wallet_menu.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
|
||||
// FIXME: terrible design.
|
||||
|
@ -22,7 +22,7 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
: this.menuWidth = 0,
|
||||
this.screenWidth = 0,
|
||||
this.screenHeight = 0,
|
||||
this.headerHeight = 10,
|
||||
this.headerHeight = 120,
|
||||
this.tileHeight = 60,
|
||||
this.fromTopEdge = 50,
|
||||
this.fromBottomEdge = 25,
|
||||
|
@ -81,7 +81,7 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final itemCount = WalletMenu.items.length;
|
||||
final itemCount = SettingActions.all.length;
|
||||
|
||||
moneroIcon = Image.asset('assets/images/monero_menu.png',
|
||||
color: Theme.of(context).accentTextTheme.overline!.decorationColor!);
|
||||
|
@ -165,21 +165,19 @@ class MenuWidgetState extends State<MenuWidget> {
|
|||
|
||||
index--;
|
||||
|
||||
final item = WalletMenu.items[index];
|
||||
final title = item.title;
|
||||
final image = item.image;
|
||||
final item = SettingActions.all[index];
|
||||
|
||||
final isLastTile = index == itemCount - 1;
|
||||
|
||||
return SettingActionButton(
|
||||
isLastTile: isLastTile,
|
||||
headerHeight: headerHeight,
|
||||
tileHeight: tileHeight,
|
||||
selectionActive: false,
|
||||
fromBottomEdge: fromBottomEdge,
|
||||
fromTopEdge: fromTopEdge,
|
||||
onTap: () => WalletMenu.action(index, context),
|
||||
image: image,
|
||||
title: title,
|
||||
onTap: () => item.onTap.call(context),
|
||||
image: item.image,
|
||||
title: item.name,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, index) => Container(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
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/screens/dashboard/wallet_menu.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';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/router.dart' as Router;
|
||||
|
@ -24,7 +24,7 @@ class _DesktopSettingsPageState extends State<DesktopSettingsPage> {
|
|||
|
||||
initState() {
|
||||
super.initState();
|
||||
itemCount = WalletMenu.items.length;
|
||||
itemCount = SettingActions.all.length;
|
||||
sideMenu.addListener((index) {
|
||||
setState(() {
|
||||
isTapped = true;
|
||||
|
@ -56,9 +56,7 @@ class _DesktopSettingsPageState extends State<DesktopSettingsPage> {
|
|||
child: ListView.separated(
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
itemBuilder: (_, index) {
|
||||
final item = WalletMenu.items[index];
|
||||
final title = item.title;
|
||||
final image = item.image;
|
||||
final item = SettingActions.all[index];
|
||||
final isLastTile = index == itemCount;
|
||||
return SettingActionButton(
|
||||
isLastTile: isLastTile,
|
||||
|
@ -70,11 +68,11 @@ class _DesktopSettingsPageState extends State<DesktopSettingsPage> {
|
|||
final settingContext =
|
||||
_settingsNavigatorKey.currentState?.context ?? context;
|
||||
sideMenu.changePage(index);
|
||||
WalletMenu.action(index, settingContext);
|
||||
item.onTap.call(settingContext);
|
||||
}
|
||||
},
|
||||
image: image,
|
||||
title: title,
|
||||
image: item.image,
|
||||
title: item.name,
|
||||
);
|
||||
},
|
||||
separatorBuilder: (_, index) => Container(
|
||||
|
|
|
@ -11,7 +11,6 @@ class SettingActionButton extends StatelessWidget {
|
|||
final String title;
|
||||
final double fromBottomEdge;
|
||||
final double fromTopEdge;
|
||||
final double headerHeight;
|
||||
final double tileHeight;
|
||||
const SettingActionButton({
|
||||
super.key,
|
||||
|
@ -22,7 +21,6 @@ class SettingActionButton extends StatelessWidget {
|
|||
required this.onTap,
|
||||
required this.image,
|
||||
required this.title,
|
||||
this.headerHeight = 120,
|
||||
this.tileHeight = 60,
|
||||
this.fromTopEdge = 50,
|
||||
this.fromBottomEdge = 25,
|
||||
|
@ -39,13 +37,12 @@ class SettingActionButton extends StatelessWidget {
|
|||
onTap: onTap,
|
||||
hoverColor: Colors.transparent,
|
||||
child: Container(
|
||||
height: isLastTile ? headerHeight : tileHeight,
|
||||
height: tileHeight,
|
||||
padding: isLastTile
|
||||
? EdgeInsets.only(
|
||||
left: 24,
|
||||
right: 24,
|
||||
top: fromBottomEdge,
|
||||
//bottom: fromTopEdge
|
||||
)
|
||||
: EdgeInsets.only(left: 24, right: 24),
|
||||
alignment: isLastTile ? Alignment.topLeft : null,
|
||||
|
|
Loading…
Reference in a new issue