2020-08-25 16:32:40 +00:00
|
|
|
import 'dart:ui';
|
2021-01-27 13:51:51 +00:00
|
|
|
import 'package:cake_wallet/entities/monero_transaction_priority.dart';
|
2020-09-30 18:23:15 +00:00
|
|
|
import 'package:cake_wallet/entities/transaction_priority.dart';
|
2020-10-07 05:58:22 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
2020-09-29 17:56:11 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
2020-09-30 18:23:15 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/picker.dart';
|
2020-10-07 05:58:22 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
2021-01-27 13:51:51 +00:00
|
|
|
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
2020-09-29 17:56:11 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
|
|
|
import 'package:mobx/mobx.dart';
|
|
|
|
import 'package:keyboard_actions/keyboard_actions.dart';
|
|
|
|
import 'package:cake_wallet/routes.dart';
|
|
|
|
import 'package:cake_wallet/view_model/send/send_view_model.dart';
|
2020-09-22 19:26:20 +00:00
|
|
|
import 'package:cake_wallet/core/execution_state.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
|
|
|
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
|
|
|
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
|
|
|
import 'package:cake_wallet/src/widgets/trail_button.dart';
|
2020-09-25 15:32:44 +00:00
|
|
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
2020-09-22 19:26:20 +00:00
|
|
|
import 'package:cake_wallet/view_model/send/send_view_model_state.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/address_text_field.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2020-09-22 19:26:20 +00:00
|
|
|
import 'package:dotted_border/dotted_border.dart';
|
2020-05-07 17:10:04 +00:00
|
|
|
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
2020-09-22 19:26:20 +00:00
|
|
|
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
|
|
|
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
2020-08-25 16:32:40 +00:00
|
|
|
|
2020-01-04 19:31:52 +00:00
|
|
|
class SendPage extends BasePage {
|
2020-10-02 17:28:29 +00:00
|
|
|
SendPage({@required this.sendViewModel})
|
|
|
|
: _addressController = TextEditingController(),
|
|
|
|
_cryptoAmountController = TextEditingController(),
|
|
|
|
_fiatAmountController = TextEditingController(),
|
2020-12-22 18:42:30 +00:00
|
|
|
_noteController = TextEditingController(),
|
2020-10-02 17:28:29 +00:00
|
|
|
_formKey = GlobalKey<FormState>(),
|
|
|
|
_cryptoAmountFocus = FocusNode(),
|
|
|
|
_fiatAmountFocus = FocusNode(),
|
|
|
|
_addressFocusNode = FocusNode() {
|
|
|
|
_addressFocusNode.addListener(() {
|
|
|
|
if (!_addressFocusNode.hasFocus && _addressController.text.isNotEmpty) {
|
|
|
|
getOpenaliasRecord(_addressFocusNode.context);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-07-06 20:09:03 +00:00
|
|
|
|
2021-01-13 16:27:30 +00:00
|
|
|
static const prefixIconWidth = 34.0;
|
|
|
|
static const prefixIconHeight = 34.0;
|
|
|
|
|
2020-07-06 20:09:03 +00:00
|
|
|
final SendViewModel sendViewModel;
|
2020-10-02 17:28:29 +00:00
|
|
|
final TextEditingController _addressController;
|
|
|
|
final TextEditingController _cryptoAmountController;
|
|
|
|
final TextEditingController _fiatAmountController;
|
2020-12-22 18:42:30 +00:00
|
|
|
final TextEditingController _noteController;
|
2020-10-02 17:28:29 +00:00
|
|
|
final GlobalKey<FormState> _formKey;
|
|
|
|
final FocusNode _cryptoAmountFocus;
|
|
|
|
final FocusNode _fiatAmountFocus;
|
|
|
|
final FocusNode _addressFocusNode;
|
2020-09-21 19:01:45 +00:00
|
|
|
|
|
|
|
bool _effectsInstalled = false;
|
2020-07-06 20:09:03 +00:00
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
@override
|
2020-09-21 19:01:45 +00:00
|
|
|
String get title => S.current.send;
|
2020-01-08 12:26:34 +00:00
|
|
|
|
|
|
|
@override
|
2020-08-20 17:43:54 +00:00
|
|
|
Color get titleColor => Colors.white;
|
2020-05-29 15:10:11 +00:00
|
|
|
|
2020-01-08 12:26:34 +00:00
|
|
|
@override
|
2020-01-04 19:31:52 +00:00
|
|
|
bool get resizeToAvoidBottomPadding => false;
|
|
|
|
|
2020-05-11 08:22:03 +00:00
|
|
|
@override
|
2020-09-22 18:32:43 +00:00
|
|
|
bool get extendBodyBehindAppBar => true;
|
2020-09-01 11:18:07 +00:00
|
|
|
|
2020-09-02 08:47:41 +00:00
|
|
|
@override
|
2020-09-22 18:32:43 +00:00
|
|
|
AppBarStyle get appBarStyle => AppBarStyle.transparent;
|
2020-09-02 08:47:41 +00:00
|
|
|
|
|
|
|
@override
|
2020-09-22 18:32:43 +00:00
|
|
|
Widget trailing(context) => TrailButton(
|
2020-11-06 18:54:00 +00:00
|
|
|
caption: S.of(context).clear,
|
|
|
|
onPressed: () {
|
|
|
|
_formKey.currentState.reset();
|
|
|
|
sendViewModel.reset();
|
|
|
|
});
|
2020-09-02 08:47:41 +00:00
|
|
|
|
2020-09-21 19:01:45 +00:00
|
|
|
@override
|
|
|
|
Widget body(BuildContext context) {
|
|
|
|
_setEffects(context);
|
|
|
|
|
2020-09-29 17:56:11 +00:00
|
|
|
return KeyboardActions(
|
|
|
|
config: KeyboardActionsConfig(
|
|
|
|
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
2020-12-10 17:53:40 +00:00
|
|
|
keyboardBarColor: Theme.of(context).accentTextTheme.body2
|
|
|
|
.backgroundColor,
|
2020-09-29 17:56:11 +00:00
|
|
|
nextFocus: false,
|
|
|
|
actions: [
|
|
|
|
KeyboardActionsItem(
|
|
|
|
focusNode: _cryptoAmountFocus,
|
|
|
|
toolbarButtons: [(_) => KeyboardDoneButton()],
|
|
|
|
),
|
|
|
|
KeyboardActionsItem(
|
|
|
|
focusNode: _fiatAmountFocus,
|
|
|
|
toolbarButtons: [(_) => KeyboardDoneButton()],
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
child: Container(
|
|
|
|
height: 0,
|
|
|
|
color: Theme.of(context).backgroundColor,
|
|
|
|
child: ScrollableWithBottomSection(
|
|
|
|
contentPadding: EdgeInsets.only(bottom: 24),
|
|
|
|
content: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
bottomLeft: Radius.circular(24),
|
|
|
|
bottomRight: Radius.circular(24)),
|
|
|
|
gradient: LinearGradient(colors: [
|
|
|
|
Theme.of(context).primaryTextTheme.subhead.color,
|
|
|
|
Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.subhead
|
|
|
|
.decorationColor,
|
|
|
|
], begin: Alignment.topLeft, end: Alignment.bottomRight),
|
|
|
|
),
|
|
|
|
child: Form(
|
|
|
|
key: _formKey,
|
|
|
|
child: Column(children: <Widget>[
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(24, 100, 24, 32),
|
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
|
|
|
AddressTextField(
|
2020-10-02 17:28:29 +00:00
|
|
|
focusNode: _addressFocusNode,
|
2020-09-29 17:56:11 +00:00
|
|
|
controller: _addressController,
|
|
|
|
onURIScanned: (uri) {
|
|
|
|
var address = '';
|
|
|
|
var amount = '';
|
2020-09-21 19:01:45 +00:00
|
|
|
|
2020-09-29 17:56:11 +00:00
|
|
|
if (uri != null) {
|
|
|
|
address = uri.path;
|
2020-12-15 19:40:28 +00:00
|
|
|
amount = uri.queryParameters['tx_amount'] ??
|
|
|
|
uri.queryParameters['amount'];
|
2020-09-29 17:56:11 +00:00
|
|
|
} else {
|
|
|
|
address = uri.toString();
|
|
|
|
}
|
2020-09-21 19:01:45 +00:00
|
|
|
|
2020-09-29 17:56:11 +00:00
|
|
|
_addressController.text = address;
|
|
|
|
_cryptoAmountController.text = amount;
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
AddressTextFieldOption.paste,
|
|
|
|
AddressTextFieldOption.qrCode,
|
|
|
|
AddressTextFieldOption.addressBook
|
|
|
|
],
|
|
|
|
buttonColor: Theme.of(context)
|
2020-09-22 18:32:43 +00:00
|
|
|
.primaryTextTheme
|
2020-09-29 17:56:11 +00:00
|
|
|
.display1
|
|
|
|
.color,
|
2020-09-21 19:01:45 +00:00
|
|
|
borderColor: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.color,
|
|
|
|
textStyle: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Colors.white),
|
2020-09-29 17:56:11 +00:00
|
|
|
hintStyle: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w500,
|
2020-09-21 19:01:45 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
2020-09-29 17:56:11 +00:00
|
|
|
.decorationColor),
|
|
|
|
validator: sendViewModel.addressValidator,
|
|
|
|
),
|
2020-11-06 18:54:00 +00:00
|
|
|
Observer(
|
|
|
|
builder: (_) => Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 20),
|
2021-01-13 16:27:30 +00:00
|
|
|
child: Stack(
|
|
|
|
children: [
|
|
|
|
BaseTextFormField(
|
|
|
|
focusNode: _cryptoAmountFocus,
|
|
|
|
controller: _cryptoAmountController,
|
|
|
|
keyboardType:
|
|
|
|
TextInputType.numberWithOptions(
|
|
|
|
signed: false, decimal: true),
|
|
|
|
prefixIcon: Padding(
|
|
|
|
padding: EdgeInsets.only(top: 9),
|
|
|
|
child: Text(
|
|
|
|
sendViewModel.currency.title +
|
|
|
|
':',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Colors.white,
|
|
|
|
)),
|
2020-11-06 18:54:00 +00:00
|
|
|
),
|
2021-01-13 16:27:30 +00:00
|
|
|
suffixIcon: SizedBox(
|
|
|
|
width: prefixIconWidth,
|
|
|
|
),
|
|
|
|
hintText: '0.0000',
|
|
|
|
borderColor: Theme.of(context)
|
2020-11-06 18:54:00 +00:00
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
2021-01-13 16:27:30 +00:00
|
|
|
.color,
|
|
|
|
textStyle: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Colors.white),
|
|
|
|
placeholderTextStyle: TextStyle(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.decorationColor,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
fontSize: 14),
|
|
|
|
validator: sendViewModel.sendAll
|
2020-11-06 18:54:00 +00:00
|
|
|
? sendViewModel.allAmountValidator
|
|
|
|
: sendViewModel
|
2021-01-13 16:27:30 +00:00
|
|
|
.amountValidator),
|
|
|
|
Positioned(
|
|
|
|
top: 2,
|
|
|
|
right: 0,
|
|
|
|
child: Container(
|
|
|
|
width: prefixIconWidth,
|
|
|
|
height: prefixIconHeight,
|
|
|
|
child: InkWell(
|
|
|
|
onTap: () async =>
|
|
|
|
sendViewModel.setSendAll(),
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.display1
|
|
|
|
.color,
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.all(
|
|
|
|
Radius.circular(6))),
|
|
|
|
child: Center(
|
|
|
|
child: Text(
|
|
|
|
S.of(context).all,
|
|
|
|
textAlign:
|
|
|
|
TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight:
|
|
|
|
FontWeight.bold,
|
|
|
|
color:
|
|
|
|
Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.display1
|
|
|
|
.decorationColor))),
|
|
|
|
))))])
|
|
|
|
)),
|
2020-09-29 17:56:11 +00:00
|
|
|
Observer(
|
|
|
|
builder: (_) => Padding(
|
|
|
|
padding: EdgeInsets.only(top: 10),
|
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.spaceBetween,
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
|
|
|
child: Text(
|
|
|
|
S.of(context).available_balance +
|
|
|
|
':',
|
2020-09-28 15:47:43 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
2020-09-29 17:56:11 +00:00
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.decorationColor),
|
|
|
|
)),
|
|
|
|
Text(
|
|
|
|
sendViewModel.balance,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.decorationColor),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 20),
|
|
|
|
child: BaseTextFormField(
|
|
|
|
focusNode: _fiatAmountFocus,
|
|
|
|
controller: _fiatAmountController,
|
|
|
|
keyboardType:
|
|
|
|
TextInputType.numberWithOptions(
|
|
|
|
signed: false, decimal: true),
|
|
|
|
prefixIcon: Padding(
|
|
|
|
padding: EdgeInsets.only(top: 9),
|
|
|
|
child:
|
|
|
|
Text(sendViewModel.fiat.title + ':',
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Colors.white,
|
|
|
|
)),
|
2020-09-28 15:47:43 +00:00
|
|
|
),
|
2020-09-29 17:56:11 +00:00
|
|
|
hintText: '0.00',
|
|
|
|
borderColor: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.color,
|
|
|
|
textStyle: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Colors.white),
|
|
|
|
placeholderTextStyle: TextStyle(
|
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.decorationColor,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
fontSize: 14),
|
|
|
|
)),
|
2020-12-22 18:42:30 +00:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(top: 20),
|
|
|
|
child: BaseTextFormField(
|
|
|
|
controller: _noteController,
|
|
|
|
keyboardType: TextInputType.multiline,
|
|
|
|
maxLines: null,
|
|
|
|
borderColor: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.color,
|
|
|
|
textStyle: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Colors.white),
|
2020-12-23 08:39:59 +00:00
|
|
|
hintText: S.of(context).note_optional,
|
2020-12-22 18:42:30 +00:00
|
|
|
placeholderTextStyle: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.decorationColor),
|
|
|
|
),
|
|
|
|
),
|
2020-09-29 17:56:11 +00:00
|
|
|
Observer(
|
|
|
|
builder: (_) => GestureDetector(
|
|
|
|
onTap: () =>
|
|
|
|
_setTransactionPriority(context),
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(top: 24),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment:
|
|
|
|
MainAxisAlignment.spaceBetween,
|
2020-12-29 18:48:57 +00:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2020-09-29 17:56:11 +00:00
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
S
|
|
|
|
.of(context)
|
|
|
|
.send_estimated_fee,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight:
|
|
|
|
FontWeight.w500,
|
|
|
|
//color: Theme.of(context).primaryTextTheme.display2.color,
|
|
|
|
color: Colors.white)),
|
|
|
|
Container(
|
|
|
|
child: Row(
|
2020-12-29 18:48:57 +00:00
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
2020-09-29 17:56:11 +00:00
|
|
|
children: <Widget>[
|
2020-12-29 18:48:57 +00:00
|
|
|
Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
sendViewModel
|
2020-09-29 17:56:11 +00:00
|
|
|
.estimatedFee
|
|
|
|
.toString() +
|
2020-12-29 18:48:57 +00:00
|
|
|
' ' +
|
|
|
|
sendViewModel
|
2020-09-29 17:56:11 +00:00
|
|
|
.currency.title,
|
2020-12-29 18:48:57 +00:00
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight:
|
2020-09-29 17:56:11 +00:00
|
|
|
FontWeight.w600,
|
2020-12-29 18:48:57 +00:00
|
|
|
//color: Theme.of(context).primaryTextTheme.display2.color,
|
|
|
|
color:
|
2020-09-29 17:56:11 +00:00
|
|
|
Colors.white)),
|
2020-12-29 18:48:57 +00:00
|
|
|
Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.only(top: 5),
|
|
|
|
child: Text(
|
|
|
|
sendViewModel
|
|
|
|
.estimatedFeeFiatAmount
|
|
|
|
+ ' ' +
|
|
|
|
sendViewModel
|
|
|
|
.fiat.title,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 12,
|
|
|
|
fontWeight:
|
|
|
|
FontWeight.w600,
|
|
|
|
color: Theme
|
|
|
|
.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.headline
|
|
|
|
.decorationColor))
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2020-09-29 17:56:11 +00:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(
|
2020-12-29 18:48:57 +00:00
|
|
|
top: 2,
|
2020-09-29 17:56:11 +00:00
|
|
|
left: 5),
|
|
|
|
child: Icon(
|
|
|
|
Icons.arrow_forward_ios,
|
|
|
|
size: 12,
|
|
|
|
color: Colors.white,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
))
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(top: 30, left: 24, bottom: 24),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.start,
|
|
|
|
children: <Widget>[
|
|
|
|
Text(
|
|
|
|
S.of(context).send_templates,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 18,
|
|
|
|
fontWeight: FontWeight.w600,
|
2020-09-22 18:32:43 +00:00
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
2020-09-29 17:56:11 +00:00
|
|
|
.display4
|
|
|
|
.color),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
height: 40,
|
|
|
|
width: double.infinity,
|
|
|
|
padding: EdgeInsets.only(left: 24),
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
GestureDetector(
|
|
|
|
onTap: () => Navigator.of(context)
|
|
|
|
.pushNamed(Routes.sendTemplate),
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.only(left: 1, right: 10),
|
|
|
|
child: DottedBorder(
|
|
|
|
borderType: BorderType.RRect,
|
|
|
|
dashPattern: [6, 4],
|
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.display2
|
|
|
|
.decorationColor,
|
|
|
|
strokeWidth: 2,
|
|
|
|
radius: Radius.circular(20),
|
|
|
|
child: Container(
|
|
|
|
height: 34,
|
|
|
|
width: 75,
|
|
|
|
padding:
|
|
|
|
EdgeInsets.only(left: 10, right: 10),
|
|
|
|
alignment: Alignment.center,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius:
|
|
|
|
BorderRadius.all(Radius.circular(20)),
|
|
|
|
color: Colors.transparent,
|
|
|
|
),
|
|
|
|
child: Text(
|
|
|
|
S.of(context).send_new,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: 14,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
color: Theme.of(context)
|
|
|
|
.primaryTextTheme
|
|
|
|
.display3
|
|
|
|
.color),
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
),
|
2020-11-06 18:54:00 +00:00
|
|
|
Observer(builder: (_) {
|
|
|
|
final templates = sendViewModel.templates;
|
|
|
|
final itemCount = templates.length;
|
|
|
|
|
|
|
|
return ListView.builder(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
shrinkWrap: true,
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
itemCount: itemCount,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
final template = templates[index];
|
|
|
|
|
|
|
|
return TemplateTile(
|
|
|
|
key: UniqueKey(),
|
|
|
|
to: template.name,
|
|
|
|
amount: template.amount,
|
|
|
|
from: template.cryptoCurrency,
|
|
|
|
onTap: () {
|
|
|
|
_addressController.text =
|
|
|
|
template.address;
|
|
|
|
_cryptoAmountController.text =
|
|
|
|
template.amount;
|
|
|
|
getOpenaliasRecord(context);
|
|
|
|
},
|
|
|
|
onRemove: () {
|
|
|
|
showPopUp<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (dialogContext) {
|
|
|
|
return AlertWithTwoActions(
|
|
|
|
alertTitle:
|
|
|
|
S.of(context).template,
|
|
|
|
alertContent: S
|
|
|
|
.of(context)
|
|
|
|
.confirm_delete_template,
|
|
|
|
rightButtonText:
|
|
|
|
S.of(context).delete,
|
|
|
|
leftButtonText:
|
|
|
|
S.of(context).cancel,
|
|
|
|
actionRightButton: () {
|
|
|
|
Navigator.of(dialogContext)
|
|
|
|
.pop();
|
|
|
|
sendViewModel.removeTemplate(
|
|
|
|
template: template);
|
|
|
|
sendViewModel
|
|
|
|
.updateTemplate();
|
|
|
|
},
|
|
|
|
actionLeftButton: () =>
|
|
|
|
Navigator.of(dialogContext)
|
|
|
|
.pop());
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
})
|
2020-09-29 17:56:11 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
bottomSectionPadding:
|
|
|
|
EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
2021-05-25 17:32:36 +00:00
|
|
|
bottomSection: Column(
|
|
|
|
children: [
|
|
|
|
Observer(builder: (_) {
|
|
|
|
return LoadingPrimaryButton(
|
|
|
|
onPressed: () async {
|
|
|
|
if (_formKey.currentState.validate()) {
|
|
|
|
await sendViewModel.createTransaction();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
text: S.of(context).send,
|
|
|
|
color: Theme.of(context).accentTextTheme.body2.color,
|
|
|
|
textColor: Colors.white,
|
|
|
|
isLoading: sendViewModel.state is IsExecutingState ||
|
|
|
|
sendViewModel.state is TransactionCommitting,
|
|
|
|
isDisabled:
|
2020-09-29 17:56:11 +00:00
|
|
|
false // FIXME !(syncStore.status is SyncedSyncStatus),
|
|
|
|
);
|
2021-05-25 17:32:36 +00:00
|
|
|
}),
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.only(top: 12),
|
|
|
|
child: PrimaryButton(
|
|
|
|
onPressed: () => Navigator.of(context).pushNamed(Routes.unspentCoinsList),
|
|
|
|
text: 'Unspent coins',
|
|
|
|
color: Colors.green,
|
|
|
|
textColor: Colors.white,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)),
|
2020-09-29 17:56:11 +00:00
|
|
|
));
|
2020-09-21 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void _setEffects(BuildContext context) {
|
|
|
|
if (_effectsInstalled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-28 19:02:30 +00:00
|
|
|
_cryptoAmountController.addListener(() {
|
|
|
|
final amount = _cryptoAmountController.text;
|
|
|
|
|
|
|
|
if (sendViewModel.sendAll && amount != S.current.all) {
|
|
|
|
sendViewModel.sendAll = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amount != sendViewModel.cryptoAmount) {
|
|
|
|
sendViewModel.setCryptoAmount(amount);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-10-07 05:58:22 +00:00
|
|
|
_fiatAmountController.addListener(() {
|
|
|
|
final amount = _fiatAmountController.text;
|
|
|
|
|
|
|
|
if (amount != sendViewModel.fiatAmount) {
|
2020-10-09 20:19:12 +00:00
|
|
|
sendViewModel.sendAll = false;
|
2020-10-07 05:58:22 +00:00
|
|
|
sendViewModel.setFiatAmount(amount);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-12-22 18:42:30 +00:00
|
|
|
_noteController.addListener(() {
|
|
|
|
final note = _noteController.text ?? '';
|
|
|
|
|
|
|
|
if (note != sendViewModel.note) {
|
|
|
|
sendViewModel.note = note;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-09-21 19:01:45 +00:00
|
|
|
reaction((_) => sendViewModel.sendAll, (bool all) {
|
|
|
|
if (all) {
|
|
|
|
_cryptoAmountController.text = S.current.all;
|
|
|
|
_fiatAmountController.text = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
reaction((_) => sendViewModel.fiatAmount, (String amount) {
|
|
|
|
if (amount != _fiatAmountController.text) {
|
|
|
|
_fiatAmountController.text = amount;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
reaction((_) => sendViewModel.cryptoAmount, (String amount) {
|
|
|
|
if (sendViewModel.sendAll && amount != S.current.all) {
|
|
|
|
sendViewModel.sendAll = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (amount != _cryptoAmountController.text) {
|
|
|
|
_cryptoAmountController.text = amount;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
reaction((_) => sendViewModel.address, (String address) {
|
|
|
|
if (address != _addressController.text) {
|
|
|
|
_addressController.text = address;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
_addressController.addListener(() {
|
|
|
|
final address = _addressController.text;
|
|
|
|
|
|
|
|
if (sendViewModel.address != address) {
|
|
|
|
sendViewModel.address = address;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-12-22 18:42:30 +00:00
|
|
|
reaction((_) => sendViewModel.note, (String note) {
|
|
|
|
if (note != _noteController.text) {
|
|
|
|
_noteController.text = note;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-09-22 19:26:20 +00:00
|
|
|
reaction((_) => sendViewModel.state, (ExecutionState state) {
|
|
|
|
if (state is FailureState) {
|
2020-09-21 19:01:45 +00:00
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
2020-09-25 15:32:44 +00:00
|
|
|
showPopUp<void>(
|
2020-09-21 19:01:45 +00:00
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return AlertWithOneAction(
|
|
|
|
alertTitle: S.of(context).error,
|
|
|
|
alertContent: state.error,
|
|
|
|
buttonText: S.of(context).ok,
|
|
|
|
buttonAction: () => Navigator.of(context).pop());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-09-22 19:26:20 +00:00
|
|
|
if (state is ExecutedSuccessfullyState) {
|
2020-09-21 19:01:45 +00:00
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
2020-09-25 15:32:44 +00:00
|
|
|
showPopUp<void>(
|
2020-09-21 19:01:45 +00:00
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return ConfirmSendingAlert(
|
|
|
|
alertTitle: S.of(context).confirm_sending,
|
|
|
|
amount: S.of(context).send_amount,
|
|
|
|
amountValue:
|
2020-09-28 15:47:43 +00:00
|
|
|
sendViewModel.pendingTransaction.amountFormatted,
|
2020-12-29 18:48:57 +00:00
|
|
|
fiatAmountValue: sendViewModel.pendingTransactionFiatAmount
|
|
|
|
+ ' ' + sendViewModel.fiat.title,
|
2020-09-21 19:01:45 +00:00
|
|
|
fee: S.of(context).send_fee,
|
|
|
|
feeValue: sendViewModel.pendingTransaction.feeFormatted,
|
2020-12-30 14:54:55 +00:00
|
|
|
feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmount
|
|
|
|
+ ' ' + sendViewModel.fiat.title,
|
2020-12-30 16:19:16 +00:00
|
|
|
recipientTitle: S.of(context).recipient_address,
|
2020-12-29 18:48:57 +00:00
|
|
|
recipientAddress: sendViewModel.address,
|
2020-10-01 17:51:30 +00:00
|
|
|
rightButtonText: S.of(context).ok,
|
|
|
|
leftButtonText: S.of(context).cancel,
|
|
|
|
actionRightButton: () {
|
2020-09-21 19:01:45 +00:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
sendViewModel.commitTransaction();
|
2020-09-25 15:32:44 +00:00
|
|
|
showPopUp<void>(
|
2020-09-21 19:01:45 +00:00
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return Observer(builder: (_) {
|
|
|
|
final state = sendViewModel.state;
|
|
|
|
|
2020-11-06 18:54:00 +00:00
|
|
|
if (state is FailureState) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
|
2020-09-21 19:01:45 +00:00
|
|
|
if (state is TransactionCommitted) {
|
2020-12-29 18:48:57 +00:00
|
|
|
return AlertWithOneAction(
|
|
|
|
alertTitle: '',
|
|
|
|
alertContent: S.of(context).send_success(
|
|
|
|
sendViewModel.currency
|
|
|
|
.toString()),
|
|
|
|
buttonText: S.of(context).ok,
|
|
|
|
buttonAction: () =>
|
|
|
|
Navigator.of(context).pop());
|
2020-11-06 18:54:00 +00:00
|
|
|
}
|
|
|
|
|
2020-12-29 18:48:57 +00:00
|
|
|
return Offstage();
|
2020-09-21 19:01:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
2020-10-01 17:51:30 +00:00
|
|
|
actionLeftButton: () => Navigator.of(context).pop());
|
2020-09-21 19:01:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state is TransactionCommitted) {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
_addressController.text = '';
|
|
|
|
_cryptoAmountController.text = '';
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
_effectsInstalled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> getOpenaliasRecord(BuildContext context) async {
|
2020-10-02 17:28:29 +00:00
|
|
|
final record =
|
|
|
|
await sendViewModel.decodeOpenaliasRecord(_addressController.text);
|
|
|
|
|
|
|
|
if (record != null) {
|
|
|
|
_addressController.text = record.address;
|
|
|
|
|
|
|
|
await showPopUp<void>(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return AlertWithOneAction(
|
|
|
|
alertTitle: S.of(context).openalias_alert_title,
|
|
|
|
alertContent:
|
|
|
|
S.of(context).openalias_alert_content(record.name),
|
|
|
|
buttonText: S.of(context).ok,
|
|
|
|
buttonAction: () => Navigator.of(context).pop());
|
|
|
|
});
|
|
|
|
}
|
2020-09-21 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> _setTransactionPriority(BuildContext context) async {
|
2021-01-27 13:51:51 +00:00
|
|
|
final items = priorityForWalletType(sendViewModel.walletType);
|
2020-09-30 18:23:15 +00:00
|
|
|
final selectedItem = items.indexOf(sendViewModel.transactionPriority);
|
2021-01-06 08:42:21 +00:00
|
|
|
final isShowScrollThumb = items.length > 3;
|
2020-09-30 18:23:15 +00:00
|
|
|
|
|
|
|
await showPopUp<void>(
|
|
|
|
builder: (_) => Picker(
|
|
|
|
items: items,
|
2021-02-12 22:38:34 +00:00
|
|
|
displayItem: sendViewModel.displayFeeRate,
|
2020-09-30 18:23:15 +00:00
|
|
|
selectedAtIndex: selectedItem,
|
|
|
|
title: S.of(context).please_select,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
onItemSelected: (TransactionPriority priority) =>
|
|
|
|
sendViewModel.setTransactionPriority(priority),
|
|
|
|
),
|
|
|
|
context: context);
|
2020-09-21 19:01:45 +00:00
|
|
|
}
|
2020-01-04 19:31:52 +00:00
|
|
|
}
|