mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
Merge pull request #57 from cake-tech/CWA-209-rework-receive-screen
Cwa 209 rework receive screen
This commit is contained in:
@@ -50,7 +50,7 @@ class SubaddressList {
|
||||
{int accountIndex, int addressIndex, String label}) async {
|
||||
await subaddress_list.setLabelForSubaddress(
|
||||
accountIndex: accountIndex, addressIndex: addressIndex, label: label);
|
||||
await update();
|
||||
await update(accountIndex: accountIndex);
|
||||
}
|
||||
|
||||
Future refresh({int accountIndex}) async {
|
||||
|
||||
@@ -1,120 +1,153 @@
|
||||
import 'dart:ui';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/account_list/account_list_store.dart';
|
||||
import 'package:cake_wallet/src/screens/accounts/widgets/account_tile.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
|
||||
class AccountListPage extends BasePage {
|
||||
@override
|
||||
String get title => S.current.accounts;
|
||||
class AccountListPage extends StatefulWidget {
|
||||
AccountListPage({@required this.accountListStore});
|
||||
|
||||
final AccountListStore accountListStore;
|
||||
|
||||
@override
|
||||
Widget trailing(BuildContext context) {
|
||||
final accountListStore = Provider.of<AccountListStore>(context);
|
||||
AccountListPageForm createState() => AccountListPageForm(accountListStore);
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: 28.0,
|
||||
height: 28.0,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle, color: Theme.of(context).selectedRowColor),
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: <Widget>[
|
||||
Icon(Icons.add, color: Palette.violet, size: 22.0),
|
||||
ButtonTheme(
|
||||
minWidth: 28.0,
|
||||
height: 28.0,
|
||||
child: FlatButton(
|
||||
shape: CircleBorder(),
|
||||
onPressed: () async {
|
||||
await Navigator.of(context)
|
||||
.pushNamed(Routes.accountCreation);
|
||||
accountListStore.updateAccountList();
|
||||
},
|
||||
child: Offstage()),
|
||||
)
|
||||
],
|
||||
));
|
||||
}
|
||||
class AccountListPageForm extends State<AccountListPage> {
|
||||
AccountListPageForm(this.accountListStore);
|
||||
|
||||
final AccountListStore accountListStore;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final accountListStore = Provider.of<AccountListStore>(context);
|
||||
Widget build(BuildContext context) {
|
||||
final walletStore = Provider.of<WalletStore>(context);
|
||||
|
||||
final currentColor = Theme.of(context).selectedRowColor;
|
||||
final notCurrentColor = Theme.of(context).backgroundColor;
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 10, bottom: 20),
|
||||
child: Observer(builder: (_) {
|
||||
final accounts = accountListStore.accounts;
|
||||
return ListView.builder(
|
||||
itemCount: accounts == null ? 0 : accounts.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final account = accounts[index];
|
||||
|
||||
return Observer(builder: (_) {
|
||||
final isCurrent = walletStore.account.id == account.id;
|
||||
|
||||
return Slidable(
|
||||
key: Key(account.id.toString()),
|
||||
actionPane: SlidableDrawerActionPane(),
|
||||
child: Container(
|
||||
color: isCurrent ? currentColor : notCurrentColor,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text(
|
||||
account.label,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.headline
|
||||
.color),
|
||||
),
|
||||
onTap: () {
|
||||
if (isCurrent) {
|
||||
return;
|
||||
}
|
||||
|
||||
walletStore.setAccount(account);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
color: Theme.of(context).dividerTheme.color,
|
||||
height: 1.0,
|
||||
)
|
||||
],
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).pop(),
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(color: PaletteDark.historyPanel.withOpacity(0.75)),
|
||||
child: Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
child: Text(
|
||||
S.of(context).choose_account,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
decoration: TextDecoration.none,
|
||||
color: Colors.white
|
||||
),
|
||||
),
|
||||
),
|
||||
secondaryActions: <Widget>[
|
||||
IconSlideAction(
|
||||
caption: S.of(context).edit,
|
||||
color: Colors.blue,
|
||||
icon: Icons.edit,
|
||||
onTap: () async {
|
||||
await Navigator.of(context).pushNamed(
|
||||
Routes.accountCreation,
|
||||
arguments: account);
|
||||
// await accountListStore.updateAccountList().then((_) {
|
||||
// if (isCurrent) walletStore.setAccount(accountListStore.accounts[index]);
|
||||
// });
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
});
|
||||
}),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 24, right: 24, top: 24),
|
||||
child: GestureDetector(
|
||||
onTap: () => null,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(14)),
|
||||
child: Container(
|
||||
height: 296,
|
||||
color: PaletteDark.menuList,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
final accounts = accountListStore.accounts;
|
||||
|
||||
return ListView.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
color: PaletteDark.mainBackgroundColor,
|
||||
height: 1,
|
||||
),
|
||||
itemCount: accounts == null ? 0 : accounts.length,
|
||||
itemBuilder: (context, index) {
|
||||
final account = accounts[index];
|
||||
|
||||
return Observer(
|
||||
builder: (_) {
|
||||
final isCurrent = walletStore.account.id == account.id;
|
||||
|
||||
return AccountTile(
|
||||
isCurrent: isCurrent,
|
||||
accountName: account.label,
|
||||
onTap: () {
|
||||
if (isCurrent) {
|
||||
return;
|
||||
}
|
||||
|
||||
walletStore.setAccount(account);
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
)
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await Navigator.of(context)
|
||||
.pushNamed(Routes.accountCreation);
|
||||
accountListStore.updateAccountList();
|
||||
},
|
||||
child: Container(
|
||||
height: 62,
|
||||
color: Colors.white,
|
||||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Icon(
|
||||
Icons.add,
|
||||
color: PaletteDark.historyPanel,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
S.of(context).create_new_account,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: PaletteDark.historyPanel,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/account.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
|
||||
class AccountPage extends BasePage {
|
||||
AccountPage({this.account});
|
||||
@@ -15,7 +16,10 @@ class AccountPage extends BasePage {
|
||||
final Account account;
|
||||
|
||||
@override
|
||||
String get title => 'Account';
|
||||
String get title => S.current.account;
|
||||
|
||||
@override
|
||||
Color get backgroundColor => PaletteDark.historyPanel;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => AccountForm(account);
|
||||
@@ -50,30 +54,31 @@ class AccountFormState extends State<AccountForm> {
|
||||
Widget build(BuildContext context) {
|
||||
final accountListStore = Provider.of<AccountListStore>(context);
|
||||
|
||||
_textController.addListener(() {
|
||||
if (_textController.text.isNotEmpty) {
|
||||
accountListStore.setDisabledStatus(false);
|
||||
} else {
|
||||
accountListStore.setDisabledStatus(true);
|
||||
}
|
||||
});
|
||||
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(20.0),
|
||||
color: PaletteDark.historyPanel,
|
||||
padding: EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: TextFormField(
|
||||
decoration: InputDecoration(
|
||||
hintStyle: TextStyle(color: Theme.of(context).hintColor),
|
||||
child: BaseTextFormField(
|
||||
controller: _textController,
|
||||
hintText: S.of(context).account,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Palette.cakeGreen, width: 2.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).focusColor, width: 1.0))),
|
||||
controller: _textController,
|
||||
validator: (value) {
|
||||
accountListStore.validateAccountName(value);
|
||||
return accountListStore.errorMessage;
|
||||
},
|
||||
),
|
||||
validator: (value) {
|
||||
accountListStore.validateAccountName(value);
|
||||
return accountListStore.errorMessage;
|
||||
},
|
||||
)
|
||||
)),
|
||||
Observer(
|
||||
builder: (_) => LoadingPrimaryButton(
|
||||
@@ -93,13 +98,11 @@ class AccountFormState extends State<AccountForm> {
|
||||
Navigator.of(context).pop(_textController.text);
|
||||
},
|
||||
text:
|
||||
widget.account != null ? 'Rename' : S.of(context).add,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.button
|
||||
.backgroundColor,
|
||||
textColor: Theme.of(context).primaryTextTheme.button.color,
|
||||
widget.account != null ? S.of(context).rename : S.of(context).add,
|
||||
color: Colors.green,
|
||||
textColor: Colors.white,
|
||||
isLoading: accountListStore.isAccountCreating,
|
||||
isDisabled: accountListStore.isDisabledStatus,
|
||||
))
|
||||
],
|
||||
),
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
|
||||
class AccountTile extends StatelessWidget {
|
||||
AccountTile({
|
||||
@required this.isCurrent,
|
||||
@required this.accountName,
|
||||
@required this.onTap
|
||||
});
|
||||
|
||||
final bool isCurrent;
|
||||
final String accountName;
|
||||
final VoidCallback onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = isCurrent ? PaletteDark.menuHeader : Colors.transparent;
|
||||
final textColor = isCurrent ? Colors.blue : Colors.white;
|
||||
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
height: 77,
|
||||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
alignment: Alignment.centerLeft,
|
||||
color: color,
|
||||
child: Text(
|
||||
accountName,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: textColor,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/qr_image.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
|
||||
class WalletCard extends StatefulWidget {
|
||||
@override
|
||||
@@ -425,12 +426,14 @@ class WalletCardState extends State<WalletCard> {
|
||||
color: PaletteDark.walletCardSubAddressField
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {},
|
||||
onTap: () => Navigator.of(context,
|
||||
rootNavigator: true)
|
||||
.pushNamed(Routes.receive),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
S.current.subaddresses,
|
||||
S.of(context).accounts_subaddresses,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.white
|
||||
|
||||
@@ -13,7 +13,7 @@ import 'package:cake_wallet/src/stores/send/send_store.dart';
|
||||
import 'package:cake_wallet/src/stores/send/sending_state.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange_trade/widgets/copy_button.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/qr_image.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/exchange_trade/widgets/timer_widget.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
|
||||
@@ -3,18 +3,26 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:esys_flutter_share/esys_flutter_share.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/stores/subaddress_list/subaddress_list_store.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/qr_image.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_image.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/accounts/account_list_page.dart';
|
||||
import 'package:cake_wallet/src/stores/account_list/account_list_store.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/header_tile.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
|
||||
class ReceivePage extends BasePage {
|
||||
@override
|
||||
bool get isModalBackButton => true;
|
||||
Color get backgroundColor => PaletteDark.mainBackgroundColor;
|
||||
|
||||
@override
|
||||
bool get resizeToAvoidBottomPadding => false;
|
||||
|
||||
@override
|
||||
String get title => S.current.receive;
|
||||
@@ -22,6 +30,7 @@ class ReceivePage extends BasePage {
|
||||
@override
|
||||
Widget trailing(BuildContext context) {
|
||||
final walletStore = Provider.of<WalletStore>(context);
|
||||
final shareImage = Image.asset('assets/images/share.png');
|
||||
|
||||
return SizedBox(
|
||||
height: 37.0,
|
||||
@@ -33,18 +42,14 @@ class ReceivePage extends BasePage {
|
||||
splashColor: Colors.transparent,
|
||||
padding: EdgeInsets.all(0),
|
||||
onPressed: () => Share.text(
|
||||
'Share address', walletStore.subaddress.address, 'text/plain'),
|
||||
child: Icon(
|
||||
Icons.share,
|
||||
size: 30.0,
|
||||
)),
|
||||
S.current.share_address, walletStore.subaddress.address, 'text/plain'),
|
||||
child: shareImage),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) =>
|
||||
SingleChildScrollView(child: ReceiveBody());
|
||||
Widget body(BuildContext context) => ReceiveBody();
|
||||
}
|
||||
|
||||
class ReceiveBody extends StatefulWidget {
|
||||
@@ -66,9 +71,15 @@ class ReceiveBodyState extends State<ReceiveBody> {
|
||||
Widget build(BuildContext context) {
|
||||
final walletStore = Provider.of<WalletStore>(context);
|
||||
final subaddressListStore = Provider.of<SubaddressListStore>(context);
|
||||
final accountListStore = Provider.of<AccountListStore>(context);
|
||||
|
||||
final currentColor = Theme.of(context).selectedRowColor;
|
||||
final notCurrentColor = Theme.of(context).scaffoldBackgroundColor;
|
||||
final copyImage = Image.asset('assets/images/copy_content.png');
|
||||
|
||||
final currentColor = PaletteDark.menuList;
|
||||
final notCurrentColor = PaletteDark.historyPanel;
|
||||
|
||||
final currentTextColor = Colors.blue;
|
||||
final notCurrentTextColor = PaletteDark.walletCardText;
|
||||
|
||||
amountController.addListener(() {
|
||||
if (_formKey.currentState.validate()) {
|
||||
@@ -78,202 +89,227 @@ class ReceiveBodyState extends State<ReceiveBody> {
|
||||
}
|
||||
});
|
||||
|
||||
return SafeArea(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
padding: EdgeInsets.all(35.0),
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Observer(builder: (_) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Spacer(
|
||||
flex: 1,
|
||||
),
|
||||
Flexible(
|
||||
flex: 2,
|
||||
return Container(
|
||||
height: MediaQuery.of(context).size.height,
|
||||
width: MediaQuery.of(context).size.width,
|
||||
color: PaletteDark.mainBackgroundColor,
|
||||
padding: EdgeInsets.only(top: 24),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Observer(builder: (_) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Spacer(
|
||||
flex: 1,
|
||||
),
|
||||
Flexible(
|
||||
flex: 2,
|
||||
child: Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 1.0,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
color: Colors.white,
|
||||
child: QrImage(
|
||||
data: walletStore.subaddress.address +
|
||||
walletStore.amountValue,
|
||||
backgroundColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
)),
|
||||
Spacer(
|
||||
flex: 1,
|
||||
)
|
||||
],
|
||||
);
|
||||
}),
|
||||
Observer(builder: (_) {
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(20.0),
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: walletStore.subaddress.address));
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
S.of(context).copied_to_clipboard,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
backgroundColor: Colors.green,
|
||||
));
|
||||
},
|
||||
child: Text(
|
||||
walletStore.subaddress.address,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color),
|
||||
child: QrImage(
|
||||
data: walletStore.subaddress.address +
|
||||
walletStore.amountValue,
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: PaletteDark.walletCardText,
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
],
|
||||
);
|
||||
}),
|
||||
Row(
|
||||
)),
|
||||
Spacer(
|
||||
flex: 1,
|
||||
)
|
||||
],
|
||||
);
|
||||
}),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(24),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: TextFormField(
|
||||
keyboardType:
|
||||
TextInputType.numberWithOptions(decimal: true),
|
||||
child: BaseTextFormField(
|
||||
controller: amountController,
|
||||
keyboardType: TextInputType.numberWithOptions(decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
style: TextStyle(
|
||||
fontSize: 14.0,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintStyle: TextStyle(
|
||||
color: Theme.of(context).hintColor),
|
||||
hintText: S.of(context).amount,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Palette.cakeGreen, width: 2.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).focusColor,
|
||||
width: 1.0))),
|
||||
textAlign: TextAlign.center,
|
||||
hintText: S.of(context).receive_amount,
|
||||
borderColor: PaletteDark.walletCardText,
|
||||
validator: (value) {
|
||||
walletStore.validateAmount(value);
|
||||
return walletStore.errorMessage;
|
||||
},
|
||||
autovalidate: true,
|
||||
controller: amountController,
|
||||
)))
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Container(
|
||||
color: Theme.of(context).accentTextTheme.headline.color,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
ListTile(
|
||||
title: Text(
|
||||
S.of(context).subaddresses,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.headline
|
||||
.color),
|
||||
),
|
||||
trailing: Container(
|
||||
width: 28.0,
|
||||
height: 28.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).selectedRowColor,
|
||||
shape: BoxShape.circle),
|
||||
child: InkWell(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.newSubaddress),
|
||||
borderRadius: BorderRadius.all(Radius.circular(14.0)),
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: Palette.violet,
|
||||
size: 22.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
color: Theme.of(context).dividerTheme.color,
|
||||
height: 1.0,
|
||||
)
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
))
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
child: Observer(
|
||||
builder: (_) => GestureDetector(
|
||||
onTap: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: walletStore.subaddress.address));
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: Text(
|
||||
S.of(context).copied_to_clipboard,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
backgroundColor: Colors.green,
|
||||
duration: Duration(milliseconds: 500),
|
||||
));
|
||||
},
|
||||
child: Container(
|
||||
height: 48,
|
||||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(27)),
|
||||
color: PaletteDark.walletCardSubAddressField
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Text(
|
||||
walletStore.subaddress.address,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 12),
|
||||
child: copyImage,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(24),
|
||||
topRight: Radius.circular(24),
|
||||
),
|
||||
color: PaletteDark.historyPanel,
|
||||
),
|
||||
child: Observer(
|
||||
builder: (_) => ListView.separated(
|
||||
separatorBuilder: (context, index) => Divider(
|
||||
height: 1,
|
||||
color: PaletteDark.menuList,
|
||||
),
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: subaddressListStore.subaddresses.length + 2,
|
||||
itemBuilder: (context, index) {
|
||||
|
||||
if (index == 0) {
|
||||
return HeaderTile(
|
||||
onTap: () async {
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AccountListPage(accountListStore: accountListStore);
|
||||
}
|
||||
);
|
||||
},
|
||||
title: walletStore.account.label,
|
||||
icon: Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 14,
|
||||
color: Colors.white,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (index == 1) {
|
||||
return HeaderTile(
|
||||
onTap: () => Navigator.of(context)
|
||||
.pushNamed(Routes.newSubaddress),
|
||||
title: S.of(context).subaddresses,
|
||||
icon: Icon(
|
||||
Icons.add,
|
||||
size: 20,
|
||||
color: Colors.white,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
index -= 2;
|
||||
|
||||
return Observer(
|
||||
builder: (_) {
|
||||
final subaddress = subaddressListStore.subaddresses[index];
|
||||
final isCurrent =
|
||||
walletStore.subaddress.address == subaddress.address;
|
||||
|
||||
final label = subaddress.label.isNotEmpty
|
||||
? subaddress.label
|
||||
: subaddress.address;
|
||||
|
||||
final content = InkWell(
|
||||
onTap: () => walletStore.setSubaddress(subaddress),
|
||||
child: Container(
|
||||
color: isCurrent ? currentColor : notCurrentColor,
|
||||
padding: EdgeInsets.only(
|
||||
left: 24,
|
||||
right: 24,
|
||||
top: 28,
|
||||
bottom: 28
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: subaddress.label.isNotEmpty
|
||||
? 18 : 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
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),
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Observer(builder: (_) {
|
||||
return ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
itemCount: subaddressListStore.subaddresses.length,
|
||||
separatorBuilder: (context, i) {
|
||||
return Divider(
|
||||
color: Theme.of(context).dividerTheme.color,
|
||||
height: 1.0,
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, i) {
|
||||
return Observer(builder: (_) {
|
||||
final subaddress = subaddressListStore.subaddresses[i];
|
||||
final isCurrent =
|
||||
walletStore.subaddress.address == subaddress.address;
|
||||
final label = subaddress.label.isNotEmpty
|
||||
? subaddress.label
|
||||
: subaddress.address;
|
||||
|
||||
return InkWell(
|
||||
onTap: () => walletStore.setSubaddress(subaddress),
|
||||
child: Container(
|
||||
color: isCurrent ? currentColor : notCurrentColor,
|
||||
child: Column(children: <Widget>[
|
||||
ListTile(
|
||||
title: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.headline
|
||||
.color),
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
})
|
||||
],
|
||||
)));
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
|
||||
class HeaderTile extends StatelessWidget {
|
||||
HeaderTile({
|
||||
@required this.onTap,
|
||||
@required this.title,
|
||||
@required this.icon
|
||||
});
|
||||
|
||||
final VoidCallback onTap;
|
||||
final String title;
|
||||
final Icon icon;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: EdgeInsets.only(
|
||||
left: 24,
|
||||
right: 24,
|
||||
top: 24,
|
||||
bottom: 24
|
||||
),
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
width: 32,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: PaletteDark.menuList
|
||||
),
|
||||
child: icon,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:qr/qr.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/qr_painter.dart';
|
||||
import 'package:cake_wallet/src/screens/receive/widgets/qr_painter.dart';
|
||||
|
||||
class QrImage extends StatelessWidget {
|
||||
QrImage({
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:cake_wallet/src/domain/monero/subaddress.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -9,13 +10,21 @@ import 'package:cake_wallet/src/stores/subaddress_creation/subaddress_creation_s
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
|
||||
class NewSubaddressPage extends BasePage {
|
||||
NewSubaddressPage({this.subaddress});
|
||||
|
||||
final Subaddress subaddress;
|
||||
|
||||
@override
|
||||
String get title => S.current.new_subaddress_title;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => NewSubaddressForm();
|
||||
Color get backgroundColor => PaletteDark.historyPanel;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => NewSubaddressForm(subaddress);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -34,65 +43,93 @@ class NewSubaddressPage extends BasePage {
|
||||
}
|
||||
|
||||
class NewSubaddressForm extends StatefulWidget {
|
||||
NewSubaddressForm(this.subaddress);
|
||||
|
||||
final Subaddress subaddress;
|
||||
|
||||
@override
|
||||
NewSubaddressFormState createState() => NewSubaddressFormState();
|
||||
NewSubaddressFormState createState() => NewSubaddressFormState(subaddress);
|
||||
}
|
||||
|
||||
class NewSubaddressFormState extends State<NewSubaddressForm> {
|
||||
NewSubaddressFormState(this.subaddress);
|
||||
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final _labelController = TextEditingController();
|
||||
final Subaddress subaddress;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (subaddress != null) _labelController.text = subaddress.label;
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_labelController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final subaddressCreationStore =
|
||||
Provider.of<SubadrressCreationStore>(context);
|
||||
|
||||
_labelController.addListener(() {
|
||||
if (_labelController.text.isNotEmpty) {
|
||||
subaddressCreationStore.setDisabledStatus(false);
|
||||
} else {
|
||||
subaddressCreationStore.setDisabledStatus(true);
|
||||
}
|
||||
});
|
||||
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: Stack(children: <Widget>[
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(left: 35, right: 35),
|
||||
child: TextFormField(
|
||||
controller: _labelController,
|
||||
decoration: InputDecoration(
|
||||
hintStyle: TextStyle(color: Theme.of(context).hintColor),
|
||||
hintText: S.of(context).new_subaddress_label_name,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Palette.cakeGreen, width: 2.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).focusColor,
|
||||
width: 1.0))),
|
||||
validator: (value) {
|
||||
subaddressCreationStore.validateSubaddressName(value);
|
||||
return subaddressCreationStore.errorMessage;
|
||||
}),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 20,
|
||||
left: 20,
|
||||
right: 20,
|
||||
child: Observer(
|
||||
child: Container(
|
||||
color: PaletteDark.historyPanel,
|
||||
padding: EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: BaseTextFormField(
|
||||
controller: _labelController,
|
||||
hintText: S.of(context).new_subaddress_label_name,
|
||||
validator: (value) {
|
||||
subaddressCreationStore.validateSubaddressName(value);
|
||||
return subaddressCreationStore.errorMessage;
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
Observer(
|
||||
builder: (_) => LoadingPrimaryButton(
|
||||
onPressed: () async {
|
||||
if (_formKey.currentState.validate()) {
|
||||
await subaddressCreationStore.add(
|
||||
label: _labelController.text);
|
||||
Navigator.of(context).pop();
|
||||
if (subaddress != null) {
|
||||
await subaddressCreationStore.setLabel(
|
||||
addressIndex: subaddress.id,
|
||||
label: _labelController.text
|
||||
);
|
||||
} else {
|
||||
await subaddressCreationStore.add(
|
||||
label: _labelController.text);
|
||||
}
|
||||
}
|
||||
},
|
||||
text: S.of(context).new_subaddress_create,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.button
|
||||
.backgroundColor,
|
||||
textColor: Theme.of(context).primaryTextTheme.button.color,
|
||||
text: subaddress != null
|
||||
? S.of(context).rename
|
||||
: S.of(context).new_subaddress_create,
|
||||
color: Colors.green,
|
||||
textColor: Colors.white,
|
||||
isLoading:
|
||||
subaddressCreationStore.state is SubaddressIsCreating),
|
||||
))
|
||||
]));
|
||||
subaddressCreationStore.state is SubaddressIsCreating,
|
||||
isDisabled: subaddressCreationStore.isDisabledStatus,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ abstract class AcountListStoreBase with Store {
|
||||
AcountListStoreBase({@required WalletService walletService}) {
|
||||
accounts = [];
|
||||
isAccountCreating = false;
|
||||
isDisabledStatus = true;
|
||||
|
||||
if (walletService.currentWallet != null) {
|
||||
_onWalletChanged(walletService.currentWallet);
|
||||
@@ -37,10 +38,18 @@ abstract class AcountListStoreBase with Store {
|
||||
@observable
|
||||
bool isAccountCreating;
|
||||
|
||||
@observable
|
||||
bool isDisabledStatus;
|
||||
|
||||
AccountList _accountList;
|
||||
StreamSubscription<Wallet> _onWalletChangeSubscription;
|
||||
StreamSubscription<List<Account>> _onAccountsChangeSubscription;
|
||||
|
||||
@action
|
||||
void setDisabledStatus(bool isDisabled) {
|
||||
isDisabledStatus = isDisabled;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_onWalletChangeSubscription.cancel();
|
||||
|
||||
@@ -17,6 +17,7 @@ class SubadrressCreationStore = SubadrressCreationStoreBase
|
||||
abstract class SubadrressCreationStoreBase with Store {
|
||||
SubadrressCreationStoreBase({@required WalletService walletService}) {
|
||||
state = SubaddressCreationStateInitial();
|
||||
isDisabledStatus = true;
|
||||
|
||||
if (walletService.currentWallet != null) {
|
||||
_onWalletChanged(walletService.currentWallet);
|
||||
@@ -26,6 +27,7 @@ abstract class SubadrressCreationStoreBase with Store {
|
||||
walletService.onWalletChange.listen(_onWalletChanged);
|
||||
}
|
||||
|
||||
@observable
|
||||
SubaddressCreationState state;
|
||||
|
||||
@observable
|
||||
@@ -34,11 +36,19 @@ abstract class SubadrressCreationStoreBase with Store {
|
||||
@observable
|
||||
String errorMessage;
|
||||
|
||||
@observable
|
||||
bool isDisabledStatus;
|
||||
|
||||
SubaddressList _subaddressList;
|
||||
StreamSubscription<Wallet> _onWalletChangeSubscription;
|
||||
StreamSubscription<Account> _onAccountChangeSubscription;
|
||||
Account _account;
|
||||
|
||||
@action
|
||||
void setDisabledStatus(bool isDisabled) {
|
||||
isDisabledStatus = isDisabled;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_onWalletChangeSubscription.cancel();
|
||||
@@ -61,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 {
|
||||
if (wallet is MoneroWallet) {
|
||||
_account = wallet.account;
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class BaseTextFormField extends StatelessWidget {
|
||||
BaseTextFormField({
|
||||
this.controller,
|
||||
this.keyboardType = TextInputType.text,
|
||||
this.textInputAction = TextInputAction.done,
|
||||
this.textAlign = TextAlign.start,
|
||||
this.autovalidate = false,
|
||||
this.hintText = '',
|
||||
this.maxLines = 1,
|
||||
this.inputFormatters,
|
||||
this.textColor = Colors.white,
|
||||
this.hintColor = PaletteDark.walletCardText,
|
||||
this.borderColor = PaletteDark.menuList,
|
||||
this.validator
|
||||
});
|
||||
|
||||
final TextEditingController controller;
|
||||
final TextInputType keyboardType;
|
||||
final TextInputAction textInputAction;
|
||||
final TextAlign textAlign;
|
||||
final bool autovalidate;
|
||||
final String hintText;
|
||||
final int maxLines;
|
||||
final List<TextInputFormatter> inputFormatters;
|
||||
final Color textColor;
|
||||
final Color hintColor;
|
||||
final Color borderColor;
|
||||
final FormFieldValidator<String> validator;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TextFormField(
|
||||
controller: controller,
|
||||
keyboardType: keyboardType,
|
||||
textInputAction: textInputAction,
|
||||
textAlign: textAlign,
|
||||
autovalidate: autovalidate,
|
||||
maxLines: maxLines,
|
||||
inputFormatters: inputFormatters,
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: textColor
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintStyle: TextStyle(
|
||||
color: hintColor,
|
||||
fontSize: 16
|
||||
),
|
||||
hintText: hintText,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: borderColor,
|
||||
width: 1.0
|
||||
)
|
||||
),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: borderColor,
|
||||
width: 1.0
|
||||
)
|
||||
)
|
||||
),
|
||||
validator: validator,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user