Skip to content

Commit

Permalink
Fix text color
Browse files Browse the repository at this point in the history
  • Loading branch information
Carapacik committed Nov 13, 2023
1 parent 80d8fb1 commit 5a73e11
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 38 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ jobs:
channel: stable
- name: Install dependencies
run: flutter pub get
- name: Install intl utils
run: dart pub global activate intl_utils
- name: Generate localization
run: dart pub global run intl_utils:generate
- name: Code generation
run: flutter pub run build_runner build -d
run: dart run build_runner build -d
- name: Analyze
run: flutter analyze
run: dart analyze
6 changes: 5 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ jobs:
channel: stable
- name: Install dependencies
run: flutter pub get
- name: Install intl utils
run: dart pub global activate intl_utils
- name: Generate localization
run: dart pub global run intl_utils:generate
- name: Code generation
run: flutter pub run build_runner build -d
run: dart run build_runner build -d
- name: Build
run: flutter build web
- name: Deploy
Expand Down
4 changes: 2 additions & 2 deletions lib/src/feature/app/model/app_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ final class AppTheme with Diagnosticable {
case ThemeMode.dark:
return darkTheme;
case ThemeMode.system:
return isDark(context) ? darkTheme : lightTheme;
return MediaQuery.platformBrightnessOf(context) == Brightness.dark ? darkTheme : lightTheme;
}
}

bool isDark(BuildContext context) => MediaQuery.platformBrightnessOf(context) == Brightness.dark;
bool isDark(BuildContext context) => computeTheme(context) == darkTheme;

Color get correctColor {
switch (colorMode) {
Expand Down
5 changes: 3 additions & 2 deletions lib/src/feature/game/model/letter_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ enum LetterStatus {
return darken(color, 0.3);
}
// for empty basic tiles
if (isDark && this == LetterStatus.notInWord || !isDark && this == LetterStatus.unknown) {
return isDark ? AppColors.secondary : AppColors.primary;
if (this == LetterStatus.notInWord || this == LetterStatus.unknown) {
final primary = !isDark && this == LetterStatus.notInWord || isDark && this == LetterStatus.unknown;
return primary ? AppColors.secondary : AppColors.primary;
}
// for high contrast
if (theme.colorMode == ColorMode.highContrast) {
Expand Down
39 changes: 11 additions & 28 deletions lib/src/feature/settings/widget/change_color_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
import 'package:wordly/src/core/resources/resources.dart';
import 'package:wordly/src/core/utils/extensions/extensions.dart';
import 'package:wordly/src/feature/app/widget/dictionary_scope.dart';
import 'package:wordly/src/feature/app/widget/theme_scope.dart';
Expand Down Expand Up @@ -29,6 +28,9 @@ class _ChangeColorPageState extends State<ChangeColorPage> {
void initState() {
super.initState();
_currentColorMode = widget.previousResult.colorMode;
if (_currentColorMode == ColorMode.other) {
_currentSelectedTileIndex = 0;
}
_currentOtherColors = widget.previousResult.otherColors ?? (Colors.green, Colors.yellow, Colors.grey);
}

Expand Down Expand Up @@ -76,9 +78,7 @@ class _ChangeColorPageState extends State<ChangeColorPage> {
onTap: _currentColorMode == ColorMode.other
? () {
if (word[index].status != LetterStatus.unknown) {
setState(() {
_currentSelectedTileIndex = index;
});
setState(() => _currentSelectedTileIndex = index);
}
}
: null,
Expand Down Expand Up @@ -141,32 +141,15 @@ class _ChangeColorPageState extends State<ChangeColorPage> {
}

Color? _currentColorByStatus(ColorMode mode, LetterStatus? status) {
if (status == null) {
if (status == null || mode != ColorMode.other) {
return null;
}
switch (mode) {
case ColorMode.casual:
final casualModeColors = {
LetterStatus.correctSpot: AppColors.green,
LetterStatus.wrongSpot: AppColors.yellow,
LetterStatus.notInWord: AppColors.grey,
};
return casualModeColors[status];
case ColorMode.highContrast:
final highContrastModeColors = {
LetterStatus.correctSpot: AppColors.orange,
LetterStatus.wrongSpot: AppColors.blue,
LetterStatus.notInWord: AppColors.grey,
};
return highContrastModeColors[status];
case ColorMode.other:
final otherModeColors = {
LetterStatus.correctSpot: _currentOtherColors.$1,
LetterStatus.wrongSpot: _currentOtherColors.$2,
LetterStatus.notInWord: _currentOtherColors.$3,
};
return otherModeColors[status];
}
final otherModeColors = {
LetterStatus.correctSpot: _currentOtherColors.$1,
LetterStatus.wrongSpot: _currentOtherColors.$2,
LetterStatus.notInWord: _currentOtherColors.$3,
};
return otherModeColors[status];
}

List<LetterInfo> _wordByDictionary(Locale dictionary) {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,10 @@ packages:
dependency: transitive
description:
name: provider
sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f
sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
url: "https://pub.dev"
source: hosted
version: "6.0.5"
version: "6.1.1"
pub_semver:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
This is a placeholder for base href that will be replaced by the value of
the `--base-href` argument provided to `flutter build`.
-->
<base href="$FLUTTER_BASE_HREF">
<base href="/WordlyPlus/">

<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
Expand Down

0 comments on commit 5a73e11

Please sign in to comment.