mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 03:06:29 +00:00
commit
602d7016d3
4 changed files with 115 additions and 72 deletions
|
@ -69,17 +69,21 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
bool _swapLock = false;
|
bool _swapLock = false;
|
||||||
|
|
||||||
void sendFieldOnChanged(String value) async {
|
void sendFieldOnChanged(String value) async {
|
||||||
final newFromAmount = Decimal.tryParse(value);
|
if (_sendFocusNode.hasFocus) {
|
||||||
|
final newFromAmount = Decimal.tryParse(value);
|
||||||
|
|
||||||
ref.read(exchangeFormStateProvider).fromAmount =
|
await ref
|
||||||
newFromAmount ?? Decimal.zero;
|
.read(exchangeFormStateProvider)
|
||||||
|
.setFromAmountAndCalculateToAmount(
|
||||||
|
newFromAmount ?? Decimal.zero, true);
|
||||||
|
|
||||||
if (newFromAmount == null) {
|
if (newFromAmount == null) {
|
||||||
_receiveController.text =
|
_receiveController.text =
|
||||||
ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
||||||
ExchangeRateType.estimated
|
ExchangeRateType.estimated
|
||||||
? "-"
|
? "-"
|
||||||
: "";
|
: "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +120,29 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
fromTicker: fromTicker,
|
fromTicker: fromTicker,
|
||||||
onSelected: (from) =>
|
onSelected: (from) =>
|
||||||
ref.read(exchangeFormStateProvider).updateFrom(from, true));
|
ref.read(exchangeFormStateProvider).updateFrom(from, true));
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (_) => WillPopScope(
|
||||||
|
onWillPop: () async => false,
|
||||||
|
child: Container(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.overlay
|
||||||
|
.withOpacity(0.6),
|
||||||
|
child: const CustomLoadingOverlay(
|
||||||
|
message: "Updating exchange rate",
|
||||||
|
eventBus: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await Future<void>.delayed(const Duration(milliseconds: 300));
|
||||||
|
Navigator.of(context).pop();
|
||||||
} else {
|
} else {
|
||||||
final toTicker = ref.read(exchangeFormStateProvider).toTicker ?? "";
|
final toTicker = ref.read(exchangeFormStateProvider).toTicker ?? "";
|
||||||
final fromTicker = ref.read(exchangeFormStateProvider).fromTicker ?? "";
|
final fromTicker = ref.read(exchangeFormStateProvider).fromTicker ?? "";
|
||||||
|
@ -1117,38 +1144,43 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
: ref.read(exchangeFormStateProvider).toAmountString;
|
: ref.read(exchangeFormStateProvider).toAmountString;
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendFocusNode.addListener(() async {
|
// _sendFocusNode.addListener(() async {
|
||||||
if (!_sendFocusNode.hasFocus) {
|
// if (!_sendFocusNode.hasFocus) {
|
||||||
final newFromAmount = Decimal.tryParse(_sendController.text);
|
// final newFromAmount = Decimal.tryParse(_sendController.text);
|
||||||
await ref
|
// await ref
|
||||||
.read(exchangeFormStateProvider)
|
// .read(exchangeFormStateProvider)
|
||||||
.setFromAmountAndCalculateToAmount(
|
// .setFromAmountAndCalculateToAmount(
|
||||||
newFromAmount ?? Decimal.zero, true);
|
// newFromAmount ?? Decimal.zero, true);
|
||||||
|
//
|
||||||
if (newFromAmount == null) {
|
// debugPrint("SendFocusNode has fired");
|
||||||
_receiveController.text =
|
//
|
||||||
ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
// if (newFromAmount == null) {
|
||||||
ExchangeRateType.estimated
|
// _receiveController.text =
|
||||||
? "-"
|
// ref.read(prefsChangeNotifierProvider).exchangeRateType ==
|
||||||
: "";
|
// ExchangeRateType.estimated
|
||||||
}
|
// ? "-"
|
||||||
}
|
// : "";
|
||||||
});
|
// }
|
||||||
_receiveFocusNode.addListener(() async {
|
// }
|
||||||
if (!_receiveFocusNode.hasFocus) {
|
// });
|
||||||
final newToAmount = Decimal.tryParse(_receiveController.text);
|
//
|
||||||
if (ref.read(prefsChangeNotifierProvider).exchangeRateType !=
|
// _receiveFocusNode.addListener(() async {
|
||||||
ExchangeRateType.estimated) {
|
// if (!_receiveFocusNode.hasFocus) {
|
||||||
await ref
|
// final newToAmount = Decimal.tryParse(_receiveController.text);
|
||||||
.read(exchangeFormStateProvider)
|
// if (ref.read(prefsChangeNotifierProvider).exchangeRateType !=
|
||||||
.setToAmountAndCalculateFromAmount(
|
// ExchangeRateType.estimated) {
|
||||||
newToAmount ?? Decimal.zero, true);
|
// await ref
|
||||||
}
|
// .read(exchangeFormStateProvider)
|
||||||
if (newToAmount == null) {
|
// .setToAmountAndCalculateFromAmount(
|
||||||
_sendController.text = "";
|
// newToAmount ?? Decimal.zero, true);
|
||||||
}
|
//
|
||||||
}
|
// debugPrint("ReceiveFocusNode has fired");
|
||||||
});
|
// }
|
||||||
|
// if (newToAmount == null) {
|
||||||
|
// _sendController.text = "";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
@ -1164,6 +1196,7 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
debugPrint("BUILD: $runtimeType");
|
debugPrint("BUILD: $runtimeType");
|
||||||
|
|
||||||
|
// provider for simpleswap; not called rn
|
||||||
ref.listen<String>(currentExchangeNameStateProvider, (previous, next) {
|
ref.listen<String>(currentExchangeNameStateProvider, (previous, next) {
|
||||||
ref.read(exchangeFormStateProvider).exchange = ref.read(exchangeProvider);
|
ref.read(exchangeFormStateProvider).exchange = ref.read(exchangeProvider);
|
||||||
});
|
});
|
||||||
|
@ -1357,13 +1390,15 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
onChanged: onRateTypeChanged,
|
onChanged: onRateTypeChanged,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (ref.read(exchangeFormStateProvider).fromAmount != null &&
|
// these reads should be watch
|
||||||
ref.read(exchangeFormStateProvider).fromAmount != Decimal.zero)
|
if (ref.watch(exchangeFormStateProvider).fromAmount != null &&
|
||||||
|
ref.watch(exchangeFormStateProvider).fromAmount != Decimal.zero)
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: isDesktop ? 20 : 12,
|
height: isDesktop ? 20 : 12,
|
||||||
),
|
),
|
||||||
if (ref.read(exchangeFormStateProvider).fromAmount != null &&
|
// these reads should be watch
|
||||||
ref.read(exchangeFormStateProvider).fromAmount != Decimal.zero)
|
if (ref.watch(exchangeFormStateProvider).fromAmount != null &&
|
||||||
|
ref.watch(exchangeFormStateProvider).fromAmount != Decimal.zero)
|
||||||
ExchangeProviderOptions(
|
ExchangeProviderOptions(
|
||||||
from: ref.watch(exchangeFormStateProvider).fromTicker,
|
from: ref.watch(exchangeFormStateProvider).fromTicker,
|
||||||
to: ref.watch(exchangeFormStateProvider).toTicker,
|
to: ref.watch(exchangeFormStateProvider).toTicker,
|
||||||
|
|
|
@ -77,35 +77,43 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 20,
|
height: 20,
|
||||||
child: Radio(
|
child: Padding(
|
||||||
activeColor: Theme.of(context)
|
padding:
|
||||||
.extension<StackColors>()!
|
EdgeInsets.only(top: isDesktop ? 20.0 : 15.0),
|
||||||
.radioButtonIconEnabled,
|
child: Radio(
|
||||||
value: ChangeNowExchange.exchangeName,
|
activeColor: Theme.of(context)
|
||||||
groupValue: ref
|
.extension<StackColors>()!
|
||||||
.watch(currentExchangeNameStateProvider.state)
|
.radioButtonIconEnabled,
|
||||||
.state,
|
value: ChangeNowExchange.exchangeName,
|
||||||
onChanged: (value) {
|
groupValue: ref
|
||||||
if (value is String) {
|
.watch(currentExchangeNameStateProvider.state)
|
||||||
ref
|
.state,
|
||||||
.read(currentExchangeNameStateProvider.state)
|
onChanged: (value) {
|
||||||
.state = value;
|
if (value is String) {
|
||||||
ref.read(exchangeFormStateProvider).exchange =
|
ref
|
||||||
Exchange.fromName(ref
|
.read(
|
||||||
.read(currentExchangeNameStateProvider
|
currentExchangeNameStateProvider.state)
|
||||||
.state)
|
.state = value;
|
||||||
.state);
|
ref.read(exchangeFormStateProvider).exchange =
|
||||||
}
|
Exchange.fromName(ref
|
||||||
},
|
.read(currentExchangeNameStateProvider
|
||||||
|
.state)
|
||||||
|
.state);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 14,
|
width: 14,
|
||||||
),
|
),
|
||||||
SvgPicture.asset(
|
Padding(
|
||||||
Assets.exchange.changeNow,
|
padding: const EdgeInsets.only(top: 5.0),
|
||||||
width: isDesktop ? 32 : 24,
|
child: SvgPicture.asset(
|
||||||
height: isDesktop ? 32 : 24,
|
Assets.exchange.changeNow,
|
||||||
|
width: isDesktop ? 32 : 24,
|
||||||
|
height: isDesktop ? 32 : 24,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 10,
|
width: 10,
|
||||||
|
|
|
@ -57,7 +57,7 @@ class DeleteWalletWarningView extends ConsumerWidget {
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.warningBackground,
|
.warningBackground,
|
||||||
child: Text(
|
child: Text(
|
||||||
"You are going to permanently delete you wallet.\n\nIf you delete your wallet, the only way you can have access to your funds is by using your backup key.\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet.\n\nPLEASE SAVE YOUR BACKUP KEY.",
|
"You are going to permanently delete your wallet.\n\nIf you delete your wallet, the only way you can have access to your funds is by using your backup key.\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet.\n\nPLEASE SAVE YOUR BACKUP KEY.",
|
||||||
style: STextStyles.baseXS(context).copyWith(
|
style: STextStyles.baseXS(context).copyWith(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
|
|
|
@ -66,7 +66,7 @@ class _DesktopAttentionDeleteWallet
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(10.0),
|
padding: const EdgeInsets.all(10.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
"You are going to permanently delete you wallet.\n\nIf you delete your wallet, "
|
"You are going to permanently delete your wallet.\n\nIf you delete your wallet, "
|
||||||
"the only way you can have access to your funds is by using your backup key."
|
"the only way you can have access to your funds is by using your backup key."
|
||||||
"\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet."
|
"\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet."
|
||||||
"\n\nPLEASE SAVE YOUR BACKUP KEY.",
|
"\n\nPLEASE SAVE YOUR BACKUP KEY.",
|
||||||
|
@ -74,7 +74,7 @@ class _DesktopAttentionDeleteWallet
|
||||||
.copyWith(
|
.copyWith(
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.textDark3,
|
.snackBarTextError,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue