CAKE-28 | added available balance row and applied transactions priority picker to base send widget
Oleksandr Sobol committed
Aug 31, 2020 at 20:53 UTC
d6a7f1fb616d2837189f7a9c8467e0600e2a3a79
2 files changed
+115
-80
lib/src/screens/send/widgets/base_send_widget.dart
+110
-80
@@ -1,3 +1,5 @@
1
+import 'package:cake_wallet/src/domain/common/transaction_priority.dart';
2
+import 'package:cake_wallet/src/widgets/picker.dart';
3
import 'package:cake_wallet/src/widgets/primary_button.dart';
4
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
5
import 'package:flutter/cupertino.dart';
@@ -152,48 +154,26 @@ class BaseSendWidget extends StatelessWidget {
154
),
155
suffixIcon: isTemplate
156
? Offstage()
155
- : Padding(
156
- padding: EdgeInsets.only(bottom: 2),
157
- child: Row(
158
- mainAxisSize: MainAxisSize.min,
159
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
160
- children: <Widget>[
161
- Container(
162
- width: MediaQuery.of(context).size.width/2,
163
- alignment: Alignment.centerLeft,
164
- child: Text(
165
- ' / ' + sendViewModel.balance,
166
- maxLines: 1,
167
- overflow: TextOverflow.ellipsis,
168
- style: TextStyle(
169
- fontSize: 14,
170
- color: Theme.of(context).primaryTextTheme.headline.decorationColor
171
- )
172
- ),
157
+ : Container(
158
+ height: 32,
159
+ width: 32,
160
+ margin: EdgeInsets.only(left: 14, top: 4, bottom: 10),
161
+ decoration: BoxDecoration(
162
+ color: Theme.of(context).primaryTextTheme.display1.color,
163
+ borderRadius: BorderRadius.all(Radius.circular(6))
164
+ ),
165
+ child: InkWell(
166
+ onTap: () => sendViewModel.setSendAll(),
167
+ child: Center(
168
+ child: Text(S.of(context).all,
169
+ textAlign: TextAlign.center,
170
+ style: TextStyle(
171
+ fontSize: 12,
172
+ fontWeight: FontWeight.bold,
173
+ color: Theme.of(context).primaryTextTheme.display1.decorationColor
174
+ )
175
),
174
- Container(
175
- height: 34,
176
- width: 34,
177
- margin: EdgeInsets.only(left: 12, bottom: 8),
178
- decoration: BoxDecoration(
179
- color: Theme.of(context).primaryTextTheme.display1.color,
180
- borderRadius: BorderRadius.all(Radius.circular(6))
181
- ),
182
- child: InkWell(
183
- onTap: () => sendViewModel.setSendAll(),
184
- child: Center(
185
- child: Text(S.of(context).all,
186
- textAlign: TextAlign.center,
187
- style: TextStyle(
188
- fontSize: 12,
189
- fontWeight: FontWeight.bold,
190
- color: Theme.of(context).primaryTextTheme.display1.decorationColor
191
- )
192
- ),
193
- ),
194
- ),
195
- )
196
- ],
176
+ ),
177
),
178
),
179
hintText: '0.0000',
@@ -212,6 +192,37 @@ class BaseSendWidget extends StatelessWidget {
192
);
193
}
194
),
195
+ isTemplate
196
+ ? Offstage()
197
+ : Observer(
198
+ builder: (_) => Padding(
199
+ padding: EdgeInsets.only(top: 10),
200
+ child: Row(
201
+ mainAxisSize: MainAxisSize.max,
202
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
203
+ children: <Widget>[
204
+ Expanded(
205
+ child: Text(
206
+ S.of(context).available_balance + ':',
207
+ style: TextStyle(
208
+ fontSize: 12,
209
+ fontWeight: FontWeight.w600,
210
+ color: Theme.of(context).primaryTextTheme.headline.decorationColor
211
+ ),
212
+ )
213
+ ),
214
+ Text(
215
+ sendViewModel.balance,
216
+ style: TextStyle(
217
+ fontSize: 12,
218
+ fontWeight: FontWeight.w600,
219
+ color: Theme.of(context).primaryTextTheme.headline.decorationColor
220
+ ),
221
+ )
222
+ ],
223
+ ),
224
+ )
225
+ ),
226
Padding(
227
padding: const EdgeInsets.only(top: 20),
228
child: BaseTextFormField(
@@ -247,45 +258,47 @@ class BaseSendWidget extends StatelessWidget {
258
),
259
isTemplate
260
? Offstage()
250
- : GestureDetector(
251
- onTap: () {},
252
- child: Container(
253
- padding: EdgeInsets.only(top: 24),
254
- child: Row(
255
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
256
- children: <Widget>[
257
- Text(S.of(context).send_estimated_fee,
258
- style: TextStyle(
259
- fontSize: 12,
260
- fontWeight: FontWeight.w500,
261
- //color: Theme.of(context).primaryTextTheme.display2.color,
262
- color: Colors.white
263
- )),
264
- Container(
265
- child: Row(
266
- children: <Widget>[
267
- Text(
268
- sendViewModel.estimatedFee.toString() + ' '
269
- + sendViewModel.currency.title,
270
- style: TextStyle(
271
- fontSize: 12,
272
- fontWeight: FontWeight.w600,
273
- //color: Theme.of(context).primaryTextTheme.display2.color,
274
- color: Colors.white
275
- )),
276
- Padding(
277
- padding: EdgeInsets.only(left: 5),
278
- child: Icon(
279
- Icons.arrow_forward_ios,
280
- size: 12,
281
- color: Colors.white,),
282
- )
283
- ],
284
- ),
285
- )
286
- ],
287
- ),
288
- ),
261
+ : Observer(
262
+ builder: (_) => GestureDetector(
263
+ onTap: () => _setTransactionPriority(context),
264
+ child: Container(
265
+ padding: EdgeInsets.only(top: 24),
266
+ child: Row(
267
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
268
+ children: <Widget>[
269
+ Text(S.of(context).send_estimated_fee,
270
+ style: TextStyle(
271
+ fontSize: 12,
272
+ fontWeight: FontWeight.w500,
273
+ //color: Theme.of(context).primaryTextTheme.display2.color,
274
+ color: Colors.white
275
+ )),
276
+ Container(
277
+ child: Row(
278
+ children: <Widget>[
279
+ Text(
280
+ sendViewModel.estimatedFee.toString() + ' '
281
+ + sendViewModel.currency.title,
282
+ style: TextStyle(
283
+ fontSize: 12,
284
+ fontWeight: FontWeight.w600,
285
+ //color: Theme.of(context).primaryTextTheme.display2.color,
286
+ color: Colors.white
287
+ )),
288
+ Padding(
289
+ padding: EdgeInsets.only(left: 5),
290
+ child: Icon(
291
+ Icons.arrow_forward_ios,
292
+ size: 12,
293
+ color: Colors.white,),
294
+ )
295
+ ],
296
+ ),
297
+ )
298
+ ],
299
+ ),
300
+ ),
301
+ )
302
)
303
],
304
),
@@ -575,4 +588,21 @@ class BaseSendWidget extends StatelessWidget {
588
});
589
}
590
}
591
+
592
+ Future<void> _setTransactionPriority(BuildContext context) async {
593
+ final items = TransactionPriority.all;
594
+ final selectedItem = items.indexOf(sendViewModel.transactionPriority);
595
+
596
+ await showDialog<void>(
597
+ builder: (_) => Picker(
598
+ items: items,
599
+ selectedAtIndex: selectedItem,
600
+ title: S.of(context).please_select,
601
+ mainAxisAlignment: MainAxisAlignment.center,
602
+ onItemSelected: (TransactionPriority priority) =>
603
+ sendViewModel.setTransactionPriority(priority),
604
+ isAlwaysShowScrollThumb: true,
605
+ ),
606
+ context: context);
607
+ }
608
}
\ No newline at end of file
lib/view_model/send_view_model.dart
+5
@@ -193,6 +193,11 @@ abstract class SendViewModelBase with Store {
193
fiatAmount = '';
194
}
195
196
+ @action
197
+ void setTransactionPriority(TransactionPriority transactionPriority) {
198
+ _settingsStore.transactionPriority = transactionPriority;
199
+ }
200
+
201
final WalletBase _wallet;
202
203
final SettingsStore _settingsStore;