Skip to content

Commit

Permalink
[1.1.1] Show how to play on first launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Carapacik committed Jun 7, 2022
1 parent a91f12e commit 8a17292
Show file tree
Hide file tree
Showing 19 changed files with 86 additions and 110 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/res/values-night-v31/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowSplashScreenBackground">#1E1F30</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowSplashScreenBackground">#1E1F30</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/res/values-v31/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowSplashScreenBackground">#F4F7FB</item>
<item name="android:forceDarkAllowed">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowSplashScreenBackground">#F4F7FB</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
6 changes: 3 additions & 3 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
<key>UIStatusBarHidden</key>
<true/>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
</array>
<array>
<string>https</string>
</array>
</dict>
</plist>
2 changes: 2 additions & 0 deletions lib/bloc/main/main_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:wordly/domain/daily_result_repository.dart';
import 'package:wordly/domain/daily_statistic_repository.dart';
import 'package:wordly/domain/level_repository.dart';
import 'package:wordly/domain/settings_repository.dart';
import 'package:wordly/utils/utils.dart';

part 'main_state.dart';

Expand Down Expand Up @@ -60,6 +61,7 @@ class MainCubit extends Cubit<MainState> {
if (state is WinGameState || state is LoseGameState) {
if (levelRepository.isLevelMode) {
levelRepository.saveLevelData();
appearReview();
} else {
final dictionaryLanguage =
settingsRepository.settingsData.dictionaryLanguage;
Expand Down
2 changes: 2 additions & 0 deletions lib/domain/board_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ abstract class BoardRepository {
Future<void> saveBoardData(final BoardData data);

Future<List<BoardData>> getAllData();

Future<bool> isFirstLaunch();
}
8 changes: 7 additions & 1 deletion lib/domain/board_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BoardRepositoryImpl implements BoardRepository {
.languageEqualTo(dictionaryLanguage)
.levelNumberEqualTo(levelNumber)
.findAll();
// Sort ny id
// Sort by id
if (data.isEmpty) {
finalData = BoardData.init(
language: dictionaryLanguage,
Expand Down Expand Up @@ -68,4 +68,10 @@ class BoardRepositoryImpl implements BoardRepository {
.findAll();
return data;
}

@override
Future<bool> isFirstLaunch() async {
final data = await _isar.boardDatas.count();
return data == 0;
}
}
6 changes: 2 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ import 'package:wordly/domain/level_repository.dart';
import 'package:wordly/domain/level_repository_impl.dart';
import 'package:wordly/domain/settings_repository.dart';
import 'package:wordly/domain/settings_repository_impl.dart';
import 'package:wordly/utils/utils.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
setPathUrlStrategy();
await checkForAndroidUpdate();
await _initSingletons();
await _setupServiceLocators();
runApp(
MultiBlocProvider(
providers: [
Expand All @@ -50,7 +48,7 @@ Future<void> main() async {
);
}

Future<void> _initSingletons() async {
Future<void> _setupServiceLocators() async {
await _initLocaleStorage();
await _initSettingsRepository();
await _initDailyResultRepository();
Expand Down
4 changes: 0 additions & 4 deletions lib/presentation/widgets/modal/daily_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ Future<void> showDailyResultDialog(
},
);
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(24),
),
insetPadding: const EdgeInsets.all(24),
backgroundColor: isWin ? AppColors.green : AppColors.red,
title: Center(
child: Text(
Expand Down
2 changes: 0 additions & 2 deletions lib/presentation/widgets/modal/how_to_play.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ Future<void> showHowToPlayDialog(final BuildContext context) async {
await showDialog<void>(
context: context,
builder: (context) => AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24)),
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
elevation: 24,
title: Text(
R.stringsOf(context).how_to_play,
style: AppTypography.m25,
Expand Down
2 changes: 0 additions & 2 deletions lib/presentation/widgets/modal/level_result.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ Future<void> showLevelResultDialog(
builder: (context) {
final mainCubit = BlocProvider.of<MainCubit>(context);
return AlertDialog(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
insetPadding: const EdgeInsets.all(24),
backgroundColor: isWin ? AppColors.green : AppColors.red,
title: Center(
child: Text(
Expand Down
2 changes: 1 addition & 1 deletion lib/presentation/widgets/modal/snackbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Future<void> showSnackBar(
behavior: SnackBarBehavior.floating,
margin: EdgeInsets.symmetric(
horizontal: width > 500 ? (width - 500) / 2 + 72 : 12,
vertical: 64,
vertical: 24,
),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
Expand Down
2 changes: 2 additions & 0 deletions lib/resources/themes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extension AppThemeExt on AppTheme {
backgroundColor: const Color(0xFFFFFFFF),
cardColor: const Color(0xFFDCE1E9),
shadowColor: const Color(0xFF787C7E),
useMaterial3: true,
);
case AppTheme.darkTheme:
return ThemeData.dark().copyWith(
Expand All @@ -26,6 +27,7 @@ extension AppThemeExt on AppTheme {
cardColor: const Color(0xFF6D6F82),
backgroundColor: const Color(0xDC121213),
shadowColor: const Color(0xFF494B61),
useMaterial3: true,
);
}
}
Expand Down
49 changes: 29 additions & 20 deletions lib/utils/check_result_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
import 'package:flutter/material.dart';
import 'package:get_it/get_it.dart';
import 'package:wordly/data/repositories/dictionary_repository.dart';
import 'package:wordly/domain/board_repository.dart';
import 'package:wordly/domain/daily_result_repository.dart';
import 'package:wordly/domain/level_repository.dart';
import 'package:wordly/presentation/widgets/widgets.dart';
import 'package:wordly/utils/utils.dart';

Future<void> checkResultDialog(
final BuildContext context, {
final bool? isWin,
}) async {
final boardRepository = GetIt.I<BoardRepository>();
final isFirstLaunch = await boardRepository.isFirstLaunch();
if (isFirstLaunch) {
await showHowToPlayDialog(context);
return;
}

final levelRepository = GetIt.I<LevelRepository>();
final dictionaryRepository = GetIt.I<DictionaryRepository>();
final isLevelMode = levelRepository.isLevelMode;
final secretWord = dictionaryRepository.secretWord;
final secretWordMeaning = dictionaryRepository.secretWordMeaning;

if (isWin != null) {
if (isLevelMode) {
await showLevelResultDialog(
context,
isWin: isWin,
word: secretWord,
secretWordMeaning: secretWordMeaning,
);
} else {
await showDailyResultDialog(
showLevelResultDialog(
context,
isWin: isWin,
word: secretWord,
secretWordMeaning: secretWordMeaning,
);
return;
}
} else {
Future.delayed(const Duration(milliseconds: 400), appearReview);
final dailyResult = GetIt.I<DailyResultRepository>().dailyResult;
if (!isLevelMode && dailyResult.dailyWord == secretWord) {
await showDailyResultDialog(
context,
isWin: dailyResult.isWin,
word: secretWord,
secretWordMeaning: secretWordMeaning,
);
}
await showDailyResultDialog(
context,
isWin: isWin,
word: secretWord,
secretWordMeaning: secretWordMeaning,
);
return;
}

final dailyResult = GetIt.I<DailyResultRepository>().dailyResult;
if (!isLevelMode && dailyResult.dailyWord == secretWord) {
await showDailyResultDialog(
context,
isWin: dailyResult.isWin,
word: secretWord,
secretWordMeaning: secretWordMeaning,
);
return;
}
}
21 changes: 0 additions & 21 deletions lib/utils/update.dart

This file was deleted.

1 change: 0 additions & 1 deletion lib/utils/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export 'duration.dart';
export 'r.dart';
export 'review.dart';
export 'share.dart';
export 'update.dart';
Loading

0 comments on commit 8a17292

Please sign in to comment.