mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-20 06:08:34 +02:00
CAKE-20 | updated send and send template pages; added send_template_store and exchange_template_store; created base_send_widget; applied send_template_store to send_view_model; applied base_send_widget to send and send template pages; added properties to address_text_field, base_text_field and template_tile
This commit is contained in:
@@ -23,9 +23,11 @@ abstract class BasePage extends StatelessWidget {
|
||||
|
||||
Widget Function(BuildContext, Widget) get rootWrapper => null;
|
||||
|
||||
final _backArrowImage = Image.asset('assets/images/back_arrow.png');
|
||||
final _backArrowImage = Image.asset('assets/images/back_arrow.png',
|
||||
color: Colors.white);
|
||||
final _backArrowImageDarkTheme =
|
||||
Image.asset('assets/images/back_arrow_dark_theme.png');
|
||||
Image.asset('assets/images/back_arrow_dark_theme.png',
|
||||
color: Colors.white);
|
||||
final _closeButtonImage = Image.asset('assets/images/close_button.png');
|
||||
final _closeButtonImageDarkTheme =
|
||||
Image.asset('assets/images/close_button_dark_theme.png');
|
||||
@@ -71,7 +73,7 @@ abstract class BasePage extends StatelessWidget {
|
||||
style: TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).primaryTextTheme.title.color),
|
||||
color: Colors.white),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,39 +1,9 @@
|
||||
import 'package:cake_wallet/core/address_validator.dart';
|
||||
import 'package:cake_wallet/core/amount_validator.dart';
|
||||
import 'package:cake_wallet/src/screens/auth/auth_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
import 'package:cake_wallet/view_model/send_view_model.dart';
|
||||
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:provider/provider.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/widgets/address_text_field.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/src/stores/balance/balance_store.dart';
|
||||
import 'package:cake_wallet/src/stores/wallet/wallet_store.dart';
|
||||
import 'package:cake_wallet/src/stores/send/send_store.dart';
|
||||
|
||||
//import 'package:cake_wallet/src/stores/send/sending_state.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/domain/common/crypto_currency.dart';
|
||||
import 'package:cake_wallet/src/domain/common/calculate_estimated_fee.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/sync_status.dart';
|
||||
import 'package:cake_wallet/src/stores/sync/sync_store.dart';
|
||||
import 'package:cake_wallet/src/widgets/top_panel.dart';
|
||||
import 'package:dotted_border/dotted_border.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart';
|
||||
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
||||
import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
|
||||
import 'package:cake_wallet/src/widgets/trail_button.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/base_send_widget.dart';
|
||||
|
||||
class SendPage extends BasePage {
|
||||
SendPage({@required this.sendViewModel});
|
||||
@@ -41,539 +11,18 @@ class SendPage extends BasePage {
|
||||
final SendViewModel sendViewModel;
|
||||
|
||||
@override
|
||||
String get title => S.current.send_title;
|
||||
String get title => sendViewModel.pageTitle;
|
||||
|
||||
@override
|
||||
Color get backgroundLightColor => Palette.lavender;
|
||||
Color get backgroundLightColor => PaletteDark.nightBlue;
|
||||
|
||||
@override
|
||||
Color get backgroundDarkColor => PaletteDark.lightNightBlue;
|
||||
Color get backgroundDarkColor => PaletteDark.nightBlue;
|
||||
|
||||
@override
|
||||
bool get resizeToAvoidBottomPadding => false;
|
||||
|
||||
@override
|
||||
Widget trailing(context) {
|
||||
// final sendStore = Provider.of<SendStore>(context);
|
||||
|
||||
return TrailButton(caption: S.of(context).clear, onPressed: () => null);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => SendForm(sendViewModel: sendViewModel);
|
||||
}
|
||||
|
||||
class SendForm extends StatefulWidget {
|
||||
SendForm({this.sendViewModel});
|
||||
|
||||
final SendViewModel sendViewModel;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => SendFormState();
|
||||
}
|
||||
|
||||
class SendFormState extends State<SendForm> {
|
||||
final _addressController = TextEditingController();
|
||||
final _cryptoAmountController = TextEditingController();
|
||||
final _fiatAmountController = TextEditingController();
|
||||
|
||||
final _focusNode = FocusNode();
|
||||
|
||||
bool _effectsInstalled = false;
|
||||
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_focusNode.addListener(() {
|
||||
if (!_focusNode.hasFocus && _addressController.text.isNotEmpty) {
|
||||
getOpenaliasRecord(context);
|
||||
}
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<void> getOpenaliasRecord(BuildContext context) async {
|
||||
final sendStore = Provider.of<SendStore>(context);
|
||||
final isOpenalias =
|
||||
await sendStore.isOpenaliasRecord(_addressController.text);
|
||||
|
||||
if (isOpenalias) {
|
||||
_addressController.text = sendStore.recordAddress;
|
||||
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.of(context).openalias_alert_title,
|
||||
alertContent:
|
||||
S.of(context).openalias_alert_content(sendStore.recordName),
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// final settingsStore = Provider.of<SettingsStore>(context);
|
||||
// final sendStore = Provider.of<SendStore>(context);
|
||||
// sendStore.settingsStore = settingsStore;
|
||||
// final balanceStore = Provider.of<BalanceStore>(context);
|
||||
// final walletStore = Provider.of<WalletStore>(context);
|
||||
// final syncStore = Provider.of<SyncStore>(context);
|
||||
// final sendTemplateStore = Provider.of<SendTemplateStore>(context);
|
||||
|
||||
_setEffects(context);
|
||||
|
||||
return Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(bottom: 24),
|
||||
content: Column(
|
||||
children: <Widget>[
|
||||
TopPanel(
|
||||
color: Theme.of(context).accentTextTheme.title.backgroundColor,
|
||||
widget: Form(
|
||||
key: _formKey,
|
||||
child: Column(children: <Widget>[
|
||||
AddressTextField(
|
||||
controller: _addressController,
|
||||
placeholder: S.of(context).send_monero_address,
|
||||
focusNode: _focusNode,
|
||||
onURIScanned: (uri) {
|
||||
var address = '';
|
||||
var amount = '';
|
||||
|
||||
if (uri != null) {
|
||||
address = uri.path;
|
||||
amount = uri.queryParameters['tx_amount'];
|
||||
} else {
|
||||
address = uri.toString();
|
||||
}
|
||||
|
||||
_addressController.text = address;
|
||||
_cryptoAmountController.text = amount;
|
||||
},
|
||||
options: [
|
||||
AddressTextFieldOption.qrCode,
|
||||
AddressTextFieldOption.addressBook
|
||||
],
|
||||
buttonColor: Theme.of(context).accentTextTheme.title.color,
|
||||
validator: widget.sendViewModel.addressValidator,
|
||||
),
|
||||
Observer(builder: (_) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: TextFormField(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color),
|
||||
controller: _cryptoAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 12),
|
||||
child: Text('XMR:',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color,
|
||||
)),
|
||||
),
|
||||
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(
|
||||
' / ' + widget.sendViewModel.balance,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.caption
|
||||
.color)),
|
||||
),
|
||||
Container(
|
||||
height: 32,
|
||||
width: 32,
|
||||
margin: EdgeInsets.only(
|
||||
left: 12, bottom: 7, top: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.title
|
||||
.color,
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(6))),
|
||||
child: InkWell(
|
||||
onTap: () => null,
|
||||
// widget.sendViewModel,
|
||||
child: Center(
|
||||
child: Text(S.of(context).all,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 9,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.caption
|
||||
.color)),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color),
|
||||
hintText: '0.0000',
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0))),
|
||||
validator: widget.sendViewModel.amountValidator),
|
||||
);
|
||||
}),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: TextFormField(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color:
|
||||
Theme.of(context).primaryTextTheme.title.color),
|
||||
controller: _fiatAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 12),
|
||||
child: Text(
|
||||
'${widget.sendViewModel.fiat.toString()}:',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color,
|
||||
)),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.caption
|
||||
.color),
|
||||
hintText: '0.00',
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
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: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color,
|
||||
)),
|
||||
Text(
|
||||
'${widget.sendViewModel.estimatedFee} ${widget.sendViewModel.currency.toString()}',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context)
|
||||
.primaryTextTheme
|
||||
.title
|
||||
.color,
|
||||
))
|
||||
],
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding: EdgeInsets.only(top: 32, left: 24, bottom: 24),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.start,
|
||||
// children: <Widget>[
|
||||
// Text(
|
||||
// S.of(context).send_templates,
|
||||
// style: TextStyle(
|
||||
// fontSize: 18,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color:
|
||||
// Theme.of(context).primaryTextTheme.caption.color),
|
||||
// )
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// Container(
|
||||
// height: 40,
|
||||
// width: double.infinity,
|
||||
// padding: EdgeInsets.only(left: 24),
|
||||
// child: Observer(builder: (_) {
|
||||
// final itemCount = sendTemplateStore.templates.length + 1;
|
||||
//
|
||||
// return ListView.builder(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// itemCount: itemCount,
|
||||
// itemBuilder: (context, index) {
|
||||
// if (index == 0) {
|
||||
// return GestureDetector(
|
||||
// onTap: () => Navigator.of(context)
|
||||
// .pushNamed(Routes.sendTemplate),
|
||||
// child: Container(
|
||||
// padding: EdgeInsets.only(right: 10),
|
||||
// child: DottedBorder(
|
||||
// borderType: BorderType.RRect,
|
||||
// dashPattern: [8, 4],
|
||||
// color: Theme.of(context)
|
||||
// .accentTextTheme
|
||||
// .title
|
||||
// .backgroundColor,
|
||||
// strokeWidth: 2,
|
||||
// radius: Radius.circular(20),
|
||||
// child: Container(
|
||||
// height: 40,
|
||||
// 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
|
||||
// .caption
|
||||
// .color),
|
||||
// ),
|
||||
// )),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// index -= 1;
|
||||
//
|
||||
// final template = sendTemplateStore.templates[index];
|
||||
//
|
||||
// return TemplateTile(
|
||||
// to: template.name,
|
||||
// amount: template.amount,
|
||||
// from: template.cryptoCurrency,
|
||||
// onTap: () {
|
||||
// _addressController.text = template.address;
|
||||
// _cryptoAmountController.text = template.amount;
|
||||
// getOpenaliasRecord(context);
|
||||
// });
|
||||
// });
|
||||
// }),
|
||||
// )
|
||||
],
|
||||
),
|
||||
bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
bottomSection: Observer(builder: (_) {
|
||||
return LoadingPrimaryButton(
|
||||
onPressed: () => null,
|
||||
// syncStore.status is SyncedSyncStatus
|
||||
// ? () async {
|
||||
// // Hack. Don't ask me.
|
||||
// FocusScope.of(context).requestFocus(FocusNode());
|
||||
//
|
||||
// if (_formKey.currentState.validate()) {
|
||||
// await showDialog<void>(
|
||||
// context: context,
|
||||
// builder: (dialogContext) {
|
||||
// return AlertWithTwoActions(
|
||||
// alertTitle:
|
||||
// S.of(context).send_creating_transaction,
|
||||
// alertContent: S.of(context).confirm_sending,
|
||||
// leftButtonText: S.of(context).send,
|
||||
// rightButtonText: S.of(context).cancel,
|
||||
// actionLeftButton: () async {
|
||||
// await Navigator.of(dialogContext)
|
||||
// .popAndPushNamed(Routes.auth, arguments:
|
||||
// (bool isAuthenticatedSuccessfully,
|
||||
// AuthPageState auth) {
|
||||
// if (!isAuthenticatedSuccessfully) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Navigator.of(auth.context).pop();
|
||||
//
|
||||
// sendStore.createTransaction(
|
||||
// address: _addressController.text,
|
||||
// paymentId: '');
|
||||
// });
|
||||
// },
|
||||
// actionRightButton: () =>
|
||||
// Navigator.of(context).pop());
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// : null,
|
||||
text: S.of(context).send,
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
isLoading: widget.sendViewModel.state is TransactionIsCreating ||
|
||||
widget.sendViewModel.state is TransactionCommitting,
|
||||
isDisabled:
|
||||
false // FIXME !(syncStore.status is SyncedSyncStatus),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _setEffects(BuildContext context) {
|
||||
if (_effectsInstalled) {
|
||||
return;
|
||||
}
|
||||
|
||||
// reaction((_) => widget.sendViewModel.fiatAmount, (String amount) {
|
||||
// if (amount != _fiatAmountController.text) {
|
||||
// _fiatAmountController.text = amount;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// reaction((_) => widget.sendViewModel.cryptoAmount, (String amount) {
|
||||
// if (amount != _cryptoAmountController.text) {
|
||||
// _cryptoAmountController.text = amount;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// reaction((_) => widget.sendViewModel.address, (String address) {
|
||||
// if (address != _addressController.text) {
|
||||
// _addressController.text = address;
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// _addressController.addListener(() {
|
||||
// final address = _addressController.text;
|
||||
//
|
||||
// if (widget.sendViewModel.address != address) {
|
||||
// widget.sendViewModel.changeAddress(address);
|
||||
// }
|
||||
// });
|
||||
|
||||
// _fiatAmountController.addListener(() {
|
||||
// final fiatAmount = _fiatAmountController.text;
|
||||
//
|
||||
// if (sendStore.fiatAmount != fiatAmount) {
|
||||
// sendStore.changeFiatAmount(fiatAmount);
|
||||
// }
|
||||
// });
|
||||
|
||||
// _cryptoAmountController.addListener(() {
|
||||
// final cryptoAmount = _cryptoAmountController.text;
|
||||
//
|
||||
// if (sendStore.cryptoAmount != cryptoAmount) {
|
||||
// sendStore.changeCryptoAmount(cryptoAmount);
|
||||
// }
|
||||
// });
|
||||
|
||||
reaction((_) => widget.sendViewModel.state, (SendViewModelState state) {
|
||||
if (state is SendingFailed) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog<void>(
|
||||
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());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (state is TransactionCreatedSuccessfully) {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// showDialog<void>(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return ConfirmSendingAlert(
|
||||
// alertTitle: S.of(context).confirm_sending,
|
||||
// amount: S.of(context).send_amount,
|
||||
// amountValue: sendStore.pendingTransaction.amount,
|
||||
// fee: S.of(context).send_fee,
|
||||
// feeValue: sendStore.pendingTransaction.fee,
|
||||
// leftButtonText: S.of(context).ok,
|
||||
// rightButtonText: S.of(context).cancel,
|
||||
// actionLeftButton: () {
|
||||
// Navigator.of(context).pop();
|
||||
// sendStore.commitTransaction();
|
||||
// showDialog<void>(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return SendingAlert(sendStore: sendStore);
|
||||
// });
|
||||
// },
|
||||
// actionRightButton: () => Navigator.of(context).pop());
|
||||
// });
|
||||
// });
|
||||
}
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_addressController.text = '';
|
||||
_cryptoAmountController.text = '';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_effectsInstalled = true;
|
||||
}
|
||||
Widget body(BuildContext context) =>
|
||||
BaseSendWidget(sendViewModel: sendViewModel);
|
||||
}
|
||||
|
||||
@@ -1,277 +1,29 @@
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
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:provider/provider.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/src/widgets/address_text_field.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/stores/settings/settings_store.dart';
|
||||
import 'package:cake_wallet/src/stores/balance/balance_store.dart';
|
||||
import 'package:cake_wallet/src/stores/send/send_store.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/top_panel.dart';
|
||||
import 'package:cake_wallet/src/stores/send_template/send_template_store.dart';
|
||||
import 'package:cake_wallet/view_model/send_view_model.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/base_send_widget.dart';
|
||||
|
||||
class SendTemplatePage extends BasePage {
|
||||
@override
|
||||
String get title => S.current.send_title;
|
||||
SendTemplatePage({@required this.sendViewModel});
|
||||
|
||||
final SendViewModel sendViewModel;
|
||||
|
||||
@override
|
||||
Color get backgroundLightColor => Palette.lavender;
|
||||
String get title => S.current.exchange_new_template;
|
||||
|
||||
@override
|
||||
Color get backgroundDarkColor => PaletteDark.lightNightBlue;
|
||||
Color get backgroundLightColor => PaletteDark.nightBlue;
|
||||
|
||||
@override
|
||||
Color get backgroundDarkColor => PaletteDark.nightBlue;
|
||||
|
||||
@override
|
||||
bool get resizeToAvoidBottomPadding => false;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => SendTemplateForm();
|
||||
}
|
||||
|
||||
class SendTemplateForm extends StatefulWidget {
|
||||
@override
|
||||
SendTemplateFormState createState() => SendTemplateFormState();
|
||||
}
|
||||
|
||||
class SendTemplateFormState extends State<SendTemplateForm> {
|
||||
final _nameController = TextEditingController();
|
||||
final _addressController = TextEditingController();
|
||||
final _cryptoAmountController = TextEditingController();
|
||||
final _fiatAmountController = TextEditingController();
|
||||
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
bool _effectsInstalled = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_nameController.dispose();
|
||||
_addressController.dispose();
|
||||
_cryptoAmountController.dispose();
|
||||
_fiatAmountController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
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);
|
||||
|
||||
return Container(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(bottom: 24),
|
||||
content: Column(
|
||||
children: <Widget>[
|
||||
TopPanel(
|
||||
color: Theme.of(context).accentTextTheme.title.backgroundColor,
|
||||
widget: Form(
|
||||
key: _formKey,
|
||||
child: Column(children: <Widget>[
|
||||
TextFormField(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context).primaryTextTheme.title.color),
|
||||
controller: _nameController,
|
||||
decoration: InputDecoration(
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context).primaryTextTheme.caption.color),
|
||||
hintText: S.of(context).send_name,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0))),
|
||||
validator: (value) {
|
||||
sendTemplateStore.validateTemplate(value);
|
||||
return sendTemplateStore.errorMessage;
|
||||
},
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: AddressTextField(
|
||||
controller: _addressController,
|
||||
placeholder: S.of(context).send_monero_address,
|
||||
onURIScanned: (uri) {
|
||||
var address = '';
|
||||
var amount = '';
|
||||
|
||||
if (uri != null) {
|
||||
address = uri.path;
|
||||
amount = uri.queryParameters['tx_amount'];
|
||||
} else {
|
||||
address = uri.toString();
|
||||
}
|
||||
|
||||
_addressController.text = address;
|
||||
_cryptoAmountController.text = amount;
|
||||
},
|
||||
options: [
|
||||
AddressTextFieldOption.qrCode,
|
||||
AddressTextFieldOption.addressBook
|
||||
],
|
||||
buttonColor: Theme.of(context).accentTextTheme.title.color,
|
||||
validator: (value) {
|
||||
sendTemplateStore.validateTemplate(value);
|
||||
return sendTemplateStore.errorMessage;
|
||||
},
|
||||
),
|
||||
),
|
||||
Observer(
|
||||
builder: (_) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: TextFormField(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context).primaryTextTheme.title.color
|
||||
),
|
||||
controller: _cryptoAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 12),
|
||||
child: Text('XMR:',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
)),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context).primaryTextTheme.title.color),
|
||||
hintText: '0.0000',
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0))),
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: TextFormField(
|
||||
style: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context).primaryTextTheme.title.color),
|
||||
controller: _fiatAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 12),
|
||||
child: Text(
|
||||
'${settingsStore.fiatCurrency.toString()}:',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
)),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: Theme.of(context).primaryTextTheme.caption.color),
|
||||
hintText: '0.00',
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 1.0)))),
|
||||
),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
bottomSection: PrimaryButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState.validate()) {
|
||||
sendTemplateStore.addTemplate(
|
||||
name: _nameController.text,
|
||||
address: _addressController.text,
|
||||
cryptoCurrency: 'XMR',
|
||||
amount: _cryptoAmountController.text
|
||||
);
|
||||
sendTemplateStore.update();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
text: S.of(context).save,
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _setEffects(BuildContext context) {
|
||||
if (_effectsInstalled) {
|
||||
return;
|
||||
}
|
||||
|
||||
final sendStore = Provider.of<SendStore>(context);
|
||||
|
||||
reaction((_) => sendStore.fiatAmount, (String amount) {
|
||||
if (amount != _fiatAmountController.text) {
|
||||
_fiatAmountController.text = amount;
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => sendStore.cryptoAmount, (String amount) {
|
||||
if (amount != _cryptoAmountController.text) {
|
||||
_cryptoAmountController.text = amount;
|
||||
}
|
||||
});
|
||||
|
||||
_fiatAmountController.addListener(() {
|
||||
final fiatAmount = _fiatAmountController.text;
|
||||
|
||||
if (sendStore.fiatAmount != fiatAmount) {
|
||||
sendStore.changeFiatAmount(fiatAmount);
|
||||
}
|
||||
});
|
||||
|
||||
_cryptoAmountController.addListener(() {
|
||||
final cryptoAmount = _cryptoAmountController.text;
|
||||
|
||||
if (sendStore.cryptoAmount != cryptoAmount) {
|
||||
sendStore.changeCryptoAmount(cryptoAmount);
|
||||
}
|
||||
});
|
||||
|
||||
_effectsInstalled = true;
|
||||
}
|
||||
Widget body(BuildContext context) =>
|
||||
BaseSendWidget(sendViewModel: sendViewModel, isTemplate: true);
|
||||
}
|
||||
@@ -0,0 +1,541 @@
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/view_model/send_view_model.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/src/widgets/address_text_field.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/top_panel.dart';
|
||||
import 'package:dotted_border/dotted_border.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/sending_alert.dart';
|
||||
import 'package:cake_wallet/src/widgets/template_tile.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
|
||||
class BaseSendWidget extends StatelessWidget {
|
||||
BaseSendWidget({
|
||||
@required this.sendViewModel,
|
||||
this.isTemplate = false
|
||||
});
|
||||
|
||||
final SendViewModel sendViewModel;
|
||||
final bool isTemplate;
|
||||
|
||||
final _addressController = TextEditingController();
|
||||
final _cryptoAmountController = TextEditingController();
|
||||
final _fiatAmountController = TextEditingController();
|
||||
final _nameController = TextEditingController();
|
||||
final _focusNode = FocusNode();
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
|
||||
bool _effectsInstalled = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
_setEffects(context);
|
||||
|
||||
return Container(
|
||||
color: PaletteDark.backgroundColor,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(bottom: 24),
|
||||
content: Column(
|
||||
children: <Widget>[
|
||||
TopPanel(
|
||||
color: PaletteDark.nightBlue,
|
||||
edgeInsets: EdgeInsets.fromLTRB(24, 24, 24, 32),
|
||||
widget: Form(
|
||||
key: _formKey,
|
||||
child: Column(children: <Widget>[
|
||||
isTemplate
|
||||
? BaseTextFormField(
|
||||
controller: _nameController,
|
||||
hintText: S.of(context).send_name,
|
||||
borderColor: PaletteDark.lightVioletBlue,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white
|
||||
),
|
||||
placeholderTextStyle: TextStyle(
|
||||
color: PaletteDark.darkCyanBlue,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14),
|
||||
validator: sendViewModel.templateValidator,
|
||||
)
|
||||
: Offstage(),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: isTemplate ? 20 : 0),
|
||||
child: AddressTextField(
|
||||
controller: _addressController,
|
||||
placeholder: S.of(context).send_address(
|
||||
sendViewModel.cryptoCurrencyTitle),
|
||||
focusNode: _focusNode,
|
||||
onURIScanned: (uri) {
|
||||
var address = '';
|
||||
var amount = '';
|
||||
|
||||
if (uri != null) {
|
||||
address = uri.path;
|
||||
amount = uri.queryParameters['tx_amount'];
|
||||
} else {
|
||||
address = uri.toString();
|
||||
}
|
||||
|
||||
_addressController.text = address;
|
||||
_cryptoAmountController.text = amount;
|
||||
},
|
||||
options: [
|
||||
AddressTextFieldOption.paste,
|
||||
AddressTextFieldOption.qrCode,
|
||||
AddressTextFieldOption.addressBook
|
||||
],
|
||||
buttonColor: PaletteDark.buttonNightBlue,
|
||||
borderColor: PaletteDark.lightVioletBlue,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: PaletteDark.darkCyanBlue
|
||||
),
|
||||
validator: sendViewModel.addressValidator,
|
||||
),
|
||||
),
|
||||
Observer(
|
||||
builder: (_) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: BaseTextFormField(
|
||||
controller: _cryptoAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 9),
|
||||
child: Text(sendViewModel.currency.title + ':',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
suffixIcon: isTemplate
|
||||
? Offstage()
|
||||
: Padding(
|
||||
padding: EdgeInsets.only(bottom: 2),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width/2,
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
' / ' + sendViewModel.balance,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: PaletteDark.darkCyanBlue
|
||||
)
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 34,
|
||||
width: 34,
|
||||
margin: EdgeInsets.only(left: 12, bottom: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: PaletteDark.buttonNightBlue,
|
||||
borderRadius: BorderRadius.all(Radius.circular(6))
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () => sendViewModel.setSendAll(),
|
||||
child: Center(
|
||||
child: Text(S.of(context).all,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: PaletteDark.lightBlueGrey
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
hintText: '0.0000',
|
||||
borderColor: PaletteDark.lightVioletBlue,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white
|
||||
),
|
||||
placeholderTextStyle: TextStyle(
|
||||
color: PaletteDark.darkCyanBlue,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14),
|
||||
validator: sendViewModel.amountValidator
|
||||
)
|
||||
);
|
||||
}
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
child: BaseTextFormField(
|
||||
controller: _fiatAmountController,
|
||||
keyboardType: TextInputType.numberWithOptions(
|
||||
signed: false, decimal: true),
|
||||
inputFormatters: [
|
||||
BlacklistingTextInputFormatter(
|
||||
RegExp('[\\-|\\ |\\,]'))
|
||||
],
|
||||
prefixIcon: Padding(
|
||||
padding: EdgeInsets.only(top: 9),
|
||||
child: Text(
|
||||
sendViewModel.fiat.title + ':',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
)),
|
||||
),
|
||||
hintText: '0.00',
|
||||
borderColor: PaletteDark.lightVioletBlue,
|
||||
textStyle: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white
|
||||
),
|
||||
placeholderTextStyle: TextStyle(
|
||||
color: PaletteDark.darkCyanBlue,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontSize: 14),
|
||||
)
|
||||
),
|
||||
isTemplate
|
||||
? Offstage()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.only(top: 24),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Text(S.of(context).send_estimated_fee,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Colors.white,
|
||||
)),
|
||||
Text(
|
||||
sendViewModel.estimatedFee.toString() + ' '
|
||||
+ sendViewModel.currency.title,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Colors.white,
|
||||
))
|
||||
],
|
||||
),
|
||||
)
|
||||
]),
|
||||
),
|
||||
),
|
||||
isTemplate
|
||||
? Offstage()
|
||||
: 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,
|
||||
color: PaletteDark.darkCyanBlue
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
isTemplate
|
||||
? Offstage()
|
||||
: 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: PaletteDark.darkCyanBlue,
|
||||
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: PaletteDark.darkCyanBlue
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
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: () {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertWithTwoActions(
|
||||
alertTitle: S.of(context).template,
|
||||
alertContent: S.of(context).confirm_delete_template,
|
||||
leftButtonText: S.of(context).delete,
|
||||
rightButtonText: S.of(context).cancel,
|
||||
actionLeftButton: () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
sendViewModel.sendTemplateStore.remove(template: template);
|
||||
sendViewModel.sendTemplateStore.update();
|
||||
},
|
||||
actionRightButton: () => Navigator.of(dialogContext).pop()
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||
bottomSection: isTemplate
|
||||
? PrimaryButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState.validate()) {
|
||||
sendViewModel.sendTemplateStore.addTemplate(
|
||||
name: _nameController.text,
|
||||
address: _addressController.text,
|
||||
cryptoCurrency: sendViewModel.currency.title,
|
||||
amount: _cryptoAmountController.text
|
||||
);
|
||||
sendViewModel.sendTemplateStore.update();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
text: S.of(context).save,
|
||||
color: Colors.green,
|
||||
textColor: Colors.white)
|
||||
: Observer(builder: (_) {
|
||||
return LoadingPrimaryButton(
|
||||
onPressed: () {
|
||||
if (_formKey.currentState.validate()) {
|
||||
print('SENT!!!');
|
||||
}
|
||||
},
|
||||
text: S.of(context).send,
|
||||
color: Colors.blue,
|
||||
textColor: Colors.white,
|
||||
isLoading: sendViewModel.state is TransactionIsCreating ||
|
||||
sendViewModel.state is TransactionCommitting,
|
||||
isDisabled:
|
||||
false // FIXME !(syncStore.status is SyncedSyncStatus),
|
||||
);
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _setEffects(BuildContext context) {
|
||||
if (_effectsInstalled) {
|
||||
return;
|
||||
}
|
||||
|
||||
reaction((_) => sendViewModel.fiatAmount, (String amount) {
|
||||
if (amount != _fiatAmountController.text) {
|
||||
_fiatAmountController.text = amount;
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => sendViewModel.cryptoAmount, (String amount) {
|
||||
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.changeAddress(address);
|
||||
}
|
||||
});
|
||||
|
||||
_fiatAmountController.addListener(() {
|
||||
final fiatAmount = _fiatAmountController.text;
|
||||
|
||||
if (sendViewModel.fiatAmount != fiatAmount) {
|
||||
sendViewModel.changeFiatAmount(fiatAmount);
|
||||
}
|
||||
});
|
||||
|
||||
_cryptoAmountController.addListener(() {
|
||||
final cryptoAmount = _cryptoAmountController.text;
|
||||
|
||||
if (sendViewModel.cryptoAmount != cryptoAmount) {
|
||||
sendViewModel.changeCryptoAmount(cryptoAmount);
|
||||
}
|
||||
});
|
||||
|
||||
_focusNode.addListener(() {
|
||||
if (!_focusNode.hasFocus && _addressController.text.isNotEmpty) {
|
||||
getOpenaliasRecord(context);
|
||||
}
|
||||
});
|
||||
|
||||
reaction((_) => sendViewModel.state, (SendViewModelState state) {
|
||||
if (state is SendingFailed) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(S.of(context).error),
|
||||
content: Text(state.error),
|
||||
actions: <Widget>[
|
||||
FlatButton(
|
||||
child: Text(S.of(context).ok),
|
||||
onPressed: () => Navigator.of(context).pop())
|
||||
],
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (state is TransactionCreatedSuccessfully) {
|
||||
// WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
// showDialog<void>(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return ConfirmSendingAlert(
|
||||
// alertTitle: S.of(context).confirm_sending,
|
||||
// amount: S.of(context).send_amount,
|
||||
// amountValue: sendStore.pendingTransaction.amount,
|
||||
// fee: S.of(context).send_fee,
|
||||
// feeValue: sendStore.pendingTransaction.fee,
|
||||
// leftButtonText: S.of(context).ok,
|
||||
// rightButtonText: S.of(context).cancel,
|
||||
// actionLeftButton: () {
|
||||
// Navigator.of(context).pop();
|
||||
// sendStore.commitTransaction();
|
||||
// showDialog<void>(
|
||||
// context: context,
|
||||
// builder: (BuildContext context) {
|
||||
// return SendingAlert(sendStore: sendStore);
|
||||
// });
|
||||
// },
|
||||
// actionRightButton: () => Navigator.of(context).pop());
|
||||
// });
|
||||
// });
|
||||
}
|
||||
|
||||
if (state is TransactionCommitted) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_addressController.text = '';
|
||||
_cryptoAmountController.text = '';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
_effectsInstalled = true;
|
||||
}
|
||||
|
||||
Future<void> getOpenaliasRecord(BuildContext context) async {
|
||||
final isOpenalias = await sendViewModel.isOpenaliasRecord(_addressController.text);
|
||||
|
||||
if (isOpenalias) {
|
||||
_addressController.text = sendViewModel.recordAddress;
|
||||
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.of(context).openalias_alert_title,
|
||||
alertContent: S.of(context).openalias_alert_content(sendViewModel.recordName),
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop()
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,31 @@
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/domain/common/contact.dart';
|
||||
import 'package:cake_wallet/src/domain/monero/subaddress.dart';
|
||||
import 'package:cake_wallet/src/domain/common/qr_scanner.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
enum AddressTextFieldOption { qrCode, addressBook, subaddressList }
|
||||
enum AddressTextFieldOption { paste, qrCode, addressBook, subaddressList }
|
||||
|
||||
class AddressTextField extends StatelessWidget {
|
||||
AddressTextField(
|
||||
{@required this.controller,
|
||||
this.isActive = true,
|
||||
this.placeholder,
|
||||
this.options = const [
|
||||
AddressTextFieldOption.qrCode,
|
||||
AddressTextFieldOption.addressBook
|
||||
],
|
||||
this.onURIScanned,
|
||||
this.focusNode,
|
||||
this.isBorderExist = true,
|
||||
this.buttonColor,
|
||||
this.validator});
|
||||
this.isActive = true,
|
||||
this.placeholder,
|
||||
this.options = const [
|
||||
AddressTextFieldOption.qrCode,
|
||||
AddressTextFieldOption.addressBook
|
||||
],
|
||||
this.onURIScanned,
|
||||
this.focusNode,
|
||||
this.isBorderExist = true,
|
||||
this.buttonColor,
|
||||
this.borderColor,
|
||||
this.textStyle,
|
||||
this.hintStyle,
|
||||
this.validator});
|
||||
|
||||
static const prefixIconWidth = 34.0;
|
||||
static const prefixIconHeight = 34.0;
|
||||
@@ -34,6 +39,9 @@ class AddressTextField extends StatelessWidget {
|
||||
final FormFieldValidator<String> validator;
|
||||
final bool isBorderExist;
|
||||
final Color buttonColor;
|
||||
final Color borderColor;
|
||||
final TextStyle textStyle;
|
||||
final TextStyle hintStyle;
|
||||
FocusNode focusNode;
|
||||
|
||||
@override
|
||||
@@ -45,106 +53,125 @@ class AddressTextField extends StatelessWidget {
|
||||
enabled: isActive,
|
||||
controller: controller,
|
||||
focusNode: focusNode,
|
||||
style: TextStyle(
|
||||
style: textStyle ?? TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).primaryTextTheme.title.color
|
||||
color: Colors.white
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
suffixIcon: SizedBox(
|
||||
width: prefixIconWidth * options.length +
|
||||
(spaceBetweenPrefixIcons * options.length),
|
||||
),
|
||||
hintStyle: TextStyle(
|
||||
hintStyle: hintStyle ?? TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).primaryTextTheme.caption.color
|
||||
color: PaletteDark.darkCyanBlue
|
||||
),
|
||||
hintText: placeholder ?? S.current.widgets_address,
|
||||
focusedBorder: isBorderExist
|
||||
? UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
color: borderColor ?? Theme.of(context).dividerColor,
|
||||
width: 1.0))
|
||||
: InputBorder.none,
|
||||
disabledBorder: isBorderExist
|
||||
? UnderlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Theme.of(context).dividerColor, width: 1.0))
|
||||
BorderSide(color: borderColor ?? Theme.of(context).dividerColor, width: 1.0))
|
||||
: InputBorder.none,
|
||||
enabledBorder: isBorderExist
|
||||
? UnderlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: Theme.of(context).dividerColor, width: 1.0))
|
||||
BorderSide(color: borderColor ?? Theme.of(context).dividerColor, width: 1.0))
|
||||
: InputBorder.none,
|
||||
),
|
||||
validator: validator,
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
right: 0,
|
||||
child: SizedBox(
|
||||
width: prefixIconWidth * options.length +
|
||||
(spaceBetweenPrefixIcons * options.length),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(width: 5),
|
||||
if (this.options.contains(AddressTextFieldOption.qrCode)) ...[
|
||||
Container(
|
||||
width: prefixIconWidth,
|
||||
height: prefixIconHeight,
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: InkWell(
|
||||
onTap: () async => _presentQRScanner(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6))),
|
||||
child: Image.asset('assets/images/qr_code_icon.png')),
|
||||
))
|
||||
top: 2,
|
||||
right: 0,
|
||||
child: SizedBox(
|
||||
width: prefixIconWidth * options.length +
|
||||
(spaceBetweenPrefixIcons * options.length),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(width: 5),
|
||||
if (this
|
||||
.options
|
||||
.contains(AddressTextFieldOption.paste)) ...[
|
||||
Container(
|
||||
width: prefixIconWidth,
|
||||
height: prefixIconHeight,
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: InkWell(
|
||||
onTap: () async => _pasteAddress(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6))),
|
||||
child: Image.asset(
|
||||
'assets/images/duplicate.png')),
|
||||
)),
|
||||
],
|
||||
if (this.options.contains(AddressTextFieldOption.qrCode)) ...[
|
||||
Container(
|
||||
width: prefixIconWidth,
|
||||
height: prefixIconHeight,
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: InkWell(
|
||||
onTap: () async => _presentQRScanner(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6))),
|
||||
child: Image.asset('assets/images/qr_code_icon.png')),
|
||||
))
|
||||
],
|
||||
if (this
|
||||
.options
|
||||
.contains(AddressTextFieldOption.addressBook)) ...[
|
||||
Container(
|
||||
width: prefixIconWidth,
|
||||
height: prefixIconHeight,
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: InkWell(
|
||||
onTap: () async => _presetAddressBookPicker(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6))),
|
||||
child: Image.asset(
|
||||
'assets/images/open_book.png')),
|
||||
))
|
||||
],
|
||||
if (this
|
||||
.options
|
||||
.contains(AddressTextFieldOption.subaddressList)) ...[
|
||||
Container(
|
||||
width: prefixIconWidth,
|
||||
height: prefixIconHeight,
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: InkWell(
|
||||
onTap: () async => _presetSubaddressListPicker(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6))),
|
||||
child: Image.asset(
|
||||
'assets/images/receive_icon_raw.png')),
|
||||
)),
|
||||
],
|
||||
],
|
||||
if (this
|
||||
.options
|
||||
.contains(AddressTextFieldOption.addressBook)) ...[
|
||||
Container(
|
||||
width: prefixIconWidth,
|
||||
height: prefixIconHeight,
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: InkWell(
|
||||
onTap: () async => _presetAddressBookPicker(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6))),
|
||||
child: Image.asset(
|
||||
'assets/images/open_book.png')),
|
||||
))
|
||||
],
|
||||
if (this
|
||||
.options
|
||||
.contains(AddressTextFieldOption.subaddressList)) ...[
|
||||
Container(
|
||||
width: prefixIconWidth,
|
||||
height: prefixIconHeight,
|
||||
padding: EdgeInsets.only(top: 0),
|
||||
child: InkWell(
|
||||
onTap: () async => _presetSubaddressListPicker(context),
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: buttonColor ?? Theme.of(context).accentTextTheme.title.color,
|
||||
borderRadius:
|
||||
BorderRadius.all(Radius.circular(6))),
|
||||
child: Image.asset(
|
||||
'assets/images/receive_icon_raw.png')),
|
||||
))
|
||||
],
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
@@ -189,4 +216,14 @@ class AddressTextField extends StatelessWidget {
|
||||
controller.text = subaddress.address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _pasteAddress(BuildContext context) async {
|
||||
String address;
|
||||
|
||||
await Clipboard.getData('text/plain').then((value) => address = value.text);
|
||||
|
||||
if (address.isNotEmpty) {
|
||||
controller.text = address;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,12 @@ class BaseTextFormField extends StatelessWidget {
|
||||
this.hintColor,
|
||||
this.borderColor,
|
||||
this.prefix,
|
||||
this.prefixIcon,
|
||||
this.suffix,
|
||||
this.suffixIcon,
|
||||
this.enabled = true,
|
||||
this.validator,
|
||||
this.textStyle,
|
||||
this.placeholderTextStyle});
|
||||
|
||||
final TextEditingController controller;
|
||||
@@ -33,11 +35,13 @@ class BaseTextFormField extends StatelessWidget {
|
||||
final Color hintColor;
|
||||
final Color borderColor;
|
||||
final Widget prefix;
|
||||
final Widget prefixIcon;
|
||||
final Widget suffix;
|
||||
final Widget suffixIcon;
|
||||
final bool enabled;
|
||||
final FormFieldValidator<String> validator;
|
||||
final TextStyle placeholderTextStyle;
|
||||
final TextStyle textStyle;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -50,11 +54,12 @@ class BaseTextFormField extends StatelessWidget {
|
||||
maxLines: maxLines,
|
||||
inputFormatters: inputFormatters,
|
||||
enabled: enabled,
|
||||
style: TextStyle(
|
||||
style: textStyle ?? TextStyle(
|
||||
fontSize: 16.0,
|
||||
color: textColor ?? Theme.of(context).primaryTextTheme.title.color),
|
||||
decoration: InputDecoration(
|
||||
prefix: prefix,
|
||||
prefixIcon: prefixIcon,
|
||||
suffix: suffix,
|
||||
suffixIcon: suffixIcon,
|
||||
hintStyle: placeholderTextStyle ??
|
||||
|
||||
@@ -1,77 +1,154 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
|
||||
class TemplateTile extends StatelessWidget {
|
||||
class TemplateTile extends StatefulWidget {
|
||||
TemplateTile({
|
||||
Key key,
|
||||
@required this.to,
|
||||
@required this.amount,
|
||||
@required this.from,
|
||||
@required this.onTap
|
||||
});
|
||||
@required this.onTap,
|
||||
@required this.onRemove
|
||||
}) : super(key: key);
|
||||
|
||||
final String to;
|
||||
final String amount;
|
||||
final String from;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback onRemove;
|
||||
|
||||
@override
|
||||
TemplateTileState createState() => TemplateTileState(
|
||||
to,
|
||||
amount,
|
||||
from,
|
||||
onTap,
|
||||
onRemove
|
||||
);
|
||||
}
|
||||
|
||||
class TemplateTileState extends State<TemplateTile> {
|
||||
TemplateTileState(
|
||||
this.to,
|
||||
this.amount,
|
||||
this.from,
|
||||
this.onTap,
|
||||
this.onRemove
|
||||
);
|
||||
|
||||
final String to;
|
||||
final String amount;
|
||||
final String from;
|
||||
final VoidCallback onTap;
|
||||
final VoidCallback onRemove;
|
||||
final trash = Image.asset('assets/images/trash.png', height: 16, width: 16, color: Colors.white);
|
||||
|
||||
bool isRemovable = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final toIcon = Image.asset('assets/images/to_icon.png',
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
);
|
||||
//final color = isRemovable ? Colors.white : Theme.of(context).primaryTextTheme.title.color;
|
||||
final color = Colors.white;
|
||||
final toIcon = Image.asset('assets/images/to_icon.png', color: color);
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
height: 40,
|
||||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
color: Theme.of(context).accentTextTheme.title.backgroundColor
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
amount,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).primaryTextTheme.title.color
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
from,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).primaryTextTheme.title.color
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: toIcon,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
to,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).primaryTextTheme.title.color
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
final content = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
amount,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
from,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: toIcon,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: 5),
|
||||
child: Text(
|
||||
to,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final tile = Container(
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
child: GestureDetector(
|
||||
onTap: onTap,
|
||||
onLongPress: () {
|
||||
setState(() {
|
||||
isRemovable = true;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
color: PaletteDark.darkVioletBlue,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
final removableTile = Container(
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
isRemovable = false;
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
height: 40,
|
||||
padding: EdgeInsets.only(left: 24, right: 10),
|
||||
color: Colors.red,
|
||||
child: content,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: onRemove,
|
||||
child: Container(
|
||||
height: 40,
|
||||
width: 44,
|
||||
color: Palette.darkRed,
|
||||
child: Center(
|
||||
child: trash,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return isRemovable ? removableTile : tile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user