mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-11 05:14:46 +00:00
refactor: create WalletListTheme
This commit is contained in:
parent
ca600b4cee
commit
7f929ee976
10 changed files with 74 additions and 74 deletions
|
@ -1,6 +1,7 @@
|
|||
import 'dart:ui';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
@ -274,14 +275,8 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
|
|||
.popAndPushNamed(Routes.welcome)
|
||||
: null,
|
||||
text: 'Accept',
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.titleSmall!
|
||||
.decorationColor!,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.headlineSmall!
|
||||
.decorationColor!),
|
||||
color: Theme.of(context).extension<WalletListTheme>()!.createNewWalletButtonBackgroundColor,
|
||||
textColor: Theme.of(context).extension<WalletListTheme>()!.restoreWalletButtonTextColor),
|
||||
),
|
||||
],
|
||||
],
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/themes/extensions/filter_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
|
||||
class SelectButton extends StatelessWidget {
|
||||
SelectButton({
|
||||
|
@ -20,16 +21,10 @@ class SelectButton extends StatelessWidget {
|
|||
? Colors.green
|
||||
: Theme.of(context).cardColor;
|
||||
final textColor = isSelected
|
||||
? Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.headlineSmall!
|
||||
.decorationColor!
|
||||
? Theme.of(context).extension<WalletListTheme>()!.restoreWalletButtonTextColor
|
||||
: Theme.of(context).primaryTextTheme!.titleLarge!.color!;
|
||||
final arrowColor = isSelected
|
||||
? Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.headlineSmall!
|
||||
.decorationColor!
|
||||
? Theme.of(context).extension<WalletListTheme>()!.restoreWalletButtonTextColor
|
||||
: Theme.of(context).extension<FilterTheme>()!.titlesColor;
|
||||
|
||||
final selectArrowImage = Image.asset('assets/images/select_arrow.png',
|
||||
|
|
|
@ -23,6 +23,7 @@ import 'package:cake_wallet/generated/i18n.dart';
|
|||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
import 'package:cake_wallet/core/seed_validator.dart';
|
||||
import 'package:cake_wallet/view_model/restore/restore_mode.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
|
||||
class WalletRestorePage extends BasePage {
|
||||
WalletRestorePage(this.walletRestoreViewModel)
|
||||
|
@ -192,14 +193,8 @@ class WalletRestorePage extends BasePage {
|
|||
return LoadingPrimaryButton(
|
||||
onPressed: _confirmForm,
|
||||
text: S.of(context).restore_recover,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.titleSmall!
|
||||
.decorationColor!,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.headlineSmall!
|
||||
.decorationColor!,
|
||||
color: Theme.of(context).extension<WalletListTheme>()!.createNewWalletButtonBackgroundColor,
|
||||
textColor: Theme.of(context).extension<WalletListTheme>()!.restoreWalletButtonTextColor,
|
||||
isLoading: walletRestoreViewModel.state is IsExecutingState,
|
||||
isDisabled: !walletRestoreViewModel.isButtonEnabled,
|
||||
);
|
||||
|
|
|
@ -17,6 +17,7 @@ import 'package:cake_wallet/src/screens/base_page.dart';
|
|||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:cake_wallet/wallet_type_utils.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
|
||||
class WalletListPage extends BasePage {
|
||||
WalletListPage({required this.walletListViewModel, required this.authService});
|
||||
|
@ -74,7 +75,7 @@ class WalletListBodyState extends State<WalletListBody> {
|
|||
itemBuilder: (__, index) {
|
||||
final wallet = widget.walletListViewModel.wallets[index];
|
||||
final currentColor = wallet.isCurrent
|
||||
? Theme.of(context).accentTextTheme!.titleSmall!.decorationColor!
|
||||
? Theme.of(context).extension<WalletListTheme>()!.createNewWalletButtonBackgroundColor
|
||||
: Theme.of(context).colorScheme.background;
|
||||
final row = GestureDetector(
|
||||
onTap: () async {
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:cake_wallet/src/screens/base_page.dart';
|
|||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/wallet_type_utils.dart';
|
||||
import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
|
||||
class WelcomePage extends BasePage {
|
||||
static const aspectRatioImage = 1.25;
|
||||
|
@ -52,10 +53,7 @@ class WelcomePage extends BasePage {
|
|||
final newWalletImage = Image.asset('assets/images/new_wallet.png',
|
||||
height: 12,
|
||||
width: 12,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.headlineSmall!
|
||||
.decorationColor!);
|
||||
color: Theme.of(context).extension<WalletListTheme>()!.restoreWalletButtonTextColor);
|
||||
final restoreWalletImage = Image.asset('assets/images/restore_wallet.png',
|
||||
height: 12,
|
||||
width: 12,
|
||||
|
@ -143,14 +141,8 @@ class WelcomePage extends BasePage {
|
|||
Navigator.pushNamed(context, Routes.newWalletFromWelcome),
|
||||
image: newWalletImage,
|
||||
text: S.of(context).create_new,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.titleSmall!
|
||||
.decorationColor!,
|
||||
textColor: Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.headlineSmall!
|
||||
.decorationColor!,
|
||||
color: Theme.of(context).extension<WalletListTheme>()!.createNewWalletButtonBackgroundColor,
|
||||
textColor: Theme.of(context).extension<WalletListTheme>()!.restoreWalletButtonTextColor,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
|
|
|
@ -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/sync_indicator_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
import 'package:cake_wallet/themes/light_theme.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
@ -69,6 +70,10 @@ class BrightTheme extends LightTheme {
|
|||
buttonColor: Colors.white.withOpacity(0.2),
|
||||
iconColor: Colors.white);
|
||||
|
||||
@override
|
||||
WalletListTheme get walletListTheme => super.walletListTheme.copyWith(
|
||||
createNewWalletButtonBackgroundColor: Palette.moderateSlateBlue);
|
||||
|
||||
@override
|
||||
ThemeData get themeData => super.themeData.copyWith(
|
||||
indicatorColor: Colors.white.withOpacity(0.5), // page indicator
|
||||
|
@ -183,18 +188,5 @@ class BrightTheme extends LightTheme {
|
|||
decorationColor:
|
||||
Palette.darkBlueCraiola, // text color (information page)
|
||||
),
|
||||
// subtitle -> titleSmall
|
||||
titleSmall: TextStyle(
|
||||
//decorationColor: Palette.blueCraiola // crete new wallet button background (wallet list page)
|
||||
decorationColor: Palette
|
||||
.moderateSlateBlue // crete new wallet button background (wallet list page)
|
||||
),
|
||||
// headline -> headlineSmall
|
||||
headlineSmall: TextStyle(
|
||||
color: Palette
|
||||
.moderateLavender, // first gradient color of wallet action buttons (wallet list page)
|
||||
decorationColor: Colors
|
||||
.white // restore wallet button text color (wallet list page)
|
||||
),
|
||||
));
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart';
|
|||
import 'package:cake_wallet/themes/extensions/pin_code_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/support_page_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
|
@ -112,6 +113,11 @@ class DarkTheme extends ThemeBase {
|
|||
buttonColor: PaletteDark.oceanBlue,
|
||||
iconColor: PaletteDark.wildBlue);
|
||||
|
||||
@override
|
||||
WalletListTheme get walletListTheme => WalletListTheme(
|
||||
restoreWalletButtonTextColor: Palette.darkBlueCraiola,
|
||||
createNewWalletButtonBackgroundColor: Colors.white);
|
||||
|
||||
@override
|
||||
ThemeData get themeData => super.themeData.copyWith(
|
||||
indicatorColor: PaletteDark.cyanBlue, // page indicator
|
||||
|
@ -230,18 +236,6 @@ class DarkTheme extends ThemeBase {
|
|||
bodySmall: TextStyle(
|
||||
decorationColor: Palette.darkLavender, // text color (information page)
|
||||
),
|
||||
// subtitle -> titleSmall
|
||||
titleSmall: TextStyle(
|
||||
decorationColor: Colors
|
||||
.white // crete new wallet button background (wallet list page)
|
||||
),
|
||||
// headline -> headlineSmall
|
||||
headlineSmall: TextStyle(
|
||||
color: PaletteDark
|
||||
.distantBlue, // first gradient color of wallet action buttons (wallet list page)
|
||||
decorationColor: Palette
|
||||
.darkBlueCraiola // restore wallet button text color (wallet list page)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
38
lib/themes/extensions/wallet_list_theme.dart
Normal file
38
lib/themes/extensions/wallet_list_theme.dart
Normal file
|
@ -0,0 +1,38 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
class WalletListTheme extends ThemeExtension<WalletListTheme> {
|
||||
final Color restoreWalletButtonTextColor;
|
||||
final Color createNewWalletButtonBackgroundColor;
|
||||
|
||||
WalletListTheme(
|
||||
{required this.restoreWalletButtonTextColor,
|
||||
required this.createNewWalletButtonBackgroundColor});
|
||||
|
||||
@override
|
||||
WalletListTheme copyWith(
|
||||
{Color? restoreWalletButtonTextColor,
|
||||
Color? createNewWalletButtonBackgroundColor}) =>
|
||||
WalletListTheme(
|
||||
restoreWalletButtonTextColor:
|
||||
restoreWalletButtonTextColor ?? this.restoreWalletButtonTextColor,
|
||||
createNewWalletButtonBackgroundColor:
|
||||
createNewWalletButtonBackgroundColor ??
|
||||
this.createNewWalletButtonBackgroundColor);
|
||||
|
||||
@override
|
||||
WalletListTheme lerp(ThemeExtension<WalletListTheme>? other, double t) {
|
||||
if (other is! WalletListTheme) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return WalletListTheme(
|
||||
restoreWalletButtonTextColor: Color.lerp(restoreWalletButtonTextColor,
|
||||
other.restoreWalletButtonTextColor, t) ??
|
||||
restoreWalletButtonTextColor,
|
||||
createNewWalletButtonBackgroundColor: Color.lerp(
|
||||
createNewWalletButtonBackgroundColor,
|
||||
other.createNewWalletButtonBackgroundColor,
|
||||
t) ??
|
||||
createNewWalletButtonBackgroundColor);
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart';
|
|||
import 'package:cake_wallet/themes/extensions/pin_code_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/support_page_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
|
@ -113,6 +114,11 @@ class LightTheme extends ThemeBase {
|
|||
buttonColor: Palette.blueAlice,
|
||||
iconColor: PaletteDark.wildBlue);
|
||||
|
||||
@override
|
||||
WalletListTheme get walletListTheme => WalletListTheme(
|
||||
restoreWalletButtonTextColor: Colors.white,
|
||||
createNewWalletButtonBackgroundColor: Palette.protectiveBlue);
|
||||
|
||||
@override
|
||||
ThemeData get themeData => super.themeData.copyWith(
|
||||
indicatorColor:
|
||||
|
@ -231,18 +237,6 @@ class LightTheme extends ThemeBase {
|
|||
bodySmall: TextStyle(
|
||||
decorationColor: Palette.darkBlueCraiola, // text color (information page)
|
||||
),
|
||||
// subtitle -> titleSmall
|
||||
titleSmall: TextStyle(
|
||||
decorationColor: Palette
|
||||
.protectiveBlue // crete new wallet button background (wallet list page)
|
||||
),
|
||||
// headline -> headlineSmall
|
||||
headlineSmall: TextStyle(
|
||||
color: Palette
|
||||
.moderateLavender, // first gradient color of wallet action buttons (wallet list page)
|
||||
decorationColor: Colors
|
||||
.white // restore wallet button text color (wallet list page)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import 'package:cake_wallet/themes/extensions/new_wallet_theme.dart';
|
|||
import 'package:cake_wallet/themes/extensions/pin_code_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/support_page_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum ThemeType { light, bright, dark }
|
||||
|
@ -70,6 +71,8 @@ abstract class ThemeBase {
|
|||
|
||||
FilterTheme get filterTheme;
|
||||
|
||||
WalletListTheme get walletListTheme;
|
||||
|
||||
ThemeData get themeData => generatedThemeData.copyWith(
|
||||
primaryColor: primaryColor,
|
||||
cardColor: containerColor,
|
||||
|
@ -87,6 +90,7 @@ abstract class ThemeBase {
|
|||
addressTheme,
|
||||
menuTheme,
|
||||
filterTheme,
|
||||
walletListTheme,
|
||||
],
|
||||
scrollbarTheme: ScrollbarThemeData(
|
||||
thumbColor: MaterialStateProperty.all(scrollbarTheme.thumbColor),
|
||||
|
|
Loading…
Reference in a new issue