diff --git a/lib/src/screens/base_page.dart b/lib/src/screens/base_page.dart index a06e0ae5a..f3a068e9c 100644 --- a/lib/src/screens/base_page.dart +++ b/lib/src/screens/base_page.dart @@ -1,7 +1,6 @@ import 'package:cake_wallet/themes/theme_base.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/src/widgets/nav_bar.dart'; @@ -9,23 +8,23 @@ import 'package:cake_wallet/src/widgets/nav_bar.dart'; enum AppBarStyle { regular, withShadow, transparent } abstract class BasePage extends StatelessWidget { - BasePage() - : _scaffoldKey = GlobalKey(); + BasePage() : _scaffoldKey = GlobalKey(); final GlobalKey _scaffoldKey; - final Image closeButtonImage = - Image.asset('assets/images/close_button.png'); + final Image closeButtonImage = Image.asset('assets/images/close_button.png'); final Image closeButtonImageDarkTheme = - Image.asset('assets/images/close_button_dark_theme.png'); + Image.asset('assets/images/close_button_dark_theme.png'); String? get title => null; - Color get backgroundLightColor => Colors.white; + Color? get backgroundLightColor => null; - Color get backgroundDarkColor => PaletteDark.backgroundColor; + Color? get backgroundDarkColor => null; Color? get titleColor => null; + bool get gradientBackground => false; + bool get resizeToAvoidBottomInset => true; bool get extendBodyBehindAppBar => false; @@ -42,15 +41,39 @@ abstract class BasePage extends StatelessWidget { void onClose(BuildContext context) => Navigator.of(context).pop(); + Color pageBackgroundColor(BuildContext context) => + (currentTheme.type == ThemeType.dark + ? backgroundDarkColor + : backgroundLightColor) ?? + (gradientBackground && currentTheme.type == ThemeType.bright + ? Colors.transparent + : Theme.of(context).colorScheme.background); + + Color? pageIconColor(BuildContext context) => + titleColor ?? + (gradientBackground + ? Theme.of(context).primaryTextTheme.titleLarge!.color! + : Theme.of(context).primaryTextTheme.titleLarge!.color!); + + Widget closeButton(BuildContext context) => Image.asset( + currentTheme.type == ThemeType.dark + ? 'assets/images/close_button_dark_theme.png' + : 'assets/images/close_button.png', + color: pageIconColor(context), + height: 16, + ); + + Widget backButton(BuildContext context) => Icon( + Icons.arrow_back_ios, + color: pageIconColor(context), + size: 16, + ); + Widget? leading(BuildContext context) { if (ModalRoute.of(context)?.isFirst ?? true) { return null; } - final _backButton = Icon(Icons.arrow_back_ios, - color: titleColor ?? Theme.of(context).primaryTextTheme!.titleLarge!.color!, - size: 16,); - return MergeSemantics( child: SizedBox( height: 37, @@ -65,7 +88,7 @@ abstract class BasePage extends StatelessWidget { (states) => Colors.transparent), ), onPressed: () => onClose(context), - child: _backButton, + child: backButton(context), ), ), ), @@ -83,7 +106,7 @@ abstract class BasePage extends StatelessWidget { fontWeight: FontWeight.bold, fontFamily: 'Lato', color: titleColor ?? - Theme.of(context).primaryTextTheme!.titleLarge!.color!), + Theme.of(context).primaryTextTheme.titleLarge!.color!), ); } @@ -92,9 +115,8 @@ abstract class BasePage extends StatelessWidget { Widget? floatingActionButton(BuildContext context) => null; ObstructingPreferredSizeWidget appBar(BuildContext context) { - final appBarColor = currentTheme.type == ThemeType.dark - ? backgroundDarkColor : backgroundLightColor; - + final appBarColor = pageBackgroundColor(context); + switch (appBarStyle) { case AppBarStyle.regular: // FIX-ME: NavBar no context @@ -138,12 +160,9 @@ abstract class BasePage extends StatelessWidget { @override Widget build(BuildContext context) { - final _backgroundColor = currentTheme.type == ThemeType.dark - ? backgroundDarkColor : backgroundLightColor; - final root = Scaffold( key: _scaffoldKey, - backgroundColor: _backgroundColor, + backgroundColor: pageBackgroundColor(context), resizeToAvoidBottomInset: resizeToAvoidBottomInset, extendBodyBehindAppBar: extendBodyBehindAppBar, endDrawer: endDrawer, diff --git a/lib/src/screens/dashboard/dashboard_page.dart b/lib/src/screens/dashboard/dashboard_page.dart index 52a0c41ab..5fe503289 100644 --- a/lib/src/screens/dashboard/dashboard_page.dart +++ b/lib/src/screens/dashboard/dashboard_page.dart @@ -66,11 +66,7 @@ class _DashboardPageView extends BasePage { final BalancePage balancePage; @override - Color get backgroundLightColor => - currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; - - @override - Color get backgroundDarkColor => Colors.transparent; + bool get gradientBackground => true; @override Widget Function(BuildContext, Widget) get rootWrapper => diff --git a/lib/src/screens/dashboard/widgets/address_page.dart b/lib/src/screens/dashboard/widgets/address_page.dart index 6fd46ebd4..57fa11311 100644 --- a/lib/src/screens/dashboard/widgets/address_page.dart +++ b/lib/src/screens/dashboard/widgets/address_page.dart @@ -50,11 +50,11 @@ class AddressPage extends BasePage { final FocusNode _cryptoAmountFocus; @override - Color get backgroundLightColor => - currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; + bool get gradientBackground => true; @override - Color get backgroundDarkColor => Colors.transparent; + Color? get titleColor => + currentTheme.themeData.accentTextTheme.displayMedium!.backgroundColor; @override bool get resizeToAvoidBottomInset => false; @@ -63,18 +63,6 @@ class AddressPage extends BasePage { @override Widget? leading(BuildContext context) { - final _backButton = Icon( - Icons.arrow_back_ios, - color: Theme.of(context) - .accentTextTheme! - .displayMedium! - .backgroundColor!, - size: 16, - ); - final _closeButton = currentTheme.type == ThemeType.dark - ? closeButtonImageDarkTheme - : closeButtonImage; - bool isMobileView = ResponsiveLayoutUtil.instance.isMobile; return MergeSemantics( @@ -91,7 +79,7 @@ class AddressPage extends BasePage { (states) => Colors.transparent), ), onPressed: () => onClose(context), - child: !isMobileView ? _closeButton : _backButton, + child: !isMobileView ? closeButton(context) : backButton(context), ), ), ), @@ -100,11 +88,9 @@ class AddressPage extends BasePage { } @override - Widget middle(BuildContext context) => - PresentReceiveOptionPicker( - receiveOptionViewModel: receiveOptionViewModel, - hasWhiteBackground: currentTheme.type == ThemeType.light, - ); + Widget middle(BuildContext context) => PresentReceiveOptionPicker( + receiveOptionViewModel: receiveOptionViewModel, + gradientBackground: gradientBackground); @override Widget Function(BuildContext, Widget) get rootWrapper => @@ -127,14 +113,7 @@ class AddressPage extends BasePage { context: context, ); }, - icon: Icon( - Icons.share, - size: 20, - color: Theme.of(context) - .accentTextTheme! - .displayMedium! - .backgroundColor!, - ), + icon: Icon(Icons.share, size: 20, color: pageIconColor(context)), ), ); } diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index d6073a0c0..ac872b81a 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -15,8 +15,8 @@ class BalancePage extends StatelessWidget { final DashboardViewModel dashboardViewModel; final SettingsStore settingsStore; - Color get backgroundLightColor => - settingsStore.currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; + @override + bool get gradientBackground => true; @override Widget build(BuildContext context) { diff --git a/lib/src/screens/dashboard/widgets/present_receive_option_picker.dart b/lib/src/screens/dashboard/widgets/present_receive_option_picker.dart index c29442450..f447bc2ef 100644 --- a/lib/src/screens/dashboard/widgets/present_receive_option_picker.dart +++ b/lib/src/screens/dashboard/widgets/present_receive_option_picker.dart @@ -10,14 +10,14 @@ import 'package:cake_wallet/generated/i18n.dart'; class PresentReceiveOptionPicker extends StatelessWidget { PresentReceiveOptionPicker( - {required this.receiveOptionViewModel, this.hasWhiteBackground = false}); + {required this.receiveOptionViewModel, this.gradientBackground = false}); final ReceiveOptionViewModel receiveOptionViewModel; - final bool hasWhiteBackground; + final bool gradientBackground; @override Widget build(BuildContext context) { - final textIconTheme = hasWhiteBackground + final textIconTheme = gradientBackground ? Theme.of(context) .accentTextTheme! .displayMedium! diff --git a/lib/src/screens/ionia/cards/ionia_manage_cards_page.dart b/lib/src/screens/ionia/cards/ionia_manage_cards_page.dart index 03b36462b..2b99cc941 100644 --- a/lib/src/screens/ionia/cards/ionia_manage_cards_page.dart +++ b/lib/src/screens/ionia/cards/ionia_manage_cards_page.dart @@ -38,10 +38,7 @@ class IoniaManageCardsPage extends BasePage { final _searchController = TextEditingController(); @override - Color get backgroundLightColor => currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; - - @override - Color get backgroundDarkColor => Colors.transparent; + bool get gradientBackground => true; @override Color get titleColor => currentTheme.type == ThemeType.bright ? Colors.white : Colors.black; diff --git a/lib/src/screens/receive/anonpay_receive_page.dart b/lib/src/screens/receive/anonpay_receive_page.dart index 8652d6b13..3d3c4b2a6 100644 --- a/lib/src/screens/receive/anonpay_receive_page.dart +++ b/lib/src/screens/receive/anonpay_receive_page.dart @@ -9,7 +9,6 @@ import 'package:cake_wallet/src/widgets/gradient_background.dart'; import 'package:cake_wallet/src/screens/receive/widgets/anonpay_status_section.dart'; import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart'; import 'package:cake_wallet/src/screens/receive/widgets/copy_link_item.dart'; -import 'package:cake_wallet/themes/theme_base.dart'; import 'package:device_display_brightness/device_display_brightness.dart'; import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart' as qr; @@ -23,11 +22,7 @@ class AnonPayReceivePage extends BasePage { String get title => S.current.receive; @override - Color get backgroundLightColor => - currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; - - @override - Color get backgroundDarkColor => Colors.transparent; + bool get gradientBackground => true; @override bool get resizeToAvoidBottomInset => false; diff --git a/lib/src/screens/receive/fullscreen_qr_page.dart b/lib/src/screens/receive/fullscreen_qr_page.dart index bd95269d9..54230deac 100644 --- a/lib/src/screens/receive/fullscreen_qr_page.dart +++ b/lib/src/screens/receive/fullscreen_qr_page.dart @@ -1,7 +1,6 @@ import 'package:cake_wallet/entities/qr_view_data.dart'; import 'package:cake_wallet/src/widgets/gradient_background.dart'; import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart'; -import 'package:cake_wallet/themes/theme_base.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; @@ -11,10 +10,7 @@ class FullscreenQRPage extends BasePage { final QrViewData qrViewData; @override - Color get backgroundLightColor => currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; - - @override - Color get backgroundDarkColor => Colors.transparent; + bool get gradientBackground => true; @override bool get resizeToAvoidBottomInset => false; diff --git a/lib/src/screens/receive/receive_page.dart b/lib/src/screens/receive/receive_page.dart index 2d12304f6..ce4cebc18 100644 --- a/lib/src/screens/receive/receive_page.dart +++ b/lib/src/screens/receive/receive_page.dart @@ -42,11 +42,7 @@ class ReceivePage extends BasePage { String get title => S.current.receive; @override - Color get backgroundLightColor => - currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; - - @override - Color get backgroundDarkColor => Colors.transparent; + bool get gradientBackground => true; @override bool get resizeToAvoidBottomInset => false; @@ -65,10 +61,7 @@ class ReceivePage extends BasePage { fontSize: 18.0, fontWeight: FontWeight.bold, fontFamily: 'Lato', - color: Theme.of(context) - .accentTextTheme! - .displayMedium! - .backgroundColor!), + color: pageIconColor(context)), ); } @@ -98,10 +91,7 @@ class ReceivePage extends BasePage { icon: Icon( Icons.share, size: 20, - color: Theme.of(context) - .accentTextTheme! - .displayMedium! - .backgroundColor!, + color: pageIconColor(context), ), ), ));