rename and fix text button style update bug

This commit is contained in:
julian 2023-01-30 15:34:21 -06:00
parent 1f7bd41d8e
commit 69435f4807
32 changed files with 81 additions and 54 deletions

View file

@ -584,7 +584,7 @@ class _AddAddressBookEntryViewState
"Address ${i + 1}", "Address ${i + 1}",
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
), ),
BlueTextButton( CustomTextButton(
onTap: () { onTap: () {
_removeForm(forms[i].id); _removeForm(forms[i].id);
}, },
@ -601,7 +601,7 @@ class _AddAddressBookEntryViewState
const SizedBox( const SizedBox(
height: 16, height: 16,
), ),
BlueTextButton( CustomTextButton(
onTap: () { onTap: () {
_addForm(); _addForm();
scrollController.animateTo( scrollController.animateTo(

View file

@ -311,7 +311,7 @@ class _ContactDetailsViewState extends ConsumerState<ContactDetailsView> {
"Addresses", "Addresses",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
BlueTextButton( CustomTextButton(
text: "Add new", text: "Add new",
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(

View file

@ -953,7 +953,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
Theme.of(context).extension<StackColors>()!.textDark3, Theme.of(context).extension<StackColors>()!.textDark3,
), ),
), ),
BlueTextButton( CustomTextButton(
text: buyWithFiat ? "Use crypto amount" : "Use fiat amount", text: buyWithFiat ? "Use crypto amount" : "Use fiat amount",
onTap: () { onTap: () {
setState(() { setState(() {
@ -1129,7 +1129,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
), ),
), ),
if (isStackCoin(selectedCrypto?.ticker)) if (isStackCoin(selectedCrypto?.ticker))
BlueTextButton( CustomTextButton(
text: "Choose from stack", text: "Choose from stack",
onTap: () { onTap: () {
try { try {

View file

@ -189,7 +189,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
), ),
if (isStackCoin(model.receiveTicker)) if (isStackCoin(model.receiveTicker))
BlueTextButton( CustomTextButton(
text: "Choose from stack", text: "Choose from stack",
onTap: () { onTap: () {
try { try {
@ -448,7 +448,7 @@ class _Step2ViewState extends ConsumerState<Step2View> {
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
), ),
if (isStackCoin(model.sendTicker)) if (isStackCoin(model.sendTicker))
BlueTextButton( CustomTextButton(
text: "Choose from stack", text: "Choose from stack",
onTap: () { onTap: () {
try { try {

View file

@ -516,7 +516,7 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
BlueTextButton( CustomTextButton(
text: "View transaction", text: "View transaction",
onTap: () { onTap: () {
final Coin coin = final Coin coin =

View file

@ -118,7 +118,7 @@ class PaynymQrPopup extends StatelessWidget {
const SizedBox( const SizedBox(
height: 6, height: 6,
), ),
BlueTextButton( CustomTextButton(
text: "Copy", text: "Copy",
textSize: isDesktop ? 18 : 10, textSize: isDesktop ? 18 : 10,
onTap: () async { onTap: () async {

View file

@ -324,7 +324,7 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
const SizedBox( const SizedBox(
height: 8, height: 8,
), ),
BlueTextButton( CustomTextButton(
text: "Copy", text: "Copy",
onTap: () async { onTap: () async {
await Clipboard.setData( await Clipboard.setData(

View file

@ -233,7 +233,7 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
BlueTextButton( CustomTextButton(
text: "Create new QR code", text: "Create new QR code",
onTap: () async { onTap: () async {
unawaited(Navigator.of(context).push( unawaited(Navigator.of(context).push(

View file

@ -1304,7 +1304,7 @@ class _SendViewState extends ConsumerState<SendView> {
style: STextStyles.smallMed12(context), style: STextStyles.smallMed12(context),
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
BlueTextButton( CustomTextButton(
text: "Send all ${coin.ticker}", text: "Send all ${coin.ticker}",
onTap: () async { onTap: () async {
if (coin == Coin.firo || if (coin == Coin.firo ||

View file

@ -484,7 +484,7 @@ class AboutView extends ConsumerWidget {
const SizedBox( const SizedBox(
height: 4, height: 4,
), ),
BlueTextButton( CustomTextButton(
text: "https://stackwallet.com", text: "https://stackwallet.com",
onTap: () { onTap: () {
launchUrl( launchUrl(

View file

@ -282,7 +282,7 @@ class _DebugViewState extends ConsumerState<DebugView> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
BlueTextButton( CustomTextButton(
text: "Save Debug Info to clipboard", text: "Save Debug Info to clipboard",
onTap: () async { onTap: () async {
try { try {
@ -350,7 +350,7 @@ class _DebugViewState extends ConsumerState<DebugView> {
}, },
), ),
const Spacer(), const Spacer(),
BlueTextButton( CustomTextButton(
text: "Save logs to file", text: "Save logs to file",
onTap: () async { onTap: () async {
final systemfile = SWBFileSystem(); final systemfile = SWBFileSystem();

View file

@ -92,7 +92,7 @@ class _CoinNodesViewState extends ConsumerState<CoinNodesView> {
), ),
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
BlueTextButton( CustomTextButton(
text: "Add new node", text: "Add new node",
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(

View file

@ -327,7 +327,7 @@ class _AutoBackupViewState extends ConsumerState<AutoBackupView> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
BlueTextButton( CustomTextButton(
text: "Back up now", text: "Back up now",
onTap: () { onTap: () {
ref.read(autoSWBServiceProvider).doBackup(); ref.read(autoSWBServiceProvider).doBackup();
@ -448,7 +448,7 @@ class _AutoBackupViewState extends ConsumerState<AutoBackupView> {
height: 20, height: 20,
), ),
Center( Center(
child: BlueTextButton( child: CustomTextButton(
text: "Edit Auto Backup", text: "Edit Auto Backup",
onTap: () async { onTap: () async {
Navigator.of(context) Navigator.of(context)

View file

@ -749,7 +749,7 @@ class _WalletNetworkSettingsViewState
? STextStyles.desktopTextExtraExtraSmall(context) ? STextStyles.desktopTextExtraExtraSmall(context)
: STextStyles.smallMed12(context), : STextStyles.smallMed12(context),
), ),
BlueTextButton( CustomTextButton(
text: "Add new node", text: "Add new node",
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
@ -880,7 +880,7 @@ class _WalletNetworkSettingsViewState
top: 16, top: 16,
bottom: 6, bottom: 6,
), ),
child: BlueTextButton( child: CustomTextButton(
text: "Rescan", text: "Rescan",
onTap: () async { onTap: () async {
await Navigator.of(context).push( await Navigator.of(context).push(

View file

@ -1092,7 +1092,7 @@ class _TransactionDetailsViewState
height: 8, height: 8,
), ),
if (coin != Coin.epicCash) if (coin != Coin.epicCash)
BlueTextButton( CustomTextButton(
text: "Open in block explorer", text: "Open in block explorer",
onTap: () async { onTap: () async {
final uri = final uri =

View file

@ -649,7 +649,7 @@ class _WalletViewState extends ConsumerState<WalletView> {
.textDark3, .textDark3,
), ),
), ),
BlueTextButton( CustomTextButton(
text: "See all", text: "See all",
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(

View file

@ -24,7 +24,7 @@ class AllWallets extends StatelessWidget {
color: Theme.of(context).extension<StackColors>()!.textDark, color: Theme.of(context).extension<StackColors>()!.textDark,
), ),
), ),
BlueTextButton( CustomTextButton(
text: "Add new", text: "Add new",
onTap: () { onTap: () {
Navigator.of(context).pushNamed(AddWalletView.routeName); Navigator.of(context).pushNamed(AddWalletView.routeName);

View file

@ -66,7 +66,7 @@ class DesktopAddressCard extends StatelessWidget {
), ),
Row( Row(
children: [ children: [
BlueTextButton( CustomTextButton(
text: "Copy", text: "Copy",
onTap: () { onTap: () {
clipboard.setData( clipboard.setData(
@ -87,7 +87,7 @@ class DesktopAddressCard extends StatelessWidget {
if (contactId != "default") if (contactId != "default")
Consumer( Consumer(
builder: (context, ref, child) { builder: (context, ref, child) {
return BlueTextButton( return CustomTextButton(
text: "Edit", text: "Edit",
onTap: () async { onTap: () async {
ref.refresh( ref.refresh(

View file

@ -182,7 +182,7 @@ class _DesktopContactDetailsState extends ConsumerState<DesktopContactDetails> {
style: style:
STextStyles.desktopTextExtraExtraSmall(context), STextStyles.desktopTextExtraExtraSmall(context),
), ),
BlueTextButton( CustomTextButton(
text: "Add new", text: "Add new",
onTap: () async { onTap: () async {
ref.refresh( ref.refresh(

View file

@ -300,7 +300,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
), ),
if (isStackCoin(ref.watch(desktopExchangeModelProvider if (isStackCoin(ref.watch(desktopExchangeModelProvider
.select((value) => value!.receiveTicker)))) .select((value) => value!.receiveTicker))))
BlueTextButton( CustomTextButton(
text: "Choose from stack", text: "Choose from stack",
onTap: selectRecipientAddressFromStack, onTap: selectRecipientAddressFromStack,
), ),
@ -432,7 +432,7 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
), ),
if (isStackCoin(ref.watch(desktopExchangeModelProvider if (isStackCoin(ref.watch(desktopExchangeModelProvider
.select((value) => value!.sendTicker)))) .select((value) => value!.sendTicker))))
BlueTextButton( CustomTextButton(
text: "Choose from stack", text: "Choose from stack",
onTap: selectRefundAddressFromStack, onTap: selectRefundAddressFromStack,
), ),

View file

@ -221,7 +221,7 @@ class _DesktopChooseFromStackState
const SizedBox( const SizedBox(
width: 80, width: 80,
), ),
BlueTextButton( CustomTextButton(
text: "Select wallet", text: "Select wallet",
onTap: () async { onTap: () async {
final address = final address =

View file

@ -72,7 +72,7 @@ class _DesktopTradeHistoryState extends ConsumerState<DesktopTradeHistory> {
"Recent trades", "Recent trades",
style: STextStyles.desktopTextExtraExtraSmall(context), style: STextStyles.desktopTextExtraExtraSmall(context),
), ),
BlueTextButton( CustomTextButton(
text: "See all", text: "See all",
onTap: () { onTap: () {
Navigator.of(context) Navigator.of(context)

View file

@ -39,7 +39,7 @@ class DesktopFavoriteWallets extends ConsumerWidget {
.textFieldActiveSearchIconRight, .textFieldActiveSearchIconRight,
), ),
), ),
BlueTextButton( CustomTextButton(
text: "Edit", text: "Edit",
onTap: () { onTap: () {
Navigator.of(context).pushNamed(ManageFavoritesView.routeName); Navigator.of(context).pushNamed(ManageFavoritesView.routeName);

View file

@ -38,7 +38,7 @@ class _MyWalletsState extends ConsumerState<MyWallets> {
), ),
), ),
const Spacer(), const Spacer(),
BlueTextButton( CustomTextButton(
text: "Add new wallet", text: "Add new wallet",
onTap: () { onTap: () {
Navigator.of( Navigator.of(

View file

@ -133,7 +133,7 @@ class _ContactListItemState extends ConsumerState<ContactListItem> {
], ],
), ),
), ),
BlueTextButton( CustomTextButton(
text: "Select wallet", text: "Select wallet",
onTap: () { onTap: () {
Navigator.of(context).pop(e); Navigator.of(context).pop(e);

View file

@ -987,7 +987,7 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
), ),
textAlign: TextAlign.left, textAlign: TextAlign.left,
), ),
BlueTextButton( CustomTextButton(
text: "Send all ${coin.ticker}", text: "Send all ${coin.ticker}",
onTap: sendAllTapped, onTap: sendAllTapped,
), ),

View file

@ -37,7 +37,7 @@ class _RecentDesktopTransactionsState
.textFieldActiveSearchIconLeft, .textFieldActiveSearchIconLeft,
), ),
), ),
BlueTextButton( CustomTextButton(
text: "See all", text: "See all",
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(

View file

@ -261,7 +261,7 @@ class _DesktopLoginViewState extends ConsumerState<DesktopLoginView> {
const SizedBox( const SizedBox(
height: 60, height: 60,
), ),
BlueTextButton( CustomTextButton(
text: "Forgot password?", text: "Forgot password?",
textSize: 20, textSize: 20,
onTap: () { onTap: () {

View file

@ -450,7 +450,7 @@ class _BackupRestoreSettings extends ConsumerState<BackupRestoreSettings> {
STextStyles.itemSubtitle( STextStyles.itemSubtitle(
context), context),
), ),
BlueTextButton( CustomTextButton(
text: "Back up now", text: "Back up now",
onTap: () { onTap: () {
ref ref

View file

@ -678,7 +678,7 @@ class DesktopAboutView extends ConsumerWidget {
const SizedBox( const SizedBox(
height: 2, height: 2,
), ),
BlueTextButton( CustomTextButton(
text: text:
"https://stackwallet.com", "https://stackwallet.com",
onTap: () { onTap: () {

View file

@ -1,17 +1,17 @@
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/providers/ui/color_theme_provider.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/rounded_container.dart'; import 'package:stackwallet/widgets/rounded_container.dart';
class BlueTextButton extends ConsumerStatefulWidget { class _CustomTextButton extends StatefulWidget {
const BlueTextButton({ const _CustomTextButton({
Key? key, Key? key,
required this.text, required this.text,
required this.enabledColor,
required this.disabledColor,
this.onTap, this.onTap,
this.enabled = true, this.enabled = true,
this.textSize, this.textSize,
@ -21,12 +21,14 @@ class BlueTextButton extends ConsumerStatefulWidget {
final VoidCallback? onTap; final VoidCallback? onTap;
final bool enabled; final bool enabled;
final double? textSize; final double? textSize;
final Color enabledColor;
final Color disabledColor;
@override @override
ConsumerState<BlueTextButton> createState() => _BlueTextButtonState(); State<_CustomTextButton> createState() => _CustomTextButtonState();
} }
class _BlueTextButtonState extends ConsumerState<BlueTextButton> class _CustomTextButtonState extends State<_CustomTextButton>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
AnimationController? controller; AnimationController? controller;
Animation<dynamic>? animation; Animation<dynamic>? animation;
@ -37,18 +39,14 @@ class _BlueTextButtonState extends ConsumerState<BlueTextButton>
@override @override
void initState() { void initState() {
if (widget.enabled) { if (widget.enabled) {
color = ref.read(colorThemeProvider.state).state.buttonTextBorderless; color = widget.enabledColor;
controller = AnimationController( controller = AnimationController(
vsync: this, vsync: this,
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
); );
animation = ColorTween( animation = ColorTween(
begin: ref.read(colorThemeProvider.state).state.buttonTextBorderless, begin: widget.enabledColor,
end: ref end: widget.enabledColor.withOpacity(0.4),
.read(colorThemeProvider.state)
.state
.buttonTextBorderless
.withOpacity(0.4),
).animate(controller!); ).animate(controller!);
animation!.addListener(() { animation!.addListener(() {
@ -57,7 +55,7 @@ class _BlueTextButtonState extends ConsumerState<BlueTextButton>
}); });
}); });
} else { } else {
color = ref.read(colorThemeProvider.state).state.textSubtitle1; color = widget.disabledColor;
} }
super.initState(); super.initState();
@ -116,3 +114,32 @@ class _BlueTextButtonState extends ConsumerState<BlueTextButton>
); );
} }
} }
class CustomTextButton extends StatelessWidget {
const CustomTextButton({
Key? key,
required this.text,
this.onTap,
this.enabled = true,
this.textSize,
}) : super(key: key);
final String text;
final VoidCallback? onTap;
final bool enabled;
final double? textSize;
@override
Widget build(BuildContext context) {
return _CustomTextButton(
key: UniqueKey(),
text: text,
enabledColor:
Theme.of(context).extension<StackColors>()!.buttonTextBorderless,
disabledColor: Theme.of(context).extension<StackColors>()!.textSubtitle1,
enabled: enabled,
textSize: textSize,
onTap: onTap,
);
}
}

View file

@ -261,7 +261,7 @@ class _NodeCardState extends ConsumerState<NodeCard> {
const SizedBox( const SizedBox(
width: 66, width: 66,
), ),
BlueTextButton( CustomTextButton(
text: "Connect", text: "Connect",
enabled: _status == "Disconnected", enabled: _status == "Disconnected",
onTap: () async { onTap: () async {
@ -285,7 +285,7 @@ class _NodeCardState extends ConsumerState<NodeCard> {
const SizedBox( const SizedBox(
width: 48, width: 48,
), ),
BlueTextButton( CustomTextButton(
text: "Details", text: "Details",
onTap: () { onTap: () {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(