Skip to content

Commit

Permalink
Setup migration mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Carapacik committed Dec 3, 2023
1 parent f983b84 commit f160559
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/src/feature/game/model/letter_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ enum LetterStatus {
}
}

Color? textColor(BuildContext context) {
final theme = SettingsScope.themeOf(context).theme;
Color? textColor(BuildContext context, {bool listen = true}) {
final theme = SettingsScope.of(context, listen: listen).theme;
final isDark = theme.isDarkTheme(context);
final color = cellColor(context);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ mixin InitializationSteps {
final statisticsDataSource = StatisticsDataSourceImpl(
sharedPreferences: sharedPreferences,
);
await statisticsDataSource.runMigration();
progress.dependencies.statisticsRepository = StatisticsRepositoryImpl(
statisticsDataSource,
);
Expand All @@ -64,6 +65,7 @@ mixin InitializationSteps {
final lvlDataSource = LevelDataSourceImpl(
sharedPreferences: sharedPreferences,
);
await lvlDataSource.runMigration();
progress.dependencies.levelRepository = LevelRepositoryImpl(
lvlDataSource,
);
Expand Down
6 changes: 6 additions & 0 deletions lib/src/feature/level/data/level_datasource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ abstract interface class LevelDataSource {

/// Get current Level from cache
List<GameResult>? loadLevelFromCache(String dictionaryKey);

/// Run migration from old api
Future<void> runMigration();
}

/// {@macro Level_datasource}
Expand Down Expand Up @@ -49,4 +52,7 @@ final class LevelDataSourceImpl implements LevelDataSource {
final rawLevels = previousLevels.map((rawItem) => json.encode(rawItem.toJson())).toList();
await _sharedPreferences.setStringList('${_prefix}_$dictionaryKey', rawLevels);
}

@override
Future<void> runMigration() async {}
}
3 changes: 1 addition & 2 deletions lib/src/feature/settings/widget/change_color_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ class _ChangeColorPageState extends State<ChangeColorPage> {
if (_currentColorMode == ColorMode.other) {
_currentSelectedTileIndex = 0;
}
_currentOtherColors = widget.previousResult.otherColors ??
(AppColors.green, AppColors.yellow, LetterStatus.notInWord.cellColor(context, listen: false));
_currentOtherColors = widget.previousResult.otherColors ?? (AppColors.green, AppColors.yellow, AppColors.grey);
}

void _changeTheme(BuildContext context) {
Expand Down
6 changes: 6 additions & 0 deletions lib/src/feature/statistic/data/statistics_datasource.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ abstract interface class StatisticsDataSource {

/// Get current Statistics from cache
GameStatistics? loadStatisticsFromCache(String dictionaryKey);

/// Run migration from old api
Future<void> runMigration();
}

/// {@macro Statistics_datasource}
Expand Down Expand Up @@ -42,4 +45,7 @@ final class StatisticsDataSourceImpl implements StatisticsDataSource {
final raw = json.encode(statistics.toJson());
await _sharedPreferences.setString('${_prefix}_$dictionaryKey', raw);
}

@override
Future<void> runMigration() async {}
}
4 changes: 3 additions & 1 deletion lib/src/feature/tutorial/widget/tutorial_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class TutorialPage extends StatelessWidget {
children: [
TextSpan(text: '\u2022'),
WidgetSpan(child: SizedBox(width: 6)),
TextSpan(text: 'After each guess, the color of the tiles will change to show how close your guess was to the word.'),
TextSpan(
text:
'After each guess, the color of the tiles will change to show how close your guess was to the word.'),
],
),
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w500),
Expand Down

0 comments on commit f160559

Please sign in to comment.