mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
commit
394409ac28
3 changed files with 331 additions and 334 deletions
|
@ -7,7 +7,7 @@ import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.d
|
||||||
import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart';
|
import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_rate_sheet.dart';
|
||||||
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
||||||
import 'package:stackwallet/services/exchange/exchange.dart';
|
import 'package:stackwallet/services/exchange/exchange.dart';
|
||||||
import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart';
|
// import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
|
||||||
class ExchangeFormState extends ChangeNotifier {
|
class ExchangeFormState extends ChangeNotifier {
|
||||||
|
@ -53,8 +53,8 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
return _from?.ticker;
|
return _from?.ticker;
|
||||||
case ExchangeRateType.fixed:
|
case ExchangeRateType.fixed:
|
||||||
switch (exchange?.name) {
|
switch (exchange?.name) {
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
return _from?.ticker;
|
// return _from?.ticker;
|
||||||
case ChangeNowExchange.exchangeName:
|
case ChangeNowExchange.exchangeName:
|
||||||
return market?.from;
|
return market?.from;
|
||||||
default:
|
default:
|
||||||
|
@ -69,8 +69,8 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
return _to?.ticker;
|
return _to?.ticker;
|
||||||
case ExchangeRateType.fixed:
|
case ExchangeRateType.fixed:
|
||||||
switch (exchange?.name) {
|
switch (exchange?.name) {
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
return _to?.ticker;
|
// return _to?.ticker;
|
||||||
case ChangeNowExchange.exchangeName:
|
case ChangeNowExchange.exchangeName:
|
||||||
return market?.to;
|
return market?.to;
|
||||||
default:
|
default:
|
||||||
|
@ -296,9 +296,9 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateRanges({required bool shouldNotifyListeners}) async {
|
Future<void> updateRanges({required bool shouldNotifyListeners}) async {
|
||||||
if (exchange?.name == SimpleSwapExchange.exchangeName) {
|
// if (exchange?.name == SimpleSwapExchange.exchangeName) {
|
||||||
reversed = false;
|
// reversed = false;
|
||||||
}
|
// }
|
||||||
final _fromTicker = reversed ? toTicker : fromTicker;
|
final _fromTicker = reversed ? toTicker : fromTicker;
|
||||||
final _toTicker = reversed ? fromTicker : toTicker;
|
final _toTicker = reversed ? fromTicker : toTicker;
|
||||||
if (_fromTicker == null || _toTicker == null) {
|
if (_fromTicker == null || _toTicker == null) {
|
||||||
|
@ -340,9 +340,9 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
required bool shouldNotifyListeners,
|
required bool shouldNotifyListeners,
|
||||||
required bool reversed,
|
required bool reversed,
|
||||||
}) async {
|
}) async {
|
||||||
if (exchange?.name == SimpleSwapExchange.exchangeName) {
|
// if (exchange?.name == SimpleSwapExchange.exchangeName) {
|
||||||
reversed = false;
|
// reversed = false;
|
||||||
}
|
// }
|
||||||
final amount = reversed ? toAmount : fromAmount;
|
final amount = reversed ? toAmount : fromAmount;
|
||||||
if (fromTicker == null ||
|
if (fromTicker == null ||
|
||||||
toTicker == null ||
|
toTicker == null ||
|
||||||
|
|
|
@ -20,7 +20,7 @@ import 'package:stackwallet/pages/exchange_view/sub_widgets/rate_type_toggle.dar
|
||||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart';
|
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart';
|
||||||
import 'package:stackwallet/providers/providers.dart';
|
import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
||||||
import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart';
|
// import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
@ -101,11 +101,11 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
currencies =
|
currencies =
|
||||||
ref.read(availableChangeNowCurrenciesProvider).currencies;
|
ref.read(availableChangeNowCurrenciesProvider).currencies;
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
currencies = ref
|
// currencies = ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.floatingRateCurrencies;
|
// .floatingRateCurrencies;
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
currencies = [];
|
currencies = [];
|
||||||
}
|
}
|
||||||
|
@ -170,17 +170,17 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
await _showFloatingRateSelectionSheet(
|
// await _showFloatingRateSelectionSheet(
|
||||||
currencies: ref
|
// currencies: ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.fixedRateCurrencies,
|
// .fixedRateCurrencies,
|
||||||
excludedTicker:
|
// excludedTicker:
|
||||||
ref.read(exchangeFormStateProvider).toTicker ?? "-",
|
// ref.read(exchangeFormStateProvider).toTicker ?? "-",
|
||||||
fromTicker: fromTicker,
|
// fromTicker: fromTicker,
|
||||||
onSelected: (from) =>
|
// onSelected: (from) =>
|
||||||
ref.read(exchangeFormStateProvider).updateFrom(from, true));
|
// ref.read(exchangeFormStateProvider).updateFrom(from, true));
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
// TODO show error?
|
// TODO show error?
|
||||||
}
|
}
|
||||||
|
@ -204,11 +204,11 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
currencies =
|
currencies =
|
||||||
ref.read(availableChangeNowCurrenciesProvider).currencies;
|
ref.read(availableChangeNowCurrenciesProvider).currencies;
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
currencies = ref
|
// currencies = ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.floatingRateCurrencies;
|
// .floatingRateCurrencies;
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
currencies = [];
|
currencies = [];
|
||||||
}
|
}
|
||||||
|
@ -272,17 +272,17 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
await _showFloatingRateSelectionSheet(
|
// await _showFloatingRateSelectionSheet(
|
||||||
currencies: ref
|
// currencies: ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.fixedRateCurrencies,
|
// .fixedRateCurrencies,
|
||||||
excludedTicker:
|
// excludedTicker:
|
||||||
ref.read(exchangeFormStateProvider).fromTicker ?? "",
|
// ref.read(exchangeFormStateProvider).fromTicker ?? "",
|
||||||
fromTicker: ref.read(exchangeFormStateProvider).fromTicker ?? "",
|
// fromTicker: ref.read(exchangeFormStateProvider).fromTicker ?? "",
|
||||||
onSelected: (to) =>
|
// onSelected: (to) =>
|
||||||
ref.read(exchangeFormStateProvider).updateTo(to, true));
|
// ref.read(exchangeFormStateProvider).updateTo(to, true));
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
// TODO show error?
|
// TODO show error?
|
||||||
}
|
}
|
||||||
|
@ -374,12 +374,12 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
case ChangeNowExchange.exchangeName:
|
case ChangeNowExchange.exchangeName:
|
||||||
allPairs = ref.read(availableChangeNowCurrenciesProvider).pairs;
|
allPairs = ref.read(availableChangeNowCurrenciesProvider).pairs;
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
allPairs = ref.read(exchangeFormStateProvider).exchangeType ==
|
// allPairs = ref.read(exchangeFormStateProvider).exchangeType ==
|
||||||
ExchangeRateType.fixed
|
// ExchangeRateType.fixed
|
||||||
? ref.read(availableSimpleswapCurrenciesProvider).fixedRatePairs
|
// ? ref.read(availableSimpleswapCurrenciesProvider).fixedRatePairs
|
||||||
: ref.read(availableSimpleswapCurrenciesProvider).floatingRatePairs;
|
// : ref.read(availableSimpleswapCurrenciesProvider).floatingRatePairs;
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
allPairs = [];
|
allPairs = [];
|
||||||
}
|
}
|
||||||
|
@ -486,18 +486,18 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
.currencies
|
.currencies
|
||||||
.where((e) => e.ticker.toUpperCase() == ticker.toUpperCase());
|
.where((e) => e.ticker.toUpperCase() == ticker.toUpperCase());
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
possibleCurrencies = [
|
// possibleCurrencies = [
|
||||||
...ref
|
// ...ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.fixedRateCurrencies
|
// .fixedRateCurrencies
|
||||||
.where((e) => e.ticker.toUpperCase() == ticker.toUpperCase()),
|
// .where((e) => e.ticker.toUpperCase() == ticker.toUpperCase()),
|
||||||
...ref
|
// ...ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.floatingRateCurrencies
|
// .floatingRateCurrencies
|
||||||
.where((e) => e.ticker.toUpperCase() == ticker.toUpperCase()),
|
// .where((e) => e.ticker.toUpperCase() == ticker.toUpperCase()),
|
||||||
];
|
// ];
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
possibleCurrencies = [];
|
possibleCurrencies = [];
|
||||||
}
|
}
|
||||||
|
@ -655,12 +655,12 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
.pairs
|
.pairs
|
||||||
.where((e) => e.to == toTicker && e.from == fromTicker);
|
.where((e) => e.to == toTicker && e.from == fromTicker);
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
available = ref
|
// available = ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.floatingRatePairs
|
// .floatingRatePairs
|
||||||
.where((e) => e.to == toTicker && e.from == fromTicker);
|
// .where((e) => e.to == toTicker && e.from == fromTicker);
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
available = [];
|
available = [];
|
||||||
}
|
}
|
||||||
|
@ -675,13 +675,13 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
.where(
|
.where(
|
||||||
(e) => e.ticker == fromTicker || e.ticker == toTicker);
|
(e) => e.ticker == fromTicker || e.ticker == toTicker);
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
availableCurrencies = ref
|
// availableCurrencies = ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.floatingRateCurrencies
|
// .floatingRateCurrencies
|
||||||
.where(
|
// .where(
|
||||||
(e) => e.ticker == fromTicker || e.ticker == toTicker);
|
// (e) => e.ticker == fromTicker || e.ticker == toTicker);
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
availableCurrencies = [];
|
availableCurrencies = [];
|
||||||
}
|
}
|
||||||
|
@ -763,47 +763,47 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
final available = ref
|
// final available = ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.floatingRatePairs
|
// .floatingRatePairs
|
||||||
.where((e) => e.to == toTicker && e.from == fromTicker);
|
// .where((e) => e.to == toTicker && e.from == fromTicker);
|
||||||
if (available.isNotEmpty) {
|
// if (available.isNotEmpty) {
|
||||||
final availableCurrencies = ref
|
// final availableCurrencies = ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.fixedRateCurrencies
|
// .fixedRateCurrencies
|
||||||
.where(
|
// .where(
|
||||||
(e) => e.ticker == fromTicker || e.ticker == toTicker);
|
// (e) => e.ticker == fromTicker || e.ticker == toTicker);
|
||||||
if (availableCurrencies.length > 1) {
|
// if (availableCurrencies.length > 1) {
|
||||||
final from = availableCurrencies
|
// final from = availableCurrencies
|
||||||
.firstWhere((e) => e.ticker == fromTicker);
|
// .firstWhere((e) => e.ticker == fromTicker);
|
||||||
final to = availableCurrencies
|
// final to = availableCurrencies
|
||||||
.firstWhere((e) => e.ticker == toTicker);
|
// .firstWhere((e) => e.ticker == toTicker);
|
||||||
|
//
|
||||||
final newFromAmount = Decimal.tryParse(_sendController.text);
|
// final newFromAmount = Decimal.tryParse(_sendController.text);
|
||||||
ref.read(exchangeFormStateProvider).fromAmount =
|
// ref.read(exchangeFormStateProvider).fromAmount =
|
||||||
newFromAmount ?? Decimal.zero;
|
// newFromAmount ?? Decimal.zero;
|
||||||
if (newFromAmount == null) {
|
// if (newFromAmount == null) {
|
||||||
_receiveController.text = "";
|
// _receiveController.text = "";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
await ref.read(exchangeFormStateProvider).updateTo(to, false);
|
// await ref.read(exchangeFormStateProvider).updateTo(to, false);
|
||||||
await ref
|
// await ref
|
||||||
.read(exchangeFormStateProvider)
|
// .read(exchangeFormStateProvider)
|
||||||
.updateFrom(from, true);
|
// .updateFrom(from, true);
|
||||||
|
//
|
||||||
_receiveController.text =
|
// _receiveController.text =
|
||||||
ref.read(exchangeFormStateProvider).toAmountString.isEmpty
|
// ref.read(exchangeFormStateProvider).toAmountString.isEmpty
|
||||||
? "-"
|
// ? "-"
|
||||||
: ref.read(exchangeFormStateProvider).toAmountString;
|
// : ref.read(exchangeFormStateProvider).toAmountString;
|
||||||
if (mounted) {
|
// if (mounted) {
|
||||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
// Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||||
}
|
// }
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -844,12 +844,12 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
.pairs
|
.pairs
|
||||||
.where((e) => e.to == toTicker && e.from == fromTicker);
|
.where((e) => e.to == toTicker && e.from == fromTicker);
|
||||||
break;
|
break;
|
||||||
case SimpleSwapExchange.exchangeName:
|
// case SimpleSwapExchange.exchangeName:
|
||||||
availableFloatingPairs = ref
|
// availableFloatingPairs = ref
|
||||||
.read(availableSimpleswapCurrenciesProvider)
|
// .read(availableSimpleswapCurrenciesProvider)
|
||||||
.floatingRatePairs
|
// .floatingRatePairs
|
||||||
.where((e) => e.to == toTicker && e.from == fromTicker);
|
// .where((e) => e.to == toTicker && e.from == fromTicker);
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
availableFloatingPairs = [];
|
availableFloatingPairs = [];
|
||||||
}
|
}
|
||||||
|
@ -1176,12 +1176,9 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
exchangeFormStateProvider.select((value) => value.toAmountString),
|
exchangeFormStateProvider.select((value) => value.toAmountString),
|
||||||
(previous, String next) {
|
(previous, String next) {
|
||||||
if (!_receiveFocusNode.hasFocus) {
|
if (!_receiveFocusNode.hasFocus) {
|
||||||
_receiveController.text = isEstimated &&
|
// ref.watch(exchangeProvider).name ==
|
||||||
ref.watch(exchangeProvider).name ==
|
// SimpleSwapExchange.exchangeName &&
|
||||||
SimpleSwapExchange.exchangeName &&
|
_receiveController.text = isEstimated && next.isEmpty ? "-" : next;
|
||||||
next.isEmpty
|
|
||||||
? "-"
|
|
||||||
: next;
|
|
||||||
//todo: check if print needed
|
//todo: check if print needed
|
||||||
// debugPrint("RECEIVE AMOUNT LISTENER ACTIVATED");
|
// debugPrint("RECEIVE AMOUNT LISTENER ACTIVATED");
|
||||||
if (_swapLock) {
|
if (_swapLock) {
|
||||||
|
@ -1335,9 +1332,10 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
|
||||||
exchangeFormStateProvider.select((value) => value.toTicker)),
|
exchangeFormStateProvider.select((value) => value.toTicker)),
|
||||||
readOnly: ref.watch(prefsChangeNotifierProvider
|
readOnly: ref.watch(prefsChangeNotifierProvider
|
||||||
.select((value) => value.exchangeRateType)) ==
|
.select((value) => value.exchangeRateType)) ==
|
||||||
ExchangeRateType.estimated ||
|
ExchangeRateType.estimated,
|
||||||
ref.watch(exchangeProvider).name ==
|
// ||
|
||||||
SimpleSwapExchange.exchangeName,
|
// ref.watch(exchangeProvider).name ==
|
||||||
|
// SimpleSwapExchange.exchangeName,
|
||||||
),
|
),
|
||||||
if (ref
|
if (ref
|
||||||
.watch(
|
.watch(
|
||||||
|
|
|
@ -7,7 +7,6 @@ import 'package:stackwallet/providers/providers.dart';
|
||||||
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
||||||
import 'package:stackwallet/services/exchange/exchange.dart';
|
import 'package:stackwallet/services/exchange/exchange.dart';
|
||||||
import 'package:stackwallet/services/exchange/exchange_response.dart';
|
import 'package:stackwallet/services/exchange/exchange_response.dart';
|
||||||
import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart';
|
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
@ -250,207 +249,207 @@ class ExchangeProviderOptions extends ConsumerWidget {
|
||||||
height: 1,
|
height: 1,
|
||||||
color: Theme.of(context).extension<StackColors>()!.background,
|
color: Theme.of(context).extension<StackColors>()!.background,
|
||||||
),
|
),
|
||||||
if (!isDesktop)
|
// if (!isDesktop)
|
||||||
const SizedBox(
|
// const SizedBox(
|
||||||
height: 16,
|
// height: 16,
|
||||||
),
|
// ),
|
||||||
ConditionalParent(
|
// ConditionalParent(
|
||||||
condition: isDesktop,
|
// condition: isDesktop,
|
||||||
builder: (child) => MouseRegion(
|
// builder: (child) => MouseRegion(
|
||||||
cursor: SystemMouseCursors.click,
|
// cursor: SystemMouseCursors.click,
|
||||||
child: child,
|
// child: child,
|
||||||
),
|
// ),
|
||||||
child: GestureDetector(
|
// child: GestureDetector(
|
||||||
onTap: () {
|
// onTap: () {
|
||||||
if (ref.read(currentExchangeNameStateProvider.state).state !=
|
// if (ref.read(currentExchangeNameStateProvider.state).state !=
|
||||||
SimpleSwapExchange.exchangeName) {
|
// SimpleSwapExchange.exchangeName) {
|
||||||
ref.read(currentExchangeNameStateProvider.state).state =
|
// // ref.read(currentExchangeNameStateProvider.state).state =
|
||||||
SimpleSwapExchange.exchangeName;
|
// // SimpleSwapExchange.exchangeName;
|
||||||
ref.read(exchangeFormStateProvider).exchange =
|
// ref.read(exchangeFormStateProvider).exchange =
|
||||||
Exchange.fromName(ref
|
// Exchange.fromName(ref
|
||||||
.read(currentExchangeNameStateProvider.state)
|
// .read(currentExchangeNameStateProvider.state)
|
||||||
.state);
|
// .state);
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
child: Container(
|
// child: Container(
|
||||||
color: Colors.transparent,
|
// color: Colors.transparent,
|
||||||
child: Padding(
|
// child: Padding(
|
||||||
padding: isDesktop
|
// padding: isDesktop
|
||||||
? const EdgeInsets.all(16)
|
// ? const EdgeInsets.all(16)
|
||||||
: const EdgeInsets.all(0),
|
// : const EdgeInsets.all(0),
|
||||||
child: Row(
|
// child: Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
// children: [
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
width: 20,
|
// width: 20,
|
||||||
height: 20,
|
// height: 20,
|
||||||
child: Radio(
|
// child: Radio(
|
||||||
activeColor: Theme.of(context)
|
// activeColor: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// .extension<StackColors>()!
|
||||||
.radioButtonIconEnabled,
|
// .radioButtonIconEnabled,
|
||||||
value: SimpleSwapExchange.exchangeName,
|
// value: SimpleSwapExchange.exchangeName,
|
||||||
groupValue: ref
|
// groupValue: ref
|
||||||
.watch(currentExchangeNameStateProvider.state)
|
// .watch(currentExchangeNameStateProvider.state)
|
||||||
.state,
|
// .state,
|
||||||
onChanged: (value) {
|
// onChanged: (value) {
|
||||||
if (value is String) {
|
// if (value is String) {
|
||||||
ref
|
// ref
|
||||||
.read(currentExchangeNameStateProvider.state)
|
// .read(currentExchangeNameStateProvider.state)
|
||||||
.state = value;
|
// .state = value;
|
||||||
ref.read(exchangeFormStateProvider).exchange =
|
// ref.read(exchangeFormStateProvider).exchange =
|
||||||
Exchange.fromName(ref
|
// Exchange.fromName(ref
|
||||||
.read(currentExchangeNameStateProvider
|
// .read(currentExchangeNameStateProvider
|
||||||
.state)
|
// .state)
|
||||||
.state);
|
// .state);
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
const SizedBox(
|
// const SizedBox(
|
||||||
width: 14,
|
// width: 14,
|
||||||
),
|
// ),
|
||||||
SvgPicture.asset(
|
// // SvgPicture.asset(
|
||||||
Assets.exchange.simpleSwap,
|
// // Assets.exchange.simpleSwap,
|
||||||
width: isDesktop ? 32 : 24,
|
// // width: isDesktop ? 32 : 24,
|
||||||
height: isDesktop ? 32 : 24,
|
// // height: isDesktop ? 32 : 24,
|
||||||
),
|
// // ),
|
||||||
const SizedBox(
|
// // const SizedBox(
|
||||||
width: 10,
|
// // width: 10,
|
||||||
),
|
// // ),
|
||||||
Expanded(
|
// // Expanded(
|
||||||
child: Column(
|
// // child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
// // mainAxisAlignment: MainAxisAlignment.start,
|
||||||
mainAxisSize: MainAxisSize.min,
|
// // mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// // crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
// // children: [
|
||||||
Text(
|
// // Text(
|
||||||
SimpleSwapExchange.exchangeName,
|
// // SimpleSwapExchange.exchangeName,
|
||||||
style: STextStyles.titleBold12(context).copyWith(
|
// // style: STextStyles.titleBold12(context).copyWith(
|
||||||
color: Theme.of(context)
|
// // color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// // .extension<StackColors>()!
|
||||||
.textDark2,
|
// // .textDark2,
|
||||||
),
|
// // ),
|
||||||
),
|
// // ),
|
||||||
if (from != null &&
|
// // if (from != null &&
|
||||||
to != null &&
|
// // to != null &&
|
||||||
toAmount != null &&
|
// // toAmount != null &&
|
||||||
toAmount! > Decimal.zero &&
|
// // toAmount! > Decimal.zero &&
|
||||||
fromAmount != null &&
|
// // fromAmount != null &&
|
||||||
fromAmount! > Decimal.zero)
|
// // fromAmount! > Decimal.zero)
|
||||||
FutureBuilder(
|
// // FutureBuilder(
|
||||||
future: SimpleSwapExchange().getEstimate(
|
// // future: SimpleSwapExchange().getEstimate(
|
||||||
from!,
|
// // from!,
|
||||||
to!,
|
// // to!,
|
||||||
// reversed ? toAmount! : fromAmount!,
|
// // // reversed ? toAmount! : fromAmount!,
|
||||||
fromAmount!,
|
// // fromAmount!,
|
||||||
fixedRate,
|
// // fixedRate,
|
||||||
// reversed,
|
// // // reversed,
|
||||||
false,
|
// // false,
|
||||||
),
|
// // ),
|
||||||
builder: (context,
|
// // builder: (context,
|
||||||
AsyncSnapshot<ExchangeResponse<Estimate>>
|
// // AsyncSnapshot<ExchangeResponse<Estimate>>
|
||||||
snapshot) {
|
// // snapshot) {
|
||||||
if (snapshot.connectionState ==
|
// // if (snapshot.connectionState ==
|
||||||
ConnectionState.done &&
|
// // ConnectionState.done &&
|
||||||
snapshot.hasData) {
|
// // snapshot.hasData) {
|
||||||
final estimate = snapshot.data?.value;
|
// // final estimate = snapshot.data?.value;
|
||||||
if (estimate != null) {
|
// // if (estimate != null) {
|
||||||
Decimal rate = (estimate.estimatedAmount /
|
// // Decimal rate = (estimate.estimatedAmount /
|
||||||
fromAmount!)
|
// // fromAmount!)
|
||||||
.toDecimal(
|
// // .toDecimal(
|
||||||
scaleOnInfinitePrecision: 12);
|
// // scaleOnInfinitePrecision: 12);
|
||||||
|
// //
|
||||||
Coin coin;
|
// // Coin coin;
|
||||||
try {
|
// // try {
|
||||||
coin =
|
// // coin =
|
||||||
coinFromTickerCaseInsensitive(to!);
|
// // coinFromTickerCaseInsensitive(to!);
|
||||||
} catch (_) {
|
// // } catch (_) {
|
||||||
coin = Coin.bitcoin;
|
// // coin = Coin.bitcoin;
|
||||||
}
|
// // }
|
||||||
return Text(
|
// // return Text(
|
||||||
"1 ${from!.toUpperCase()} ~ ${Format.localizedStringAsFixed(
|
// // "1 ${from!.toUpperCase()} ~ ${Format.localizedStringAsFixed(
|
||||||
value: rate,
|
// // value: rate,
|
||||||
locale: ref.watch(
|
// // locale: ref.watch(
|
||||||
localeServiceChangeNotifierProvider
|
// // localeServiceChangeNotifierProvider
|
||||||
.select(
|
// // .select(
|
||||||
(value) => value.locale),
|
// // (value) => value.locale),
|
||||||
),
|
// // ),
|
||||||
decimalPlaces:
|
// // decimalPlaces:
|
||||||
Constants.decimalPlacesForCoin(
|
// // Constants.decimalPlacesForCoin(
|
||||||
coin),
|
// // coin),
|
||||||
)} ${to!.toUpperCase()}",
|
// // )} ${to!.toUpperCase()}",
|
||||||
style:
|
// // style:
|
||||||
STextStyles.itemSubtitle12(context)
|
// // STextStyles.itemSubtitle12(context)
|
||||||
.copyWith(
|
// // .copyWith(
|
||||||
color: Theme.of(context)
|
// // color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// // .extension<StackColors>()!
|
||||||
.textSubtitle1,
|
// // .textSubtitle1,
|
||||||
),
|
// // ),
|
||||||
);
|
// // );
|
||||||
} else {
|
// // } else {
|
||||||
Logging.instance.log(
|
// // Logging.instance.log(
|
||||||
"$runtimeType failed to fetch rate for SimpleSwap: ${snapshot.data}",
|
// // "$runtimeType failed to fetch rate for SimpleSwap: ${snapshot.data}",
|
||||||
level: LogLevel.Warning,
|
// // level: LogLevel.Warning,
|
||||||
);
|
// // );
|
||||||
return Text(
|
// // return Text(
|
||||||
"Failed to fetch rate",
|
// // "Failed to fetch rate",
|
||||||
style:
|
// // style:
|
||||||
STextStyles.itemSubtitle12(context)
|
// // STextStyles.itemSubtitle12(context)
|
||||||
.copyWith(
|
// // .copyWith(
|
||||||
color: Theme.of(context)
|
// // color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// // .extension<StackColors>()!
|
||||||
.textSubtitle1,
|
// // .textSubtitle1,
|
||||||
),
|
// // ),
|
||||||
);
|
// // );
|
||||||
}
|
// // }
|
||||||
} else {
|
// // } else {
|
||||||
return AnimatedText(
|
// // return AnimatedText(
|
||||||
stringsToLoopThrough: const [
|
// // stringsToLoopThrough: const [
|
||||||
"Loading",
|
// // "Loading",
|
||||||
"Loading.",
|
// // "Loading.",
|
||||||
"Loading..",
|
// // "Loading..",
|
||||||
"Loading...",
|
// // "Loading...",
|
||||||
],
|
// // ],
|
||||||
style: STextStyles.itemSubtitle12(context)
|
// // style: STextStyles.itemSubtitle12(context)
|
||||||
.copyWith(
|
// // .copyWith(
|
||||||
color: Theme.of(context)
|
// // color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// // .extension<StackColors>()!
|
||||||
.textSubtitle1,
|
// // .textSubtitle1,
|
||||||
),
|
// // ),
|
||||||
);
|
// // );
|
||||||
}
|
// // }
|
||||||
},
|
// // },
|
||||||
),
|
// // ),
|
||||||
// if (!(from != null &&
|
// // // if (!(from != null &&
|
||||||
// to != null &&
|
// // // to != null &&
|
||||||
// (reversed
|
// // // (reversed
|
||||||
// ? toAmount != null && toAmount! > Decimal.zero
|
// // // ? toAmount != null && toAmount! > Decimal.zero
|
||||||
// : fromAmount != null &&
|
// // // : fromAmount != null &&
|
||||||
// fromAmount! > Decimal.zero)))
|
// // // fromAmount! > Decimal.zero)))
|
||||||
if (!(from != null &&
|
// // if (!(from != null &&
|
||||||
to != null &&
|
// // to != null &&
|
||||||
toAmount != null &&
|
// // toAmount != null &&
|
||||||
toAmount! > Decimal.zero &&
|
// // toAmount! > Decimal.zero &&
|
||||||
fromAmount != null &&
|
// // fromAmount != null &&
|
||||||
fromAmount! > Decimal.zero))
|
// // fromAmount! > Decimal.zero))
|
||||||
Text(
|
// // Text(
|
||||||
"n/a",
|
// // "n/a",
|
||||||
style: STextStyles.itemSubtitle12(context)
|
// // style: STextStyles.itemSubtitle12(context)
|
||||||
.copyWith(
|
// // .copyWith(
|
||||||
color: Theme.of(context)
|
// // color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
// // .extension<StackColors>()!
|
||||||
.textSubtitle1,
|
// // .textSubtitle1,
|
||||||
),
|
// // ),
|
||||||
),
|
// // ),
|
||||||
],
|
// // ],
|
||||||
),
|
// // ),
|
||||||
),
|
// // ),
|
||||||
],
|
// ],
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue