CWA-210 | added estimated fee row and clear button to the send page; removed validation from cryptocurrency textfield in the send template page; changed call send template page in the router; fix "clear" in polish

This commit is contained in:
Oleksandr Sobol 2020-05-11 11:22:03 +03:00
parent 25f3920073
commit 3f5ced13e1
6 changed files with 93 additions and 51 deletions

View file

@ -5049,7 +5049,7 @@ class $pl extends S {
@override
String get settings_change_language => "Zmień język";
@override
String get clear => "Jasny";
String get clear => "Wyczyść";
@override
String get settings_change_pin => "Zmień PIN";
@override

View file

@ -239,9 +239,12 @@ class Router {
case Routes.sendTemplate:
return CupertinoPageRoute<void>(
builder: (_) => SendTemplatePage(
sendStore: settings.arguments as SendStore,
)
builder: (_) => Provider(
create: (_) => SendStore(
walletService: walletService,
priceStore: priceStore,
transactionDescriptions: transactionDescriptions),
child: SendTemplatePage())
);
case Routes.receive:

View file

@ -40,6 +40,32 @@ class SendPage extends BasePage {
@override
bool get resizeToAvoidBottomPadding => false;
@override
Widget trailing(context) {
final sendStore = Provider.of<SendStore>(context);
return Container(
height: 32,
width: 82,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(16)),
color: PaletteDark.menuHeader
),
child: ButtonTheme(
minWidth: double.minPositive,
child: FlatButton(
onPressed: () => sendStore.clear(),
child: Text(
S.of(context).clear,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 10.0,
color: Colors.blue),
)),
),
);
}
@override
Widget body(BuildContext context) => SendForm();
}
@ -201,6 +227,7 @@ class SendFormState extends State<SendForm> {
onTap: () => sendStore.setSendAll(),
child: Center(
child: Text(S.of(context).all,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 9,
fontWeight: FontWeight.bold,
@ -270,6 +297,27 @@ class SendFormState extends State<SendForm> {
color: PaletteDark.walletCardSubAddressField,
width: 1.0)))),
),
Padding(
padding: const EdgeInsets.only(top: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(S.of(context).send_estimated_fee,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.white,
)),
Text(
'${calculateEstimatedFee(priority: settingsStore.transactionPriority)} XMR',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.w600,
color: Colors.white,
))
],
),
)
]),
),
),
@ -434,6 +482,20 @@ class SendFormState extends State<SendForm> {
}
});
reaction((_) => sendStore.address, (String address) {
if (address != _addressController.text) {
_addressController.text = address;
}
});
_addressController.addListener(() {
final address = _addressController.text;
if (sendStore.address != address) {
sendStore.changeAddress(address);
}
});
_fiatAmountController.addListener(() {
final fiatAmount = _fiatAmountController.text;

View file

@ -17,10 +17,6 @@ import 'package:cake_wallet/src/widgets/top_panel.dart';
import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
class SendTemplatePage extends BasePage {
SendTemplatePage({@required this.sendStore});
final SendStore sendStore;
@override
String get title => S.current.send_title;
@ -31,23 +27,15 @@ class SendTemplatePage extends BasePage {
bool get resizeToAvoidBottomPadding => false;
@override
Widget body(BuildContext context) => SendTemplateForm(sendStore);
Widget body(BuildContext context) => SendTemplateForm();
}
class SendTemplateForm extends StatefulWidget {
SendTemplateForm(this.sendStore);
final SendStore sendStore;
@override
SendTemplateFormState createState() => SendTemplateFormState(sendStore);
SendTemplateFormState createState() => SendTemplateFormState();
}
class SendTemplateFormState extends State<SendTemplateForm> {
SendTemplateFormState(this.sendStore);
final SendStore sendStore;
final _nameController = TextEditingController();
final _addressController = TextEditingController();
final _cryptoAmountController = TextEditingController();
@ -70,9 +58,11 @@ class SendTemplateFormState extends State<SendTemplateForm> {
Widget build(BuildContext context) {
final settingsStore = Provider.of<SettingsStore>(context);
final balanceStore = Provider.of<BalanceStore>(context);
final sendStore = Provider.of<SendStore>(context);
sendStore.settingsStore = settingsStore;
final sendTemplateStore = Provider.of<SendTemplateStore>(context);
_setEffects(context, sendStore);
_setEffects(context);
return Container(
color: PaletteDark.historyPanel,
@ -163,30 +153,6 @@ class SendTemplateFormState extends State<SendTemplateForm> {
color: Colors.white,
)),
),
suffixIcon: Padding(
padding: EdgeInsets.only(
bottom: 5
),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width/2,
alignment: Alignment.centerLeft,
child: Text(
' / ' + balanceStore.unlockedBalance,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 16,
color: PaletteDark.walletCardText
)
),
),
],
),
),
hintStyle: TextStyle(
fontSize: 16.0,
color: Colors.white),
@ -199,11 +165,7 @@ class SendTemplateFormState extends State<SendTemplateForm> {
borderSide: BorderSide(
color: PaletteDark.walletCardSubAddressField,
width: 1.0))),
validator: (value) {
sendStore.validateXMR(
value, balanceStore.unlockedBalance);
return sendStore.errorMessage;
}),
),
);
}
),
@ -271,12 +233,12 @@ class SendTemplateFormState extends State<SendTemplateForm> {
);
}
void _setEffects(BuildContext context, SendStore sendStore) {
void _setEffects(BuildContext context) {
if (_effectsInstalled) {
return;
}
//final sendStore = Provider.of<SendStore>(context);
final sendStore = Provider.of<SendStore>(context);
reaction((_) => sendStore.fiatAmount, (String amount) {
if (amount != _fiatAmountController.text) {

View file

@ -45,6 +45,9 @@ abstract class SendStoreBase with Store {
@observable
String cryptoAmount;
@observable
String address;
@observable
bool isValid;
@ -157,6 +160,18 @@ abstract class SendStoreBase with Store {
}
}
@action
void changeAddress(String address) {
this.address = address;
}
@action
void clear() {
address = '';
cryptoAmount = '';
fiatAmount = '';
}
Future<bool> isOpenaliasRecord(String name) async {
final _openaliasRecord = await OpenaliasRecord
.fetchAddressAndName(OpenaliasRecord.formatDomainName(name));

View file

@ -58,7 +58,7 @@
"exchange" : "Wymieniać się",
"clear" : "Jasny",
"clear" : "Wyczyść",
"change_exchange_provider" : "Zmień dostawcę programu Exchange",
"you_will_send" : "Wyślesz",
"you_will_get" : "Dostaniesz",