feat: PDF sources: read, take notes and cards from pages, deadlines
PDFs live in a studyset's new Files tab: uploaded from Add material (a file the studyset holds already asks first), each row with its pages, cards, notes and size, how far it is read and its reading deadline; renamed, given a deadline (a page or a chapter by a day), marked as read, started afresh, deleted with a moment to undo. The reader (/pdfs/:id) opens where reading left off: on wide windows a rail of tools (search, fit, zoom, fullscreen), a page counter with the chapter, and a sidebar; on phones a top bar, a page scrubber and a sheet. The sidebar holds the PDF's flashcards, by page or chapter, made from selected text or written there, each tied to its page and tagged with its chapter; and the page's note, an ordinary note tied to the page. Screenshots of a region become images that know their page. Cards and screenshots lead back to their page; reading on past a chapter with cards suggests studying it. Home shows the deadlines running and to come, and a timeline of them. Server: pdf_source rows (content in the payload, last writer wins) and an append-only pdf_reading log, the furthest page derived from it so devices never conflict. Files up to 50 MB for PDFs (20 MB for others; a larger file that isn't a PDF is deleted once stored). A deleted PDF takes its file's asset row along unless another PDF has the same file. Card payload 4 and note payload 2 keep the page. The reader draws with pdfrx (PDFium) behind PdfEngine in Dependencies; widget tests use a fake, and integration_test/pdf_engine_test.dart checks the real engine on a device or the desktop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
ec34bb2334
commit
b96db731c1
2 changed files with 34926 additions and 58 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/asset/data/asset_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/content/rich_content.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';
|
||||
|
|
@ -6,6 +7,7 @@ import 'package:halkyon_learn_flutter/src/feature/learning_path/data/learning_pa
|
|||
import 'package:halkyon_learn_flutter/src/feature/learning_path/model/learning_path.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/note/data/note_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/note/model/note_content.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/pdf_source/data/pdf_source_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/study/data/review_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/study/model/rating.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/study/model/study_progress.dart';
|
||||
|
|
@ -16,11 +18,15 @@ import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_reposit
|
|||
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/fake_asset_gateway.dart';
|
||||
import '../../../support/fake_asset_server_gateway.dart';
|
||||
import '../../../support/fake_card_gateway.dart';
|
||||
import '../../../support/fake_learning_path_gateway.dart';
|
||||
import '../../../support/fake_note_gateway.dart';
|
||||
import '../../../support/fake_pdf_source_gateway.dart';
|
||||
import '../../../support/fake_review_gateway.dart';
|
||||
import '../../../support/fake_studyset_gateway.dart';
|
||||
import '../../../support/memory_asset_file_cache.dart';
|
||||
|
||||
void main() {
|
||||
late FakeStudysetGateway gateway;
|
||||
|
|
@ -61,6 +67,14 @@ void main() {
|
|||
cards,
|
||||
notes,
|
||||
paths,
|
||||
PdfSourceRepository(
|
||||
FakePdfSourceGateway(),
|
||||
AssetRepository(
|
||||
FakeAssetGateway(),
|
||||
FakeAssetServerGateway(),
|
||||
MemoryAssetFileCache(),
|
||||
),
|
||||
),
|
||||
undoWindow: undoWindow,
|
||||
);
|
||||
bloc = StudysetListBloc(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/asset/data/asset_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/core/content/rich_content.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';
|
||||
|
|
@ -6,15 +10,20 @@ import 'package:halkyon_learn_flutter/src/feature/learning_path/data/learning_pa
|
|||
import 'package:halkyon_learn_flutter/src/feature/learning_path/model/learning_path.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/note/data/note_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/note/model/note_content.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/pdf_source/data/pdf_source_repository.dart';
|
||||
import 'package:halkyon_learn_flutter/src/feature/studyset/data/studyset_deletions.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 '../../../support/eventually.dart';
|
||||
import '../../../support/fake_asset_gateway.dart';
|
||||
import '../../../support/fake_asset_server_gateway.dart';
|
||||
import '../../../support/fake_card_gateway.dart';
|
||||
import '../../../support/fake_learning_path_gateway.dart';
|
||||
import '../../../support/fake_note_gateway.dart';
|
||||
import '../../../support/fake_pdf_source_gateway.dart';
|
||||
import '../../../support/fake_studyset_gateway.dart';
|
||||
import '../../../support/memory_asset_file_cache.dart';
|
||||
|
||||
void main() {
|
||||
late FakeStudysetGateway studysetGateway;
|
||||
|
|
@ -25,6 +34,9 @@ void main() {
|
|||
late NoteRepository notes;
|
||||
late FakeLearningPathGateway pathGateway;
|
||||
late LearningPathRepository paths;
|
||||
late FakePdfSourceGateway pdfGateway;
|
||||
late AssetRepository assets;
|
||||
late PdfSourceRepository pdfs;
|
||||
late StudysetDeletions deletions;
|
||||
|
||||
setUp(() {
|
||||
|
|
@ -36,6 +48,13 @@ void main() {
|
|||
notes = NoteRepository(noteGateway);
|
||||
pathGateway = FakeLearningPathGateway();
|
||||
paths = LearningPathRepository(pathGateway);
|
||||
pdfGateway = FakePdfSourceGateway();
|
||||
assets = AssetRepository(
|
||||
FakeAssetGateway(),
|
||||
FakeAssetServerGateway(),
|
||||
MemoryAssetFileCache(),
|
||||
);
|
||||
pdfs = PdfSourceRepository(pdfGateway, assets);
|
||||
});
|
||||
tearDown(() async {
|
||||
await deletions.dispose();
|
||||
|
|
@ -43,6 +62,8 @@ void main() {
|
|||
await cards.dispose();
|
||||
await notes.dispose();
|
||||
await paths.dispose();
|
||||
await pdfs.dispose();
|
||||
await assets.dispose();
|
||||
});
|
||||
|
||||
void open(Duration undoWindow) => deletions = StudysetDeletions(
|
||||
|
|
@ -50,6 +71,7 @@ void main() {
|
|||
cards,
|
||||
notes,
|
||||
paths,
|
||||
pdfs,
|
||||
undoWindow: undoWindow,
|
||||
);
|
||||
|
||||
|
|
@ -59,8 +81,8 @@ void main() {
|
|||
);
|
||||
|
||||
test('a deletion waits for the time to undo, then deletes the whole '
|
||||
'subtree, what is inside first, each with its cards, notes and paths '
|
||||
'blanked', () async {
|
||||
'subtree, what is inside first, each with its cards, notes, paths and '
|
||||
'PDFs blanked', () async {
|
||||
open(const Duration(milliseconds: 50));
|
||||
final japanese = await studysets.create(StudysetContent.titled('Japanese'));
|
||||
final kana = await studysets.create(
|
||||
|
|
@ -76,6 +98,11 @@ void main() {
|
|||
kana,
|
||||
LearningPathContent.titled('Hiragana'),
|
||||
);
|
||||
final kanaPdf = (await pdfs.import(
|
||||
kana,
|
||||
bytes: Uint8List.fromList(utf8.encode('%PDF-1.7 kana')),
|
||||
fileName: 'kana.pdf',
|
||||
) as PdfImported).id;
|
||||
|
||||
deletions.delete(japanese);
|
||||
expect(deletions.pending, {japanese});
|
||||
|
|
@ -92,6 +119,7 @@ void main() {
|
|||
'blank path $kanaPath',
|
||||
'delete path $kanaPath',
|
||||
]);
|
||||
expect(pdfGateway.deletions, ['blank $kanaPdf', 'delete $kanaPdf']);
|
||||
expect(await studysets.all(), isEmpty);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue