Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lib/src/utils/gestures_exclusion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ class AndroidGesturesExclusionWidget extends StatefulWidget {
/// Global key of the board widget.
final GlobalKey boardKey;

/// Optional callback called when focus is gained, to check whether
/// to exclude gestures or not.
/// Whether to exclude gestures when focus is gained.
///
/// If provided, the widget will call this callback when focus is gained,
/// and will not exclude gestures if the callback returns false.
/// If not provided, the widget will enable immersive mode by default.
final bool Function()? shouldExcludeGesturesOnFocusGained;
/// If null, gestures exclusion will be enabled by default.
final bool? shouldExcludeGesturesOnFocusGained;

/// Whether to set immersive mode with the gestures exclusion.
///
Expand All @@ -63,7 +60,7 @@ class _AndroidGesturesExclusionWidgetState extends State<AndroidGesturesExclusio
data: MediaQuery.of(context).copyWith(viewPadding: initialViewPadding),
child: FocusDetector(
onFocusGained: () {
if (widget.shouldExcludeGesturesOnFocusGained?.call() ?? true) {
if (widget.shouldExcludeGesturesOnFocusGained ?? true) {
setAndroidBoardGesturesExclusion(
widget.boardKey,
withImmersiveMode: widget.shouldSetImmersiveMode,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/game/game_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class _GameScreenState extends ConsumerState<GameScreen> {
body: Theme.of(context).platform == TargetPlatform.android
? AndroidGesturesExclusionWidget(
boardKey: _boardKey,
shouldExcludeGesturesOnFocusGained: () => isRealTimePlayingGame,
shouldExcludeGesturesOnFocusGained: isRealTimePlayingGame,
shouldSetImmersiveMode: boardPreferences.immersiveModeWhilePlaying ?? false,
child: body,
)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/puzzle/puzzle_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ class _BodyState extends ConsumerState<_Body> {
return Theme.of(context).platform == TargetPlatform.android
? AndroidGesturesExclusionWidget(
boardKey: widget.boardKey,
shouldExcludeGesturesOnFocusGained: () => puzzleState.mode != PuzzleMode.view,
shouldExcludeGesturesOnFocusGained: puzzleState.mode != PuzzleMode.view,
shouldSetImmersiveMode: boardPreferences.immersiveModeWhilePlaying ?? false,
child: content,
)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/puzzle/storm_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class _BodyState extends ConsumerState<_Body> {
return Theme.of(context).platform == TargetPlatform.android
? AndroidGesturesExclusionWidget(
boardKey: _boardKey,
shouldExcludeGesturesOnFocusGained: () =>
shouldExcludeGesturesOnFocusGained:
stormState.mode == StormMode.initial || stormState.mode == StormMode.running,
shouldSetImmersiveMode: boardPreferences.immersiveModeWhilePlaying ?? false,
child: content,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/view/puzzle/streak_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ class _BodyState extends ConsumerState<_Body> {
return Theme.of(context).platform == TargetPlatform.android
? AndroidGesturesExclusionWidget(
boardKey: _boardKey,
shouldExcludeGesturesOnFocusGained: () => puzzleState.mode != PuzzleMode.view,
shouldExcludeGesturesOnFocusGained: puzzleState.mode != PuzzleMode.view,
shouldSetImmersiveMode: boardPreferences.immersiveModeWhilePlaying ?? false,
child: content,
)
Expand Down