mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-17 01:37:40 +00:00
save
This commit is contained in:
parent
b6de1be6c4
commit
ed5a139490
1 changed files with 49 additions and 70 deletions
|
@ -66,9 +66,8 @@ class SendPage extends BasePage {
|
||||||
color: titleColor(context),
|
color: titleColor(context),
|
||||||
size: 16,
|
size: 16,
|
||||||
);
|
);
|
||||||
final _closeButton = currentTheme.type == ThemeType.dark
|
final _closeButton =
|
||||||
? closeButtonImageDarkTheme
|
currentTheme.type == ThemeType.dark ? closeButtonImageDarkTheme : closeButtonImage;
|
||||||
: closeButtonImage;
|
|
||||||
|
|
||||||
bool isMobileView = ResponsiveLayoutUtil.instance.isMobile;
|
bool isMobileView = ResponsiveLayoutUtil.instance.isMobile;
|
||||||
|
|
||||||
|
@ -79,13 +78,10 @@ class SendPage extends BasePage {
|
||||||
child: ButtonTheme(
|
child: ButtonTheme(
|
||||||
minWidth: double.minPositive,
|
minWidth: double.minPositive,
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
label: !isMobileView
|
label: !isMobileView ? S.of(context).close : S.of(context).seed_alert_back,
|
||||||
? S.of(context).close
|
|
||||||
: S.of(context).seed_alert_back,
|
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
overlayColor: MaterialStateColor.resolveWith(
|
overlayColor: MaterialStateColor.resolveWith((states) => Colors.transparent),
|
||||||
(states) => Colors.transparent),
|
|
||||||
),
|
),
|
||||||
onPressed: () => onClose(context),
|
onPressed: () => onClose(context),
|
||||||
child: !isMobileView ? _closeButton : _backButton,
|
child: !isMobileView ? _closeButton : _backButton,
|
||||||
|
@ -123,8 +119,7 @@ class SendPage extends BasePage {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(right: 8.0),
|
padding: const EdgeInsets.only(right: 8.0),
|
||||||
child: Observer(
|
child: Observer(
|
||||||
builder: (_) =>
|
builder: (_) => SyncIndicatorIcon(isSynced: sendViewModel.isReadyForSend),
|
||||||
SyncIndicatorIcon(isSynced: sendViewModel.isReadyForSend),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (supMiddle != null) supMiddle
|
if (supMiddle != null) supMiddle
|
||||||
|
@ -158,10 +153,10 @@ class SendPage extends BasePage {
|
||||||
_setEffects(context);
|
_setEffects(context);
|
||||||
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onLongPress: () => sendViewModel.balanceViewModel.isReversing =
|
onLongPress: () =>
|
||||||
!sendViewModel.balanceViewModel.isReversing,
|
sendViewModel.balanceViewModel.isReversing = !sendViewModel.balanceViewModel.isReversing,
|
||||||
onLongPressUp: () => sendViewModel.balanceViewModel.isReversing =
|
onLongPressUp: () =>
|
||||||
!sendViewModel.balanceViewModel.isReversing,
|
sendViewModel.balanceViewModel.isReversing = !sendViewModel.balanceViewModel.isReversing,
|
||||||
child: Form(
|
child: Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: ScrollableWithBottomSection(
|
child: ScrollableWithBottomSection(
|
||||||
|
@ -191,8 +186,7 @@ class SendPage extends BasePage {
|
||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(top: 10, left: 24, right: 24, bottom: 10),
|
||||||
top: 10, left: 24, right: 24, bottom: 10),
|
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 10,
|
height: 10,
|
||||||
child: Observer(
|
child: Observer(
|
||||||
|
@ -208,8 +202,12 @@ class SendPage extends BasePage {
|
||||||
radius: 6.0,
|
radius: 6.0,
|
||||||
dotWidth: 6.0,
|
dotWidth: 6.0,
|
||||||
dotHeight: 6.0,
|
dotHeight: 6.0,
|
||||||
dotColor: Theme.of(context).extension<SendPageTheme>()!.indicatorDotColor,
|
dotColor: Theme.of(context)
|
||||||
activeDotColor: Theme.of(context).extension<SendPageTheme>()!.templateBackgroundColor),
|
.extension<SendPageTheme>()!
|
||||||
|
.indicatorDotColor,
|
||||||
|
activeDotColor: Theme.of(context)
|
||||||
|
.extension<SendPageTheme>()!
|
||||||
|
.templateBackgroundColor),
|
||||||
)
|
)
|
||||||
: Offstage();
|
: Offstage();
|
||||||
},
|
},
|
||||||
|
@ -230,8 +228,7 @@ class SendPage extends BasePage {
|
||||||
return Row(
|
return Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
AddTemplateButton(
|
AddTemplateButton(
|
||||||
onTap: () => Navigator.of(context)
|
onTap: () => Navigator.of(context).pushNamed(Routes.sendTemplate),
|
||||||
.pushNamed(Routes.sendTemplate),
|
|
||||||
currentTemplatesLength: templates.length,
|
currentTemplatesLength: templates.length,
|
||||||
),
|
),
|
||||||
ListView.builder(
|
ListView.builder(
|
||||||
|
@ -244,8 +241,7 @@ class SendPage extends BasePage {
|
||||||
return TemplateTile(
|
return TemplateTile(
|
||||||
key: UniqueKey(),
|
key: UniqueKey(),
|
||||||
to: template.name,
|
to: template.name,
|
||||||
hasMultipleRecipients:
|
hasMultipleRecipients: template.additionalRecipients != null &&
|
||||||
template.additionalRecipients != null &&
|
|
||||||
template.additionalRecipients!.length > 1,
|
template.additionalRecipients!.length > 1,
|
||||||
amount: template.isCurrencySelected
|
amount: template.isCurrencySelected
|
||||||
? template.amount
|
? template.amount
|
||||||
|
@ -257,7 +253,9 @@ class SendPage extends BasePage {
|
||||||
if (template.additionalRecipients?.isNotEmpty ?? false) {
|
if (template.additionalRecipients?.isNotEmpty ?? false) {
|
||||||
sendViewModel.clearOutputs();
|
sendViewModel.clearOutputs();
|
||||||
|
|
||||||
for (int i = 0;i < template.additionalRecipients!.length;i++) {
|
for (int i = 0;
|
||||||
|
i < template.additionalRecipients!.length;
|
||||||
|
i++) {
|
||||||
Output output;
|
Output output;
|
||||||
try {
|
try {
|
||||||
output = sendViewModel.outputs[i];
|
output = sendViewModel.outputs[i];
|
||||||
|
@ -286,26 +284,17 @@ class SendPage extends BasePage {
|
||||||
context: context,
|
context: context,
|
||||||
builder: (dialogContext) {
|
builder: (dialogContext) {
|
||||||
return AlertWithTwoActions(
|
return AlertWithTwoActions(
|
||||||
alertTitle:
|
alertTitle: S.of(context).template,
|
||||||
S.of(context).template,
|
alertContent: S.of(context).confirm_delete_template,
|
||||||
alertContent: S
|
rightButtonText: S.of(context).delete,
|
||||||
.of(context)
|
leftButtonText: S.of(context).cancel,
|
||||||
.confirm_delete_template,
|
|
||||||
rightButtonText:
|
|
||||||
S.of(context).delete,
|
|
||||||
leftButtonText:
|
|
||||||
S.of(context).cancel,
|
|
||||||
actionRightButton: () {
|
actionRightButton: () {
|
||||||
Navigator.of(dialogContext)
|
Navigator.of(dialogContext).pop();
|
||||||
.pop();
|
sendViewModel.sendTemplateViewModel
|
||||||
sendViewModel
|
.removeTemplate(template: template);
|
||||||
.sendTemplateViewModel
|
|
||||||
.removeTemplate(
|
|
||||||
template: template);
|
|
||||||
},
|
},
|
||||||
actionLeftButton: () =>
|
actionLeftButton: () =>
|
||||||
Navigator.of(dialogContext)
|
Navigator.of(dialogContext).pop());
|
||||||
.pop());
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -321,8 +310,7 @@ class SendPage extends BasePage {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
bottomSectionPadding:
|
bottomSectionPadding: EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
||||||
EdgeInsets.only(left: 24, right: 24, bottom: 24),
|
|
||||||
bottomSection: Column(
|
bottomSection: Column(
|
||||||
children: [
|
children: [
|
||||||
if (sendViewModel.hasCurrecyChanger)
|
if (sendViewModel.hasCurrecyChanger)
|
||||||
|
@ -331,10 +319,10 @@ class SendPage extends BasePage {
|
||||||
padding: EdgeInsets.only(bottom: 12),
|
padding: EdgeInsets.only(bottom: 12),
|
||||||
child: PrimaryButton(
|
child: PrimaryButton(
|
||||||
onPressed: () => presentCurrencyPicker(context),
|
onPressed: () => presentCurrencyPicker(context),
|
||||||
text:
|
text: 'Change your asset (${sendViewModel.selectedCryptoCurrency})',
|
||||||
'Change your asset (${sendViewModel.selectedCryptoCurrency})',
|
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
textColor: Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
|
textColor:
|
||||||
|
Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
|
||||||
))),
|
))),
|
||||||
if (sendViewModel.sendTemplateViewModel.hasMultiRecipient)
|
if (sendViewModel.sendTemplateViewModel.hasMultiRecipient)
|
||||||
Padding(
|
Padding(
|
||||||
|
@ -343,22 +331,21 @@ class SendPage extends BasePage {
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
sendViewModel.addOutput();
|
sendViewModel.addOutput();
|
||||||
Future.delayed(const Duration(milliseconds: 250), () {
|
Future.delayed(const Duration(milliseconds: 250), () {
|
||||||
controller
|
controller.jumpToPage(sendViewModel.outputs.length - 1);
|
||||||
.jumpToPage(sendViewModel.outputs.length - 1);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
text: S.of(context).add_receiver,
|
text: S.of(context).add_receiver,
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
textColor: Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
|
textColor: Theme.of(context).extension<SeedWidgetTheme>()!.hintTextColor,
|
||||||
isDottedBorder: true,
|
isDottedBorder: true,
|
||||||
borderColor: Theme.of(context).extension<SendPageTheme>()!.templateDottedBorderColor,
|
borderColor:
|
||||||
|
Theme.of(context).extension<SendPageTheme>()!.templateDottedBorderColor,
|
||||||
)),
|
)),
|
||||||
Observer(
|
Observer(
|
||||||
builder: (_) {
|
builder: (_) {
|
||||||
return LoadingPrimaryButton(
|
return LoadingPrimaryButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
if (_formKey.currentState != null &&
|
if (_formKey.currentState != null && !_formKey.currentState!.validate()) {
|
||||||
!_formKey.currentState!.validate()) {
|
|
||||||
if (sendViewModel.outputs.length > 1) {
|
if (sendViewModel.outputs.length > 1) {
|
||||||
showErrorValidationAlert(context);
|
showErrorValidationAlert(context);
|
||||||
}
|
}
|
||||||
|
@ -367,9 +354,7 @@ class SendPage extends BasePage {
|
||||||
}
|
}
|
||||||
|
|
||||||
final notValidItems = sendViewModel.outputs
|
final notValidItems = sendViewModel.outputs
|
||||||
.where((item) =>
|
.where((item) => item.address.isEmpty || item.cryptoAmount.isEmpty)
|
||||||
item.address.isEmpty ||
|
|
||||||
item.cryptoAmount.isEmpty)
|
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (notValidItems.isNotEmpty) {
|
if (notValidItems.isNotEmpty) {
|
||||||
|
@ -389,8 +374,7 @@ class SendPage extends BasePage {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
text: S.of(context).send,
|
text: S.of(context).send,
|
||||||
color:
|
color: Theme.of(context).primaryColor,
|
||||||
Theme.of(context).primaryColor,
|
|
||||||
textColor: Colors.white,
|
textColor: Colors.white,
|
||||||
isLoading: sendViewModel.state is IsExecutingState ||
|
isLoading: sendViewModel.state is IsExecutingState ||
|
||||||
sendViewModel.state is TransactionCommitting,
|
sendViewModel.state is TransactionCommitting,
|
||||||
|
@ -433,14 +417,11 @@ class SendPage extends BasePage {
|
||||||
return ConfirmSendingAlert(
|
return ConfirmSendingAlert(
|
||||||
alertTitle: S.of(context).confirm_sending,
|
alertTitle: S.of(context).confirm_sending,
|
||||||
amount: S.of(context).send_amount,
|
amount: S.of(context).send_amount,
|
||||||
amountValue:
|
amountValue: sendViewModel.pendingTransaction!.amountFormatted,
|
||||||
sendViewModel.pendingTransaction!.amountFormatted,
|
fiatAmountValue: sendViewModel.pendingTransactionFiatAmountFormatted,
|
||||||
fiatAmountValue:
|
|
||||||
sendViewModel.pendingTransactionFiatAmountFormatted,
|
|
||||||
fee: S.of(context).send_fee,
|
fee: S.of(context).send_fee,
|
||||||
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
|
feeValue: sendViewModel.pendingTransaction!.feeFormatted,
|
||||||
feeFiatAmount: sendViewModel
|
feeFiatAmount: sendViewModel.pendingTransactionFeeFiatAmountFormatted,
|
||||||
.pendingTransactionFeeFiatAmountFormatted,
|
|
||||||
outputs: sendViewModel.outputs,
|
outputs: sendViewModel.outputs,
|
||||||
rightButtonText: S.of(context).ok,
|
rightButtonText: S.of(context).ok,
|
||||||
leftButtonText: S.of(context).cancel,
|
leftButtonText: S.of(context).cancel,
|
||||||
|
@ -461,8 +442,7 @@ class SendPage extends BasePage {
|
||||||
return AlertWithOneAction(
|
return AlertWithOneAction(
|
||||||
alertTitle: '',
|
alertTitle: '',
|
||||||
alertContent: S.of(context).send_success(
|
alertContent: S.of(context).send_success(
|
||||||
sendViewModel.selectedCryptoCurrency
|
sendViewModel.selectedCryptoCurrency.toString()),
|
||||||
.toString()),
|
|
||||||
buttonText: S.of(context).ok,
|
buttonText: S.of(context).ok,
|
||||||
buttonAction: () {
|
buttonAction: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
@ -492,8 +472,8 @@ class SendPage extends BasePage {
|
||||||
|
|
||||||
Future<void> _setInputsFromTemplate(BuildContext context,
|
Future<void> _setInputsFromTemplate(BuildContext context,
|
||||||
{required Output output, required Template template}) async {
|
{required Output output, required Template template}) async {
|
||||||
final fiatFromTemplate = FiatCurrency.all
|
final fiatFromTemplate =
|
||||||
.singleWhere((element) => element.title == template.fiatCurrency);
|
FiatCurrency.all.singleWhere((element) => element.title == template.fiatCurrency);
|
||||||
|
|
||||||
output.address = template.address;
|
output.address = template.address;
|
||||||
|
|
||||||
|
@ -534,12 +514,11 @@ class SendPage extends BasePage {
|
||||||
builder: (_) => Picker(
|
builder: (_) => Picker(
|
||||||
items: sendViewModel.currencies,
|
items: sendViewModel.currencies,
|
||||||
displayItem: (Object item) => item.toString(),
|
displayItem: (Object item) => item.toString(),
|
||||||
selectedAtIndex: sendViewModel.currencies
|
selectedAtIndex:
|
||||||
.indexOf(sendViewModel.selectedCryptoCurrency),
|
sendViewModel.currencies.indexOf(sendViewModel.selectedCryptoCurrency),
|
||||||
title: S.of(context).please_select,
|
title: S.of(context).please_select,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
onItemSelected: (CryptoCurrency cur) =>
|
onItemSelected: (CryptoCurrency cur) => sendViewModel.selectedCryptoCurrency = cur,
|
||||||
sendViewModel.selectedCryptoCurrency = cur,
|
|
||||||
),
|
),
|
||||||
context: context);
|
context: context);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue