fix: animation duration/period not set before calling repeat

This commit is contained in:
julian 2023-06-07 09:02:22 -06:00
parent e7ed01aad5
commit d627f8e73c
2 changed files with 21 additions and 6 deletions
lib
pages/wallet_view/sub_widgets
widgets/animated_widgets

View file

@ -66,26 +66,38 @@ class _RefreshButtonState extends ConsumerState<WalletRefreshButton> {
widget.tokenContractAddress == null) {
switch (event.newStatus) {
case WalletSyncStatus.unableToSync:
_spinController.stop?.call();
if (_spinController.hasLoadedAnimation) {
_spinController.stop?.call();
}
break;
case WalletSyncStatus.synced:
_spinController.stop?.call();
if (_spinController.hasLoadedAnimation) {
_spinController.stop?.call();
}
break;
case WalletSyncStatus.syncing:
_spinController.repeat?.call();
if (_spinController.hasLoadedAnimation) {
_spinController.repeat?.call();
}
break;
}
} else if (widget.tokenContractAddress != null &&
event.walletId == widget.walletId + widget.tokenContractAddress!) {
switch (event.newStatus) {
case WalletSyncStatus.unableToSync:
_spinController.stop?.call();
if (_spinController.hasLoadedAnimation) {
_spinController.stop?.call();
}
break;
case WalletSyncStatus.synced:
_spinController.stop?.call();
if (_spinController.hasLoadedAnimation) {
_spinController.stop?.call();
}
break;
case WalletSyncStatus.syncing:
_spinController.repeat?.call();
if (_spinController.hasLoadedAnimation) {
_spinController.repeat?.call();
}
break;
}
}

View file

@ -17,6 +17,8 @@ class RotatingArrowsController {
VoidCallback? forward;
VoidCallback? repeat;
VoidCallback? stop;
bool hasLoadedAnimation = false;
}
class RotatingArrows extends StatefulWidget {
@ -86,6 +88,7 @@ class _RotatingArrowsState extends State<RotatingArrows>
),
onLoaded: (composition) {
animationController.duration = composition.duration;
widget.controller?.hasLoadedAnimation = true;
// if controller was not set just assume continuous repeat
if (widget.spinByDefault) {