From 85a30d1d81f94d51d2cda4c1db117e8f7ce368ca Mon Sep 17 00:00:00 2001 From: Rafael Saes Date: Wed, 5 Jul 2023 08:45:38 -0300 Subject: [PATCH] refactor: primaryTextTheme.bodyLarge.backgroundColor -> AlertTheme.leftButtonTextColor --- lib/src/widgets/base_alert_dialog.dart | 6 ++---- lib/themes/bright_theme.dart | 5 +---- lib/themes/dark_theme.dart | 9 +++++---- lib/themes/extensions/alert_theme.dart | 23 +++++++++++++++++++++++ lib/themes/light_theme.dart | 9 +++++---- lib/themes/theme_base.dart | 4 ++++ 6 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 lib/themes/extensions/alert_theme.dart diff --git a/lib/src/widgets/base_alert_dialog.dart b/lib/src/widgets/base_alert_dialog.dart index 322259011..508434b5d 100644 --- a/lib/src/widgets/base_alert_dialog.dart +++ b/lib/src/widgets/base_alert_dialog.dart @@ -1,5 +1,6 @@ import 'dart:ui'; import 'package:cake_wallet/src/widgets/section_divider.dart'; +import 'package:cake_wallet/themes/extensions/alert_theme.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/palette.dart'; @@ -68,10 +69,7 @@ class BaseAlertDialog extends StatelessWidget { fontFamily: 'Lato', fontWeight: FontWeight.w600, color: leftActionButtonTextColor ?? - Theme.of(context) - .primaryTextTheme! - .bodyLarge! - .backgroundColor!, + Theme.of(context).extension()!.leftButtonTextColor, decoration: TextDecoration.none, ), )), diff --git a/lib/themes/bright_theme.dart b/lib/themes/bright_theme.dart index f24b8099a..83be27113 100644 --- a/lib/themes/bright_theme.dart +++ b/lib/themes/bright_theme.dart @@ -175,9 +175,6 @@ class BrightTheme extends LightTheme { color: Palette.darkBlueCraiola, // template title (send page) backgroundColor: Colors.white, // icon color on order row (moonpay) ), - // body2 -> bodyLarge - bodyLarge: TextStyle( - backgroundColor: Palette.brightOrange // alert left button text - )), + ), ); } diff --git a/lib/themes/dark_theme.dart b/lib/themes/dark_theme.dart index cd1d6af26..996dd08e6 100644 --- a/lib/themes/dark_theme.dart +++ b/lib/themes/dark_theme.dart @@ -1,4 +1,5 @@ import 'package:cake_wallet/themes/extensions/address_theme.dart'; +import 'package:cake_wallet/themes/extensions/alert_theme.dart'; import 'package:cake_wallet/themes/extensions/balance_page_theme.dart'; import 'package:cake_wallet/themes/extensions/cake_scrollbar_theme.dart'; import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart'; @@ -127,6 +128,10 @@ class DarkTheme extends ThemeBase { PickerTheme get pickerTheme => PickerTheme(dividerColor: PaletteDark.dividerColor); + @override + AlertTheme get alertTheme => + AlertTheme(leftButtonTextColor: Palette.alizarinRed); + @override ThemeData get themeData => super.themeData.copyWith( indicatorColor: PaletteDark.cyanBlue, // page indicator @@ -232,10 +237,6 @@ class DarkTheme extends ThemeBase { backgroundColor: Colors.white, // icon color on order row (moonpay) ), - // body2 -> bodyLarge - bodyLarge: TextStyle( - backgroundColor: Palette.alizarinRed // alert left button text - ) ), ); } diff --git a/lib/themes/extensions/alert_theme.dart b/lib/themes/extensions/alert_theme.dart new file mode 100644 index 000000000..3c3cc90a6 --- /dev/null +++ b/lib/themes/extensions/alert_theme.dart @@ -0,0 +1,23 @@ +import 'package:flutter/material.dart'; + +class AlertTheme extends ThemeExtension { + final Color leftButtonTextColor; + + AlertTheme({required this.leftButtonTextColor}); + + @override + AlertTheme copyWith({Color? leftButtonTextColor}) => AlertTheme( + leftButtonTextColor: leftButtonTextColor ?? this.leftButtonTextColor); + + @override + AlertTheme lerp(ThemeExtension? other, double t) { + if (other is! AlertTheme) { + return this; + } + + return AlertTheme( + leftButtonTextColor: + Color.lerp(leftButtonTextColor, other.leftButtonTextColor, t) ?? + leftButtonTextColor); + } +} diff --git a/lib/themes/light_theme.dart b/lib/themes/light_theme.dart index 674c18681..fe74e8f56 100644 --- a/lib/themes/light_theme.dart +++ b/lib/themes/light_theme.dart @@ -1,4 +1,5 @@ import 'package:cake_wallet/themes/extensions/address_theme.dart'; +import 'package:cake_wallet/themes/extensions/alert_theme.dart'; import 'package:cake_wallet/themes/extensions/balance_page_theme.dart'; import 'package:cake_wallet/themes/extensions/cake_scrollbar_theme.dart'; import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart'; @@ -128,6 +129,10 @@ class LightTheme extends ThemeBase { PickerTheme get pickerTheme => PickerTheme(dividerColor: Palette.periwinkleCraiola); + @override + AlertTheme get alertTheme => + AlertTheme(leftButtonTextColor: Palette.brightOrange); + @override ThemeData get themeData => super.themeData.copyWith( indicatorColor: @@ -233,10 +238,6 @@ class LightTheme extends ThemeBase { backgroundColor: Colors.black, // icon color on order row (moonpay) ), - // body2 -> bodyLarge - bodyLarge: TextStyle( - backgroundColor: Palette.brightOrange // alert left button text - ) ), ); } diff --git a/lib/themes/theme_base.dart b/lib/themes/theme_base.dart index 7a4b9ff73..bd881358a 100644 --- a/lib/themes/theme_base.dart +++ b/lib/themes/theme_base.dart @@ -1,4 +1,5 @@ import 'package:cake_wallet/themes/extensions/address_theme.dart'; +import 'package:cake_wallet/themes/extensions/alert_theme.dart'; import 'package:cake_wallet/themes/extensions/balance_page_theme.dart'; import 'package:cake_wallet/themes/extensions/cake_scrollbar_theme.dart'; import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart'; @@ -79,6 +80,8 @@ abstract class ThemeBase { PickerTheme get pickerTheme; + AlertTheme get alertTheme; + ThemeData get themeData => generatedThemeData.copyWith( primaryColor: primaryColor, cardColor: containerColor, @@ -99,6 +102,7 @@ abstract class ThemeBase { walletListTheme, infoTheme, pickerTheme, + alertTheme, ], scrollbarTheme: ScrollbarThemeData( thumbColor: MaterialStateProperty.all(scrollbarTheme.thumbColor),