diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c233f0a..d9442b7 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ + with TickerProviderStateMixin { + bool _wasAnimatingBeforeLostFocus = false; + Animation? animation; AnimationController? animationController; @@ -60,6 +65,20 @@ class _StatusState extends State with TickerProviderStateMixin { void initState() { super.initState(); + EventChannelWindowFocus.setGlobalListener((hasFocus) { + if (!widget.pauseOnLostFocus) { + return; + } + + if (hasFocus && _wasAnimatingBeforeLostFocus) { + animationController?.forward(); + } else if (!hasFocus) { + _wasAnimatingBeforeLostFocus = + animationController?.isAnimating ?? false; + animationController?.stop(); + } + }); + if (widget.autoStart) { initializeAnimation(); }