diff --git a/lib/src/view/game/game_screen.dart b/lib/src/view/game/game_screen.dart index 656c92d9c6..74fcdd44d3 100644 --- a/lib/src/view/game/game_screen.dart +++ b/lib/src/view/game/game_screen.dart @@ -53,6 +53,9 @@ class GameScreen extends ConsumerStatefulWidget { class _GameScreenState extends ConsumerState with AndroidImmersiveMode, RouteAware, Wakelock { + final _whiteClockKey = GlobalKey(debugLabel: 'whiteClockOnGameScreen'); + final _blackClockKey = GlobalKey(debugLabel: 'blackClockOnGameScreen'); + @override void didChangeDependencies() { super.didChangeDependencies(); @@ -90,6 +93,8 @@ class _GameScreenState extends ConsumerState gameState: state, ctrlProvider: ctrlProvider, gameProvider: gameProvider, + whiteClockKey: _whiteClockKey, + blackClockKey: _blackClockKey, ); return PlatformWidget( androidBuilder: (context) => _androidBuilder( @@ -239,11 +244,15 @@ class _Body extends ConsumerWidget { required this.gameState, required this.ctrlProvider, required this.gameProvider, + required this.whiteClockKey, + required this.blackClockKey, }); final GameState gameState; final GameControllerProvider ctrlProvider; final LobbyGameProvider gameProvider; + final GlobalKey whiteClockKey; + final GlobalKey blackClockKey; @override Widget build(BuildContext context, WidgetRef ref) { @@ -293,6 +302,7 @@ class _Body extends ConsumerWidget { : null, clock: gameState.game.clock != null ? CountdownClock( + key: blackClockKey, duration: gameState.game.clock!.black, active: gameState.activeClockSide == Side.black, emergencyThreshold: @@ -325,6 +335,7 @@ class _Body extends ConsumerWidget { : null, clock: gameState.game.clock != null ? CountdownClock( + key: whiteClockKey, duration: gameState.game.clock!.white, active: gameState.activeClockSide == Side.white, emergencyThreshold: diff --git a/lib/src/view/watch/tv_screen.dart b/lib/src/view/watch/tv_screen.dart index 389be7d8e3..05f9d75324 100644 --- a/lib/src/view/watch/tv_screen.dart +++ b/lib/src/view/watch/tv_screen.dart @@ -31,6 +31,9 @@ class _TvScreenState extends ConsumerState TvControllerProvider get _tvGameCtrl => tvControllerProvider(widget.channel, widget.initialGame); + final _whiteClockKey = GlobalKey(debugLabel: 'whiteClockOnTvScreen'); + final _blackClockKey = GlobalKey(debugLabel: 'blackClockOnTvScreen'); + @override Widget build(BuildContext context) { return PlatformWidget( @@ -49,7 +52,12 @@ class _TvScreenState extends ConsumerState ToggleSoundButton(), ], ), - body: _Body(widget.channel, widget.initialGame), + body: _Body( + widget.channel, + widget.initialGame, + whiteClockKey: _whiteClockKey, + blackClockKey: _blackClockKey, + ), ); } @@ -61,7 +69,12 @@ class _TvScreenState extends ConsumerState middle: Text('${widget.channel.label} TV'), trailing: ToggleSoundButton(), ), - child: _Body(widget.channel, widget.initialGame), + child: _Body( + widget.channel, + widget.initialGame, + whiteClockKey: _whiteClockKey, + blackClockKey: _blackClockKey, + ), ); } @@ -116,10 +129,17 @@ class _TvScreenState extends ConsumerState } class _Body extends ConsumerWidget { - const _Body(this.channel, this.initialGame); + const _Body( + this.channel, + this.initialGame, { + required this.whiteClockKey, + required this.blackClockKey, + }); final TvChannel channel; final (GameId id, Side orientation)? initialGame; + final GlobalKey whiteClockKey; + final GlobalKey blackClockKey; @override Widget build(BuildContext context, WidgetRef ref) { @@ -145,6 +165,7 @@ class _Body extends ConsumerWidget { player: game.black.setOnGame(true), clock: gameState.game.clock != null ? CountdownClock( + key: blackClockKey, duration: gameState.game.clock!.black, active: gameState.activeClockSide == Side.black, ) @@ -155,6 +176,7 @@ class _Body extends ConsumerWidget { player: game.white.setOnGame(true), clock: gameState.game.clock != null ? CountdownClock( + key: whiteClockKey, duration: gameState.game.clock!.white, active: gameState.activeClockSide == Side.white, )