arrow rotate and svg usage clean up

This commit is contained in:
julian 2023-04-24 16:26:54 -06:00
parent dbc34168ef
commit ef87517705
10 changed files with 182 additions and 386 deletions

View file

@ -1,9 +1,8 @@
import 'package:flutter/material.dart'; 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/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart';
@ -21,37 +20,15 @@ class RestoringDialog extends StatefulWidget {
State<RestoringDialog> createState() => _RestoringDialogState(); State<RestoringDialog> createState() => _RestoringDialogState();
} }
class _RestoringDialogState extends State<RestoringDialog> class _RestoringDialogState extends State<RestoringDialog> {
with TickerProviderStateMixin {
late AnimationController? _spinController;
late Animation<double> _spinAnimation;
late final Future<void> Function() onCancel; late final Future<void> Function() onCancel;
@override @override
void initState() { void initState() {
onCancel = widget.onCancel; onCancel = widget.onCancel;
_spinController = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat();
_spinAnimation = CurvedAnimation(
parent: _spinController!,
curve: Curves.linear,
);
super.initState(); super.initState();
} }
@override
void dispose() {
_spinController?.dispose();
_spinController = null;
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (Util.isDesktop) { if (Util.isDesktop) {
@ -69,14 +46,9 @@ class _RestoringDialogState extends State<RestoringDialog>
const Spacer( const Spacer(
flex: 1, flex: 1,
), ),
RotationTransition( const RotatingArrows(
turns: _spinAnimation, width: 40,
child: SvgPicture.asset(Assets.svg.arrowRotate, height: 40,
width: 40,
height: 40,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
), ),
const Spacer( const Spacer(
flex: 2, flex: 2,
@ -127,14 +99,9 @@ class _RestoringDialogState extends State<RestoringDialog>
child: StackDialog( child: StackDialog(
title: "Restoring wallet", title: "Restoring wallet",
message: "This may take a while. Please do not exit this screen.", message: "This may take a while. Please do not exit this screen.",
icon: RotationTransition( icon: const RotatingArrows(
turns: _spinAnimation, width: 24,
child: SvgPicture.asset(Assets.svg.arrowRotate, height: 24,
width: 24,
height: 24,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark),
), ),
rightButton: TextButton( rightButton: TextButton(
style: Theme.of(context) style: Theme.of(context)

View file

@ -1,11 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:lottie/lottie.dart';
import 'package:stackwallet/utilities/assets.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/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_widgets/rotate_animation.dart'; import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart';
@ -20,40 +17,7 @@ class ClaimingPaynymDialog extends StatefulWidget {
State<ClaimingPaynymDialog> createState() => _RestoringDialogState(); State<ClaimingPaynymDialog> createState() => _RestoringDialogState();
} }
class _RestoringDialogState extends State<ClaimingPaynymDialog> class _RestoringDialogState extends State<ClaimingPaynymDialog> {
with TickerProviderStateMixin {
late AnimationController? _spinController;
late Animation<double> _spinAnimation;
late RotateAnimationController? _rotateAnimationController;
@override
void initState() {
_spinController = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat();
_spinAnimation = CurvedAnimation(
parent: _spinController!,
curve: Curves.linear,
);
_rotateAnimationController = RotateAnimationController();
super.initState();
}
@override
void dispose() {
_spinController?.dispose();
_spinController = null;
_rotateAnimationController?.forward = null;
_rotateAnimationController?.reset = null;
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (Util.isDesktop) { if (Util.isDesktop) {
@ -70,15 +34,9 @@ class _RestoringDialogState extends State<ClaimingPaynymDialog>
), ),
], ],
), ),
RotationTransition( const RotatingArrows(
turns: _spinAnimation, width: 40,
child: SvgPicture.asset( height: 40,
Assets.svg.arrowRotate,
color:
Theme.of(context).extension<StackColors>()!.accentColorDark,
width: 40,
height: 40,
),
), ),
Padding( Padding(
padding: const EdgeInsets.all(40), padding: const EdgeInsets.all(40),
@ -123,38 +81,9 @@ class _RestoringDialogState extends State<ClaimingPaynymDialog>
child: StackDialog( child: StackDialog(
title: "Claiming PayNym", title: "Claiming PayNym",
message: "We are generating your PayNym", message: "We are generating your PayNym",
// icon: RotationTransition( icon: const RotatingArrows(
// turns: _spinAnimation, width: 24,
// child: SvgPicture.asset( height: 24,
// Assets.svg.arrowRotate,
// color:
// Theme.of(context).extension<StackColors>()!.accentColorDark,
// width: 24,
// height: 24,
// ),
// ),
icon: RotateAnimation(
lottie: Lottie.asset(
Assets.lottie.arrowRotate,
delegates: LottieDelegates(
values: [
ValueDelegate.color(
const ["**"],
value: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
ValueDelegate.strokeColor(
const ["**"],
value: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
],
),
),
curve: Curves.easeInOutCubic,
controller: _rotateAnimationController,
), ),
rightButton: SecondaryButton( rightButton: SecondaryButton(
label: "Cancel", label: "Cancel",

View file

@ -1,17 +1,14 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:lottie/lottie.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/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart';
import '../../../widgets/animated_widgets/rotate_animation.dart';
class BuildingTransactionDialog extends StatefulWidget { class BuildingTransactionDialog extends StatefulWidget {
const BuildingTransactionDialog({ const BuildingTransactionDialog({
Key? key, Key? key,
@ -26,45 +23,16 @@ class BuildingTransactionDialog extends StatefulWidget {
State<BuildingTransactionDialog> createState() => _RestoringDialogState(); State<BuildingTransactionDialog> createState() => _RestoringDialogState();
} }
class _RestoringDialogState extends State<BuildingTransactionDialog> class _RestoringDialogState extends State<BuildingTransactionDialog> {
with TickerProviderStateMixin {
late AnimationController? _spinController;
late Animation<double> _spinAnimation;
late RotateAnimationController? _rotateAnimationController;
late final VoidCallback onCancel; late final VoidCallback onCancel;
@override @override
void initState() { void initState() {
onCancel = widget.onCancel; onCancel = widget.onCancel;
_spinController = AnimationController(
duration: const Duration(seconds: 2),
vsync: this,
)..repeat();
_spinAnimation = CurvedAnimation(
parent: _spinController!,
curve: Curves.linear,
);
_rotateAnimationController = RotateAnimationController();
super.initState(); super.initState();
} }
@override
void dispose() {
_spinController?.dispose();
_spinController = null;
_rotateAnimationController?.forward = null;
_rotateAnimationController?.reset = null;
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final isChans = Theme.of(context).extension<StackColors>()!.themeType == final isChans = Theme.of(context).extension<StackColors>()!.themeType ==
@ -90,28 +58,9 @@ class _RestoringDialogState extends State<BuildingTransactionDialog>
), ),
), ),
if (!isChans) if (!isChans)
RotateAnimation( const RotatingArrows(
lottie: Lottie.asset( width: 40,
Assets.lottie.arrowRotate, height: 40,
delegates: LottieDelegates(
values: [
ValueDelegate.color(
const ["**"],
value: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
ValueDelegate.strokeColor(
const ["**"],
value: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
),
],
),
),
curve: Curves.easeInOutCubic,
controller: _rotateAnimationController,
), ),
const SizedBox( const SizedBox(
height: 40, height: 40,
@ -174,16 +123,9 @@ class _RestoringDialogState extends State<BuildingTransactionDialog>
) )
: StackDialog( : StackDialog(
title: "Generating transaction", title: "Generating transaction",
icon: RotationTransition( icon: const RotatingArrows(
turns: _spinAnimation, width: 24,
child: SvgPicture.asset( height: 24,
Assets.svg.arrowRotate,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
width: 24,
height: 24,
),
), ),
rightButton: TextButton( rightButton: TextButton(
style: Theme.of(context) style: Theme.of(context)

View file

@ -214,7 +214,7 @@ class _StackRestoreProgressViewState
@override @override
void initState() { void initState() {
WidgetsBinding.instance.addPostFrameCallback((_) async { WidgetsBinding.instance.addPostFrameCallback((_) async {
_restore(); unawaited(_restore());
}); });
super.initState(); super.initState();
} }
@ -325,7 +325,7 @@ class _StackRestoreProgressViewState
: null, : null,
) )
: RoundedContainer( : RoundedContainer(
padding: EdgeInsets.all(0), padding: EdgeInsets.zero,
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.popupBG, .popupBG,
@ -411,7 +411,7 @@ class _StackRestoreProgressViewState
: null, : null,
) )
: RoundedContainer( : RoundedContainer(
padding: EdgeInsets.all(0), padding: EdgeInsets.zero,
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.popupBG, .popupBG,
@ -497,7 +497,7 @@ class _StackRestoreProgressViewState
: null, : null,
) )
: RoundedContainer( : RoundedContainer(
padding: EdgeInsets.all(0), padding: EdgeInsets.zero,
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.popupBG, .popupBG,
@ -548,44 +548,42 @@ class _StackRestoreProgressViewState
final state = ref.watch(stackRestoringUIStateProvider final state = ref.watch(stackRestoringUIStateProvider
.select((value) => value.trades)); .select((value) => value.trades));
return !isDesktop return !isDesktop
? Container( ? RestoringItemCard(
child: RestoringItemCard( left: SizedBox(
left: SizedBox( width: 32,
width: 32, height: 32,
height: 32, child: RoundedContainer(
child: RoundedContainer( padding: const EdgeInsets.all(0),
padding: const EdgeInsets.all(0), color: Theme.of(context)
color: Theme.of(context) .extension<StackColors>()!
.extension<StackColors>()! .buttonBackSecondary,
.buttonBackSecondary, child: Center(
child: Center( child: SvgPicture.asset(
child: SvgPicture.asset( Assets.svg.arrowsTwoWay,
Assets.svg.arrowsTwoWay, width: 16,
width: 16, height: 16,
height: 16, color: Theme.of(context)
color: Theme.of(context) .extension<StackColors>()!
.extension<StackColors>()! .accentColorDark,
.accentColorDark,
),
), ),
), ),
), ),
right: SizedBox(
width: 20,
height: 20,
child: _getIconForState(state),
),
title: "Exchange history",
subTitle: state == StackRestoringStatus.failed
? Text(
"Something went wrong",
style: STextStyles.errorSmall(context),
)
: null,
), ),
right: SizedBox(
width: 20,
height: 20,
child: _getIconForState(state),
),
title: "Exchange history",
subTitle: state == StackRestoringStatus.failed
? Text(
"Something went wrong",
style: STextStyles.errorSmall(context),
)
: null,
) )
: RoundedContainer( : RoundedContainer(
padding: EdgeInsets.all(0), padding: EdgeInsets.zero,
color: Theme.of(context) color: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.popupBG, .popupBG,

View file

@ -1,8 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart';
import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart';
@ -66,18 +64,12 @@ class _RescanningDialogState extends State<RescanningDialog>
maxWidth: 500, maxWidth: 500,
child: child, child: child,
), ),
child: StackDialog( child: const StackDialog(
title: "Rescanning blockchain", title: "Rescanning blockchain",
message: "This may take a while. Please do not exit this screen.", message: "This may take a while. Please do not exit this screen.",
icon: RotationTransition( icon: RotatingArrows(
turns: _spinAnimation, width: 24,
child: SvgPicture.asset( height: 24,
Assets.svg.arrowRotate,
width: 24,
height: 24,
color:
Theme.of(context).extension<StackColors>()!.accentColorDark,
),
), ),
// rightButton: TextButton( // rightButton: TextButton(
// style: Theme.of(context).textButtonTheme.style?.copyWith( // style: Theme.of(context).textButtonTheme.style?.copyWith(

View file

@ -3,15 +3,14 @@ import 'dart:async';
import 'package:event_bus/event_bus.dart'; import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages/token_view/token_view.dart'; import 'package:stackwallet/pages/token_view/token_view.dart';
import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/global/wallets_provider.dart';
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/global_event_bus.dart'; import 'package:stackwallet/services/event_bus/global_event_bus.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart';
/// [eventBus] should only be set during testing /// [eventBus] should only be set during testing
class WalletRefreshButton extends ConsumerStatefulWidget { class WalletRefreshButton extends ConsumerStatefulWidget {
@ -36,30 +35,16 @@ class WalletRefreshButton extends ConsumerStatefulWidget {
ConsumerState<WalletRefreshButton> createState() => _RefreshButtonState(); ConsumerState<WalletRefreshButton> createState() => _RefreshButtonState();
} }
class _RefreshButtonState extends ConsumerState<WalletRefreshButton> class _RefreshButtonState extends ConsumerState<WalletRefreshButton> {
with TickerProviderStateMixin {
late final EventBus eventBus; late final EventBus eventBus;
late AnimationController? _spinController; late RotatingArrowsController _spinController;
late Animation<double> _spinAnimation;
late StreamSubscription<dynamic> _syncStatusSubscription; late StreamSubscription<dynamic> _syncStatusSubscription;
@override @override
void initState() { void initState() {
_spinController = AnimationController( _spinController = RotatingArrowsController();
duration: const Duration(seconds: 2),
vsync: this,
);
_spinAnimation = CurvedAnimation(
parent: _spinController!,
curve: Curves.linear,
);
if (widget.initialSyncStatus == WalletSyncStatus.syncing) {
_spinController?.repeat();
}
eventBus = eventBus =
widget.eventBus != null ? widget.eventBus! : GlobalEventBus.instance; widget.eventBus != null ? widget.eventBus! : GlobalEventBus.instance;
@ -71,26 +56,26 @@ class _RefreshButtonState extends ConsumerState<WalletRefreshButton>
widget.tokenContractAddress == null) { widget.tokenContractAddress == null) {
switch (event.newStatus) { switch (event.newStatus) {
case WalletSyncStatus.unableToSync: case WalletSyncStatus.unableToSync:
_spinController?.stop(); _spinController.stop?.call();
break; break;
case WalletSyncStatus.synced: case WalletSyncStatus.synced:
_spinController?.stop(); _spinController.stop?.call();
break; break;
case WalletSyncStatus.syncing: case WalletSyncStatus.syncing:
unawaited(_spinController?.repeat()); _spinController.repeat?.call();
break; break;
} }
} else if (widget.tokenContractAddress != null && } else if (widget.tokenContractAddress != null &&
event.walletId == widget.walletId + widget.tokenContractAddress!) { event.walletId == widget.walletId + widget.tokenContractAddress!) {
switch (event.newStatus) { switch (event.newStatus) {
case WalletSyncStatus.unableToSync: case WalletSyncStatus.unableToSync:
_spinController?.stop(); _spinController.stop?.call();
break; break;
case WalletSyncStatus.synced: case WalletSyncStatus.synced:
_spinController?.stop(); _spinController.stop?.call();
break; break;
case WalletSyncStatus.syncing: case WalletSyncStatus.syncing:
unawaited(_spinController?.repeat()); _spinController.repeat?.call();
break; break;
} }
} }
@ -102,9 +87,6 @@ class _RefreshButtonState extends ConsumerState<WalletRefreshButton>
@override @override
void dispose() { void dispose() {
_spinController?.dispose();
_spinController = null;
_syncStatusSubscription.cancel(); _syncStatusSubscription.cancel();
super.dispose(); super.dispose();
@ -129,11 +111,11 @@ class _RefreshButtonState extends ConsumerState<WalletRefreshButton>
.getManagerProvider(widget.walletId); .getManagerProvider(widget.walletId);
final isRefreshing = ref.read(managerProvider).isRefreshing; final isRefreshing = ref.read(managerProvider).isRefreshing;
if (!isRefreshing) { if (!isRefreshing) {
_spinController?.repeat(); _spinController.repeat?.call();
ref ref
.read(managerProvider) .read(managerProvider)
.refresh() .refresh()
.then((_) => _spinController?.stop()); .then((_) => _spinController.stop?.call());
} }
} else { } else {
if (!ref.read(tokenServiceProvider)!.isRefreshing) { if (!ref.read(tokenServiceProvider)!.isRefreshing) {
@ -151,22 +133,20 @@ class _RefreshButtonState extends ConsumerState<WalletRefreshButton>
Constants.size.circularBorderRadius, Constants.size.circularBorderRadius,
), ),
), ),
child: RotationTransition( child: RotatingArrows(
turns: _spinAnimation, spinByDefault: widget.initialSyncStatus == WalletSyncStatus.syncing,
child: SvgPicture.asset( width: isDesktop ? 12 : 24,
Assets.svg.arrowRotate, height: isDesktop ? 12 : 24,
width: isDesktop ? 12 : 24, controller: _spinController,
height: isDesktop ? 12 : 24, color: widget.overrideIconColor != null
color: widget.overrideIconColor != null ? widget.overrideIconColor!
? widget.overrideIconColor! : isDesktop
: isDesktop ? Theme.of(context)
? Theme.of(context) .extension<StackColors>()!
.extension<StackColors>()! .textFieldDefaultSearchIconRight
.textFieldDefaultSearchIconRight : Theme.of(context)
: Theme.of(context) .extension<StackColors>()!
.extension<StackColors>()! .textFavoriteCard,
.textFavoriteCard,
),
), ),
), ),
); );

View file

@ -1,7 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart';
class CancellingTransactionProgressDialog extends StatefulWidget { class CancellingTransactionProgressDialog extends StatefulWidget {
@ -13,51 +11,19 @@ class CancellingTransactionProgressDialog extends StatefulWidget {
} }
class _CancellingTransactionProgressDialogState class _CancellingTransactionProgressDialogState
extends State<CancellingTransactionProgressDialog> extends State<CancellingTransactionProgressDialog> {
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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return WillPopScope( return WillPopScope(
onWillPop: () async { onWillPop: () async {
return false; return false;
}, },
child: StackDialog( child: const StackDialog(
title: "Cancelling transaction", title: "Cancelling transaction",
message: "This may take a while. Please do not exit this screen.", message: "This may take a while. Please do not exit this screen.",
icon: RotationTransition( icon: RotatingArrows(
turns: _spinAnimation, width: 24,
child: SvgPicture.asset( height: 24,
Assets.svg.arrowRotate,
width: 24,
height: 24,
color: Theme.of(context).extension<StackColors>()!.accentColorDark,
),
), ),
// rightButton: TextButton( // rightButton: TextButton(
// style: Theme.of(context).textButtonTheme.style?.copyWith( // style: Theme.of(context).textButtonTheme.style?.copyWith(

View file

@ -1,64 +0,0 @@
import 'package:flutter/widgets.dart';
class RotateAnimationController {
VoidCallback? forward;
VoidCallback? reset;
}
class RotateAnimation extends StatefulWidget {
const RotateAnimation({
Key? key,
required this.lottie,
required this.curve,
this.controller,
}) : super(key: key);
final Widget lottie;
final Curve curve;
final RotateAnimationController? controller;
@override
State<RotateAnimation> createState() => _RotateAnimationState();
}
class _RotateAnimationState extends State<RotateAnimation>
with SingleTickerProviderStateMixin {
late final AnimationController animationController;
late final Animation<double> animation;
late final Duration duration;
@override
void initState() {
animationController = AnimationController(
vsync: this,
);
animation = Tween<double>(
begin: 0.0,
).animate(
CurvedAnimation(
curve: widget.curve,
parent: animationController,
),
);
widget.controller?.forward = animationController.forward;
widget.controller?.reset = animationController.reset;
super.initState();
}
@override
void dispose() {
animationController.dispose();
widget.controller?.forward = null;
super.dispose();
}
@override
Widget build(BuildContext context) {
return RotationTransition(
turns: animation,
child: widget.lottie,
);
}
}

View file

@ -0,0 +1,87 @@
import 'package:flutter/material.dart';
import 'package:lottie/lottie.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
class RotatingArrowsController {
VoidCallback? forward;
VoidCallback? repeat;
VoidCallback? stop;
}
class RotatingArrows extends StatefulWidget {
const RotatingArrows({
Key? key,
required this.height,
required this.width,
this.controller,
this.color,
this.spinByDefault = true,
}) : super(key: key);
final double height;
final double width;
final RotatingArrowsController? controller;
final Color? color;
final bool spinByDefault;
@override
State<RotatingArrows> createState() => _RotatingArrowsState();
}
class _RotatingArrowsState extends State<RotatingArrows>
with SingleTickerProviderStateMixin {
late final AnimationController animationController;
@override
void initState() {
animationController = AnimationController(vsync: this);
widget.controller?.forward = animationController.forward;
widget.controller?.repeat = animationController.repeat;
widget.controller?.stop = animationController.stop;
super.initState();
}
@override
void dispose() {
animationController.dispose();
widget.controller?.forward = null;
widget.controller?.repeat = null;
widget.controller?.stop = null;
super.dispose();
}
@override
Widget build(BuildContext context) {
return Lottie.asset(
Assets.lottie.arrowRotate,
controller: animationController,
height: widget.height,
width: widget.width,
delegates: LottieDelegates(
values: [
ValueDelegate.color(
const ["**"],
value: widget.color ??
Theme.of(context).extension<StackColors>()!.accentColorDark,
),
ValueDelegate.strokeColor(
const ["**"],
value: widget.color ??
Theme.of(context).extension<StackColors>()!.accentColorDark,
),
],
),
onLoaded: (composition) {
animationController.duration = composition.duration;
// if controller was not set just assume continuous repeat
if (widget.spinByDefault) {
animationController.repeat();
}
},
);
}
}

View file

@ -248,7 +248,6 @@ flutter:
- assets/svg/chevron-up.svg - assets/svg/chevron-up.svg
- assets/svg/lock-keyhole.svg - assets/svg/lock-keyhole.svg
- assets/svg/lock-open.svg - assets/svg/lock-open.svg
- assets/svg/rotate-exclamation.svg
- assets/svg/folder-down.svg - assets/svg/folder-down.svg
- assets/svg/network-wired.svg - assets/svg/network-wired.svg
- assets/svg/network-wired-2.svg - assets/svg/network-wired-2.svg