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
Oleksandr Sobol committed
May 11, 2020 at 11:22 UTC
3f5ced13e17ec71f471ac904342f12e675dca453
6 files changed
+93
-51
lib/generated/i18n.dart
+1
-1
@@ -5049,7 +5049,7 @@ class $pl extends S {
5049
@override
5050
String get settings_change_language => "Zmień język";
5051
@override
5052
- String get clear => "Jasny";
5052
+ String get clear => "Wyczyść";
5053
@override
5054
String get settings_change_pin => "Zmień PIN";
5055
@override
lib/router.dart
+6
-3
@@ -239,9 +239,12 @@ class Router {
239
240
case Routes.sendTemplate:
241
return CupertinoPageRoute<void>(
242
- builder: (_) => SendTemplatePage(
243
- sendStore: settings.arguments as SendStore,
244
- )
242
+ builder: (_) => Provider(
243
+ create: (_) => SendStore(
244
+ walletService: walletService,
245
+ priceStore: priceStore,
246
+ transactionDescriptions: transactionDescriptions),
247
+ child: SendTemplatePage())
248
);
249
250
case Routes.receive:
lib/src/screens/send/send_page.dart
+62
@@ -40,6 +40,32 @@ class SendPage extends BasePage {
40
@override
41
bool get resizeToAvoidBottomPadding => false;
42
43
+ @override
44
+ Widget trailing(context) {
45
+ final sendStore = Provider.of<SendStore>(context);
46
+
47
+ return Container(
48
+ height: 32,
49
+ width: 82,
50
+ decoration: BoxDecoration(
51
+ borderRadius: BorderRadius.all(Radius.circular(16)),
52
+ color: PaletteDark.menuHeader
53
+ ),
54
+ child: ButtonTheme(
55
+ minWidth: double.minPositive,
56
+ child: FlatButton(
57
+ onPressed: () => sendStore.clear(),
58
+ child: Text(
59
+ S.of(context).clear,
60
+ textAlign: TextAlign.center,
61
+ style: TextStyle(
62
+ fontSize: 10.0,
63
+ color: Colors.blue),
64
+ )),
65
+ ),
66
+ );
67
+ }
68
+
69
@override
70
Widget body(BuildContext context) => SendForm();
71
}
@@ -201,6 +227,7 @@ class SendFormState extends State<SendForm> {
227
onTap: () => sendStore.setSendAll(),
228
child: Center(
229
child: Text(S.of(context).all,
230
+ textAlign: TextAlign.center,
231
style: TextStyle(
232
fontSize: 9,
233
fontWeight: FontWeight.bold,
@@ -270,6 +297,27 @@ class SendFormState extends State<SendForm> {
297
color: PaletteDark.walletCardSubAddressField,
298
width: 1.0)))),
299
),
300
+ Padding(
301
+ padding: const EdgeInsets.only(top: 20),
302
+ child: Row(
303
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
304
+ children: <Widget>[
305
+ Text(S.of(context).send_estimated_fee,
306
+ style: TextStyle(
307
+ fontSize: 12,
308
+ fontWeight: FontWeight.w600,
309
+ color: Colors.white,
310
+ )),
311
+ Text(
312
+ '${calculateEstimatedFee(priority: settingsStore.transactionPriority)} XMR',
313
+ style: TextStyle(
314
+ fontSize: 12,
315
+ fontWeight: FontWeight.w600,
316
+ color: Colors.white,
317
+ ))
318
+ ],
319
+ ),
320
+ )
321
]),
322
),
323
),
@@ -434,6 +482,20 @@ class SendFormState extends State<SendForm> {
482
}
483
});
484
485
+ reaction((_) => sendStore.address, (String address) {
486
+ if (address != _addressController.text) {
487
+ _addressController.text = address;
488
+ }
489
+ });
490
+
491
+ _addressController.addListener(() {
492
+ final address = _addressController.text;
493
+
494
+ if (sendStore.address != address) {
495
+ sendStore.changeAddress(address);
496
+ }
497
+ });
498
+
499
_fiatAmountController.addListener(() {
500
final fiatAmount = _fiatAmountController.text;
501
lib/src/screens/send/send_template_page.dart
+8
-46
@@ -17,10 +17,6 @@ import 'package:cake_wallet/src/widgets/top_panel.dart';
17
import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
18
19
class SendTemplatePage extends BasePage {
20
- SendTemplatePage({@required this.sendStore});
21
-
22
- final SendStore sendStore;
23
-
20
@override
21
String get title => S.current.send_title;
22
@@ -31,23 +27,15 @@ class SendTemplatePage extends BasePage {
27
bool get resizeToAvoidBottomPadding => false;
28
29
@override
34
- Widget body(BuildContext context) => SendTemplateForm(sendStore);
30
+ Widget body(BuildContext context) => SendTemplateForm();
31
}
32
33
class SendTemplateForm extends StatefulWidget {
38
- SendTemplateForm(this.sendStore);
39
-
40
- final SendStore sendStore;
41
-
34
@override
43
- SendTemplateFormState createState() => SendTemplateFormState(sendStore);
35
+ SendTemplateFormState createState() => SendTemplateFormState();
36
}
37
38
class SendTemplateFormState extends State<SendTemplateForm> {
47
- SendTemplateFormState(this.sendStore);
48
-
49
- final SendStore sendStore;
50
-
39
final _nameController = TextEditingController();
40
final _addressController = TextEditingController();
41
final _cryptoAmountController = TextEditingController();
@@ -70,9 +58,11 @@ class SendTemplateFormState extends State<SendTemplateForm> {
58
Widget build(BuildContext context) {
59
final settingsStore = Provider.of<SettingsStore>(context);
60
final balanceStore = Provider.of<BalanceStore>(context);
61
+ final sendStore = Provider.of<SendStore>(context);
62
+ sendStore.settingsStore = settingsStore;
63
final sendTemplateStore = Provider.of<SendTemplateStore>(context);
64
75
- _setEffects(context, sendStore);
65
+ _setEffects(context);
66
67
return Container(
68
color: PaletteDark.historyPanel,
@@ -163,30 +153,6 @@ class SendTemplateFormState extends State<SendTemplateForm> {
153
color: Colors.white,
154
)),
155
),
166
- suffixIcon: Padding(
167
- padding: EdgeInsets.only(
168
- bottom: 5
169
- ),
170
- child: Row(
171
- mainAxisSize: MainAxisSize.min,
172
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
173
- children: <Widget>[
174
- Container(
175
- width: MediaQuery.of(context).size.width/2,
176
- alignment: Alignment.centerLeft,
177
- child: Text(
178
- ' / ' + balanceStore.unlockedBalance,
179
- maxLines: 1,
180
- overflow: TextOverflow.ellipsis,
181
- style: TextStyle(
182
- fontSize: 16,
183
- color: PaletteDark.walletCardText
184
- )
185
- ),
186
- ),
187
- ],
188
- ),
189
- ),
156
hintStyle: TextStyle(
157
fontSize: 16.0,
158
color: Colors.white),
@@ -199,11 +165,7 @@ class SendTemplateFormState extends State<SendTemplateForm> {
165
borderSide: BorderSide(
166
color: PaletteDark.walletCardSubAddressField,
167
width: 1.0))),
202
- validator: (value) {
203
- sendStore.validateXMR(
204
- value, balanceStore.unlockedBalance);
205
- return sendStore.errorMessage;
206
- }),
168
+ ),
169
);
170
}
171
),
@@ -271,12 +233,12 @@ class SendTemplateFormState extends State<SendTemplateForm> {
233
);
234
}
235
274
- void _setEffects(BuildContext context, SendStore sendStore) {
236
+ void _setEffects(BuildContext context) {
237
if (_effectsInstalled) {
238
return;
239
}
240
279
- //final sendStore = Provider.of<SendStore>(context);
241
+ final sendStore = Provider.of<SendStore>(context);
242
243
reaction((_) => sendStore.fiatAmount, (String amount) {
244
if (amount != _fiatAmountController.text) {
lib/src/stores/send/send_store.dart
+15
@@ -45,6 +45,9 @@ abstract class SendStoreBase with Store {
45
@observable
46
String cryptoAmount;
47
48
+ @observable
49
+ String address;
50
+
51
@observable
52
bool isValid;
53
@@ -157,6 +160,18 @@ abstract class SendStoreBase with Store {
160
}
161
}
162
163
+ @action
164
+ void changeAddress(String address) {
165
+ this.address = address;
166
+ }
167
+
168
+ @action
169
+ void clear() {
170
+ address = '';
171
+ cryptoAmount = '';
172
+ fiatAmount = '';
173
+ }
174
+
175
Future<bool> isOpenaliasRecord(String name) async {
176
final _openaliasRecord = await OpenaliasRecord
177
.fetchAddressAndName(OpenaliasRecord.formatDomainName(name));
res/values/strings_pl.arb
+1
-1
@@ -58,7 +58,7 @@
58
59
60
"exchange" : "Wymieniać się",
61
- "clear" : "Jasny",
61
+ "clear" : "Wyczyść",
62
"change_exchange_provider" : "Zmień dostawcę programu Exchange",
63
"you_will_send" : "Wyślesz",
64
"you_will_get" : "Dostaniesz",