feat(app): the studyset screen with its topics, the tree's own screen
A studyset's screen, as decided with the tree (2026-09-30/10-01):
- A breadcrumb from the library down to the studyset; its steps go up
(replacing the location, so back leads further up), and steps that
don't fit fold into a "…" listing them, nearest first.
- From expanded windows on, two columns: the description over the topics,
the flashcards beside them, Study and Add material in the app bar. Below
that, the topics are in a drawer, opened from a bar at the bottom that
also holds Study and Add material and slides away while reading onwards;
the back button stays where a drawer would have taken its place.
- The topics: "All topics" for the whole studyset, then the studysets
inside it in their order, each with the study it invites, what it holds
and its options (edit, delete), opening on top of this screen; a switch
rearranges them by dragging; "New sub-studyset" creates one inside.
- Study covers the studyset with everything inside it ("Learn 12" while
something is due). Add material offers flashcards for now.
- Options: Edit (the sheet, now with the description, edited in the whole
window, and for a studyset inside another the colour of the one it is
in, which a new one takes at first), Move to… (the tree and the top
level, without the studyset itself and what is inside it), Archive or
Unarchive with Undo, Delete with Undo, which closes the screen.
- The description cut short when long, the whole a tap away; the licence
as the last line, linking to its text where that is known.
The list's bloc, scoped to a parent, lists its children, works out the
studyset's own progress, creates inside it, reorders and moves. The card
list leaves adding and studying to the screen. The inline editing of the
title and description, and its bloc, are gone.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
9c2960f49d
commit
31d87e8415
2 changed files with 2597 additions and 541 deletions
|
|
@ -1,98 +0,0 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/card/data/card_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/card/model/card_content.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/bloc/studyset_edit_bloc.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/model/studyset.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/model/studyset_content.dart';
|
||||
|
||||
import '../../../support/fake_card_gateway.dart';
|
||||
import '../../../support/fake_studyset_gateway.dart';
|
||||
|
||||
void main() {
|
||||
late FakeStudysetGateway gateway;
|
||||
late StudysetRepository repository;
|
||||
|
||||
setUp(() {
|
||||
gateway = FakeStudysetGateway();
|
||||
repository = StudysetRepository(gateway);
|
||||
});
|
||||
tearDown(() => repository.dispose());
|
||||
|
||||
group('StudysetEditBloc', () {
|
||||
late FakeCardGateway cardGateway;
|
||||
late CardRepository cards;
|
||||
late Studyset studyset;
|
||||
late StudysetEditBloc bloc;
|
||||
|
||||
setUp(() async {
|
||||
cardGateway = FakeCardGateway();
|
||||
cards = CardRepository(cardGateway);
|
||||
final id = await repository.create(StudysetContent.titled('Japanese'));
|
||||
studyset = Studyset(id: id, content: StudysetContent.titled('Japanese'));
|
||||
bloc = StudysetEditBloc(repository, cards, studyset);
|
||||
});
|
||||
tearDown(() async {
|
||||
await bloc.close();
|
||||
await cards.dispose();
|
||||
});
|
||||
|
||||
test('deleting the studyset blanks and deletes its cards too', () async {
|
||||
final card = await cards.create(studyset.id, CardContent.empty());
|
||||
|
||||
bloc.add(const StudysetEditEventDeleteRequested());
|
||||
|
||||
await expectLater(
|
||||
bloc.stream,
|
||||
emits(
|
||||
isA<StudysetEditState>().having((s) => s.isDeleted, 'deleted', true),
|
||||
),
|
||||
);
|
||||
expect(cardGateway.deletions, ['blank $card', 'delete $card']);
|
||||
expect(await cards.cardsOf(studyset.id), isEmpty);
|
||||
});
|
||||
|
||||
test('keeps changes unsaved until asked to save', () async {
|
||||
bloc.add(const StudysetEditEventTitleChanged('日本語'));
|
||||
await expectLater(
|
||||
bloc.stream,
|
||||
emits(
|
||||
isA<StudysetEditState>().having(
|
||||
(s) => s.hasChanges,
|
||||
'has changes',
|
||||
true,
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(
|
||||
(await repository.watchAll().first).single.content.title,
|
||||
'Japanese',
|
||||
);
|
||||
|
||||
bloc.add(const StudysetEditEventSaveRequested());
|
||||
await expectLater(
|
||||
bloc.stream,
|
||||
emits(
|
||||
isA<StudysetEditState>().having(
|
||||
(s) => s.hasChanges,
|
||||
'has changes',
|
||||
false,
|
||||
),
|
||||
),
|
||||
);
|
||||
expect((await repository.watchAll().first).single.content.title, '日本語');
|
||||
});
|
||||
|
||||
test('deletes the studyset and says so', () async {
|
||||
bloc.add(const StudysetEditEventDeleteRequested());
|
||||
|
||||
await expectLater(
|
||||
bloc.stream,
|
||||
emits(
|
||||
isA<StudysetEditState>().having((s) => s.isDeleted, 'deleted', true),
|
||||
),
|
||||
);
|
||||
expect(await repository.watchAll().first, isEmpty);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -9,8 +9,8 @@ import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_deletio
|
|||
import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_payload.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/model/studyset_content.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/model/studyset_tree.dart';
|
||||
|
||||
import '../../../support/eventually.dart';
|
||||
import '../../../support/fake_card_gateway.dart';
|
||||
import '../../../support/fake_review_gateway.dart';
|
||||
import '../../../support/fake_studyset_gateway.dart';
|
||||
|
|
@ -37,13 +37,17 @@ void main() {
|
|||
});
|
||||
|
||||
/// Opens the library, where a deletion can be undone for [undoWindow].
|
||||
void start({Duration undoWindow = const Duration(milliseconds: 1)}) {
|
||||
void start({
|
||||
Duration undoWindow = const Duration(milliseconds: 1),
|
||||
String? parentId,
|
||||
}) {
|
||||
deletions = StudysetDeletions(studysets, cards, undoWindow: undoWindow);
|
||||
bloc = StudysetListBloc(
|
||||
studysets,
|
||||
cards,
|
||||
ReviewRepository(FakeReviewGateway()),
|
||||
deletions,
|
||||
parentId: parentId,
|
||||
)..add(const StudysetListEventStarted());
|
||||
}
|
||||
|
||||
|
|
@ -245,36 +249,92 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('deleting hides a studyset at once, and deletes it with what is '
|
||||
'inside it once the time to undo is over', () async {
|
||||
final id = await studysets.create(StudysetContent.titled('Japanese'));
|
||||
final kana = await studysets.create(
|
||||
StudysetContent.titled('Kana'),
|
||||
parentId: id,
|
||||
);
|
||||
final card = await cards.create(kana, newCard());
|
||||
start(undoWindow: const Duration(milliseconds: 50));
|
||||
await listing(['Japanese']);
|
||||
|
||||
bloc.add(StudysetListEventDeleteRequested(id));
|
||||
await listing([]);
|
||||
expect(gateway.deleted, isEmpty);
|
||||
|
||||
await eventually(() => gateway.deleted.length == 2);
|
||||
expect(gateway.deleted, [kana, id]);
|
||||
expect(cardGateway.deletions, ['blank $card', 'delete $card']);
|
||||
});
|
||||
|
||||
test('undoing in time keeps the studyset', () async {
|
||||
test('leaves out a studyset whose deletion waits, and shows it again '
|
||||
'when that is undone', () async {
|
||||
final id = await studysets.create(StudysetContent.titled('Japanese'));
|
||||
start(undoWindow: const Duration(hours: 1));
|
||||
await listing(['Japanese']);
|
||||
|
||||
bloc.add(StudysetListEventDeleteRequested(id));
|
||||
deletions.delete(id);
|
||||
await listing([]);
|
||||
bloc.add(StudysetListEventDeleteUndone(id));
|
||||
deletions.undo(id);
|
||||
|
||||
await listing(['Japanese']);
|
||||
expect(gateway.deleted, isEmpty);
|
||||
});
|
||||
|
||||
group('inside a studyset', () {
|
||||
test('lists its children in their order, each with its progress, and '
|
||||
"works out the studyset's own", () async {
|
||||
final japanese = await studysets.create(
|
||||
StudysetContent.titled('Japanese'),
|
||||
);
|
||||
final kanji = await studysets.create(
|
||||
StudysetContent.titled('Kanji'),
|
||||
parentId: japanese,
|
||||
);
|
||||
final kana = await studysets.create(
|
||||
StudysetContent.titled('Kana'),
|
||||
parentId: japanese,
|
||||
);
|
||||
await studysets.reorder(kana, toIndex: 0);
|
||||
await cards.create(japanese, newCard());
|
||||
await cards.create(kana, newCard());
|
||||
|
||||
start(parentId: japanese);
|
||||
final state = await listing(['Kana', 'Kanji']);
|
||||
|
||||
expect(state.progress, {
|
||||
kana: const StudyProgress(cards: 1, due: 1, reviewsDue: 0, mature: 0),
|
||||
kanji: const StudyProgress(cards: 0, due: 0, reviewsDue: 0, mature: 0),
|
||||
japanese: const StudyProgress(
|
||||
cards: 2,
|
||||
due: 2,
|
||||
reviewsDue: 0,
|
||||
mature: 0,
|
||||
),
|
||||
});
|
||||
expect(state.studysets.map((studyset) => studyset.id), [kana, kanji]);
|
||||
});
|
||||
|
||||
test('moves a studyset somewhere else', () async {
|
||||
final japanese = await studysets.create(
|
||||
StudysetContent.titled('Japanese'),
|
||||
);
|
||||
final kana = await studysets.create(
|
||||
StudysetContent.titled('Kana'),
|
||||
parentId: japanese,
|
||||
);
|
||||
start(parentId: japanese);
|
||||
await listing(['Kana']);
|
||||
|
||||
bloc.add(StudysetListEventMoveRequested(kana, parentId: null));
|
||||
|
||||
await listing([]);
|
||||
expect(topLevel(await studysets.all()), hasLength(2));
|
||||
});
|
||||
|
||||
test('creates studysets inside it and reorders them', () async {
|
||||
final japanese = await studysets.create(
|
||||
StudysetContent.titled('Japanese'),
|
||||
);
|
||||
start(parentId: japanese);
|
||||
await listing([]);
|
||||
|
||||
bloc
|
||||
..add(StudysetListEventCreateRequested(StudysetContent.titled('Kana')))
|
||||
..add(
|
||||
StudysetListEventCreateRequested(StudysetContent.titled('Kanji')),
|
||||
);
|
||||
final created = await listing(['Kana', 'Kanji']);
|
||||
bloc.add(
|
||||
StudysetListEventReorderRequested(
|
||||
created.studysets.last.id,
|
||||
toIndex: 0,
|
||||
),
|
||||
);
|
||||
|
||||
await listing(['Kanji', 'Kana']);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue