diff --git a/lib/src/feature/components/widget/drawer.dart b/lib/src/feature/components/widget/drawer.dart index d8931b22..56173785 100644 --- a/lib/src/feature/components/widget/drawer.dart +++ b/lib/src/feature/components/widget/drawer.dart @@ -64,6 +64,7 @@ class CustomDrawer extends StatelessWidget { await navigator.push( MaterialPageRoute( builder: (context) => const TutorialPage(), + fullscreenDialog: true, ), ); }, @@ -92,6 +93,7 @@ class CustomDrawer extends StatelessWidget { await navigator.push( MaterialPageRoute( builder: (context) => const AboutPage(), + fullscreenDialog: true, ), ); }, diff --git a/lib/src/feature/game/data/game_datasource.dart b/lib/src/feature/game/data/game_datasource.dart index a5eff9cc..d98b35eb 100644 --- a/lib/src/feature/game/data/game_datasource.dart +++ b/lib/src/feature/game/data/game_datasource.dart @@ -13,6 +13,10 @@ abstract interface class GameDataSource { GameResult? loadDailyFromCache(String dictionary, String date); GameResult? loadLvlFromCache(String dictionary); + + bool get isFirstEnter; + + Future saveFirstEnter(); } final class GameDataSourceImpl implements GameDataSource { @@ -22,6 +26,13 @@ final class GameDataSourceImpl implements GameDataSource { final SharedPreferences _sharedPreferences; static const _boardPrefix = 'board'; + static const _firstEnterPrefix = 'is_first_enter'; + + @override + bool get isFirstEnter => _sharedPreferences.getBool(_firstEnterPrefix) ?? true; + + @override + Future saveFirstEnter() => _sharedPreferences.setBool(_firstEnterPrefix, false); @override Future saveDailyBoard(String dictionary, String date, GameResult savedResult) async { diff --git a/lib/src/feature/game/data/game_repository.dart b/lib/src/feature/game/data/game_repository.dart index a3c67b3c..ad39598d 100644 --- a/lib/src/feature/game/data/game_repository.dart +++ b/lib/src/feature/game/data/game_repository.dart @@ -12,6 +12,10 @@ import 'package:wordly/src/feature/game/model/game_result.dart'; abstract interface class IGameRepository { Future init(); + bool get isFirstEnter; + + Future saveFirstEnter(); + Map currentDictionary(Locale dictionary); String generateSecretWord(Locale dictionary, {int levelNumber = 0}); @@ -82,4 +86,10 @@ final class GameRepository implements IGameRepository { @override Future saveLvlBoard(Locale dictionary, GameResult savedResult) => _gameDataSource.saveLvlBoard(dictionary.languageCode, savedResult); + + @override + bool get isFirstEnter => _gameDataSource.isFirstEnter; + + @override + Future saveFirstEnter() => _gameDataSource.saveFirstEnter(); } diff --git a/lib/src/feature/game/widget/game_page.dart b/lib/src/feature/game/widget/game_page.dart index d4380818..4e4bc9c1 100644 --- a/lib/src/feature/game/widget/game_page.dart +++ b/lib/src/feature/game/widget/game_page.dart @@ -15,6 +15,7 @@ import 'package:wordly/src/feature/game/widget/words_grid.dart'; import 'package:wordly/src/feature/level/widget/level_page.dart'; import 'package:wordly/src/feature/settings/widget/settings_scope.dart'; import 'package:wordly/src/feature/statistic/widget/statistic_page.dart'; +import 'package:wordly/src/feature/tutorial/widget/tutorial_page.dart'; class GamePage extends StatefulWidget { const GamePage({super.key}); @@ -31,6 +32,18 @@ class _GamePageState extends State { super.initState(); _focusNode = FocusNode(); WidgetsBinding.instance.addPostFrameCallback((_) { + if (context.dependencies.gameRepository.isFirstEnter) { + unawaited(context.dependencies.gameRepository.saveFirstEnter()); + unawaited( + Navigator.of(context).push( + MaterialPageRoute( + builder: (context) => const TutorialPage(), + fullscreenDialog: true, + ), + ), + ); + return; + } final bloc = context.read(); final state = bloc.state; if (state.isResultState) {