From 94b574b2da29cfe0617a7e1b11bd4fc8545ae218 Mon Sep 17 00:00:00 2001 From: Rafael Saes Date: Wed, 5 Jul 2023 09:29:32 -0300 Subject: [PATCH] refactor: primaryTextTheme.labelSmall.decorationColor -> PlaceholderTheme.color --- .../dashboard/widgets/transactions_page.dart | 6 ++---- lib/themes/bright_theme.dart | 6 +++++- lib/themes/dark_theme.dart | 5 ++++- lib/themes/extensions/placeholder_theme.dart | 20 +++++++++++++++++++ lib/themes/light_theme.dart | 6 +++++- lib/themes/theme_base.dart | 4 ++++ 6 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 lib/themes/extensions/placeholder_theme.dart diff --git a/lib/src/screens/dashboard/widgets/transactions_page.dart b/lib/src/screens/dashboard/widgets/transactions_page.dart index e92e97f04..c6fe90324 100644 --- a/lib/src/screens/dashboard/widgets/transactions_page.dart +++ b/lib/src/screens/dashboard/widgets/transactions_page.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/src/screens/dashboard/widgets/anonpay_transaction_row.dart'; import 'package:cake_wallet/src/screens/dashboard/widgets/order_row.dart'; +import 'package:cake_wallet/themes/extensions/placeholder_theme.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/view_model/dashboard/anonpay_transaction_list_item.dart'; import 'package:cake_wallet/view_model/dashboard/order_list_item.dart'; @@ -136,10 +137,7 @@ class TransactionsPage extends StatelessWidget { S.of(context).placeholder_transactions, style: TextStyle( fontSize: 14, - color: Theme.of(context) - .primaryTextTheme - .labelSmall! - .decorationColor!), + color: Theme.of(context).extension()!.color), ), ); })) diff --git a/lib/themes/bright_theme.dart b/lib/themes/bright_theme.dart index 498854a83..0d653a587 100644 --- a/lib/themes/bright_theme.dart +++ b/lib/themes/bright_theme.dart @@ -6,6 +6,7 @@ import 'package:cake_wallet/themes/extensions/indicator_dot_theme.dart'; import 'package:cake_wallet/themes/extensions/menu_theme.dart'; import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart'; import 'package:cake_wallet/themes/extensions/order_theme.dart'; +import 'package:cake_wallet/themes/extensions/placeholder_theme.dart'; import 'package:cake_wallet/themes/extensions/send_page_theme.dart'; import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart'; import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart'; @@ -85,6 +86,10 @@ class BrightTheme extends LightTheme { templateDotterBorderColor: Palette.shadowWhite, secondGradientColor: Palette.pinkFlamingo); + @override + PlaceholderTheme get placeholderTheme => + PlaceholderTheme(color: Colors.white.withOpacity(0.5)); + @override ThemeData get themeData => super.themeData.copyWith( indicatorColor: Colors.white.withOpacity(0.5), // page indicator @@ -147,7 +152,6 @@ class BrightTheme extends LightTheme { ), labelSmall: TextStyle( color: Palette.darkGray, // transaction/trade details titles - decorationColor: Colors.white.withOpacity(0.5), // placeholder ), ), ); diff --git a/lib/themes/dark_theme.dart b/lib/themes/dark_theme.dart index dbbb57c8e..3d78d23f7 100644 --- a/lib/themes/dark_theme.dart +++ b/lib/themes/dark_theme.dart @@ -13,6 +13,7 @@ import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart'; import 'package:cake_wallet/themes/extensions/order_theme.dart'; import 'package:cake_wallet/themes/extensions/picker_theme.dart'; import 'package:cake_wallet/themes/extensions/pin_code_theme.dart'; +import 'package:cake_wallet/themes/extensions/placeholder_theme.dart'; import 'package:cake_wallet/themes/extensions/seed_widget_theme.dart'; import 'package:cake_wallet/themes/extensions/send_page_theme.dart'; import 'package:cake_wallet/themes/extensions/support_page_theme.dart'; @@ -156,6 +157,9 @@ class DarkTheme extends ThemeBase { SeedWidgetTheme get seedWidgetTheme => SeedWidgetTheme(hintTextColor: PaletteDark.darkCyanBlue); + @override + PlaceholderTheme get placeholderTheme => PlaceholderTheme(color: Colors.grey); + @override ThemeData get themeData => super.themeData.copyWith( indicatorColor: PaletteDark.cyanBlue, // page indicator @@ -220,7 +224,6 @@ class DarkTheme extends ThemeBase { labelSmall: TextStyle( color: PaletteDark.lightBlueGrey, // transaction/trade details titles - decorationColor: Colors.grey, // placeholder ), ), ); diff --git a/lib/themes/extensions/placeholder_theme.dart b/lib/themes/extensions/placeholder_theme.dart new file mode 100644 index 000000000..14470a9c9 --- /dev/null +++ b/lib/themes/extensions/placeholder_theme.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; + +class PlaceholderTheme extends ThemeExtension { + final Color color; + + PlaceholderTheme({required this.color}); + + @override + PlaceholderTheme copyWith({Color? color}) => + PlaceholderTheme(color: color ?? this.color); + + @override + PlaceholderTheme lerp(ThemeExtension? other, double t) { + if (other is! PlaceholderTheme) { + return this; + } + + return PlaceholderTheme(color: Color.lerp(color, other.color, t) ?? color); + } +} diff --git a/lib/themes/light_theme.dart b/lib/themes/light_theme.dart index c3ecbb06d..bde5a97ea 100644 --- a/lib/themes/light_theme.dart +++ b/lib/themes/light_theme.dart @@ -13,6 +13,7 @@ import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart'; import 'package:cake_wallet/themes/extensions/order_theme.dart'; import 'package:cake_wallet/themes/extensions/picker_theme.dart'; import 'package:cake_wallet/themes/extensions/pin_code_theme.dart'; +import 'package:cake_wallet/themes/extensions/placeholder_theme.dart'; import 'package:cake_wallet/themes/extensions/seed_widget_theme.dart'; import 'package:cake_wallet/themes/extensions/send_page_theme.dart'; import 'package:cake_wallet/themes/extensions/support_page_theme.dart'; @@ -157,6 +158,10 @@ class LightTheme extends ThemeBase { SeedWidgetTheme get seedWidgetTheme => SeedWidgetTheme(hintTextColor: Palette.darkGray); + @override + PlaceholderTheme get placeholderTheme => + PlaceholderTheme(color: PaletteDark.darkCyanBlue); + @override ThemeData get themeData => super.themeData.copyWith( indicatorColor: @@ -222,7 +227,6 @@ class LightTheme extends ThemeBase { ), labelSmall: TextStyle( color: Palette.darkGray, // transaction/trade details titles - decorationColor: PaletteDark.darkCyanBlue, // placeholder ), ), ); diff --git a/lib/themes/theme_base.dart b/lib/themes/theme_base.dart index 94e146d60..df18e7cde 100644 --- a/lib/themes/theme_base.dart +++ b/lib/themes/theme_base.dart @@ -12,6 +12,7 @@ import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart'; import 'package:cake_wallet/themes/extensions/order_theme.dart'; import 'package:cake_wallet/themes/extensions/picker_theme.dart'; import 'package:cake_wallet/themes/extensions/pin_code_theme.dart'; +import 'package:cake_wallet/themes/extensions/placeholder_theme.dart'; import 'package:cake_wallet/themes/extensions/seed_widget_theme.dart'; import 'package:cake_wallet/themes/extensions/send_page_theme.dart'; import 'package:cake_wallet/themes/extensions/support_page_theme.dart'; @@ -91,6 +92,8 @@ abstract class ThemeBase { SeedWidgetTheme get seedWidgetTheme; + PlaceholderTheme get placeholderTheme; + ThemeData get themeData => generatedThemeData.copyWith( primaryColor: primaryColor, cardColor: containerColor, @@ -115,6 +118,7 @@ abstract class ThemeBase { orderTheme, sendPageTheme, seedWidgetTheme, + placeholderTheme, ], scrollbarTheme: ScrollbarThemeData( thumbColor: MaterialStateProperty.all(scrollbarTheme.thumbColor),