stack_wallet/lib/providers/ui/preview_tx_button_state_provider.dart

52 lines
1.7 KiB
Dart
Raw Normal View History

2023-05-26 21:21:16 +00:00
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
2022-08-26 08:11:35 +00:00
import 'package:flutter_riverpod/flutter_riverpod.dart';
2024-06-25 20:46:36 +00:00
import '../../utilities/amount/amount.dart';
import '../../wallets/crypto_currency/crypto_currency.dart';
2024-06-25 20:46:36 +00:00
import '../wallet/public_private_balance_state_provider.dart';
2022-08-26 08:11:35 +00:00
final pSendAmount = StateProvider.autoDispose<Amount?>((_) => null);
final pValidSendToAddress = StateProvider.autoDispose<bool>((_) => false);
final pValidSparkSendToAddress = StateProvider.autoDispose<bool>((_) => false);
2024-06-25 20:46:36 +00:00
final pIsExchangeAddress = StateProvider<bool>((_) => false);
final pPreviewTxButtonEnabled =
2024-05-15 21:20:45 +00:00
Provider.autoDispose.family<bool, CryptoCurrency>((ref, coin) {
final amount = ref.watch(pSendAmount) ?? Amount.zero;
2024-05-15 21:20:45 +00:00
if (coin is Firo) {
2024-06-25 20:46:36 +00:00
final firoType = ref.watch(publicPrivateBalanceStateProvider);
switch (firoType) {
case FiroType.lelantus:
return ref.watch(pValidSendToAddress) &&
!ref.watch(pValidSparkSendToAddress) &&
amount > Amount.zero;
case FiroType.spark:
return (ref.watch(pValidSendToAddress) ||
ref.watch(pValidSparkSendToAddress)) &&
!ref.watch(pIsExchangeAddress) &&
amount > Amount.zero;
case FiroType.public:
return ref.watch(pValidSendToAddress) && amount > Amount.zero;
}
} else {
return ref.watch(pValidSendToAddress) && amount > Amount.zero;
}
2023-04-13 15:21:27 +00:00
});
2022-08-26 08:11:35 +00:00
2023-04-13 15:21:27 +00:00
final previewTokenTxButtonStateProvider = StateProvider.autoDispose<bool>((_) {
2022-08-26 08:11:35 +00:00
return false;
});