mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
improve address rotation button ui + fix bug when autogenerate is disabled (#3334)
* improve address rotation button ui + fix bug when autogenerate is disabled * remove dumbass debug print * add button show condition
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:cake_wallet/core/utilities.dart';
|
||||
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/new-ui/widgets/modern_button.dart';
|
||||
import 'package:cake_wallet/new-ui/widgets/receive_page/payjoin_copy_modal.dart';
|
||||
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_address_type.dart';
|
||||
import 'package:cake_wallet/new-ui/widgets/receive_page/receive_address_widget.dart';
|
||||
@@ -22,6 +23,7 @@ import 'package:cw_core/crypto_currency.dart';
|
||||
import 'package:cw_core/payment_uris.dart';
|
||||
import 'package:cw_core/receive_page_option.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
|
||||
@@ -194,29 +196,37 @@ class _NewReceivePageState extends State<NewReceivePage> {
|
||||
ModalTopBar(
|
||||
title: _largeQrMode ? "" : S.of(context).receive,
|
||||
leadingIcon: Icon(Icons.close),
|
||||
trailingIcon: _largeQrMode
|
||||
? Icon(Icons.share)
|
||||
: widget.addressListViewModel.hasAddressRotation
|
||||
/* TODO rotating is broken on mweb, disabling for now, fix after mvp*/
|
||||
&&
|
||||
!(widget.receiveOptionViewModel.selectedReceiveOption.description ?? "")
|
||||
.toLowerCase()
|
||||
.contains("mweb")
|
||||
? Icon(Icons.refresh)
|
||||
: null,
|
||||
onLeadingPressed: () {
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
},
|
||||
onTrailingPressed: () {
|
||||
if (_largeQrMode) {
|
||||
ShareUtil.share(
|
||||
text: widget.addressListViewModel.uri.toString(),
|
||||
context: context,
|
||||
);
|
||||
} else if (widget.addressListViewModel.hasAddressRotation) {
|
||||
widget.addressListViewModel.rotateAddress();
|
||||
}
|
||||
},
|
||||
trailingWidget: Observer(
|
||||
builder: (_) => AnimatedSwitcher(
|
||||
duration: Duration(milliseconds: 300),
|
||||
child: _largeQrMode || widget.addressListViewModel.hasAddressRotation
|
||||
/* TODO rotating is broken on mweb, disabling for now, fix after mvp*/
|
||||
&&
|
||||
!(widget.receiveOptionViewModel.selectedReceiveOption.description ?? "")
|
||||
.toLowerCase()
|
||||
.contains("mweb") ? ModernButton(
|
||||
key: ValueKey(_largeQrMode),
|
||||
size: 36,
|
||||
icon: _largeQrMode ? Icon(Icons.share) : widget.addressListViewModel.isRotatingAddress
|
||||
? CupertinoActivityIndicator()
|
||||
: Icon(Icons.refresh),
|
||||
onPressed: () {
|
||||
if(_largeQrMode) {
|
||||
ShareUtil.share(
|
||||
text: widget.addressListViewModel.uri.toString(),
|
||||
context: context,
|
||||
);
|
||||
} else {
|
||||
if(widget.addressListViewModel.hasAddressRotation) {
|
||||
widget.addressListViewModel.rotateAddress();
|
||||
}
|
||||
}
|
||||
}):SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
|
||||
@@ -614,11 +614,20 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
void setAddress(WalletAddressListItem address) =>
|
||||
wallet.walletAddresses.address = address.address;
|
||||
|
||||
@observable
|
||||
bool isRotatingAddress = false;
|
||||
|
||||
@action
|
||||
Future<void> rotateAddress() async {
|
||||
await createNewAddress(wallet, "");
|
||||
if (isElectrumWallet) {
|
||||
if(isRotatingAddress) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
isRotatingAddress = true;
|
||||
await createNewAddress(wallet, "");
|
||||
wallet.walletAddresses.address = addressList.whereType<WalletAddressListItem>().last.address;
|
||||
} finally {
|
||||
isRotatingAddress = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user