patch small issue with trad and theme
This commit is contained in:
@@ -35,7 +35,9 @@ class GameNotifier extends Notifier<GameState> {
|
||||
final repo = ref.read(pokemonRepositoryProvider);
|
||||
final isShiny = _random.nextInt(AppConstants.shinyOdds) == 0;
|
||||
|
||||
final id = ref.read(genFilterProvider.notifier).randomId(_random);
|
||||
final genFilter = ref.read(genFilterProvider.notifier);
|
||||
await genFilter.ready;
|
||||
final id = genFilter.randomId(_random);
|
||||
try {
|
||||
final pokemon = await repo.getById(id);
|
||||
if (pokemon == null) {
|
||||
|
||||
@@ -6,10 +6,12 @@ import '../../core/config/app_constants.dart';
|
||||
/// Gère les générations activées pour le tirage et fournit un id aléatoire dans celles-ci.
|
||||
/// La sélection est persistée dans les préférences.
|
||||
class GenFilterNotifier extends Notifier<Set<int>> {
|
||||
late final Future<void> _ready;
|
||||
|
||||
@override
|
||||
Set<int> build() {
|
||||
_load();
|
||||
// Default: all gens enabled
|
||||
_ready = _load();
|
||||
// Default: all gens enabled — overwritten by _load() once prefs are read.
|
||||
return Set.from(List.generate(AppConstants.genRanges.length, (i) => i));
|
||||
}
|
||||
|
||||
@@ -21,6 +23,9 @@ class GenFilterNotifier extends Notifier<Set<int>> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolves once the persisted filter has been loaded from SharedPreferences.
|
||||
Future<void> get ready => _ready;
|
||||
|
||||
Future<void> toggle(int genIndex) async {
|
||||
final next = Set<int>.from(state);
|
||||
if (next.contains(genIndex)) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import 'repository_provider.dart';
|
||||
/// Liste complète du Pokédex (triée par id), avec synchro initiale gérée par le repository.
|
||||
class PokedexNotifier extends AsyncNotifier<List<Pokemon>> {
|
||||
Future<List<Pokemon>> _load() async {
|
||||
final repo = ref.read(pokemonRepositoryProvider);
|
||||
final repo = ref.watch(pokemonRepositoryProvider);
|
||||
final list = await repo.getAll();
|
||||
list.sort((a, b) => a.id.compareTo(b.id));
|
||||
return list;
|
||||
|
||||
@@ -4,10 +4,14 @@ import '../../data/datasources/pokemon_local_datasource.dart';
|
||||
import '../../data/datasources/pokemon_remote_datasource.dart';
|
||||
import '../../data/repositories/pokemon_repository_impl.dart';
|
||||
import '../../domain/repositories/pokemon_repository.dart';
|
||||
import 'locale_provider.dart';
|
||||
|
||||
/// Point d'injection unique du repository. Sur le web, pas de SQLite (local = null).
|
||||
/// Point d'injection unique du repository.
|
||||
/// Se reconstruit automatiquement quand la langue change,
|
||||
/// ce qui invalide [pokedexProvider] en cascade.
|
||||
final pokemonRepositoryProvider = Provider<PokemonRepository>((ref) {
|
||||
final remote = PokemonRemoteDataSource();
|
||||
final local = kIsWeb ? null : PokemonLocalDataSource();
|
||||
final lang = ref.watch(localeProvider).languageCode;
|
||||
final remote = PokemonRemoteDataSource(languageCode: lang);
|
||||
final local = kIsWeb ? null : PokemonLocalDataSource(languageCode: lang);
|
||||
return PokemonRepositoryImpl(remote: remote, local: local);
|
||||
});
|
||||
|
||||
@@ -2,25 +2,21 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Palette de couleurs nommée de l'application (couleur primaire + surface de fond).
|
||||
/// Palette de couleurs de l'application (couleur primaire + surface de fond).
|
||||
/// Le nom affiché est géré via AppLocalizations (palette0…palette4).
|
||||
class AppPalette {
|
||||
final String name;
|
||||
final Color primary;
|
||||
final Color surface;
|
||||
|
||||
const AppPalette({
|
||||
required this.name,
|
||||
required this.primary,
|
||||
required this.surface,
|
||||
});
|
||||
const AppPalette({required this.primary, required this.surface});
|
||||
}
|
||||
|
||||
const List<AppPalette> appPalettes = [
|
||||
AppPalette(name: 'Pokédex Rouge', primary: Color(0xFFD32F2F), surface: Color(0xFF1B2333)),
|
||||
AppPalette(name: 'Océan Bleu', primary: Color(0xFF1565C0), surface: Color(0xFF0D1B2A)),
|
||||
AppPalette(name: 'Forêt Verte', primary: Color(0xFF2E7D32), surface: Color(0xFF1A2B1A)),
|
||||
AppPalette(name: 'Foudre Jaune', primary: Color(0xFFF9A825), surface: Color(0xFF1C1A00)),
|
||||
AppPalette(name: 'Ombre Violette',primary: Color(0xFF6A1B9A), surface: Color(0xFF1A0A2B)),
|
||||
AppPalette(primary: Color(0xFFD32F2F), surface: Color(0xFF1B2333)),
|
||||
AppPalette(primary: Color(0xFF1565C0), surface: Color(0xFF0D1B2A)),
|
||||
AppPalette(primary: Color(0xFF2E7D32), surface: Color(0xFF1A2B1A)),
|
||||
AppPalette(primary: Color(0xFFF9A825), surface: Color(0xFF1C1A00)),
|
||||
AppPalette(primary: Color(0xFF6A1B9A), surface: Color(0xFF1A0A2B)),
|
||||
];
|
||||
|
||||
const String _prefsPaletteIndex = 'palette_index';
|
||||
|
||||
Reference in New Issue
Block a user