2021-09-26 22:31:55 -07:00
|
|
|
import 'dart:ui';
|
2021-08-05 06:43:05 -07:00
|
|
|
|
2021-06-26 07:30:12 -07:00
|
|
|
import 'package:flutter/material.dart';
|
2022-04-15 23:51:13 -07:00
|
|
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
2021-08-06 00:53:54 -07:00
|
|
|
import 'package:mobx/mobx.dart';
|
2021-06-26 07:30:12 -07:00
|
|
|
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
2022-03-16 21:03:37 -07:00
|
|
|
import 'accounts.dart';
|
2022-03-07 06:53:18 -08:00
|
|
|
import 'dualmoneyinput.dart';
|
2021-11-11 17:44:46 -08:00
|
|
|
import 'package:warp_api/types.dart';
|
2021-06-26 07:30:12 -07:00
|
|
|
import 'package:warp_api/warp_api.dart';
|
2021-07-07 08:40:05 -07:00
|
|
|
import 'package:decimal/decimal.dart';
|
2021-09-12 04:24:40 -07:00
|
|
|
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
2021-07-07 08:40:05 -07:00
|
|
|
import 'dart:math' as math;
|
2021-06-26 07:30:12 -07:00
|
|
|
|
|
|
|
import 'main.dart';
|
2021-07-07 08:40:05 -07:00
|
|
|
import 'store.dart';
|
2021-08-15 09:18:09 -07:00
|
|
|
import 'generated/l10n.dart';
|
2021-06-26 07:30:12 -07:00
|
|
|
|
|
|
|
class SendPage extends StatefulWidget {
|
2021-10-03 08:47:44 -07:00
|
|
|
final SendPageArgs? args;
|
2021-08-06 00:53:54 -07:00
|
|
|
|
2021-10-03 08:47:44 -07:00
|
|
|
SendPage(this.args);
|
2021-06-26 07:30:12 -07:00
|
|
|
|
|
|
|
@override
|
|
|
|
SendState createState() => SendState();
|
2021-11-11 17:44:46 -08:00
|
|
|
|
|
|
|
bool get isMulti => args?.isMulti ?? false;
|
2021-06-26 07:30:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class SendState extends State<SendPage> {
|
2021-09-21 05:52:52 -07:00
|
|
|
static final zero = decimalFormat(0, 3);
|
2021-06-26 07:30:12 -07:00
|
|
|
final _formKey = GlobalKey<FormState>();
|
2021-10-09 07:17:27 -07:00
|
|
|
final _amountKey = GlobalKey<DualMoneyInputState>();
|
2022-08-29 20:42:08 -07:00
|
|
|
var _initialAmount = 0;
|
2021-06-26 07:30:12 -07:00
|
|
|
var _address = "";
|
2021-09-27 01:57:55 -07:00
|
|
|
var _sBalance = 0;
|
|
|
|
var _tBalance = 0;
|
2021-09-26 22:31:55 -07:00
|
|
|
var _excludedBalance = 0;
|
|
|
|
var _underConfirmedBalance = 0;
|
2021-10-04 02:20:42 -07:00
|
|
|
var _unconfirmedSpentBalance = 0;
|
|
|
|
var _unconfirmedBalance = 0;
|
2021-06-26 07:30:12 -07:00
|
|
|
final _addressController = TextEditingController();
|
2021-07-09 22:44:34 -07:00
|
|
|
final _memoController = TextEditingController();
|
2022-04-15 23:51:13 -07:00
|
|
|
final _subjectController = TextEditingController();
|
2022-03-07 18:47:41 -08:00
|
|
|
var _memoInitialized = false;
|
2021-09-26 22:31:55 -07:00
|
|
|
ReactionDisposer? _newBlockAutorunDispose;
|
2021-11-11 17:44:46 -08:00
|
|
|
final _fee = DEFAULT_FEE;
|
|
|
|
var _usedBalance = 0;
|
2022-04-15 23:51:13 -07:00
|
|
|
var _replyTo = settings.includeReplyTo;
|
2021-06-26 07:30:12 -07:00
|
|
|
|
|
|
|
@override
|
|
|
|
initState() {
|
2022-08-29 20:42:08 -07:00
|
|
|
super.initState();
|
|
|
|
|
|
|
|
final draftRecipient = active.draftRecipient;
|
|
|
|
if (draftRecipient != null) {
|
|
|
|
_addressController.text = draftRecipient.address;
|
|
|
|
_initialAmount = draftRecipient.amount;
|
|
|
|
_memoController.text = draftRecipient.memo;
|
|
|
|
_replyTo = draftRecipient.reply_to;
|
|
|
|
_subjectController.text = draftRecipient.subject;
|
|
|
|
_memoInitialized = true;
|
|
|
|
active.setDraftRecipient(null);
|
|
|
|
}
|
|
|
|
|
2021-10-03 08:47:44 -07:00
|
|
|
if (widget.args?.contact != null)
|
|
|
|
_addressController.text = widget.args!.contact!.address;
|
2022-04-15 23:51:13 -07:00
|
|
|
if (widget.args?.address != null)
|
|
|
|
_addressController.text = widget.args!.address!;
|
|
|
|
if (widget.args?.subject != null)
|
|
|
|
_subjectController.text = widget.args!.subject!;
|
2021-11-11 17:44:46 -08:00
|
|
|
final recipients = widget.args?.recipients ?? [];
|
|
|
|
_usedBalance = recipients.fold(0, (acc, r) => acc + r.amount);
|
2021-10-03 08:47:44 -07:00
|
|
|
|
2021-10-09 19:11:40 -07:00
|
|
|
final uri = widget.args?.uri;
|
|
|
|
if (uri != null)
|
|
|
|
Future.microtask(() {
|
|
|
|
_setPaymentURI(uri);
|
|
|
|
});
|
2021-09-26 22:31:55 -07:00
|
|
|
|
|
|
|
_newBlockAutorunDispose = autorun((_) async {
|
2022-03-07 06:53:18 -08:00
|
|
|
final _ = active.dataEpoch;
|
2022-10-12 18:25:29 -07:00
|
|
|
final balances = active.balances;
|
|
|
|
final sBalance = balances.shieldedBalance;
|
2022-03-07 06:53:18 -08:00
|
|
|
final tBalance = active.tbalance;
|
2022-10-12 18:25:29 -07:00
|
|
|
final excludedBalance = balances.excludedBalance;
|
|
|
|
final underConfirmedBalance = balances.underConfirmedBalance;
|
2022-11-17 17:03:43 -08:00
|
|
|
int? unconfirmedBalance = unconfirmedBalanceStream.value;
|
2021-09-26 22:31:55 -07:00
|
|
|
setState(() {
|
2021-09-27 01:57:55 -07:00
|
|
|
_sBalance = sBalance;
|
|
|
|
_tBalance = tBalance;
|
2021-09-26 22:31:55 -07:00
|
|
|
_excludedBalance = excludedBalance;
|
|
|
|
_underConfirmedBalance = underConfirmedBalance;
|
2022-11-17 17:03:43 -08:00
|
|
|
_unconfirmedBalance = unconfirmedBalance ?? 0;
|
2021-09-26 22:31:55 -07:00
|
|
|
});
|
|
|
|
});
|
2021-06-26 07:30:12 -07:00
|
|
|
}
|
|
|
|
|
2021-08-06 19:18:20 -07:00
|
|
|
@override
|
|
|
|
void dispose() {
|
2021-09-26 22:31:55 -07:00
|
|
|
_newBlockAutorunDispose?.call();
|
2021-08-06 19:18:20 -07:00
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2021-06-26 07:30:12 -07:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-09-26 11:44:19 -07:00
|
|
|
final s = S.of(context);
|
2022-02-22 21:20:45 -08:00
|
|
|
final simpleMode = settings.simpleMode;
|
2022-03-07 18:47:41 -08:00
|
|
|
if (!_memoInitialized) {
|
|
|
|
_memoController.text = settings.memoSignature ?? s.sendFrom(APP_NAME);
|
|
|
|
_memoInitialized = true;
|
|
|
|
}
|
2022-02-23 19:36:02 -08:00
|
|
|
|
2021-06-26 07:30:12 -07:00
|
|
|
return Scaffold(
|
2022-03-07 06:53:18 -08:00
|
|
|
appBar: AppBar(title: Text(s.sendCointicker(active.coinDef.ticker))),
|
2021-09-26 11:44:19 -07:00
|
|
|
body: GestureDetector(
|
|
|
|
onTap: () {
|
|
|
|
FocusScope.of(context).unfocus();
|
|
|
|
},
|
|
|
|
child: Form(
|
|
|
|
key: _formKey,
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
padding: EdgeInsets.all(20),
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
Row(children: <Widget>[
|
|
|
|
Expanded(
|
2021-09-27 01:57:55 -07:00
|
|
|
child: TypeAheadFormField(
|
|
|
|
textFieldConfiguration: TextFieldConfiguration(
|
|
|
|
controller: _addressController,
|
|
|
|
decoration: InputDecoration(
|
2022-03-07 06:53:18 -08:00
|
|
|
labelText: s.sendCointickerTo(active.coinDef.ticker)),
|
2021-09-27 01:57:55 -07:00
|
|
|
minLines: 4,
|
|
|
|
maxLines: 10,
|
|
|
|
keyboardType: TextInputType.multiline,
|
2021-09-26 11:44:19 -07:00
|
|
|
),
|
2021-09-27 01:57:55 -07:00
|
|
|
onSaved: _onAddress,
|
|
|
|
validator: _checkAddress,
|
2022-03-16 21:03:37 -07:00
|
|
|
onSuggestionSelected: (Suggestion suggestion) {
|
|
|
|
_addressController.text = suggestion.name;
|
2021-09-27 01:57:55 -07:00
|
|
|
},
|
|
|
|
suggestionsCallback: (String pattern) {
|
2022-03-16 21:03:37 -07:00
|
|
|
final matchingContacts = contacts.contacts.where((c) => c.name
|
2021-09-27 01:57:55 -07:00
|
|
|
.toLowerCase()
|
2022-03-16 21:03:37 -07:00
|
|
|
.contains(pattern.toLowerCase())).map((c) => ContactSuggestion(c));
|
|
|
|
final matchingAccounts = accounts.list
|
|
|
|
.where((a) => a.coin == active.coin && a.name
|
|
|
|
.toLowerCase()
|
|
|
|
.contains(pattern.toLowerCase())).map((a) => AccountSuggestion(a));
|
|
|
|
return [...matchingContacts, ...matchingAccounts];
|
2021-09-27 01:57:55 -07:00
|
|
|
},
|
2022-03-16 21:03:37 -07:00
|
|
|
itemBuilder: (BuildContext context, Suggestion suggestion) =>
|
|
|
|
ListTile(title: Text(suggestion.name)),
|
2021-09-27 01:57:55 -07:00
|
|
|
noItemsFoundBuilder: (_) => SizedBox(),
|
|
|
|
)),
|
2021-09-26 11:44:19 -07:00
|
|
|
IconButton(
|
|
|
|
icon: new Icon(MdiIcons.qrcodeScan),
|
|
|
|
onPressed: _onScan)
|
|
|
|
]),
|
2021-11-11 17:44:46 -08:00
|
|
|
DualMoneyInputWidget(
|
|
|
|
key: _amountKey,
|
2022-12-07 08:21:01 -08:00
|
|
|
max: true,
|
2022-08-29 20:42:08 -07:00
|
|
|
initialValue: _initialAmount,
|
2021-11-11 17:44:46 -08:00
|
|
|
spendable: spendable),
|
2022-11-12 19:43:09 -08:00
|
|
|
if (!simpleMode) BalanceTable(_sBalance, _tBalance,
|
2021-11-11 17:44:46 -08:00
|
|
|
_excludedBalance, _underConfirmedBalance, change, _usedBalance, _fee),
|
2022-04-15 23:51:13 -07:00
|
|
|
Container(child: InputDecorator(
|
|
|
|
decoration: InputDecoration(labelText: s.memo),
|
|
|
|
child: Column(children: [
|
|
|
|
FormBuilderCheckbox(
|
|
|
|
name: 'reply-to',
|
|
|
|
title: Text(s.includeReplyTo),
|
|
|
|
initialValue: _replyTo,
|
2022-12-10 14:10:07 -08:00
|
|
|
onChanged: (v) {
|
2022-04-15 23:51:13 -07:00
|
|
|
setState(() {
|
2022-12-10 14:10:07 -08:00
|
|
|
_replyTo = v ?? false;
|
2022-04-15 23:51:13 -07:00
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
TextFormField(
|
|
|
|
decoration:
|
|
|
|
InputDecoration(labelText: s.subject),
|
|
|
|
controller: _subjectController,
|
|
|
|
),
|
|
|
|
TextFormField(
|
|
|
|
decoration:
|
|
|
|
InputDecoration(labelText: s.body),
|
|
|
|
minLines: 4,
|
|
|
|
maxLines: null,
|
|
|
|
keyboardType: TextInputType.multiline,
|
|
|
|
controller: _memoController,
|
|
|
|
)]))),
|
2021-09-26 11:44:19 -07:00
|
|
|
Padding(padding: EdgeInsets.all(8)),
|
|
|
|
ButtonBar(
|
|
|
|
children: confirmButtons(context, _onSend,
|
2021-11-11 17:44:46 -08:00
|
|
|
okLabel: widget.isMulti ? s.add : s.send,
|
|
|
|
okIcon: Icon(MdiIcons.send)))
|
2021-09-26 11:44:19 -07:00
|
|
|
])))));
|
2021-06-26 07:30:12 -07:00
|
|
|
}
|
|
|
|
|
2022-03-16 21:03:37 -07:00
|
|
|
Suggestion? getSuggestion(String v) {
|
|
|
|
final c = contacts.contacts.where((c) => c.name == v);
|
|
|
|
if (c.isNotEmpty) return ContactSuggestion(c.first);
|
|
|
|
final a = accounts.list.where((a) => a.name == v);
|
|
|
|
if (a.isNotEmpty) return AccountSuggestion(a.first);
|
2022-12-05 09:45:35 -08:00
|
|
|
return null;
|
2022-03-16 21:03:37 -07:00
|
|
|
}
|
|
|
|
|
2021-09-10 02:56:15 -07:00
|
|
|
String? _checkAddress(String? v) {
|
2021-09-26 11:44:19 -07:00
|
|
|
final s = S.of(context);
|
|
|
|
if (v == null || v.isEmpty) return s.addressIsEmpty;
|
2022-03-16 21:03:37 -07:00
|
|
|
final suggestion = getSuggestion(v);
|
|
|
|
if (suggestion != null) return null;
|
2022-03-07 06:53:18 -08:00
|
|
|
if (!WarpApi.validAddress(active.coin, v)) return s.invalidAddress;
|
2021-06-26 07:30:12 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-07 08:40:05 -07:00
|
|
|
void _onScan() async {
|
2021-09-10 02:56:15 -07:00
|
|
|
final code = await scanCode(context);
|
2021-09-25 02:09:41 -07:00
|
|
|
if (code != null) {
|
2022-08-31 08:36:41 -07:00
|
|
|
_setPaymentURI(code);
|
2021-09-25 02:09:41 -07:00
|
|
|
}
|
2021-06-26 07:30:12 -07:00
|
|
|
}
|
2021-10-03 08:47:44 -07:00
|
|
|
|
2022-08-31 08:36:41 -07:00
|
|
|
void _setPaymentURI(String uriOrAddress) {
|
2021-10-03 08:47:44 -07:00
|
|
|
try {
|
2022-08-31 08:36:41 -07:00
|
|
|
final paymentURI = decodeAddress(context, uriOrAddress);
|
2021-10-03 08:47:44 -07:00
|
|
|
setState(() {
|
2022-08-31 08:36:41 -07:00
|
|
|
_address = paymentURI.address;
|
2021-10-03 08:47:44 -07:00
|
|
|
_addressController.text = _address;
|
2022-08-31 08:36:41 -07:00
|
|
|
if (paymentURI.memo.isNotEmpty)
|
|
|
|
_memoController.text = paymentURI.memo;
|
|
|
|
if (paymentURI.amount != 0)
|
|
|
|
amountInput?.setAmount(paymentURI.amount);
|
2021-10-03 08:47:44 -07:00
|
|
|
});
|
2022-08-31 08:36:41 -07:00
|
|
|
}
|
2022-10-07 07:17:18 -07:00
|
|
|
on String catch (e) {
|
|
|
|
showSnackBar(S.of(context).invalidQrCode(e));
|
2022-08-31 08:36:41 -07:00
|
|
|
}
|
2021-10-03 08:47:44 -07:00
|
|
|
}
|
2021-06-26 07:30:12 -07:00
|
|
|
|
2021-07-07 08:40:05 -07:00
|
|
|
void _onAddress(v) {
|
2022-03-16 21:03:37 -07:00
|
|
|
final suggestion = getSuggestion(v);
|
|
|
|
if (suggestion == null)
|
2021-09-12 04:24:40 -07:00
|
|
|
_address = v;
|
|
|
|
else {
|
2022-03-16 21:03:37 -07:00
|
|
|
_address = suggestion.address;
|
2021-09-12 04:24:40 -07:00
|
|
|
}
|
2021-06-26 07:30:12 -07:00
|
|
|
}
|
|
|
|
|
2021-07-07 08:40:05 -07:00
|
|
|
void _onSend() async {
|
2021-06-26 07:30:12 -07:00
|
|
|
final form = _formKey.currentState;
|
|
|
|
if (form == null) return;
|
|
|
|
|
|
|
|
if (form.validate()) {
|
|
|
|
form.save();
|
2021-10-19 18:22:37 -07:00
|
|
|
final amount = amountInput?.amount ?? 0;
|
2022-12-10 14:10:07 -08:00
|
|
|
final feeIncluded = amountInput?.feeIncluded ?? false;
|
2022-11-12 19:43:09 -08:00
|
|
|
final memo = _memoController.text;
|
|
|
|
final subject = _subjectController.text;
|
|
|
|
final recipient = Recipient(
|
|
|
|
_address,
|
|
|
|
amount,
|
2022-12-10 14:10:07 -08:00
|
|
|
feeIncluded,
|
2022-11-12 19:43:09 -08:00
|
|
|
_replyTo,
|
|
|
|
subject,
|
|
|
|
memo,
|
2022-12-05 09:45:35 -08:00
|
|
|
0,
|
2022-11-12 19:43:09 -08:00
|
|
|
);
|
|
|
|
active.setDraftRecipient(recipient);
|
|
|
|
|
|
|
|
if (!widget.isMulti)
|
|
|
|
// send closes the page
|
|
|
|
await send(context, [recipient]);
|
|
|
|
else
|
|
|
|
Navigator.of(context).pop(recipient);
|
2021-06-26 07:30:12 -07:00
|
|
|
}
|
|
|
|
}
|
2021-07-07 08:40:05 -07:00
|
|
|
|
2022-04-08 04:34:24 -07:00
|
|
|
int amountInZAT(Decimal v) => (v * ZECUNIT_DECIMAL).toBigInt().toInt();
|
2021-09-26 11:44:19 -07:00
|
|
|
|
|
|
|
String amountFromZAT(int v) =>
|
|
|
|
(Decimal.fromInt(v) / ZECUNIT_DECIMAL).toString();
|
2021-08-06 00:53:54 -07:00
|
|
|
|
2021-11-11 17:44:46 -08:00
|
|
|
get spendable => math.max(
|
2022-11-12 19:43:09 -08:00
|
|
|
_tBalance +
|
|
|
|
_sBalance -
|
|
|
|
_excludedBalance -
|
|
|
|
_underConfirmedBalance -
|
2022-12-10 14:10:07 -08:00
|
|
|
_usedBalance,
|
2021-11-11 17:44:46 -08:00
|
|
|
0);
|
2021-10-04 02:20:42 -07:00
|
|
|
|
|
|
|
get change => _unconfirmedSpentBalance + _unconfirmedBalance;
|
2021-10-09 07:17:27 -07:00
|
|
|
|
|
|
|
DualMoneyInputState? get amountInput => _amountKey.currentState;
|
2021-06-26 07:30:12 -07:00
|
|
|
}
|
|
|
|
|
2021-09-26 22:31:55 -07:00
|
|
|
class BalanceTable extends StatelessWidget {
|
2021-09-27 01:57:55 -07:00
|
|
|
final int sBalance;
|
|
|
|
final int tBalance;
|
2021-09-26 22:31:55 -07:00
|
|
|
final int excludedBalance;
|
|
|
|
final int underConfirmedBalance;
|
2021-10-04 02:20:42 -07:00
|
|
|
final int change;
|
2021-11-11 17:44:46 -08:00
|
|
|
final int used;
|
|
|
|
final int fee;
|
2021-09-26 22:31:55 -07:00
|
|
|
|
2022-11-12 19:43:09 -08:00
|
|
|
BalanceTable(this.sBalance, this.tBalance,
|
2021-11-11 17:44:46 -08:00
|
|
|
this.excludedBalance, this.underConfirmedBalance, this.change, this.used, this.fee);
|
2021-09-26 22:31:55 -07:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-09-27 01:57:55 -07:00
|
|
|
final theme = Theme.of(context);
|
2022-12-07 08:21:01 -08:00
|
|
|
final s = S.of(context);
|
2021-09-27 01:57:55 -07:00
|
|
|
return Container(
|
2021-11-11 17:44:46 -08:00
|
|
|
decoration: BoxDecoration(
|
|
|
|
border: Border.all(color: theme.dividerColor, width: 1),
|
|
|
|
borderRadius: BorderRadius.circular(8)),
|
2021-09-27 01:57:55 -07:00
|
|
|
child: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
2022-12-07 08:21:01 -08:00
|
|
|
BalanceRow(Text(s.totalBalance), totalBalance),
|
|
|
|
BalanceRow(Text(s.underConfirmed), -underConfirmed),
|
|
|
|
BalanceRow(Text(s.excludedNotes), -excludedBalance),
|
|
|
|
BalanceRow(Text(s.spendableBalance), spendable,
|
|
|
|
style: TextStyle(color: theme.primaryColor)),
|
2021-11-11 17:44:46 -08:00
|
|
|
]));
|
2021-09-26 22:31:55 -07:00
|
|
|
}
|
2021-09-27 01:57:55 -07:00
|
|
|
|
2022-12-07 08:21:01 -08:00
|
|
|
get totalBalance => sBalance + tBalance + change - used;
|
2021-11-11 17:44:46 -08:00
|
|
|
|
2021-10-04 02:20:42 -07:00
|
|
|
get underConfirmed => -underConfirmedBalance - change;
|
2021-09-27 01:57:55 -07:00
|
|
|
|
|
|
|
get spendable => math.max(
|
2021-11-11 17:44:46 -08:00
|
|
|
sBalance +
|
2022-11-12 19:43:09 -08:00
|
|
|
tBalance -
|
2021-11-11 17:44:46 -08:00
|
|
|
excludedBalance -
|
|
|
|
underConfirmedBalance -
|
2022-12-10 14:10:07 -08:00
|
|
|
used,
|
2021-11-11 17:44:46 -08:00
|
|
|
0);
|
2021-09-26 22:31:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
class BalanceRow extends StatelessWidget {
|
|
|
|
final label;
|
|
|
|
final amount;
|
2021-09-27 01:57:55 -07:00
|
|
|
final style;
|
|
|
|
|
|
|
|
BalanceRow(this.label, this.amount, {this.style});
|
|
|
|
|
2021-09-26 22:31:55 -07:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-09-27 01:57:55 -07:00
|
|
|
return ListTile(
|
|
|
|
title: label,
|
2022-08-29 20:42:08 -07:00
|
|
|
trailing: Text(amountToString(amount, MAX_PRECISION),
|
2021-11-11 17:44:46 -08:00
|
|
|
style: TextStyle(fontFeatures: [FontFeature.tabularFigures()])
|
|
|
|
.merge(style)),
|
2021-09-26 22:31:55 -07:00
|
|
|
visualDensity: VisualDensity(horizontal: 0, vertical: -4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-12 19:43:09 -08:00
|
|
|
Future<void> send(BuildContext context, List<Recipient> recipients) async {
|
2021-11-11 17:44:46 -08:00
|
|
|
final s = S.of(context);
|
|
|
|
|
2022-07-16 20:29:51 -07:00
|
|
|
showSnackBar(s.preparingTransaction, autoClose: true);
|
2021-11-11 17:44:46 -08:00
|
|
|
|
2021-11-17 20:57:52 -08:00
|
|
|
if (settings.protectSend &&
|
|
|
|
!await authenticate(context, s.pleaseAuthenticateToSend)) return;
|
2021-11-11 17:44:46 -08:00
|
|
|
|
2022-11-12 19:43:09 -08:00
|
|
|
if (recipients.length == 1)
|
|
|
|
active.setDraftRecipient(recipients[0]);
|
2022-11-16 06:16:44 -08:00
|
|
|
try {
|
|
|
|
final txPlan = await WarpApi.prepareTx(active.coin, active.id, recipients,
|
|
|
|
settings.anchorOffset);
|
|
|
|
Navigator.pushReplacementNamed(context, '/txplan', arguments: txPlan);
|
|
|
|
}
|
|
|
|
on String catch (message) {
|
|
|
|
showSnackBar(message);
|
|
|
|
}
|
2021-06-26 07:30:12 -07:00
|
|
|
}
|
2022-03-09 05:19:42 -08:00
|
|
|
|
2022-03-16 21:03:37 -07:00
|
|
|
abstract class Suggestion {
|
|
|
|
String get name;
|
|
|
|
String get address;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ContactSuggestion extends Suggestion {
|
|
|
|
final Contact contact;
|
|
|
|
|
|
|
|
ContactSuggestion(this.contact);
|
|
|
|
|
|
|
|
String get name => contact.name;
|
|
|
|
String get address => contact.address;
|
|
|
|
}
|
|
|
|
|
|
|
|
class AccountSuggestion extends Suggestion {
|
|
|
|
final Account account;
|
|
|
|
|
|
|
|
AccountSuggestion(this.account);
|
|
|
|
|
|
|
|
String get name => account.name;
|
|
|
|
String get address => account.address;
|
|
|
|
}
|
|
|
|
|
|
|
|
|