branding added
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/// Session state for the Values Sort practice: sorting, ranking, reflection.
|
||||
/// Session state for the Values Compass practice: sorting, ranking, reflection.
|
||||
library;
|
||||
|
||||
import 'dart:async';
|
||||
@@ -25,14 +25,13 @@ enum SortStage {
|
||||
sorting,
|
||||
hub,
|
||||
overview,
|
||||
pileReview,
|
||||
ranking,
|
||||
reflection,
|
||||
}
|
||||
|
||||
/// ChangeNotifier that owns the deck, pile assignments, ranking, and journals.
|
||||
class ValuesSortController extends ChangeNotifier {
|
||||
ValuesSortController({required StorageService this._storage});
|
||||
ValuesSortController({required this._storage});
|
||||
|
||||
final StorageService _storage;
|
||||
|
||||
@@ -65,9 +64,6 @@ class ValuesSortController extends ChangeNotifier {
|
||||
/// Reflections keyed by `valueId|promptIndex`.
|
||||
final Map<String, String> _reflections = {};
|
||||
|
||||
ValuePile? _reviewPile;
|
||||
ValuePile? get reviewPile => _reviewPile;
|
||||
|
||||
String? _activeReflectionValueId;
|
||||
String? get activeReflectionValueId => _activeReflectionValueId;
|
||||
|
||||
@@ -112,7 +108,6 @@ class ValuesSortController extends ChangeNotifier {
|
||||
..addAll(_deck);
|
||||
_rankedIds.clear();
|
||||
_reflections.clear();
|
||||
_reviewPile = null;
|
||||
_activeReflectionValueId = null;
|
||||
_activePromptIndex = 0;
|
||||
}
|
||||
@@ -218,12 +213,6 @@ class ValuesSortController extends ChangeNotifier {
|
||||
_commit();
|
||||
}
|
||||
|
||||
void openPileReview(ValuePile pile) {
|
||||
_reviewPile = pile;
|
||||
_stage = SortStage.pileReview;
|
||||
_commit();
|
||||
}
|
||||
|
||||
void goToRanking() {
|
||||
_syncRankingWithMostImportant();
|
||||
if (_rankedIds.isEmpty) {
|
||||
@@ -333,7 +322,6 @@ class ValuesSortController extends ChangeNotifier {
|
||||
'version': 1,
|
||||
'deckFingerprint': _deckFingerprint,
|
||||
'stage': _stage.name,
|
||||
'reviewPile': _reviewPile?.name,
|
||||
'assignments': {
|
||||
for (final e in _assignments.entries) e.key: e.value.name,
|
||||
},
|
||||
@@ -414,7 +402,6 @@ class ValuesSortController extends ChangeNotifier {
|
||||
.where(knownIds.contains),
|
||||
);
|
||||
|
||||
_reviewPile = ValuePileX.fromName(data['reviewPile'] as String?);
|
||||
_activeReflectionValueId = data['activeReflectionValueId'] as String?;
|
||||
if (_activeReflectionValueId != null &&
|
||||
!knownIds.contains(_activeReflectionValueId)) {
|
||||
@@ -423,19 +410,21 @@ class ValuesSortController extends ChangeNotifier {
|
||||
_activePromptIndex = (data['activePromptIndex'] as num?)?.toInt() ?? 0;
|
||||
|
||||
final stageName = data['stage'] as String? ?? SortStage.welcome.name;
|
||||
_stage = SortStage.values.firstWhere(
|
||||
(s) => s.name == stageName,
|
||||
orElse: () => SortStage.welcome,
|
||||
);
|
||||
// Remap removed refine stage onto the hub for older sessions.
|
||||
if (stageName == 'pileReview') {
|
||||
_stage = SortStage.hub;
|
||||
} else {
|
||||
_stage = SortStage.values.firstWhere(
|
||||
(s) => s.name == stageName,
|
||||
orElse: () => SortStage.welcome,
|
||||
);
|
||||
}
|
||||
|
||||
// If restored mid-sort but nothing left unsorted, land on the hub.
|
||||
if (_stage == SortStage.sorting && isSortComplete) {
|
||||
_seedRankingFromMostImportant();
|
||||
_stage = SortStage.hub;
|
||||
}
|
||||
if (_stage == SortStage.pileReview && _reviewPile == null) {
|
||||
_stage = SortStage.hub;
|
||||
}
|
||||
} catch (_) {
|
||||
await _storage.clearSortSession();
|
||||
_resetSortState();
|
||||
|
||||
Reference in New Issue
Block a user