mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-09 12:19:24 +00:00
simplex supported currencies provider -> simplex provider
we may need to store a quote or "estimate" in the provider for UI dataflow purposes (because we can't run async functions in widget builds/constructors?)
This commit is contained in:
parent
bda6865657
commit
7eefe196c9
5 changed files with 18 additions and 20 deletions
|
@ -1,8 +1,10 @@
|
||||||
|
import 'package:decimal/decimal.dart';
|
||||||
import 'package:stackwallet/models/buy/response_objects/crypto.dart';
|
import 'package:stackwallet/models/buy/response_objects/crypto.dart';
|
||||||
import 'package:stackwallet/models/buy/response_objects/fiat.dart';
|
import 'package:stackwallet/models/buy/response_objects/fiat.dart';
|
||||||
|
import 'package:stackwallet/models/buy/response_objects/quote.dart';
|
||||||
// import 'package:stackwallet/models/buy/response_objects/pair.dart';
|
// import 'package:stackwallet/models/buy/response_objects/pair.dart';
|
||||||
|
|
||||||
class SimplexSupportedCurrencies {
|
class Simplex {
|
||||||
List<Crypto> supportedCryptos = [];
|
List<Crypto> supportedCryptos = [];
|
||||||
List<Fiat> supportedFiats = [];
|
List<Fiat> supportedFiats = [];
|
||||||
|
|
|
@ -84,7 +84,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
||||||
void cryptoFieldOnChanged(String value) async {}
|
void cryptoFieldOnChanged(String value) async {}
|
||||||
|
|
||||||
void selectCrypto() async {
|
void selectCrypto() async {
|
||||||
if (ref.read(supportedSimplexCurrenciesProvider).supportedCryptos.isEmpty) {
|
if (ref.read(simplexProvider).supportedCryptos.isEmpty) {
|
||||||
bool shouldPop = false;
|
bool shouldPop = false;
|
||||||
unawaited(
|
unawaited(
|
||||||
showDialog(
|
showDialog(
|
||||||
|
@ -106,7 +106,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
||||||
}
|
}
|
||||||
|
|
||||||
await _showFloatingCryptoSelectionSheet(
|
await _showFloatingCryptoSelectionSheet(
|
||||||
coins: ref.read(supportedSimplexCurrenciesProvider).supportedCryptos,
|
coins: ref.read(simplexProvider).supportedCryptos,
|
||||||
onSelected: (crypto) {
|
onSelected: (crypto) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedCrypto = crypto;
|
selectedCrypto = crypto;
|
||||||
|
@ -188,7 +188,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> selectFiat() async {
|
Future<void> selectFiat() async {
|
||||||
if (ref.read(supportedSimplexCurrenciesProvider).supportedFiats.isEmpty) {
|
if (ref.read(simplexProvider).supportedFiats.isEmpty) {
|
||||||
bool shouldPop = false;
|
bool shouldPop = false;
|
||||||
unawaited(
|
unawaited(
|
||||||
showDialog(
|
showDialog(
|
||||||
|
@ -210,7 +210,7 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
||||||
}
|
}
|
||||||
|
|
||||||
await _showFloatingFiatSelectionSheet(
|
await _showFloatingFiatSelectionSheet(
|
||||||
fiats: ref.read(supportedSimplexCurrenciesProvider).supportedFiats,
|
fiats: ref.read(simplexProvider).supportedFiats,
|
||||||
onSelected: (fiat) {
|
onSelected: (fiat) {
|
||||||
setState(() {
|
setState(() {
|
||||||
selectedFiat = fiat;
|
selectedFiat = fiat;
|
||||||
|
@ -223,12 +223,8 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
||||||
final response = await SimplexAPI.instance.getSupported();
|
final response = await SimplexAPI.instance.getSupported();
|
||||||
|
|
||||||
if (response.value != null) {
|
if (response.value != null) {
|
||||||
ref
|
ref.read(simplexProvider).updateSupportedCryptos(response.value!.item1);
|
||||||
.read(supportedSimplexCurrenciesProvider)
|
ref.read(simplexProvider).updateSupportedFiats(response.value!.item2);
|
||||||
.updateSupportedCryptos(response.value!.item1);
|
|
||||||
ref
|
|
||||||
.read(supportedSimplexCurrenciesProvider)
|
|
||||||
.updateSupportedFiats(response.value!.item2);
|
|
||||||
} else {
|
} else {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"_loadSimplexCurrencies: $response",
|
"_loadSimplexCurrencies: $response",
|
||||||
|
@ -334,8 +330,8 @@ class _BuyFormState extends ConsumerState<BuyForm> {
|
||||||
clipboard = widget.clipboard;
|
clipboard = widget.clipboard;
|
||||||
scanner = widget.scanner;
|
scanner = widget.scanner;
|
||||||
|
|
||||||
coins = ref.read(supportedSimplexCurrenciesProvider).supportedCryptos;
|
coins = ref.read(simplexProvider).supportedCryptos;
|
||||||
fiats = ref.read(supportedSimplexCurrenciesProvider).supportedFiats;
|
fiats = ref.read(simplexProvider).supportedFiats;
|
||||||
|
|
||||||
// TODO set initial crypto to open wallet if a wallet is open
|
// TODO set initial crypto to open wallet if a wallet is open
|
||||||
|
|
||||||
|
|
6
lib/providers/buy/simplex_provider.dart
Normal file
6
lib/providers/buy/simplex_provider.dart
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:stackwallet/models/buy/simplex/simplex.dart';
|
||||||
|
|
||||||
|
final simplexProvider = Provider<Simplex>(
|
||||||
|
(ref) => Simplex(),
|
||||||
|
);
|
|
@ -1,6 +0,0 @@
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
||||||
import 'package:stackwallet/models/buy/simplex/simplex_supported_currencies.dart';
|
|
||||||
|
|
||||||
final supportedSimplexCurrenciesProvider = Provider<SimplexSupportedCurrencies>(
|
|
||||||
(ref) => SimplexSupportedCurrencies(),
|
|
||||||
);
|
|
|
@ -1,6 +1,6 @@
|
||||||
export './buy/buy_form_state_provider.dart';
|
export './buy/buy_form_state_provider.dart';
|
||||||
export './buy/simplex_initial_load_status.dart';
|
export './buy/simplex_initial_load_status.dart';
|
||||||
export './buy/simplex_supported_currencies_provider.dart';
|
export './buy/simplex_provider.dart';
|
||||||
export './exchange/available_changenow_currencies_provider.dart';
|
export './exchange/available_changenow_currencies_provider.dart';
|
||||||
export './exchange/available_simpleswap_currencies_provider.dart';
|
export './exchange/available_simpleswap_currencies_provider.dart';
|
||||||
export './exchange/changenow_initial_load_status.dart';
|
export './exchange/changenow_initial_load_status.dart';
|
||||||
|
|
Loading…
Reference in a new issue