mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
async hasConnected ui update
This commit is contained in:
parent
5eb4b3bff5
commit
8a7d669b62
2 changed files with 98 additions and 49 deletions
|
@ -44,6 +44,10 @@ class PaynymDetailsPopup extends ConsumerStatefulWidget {
|
|||
class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
||||
bool _showInsufficientFundsInfo = false;
|
||||
|
||||
Future<void> _onSend() async {
|
||||
// todo send
|
||||
}
|
||||
|
||||
Future<void> _onConnectPressed() async {
|
||||
bool canPop = false;
|
||||
unawaited(
|
||||
|
@ -63,7 +67,7 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
.getManager(widget.walletId)
|
||||
.wallet as DogecoinWallet;
|
||||
|
||||
if (wallet.hasConnected(widget.accountLite.code)) {
|
||||
if (await wallet.hasConnected(widget.accountLite.code)) {
|
||||
canPop = true;
|
||||
Navigator.of(context).pop();
|
||||
// TODO show info popup
|
||||
|
@ -136,6 +140,9 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final wallet = ref.watch(walletsChangeNotifierProvider.select(
|
||||
(value) => value.getManager(widget.walletId).wallet as DogecoinWallet));
|
||||
|
||||
return DesktopDialog(
|
||||
maxWidth: MediaQuery.of(context).size.width - 32,
|
||||
maxHeight: double.infinity,
|
||||
|
@ -168,20 +175,49 @@ class _PaynymDetailsPopupState extends ConsumerState<PaynymDetailsPopup> {
|
|||
),
|
||||
],
|
||||
),
|
||||
PrimaryButton(
|
||||
label: "Connect",
|
||||
buttonHeight: ButtonHeight.l,
|
||||
FutureBuilder(
|
||||
future: wallet.hasConnected(widget.accountLite.code),
|
||||
builder: (context, AsyncSnapshot<bool> snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
if (snapshot.data!) {
|
||||
return PrimaryButton(
|
||||
label: "Send",
|
||||
buttonHeight: ButtonHeight.s,
|
||||
icon: SvgPicture.asset(
|
||||
Assets.svg.circlePlusFilled,
|
||||
width: 10,
|
||||
height: 10,
|
||||
Assets.svg.circleArrowUpRight,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextPrimary,
|
||||
),
|
||||
iconSpacing: 4,
|
||||
width: 86,
|
||||
iconSpacing: 6,
|
||||
onPressed: _onSend,
|
||||
);
|
||||
} else {
|
||||
return PrimaryButton(
|
||||
label: "Connect",
|
||||
buttonHeight: ButtonHeight.s,
|
||||
icon: SvgPicture.asset(
|
||||
Assets.svg.circlePlusFilled,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextPrimary,
|
||||
),
|
||||
iconSpacing: 6,
|
||||
onPressed: _onConnectPressed,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return const SizedBox(
|
||||
height: 100,
|
||||
child: LoadingIndicator(),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -63,7 +63,7 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
.getManager(widget.walletId)
|
||||
.wallet as DogecoinWallet;
|
||||
|
||||
if (wallet.hasConnected(widget.accountLite.code)) {
|
||||
if (await wallet.hasConnected(widget.accountLite.code)) {
|
||||
canPop = true;
|
||||
Navigator.of(context, rootNavigator: true).pop();
|
||||
// TODO show info popup
|
||||
|
@ -187,26 +187,15 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
),
|
||||
Row(
|
||||
children: [
|
||||
if (!wallet.hasConnected(widget.accountLite.code))
|
||||
Expanded(
|
||||
child: PrimaryButton(
|
||||
label: "Connect",
|
||||
buttonHeight: ButtonHeight.s,
|
||||
icon: SvgPicture.asset(
|
||||
Assets.svg.circlePlusFilled,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextPrimary,
|
||||
),
|
||||
iconSpacing: 6,
|
||||
onPressed: _onConnectPressed,
|
||||
),
|
||||
),
|
||||
if (wallet.hasConnected(widget.accountLite.code))
|
||||
Expanded(
|
||||
child: PrimaryButton(
|
||||
child: FutureBuilder(
|
||||
future: wallet.hasConnected(widget.accountLite.code),
|
||||
builder: (context, AsyncSnapshot<bool> snapshot) {
|
||||
if (snapshot.connectionState ==
|
||||
ConnectionState.done &&
|
||||
snapshot.hasData) {
|
||||
if (snapshot.data!) {
|
||||
return PrimaryButton(
|
||||
label: "Send",
|
||||
buttonHeight: ButtonHeight.s,
|
||||
icon: SvgPicture.asset(
|
||||
|
@ -219,6 +208,30 @@ class _PaynymDetailsPopupState extends ConsumerState<DesktopPaynymDetails> {
|
|||
),
|
||||
iconSpacing: 6,
|
||||
onPressed: _onSend,
|
||||
);
|
||||
} else {
|
||||
return PrimaryButton(
|
||||
label: "Connect",
|
||||
buttonHeight: ButtonHeight.s,
|
||||
icon: SvgPicture.asset(
|
||||
Assets.svg.circlePlusFilled,
|
||||
width: 16,
|
||||
height: 16,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.buttonTextPrimary,
|
||||
),
|
||||
iconSpacing: 6,
|
||||
onPressed: _onConnectPressed,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return const SizedBox(
|
||||
height: 100,
|
||||
child: LoadingIndicator(),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
|
|
Loading…
Reference in a new issue