Fix UI issues, paddings and alignments

This commit is contained in:
OmarHatem 2023-02-15 16:07:46 +02:00
parent b1947426fb
commit f8d70e7ce6
4 changed files with 44 additions and 54 deletions

View file

@ -1,23 +1,19 @@
import 'dart:async'; 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/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/yat_emoji_id.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/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/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.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/balance_page.dart';
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart'; import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
import 'package:mobx/mobx.dart'; import 'package:mobx/mobx.dart';
import 'package:cake_wallet/main.dart'; import 'package:cake_wallet/main.dart';
import 'package:cake_wallet/router.dart' as Router; import 'package:cake_wallet/router.dart' as Router;
class DesktopDashboardPage extends BasePage { class DesktopDashboardPage extends StatelessWidget {
DesktopDashboardPage({ DesktopDashboardPage({
required this.balancePage, required this.balancePage,
required this.walletViewModel, required this.walletViewModel,
@ -25,32 +21,18 @@ class DesktopDashboardPage extends BasePage {
required this.desktopSidebarViewModel, required this.desktopSidebarViewModel,
}); });
static final GlobalKey<NavigatorState> desktopKey = GlobalKey<NavigatorState>();
@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 BalancePage balancePage;
final DashboardViewModel walletViewModel; final DashboardViewModel walletViewModel;
final WalletAddressListViewModel addressListViewModel; final WalletAddressListViewModel addressListViewModel;
final DesktopSidebarViewModel desktopSidebarViewModel; final DesktopSidebarViewModel desktopSidebarViewModel;
static final GlobalKey<NavigatorState> desktopKey = GlobalKey<NavigatorState>();
bool _isEffectsInstalled = false; bool _isEffectsInstalled = false;
StreamSubscription<bool>? _onInactiveSub; StreamSubscription<bool>? _onInactiveSub;
@override @override
Widget body(BuildContext context) { Widget build(BuildContext context) {
_setEffects(context); _setEffects(context);
return Row( return Row(
@ -60,19 +42,18 @@ class DesktopDashboardPage extends BasePage {
width: 400, width: 400,
child: balancePage, child: balancePage,
), ),
Expanded( Flexible(
flex: 4, child: ConstrainedBox(
child: Center( constraints: BoxConstraints(maxWidth: 500),
child: ConstrainedBox( child: Navigator(
constraints: BoxConstraints(maxWidth: 500), key: desktopKey,
child: Navigator( initialRoute: Routes.desktop_actions,
key: desktopKey, onGenerateRoute: (settings) => Router.createRoute(settings),
initialRoute: Routes.desktop_actions, onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) {
onGenerateRoute: (settings) => Router.createRoute(settings), return [
onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!
return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!]; ];
}, },
),
), ),
), ),
), ),
@ -128,3 +109,4 @@ class DesktopDashboardPage extends BasePage {
}); });
} }
} }

View file

@ -2,7 +2,6 @@ import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/screens/dashboard/desktop_dashboard_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/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.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_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/desktop_widgets/desktop_wallet_selection_dropdown.dart';
@ -31,12 +30,16 @@ class DesktopSidebarWrapper extends BasePage {
currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white;
@override @override
Color get backgroundDarkColor => Colors.transparent; Color get backgroundDarkColor => Colors.black.withOpacity(0.1);
@override
bool get resizeToAvoidBottomInset => false;
final pageController = PageController(); final pageController = PageController();
final selectedIconPath = 'assets/images/desktop_transactions_solid_icon.png'; final selectedIconPath = 'assets/images/desktop_transactions_solid_icon.png';
final unselectedIconPath = 'assets/images/desktop_transactions_outline_icon.png'; final unselectedIconPath = 'assets/images/desktop_transactions_outline_icon.png';
double get sideMenuWidth => 76.0; double get sideMenuWidth => 76.0;
@override @override
@ -75,7 +78,7 @@ class DesktopSidebarWrapper extends BasePage {
onTap: () { onTap: () {
String? currentPath; String? currentPath;
desktopKey.currentState?.popUntil((route) { DesktopDashboardPage.desktopKey.currentState?.popUntil((route) {
currentPath = route.settings.name; currentPath = route.settings.name;
return true; return true;
}); });
@ -88,7 +91,7 @@ class DesktopSidebarWrapper extends BasePage {
desktopSidebarViewModel.resetSidebar(); desktopSidebarViewModel.resetSidebar();
Future.delayed(Duration(milliseconds: 10), () { Future.delayed(Duration(milliseconds: 10), () {
desktopSidebarViewModel.onPageChange(SidebarItem.transactions); desktopSidebarViewModel.onPageChange(SidebarItem.transactions);
desktopKey.currentState?.pushNamed(Routes.transactionsPage); DesktopDashboardPage.desktopKey.currentState?.pushNamed(Routes.transactionsPage);
}); });
} }
}, },

View file

@ -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/store/settings_store.dart';
import 'package:cake_wallet/themes/theme_base.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:flutter/material.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.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:flutter_mobx/flutter_mobx.dart';
import 'package:auto_size_text/auto_size_text.dart'; import 'package:auto_size_text/auto_size_text.dart';
import 'package:cake_wallet/src/widgets/introducing_card.dart'; import 'package:cake_wallet/src/widgets/introducing_card.dart';
@ -26,7 +24,7 @@ class BalancePage extends StatelessWidget{
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
SizedBox(height: 56), SizedBox(height: ResponsiveLayoutUtil.instance.isMobile(context) ? 56 : 16),
Container( Container(
margin: const EdgeInsets.only(left: 24, bottom: 16), margin: const EdgeInsets.only(left: 24, bottom: 16),
child: Observer(builder: (_) { child: Observer(builder: (_) {

View file

@ -52,21 +52,28 @@ class NavBar extends StatelessWidget implements ObstructingPreferredSizeWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (leading == null && middle == null && trailing == null) {
return const SizedBox();
}
final pad = height - _originalHeight; final pad = height - _originalHeight;
final paddingTop = pad / 2; final paddingTop = pad / 2;
final _paddingBottom = (pad / 2); final _paddingBottom = (pad / 2);
if (!ResponsiveLayoutUtil.instance.isMobile(context)) { if (!ResponsiveLayoutUtil.instance.isMobile(context)) {
return Padding( return Container(
padding: const EdgeInsetsDirectional.only(end: 24, top: 8, bottom: 8), padding: const EdgeInsetsDirectional.only(end: 24),
child: Row( color: backgroundColor,
mainAxisSize: MainAxisSize.max, child: Center(
mainAxisAlignment: MainAxisAlignment.spaceBetween, child: Row(
children: [ mainAxisSize: MainAxisSize.max,
if (leading != null) Flexible(child: leading!) else const SizedBox(), mainAxisAlignment: MainAxisAlignment.spaceBetween,
if (middle != null) middle!, children: [
trailing ?? const SizedBox(), if (leading != null) Flexible(child: leading!) else const SizedBox(),
], if (middle != null) middle!,
trailing ?? const SizedBox(),
],
),
), ),
); );
} }