mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-20 22:28:46 +00:00
CWA-209 | added possibility to show address of subaddress instead empty label; added possibility to edit label of subaddress; added setLabel method to subaddress creation store; fixed setLabelSubaddress method in the subaddress_list.dart
This commit is contained in:
parent
4b5a2f8b06
commit
9193cb63f6
5 changed files with 79 additions and 12 deletions
|
@ -258,7 +258,7 @@ class Router {
|
||||||
builder: (_) => Provider(
|
builder: (_) => Provider(
|
||||||
create: (_) =>
|
create: (_) =>
|
||||||
SubadrressCreationStore(walletService: walletService),
|
SubadrressCreationStore(walletService: walletService),
|
||||||
child: NewSubaddressPage()));
|
child: NewSubaddressPage(subaddress: settings.arguments as Subaddress,)));
|
||||||
|
|
||||||
case Routes.disclaimer:
|
case Routes.disclaimer:
|
||||||
return CupertinoPageRoute<void>(builder: (_) => DisclaimerPage());
|
return CupertinoPageRoute<void>(builder: (_) => DisclaimerPage());
|
||||||
|
|
|
@ -50,7 +50,7 @@ class SubaddressList {
|
||||||
{int accountIndex, int addressIndex, String label}) async {
|
{int accountIndex, int addressIndex, String label}) async {
|
||||||
await subaddress_list.setLabelForSubaddress(
|
await subaddress_list.setLabelForSubaddress(
|
||||||
accountIndex: accountIndex, addressIndex: addressIndex, label: label);
|
accountIndex: accountIndex, addressIndex: addressIndex, label: label);
|
||||||
await update();
|
await update(accountIndex: accountIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future refresh({int accountIndex}) async {
|
Future refresh({int accountIndex}) async {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||||
import 'package:esys_flutter_share/esys_flutter_share.dart';
|
import 'package:esys_flutter_share/esys_flutter_share.dart';
|
||||||
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/palette.dart';
|
import 'package:cake_wallet/palette.dart';
|
||||||
|
@ -77,6 +78,9 @@ class ReceiveBodyState extends State<ReceiveBody> {
|
||||||
final currentColor = PaletteDark.menuList;
|
final currentColor = PaletteDark.menuList;
|
||||||
final notCurrentColor = PaletteDark.historyPanel;
|
final notCurrentColor = PaletteDark.historyPanel;
|
||||||
|
|
||||||
|
final currentTextColor = Colors.blue;
|
||||||
|
final notCurrentTextColor = PaletteDark.walletCardText;
|
||||||
|
|
||||||
amountController.addListener(() {
|
amountController.addListener(() {
|
||||||
if (_formKey.currentState.validate()) {
|
if (_formKey.currentState.validate()) {
|
||||||
walletStore.onChangedAmountValue(amountController.text);
|
walletStore.onChangedAmountValue(amountController.text);
|
||||||
|
@ -253,9 +257,11 @@ class ReceiveBodyState extends State<ReceiveBody> {
|
||||||
final isCurrent =
|
final isCurrent =
|
||||||
walletStore.subaddress.address == subaddress.address;
|
walletStore.subaddress.address == subaddress.address;
|
||||||
|
|
||||||
final label = subaddress.label;
|
final label = subaddress.label.isNotEmpty
|
||||||
|
? subaddress.label
|
||||||
|
: subaddress.address;
|
||||||
|
|
||||||
return InkWell(
|
final content = InkWell(
|
||||||
onTap: () => walletStore.setSubaddress(subaddress),
|
onTap: () => walletStore.setSubaddress(subaddress),
|
||||||
child: Container(
|
child: Container(
|
||||||
color: isCurrent ? currentColor : notCurrentColor,
|
color: isCurrent ? currentColor : notCurrentColor,
|
||||||
|
@ -268,13 +274,33 @@ class ReceiveBodyState extends State<ReceiveBody> {
|
||||||
child: Text(
|
child: Text(
|
||||||
label,
|
label,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: subaddress.label.isNotEmpty
|
||||||
|
? 18 : 10,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: PaletteDark.walletCardText
|
color: isCurrent
|
||||||
|
? currentTextColor
|
||||||
|
: notCurrentTextColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return isCurrent
|
||||||
|
? content
|
||||||
|
: Slidable(
|
||||||
|
key: Key(subaddress.address),
|
||||||
|
actionPane: SlidableDrawerActionPane(),
|
||||||
|
child: content,
|
||||||
|
secondaryActions: <Widget>[
|
||||||
|
IconSlideAction(
|
||||||
|
caption: S.of(context).edit,
|
||||||
|
color: PaletteDark.walletCardSubAddressField,
|
||||||
|
icon: Icons.edit,
|
||||||
|
onTap: () => Navigator.of(context)
|
||||||
|
.pushNamed(Routes.newSubaddress, arguments: subaddress),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/src/domain/monero/subaddress.dart';
|
||||||
import 'package:mobx/mobx.dart';
|
import 'package:mobx/mobx.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
@ -12,6 +13,10 @@ import 'package:cake_wallet/palette.dart';
|
||||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||||
|
|
||||||
class NewSubaddressPage extends BasePage {
|
class NewSubaddressPage extends BasePage {
|
||||||
|
NewSubaddressPage({this.subaddress});
|
||||||
|
|
||||||
|
final Subaddress subaddress;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get title => S.current.new_subaddress_title;
|
String get title => S.current.new_subaddress_title;
|
||||||
|
|
||||||
|
@ -19,7 +24,7 @@ class NewSubaddressPage extends BasePage {
|
||||||
Color get backgroundColor => PaletteDark.historyPanel;
|
Color get backgroundColor => PaletteDark.historyPanel;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) => NewSubaddressForm();
|
Widget body(BuildContext context) => NewSubaddressForm(subaddress);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -38,13 +43,26 @@ class NewSubaddressPage extends BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
class NewSubaddressForm extends StatefulWidget {
|
class NewSubaddressForm extends StatefulWidget {
|
||||||
|
NewSubaddressForm(this.subaddress);
|
||||||
|
|
||||||
|
final Subaddress subaddress;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
NewSubaddressFormState createState() => NewSubaddressFormState();
|
NewSubaddressFormState createState() => NewSubaddressFormState(subaddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
class NewSubaddressFormState extends State<NewSubaddressForm> {
|
class NewSubaddressFormState extends State<NewSubaddressForm> {
|
||||||
|
NewSubaddressFormState(this.subaddress);
|
||||||
|
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
final _labelController = TextEditingController();
|
final _labelController = TextEditingController();
|
||||||
|
final Subaddress subaddress;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
if (subaddress != null) _labelController.text = subaddress.label;
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
@ -88,12 +106,20 @@ class NewSubaddressFormState extends State<NewSubaddressForm> {
|
||||||
builder: (_) => LoadingPrimaryButton(
|
builder: (_) => LoadingPrimaryButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (_formKey.currentState.validate()) {
|
if (_formKey.currentState.validate()) {
|
||||||
|
if (subaddress != null) {
|
||||||
|
await subaddressCreationStore.setLabel(
|
||||||
|
addressIndex: subaddress.id,
|
||||||
|
label: _labelController.text
|
||||||
|
);
|
||||||
|
} else {
|
||||||
await subaddressCreationStore.add(
|
await subaddressCreationStore.add(
|
||||||
label: _labelController.text);
|
label: _labelController.text);
|
||||||
Navigator.of(context).pop();
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
text: S.of(context).new_subaddress_create,
|
text: subaddress != null
|
||||||
|
? S.of(context).rename
|
||||||
|
: S.of(context).new_subaddress_create,
|
||||||
color: Colors.green,
|
color: Colors.green,
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
isLoading:
|
isLoading:
|
||||||
|
|
|
@ -27,6 +27,7 @@ abstract class SubadrressCreationStoreBase with Store {
|
||||||
walletService.onWalletChange.listen(_onWalletChanged);
|
walletService.onWalletChange.listen(_onWalletChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@observable
|
||||||
SubaddressCreationState state;
|
SubaddressCreationState state;
|
||||||
|
|
||||||
@observable
|
@observable
|
||||||
|
@ -70,6 +71,20 @@ abstract class SubadrressCreationStoreBase with Store {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> setLabel({int addressIndex, String label}) async {
|
||||||
|
try {
|
||||||
|
state = SubaddressIsCreating();
|
||||||
|
await _subaddressList.setLabelSubaddress(
|
||||||
|
accountIndex: _account.id,
|
||||||
|
addressIndex: addressIndex,
|
||||||
|
label: label
|
||||||
|
);
|
||||||
|
state = SubaddressCreatedSuccessfully();
|
||||||
|
} catch (e) {
|
||||||
|
state = SubaddressCreationFailure(error: e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _onWalletChanged(Wallet wallet) async {
|
Future<void> _onWalletChanged(Wallet wallet) async {
|
||||||
if (wallet is MoneroWallet) {
|
if (wallet is MoneroWallet) {
|
||||||
_account = wallet.account;
|
_account = wallet.account;
|
||||||
|
|
Loading…
Reference in a new issue