ensure only one firo ex addr popup is active at any one time

This commit is contained in:
julian 2024-06-25 15:20:55 -06:00
parent f634ce8701
commit 769edc3bc0
3 changed files with 32 additions and 8 deletions

View file

@ -128,6 +128,8 @@ class _SendViewState extends ConsumerState<SendView> {
bool _addressToggleFlag = false;
bool _isFiroExWarningDisplayed = false;
bool _cryptoAmountChangeLock = false;
late VoidCallback onCryptoAmountChanged;
@ -400,8 +402,13 @@ class _SendViewState extends ConsumerState<SendView> {
(coin as Firo).isExchangeAddress(_address ?? "");
if (ref.read(publicPrivateBalanceStateProvider) == FiroType.spark &&
ref.read(pIsExchangeAddress)) {
showFiroExchangeAddressWarning(context);
ref.read(pIsExchangeAddress) &&
!_isFiroExWarningDisplayed) {
_isFiroExWarningDisplayed = true;
showFiroExchangeAddressWarning(
context,
() => _isFiroExWarningDisplayed = false,
);
}
}
@ -1034,9 +1041,16 @@ class _SendViewState extends ConsumerState<SendView> {
});
}
if (previous != next && next == FiroType.spark && isExchangeAddress) {
if (previous != next &&
next == FiroType.spark &&
isExchangeAddress &&
!_isFiroExWarningDisplayed) {
_isFiroExWarningDisplayed = true;
WidgetsBinding.instance.addPostFrameCallback(
(_) => showFiroExchangeAddressWarning(context),
(_) => showFiroExchangeAddressWarning(
context,
() => _isFiroExWarningDisplayed = false,
),
);
}
});

View file

@ -122,6 +122,8 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
bool _addressToggleFlag = false;
bool _isFiroExWarningDisplayed = false;
bool _cryptoAmountChangeLock = false;
late VoidCallback onCryptoAmountChanged;
@ -951,9 +953,13 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
final firoType = ref.watch(publicPrivateBalanceStateProvider);
if (coin is Firo && firoType == FiroType.spark) {
if (ref.watch(pIsExchangeAddress)) {
if (ref.watch(pIsExchangeAddress) && !_isFiroExWarningDisplayed) {
_isFiroExWarningDisplayed = true;
WidgetsBinding.instance.addPostFrameCallback(
(_) => showFiroExchangeAddressWarning(context),
(_) => showFiroExchangeAddressWarning(
context,
() => _isFiroExWarningDisplayed = false,
),
);
}
}

View file

@ -18,9 +18,13 @@ class FiroExchangeAddressDialog extends StatelessWidget {
}
}
Future<void> showFiroExchangeAddressWarning(BuildContext context) async {
return await showDialog<void>(
Future<void> showFiroExchangeAddressWarning(
BuildContext context,
VoidCallback onClosed,
) async {
await showDialog<void>(
context: context,
builder: (_) => const FiroExchangeAddressDialog(),
);
onClosed();
}