feat(route): search opens PDFs in pen editor too
The search-result document jump still opened the OLD PdfAnnotatorScreen, the last live entry to it. Route it to PenEditorScreen instead, and add an initialPage param to the editor so the jump lands on the hit's page (clamped to the document range once it loads). With this, PenEditorScreen is the ONLY reachable PDF surface; the old annotator is now dead code (no remaining references). flutter analyze: 0 issues. Full suite: 258/258.
This commit is contained in:
@@ -41,10 +41,18 @@ String _documentIdFromPath(String path) {
|
||||
}
|
||||
|
||||
class PenEditorScreen extends StatefulWidget {
|
||||
const PenEditorScreen({super.key, required this.pdfPath});
|
||||
const PenEditorScreen({
|
||||
super.key,
|
||||
required this.pdfPath,
|
||||
this.initialPage = 0,
|
||||
});
|
||||
|
||||
final String pdfPath;
|
||||
|
||||
/// 0-based page to open on (e.g. a search-result jump). Clamped to the
|
||||
/// document's page range once it loads.
|
||||
final int initialPage;
|
||||
|
||||
@override
|
||||
State<PenEditorScreen> createState() => _PenEditorScreenState();
|
||||
}
|
||||
@@ -212,7 +220,13 @@ class _PenEditorScreenState extends State<PenEditorScreen> {
|
||||
doc.dispose();
|
||||
return;
|
||||
}
|
||||
setState(() => _document = doc);
|
||||
setState(() {
|
||||
_document = doc;
|
||||
// Honor a requested initial page (search-result jump), clamped.
|
||||
if (doc.pages.isNotEmpty) {
|
||||
_pageIndex = widget.initialPage.clamp(0, doc.pages.length - 1);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
if (mounted) setState(() => _openError = e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user