From a0b46eaf3da94f694d6c8e7d9ef47f87b46c284b Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Sat, 7 Feb 2026 23:19:13 -0800 Subject: [PATCH] fix overlay toggle stream reload, fix spring-back animation listener Co-Authored-By: Claude Opus 4.6 --- lib/screens/channel/channel.dart | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/screens/channel/channel.dart b/lib/screens/channel/channel.dart index bda8b7b7..a4fa6b76 100644 --- a/lib/screens/channel/channel.dart +++ b/lib/screens/channel/channel.dart @@ -91,14 +91,17 @@ class _VideoChatState extends State ); // Spring-back animation with smooth easing - _springBackAnimation = - Tween(begin: 0, end: 0).animate( - CurvedAnimation(parent: _animationController, curve: Curves.easeOut), - )..addListener(() { - setState(() { - _pipDragDistance = _springBackAnimation.value; - }); - }); + _springBackAnimation = Tween(begin: 0, end: 0).animate( + CurvedAnimation(parent: _animationController, curve: Curves.easeOut), + ); + + // Attach listener to the controller (not the derived animation) so it + // survives _springBackAnimation being reassigned in _animateSpringBack. + _animationController.addListener(() { + setState(() { + _pipDragDistance = _springBackAnimation.value; + }); + }); // Register as observer for app lifecycle events WidgetsBinding.instance.addObserver(this); @@ -201,7 +204,7 @@ class _VideoChatState extends State /// and an instructional overlay during the drag gesture. Widget _buildPipGestureWrapper({required Widget child, double? aspectRatio}) { return AnimatedBuilder( - animation: Listenable.merge([_animationController, _springBackAnimation]), + animation: _animationController, builder: (context, _) { final currentDragDistance = _isPipDragging ? _pipDragDistance @@ -321,9 +324,12 @@ class _VideoChatState extends State final video = Observer( builder: (context) { - if (!_videoStore.settingsStore.showOverlay) return player; - - return Stack(children: [player, overlay]); + return Stack( + children: [ + player, + if (_videoStore.settingsStore.showOverlay) overlay, + ], + ); }, );