@@ -15,7 +15,7 @@ import 'package:trios/utils/extensions.dart';
1515/// State class for the ships page controller
1616class ShipsPageState {
1717 final bool showEnabled;
18- final bool showSpoilers ;
18+ final SpoilerLevel spoilerLevelToShow ;
1919 final bool splitPane;
2020 final bool showFilters;
2121 final List <GridFilter <Ship >> filterCategories;
@@ -31,7 +31,7 @@ class ShipsPageState {
3131
3232 const ShipsPageState ({
3333 this .showEnabled = false ,
34- this .showSpoilers = false ,
34+ this .spoilerLevelToShow = SpoilerLevel .showNone ,
3535 this .splitPane = false ,
3636 this .showFilters = false ,
3737 this .filterCategories = const [],
@@ -46,7 +46,7 @@ class ShipsPageState {
4646
4747 ShipsPageState copyWith ({
4848 bool ? showEnabled,
49- bool ? showSpoilers ,
49+ SpoilerLevel ? spoilerLevelToShow ,
5050 bool ? splitPane,
5151 bool ? showFilters,
5252 List <GridFilter <Ship >>? filterCategories,
@@ -60,7 +60,7 @@ class ShipsPageState {
6060 }) {
6161 return ShipsPageState (
6262 showEnabled: showEnabled ?? this .showEnabled,
63- showSpoilers : showSpoilers ?? this .showSpoilers ,
63+ spoilerLevelToShow : spoilerLevelToShow ?? this .spoilerLevelToShow ,
6464 splitPane: splitPane ?? this .splitPane,
6565 showFilters: showFilters ?? this .showFilters,
6666 filterCategories: filterCategories ?? this .filterCategories,
@@ -76,8 +76,11 @@ class ShipsPageState {
7676 }
7777}
7878
79+ enum SpoilerLevel { showNone, showSlightSpoilers, showAllSpoilers }
80+
7981/// Controller for the ships page using AutoDisposeNotifier (synchronous)
8082class ShipsPageController extends AutoDisposeNotifier <ShipsPageState > {
83+ final slightSpoilerTags = ["codex_unlockable" ];
8184 final spoilerTags = ["threat" , "dweller" ];
8285
8386 @override
@@ -185,7 +188,7 @@ class ShipsPageController extends AutoDisposeNotifier<ShipsPageState> {
185188 ships = _filterByEnabled (ships, mods, currentState.showEnabled);
186189
187190 // Apply spoiler filter
188- ships = _filterBySpoilers (ships, currentState.showSpoilers );
191+ ships = _filterBySpoilers (ships, currentState.spoilerLevelToShow );
189192
190193 // Store ships before grid filters for filter panel
191194 final shipsBeforeGridFilter = ships.toList ();
@@ -225,9 +228,9 @@ class ShipsPageController extends AutoDisposeNotifier<ShipsPageState> {
225228 }
226229
227230 /// Toggle show spoilers filter
228- void toggleShowSpoilers ( ) {
231+ void setShowSpoilers ( SpoilerLevel spoilerLevelToShow ) {
229232 final mods = ref.read (AppState .mods);
230- final updatedState = state.copyWith (showSpoilers : ! state.showSpoilers );
233+ final updatedState = state.copyWith (spoilerLevelToShow : spoilerLevelToShow );
231234 final processedState = _processAllFilters (updatedState, mods);
232235
233236 state = processedState;
@@ -301,17 +304,26 @@ class ShipsPageController extends AutoDisposeNotifier<ShipsPageState> {
301304 }
302305
303306 /// Filter ships based on spoiler settings
304- List <Ship > _filterBySpoilers (List <Ship > ships, bool showSpoilers) {
305- if (showSpoilers) return ships;
307+ List <Ship > _filterBySpoilers (
308+ List <Ship > ships,
309+ SpoilerLevel spoilerLevelToShow,
310+ ) {
311+ if (spoilerLevelToShow == SpoilerLevel .showAllSpoilers) return ships;
306312
307313 return ships.where ((ship) {
308314 final hints = ship.hints.orEmpty ().map ((h) => h.toLowerCase ());
309315 final tags = ship.tags.orEmpty ().map ((t) => t.toLowerCase ());
310316
311317 final hidden = hints.contains ('hide_in_codex' );
318+ final isSlightSpoiler = tags.any (slightSpoilerTags.contains);
312319 final isSpoiler = tags.any (spoilerTags.contains);
313320
314- return ! hidden && ! isSpoiler;
321+ if (spoilerLevelToShow == SpoilerLevel .showSlightSpoilers) {
322+ return ! hidden && ! isSpoiler;
323+ }
324+
325+ // Show no spoilers
326+ return ! hidden && ! isSlightSpoiler && ! isSpoiler;
315327 }).toList ();
316328 }
317329
0 commit comments