mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 12:09:43 +00:00
refactor: create QRCodeTheme
This commit is contained in:
parent
3f51f22982
commit
74abc02a4f
9 changed files with 54 additions and 21 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'package:cake_wallet/entities/contact_base.dart';
|
import 'package:cake_wallet/entities/contact_base.dart';
|
||||||
|
import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||||
import 'package:cake_wallet/themes/extensions/exchange_page_theme.dart';
|
import 'package:cake_wallet/themes/extensions/exchange_page_theme.dart';
|
||||||
|
@ -177,7 +178,7 @@ class ExchangeCardState extends State<ExchangeCard> {
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: Theme.of(context).textTheme!.headlineSmall!.color!),
|
color: Theme.of(context).extension<QRCodeTheme>()!.qrCodeColor),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||||
|
import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
|
||||||
import 'package:cake_wallet/src/widgets/check_box_picker.dart';
|
import 'package:cake_wallet/src/widgets/check_box_picker.dart';
|
||||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
@ -49,10 +50,7 @@ class PresentProviderPicker extends StatelessWidget {
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 10.0,
|
fontSize: 10.0,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Theme.of(context)
|
color: Theme.of(context).extension<QRCodeTheme>()!.qrCodeColor)))
|
||||||
.textTheme!
|
|
||||||
.headlineSmall!
|
|
||||||
.color!)))
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(width: 5),
|
SizedBox(width: 5),
|
||||||
|
|
|
@ -9,6 +9,7 @@ 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/anonpay_status_section.dart';
|
||||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.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/src/screens/receive/widgets/copy_link_item.dart';
|
||||||
|
import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
|
||||||
import 'package:device_display_brightness/device_display_brightness.dart';
|
import 'package:device_display_brightness/device_display_brightness.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart' as qr;
|
import 'package:qr_flutter/qr_flutter.dart' as qr;
|
||||||
|
@ -68,7 +69,7 @@ class AnonPayReceivePage extends BasePage {
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 10.0,
|
fontSize: 10.0,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Theme.of(context).textTheme!.headlineSmall!.color!),
|
color: Theme.of(context).extension<QRCodeTheme>()!.qrCodeColor),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:cake_wallet/entities/qr_view_data.dart';
|
import 'package:cake_wallet/entities/qr_view_data.dart';
|
||||||
|
import 'package:cake_wallet/themes/extensions/qr_code_theme.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
|
import 'package:cake_wallet/src/screens/exchange/widgets/currency_picker.dart';
|
||||||
import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
|
import 'package:cake_wallet/src/screens/receive/widgets/currency_input_field.dart';
|
||||||
|
@ -36,7 +37,7 @@ class QRWidget extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final copyImage = Image.asset('assets/images/copy_address.png',
|
final copyImage = Image.asset('assets/images/copy_address.png',
|
||||||
color: Theme.of(context).textTheme!.titleMedium!.decorationColor!);
|
color: Theme.of(context).extension<QRCodeTheme>()!.qrWidgetCopyButtonColor);
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
|
@ -105,6 +105,11 @@ class BrightTheme extends LightTheme {
|
||||||
amountHintTextColor: Colors.white,
|
amountHintTextColor: Colors.white,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
QRCodeTheme get qrCodeTheme => super
|
||||||
|
.qrCodeTheme
|
||||||
|
.copyWith(qrWidgetCopyButtonColor: Colors.white.withOpacity(0.4));
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ThemeData get themeData => super.themeData.copyWith(
|
ThemeData get themeData => super.themeData.copyWith(
|
||||||
indicatorColor: Colors.white.withOpacity(0.5), // page indicator
|
indicatorColor: Colors.white.withOpacity(0.5), // page indicator
|
||||||
|
@ -121,10 +126,6 @@ class BrightTheme extends LightTheme {
|
||||||
decorationColor:
|
decorationColor:
|
||||||
Colors.white.withOpacity(0.4), // copy button (qr widget)
|
Colors.white.withOpacity(0.4), // copy button (qr widget)
|
||||||
),
|
),
|
||||||
// headline -> headlineSmall
|
|
||||||
headlineSmall: TextStyle(
|
|
||||||
color: Colors.white, // qr code
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,6 +189,11 @@ class DarkTheme extends ThemeBase {
|
||||||
amountBottomBorderColor: PaletteDark.darkGrey,
|
amountBottomBorderColor: PaletteDark.darkGrey,
|
||||||
amountHintTextColor: PaletteDark.cyanBlue);
|
amountHintTextColor: PaletteDark.cyanBlue);
|
||||||
|
|
||||||
|
@override
|
||||||
|
QRCodeTheme get qrCodeTheme => QRCodeTheme(
|
||||||
|
qrCodeColor: PaletteDark.lightBlueGrey,
|
||||||
|
qrWidgetCopyButtonColor: PaletteDark.lightBlueGrey);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ThemeData get themeData => super.themeData.copyWith(
|
ThemeData get themeData => super.themeData.copyWith(
|
||||||
indicatorColor: PaletteDark.cyanBlue, // page indicator
|
indicatorColor: PaletteDark.cyanBlue, // page indicator
|
||||||
|
@ -206,11 +211,6 @@ class DarkTheme extends ThemeBase {
|
||||||
// subhead -> titleMedium
|
// subhead -> titleMedium
|
||||||
titleMedium: TextStyle(
|
titleMedium: TextStyle(
|
||||||
color: PaletteDark.nightBlue, // address button border
|
color: PaletteDark.nightBlue, // address button border
|
||||||
decorationColor: PaletteDark.lightBlueGrey, // copy button (qr widget)
|
|
||||||
),
|
|
||||||
// headline -> headlineSmall
|
|
||||||
headlineSmall: TextStyle(
|
|
||||||
color: PaletteDark.lightBlueGrey, // qr code
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
28
lib/themes/extensions/qr_code_theme.dart
Normal file
28
lib/themes/extensions/qr_code_theme.dart
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class QRCodeTheme extends ThemeExtension<QRCodeTheme> {
|
||||||
|
final Color qrCodeColor;
|
||||||
|
final Color qrWidgetCopyButtonColor;
|
||||||
|
|
||||||
|
QRCodeTheme(
|
||||||
|
{required this.qrCodeColor, required this.qrWidgetCopyButtonColor});
|
||||||
|
|
||||||
|
@override
|
||||||
|
QRCodeTheme copyWith({Color? qrCodeColor, Color? qrWidgetCopyButtonColor}) =>
|
||||||
|
QRCodeTheme(
|
||||||
|
qrCodeColor: qrCodeColor ?? this.qrCodeColor,
|
||||||
|
qrWidgetCopyButtonColor:
|
||||||
|
qrWidgetCopyButtonColor ?? this.qrWidgetCopyButtonColor);
|
||||||
|
|
||||||
|
@override
|
||||||
|
QRCodeTheme lerp(ThemeExtension<QRCodeTheme>? other, double t) {
|
||||||
|
if (other is! QRCodeTheme) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return QRCodeTheme(
|
||||||
|
qrCodeColor: Color.lerp(qrCodeColor, other.qrCodeColor, t)!,
|
||||||
|
qrWidgetCopyButtonColor: Color.lerp(
|
||||||
|
qrWidgetCopyButtonColor, other.qrWidgetCopyButtonColor, t)!);
|
||||||
|
}
|
||||||
|
}
|
|
@ -191,6 +191,11 @@ class LightTheme extends ThemeBase {
|
||||||
amountBottomBorderColor: Palette.darkBlueCraiola,
|
amountBottomBorderColor: Palette.darkBlueCraiola,
|
||||||
amountHintTextColor: Palette.darkBlueCraiola);
|
amountHintTextColor: Palette.darkBlueCraiola);
|
||||||
|
|
||||||
|
@override
|
||||||
|
QRCodeTheme get qrCodeTheme => QRCodeTheme(
|
||||||
|
qrCodeColor: Colors.white,
|
||||||
|
qrWidgetCopyButtonColor: PaletteDark.lightBlueGrey);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ThemeData get themeData => super.themeData.copyWith(
|
ThemeData get themeData => super.themeData.copyWith(
|
||||||
indicatorColor:
|
indicatorColor:
|
||||||
|
@ -209,11 +214,6 @@ class LightTheme extends ThemeBase {
|
||||||
// subhead -> titleMedium
|
// subhead -> titleMedium
|
||||||
titleMedium: TextStyle(
|
titleMedium: TextStyle(
|
||||||
color: Palette.blueAlice, // address button border
|
color: Palette.blueAlice, // address button border
|
||||||
decorationColor: PaletteDark.lightBlueGrey, // copy button (qr widget)
|
|
||||||
),
|
|
||||||
// headline -> headlineSmall
|
|
||||||
headlineSmall: TextStyle(
|
|
||||||
color: Colors.white, // qr code
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -104,6 +104,8 @@ abstract class ThemeBase {
|
||||||
|
|
||||||
ReceivePageTheme get receivePageTheme;
|
ReceivePageTheme get receivePageTheme;
|
||||||
|
|
||||||
|
QRCodeTheme get qrCodeTheme;
|
||||||
|
|
||||||
ThemeData get themeData => generatedThemeData.copyWith(
|
ThemeData get themeData => generatedThemeData.copyWith(
|
||||||
primaryColor: primaryColor,
|
primaryColor: primaryColor,
|
||||||
cardColor: containerColor,
|
cardColor: containerColor,
|
||||||
|
@ -133,6 +135,7 @@ abstract class ThemeBase {
|
||||||
cakeTextTheme,
|
cakeTextTheme,
|
||||||
accountListTheme,
|
accountListTheme,
|
||||||
receivePageTheme,
|
receivePageTheme,
|
||||||
|
qrCodeTheme,
|
||||||
],
|
],
|
||||||
scrollbarTheme: ScrollbarThemeData(
|
scrollbarTheme: ScrollbarThemeData(
|
||||||
thumbColor: MaterialStateProperty.all(scrollbarTheme.thumbColor),
|
thumbColor: MaterialStateProperty.all(scrollbarTheme.thumbColor),
|
||||||
|
|
Loading…
Reference in a new issue