mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-03-12 09:27:01 +00:00
show insufficient balance warning on connect to paynym attempt
This commit is contained in:
parent
512711183c
commit
039508ee32
2 changed files with 103 additions and 40 deletions
lib/pages/paynym
|
@ -15,6 +15,7 @@ import 'package:stackwallet/route_generator.dart';
|
||||||
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
||||||
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart';
|
||||||
|
@ -22,6 +23,7 @@ import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||||
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
|
|
||||||
class PaynymDetailsPopup extends ConsumerStatefulWidget {
|
class PaynymDetailsPopup extends ConsumerStatefulWidget {
|
||||||
const PaynymDetailsPopup({
|
const PaynymDetailsPopup({
|
||||||
|
@ -38,6 +40,8 @@ class PaynymDetailsPopup extends ConsumerStatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
||||||
|
bool _showInsufficientFundsInfo = false;
|
||||||
|
|
||||||
Future<void> _onConnectPressed() async {
|
Future<void> _onConnectPressed() async {
|
||||||
bool canPop = false;
|
bool canPop = false;
|
||||||
unawaited(
|
unawaited(
|
||||||
|
@ -79,13 +83,14 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
||||||
selectedTxFeeRate: rates.medium,
|
selectedTxFeeRate: rates.medium,
|
||||||
targetPaymentCodeString: widget.accountLite.code,
|
targetPaymentCodeString: widget.accountLite.code,
|
||||||
);
|
);
|
||||||
} on InsufficientBalanceException catch (e) {
|
} on InsufficientBalanceException catch (_) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
canPop = true;
|
canPop = true;
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
// TODO show info popup
|
setState(() {
|
||||||
print(e);
|
_showInsufficientFundsInfo = true;
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,39 +150,69 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
||||||
right: 24,
|
right: 24,
|
||||||
bottom: 16,
|
bottom: 16,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
PayNymBot(
|
Row(
|
||||||
paymentCodeString: widget.accountLite.code,
|
children: [
|
||||||
size: 32,
|
PayNymBot(
|
||||||
|
paymentCodeString: widget.accountLite.code,
|
||||||
|
size: 32,
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 12,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
widget.accountLite.nymName,
|
||||||
|
style: STextStyles.w600_12(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(
|
PrimaryButton(
|
||||||
width: 12,
|
label: "Connect",
|
||||||
),
|
buttonHeight: ButtonHeight.l,
|
||||||
Text(
|
icon: SvgPicture.asset(
|
||||||
widget.accountLite.nymName,
|
Assets.svg.circlePlusFilled,
|
||||||
style: STextStyles.w600_12(context),
|
width: 10,
|
||||||
|
height: 10,
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextPrimary,
|
||||||
|
),
|
||||||
|
iconSpacing: 4,
|
||||||
|
width: 86,
|
||||||
|
onPressed: _onConnectPressed,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
PrimaryButton(
|
if (_showInsufficientFundsInfo)
|
||||||
label: "Connect",
|
Column(
|
||||||
buttonHeight: ButtonHeight.l,
|
mainAxisSize: MainAxisSize.min,
|
||||||
icon: SvgPicture.asset(
|
children: [
|
||||||
Assets.svg.circlePlusFilled,
|
const SizedBox(
|
||||||
width: 10,
|
height: 24,
|
||||||
height: 10,
|
),
|
||||||
color: Theme.of(context)
|
RoundedContainer(
|
||||||
.extension<StackColors>()!
|
color: Theme.of(context)
|
||||||
.buttonTextPrimary,
|
.extension<StackColors>()!
|
||||||
|
.warningBackground,
|
||||||
|
child: Text(
|
||||||
|
"Adding a PayNym to your contacts requires a one-time "
|
||||||
|
"transaction fee for creating the record on the "
|
||||||
|
"blockchain. Please deposit more "
|
||||||
|
"${ref.read(walletsChangeNotifierProvider).getManager(widget.walletId).wallet.coin.ticker} "
|
||||||
|
"into your wallet and try again.",
|
||||||
|
style: STextStyles.infoSmall(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.warningForeground,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
iconSpacing: 4,
|
|
||||||
width: 86,
|
|
||||||
onPressed: _onConnectPressed,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
@ -6,6 +6,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:qr_flutter/qr_flutter.dart';
|
import 'package:qr_flutter/qr_flutter.dart';
|
||||||
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
import 'package:stackwallet/models/paynym/paynym_account_lite.dart';
|
||||||
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart';
|
import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart';
|
||||||
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
|
import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart';
|
||||||
import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart';
|
import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart';
|
||||||
|
@ -14,16 +15,16 @@ import 'package:stackwallet/route_generator.dart';
|
||||||
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
import 'package:stackwallet/services/coins/coin_paynym_extension.dart';
|
||||||
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||||
import 'package:stackwallet/widgets/loading_indicator.dart';
|
import 'package:stackwallet/widgets/loading_indicator.dart';
|
||||||
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
|
|
||||||
import '../../../notifications/show_flush_bar.dart';
|
|
||||||
|
|
||||||
class DesktopPaynymDetails extends ConsumerStatefulWidget {
|
class DesktopPaynymDetails extends ConsumerStatefulWidget {
|
||||||
const DesktopPaynymDetails({
|
const DesktopPaynymDetails({
|
||||||
Key? key,
|
Key? key,
|
||||||
|
@ -40,6 +41,8 @@ class DesktopPaynymDetails extends ConsumerStatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
||||||
|
bool _showInsufficientFundsInfo = false;
|
||||||
|
|
||||||
Future<void> _onConnectPressed() async {
|
Future<void> _onConnectPressed() async {
|
||||||
bool canPop = false;
|
bool canPop = false;
|
||||||
unawaited(
|
unawaited(
|
||||||
|
@ -59,15 +62,15 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
||||||
.getManager(widget.walletId)
|
.getManager(widget.walletId)
|
||||||
.wallet as DogecoinWallet;
|
.wallet as DogecoinWallet;
|
||||||
|
|
||||||
// sanity check to prevent second notifcation tx
|
// sanity check to prevent second notification tx
|
||||||
if (wallet.hasConnectedConfirmed(widget.accountLite.code)) {
|
if (wallet.hasConnectedConfirmed(widget.accountLite.code)) {
|
||||||
canPop = true;
|
canPop = true;
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
// TODO show info popup
|
// TODO show info popup
|
||||||
return;
|
return;
|
||||||
} else if (wallet.hasConnected(widget.accountLite.code)) {
|
} else if (wallet.hasConnected(widget.accountLite.code)) {
|
||||||
canPop = true;
|
canPop = true;
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
// TODO show info popup
|
// TODO show info popup
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -84,10 +87,11 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
||||||
} on InsufficientBalanceException catch (e) {
|
} on InsufficientBalanceException catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
canPop = true;
|
canPop = true;
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
}
|
}
|
||||||
// TODO show info popup
|
setState(() {
|
||||||
print(e);
|
_showInsufficientFundsInfo = true;
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,10 +100,7 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
||||||
|
|
||||||
canPop = true;
|
canPop = true;
|
||||||
// close loading
|
// close loading
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context, rootNavigator: true).pop();
|
||||||
|
|
||||||
// Close details
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
// show info pop up
|
// show info pop up
|
||||||
await showDialog<void>(
|
await showDialog<void>(
|
||||||
|
@ -192,6 +193,33 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
if (_showInsufficientFundsInfo)
|
||||||
|
Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const SizedBox(
|
||||||
|
height: 24,
|
||||||
|
),
|
||||||
|
RoundedContainer(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.warningBackground,
|
||||||
|
child: Text(
|
||||||
|
"Adding a PayNym to your contacts requires a one-time "
|
||||||
|
"transaction fee for creating the record on the "
|
||||||
|
"blockchain. Please deposit more "
|
||||||
|
"${ref.read(walletsChangeNotifierProvider).getManager(widget.walletId).wallet.coin.ticker} "
|
||||||
|
"into your wallet and try again.",
|
||||||
|
style: STextStyles.desktopTextExtraExtraSmall(context)
|
||||||
|
.copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.warningForeground,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue