mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-20 06:08:34 +02:00
Merge branch 'main' of https://github.com/cake-tech/cake_wallet into CW-66-open-app-from-qr-code
Conflicts: res/values/strings_de.arb res/values/strings_en.arb res/values/strings_es.arb res/values/strings_fr.arb res/values/strings_hi.arb res/values/strings_hr.arb res/values/strings_it.arb res/values/strings_ja.arb res/values/strings_ko.arb res/values/strings_nl.arb res/values/strings_pl.arb res/values/strings_pt.arb res/values/strings_ru.arb res/values/strings_uk.arb res/values/strings_zh.arb
This commit is contained in:
@@ -705,6 +705,7 @@ Future setup(
|
||||
ioniaAnyPayService: getIt.get<IoniaAnyPay>(),
|
||||
amount: amount,
|
||||
ioniaMerchant: merchant,
|
||||
sendViewModel: getIt.get<SendViewModel>()
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ class PreferencesKey {
|
||||
static const shouldSaveRecipientAddressKey = 'save_recipient_address';
|
||||
static const allowBiometricalAuthenticationKey =
|
||||
'allow_biometrical_authentication';
|
||||
static const disableExchangeKey = 'disable_exchange';
|
||||
static const currentTheme = 'current_theme';
|
||||
static const isDarkThemeLegacy = 'dark_theme';
|
||||
static const displayActionListModeKey = 'display_list_mode';
|
||||
|
||||
@@ -232,7 +232,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final fromAmount = double.parse(responseJSON['fromAmount'].toString());
|
||||
final toAmount = double.parse(responseJSON['toAmount'].toString());
|
||||
final rateId = responseJSON['rateId'] as String ?? '';
|
||||
final rateId = responseJSON['rateId'] as String? ?? '';
|
||||
|
||||
if (rateId.isNotEmpty) {
|
||||
_lastUsedRateId = rateId;
|
||||
|
||||
@@ -315,6 +315,8 @@ class DashboardPage extends BasePage {
|
||||
}
|
||||
|
||||
Future<void> _onClickExchangeButton(BuildContext context) async {
|
||||
await Navigator.of(context).pushNamed(Routes.exchange);
|
||||
if (walletViewModel.isEnabledExchangeAction) {
|
||||
await Navigator.of(context).pushNamed(Routes.exchange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/widgets/confirm_modal.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/widgets/ionia_alert_model.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/widgets/text_icon_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
@@ -18,6 +17,7 @@ import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/send/widgets/confirm_sending_alert.dart';
|
||||
|
||||
class IoniaBuyGiftCardDetailPage extends BasePage {
|
||||
IoniaBuyGiftCardDetailPage(this.ioniaPurchaseViewModel);
|
||||
@@ -295,73 +295,35 @@ class IoniaBuyGiftCardDetailPage extends BasePage {
|
||||
|
||||
final amount = ioniaPurchaseViewModel.invoice!.totalAmount;
|
||||
final addresses = ioniaPurchaseViewModel.invoice!.outAddresses;
|
||||
ioniaPurchaseViewModel.sendViewModel.outputs.first.setCryptoAmount(amount);
|
||||
ioniaPurchaseViewModel.sendViewModel.outputs.first.address = addresses.first;
|
||||
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (_) {
|
||||
return IoniaConfirmModal(
|
||||
return ConfirmSendingAlert(
|
||||
alertTitle: S.of(context).confirm_sending,
|
||||
alertContent: Container(
|
||||
height: 200,
|
||||
padding: EdgeInsets.all(15),
|
||||
child: Column(children: [
|
||||
Row(children: [
|
||||
Text(S.of(context).payment_id,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: PaletteDark.pigeonBlue,
|
||||
decoration: TextDecoration.none)),
|
||||
Text(ioniaPurchaseViewModel.invoice!.paymentId,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: PaletteDark.pigeonBlue,
|
||||
decoration: TextDecoration.none))
|
||||
], mainAxisAlignment: MainAxisAlignment.spaceBetween),
|
||||
SizedBox(height: 10),
|
||||
Row(children: [
|
||||
Text(S.of(context).amount,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: PaletteDark.pigeonBlue,
|
||||
decoration: TextDecoration.none)),
|
||||
Text('$amount ${ioniaPurchaseViewModel.invoice!.chain}',
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: PaletteDark.pigeonBlue,
|
||||
decoration: TextDecoration.none))
|
||||
], mainAxisAlignment: MainAxisAlignment.spaceBetween),
|
||||
SizedBox(height: 25),
|
||||
Row(children: [
|
||||
Text(S.of(context).recipient_address,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: PaletteDark.pigeonBlue,
|
||||
decoration: TextDecoration.none))
|
||||
], mainAxisAlignment: MainAxisAlignment.center),
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
itemBuilder: (_, int index) {
|
||||
return Text(addresses[index],
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w400,
|
||||
color: PaletteDark.pigeonBlue,
|
||||
decoration: TextDecoration.none));
|
||||
},
|
||||
itemCount: addresses.length,
|
||||
physics: NeverScrollableScrollPhysics()))
|
||||
])),
|
||||
paymentId: S.of(context).payment_id,
|
||||
paymentIdValue: ioniaPurchaseViewModel.invoice!.paymentId,
|
||||
amount: S.of(context).send_amount,
|
||||
amountValue: '$amount ${ioniaPurchaseViewModel.invoice!.chain}',
|
||||
fiatAmountValue:
|
||||
'~ ${ioniaPurchaseViewModel.sendViewModel.outputs.first.fiatAmount} '
|
||||
'${ioniaPurchaseViewModel.sendViewModel.fiat.title}',
|
||||
fee: S.of(context).send_fee,
|
||||
feeValue:
|
||||
'${ioniaPurchaseViewModel.sendViewModel.outputs.first.estimatedFee} '
|
||||
'${ioniaPurchaseViewModel.invoice!.chain}',
|
||||
feeFiatAmount:
|
||||
'${ioniaPurchaseViewModel.sendViewModel.outputs.first.estimatedFeeFiatAmount} '
|
||||
'${ioniaPurchaseViewModel.sendViewModel.fiat.title}',
|
||||
outputs: ioniaPurchaseViewModel.sendViewModel.outputs,
|
||||
rightButtonText: S.of(context).ok,
|
||||
leftButtonText: S.of(context).cancel,
|
||||
leftActionColor: Color(0xffFF6600),
|
||||
rightActionColor: Theme.of(context).accentTextTheme!.bodyText1!.color!,
|
||||
alertLeftActionButtonTextColor: Colors.white,
|
||||
alertRightActionButtonTextColor: Colors.white,
|
||||
alertLeftActionButtonColor: Palette.brightOrange,
|
||||
alertRightActionButtonColor: Theme.of(context).textTheme!.subtitle2!.color,
|
||||
actionRightButton: () async {
|
||||
Navigator.of(context).pop();
|
||||
await ioniaPurchaseViewModel.commitPaymentInvoice();
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class IoniaConfirmModal extends StatelessWidget {
|
||||
IoniaConfirmModal({
|
||||
required this.alertTitle,
|
||||
required this.alertContent,
|
||||
required this.leftButtonText,
|
||||
required this.rightButtonText,
|
||||
required this.actionLeftButton,
|
||||
required this.actionRightButton,
|
||||
required this.leftActionColor,
|
||||
required this.rightActionColor,
|
||||
this.hideActions = false,
|
||||
});
|
||||
|
||||
final String alertTitle;
|
||||
final Widget alertContent;
|
||||
final String leftButtonText;
|
||||
final String rightButtonText;
|
||||
final VoidCallback actionLeftButton;
|
||||
final VoidCallback actionRightButton;
|
||||
final Color leftActionColor;
|
||||
final Color rightActionColor;
|
||||
final bool hideActions;
|
||||
|
||||
Widget actionButtons(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: <Widget>[
|
||||
IoniaActionButton(
|
||||
buttonText: leftButtonText,
|
||||
action: actionLeftButton,
|
||||
backgoundColor: leftActionColor,
|
||||
),
|
||||
Container(
|
||||
width: 1,
|
||||
height: 52,
|
||||
color: Theme.of(context).dividerColor,
|
||||
),
|
||||
IoniaActionButton(
|
||||
buttonText: rightButtonText,
|
||||
action: actionRightButton,
|
||||
backgoundColor: rightActionColor,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget title(BuildContext context) {
|
||||
return Text(
|
||||
alertTitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).primaryTextTheme!.headline6!.color!,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Colors.transparent,
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 3.0, sigmaY: 3.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(color: PaletteDark.darkNightBlue.withOpacity(0.75)),
|
||||
child: Center(
|
||||
child: GestureDetector(
|
||||
onTap: () => null,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.all(Radius.circular(30)),
|
||||
child: Container(
|
||||
width: 327,
|
||||
color: Theme.of(context).accentTextTheme!.headline6!.decorationColor!,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.fromLTRB(24, 20, 24, 0),
|
||||
child: title(context),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 16, bottom: 8),
|
||||
child: Container(
|
||||
height: 1,
|
||||
color: Theme.of(context).dividerColor,
|
||||
),
|
||||
),
|
||||
alertContent,
|
||||
actionButtons(context),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class IoniaActionButton extends StatelessWidget {
|
||||
const IoniaActionButton({
|
||||
required this.buttonText,
|
||||
required this.action,
|
||||
required this.backgoundColor,
|
||||
});
|
||||
|
||||
final String buttonText;
|
||||
final VoidCallback action;
|
||||
final Color backgoundColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Flexible(
|
||||
child: Container(
|
||||
height: 52,
|
||||
padding: EdgeInsets.only(left: 6, right: 6),
|
||||
color: backgoundColor,
|
||||
child: ButtonTheme(
|
||||
minWidth: double.infinity,
|
||||
child: TextButton(
|
||||
onPressed: action,
|
||||
// FIX-ME: ignored highlightColor and splashColor
|
||||
//highlightColor: Colors.transparent,
|
||||
//splashColor: Colors.transparent,
|
||||
child: Text(
|
||||
buttonText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w600,
|
||||
color: backgoundColor != null ? Colors.white : Theme.of(context).primaryTextTheme!.bodyText2!.backgroundColor!,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
)),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ class QrPainter extends CustomPainter {
|
||||
this.errorCorrectionLevel,
|
||||
) : this._qr = QrCode(version, errorCorrectionLevel)..addData(data) {
|
||||
_p.color = this.color;
|
||||
_qr.addData(data);
|
||||
_qrImage = QrImage(_qr);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/src/widgets/base_alert_dialog.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/widgets/cake_scrollbar.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
ConfirmSendingAlert({
|
||||
required this.alertTitle,
|
||||
this.paymentId,
|
||||
this.paymentIdValue,
|
||||
required this.amount,
|
||||
required this.amountValue,
|
||||
required this.fiatAmountValue,
|
||||
@@ -19,9 +22,15 @@ class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
required this.rightButtonText,
|
||||
required this.actionLeftButton,
|
||||
required this.actionRightButton,
|
||||
this.alertBarrierDismissible = true});
|
||||
this.alertBarrierDismissible = true,
|
||||
this.alertLeftActionButtonTextColor,
|
||||
this.alertRightActionButtonTextColor,
|
||||
this.alertLeftActionButtonColor,
|
||||
this.alertRightActionButtonColor});
|
||||
|
||||
final String alertTitle;
|
||||
final String? paymentId;
|
||||
final String? paymentIdValue;
|
||||
final String amount;
|
||||
final String amountValue;
|
||||
final String fiatAmountValue;
|
||||
@@ -34,6 +43,10 @@ class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
final VoidCallback actionLeftButton;
|
||||
final VoidCallback actionRightButton;
|
||||
final bool alertBarrierDismissible;
|
||||
final Color? alertLeftActionButtonTextColor;
|
||||
final Color? alertRightActionButtonTextColor;
|
||||
final Color? alertLeftActionButtonColor;
|
||||
final Color? alertRightActionButtonColor;
|
||||
|
||||
@override
|
||||
String get titleText => alertTitle;
|
||||
@@ -56,8 +69,22 @@ class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
@override
|
||||
bool get barrierDismissible => alertBarrierDismissible;
|
||||
|
||||
@override
|
||||
Color? get leftActionButtonTextColor => alertLeftActionButtonTextColor;
|
||||
|
||||
@override
|
||||
Color? get rightActionButtonTextColor => alertRightActionButtonTextColor;
|
||||
|
||||
@override
|
||||
Color? get leftActionButtonColor => alertLeftActionButtonColor;
|
||||
|
||||
@override
|
||||
Color? get rightActionButtonColor => alertRightActionButtonColor;
|
||||
|
||||
@override
|
||||
Widget content(BuildContext context) => ConfirmSendingAlertContent(
|
||||
paymentId: paymentId,
|
||||
paymentIdValue: paymentIdValue,
|
||||
amount: amount,
|
||||
amountValue: amountValue,
|
||||
fiatAmountValue: fiatAmountValue,
|
||||
@@ -70,6 +97,8 @@ class ConfirmSendingAlert extends BaseAlertDialog {
|
||||
|
||||
class ConfirmSendingAlertContent extends StatefulWidget {
|
||||
ConfirmSendingAlertContent({
|
||||
this.paymentId,
|
||||
this.paymentIdValue,
|
||||
required this.amount,
|
||||
required this.amountValue,
|
||||
required this.fiatAmountValue,
|
||||
@@ -78,6 +107,8 @@ class ConfirmSendingAlertContent extends StatefulWidget {
|
||||
required this.feeFiatAmount,
|
||||
required this.outputs});
|
||||
|
||||
final String? paymentId;
|
||||
final String? paymentIdValue;
|
||||
final String amount;
|
||||
final String amountValue;
|
||||
final String fiatAmountValue;
|
||||
@@ -88,6 +119,8 @@ class ConfirmSendingAlertContent extends StatefulWidget {
|
||||
|
||||
@override
|
||||
ConfirmSendingAlertContentState createState() => ConfirmSendingAlertContentState(
|
||||
paymentId: paymentId,
|
||||
paymentIdValue: paymentIdValue,
|
||||
amount: amount,
|
||||
amountValue: amountValue,
|
||||
fiatAmountValue: fiatAmountValue,
|
||||
@@ -100,6 +133,8 @@ class ConfirmSendingAlertContent extends StatefulWidget {
|
||||
|
||||
class ConfirmSendingAlertContentState extends State<ConfirmSendingAlertContent> {
|
||||
ConfirmSendingAlertContentState({
|
||||
this.paymentId,
|
||||
this.paymentIdValue,
|
||||
required this.amount,
|
||||
required this.amountValue,
|
||||
required this.fiatAmountValue,
|
||||
@@ -115,6 +150,8 @@ class ConfirmSendingAlertContentState extends State<ConfirmSendingAlertContent>
|
||||
: S.current.recipient_address;
|
||||
}
|
||||
|
||||
final String? paymentId;
|
||||
final String? paymentIdValue;
|
||||
final String amount;
|
||||
final String amountValue;
|
||||
final String fiatAmountValue;
|
||||
@@ -129,6 +166,7 @@ class ConfirmSendingAlertContentState extends State<ConfirmSendingAlertContent>
|
||||
double fromTop = 0;
|
||||
String recipientTitle;
|
||||
int itemCount;
|
||||
bool showScrollbar = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -140,6 +178,12 @@ class ConfirmSendingAlertContentState extends State<ConfirmSendingAlertContent>
|
||||
setState(() {});
|
||||
});
|
||||
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
showScrollbar = controller.position.maxScrollExtent > 0;
|
||||
});
|
||||
});
|
||||
|
||||
return Stack(
|
||||
alignment: Alignment.center,
|
||||
clipBehavior: Clip.none,
|
||||
@@ -150,6 +194,44 @@ class ConfirmSendingAlertContentState extends State<ConfirmSendingAlertContent>
|
||||
controller: controller,
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
if (paymentIdValue != null && paymentId != null)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 32),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
paymentId!,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontFamily: 'Lato',
|
||||
color: Theme.of(context).primaryTextTheme!
|
||||
.headline6!.color!,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
paymentIdValue!,
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontFamily: 'Lato',
|
||||
color: Theme.of(context).primaryTextTheme!
|
||||
.headline6!.color!,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@@ -365,7 +447,7 @@ class ConfirmSendingAlertContentState extends State<ConfirmSendingAlertContent>
|
||||
)
|
||||
)
|
||||
),
|
||||
if (itemCount > 1) CakeScrollbar(
|
||||
if (showScrollbar) CakeScrollbar(
|
||||
backgroundHeight: backgroundHeight,
|
||||
thumbHeight: thumbHeight,
|
||||
fromTop: fromTop,
|
||||
|
||||
@@ -11,6 +11,10 @@ class BaseAlertDialog extends StatelessWidget {
|
||||
VoidCallback get actionLeft => () {};
|
||||
VoidCallback get actionRight => () {};
|
||||
bool get barrierDismissible => true;
|
||||
Color? get leftActionButtonTextColor => null;
|
||||
Color? get rightActionButtonTextColor => null;
|
||||
Color? get leftActionButtonColor => null;
|
||||
Color? get rightActionButtonColor => null;
|
||||
|
||||
Widget title(BuildContext context) {
|
||||
return Text(
|
||||
@@ -45,52 +49,64 @@ class BaseAlertDialog extends StatelessWidget {
|
||||
height: 52,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
color: Theme.of(context).accentTextTheme!.bodyText1!.decorationColor!,
|
||||
child: TextButton(
|
||||
onPressed: actionLeft,
|
||||
child: Text(
|
||||
leftActionButtonText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).primaryTextTheme!.bodyText1!.backgroundColor!,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: actionLeft,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: leftActionButtonColor ??
|
||||
Theme.of(context)
|
||||
.accentTextTheme!
|
||||
.bodyText1!
|
||||
.decorationColor!,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.zero))),
|
||||
child: Text(
|
||||
leftActionButtonText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w600,
|
||||
color: leftActionButtonTextColor ??
|
||||
Theme.of(context).primaryTextTheme!
|
||||
.bodyText1!.backgroundColor!,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
)),
|
||||
),
|
||||
Container(
|
||||
width: 1,
|
||||
color: Theme.of(context).dividerColor,
|
||||
),
|
||||
Flexible(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
color: Theme.of(context).accentTextTheme!.bodyText2!.backgroundColor!,
|
||||
child: TextButton(
|
||||
onPressed: actionRight,
|
||||
child: Text(
|
||||
rightActionButtonText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).primaryTextTheme!.bodyText2!.backgroundColor!,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
Expanded(
|
||||
child: TextButton(
|
||||
onPressed: actionRight,
|
||||
style: TextButton.styleFrom(
|
||||
backgroundColor: rightActionButtonColor ??
|
||||
Theme.of(context).accentTextTheme!
|
||||
.bodyText2!.backgroundColor!,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.zero))),
|
||||
child: Text(
|
||||
rightActionButtonText,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontFamily: 'Lato',
|
||||
fontWeight: FontWeight.w600,
|
||||
color: rightActionButtonTextColor ??
|
||||
Theme.of(context)
|
||||
.primaryTextTheme!
|
||||
.bodyText2!
|
||||
.backgroundColor!,
|
||||
decoration: TextDecoration.none,
|
||||
),
|
||||
)),
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -30,6 +30,7 @@ abstract class SettingsStoreBase with Store {
|
||||
required BalanceDisplayMode initialBalanceDisplayMode,
|
||||
required bool initialSaveRecipientAddress,
|
||||
required bool initialAllowBiometricalAuthentication,
|
||||
required bool initialExchangeEnabled,
|
||||
required ThemeBase initialTheme,
|
||||
required int initialPinLength,
|
||||
required String initialLanguageCode,
|
||||
@@ -47,6 +48,7 @@ abstract class SettingsStoreBase with Store {
|
||||
balanceDisplayMode = initialBalanceDisplayMode,
|
||||
shouldSaveRecipientAddress = initialSaveRecipientAddress,
|
||||
allowBiometricalAuthentication = initialAllowBiometricalAuthentication,
|
||||
disableExchange = initialExchangeEnabled,
|
||||
currentTheme = initialTheme,
|
||||
pinCodeLength = initialPinLength,
|
||||
languageCode = initialLanguageCode,
|
||||
@@ -143,6 +145,9 @@ abstract class SettingsStoreBase with Store {
|
||||
@observable
|
||||
bool allowBiometricalAuthentication;
|
||||
|
||||
@observable
|
||||
bool disableExchange;
|
||||
|
||||
@observable
|
||||
ThemeBase currentTheme;
|
||||
|
||||
@@ -221,6 +226,8 @@ abstract class SettingsStoreBase with Store {
|
||||
final allowBiometricalAuthentication = sharedPreferences
|
||||
.getBool(PreferencesKey.allowBiometricalAuthenticationKey) ??
|
||||
false;
|
||||
final disableExchange = sharedPreferences
|
||||
.getBool(PreferencesKey.disableExchangeKey) ?? false;
|
||||
final legacyTheme =
|
||||
(sharedPreferences.getBool(PreferencesKey.isDarkThemeLegacy) ?? false)
|
||||
? ThemeType.dark.index
|
||||
@@ -284,6 +291,7 @@ abstract class SettingsStoreBase with Store {
|
||||
initialBalanceDisplayMode: currentBalanceDisplayMode,
|
||||
initialSaveRecipientAddress: shouldSaveRecipientAddress,
|
||||
initialAllowBiometricalAuthentication: allowBiometricalAuthentication,
|
||||
initialExchangeEnabled: disableExchange,
|
||||
initialTheme: savedTheme,
|
||||
actionlistDisplayMode: actionListDisplayMode,
|
||||
initialPinLength: pinLength,
|
||||
|
||||
@@ -53,7 +53,6 @@ abstract class DashboardViewModelBase with Store {
|
||||
hasBuyAction = false,
|
||||
isEnabledBuyAction = false,
|
||||
hasExchangeAction = false,
|
||||
isEnabledExchangeAction = false,
|
||||
isShowFirstYatIntroduction = false,
|
||||
isShowSecondYatIntroduction = false,
|
||||
isShowThirdYatIntroduction = false,
|
||||
@@ -249,8 +248,8 @@ abstract class DashboardViewModelBase with Store {
|
||||
void furtherShowYatPopup(bool shouldShow) =>
|
||||
settingsStore.shouldShowYatPopup = shouldShow;
|
||||
|
||||
@observable
|
||||
bool isEnabledExchangeAction;
|
||||
@computed
|
||||
bool get isEnabledExchangeAction => !settingsStore.disableExchange;
|
||||
|
||||
@observable
|
||||
bool hasExchangeAction;
|
||||
@@ -365,7 +364,6 @@ abstract class DashboardViewModelBase with Store {
|
||||
}
|
||||
|
||||
void updateActions() {
|
||||
isEnabledExchangeAction = true;
|
||||
hasExchangeAction = !isHaven;
|
||||
isEnabledBuyAction = wallet.type != WalletType.haven
|
||||
&& wallet.type != WalletType.monero;
|
||||
|
||||
@@ -7,7 +7,6 @@ import 'package:cake_wallet/exchange/sideshift/sideshift_exchange_provider.dart'
|
||||
import 'package:cake_wallet/exchange/sideshift/sideshift_request.dart';
|
||||
import 'package:cake_wallet/exchange/simpleswap/simpleswap_exchange_provider.dart';
|
||||
import 'package:cake_wallet/view_model/settings/settings_view_model.dart';
|
||||
import 'package:cw_core/transaction_priority.dart';
|
||||
import 'package:cake_wallet/exchange/simpleswap/simpleswap_request.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/crypto_currency.dart';
|
||||
@@ -375,96 +374,105 @@ abstract class ExchangeViewModelBase with Store {
|
||||
TradeRequest? request;
|
||||
String amount = '';
|
||||
|
||||
for (var provider in _sortedAvailableProviders.values) {
|
||||
if (!(await provider.checkIsAvailable())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
for (var provider in _sortedAvailableProviders.values) {
|
||||
if (!(await provider.checkIsAvailable())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (provider is SideShiftExchangeProvider) {
|
||||
request = SideShiftRequest(
|
||||
depositMethod: depositCurrency,
|
||||
settleMethod: receiveCurrency,
|
||||
depositAmount: depositAmount.replaceAll(',', '.'),
|
||||
settleAddress: receiveAddress,
|
||||
refundAddress: depositAddress,
|
||||
);
|
||||
amount = depositAmount;
|
||||
}
|
||||
if (provider is SideShiftExchangeProvider) {
|
||||
request = SideShiftRequest(
|
||||
depositMethod: depositCurrency,
|
||||
settleMethod: receiveCurrency,
|
||||
depositAmount: depositAmount.replaceAll(',', '.'),
|
||||
settleAddress: receiveAddress,
|
||||
refundAddress: depositAddress,
|
||||
);
|
||||
amount = depositAmount;
|
||||
}
|
||||
|
||||
if (provider is SimpleSwapExchangeProvider) {
|
||||
request = SimpleSwapRequest(
|
||||
from: depositCurrency,
|
||||
to: receiveCurrency,
|
||||
amount: depositAmount.replaceAll(',', '.'),
|
||||
address: receiveAddress,
|
||||
refundAddress: depositAddress,
|
||||
);
|
||||
amount = depositAmount;
|
||||
}
|
||||
|
||||
if (provider is XMRTOExchangeProvider) {
|
||||
request = XMRTOTradeRequest(
|
||||
if (provider is SimpleSwapExchangeProvider) {
|
||||
request = SimpleSwapRequest(
|
||||
from: depositCurrency,
|
||||
to: receiveCurrency,
|
||||
amount: depositAmount.replaceAll(',', '.'),
|
||||
receiveAmount: receiveAmount.replaceAll(',', '.'),
|
||||
address: receiveAddress,
|
||||
refundAddress: depositAddress,
|
||||
isBTCRequest: isReceiveAmountEntered);
|
||||
amount = depositAmount;
|
||||
}
|
||||
);
|
||||
amount = depositAmount;
|
||||
}
|
||||
|
||||
if (provider is ChangeNowExchangeProvider) {
|
||||
request = ChangeNowRequest(
|
||||
from: depositCurrency,
|
||||
to: receiveCurrency,
|
||||
fromAmount: depositAmount.replaceAll(',', '.'),
|
||||
toAmount: receiveAmount.replaceAll(',', '.'),
|
||||
refundAddress: depositAddress,
|
||||
address: receiveAddress,
|
||||
isReverse: isReverse);
|
||||
amount = isReverse ? receiveAmount : depositAmount;
|
||||
}
|
||||
if (provider is XMRTOExchangeProvider) {
|
||||
request = XMRTOTradeRequest(
|
||||
from: depositCurrency,
|
||||
to: receiveCurrency,
|
||||
amount: depositAmount.replaceAll(',', '.'),
|
||||
receiveAmount: receiveAmount.replaceAll(',', '.'),
|
||||
address: receiveAddress,
|
||||
refundAddress: depositAddress,
|
||||
isBTCRequest: isReceiveAmountEntered);
|
||||
amount = depositAmount;
|
||||
}
|
||||
|
||||
if (provider is MorphTokenExchangeProvider) {
|
||||
request = MorphTokenRequest(
|
||||
from: depositCurrency,
|
||||
to: receiveCurrency,
|
||||
amount: depositAmount.replaceAll(',', '.'),
|
||||
refundAddress: depositAddress,
|
||||
address: receiveAddress);
|
||||
amount = depositAmount;
|
||||
}
|
||||
if (provider is ChangeNowExchangeProvider) {
|
||||
request = ChangeNowRequest(
|
||||
from: depositCurrency,
|
||||
to: receiveCurrency,
|
||||
fromAmount: depositAmount.replaceAll(',', '.'),
|
||||
toAmount: receiveAmount.replaceAll(',', '.'),
|
||||
refundAddress: depositAddress,
|
||||
address: receiveAddress,
|
||||
isReverse: isReverse);
|
||||
amount = isReverse ? receiveAmount : depositAmount;
|
||||
}
|
||||
|
||||
amount = amount.replaceAll(',', '.');
|
||||
if (provider is MorphTokenExchangeProvider) {
|
||||
request = MorphTokenRequest(
|
||||
from: depositCurrency,
|
||||
to: receiveCurrency,
|
||||
amount: depositAmount.replaceAll(',', '.'),
|
||||
refundAddress: depositAddress,
|
||||
address: receiveAddress);
|
||||
amount = depositAmount;
|
||||
}
|
||||
|
||||
if (limitsState is LimitsLoadedSuccessfully) {
|
||||
if (double.parse(amount) < limits.min!) {
|
||||
continue;
|
||||
} else if (limits.max != null && double.parse(amount) > limits.max!) {
|
||||
continue;
|
||||
} else {
|
||||
try {
|
||||
tradeState = TradeIsCreating();
|
||||
final trade = await provider.createTrade(
|
||||
request: request!, isFixedRateMode: isFixedRateMode);
|
||||
trade.walletId = wallet.id;
|
||||
tradesStore.setTrade(trade);
|
||||
await trades.add(trade);
|
||||
tradeState = TradeIsCreatedSuccessfully(trade: trade);
|
||||
/// return after the first successful trade
|
||||
return;
|
||||
} catch (e) {
|
||||
amount = amount.replaceAll(',', '.');
|
||||
|
||||
if (limitsState is LimitsLoadedSuccessfully) {
|
||||
if (double.parse(amount) < limits.min!) {
|
||||
continue;
|
||||
} else if (limits.max != null && double.parse(amount) > limits.max!) {
|
||||
continue;
|
||||
} else {
|
||||
try {
|
||||
tradeState = TradeIsCreating();
|
||||
final trade = await provider.createTrade(
|
||||
request: request!, isFixedRateMode: isFixedRateMode);
|
||||
trade.walletId = wallet.id;
|
||||
tradesStore.setTrade(trade);
|
||||
await trades.add(trade);
|
||||
tradeState = TradeIsCreatedSuccessfully(trade: trade);
|
||||
/// return after the first successful trade
|
||||
return;
|
||||
} catch (e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// if the code reached here then none of the providers succeeded
|
||||
tradeState = TradeIsCreatedFailure(
|
||||
title: S.current.trade_not_created,
|
||||
error: S.current.none_of_selected_providers_can_exchange);
|
||||
/// if the code reached here then none of the providers succeeded
|
||||
tradeState = TradeIsCreatedFailure(
|
||||
title: S.current.trade_not_created,
|
||||
error: S.current.none_of_selected_providers_can_exchange);
|
||||
} on ConcurrentModificationError {
|
||||
/// if create trade happened at the exact same time of the scheduled rate update
|
||||
/// then delay the create trade a bit and try again
|
||||
///
|
||||
/// this is because the limitation of the SplayTreeMap that
|
||||
/// you can't modify it while iterating through it
|
||||
Future.delayed(Duration(milliseconds: 500), createTrade);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:cake_wallet/ionia/ionia_anypay.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_any_pay_payment_info.dart';
|
||||
import 'package:cake_wallet/view_model/send/send_view_model.dart';
|
||||
|
||||
part 'ionia_purchase_merch_view_model.g.dart';
|
||||
|
||||
@@ -17,6 +18,7 @@ abstract class IoniaMerchPurchaseViewModelBase with Store {
|
||||
required this.ioniaAnyPayService,
|
||||
required this.amount,
|
||||
required this.ioniaMerchant,
|
||||
required this.sendViewModel,
|
||||
}) : tipAmount = 0.0,
|
||||
percentage = 0.0,
|
||||
invoiceCreationState = InitialExecutionState(),
|
||||
@@ -40,6 +42,8 @@ abstract class IoniaMerchPurchaseViewModelBase with Store {
|
||||
|
||||
final IoniaMerchant ioniaMerchant;
|
||||
|
||||
final SendViewModel sendViewModel;
|
||||
|
||||
final IoniaAnyPay ioniaAnyPayService;
|
||||
|
||||
IoniaAnyPayPaymentInfo? paymentInfo;
|
||||
|
||||
@@ -208,6 +208,12 @@ abstract class SettingsViewModelBase with Store {
|
||||
setAllowBiometricalAuthentication(value);
|
||||
}
|
||||
}),
|
||||
SwitcherListItem(
|
||||
title: S.current.disable_exchange,
|
||||
value: () => _settingsStore.disableExchange,
|
||||
onValueChange: (BuildContext context, bool value) {
|
||||
_settingsStore.disableExchange = value;
|
||||
}),
|
||||
ChoicesListItem(
|
||||
title: S.current.color_theme,
|
||||
items: ThemeList.all,
|
||||
|
||||
Reference in New Issue
Block a user