mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 17:57:40 +00:00
claiming paynym spinner dialog
This commit is contained in:
parent
5c8f72afa6
commit
f897b67714
4 changed files with 137 additions and 3 deletions
114
lib/pages/paynym/dialogs/claiming_paynym_dialog.dart
Normal file
114
lib/pages/paynym/dialogs/claiming_paynym_dialog.dart
Normal file
|
@ -0,0 +1,114 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
|
||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||
|
||||
class ClaimingPaynymDialog extends StatefulWidget {
|
||||
const ClaimingPaynymDialog({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ClaimingPaynymDialog> createState() => _RestoringDialogState();
|
||||
}
|
||||
|
||||
class _RestoringDialogState extends State<ClaimingPaynymDialog>
|
||||
with TickerProviderStateMixin {
|
||||
late AnimationController? _spinController;
|
||||
late Animation<double> _spinAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_spinController = AnimationController(
|
||||
duration: const Duration(seconds: 2),
|
||||
vsync: this,
|
||||
)..repeat();
|
||||
|
||||
_spinAnimation = CurvedAnimation(
|
||||
parent: _spinController!,
|
||||
curve: Curves.linear,
|
||||
);
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_spinController?.dispose();
|
||||
_spinController = null;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (Util.isDesktop) {
|
||||
return DesktopDialog(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(40),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
"Claiming PayNym",
|
||||
style: STextStyles.desktopH3(context),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Text(
|
||||
"We are generating your PayNym",
|
||||
style: STextStyles.desktopSubtitleH1(context),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 40,
|
||||
),
|
||||
RotationTransition(
|
||||
turns: _spinAnimation,
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.arrowRotate,
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return WillPopScope(
|
||||
onWillPop: () async {
|
||||
return false;
|
||||
},
|
||||
child: StackDialog(
|
||||
title: "Claiming PayNym",
|
||||
message: "We are generating your PayNym",
|
||||
icon: RotationTransition(
|
||||
turns: _spinAnimation,
|
||||
child: SvgPicture.asset(
|
||||
Assets.svg.arrowRotate,
|
||||
color:
|
||||
Theme.of(context).extension<StackColors>()!.accentColorDark,
|
||||
width: 24,
|
||||
height: 24,
|
||||
),
|
||||
),
|
||||
rightButton: SecondaryButton(
|
||||
label: "Cancel",
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
|
@ -7,6 +9,8 @@ import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
|||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||
import 'package:stackwallet/widgets/desktop/primary_button.dart';
|
||||
|
||||
import 'dialogs/claiming_paynym_dialog.dart';
|
||||
|
||||
class PaynymClaimView extends StatefulWidget {
|
||||
const PaynymClaimView({Key? key}) : super(key: key);
|
||||
|
||||
|
@ -67,8 +71,21 @@ class _PaynymClaimViewState extends State<PaynymClaimView> {
|
|||
),
|
||||
PrimaryButton(
|
||||
label: "Claim",
|
||||
onPressed: () {
|
||||
onPressed: () async {
|
||||
bool shouldCancel = false;
|
||||
unawaited(
|
||||
showDialog<bool?>(
|
||||
context: context,
|
||||
builder: (context) => const ClaimingPaynymDialog(),
|
||||
).then((value) => shouldCancel = value == true),
|
||||
);
|
||||
// generate and submit paynym to api
|
||||
|
||||
await Future<void>.delayed(const Duration(seconds: 3));
|
||||
|
||||
if (mounted && !shouldCancel) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:stackwallet/pages/paynym/paynym_claim_view.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/theme/stack_colors.dart';
|
||||
|
||||
import '../../paynym/paynym_claim_view.dart';
|
||||
|
||||
class WalletNavigationBar extends StatefulWidget {
|
||||
const WalletNavigationBar({
|
||||
Key? key,
|
||||
|
|
4
lib/providers/global/paynym_api_provider.dart
Normal file
4
lib/providers/global/paynym_api_provider.dart
Normal file
|
@ -0,0 +1,4 @@
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:stackwallet/utilities/paynym_api.dart';
|
||||
|
||||
final paynymAPIProvider = Provider<PaynymAPI>((_) => PaynymAPI());
|
Loading…
Reference in a new issue