refactor: create TransactionTradeTheme

This commit is contained in:
Rafael Saes 2023-07-05 09:38:00 -03:00
parent 94b574b2da
commit cdc10cba0a
22 changed files with 87 additions and 62 deletions

View file

@ -1,5 +1,6 @@
import 'package:cake_wallet/core/address_validator.dart';
import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cw_core/currency.dart';
import 'package:flutter/material.dart';
@ -48,7 +49,7 @@ class ContactPage extends BasePage {
@override
Widget body(BuildContext context) {
final downArrow = Image.asset('assets/images/arrow_bottom_purple_icon.png',
color: Theme.of(context).primaryTextTheme!.labelSmall!.color!,
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
height: 8);
reaction((_) => contactViewModel.state, (ExecutionState state) {

View file

@ -8,6 +8,7 @@ import 'package:cake_wallet/src/widgets/picker_wrapper_widget.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
//import 'package:date_range_picker/date_range_picker.dart' as date_rage_picker;
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class FilterWidget extends StatelessWidget {
FilterWidget({required this.dashboardViewModel});
@ -33,10 +34,7 @@ class FilterWidget extends StatelessWidget {
child: Text(
S.of(context).filter_by,
style: TextStyle(
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!,
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
fontSize: 16,
fontFamily: 'Lato',
decoration: TextDecoration.none,

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:cw_core/transaction_direction.dart';
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class TransactionRow extends StatelessWidget {
TransactionRow(
@ -36,7 +37,7 @@ class TransactionRow extends StatelessWidget {
width: 36,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Theme.of(context).textTheme!.labelSmall!.decorationColor!
color: Theme.of(context).extension<TransactionTradeTheme>()!.rowsColor
),
child: Image.asset(
direction == TransactionDirection.incoming

View file

@ -10,6 +10,7 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class ExchangeConfirmPage extends BasePage {
ExchangeConfirmPage({required this.tradesStore}) : trade = tradesStore.trade!;
@ -65,10 +66,7 @@ class ExchangeConfirmPage extends BasePage {
style: TextStyle(
fontSize: 12.0,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
),
Text(
trade.id,

View file

@ -21,6 +21,7 @@ import 'package:cake_wallet/src/screens/exchange_trade/widgets/timer_widget.dart
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
void showInformation(
ExchangeTradeViewModel exchangeTradeViewModel, BuildContext context) {
@ -112,7 +113,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
final copyImage = Image.asset('assets/images/copy_content.png',
height: 16,
width: 16,
color: Theme.of(context).primaryTextTheme!.labelSmall!.color!);
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor);
_setEffects();
@ -134,10 +135,7 @@ class ExchangeTradeState extends State<ExchangeTradeForm> {
style: TextStyle(
fontSize: 14.0,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
),
if (trade.expiredAt != null)
TimerWidget(trade.expiredAt!,

View file

@ -12,6 +12,7 @@ import 'package:flutter/material.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class IoniaAccountCardsPage extends BasePage {
IoniaAccountCardsPage(this.ioniaAccountViewModel);
@ -172,7 +173,7 @@ class _IoniaCardListView extends StatelessWidget {
emptyText,
textAlign: TextAlign.center,
style: textSmall(
color: Theme.of(context).primaryTextTheme!.labelSmall!.color!,
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
),
),
)

View file

@ -20,6 +20,7 @@ import 'package:mobx/mobx.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
import 'package:cake_wallet/themes/extensions/send_page_theme.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class IoniaBuyGiftCardDetailPage extends BasePage {
IoniaBuyGiftCardDetailPage(this.ioniaPurchaseViewModel);
@ -416,7 +417,7 @@ class TipButton extends StatelessWidget {
return isSelected
? Theme.of(context).dialogTheme.backgroundColor!
: Theme.of(context).primaryTextTheme!.labelSmall!.color!;
: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor;
}
Color? backgroundColor(BuildContext context) {

View file

@ -11,6 +11,7 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:flutter/services.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class IoniaPaymentStatusPage extends BasePage {
IoniaPaymentStatusPage(this.viewModel);
@ -196,7 +197,7 @@ class _IoniaPaymentStatusPageBodyBodyState extends State<_IoniaPaymentStatusPage
Text(
title,
style: textXSmall(
color: Theme.of(context).primaryTextTheme!.labelSmall!.color!,
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
),
),
SizedBox(height: 8),

View file

@ -1,5 +1,6 @@
import 'package:cake_wallet/typography.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class IoniaTile extends StatelessWidget {
const IoniaTile({
@ -26,7 +27,7 @@ class IoniaTile extends StatelessWidget {
Text(
title,
style: textXSmall(
color: Theme.of(context).primaryTextTheme!.labelSmall!.color!,
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor,
),
),
SizedBox(height: 8),

View file

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class RestoreButton extends StatelessWidget {
const RestoreButton({
@ -57,10 +58,7 @@ class RestoreButton extends StatelessWidget {
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.normal,
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
),
)
],

View file

@ -13,6 +13,7 @@ import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/src/widgets/primary_button.dart';
import 'package:cake_wallet/src/screens/base_page.dart';
import 'package:cake_wallet/view_model/wallet_seed_view_model.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class WalletSeedPage extends BasePage {
WalletSeedPage(this.walletSeedViewModel, {required this.isNewWalletCreated});
@ -150,10 +151,7 @@ class WalletSeedPage extends BasePage {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
),
)
: Offstage(),

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:cake_wallet/src/widgets/standard_list.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class SettingsCellWithArrow extends StandardListRow {
SettingsCellWithArrow({required String title, required Function(BuildContext context)? handler})
@ -8,5 +9,5 @@ class SettingsCellWithArrow extends StandardListRow {
@override
Widget buildTrailing(BuildContext context) =>
Image.asset('assets/images/select_arrow.png',
color: Theme.of(context).primaryTextTheme!.labelSmall!.color!);
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor);
}

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class SettingsVersionCell extends StatelessWidget {
SettingsVersionCell({required this.title});
@ -18,7 +19,7 @@ class SettingsVersionCell extends StatelessWidget {
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: Theme.of(context).primaryTextTheme!.labelSmall!.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
)
],
),

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class TextFieldListRow extends StatelessWidget {
TextFieldListRow(
@ -34,10 +35,7 @@ class TextFieldListRow extends StatelessWidget {
style: TextStyle(
fontSize: titleFontSize,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
textAlign: TextAlign.left),
TextField(
controller: _textController,
@ -57,10 +55,7 @@ class TextFieldListRow extends StatelessWidget {
hintStyle: TextStyle(
fontSize: valueFontSize,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
border: InputBorder.none),
onSubmitted: (value) => onSubmitted?.call(value),
)

View file

@ -1,5 +1,6 @@
import 'package:cake_wallet/src/widgets/standard_switch.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class UnspentCoinsSwitchRow extends StatelessWidget {
UnspentCoinsSwitchRow(
@ -28,10 +29,7 @@ class UnspentCoinsSwitchRow extends StatelessWidget {
style: TextStyle(
fontSize: titleFontSize,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
textAlign: TextAlign.left),
Padding(
padding: EdgeInsets.only(top: 12),

View file

@ -1,5 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class ListRow extends StatelessWidget {
ListRow(
@ -30,10 +31,7 @@ class ListRow extends StatelessWidget {
style: TextStyle(
fontSize: titleFontSize,
fontWeight: FontWeight.w500,
color: Theme.of(context)
.primaryTextTheme!
.labelSmall!
.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
textAlign: TextAlign.left),
Padding(
padding: const EdgeInsets.only(top: 12),

View file

@ -3,6 +3,7 @@ import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator_icon.da
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:cake_wallet/themes/extensions/address_theme.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
class StandardListStatusRow extends StatelessWidget {
StandardListStatusRow({required this.title, required this.value});
@ -25,7 +26,7 @@ class StandardListStatusRow extends StatelessWidget {
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: Theme.of(context).primaryTextTheme!.labelSmall!.color!),
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
textAlign: TextAlign.left),
Padding(
padding: const EdgeInsets.only(top: 12),

View file

@ -9,6 +9,7 @@ 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/transaction_trade_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';
@ -90,6 +91,11 @@ class BrightTheme extends LightTheme {
PlaceholderTheme get placeholderTheme =>
PlaceholderTheme(color: Colors.white.withOpacity(0.5));
@override
TransactionTradeTheme get transactionTradeTheme => super
.transactionTradeTheme
.copyWith(rowsColor: Colors.white.withOpacity(0.2));
@override
ThemeData get themeData => super.themeData.copyWith(
indicatorColor: Colors.white.withOpacity(0.5), // page indicator
@ -100,8 +106,6 @@ class BrightTheme extends LightTheme {
labelSmall: TextStyle(
backgroundColor:
Colors.white.withOpacity(0.5), // date section row
decorationColor: Colors.white
.withOpacity(0.2) // icons (transaction and trade rows)
),
// subhead -> titleMedium
titleMedium: TextStyle(
@ -150,9 +154,6 @@ class BrightTheme extends LightTheme {
bodySmall: TextStyle(
color: PaletteDark.pigeonBlue, // secondary text
),
labelSmall: TextStyle(
color: Palette.darkGray, // transaction/trade details titles
),
),
);
}

View file

@ -18,6 +18,7 @@ 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';
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_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';
@ -160,6 +161,11 @@ class DarkTheme extends ThemeBase {
@override
PlaceholderTheme get placeholderTheme => PlaceholderTheme(color: Colors.grey);
@override
TransactionTradeTheme get transactionTradeTheme => TransactionTradeTheme(
detailsTitlesColor: PaletteDark.lightBlueGrey,
rowsColor: PaletteDark.wildNightBlue);
@override
ThemeData get themeData => super.themeData.copyWith(
indicatorColor: PaletteDark.cyanBlue, // page indicator
@ -174,8 +180,6 @@ class DarkTheme extends ThemeBase {
textTheme: TextTheme(
labelSmall: TextStyle(
backgroundColor: PaletteDark.darkCyanBlue, // date section row
decorationColor: PaletteDark
.wildNightBlue // icons (transaction and trade rows)
),
// subhead -> titleMedium
titleMedium: TextStyle(
@ -221,10 +225,6 @@ class DarkTheme extends ThemeBase {
bodySmall: TextStyle(
color: PaletteDark.darkCyanBlue, // secondary text
),
labelSmall: TextStyle(
color:
PaletteDark.lightBlueGrey, // transaction/trade details titles
),
),
);
}

View file

@ -0,0 +1,29 @@
import 'package:flutter/material.dart';
class TransactionTradeTheme extends ThemeExtension<TransactionTradeTheme> {
final Color detailsTitlesColor;
final Color rowsColor;
TransactionTradeTheme(
{required this.detailsTitlesColor, required this.rowsColor});
@override
TransactionTradeTheme copyWith(
{Color? detailsTitlesColor, Color? rowsColor}) =>
TransactionTradeTheme(
detailsTitlesColor: detailsTitlesColor ?? this.detailsTitlesColor,
rowsColor: rowsColor ?? this.rowsColor);
@override
TransactionTradeTheme lerp(
ThemeExtension<TransactionTradeTheme>? other, double t) {
if (other is! TransactionTradeTheme) {
return this;
}
return TransactionTradeTheme(
detailsTitlesColor:
Color.lerp(detailsTitlesColor, other.detailsTitlesColor, t)!,
rowsColor: Color.lerp(rowsColor, other.rowsColor, t)!);
}
}

View file

@ -18,6 +18,7 @@ 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';
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_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';
@ -162,6 +163,11 @@ class LightTheme extends ThemeBase {
PlaceholderTheme get placeholderTheme =>
PlaceholderTheme(color: PaletteDark.darkCyanBlue);
@override
TransactionTradeTheme get transactionTradeTheme => TransactionTradeTheme(
detailsTitlesColor: Palette.darkGray,
rowsColor: Palette.blueAlice);
@override
ThemeData get themeData => super.themeData.copyWith(
indicatorColor:
@ -177,8 +183,6 @@ class LightTheme extends ThemeBase {
textTheme: TextTheme(
labelSmall: TextStyle(
backgroundColor: PaletteDark.darkCyanBlue, // date section row
decorationColor:
Palette.blueAlice // icons (transaction and trade rows)
),
// subhead -> titleMedium
titleMedium: TextStyle(
@ -225,9 +229,6 @@ class LightTheme extends ThemeBase {
bodySmall: TextStyle(
color: PaletteDark.pigeonBlue, // secondary text
),
labelSmall: TextStyle(
color: Palette.darkGray, // transaction/trade details titles
),
),
);
}

View file

@ -17,6 +17,7 @@ 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';
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
import 'package:cake_wallet/themes/extensions/transaction_trade_theme.dart';
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
import 'package:flutter/material.dart';
@ -94,6 +95,8 @@ abstract class ThemeBase {
PlaceholderTheme get placeholderTheme;
TransactionTradeTheme get transactionTradeTheme;
ThemeData get themeData => generatedThemeData.copyWith(
primaryColor: primaryColor,
cardColor: containerColor,
@ -119,6 +122,7 @@ abstract class ThemeBase {
sendPageTheme,
seedWidgetTheme,
placeholderTheme,
transactionTradeTheme,
],
scrollbarTheme: ScrollbarThemeData(
thumbColor: MaterialStateProperty.all(scrollbarTheme.thumbColor),