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>
52 lines
1.3 KiB
Dart
52 lines
1.3 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:halkyon_learn_flutter/src/core/asset/data/asset_gateway.dart';
|
|
|
|
/// An [AssetGateway] in memory: ids are `asset-001`, `asset-002`, … in the
|
|
/// order of creation.
|
|
class FakeAssetGateway() implements AssetGateway {
|
|
final _rows = <String, AssetRow>{};
|
|
var _next = 1;
|
|
|
|
/// The rows, in the order they were stored.
|
|
List<AssetRow> get rows => [..._rows.values];
|
|
|
|
/// The rows deleted, in order.
|
|
final deleted = <String>[];
|
|
|
|
/// Stores [row] as if another device had written it and a sync had
|
|
/// brought it here.
|
|
void receiveRemote(AssetRow row) => _rows[row.id] = row;
|
|
|
|
@override
|
|
Future<AssetRow?> byId(String id) async => _rows[id];
|
|
|
|
@override
|
|
Future<AssetRow?> bySha256(String sha256) async =>
|
|
_rows.values.where((row) => row.sha256 == sha256).firstOrNull;
|
|
|
|
@override
|
|
Future<String> insert({
|
|
required String sha256,
|
|
required String mimeType,
|
|
required int byteSize,
|
|
required ByteData payload,
|
|
}) async {
|
|
final id = 'asset-${'${_next++}'.padLeft(3, '0')}';
|
|
_rows[id] = (
|
|
id: id,
|
|
sha256: sha256,
|
|
mimeType: mimeType,
|
|
byteSize: byteSize,
|
|
payload: payload,
|
|
);
|
|
return id;
|
|
}
|
|
|
|
@override
|
|
Future<void> delete(String id) async {
|
|
if (_rows.remove(id) != null) {
|
|
deleted.add(id);
|
|
}
|
|
}
|
|
}
|