A cross platform Audiobookshelf client for Android and iOS
Dart
See all your ebook highlights in one place and share a quote from any of them
Barnabas88cbdca1cce2
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arbindex ebde72d7..4d6f868e 100644--- a/lib/l10n/app_en.arb+++ b/lib/l10n/app_en.arb@@ -356,6 +356,52 @@}},"bookmarksTitle": "All Bookmarks",+ "bookmarksTabBookmarks": "Bookmarks",+ "bookmarksTabHighlights": "Highlights",+ "highlightOpenInBook": "Open in book",+ "highlightDeleteAction": "Delete highlight",+ "highlightDeleted": "Highlight deleted",+ "highlightsDeleteCount": "Delete {count} highlight(s)?",+ "@highlightsDeleteCount": {+ "placeholders": {+ "count": {+ "type": "int"+ }+ }+ },+ "highlightsDeletedCount": "Deleted {count} highlight(s)",+ "@highlightsDeletedCount": {+ "placeholders": {+ "count": {+ "type": "int"+ }+ }+ },+ "quoteShareTitle": "Share quote",+ "quoteShareAction": "Share",+ "quoteShareFailed": "Couldn't make the quote image",+ "quoteShapePortrait": "Portrait",+ "quoteShapeSquare": "Square",+ "quoteShapeStory": "Story",+ "quoteStyleBlur": "Blurred",+ "quoteStyleDim": "Dimmed",+ "quoteStyleNone": "Plain cover",+ "quoteTextLight": "Light text",+ "quoteTextDark": "Dark text",+ "quoteFieldTitle": "Title",+ "quoteFieldDetail": "Details",+ "quoteFieldDetailHint": "Author, chapter, page, who said it",+ "highlightsMeta": "{chapter} · {date}",+ "@highlightsMeta": {+ "placeholders": {+ "chapter": {+ "type": "String"+ },+ "date": {+ "type": "String"+ }+ }+ },"bookmarksCancelSelection": "Cancel selection","bookmarksSortedByNewest": "Sorted by newest","bookmarksSortedByPosition": "Sorted by position",diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dartindex 4edb32eb..70be318c 100644--- a/lib/l10n/app_localizations.dart+++ b/lib/l10n/app_localizations.dart@@ -1468,6 +1468,138 @@ abstract class AppLocalizations {/// **'All Bookmarks'**String get bookmarksTitle;+ /// No description provided for @bookmarksTabBookmarks.+ ///+ /// In en, this message translates to:+ /// **'Bookmarks'**+ String get bookmarksTabBookmarks;++ /// No description provided for @bookmarksTabHighlights.+ ///+ /// In en, this message translates to:+ /// **'Highlights'**+ String get bookmarksTabHighlights;++ /// No description provided for @highlightOpenInBook.+ ///+ /// In en, this message translates to:+ /// **'Open in book'**+ String get highlightOpenInBook;++ /// No description provided for @highlightDeleteAction.+ ///+ /// In en, this message translates to:+ /// **'Delete highlight'**+ String get highlightDeleteAction;++ /// No description provided for @highlightDeleted.+ ///+ /// In en, this message translates to:+ /// **'Highlight deleted'**+ String get highlightDeleted;++ /// No description provided for @highlightsDeleteCount.+ ///+ /// In en, this message translates to:+ /// **'Delete {count} highlight(s)?'**+ String highlightsDeleteCount(int count);++ /// No description provided for @highlightsDeletedCount.+ ///+ /// In en, this message translates to:+ /// **'Deleted {count} highlight(s)'**+ String highlightsDeletedCount(int count);++ /// No description provided for @quoteShareTitle.+ ///+ /// In en, this message translates to:+ /// **'Share quote'**+ String get quoteShareTitle;++ /// No description provided for @quoteShareAction.+ ///+ /// In en, this message translates to:+ /// **'Share'**+ String get quoteShareAction;++ /// No description provided for @quoteShareFailed.+ ///+ /// In en, this message translates to:+ /// **'Couldn\'t make the quote image'**+ String get quoteShareFailed;++ /// No description provided for @quoteShapePortrait.+ ///+ /// In en, this message translates to:+ /// **'Portrait'**+ String get quoteShapePortrait;++ /// No description provided for @quoteShapeSquare.+ ///+ /// In en, this message translates to:+ /// **'Square'**+ String get quoteShapeSquare;++ /// No description provided for @quoteShapeStory.+ ///+ /// In en, this message translates to:+ /// **'Story'**+ String get quoteShapeStory;++ /// No description provided for @quoteStyleBlur.+ ///+ /// In en, this message translates to:+ /// **'Blurred'**+ String get quoteStyleBlur;++ /// No description provided for @quoteStyleDim.+ ///+ /// In en, this message translates to:+ /// **'Dimmed'**+ String get quoteStyleDim;++ /// No description provided for @quoteStyleNone.+ ///+ /// In en, this message translates to:+ /// **'Plain cover'**+ String get quoteStyleNone;++ /// No description provided for @quoteTextLight.+ ///+ /// In en, this message translates to:+ /// **'Light text'**+ String get quoteTextLight;++ /// No description provided for @quoteTextDark.+ ///+ /// In en, this message translates to:+ /// **'Dark text'**+ String get quoteTextDark;++ /// No description provided for @quoteFieldTitle.+ ///+ /// In en, this message translates to:+ /// **'Title'**+ String get quoteFieldTitle;++ /// No description provided for @quoteFieldDetail.+ ///+ /// In en, this message translates to:+ /// **'Details'**+ String get quoteFieldDetail;++ /// No description provided for @quoteFieldDetailHint.+ ///+ /// In en, this message translates to:+ /// **'Author, chapter, page, who said it'**+ String get quoteFieldDetailHint;++ /// No description provided for @highlightsMeta.+ ///+ /// In en, this message translates to:+ /// **'{chapter} · {date}'**+ String highlightsMeta(String chapter, String date);+/// No description provided for @bookmarksCancelSelection.////// In en, this message translates to:diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dartindex 65eb215d..e119a168 100644--- a/lib/l10n/app_localizations_de.dart+++ b/lib/l10n/app_localizations_de.dart@@ -755,6 +755,78 @@ class AppLocalizationsDe extends AppLocalizations {@overrideString get bookmarksTitle => 'Alle Lesezeichen';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Auswahl aufheben';diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dartindex ad84d8d6..422c9eea 100644--- a/lib/l10n/app_localizations_el.dart+++ b/lib/l10n/app_localizations_el.dart@@ -748,6 +748,78 @@ class AppLocalizationsEl extends AppLocalizations {@overrideString get bookmarksTitle => 'All Bookmarks';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Cancel selection';diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dartindex c4808fb8..36470be9 100644--- a/lib/l10n/app_localizations_en.dart+++ b/lib/l10n/app_localizations_en.dart@@ -748,6 +748,78 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get bookmarksTitle => 'All Bookmarks';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Cancel selection';diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dartindex e0b88284..fdfe2185 100644--- a/lib/l10n/app_localizations_es.dart+++ b/lib/l10n/app_localizations_es.dart@@ -750,6 +750,78 @@ class AppLocalizationsEs extends AppLocalizations {@overrideString get bookmarksTitle => 'All Bookmarks';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Cancel selection';diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dartindex 105ab0e5..5044a808 100644--- a/lib/l10n/app_localizations_fr.dart+++ b/lib/l10n/app_localizations_fr.dart@@ -756,6 +756,78 @@ class AppLocalizationsFr extends AppLocalizations {@overrideString get bookmarksTitle => 'Tous les signets';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Annuler la sélection';diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dartindex b03ec9f2..92b70857 100644--- a/lib/l10n/app_localizations_it.dart+++ b/lib/l10n/app_localizations_it.dart@@ -748,6 +748,78 @@ class AppLocalizationsIt extends AppLocalizations {@overrideString get bookmarksTitle => 'All Bookmarks';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Cancel selection';diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dartindex 9fc7b7da..c0549e78 100644--- a/lib/l10n/app_localizations_ja.dart+++ b/lib/l10n/app_localizations_ja.dart@@ -748,6 +748,78 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get bookmarksTitle => 'All Bookmarks';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Cancel selection';diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dartindex 11c58182..268a86c0 100644--- a/lib/l10n/app_localizations_no.dart+++ b/lib/l10n/app_localizations_no.dart@@ -748,6 +748,78 @@ class AppLocalizationsNo extends AppLocalizations {@overrideString get bookmarksTitle => 'All Bookmarks';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Cancel selection';diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dartindex 65ca61a4..7f1f86a0 100644--- a/lib/l10n/app_localizations_pt.dart+++ b/lib/l10n/app_localizations_pt.dart@@ -748,6 +748,78 @@ class AppLocalizationsPt extends AppLocalizations {@overrideString get bookmarksTitle => 'All Bookmarks';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Cancel selection';diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dartindex 55e347d8..b74757fe 100644--- a/lib/l10n/app_localizations_ro.dart+++ b/lib/l10n/app_localizations_ro.dart@@ -748,6 +748,78 @@ class AppLocalizationsRo extends AppLocalizations {@overrideString get bookmarksTitle => 'All Bookmarks';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Cancel selection';diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dartindex 37c55008..e9c9b739 100644--- a/lib/l10n/app_localizations_ru.dart+++ b/lib/l10n/app_localizations_ru.dart@@ -748,6 +748,78 @@ class AppLocalizationsRu extends AppLocalizations {@overrideString get bookmarksTitle => 'Все закладки';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => 'Отменить выбранное';diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dartindex 57d85d29..e285b893 100644--- a/lib/l10n/app_localizations_zh.dart+++ b/lib/l10n/app_localizations_zh.dart@@ -737,6 +737,78 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get bookmarksTitle => '全部书签';+ @override+ String get bookmarksTabBookmarks => 'Bookmarks';++ @override+ String get bookmarksTabHighlights => 'Highlights';++ @override+ String get highlightOpenInBook => 'Open in book';++ @override+ String get highlightDeleteAction => 'Delete highlight';++ @override+ String get highlightDeleted => 'Highlight deleted';++ @override+ String highlightsDeleteCount(int count) {+ return 'Delete $count highlight(s)?';+ }++ @override+ String highlightsDeletedCount(int count) {+ return 'Deleted $count highlight(s)';+ }++ @override+ String get quoteShareTitle => 'Share quote';++ @override+ String get quoteShareAction => 'Share';++ @override+ String get quoteShareFailed => 'Couldn\'t make the quote image';++ @override+ String get quoteShapePortrait => 'Portrait';++ @override+ String get quoteShapeSquare => 'Square';++ @override+ String get quoteShapeStory => 'Story';++ @override+ String get quoteStyleBlur => 'Blurred';++ @override+ String get quoteStyleDim => 'Dimmed';++ @override+ String get quoteStyleNone => 'Plain cover';++ @override+ String get quoteTextLight => 'Light text';++ @override+ String get quoteTextDark => 'Dark text';++ @override+ String get quoteFieldTitle => 'Title';++ @override+ String get quoteFieldDetail => 'Details';++ @override+ String get quoteFieldDetailHint => 'Author, chapter, page, who said it';++ @override+ String highlightsMeta(String chapter, String date) {+ return '$chapter · $date';+ }+@overrideString get bookmarksCancelSelection => '取消选择';diff --git a/lib/screens/bookmarks_screen.dart b/lib/screens/bookmarks_screen.dartindex bcfc87c3..0c637c9f 100644--- a/lib/screens/bookmarks_screen.dart+++ b/lib/screens/bookmarks_screen.dart@@ -2,6 +2,7 @@ import 'dart:convert';import 'dart:io';import 'package:cached_network_image/cached_network_image.dart';import 'package:flutter/material.dart';+import 'package:flutter/services.dart';import 'package:provider/provider.dart';import '../providers/auth_provider.dart';import '../providers/library_provider.dart';@@ -13,7 +14,12 @@ import '../services/scoped_prefs.dart';import '../widgets/bookmark_detail_dialog.dart';import '../widgets/card_buttons.dart';import '../services/download_service.dart';+import '../services/ebook_annotation_service.dart';+import '../services/ebook_cache.dart';import '../widgets/absorb_page_header.dart';+import '../widgets/adaptive_modal.dart';+import '../widgets/ebook_router.dart';+import '../widgets/quote_share_sheet.dart';import '../widgets/overlay_toast.dart';import '../l10n/app_localizations.dart';@@ -23,13 +29,20 @@ class BookmarksScreen extends StatefulWidget {State<BookmarksScreen> createState() => _BookmarksScreenState();}-class _BookmarksScreenState extends State<BookmarksScreen> {+class _BookmarksScreenState extends State<BookmarksScreen>+ with SingleTickerProviderStateMixin {bool _loading = true;Map<String, List<Bookmark>> _allBookmarks = {};+ Map<String, List<EbookAnnotation>> _highlights = {};+ late final TabController _tabs;+ int _tabIndex = 0;bool _selecting = false;String _sort = 'newest';// Selected bookmarks as "itemId::bookmarkId" keysfinal Set<String> _selected = {};+ // Same idea on the highlights tab, keyed "itemId::annotationId". Separate+ // sets so a selection can't leak across tabs.+ final Set<String> _selectedHighlights = {};final Map<String, String> _titleCache = {};bool _speedAdjustedTime = true;// Per-book playback speed so each group's timestamps honor the@@ -42,12 +55,66 @@ class _BookmarksScreenState extends State<BookmarksScreen> {@overridevoid initState() {super.initState();+ _tabs = TabController(length: 2, vsync: this);+ _tabs.addListener(() {+ if (!mounted || _tabs.index == _tabIndex) return;+ setState(() => _tabIndex = _tabs.index);+ // Selection is a bookmarks-only mode, so leave it behind on the way out.+ if (_tabs.index != 0 && _selecting) _exitSelection();+ });_loadSort();+ _loadHighlights();PlayerSettings.getSpeedAdjustedTime().then((v) {if (mounted && v != _speedAdjustedTime) setState(() => _speedAdjustedTime = v);});}+ @override+ void dispose() {+ _tabs.dispose();+ super.dispose();+ }++ Future<void> _loadHighlights() async {+ final highlights = await EbookAnnotationService().getAllHighlights();+ if (!mounted) return;+ // The tab bar disappears with the last highlight, so don't strand the view+ // on a tab that no longer has a header.+ if (highlights.isEmpty && _tabs.index != 0) _tabs.index = 0;+ setState(() => _highlights = highlights);+ await _fetchMissingTitles(highlights.keys.toList());+ }++ /// Fills the title cache for books we only know by ID, so highlight cards+ /// show a real title instead of a placeholder bar.+ Future<void> _fetchMissingTitles(List<String> itemIds) async {+ final api = context.read<AuthProvider>().apiService;+ var dirty = false;+ for (final itemId in itemIds) {+ if (!mounted) break;+ if (_titleCache.containsKey(itemId)) continue;+ final resolved = _resolveTitle(itemId);+ if (resolved != null) {+ _titleCache[itemId] = resolved;+ dirty = true;+ continue;+ }+ if (api == null) continue;+ final item = await api.getLibraryItem(itemId);+ final media = item?['media'] as Map<String, dynamic>? ?? {};+ final metadata = media['metadata'] as Map<String, dynamic>? ?? {};+ final title = metadata['title'] as String?;+ if (title != null && title.isNotEmpty) {+ _titleCache[itemId] = title;+ dirty = true;+ }+ }+ if (dirty) {+ await _saveTitleCache();+ if (mounted) setState(() {});+ }+ }+Future<void> _loadBookSpeeds() async {_defaultSpeed = await PlayerSettings.getDefaultSpeed();var changed = false;@@ -199,9 +266,85 @@ class _BookmarksScreenState extends State<BookmarksScreen> {setState(() {_selecting = false;_selected.clear();+ _selectedHighlights.clear();+ });+ }++ void _toggleHighlight(String itemId, String annotationId) {+ setState(() {+ final key = _selKey(itemId, annotationId);+ if (_selectedHighlights.contains(key)) {+ _selectedHighlights.remove(key);+ if (_selectedHighlights.isEmpty) _selecting = false;+ } else {+ _selectedHighlights.add(key);+ }+ });+ }++ void _toggleHighlightGroup(String itemId, List<EbookAnnotation> highlights) {+ setState(() {+ final keys = highlights.map((h) => _selKey(itemId, h.id)).toSet();+ if (keys.every(_selectedHighlights.contains)) {+ _selectedHighlights.removeAll(keys);+ if (_selectedHighlights.isEmpty) _selecting = false;+ } else {+ _selectedHighlights.addAll(keys);+ }+ });+ }++ void _enterHighlightSelection(String itemId, String annotationId) {+ setState(() {+ _selecting = true;+ _selectedHighlights.add(_selKey(itemId, annotationId));});}+ Future<void> _deleteSelectedHighlights() async {+ if (_selectedHighlights.isEmpty) return;+ final l = AppLocalizations.of(context)!;+ final count = _selectedHighlights.length;+ final confirmed = await showDialog<bool>(+ context: context,+ builder: (ctx) => AlertDialog(+ icon: const Icon(Icons.delete_outline_rounded),+ title: Text(l.highlightsDeleteCount(count)),+ content: Text(l.bookmarksDeleteContent),+ actions: [+ TextButton(+ onPressed: () => Navigator.pop(ctx, false),+ child: Text(l.cancel),+ ),+ FilledButton(+ onPressed: () => Navigator.pop(ctx, true),+ child: Text(l.delete),+ ),+ ],+ ),+ );+ if (confirmed != true || !mounted) return;++ final grouped = <String, List<String>>{};+ for (final key in _selectedHighlights) {+ final parts = key.split('::');+ grouped.putIfAbsent(parts[0], () => []).add(parts[1]);+ }+ for (final entry in grouped.entries) {+ for (final id in entry.value) {+ await EbookAnnotationService()+ .delete(itemId: entry.key, annotationId: id);+ }+ }++ _exitSelection();+ await _loadHighlights();+ if (mounted) {+ showOverlayToast(context, l.highlightsDeletedCount(count),+ icon: Icons.delete_outline_rounded);+ }+ }+Future<void> _deleteSelected() async {if (_selected.isEmpty) return;@@ -362,6 +505,211 @@ class _BookmarksScreenState extends State<BookmarksScreen> {AppShell.goToAbsorbingGlobal();}+ /// Opens the book at the highlight. A downloaded ebook opens from the reader+ /// cache, so this still works offline.+ Future<void> _openHighlight(String itemId, EbookAnnotation highlight) async {+ final l = AppLocalizations.of(context)!;+ final api = context.read<AuthProvider>().apiService;+ var title = _resolveTitle(itemId);+ var ebookFile = await cachedEbookFileFor(itemId);+ if (ebookFile == null && api != null) {+ final item = await api.getLibraryItem(itemId);+ ebookFile = resolveEbookFile(item);+ if (title == null) {+ final media = item?['media'] as Map<String, dynamic>? ?? {};+ final metadata = media['metadata'] as Map<String, dynamic>? ?? {};+ title = metadata['title'] as String?;+ }+ }+ if (!mounted) return;+ if (ebookFile == null) {+ showOverlayToast(+ context,+ api == null ? l.bookmarksNotConnected : l.noEbookFileFound,+ icon: Icons.menu_book_outlined,+ );+ return;+ }+ await openEbookReader(+ context,+ itemId: itemId,+ title: title ?? '',+ ebookFile: ebookFile,+ openAtCfi: highlight.cfi,+ );+ // Highlights added or removed while reading show up on the way back.+ if (mounted) await _loadHighlights();+ }++ Future<void> _highlightActions(String itemId, EbookAnnotation highlight) async {+ final l = AppLocalizations.of(context)!;+ final cs = Theme.of(context).colorScheme;+ final tt = Theme.of(context).textTheme;+ final action = await showAdaptiveActionMenu<String>(+ context: context,+ showDragHandle: true,+ backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,+ shape: const RoundedRectangleBorder(+ borderRadius: BorderRadius.vertical(top: Radius.circular(24)),+ ),+ builder: (ctx) => SafeArea(+ child: Column(mainAxisSize: MainAxisSize.min, children: [+ if ((highlight.selectedText ?? '').isNotEmpty)+ Padding(+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 12),+ child: Text(+ highlight.selectedText!,+ maxLines: 3,+ overflow: TextOverflow.ellipsis,+ style: tt.bodyMedium?.copyWith(color: cs.onSurfaceVariant),+ ),+ ),+ ListTile(+ leading: Icon(Icons.ios_share_rounded, color: cs.onSurfaceVariant),+ title: Text(l.quoteShareTitle),+ onTap: () => Navigator.pop(ctx, 'share'),+ ),+ ListTile(+ leading: Icon(Icons.menu_book_rounded, color: cs.onSurfaceVariant),+ title: Text(l.highlightOpenInBook),+ onTap: () => Navigator.pop(ctx, 'open'),+ ),+ ListTile(+ leading: Icon(Icons.copy_rounded, color: cs.onSurfaceVariant),+ title: Text(l.readerTooltipCopy),+ onTap: () => Navigator.pop(ctx, 'copy'),+ ),+ ListTile(+ leading: Icon(Icons.delete_outline_rounded, color: cs.error),+ title: Text(l.highlightDeleteAction, style: TextStyle(color: cs.error)),+ onTap: () => Navigator.pop(ctx, 'delete'),+ ),+ ]),+ ),+ );+ if (action == null || !mounted) return;+ if (action == 'share') {+ await _shareHighlight(itemId, highlight);+ } else if (action == 'open') {+ await _openHighlight(itemId, highlight);+ } else if (action == 'copy') {+ await Clipboard.setData(ClipboardData(text: highlight.selectedText ?? ''));+ if (mounted) showOverlayToast(context, l.readerCopied, icon: Icons.copy_rounded);+ } else if (action == 'delete') {+ await EbookAnnotationService()+ .delete(itemId: itemId, annotationId: highlight.id);+ await _loadHighlights();+ if (mounted) {+ showOverlayToast(context, l.highlightDeleted,+ icon: Icons.delete_outline_rounded);+ }+ }+ }++ Future<void> _shareHighlight(String itemId, EbookAnnotation highlight) async {+ await showQuoteShareSheet(+ context,+ itemId: itemId,+ quote: highlight.selectedText ?? '',+ bookTitle: _resolveTitle(itemId),+ author: _resolveAuthor(itemId),+ chapter: highlight.chapter,+ );+ }++ /// Author for the quote card, from whatever cache already knows this book.+ /// The card just drops the line when nothing does.+ String? _resolveAuthor(String itemId) {+ final libCache = context.read<LibraryProvider>().absorbingItemCache[itemId];+ if (libCache != null) {+ final media = libCache['media'] as Map<String, dynamic>? ?? {};+ final metadata = media['metadata'] as Map<String, dynamic>? ?? {};+ final author = metadata['authorName'] as String?;+ if (author != null && author.isNotEmpty) return author;+ }+ final dl = DownloadService().getInfo(itemId);+ if (dl.author != null && dl.author!.isNotEmpty) return dl.author;+ return null;+ }++ Widget _emptyState(ColorScheme cs, TextTheme tt, IconData icon, String label) {+ return Center(+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Icon(icon, size: 48, color: cs.onSurfaceVariant.withValues(alpha: 0.4)),+ const SizedBox(height: 12),+ Text(label, style: tt.bodyLarge?.copyWith(color: cs.onSurfaceVariant)),+ ],+ ),+ );+ }++ Widget _buildBookmarksTab(ColorScheme cs, TextTheme tt, AppLocalizations l) {+ if (_allBookmarks.isEmpty) {+ return _emptyState(+ cs, tt, Icons.bookmark_border_rounded, l.bookmarksNoBookmarks);+ }+ return ListView.builder(+ padding: const EdgeInsets.fromLTRB(16, 0, 16, 24),+ itemCount: _allBookmarks.length,+ itemBuilder: (ctx, i) {+ final lib = context.read<LibraryProvider>();+ final itemId = _allBookmarks.keys.elementAt(i);+ final bookmarks = _allBookmarks[itemId]!;+ final resolvedTitle = _resolveTitle(itemId);+ final coverUrl = lib.getCoverUrl(itemId, width: 400);+ return _BookGroup(+ itemId: itemId,+ title: resolvedTitle,+ coverUrl: coverUrl,+ mediaHeaders: lib.mediaHeaders,+ bookmarks: bookmarks,+ displaySpeed: _displaySpeedFor(itemId),+ cs: cs,+ tt: tt,+ selecting: _selecting,+ selected: _selected,+ onToggle: _toggleSelect,+ onToggleGroup: () => _toggleBookGroup(itemId, bookmarks),+ onLongPress: _enterSelection,+ onJump: (id, bm) => _jumpToBookmark(id, bm, resolvedTitle ?? ''),+ );+ },+ );+ }++ Widget _buildHighlightsTab(ColorScheme cs, TextTheme tt, AppLocalizations l) {+ if (_highlights.isEmpty) {+ return _emptyState(+ cs, tt, Icons.format_quote_rounded, l.readerNoHighlights);+ }+ return ListView.builder(+ padding: const EdgeInsets.fromLTRB(16, 0, 16, 24),+ itemCount: _highlights.length,+ itemBuilder: (ctx, i) {+ final lib = context.read<LibraryProvider>();+ final itemId = _highlights.keys.elementAt(i);+ final highlights = _highlights[itemId]!;+ return _HighlightGroup(+ itemId: itemId,+ title: _resolveTitle(itemId),+ coverUrl: lib.getCoverUrl(itemId, width: 400),+ mediaHeaders: lib.mediaHeaders,+ highlights: highlights,+ cs: cs,+ tt: tt,+ selecting: _selecting,+ selected: _selectedHighlights,+ onActions: _highlightActions,+ onToggle: _toggleHighlight,+ onToggleGroup: () => _toggleHighlightGroup(itemId, highlights),+ onLongPress: _enterHighlightSelection,+ );+ },+ );+ }+@overrideWidget build(BuildContext context) {final cs = Theme.of(context).colorScheme;@@ -387,7 +735,13 @@ class _BookmarksScreenState extends State<BookmarksScreen> {onPressed: _exitSelection,)else ...[- if (_allBookmarks.isNotEmpty) ...[+ if (_tabIndex == 1 && _highlights.isNotEmpty)+ IconButton(+ icon: Icon(Icons.checklist_rounded, color: cs.onSurfaceVariant),+ tooltip: l.bookmarksSelect,+ onPressed: () => setState(() => _selecting = true),+ ),+ if (_tabIndex == 0 && _allBookmarks.isNotEmpty) ...[GestureDetector(onTap: () {final next = _sort == 'newest' ? 'position'@@ -435,54 +789,39 @@ class _BookmarksScreenState extends State<BookmarksScreen> {),const SizedBox(height: 12),- // Content- if (_allBookmarks.isEmpty)- Expanded(- child: Center(- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Icon(Icons.bookmark_border_rounded, size: 48, color: cs.onSurfaceVariant.withValues(alpha: 0.4)),- const SizedBox(height: 12),- Text(l.bookmarksNoBookmarks, style: tt.bodyLarge?.copyWith(color: cs.onSurfaceVariant)),- ],- ),- ),- )- else- Expanded(- child: ListView.builder(- padding: const EdgeInsets.fromLTRB(16, 0, 16, 24),- itemCount: _allBookmarks.length,- itemBuilder: (ctx, i) {- final lib = context.read<LibraryProvider>();- final itemId = _allBookmarks.keys.elementAt(i);- final bookmarks = _allBookmarks[itemId]!;- final resolvedTitle = _resolveTitle(itemId);- final coverUrl = lib.getCoverUrl(itemId, width: 400);- return _BookGroup(- itemId: itemId,- title: resolvedTitle,- coverUrl: coverUrl,- mediaHeaders: lib.mediaHeaders,- bookmarks: bookmarks,- displaySpeed: _displaySpeedFor(itemId),- cs: cs,- tt: tt,- selecting: _selecting,- selected: _selected,- onToggle: _toggleSelect,- onToggleGroup: () => _toggleBookGroup(itemId, bookmarks),- onLongPress: _enterSelection,- onJump: (id, bm) =>- _jumpToBookmark(id, bm, resolvedTitle ?? ''),- );- },- ),+ // Audiobook bookmarks and ebook highlights, tabbed only once+ // there's at least one highlight to show.+ if (_highlights.isNotEmpty)+ TabBar(+ controller: _tabs,+ tabs: [+ Tab(text: l.bookmarksTabBookmarks),+ Tab(text: l.bookmarksTabHighlights),+ ],+ labelColor: cs.primary,+ unselectedLabelColor: cs.onSurfaceVariant,+ indicatorColor: cs.primary,+ dividerColor: Colors.transparent,),+ if (_highlights.isNotEmpty) const SizedBox(height: 8),++ Expanded(+ child: _highlights.isEmpty+ ? _buildBookmarksTab(cs, tt, l)+ : TabBarView(+ controller: _tabs,+ children: [+ _buildBookmarksTab(cs, tt, l),+ _buildHighlightsTab(cs, tt, l),+ ],+ ),+ ),// Bottom delete bar- if (_selecting && _selected.isNotEmpty)+ if (_selecting &&+ (_tabIndex == 0+ ? _selected.isNotEmpty+ : _selectedHighlights.isNotEmpty))Container(padding: const EdgeInsets.fromLTRB(20, 12, 20, 12),decoration: BoxDecoration(@@ -493,7 +832,9 @@ class _BookmarksScreenState extends State<BookmarksScreen> {top: false,child: Row(children: [Text(- l.bookmarksSelectedCount(_selected.length),+ l.bookmarksSelectedCount(_tabIndex == 0+ ? _selected.length+ : _selectedHighlights.length),style: tt.bodyMedium?.copyWith(color: cs.onSurface),),const Spacer(),@@ -504,7 +845,9 @@ class _BookmarksScreenState extends State<BookmarksScreen> {backgroundColor: cs.errorContainer,foregroundColor: cs.onErrorContainer,),- onPressed: _deleteSelected,+ onPressed: _tabIndex == 0+ ? _deleteSelected+ : _deleteSelectedHighlights,),]),),@@ -580,14 +923,7 @@ class _BookGroup extends StatelessWidget {color: allSelected ? cs.primary : cs.onSurfaceVariant.withValues(alpha: 0.5),),),- ClipRRect(- borderRadius: BorderRadius.circular(6),- child: SizedBox(- width: 40,- height: 40,- child: _buildCover(),- ),- ),+ _BookCover(coverUrl: coverUrl, mediaHeaders: mediaHeaders, cs: cs),const SizedBox(width: 12),Expanded(child: title == null@@ -636,32 +972,55 @@ class _BookGroup extends StatelessWidget {);}- Widget _buildCover() {- if (coverUrl == null || coverUrl!.isEmpty) return _coverPlaceholder();+}++class _BookCover extends StatelessWidget {+ final String? coverUrl;+ final Map<String, String> mediaHeaders;+ final ColorScheme cs;+ final IconData placeholderIcon;++ const _BookCover({+ required this.coverUrl,+ required this.mediaHeaders,+ required this.cs,+ this.placeholderIcon = Icons.headphones_rounded,+ });++ @override+ Widget build(BuildContext context) {+ return ClipRRect(+ borderRadius: BorderRadius.circular(6),+ child: SizedBox(width: 40, height: 40, child: _image()),+ );+ }++ Widget _image() {+ if (coverUrl == null || coverUrl!.isEmpty) return _placeholder();if (coverUrl!.startsWith('/')) {final file = File(coverUrl!);if (file.existsSync()) {return Image.file(file, fit: BoxFit.cover,- errorBuilder: (_, __, ___) => _coverPlaceholder());+ errorBuilder: (_, __, ___) => _placeholder());}- return _coverPlaceholder();+ return _placeholder();}return CachedNetworkImage(imageUrl: coverUrl!,fit: BoxFit.cover,httpHeaders: mediaHeaders,- placeholder: (_, __) => _coverPlaceholder(),- errorWidget: (_, __, ___) => _coverPlaceholder(),+ placeholder: (_, __) => _placeholder(),+ errorWidget: (_, __, ___) => _placeholder(),);}- Widget _coverPlaceholder() {+ Widget _placeholder() {return Container(color: cs.surfaceContainerHighest,child: Center(- child: Icon(Icons.headphones_rounded, size: 20,+ child: Icon(placeholderIcon, size: 20,color: cs.onSurfaceVariant.withValues(alpha: 0.4)),),);@@ -752,3 +1111,225 @@ class _BookmarkRow extends StatelessWidget {);}}++class _HighlightGroup extends StatelessWidget {+ final String itemId;+ final String? title;+ final String? coverUrl;+ final Map<String, String> mediaHeaders;+ final List<EbookAnnotation> highlights;+ final ColorScheme cs;+ final TextTheme tt;+ final bool selecting;+ final Set<String> selected;+ final void Function(String itemId, EbookAnnotation highlight) onActions;+ final void Function(String itemId, String annotationId) onToggle;+ final VoidCallback onToggleGroup;+ final void Function(String itemId, String annotationId) onLongPress;++ const _HighlightGroup({+ required this.itemId,+ required this.title,+ this.coverUrl,+ this.mediaHeaders = const {},+ required this.highlights,+ required this.cs,+ required this.tt,+ required this.selecting,+ required this.selected,+ required this.onActions,+ required this.onToggle,+ required this.onToggleGroup,+ required this.onLongPress,+ });++ String _selKey(String id) => '$itemId::$id';++ @override+ Widget build(BuildContext context) {+ final groupKeys = highlights.map((h) => _selKey(h.id)).toSet();+ final allSelected = selecting && groupKeys.every(selected.contains);++ return Padding(+ padding: const EdgeInsets.only(bottom: 12),+ child: Card(+ elevation: 0,+ color: cs.surfaceContainerHigh,+ shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),+ child: Padding(+ padding: const EdgeInsets.all(14),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ GestureDetector(+ onTap: selecting ? onToggleGroup : null,+ child: Row(children: [+ if (selecting)+ Padding(+ padding: const EdgeInsets.only(right: 10),+ child: Icon(+ allSelected+ ? Icons.check_circle_rounded+ : Icons.circle_outlined,+ size: 22,+ color: allSelected+ ? cs.primary+ : cs.onSurfaceVariant.withValues(alpha: 0.5),+ ),+ ),+ _BookCover(+ coverUrl: coverUrl,+ mediaHeaders: mediaHeaders,+ cs: cs,+ placeholderIcon: Icons.menu_book_rounded,+ ),+ const SizedBox(width: 12),+ Expanded(+ child: title == null+ ? Container(+ height: 14,+ decoration: BoxDecoration(+ color: cs.onSurface.withValues(alpha: 0.06),+ borderRadius: BorderRadius.circular(4),+ ),+ )+ : Text(+ title!,+ style: tt.titleSmall?.copyWith(fontWeight: FontWeight.w600),+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ ),+ ),+ Text(+ '${highlights.length}',+ style: tt.labelSmall?.copyWith(color: cs.onSurfaceVariant),+ ),+ ]),+ ),+ const SizedBox(height: 8),+ for (var j = 0; j < highlights.length; j++) ...[+ if (j > 0)+ Divider(height: 1, indent: 14, color: cs.outlineVariant.withValues(alpha: 0.3)),+ _HighlightRow(+ itemId: itemId,+ highlight: highlights[j],+ cs: cs,+ tt: tt,+ selecting: selecting,+ isSelected: selected.contains(_selKey(highlights[j].id)),+ onActions: onActions,+ onToggle: onToggle,+ onLongPress: onLongPress,+ ),+ ],+ ],+ ),+ ),+ ),+ );+ }+}++class _HighlightRow extends StatelessWidget {+ final String itemId;+ final EbookAnnotation highlight;+ final ColorScheme cs;+ final TextTheme tt;+ final bool selecting;+ final bool isSelected;+ final void Function(String itemId, EbookAnnotation highlight) onActions;+ final void Function(String itemId, String annotationId) onToggle;+ final void Function(String itemId, String annotationId) onLongPress;++ const _HighlightRow({+ required this.itemId,+ required this.highlight,+ required this.cs,+ required this.tt,+ required this.selecting,+ required this.isSelected,+ required this.onActions,+ required this.onToggle,+ required this.onLongPress,+ });++ @override+ Widget build(BuildContext context) {+ final l = AppLocalizations.of(context)!;+ final hex = (highlight.color ?? HighlightColor.yellow).hex;+ final barColor = Color(int.parse('FF${hex.substring(1)}', radix: 16));+ final created = highlight.createdAt;+ final date = l.backupDateFormat(created.month, created.day, created.year);+ final chapter = highlight.chapter;+ final meta = chapter != null && chapter.isNotEmpty+ ? l.highlightsMeta(chapter, date)+ : date;++ return GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: selecting+ ? () => onToggle(itemId, highlight.id)+ : () => onActions(itemId, highlight),+ onLongPress: selecting ? null : () => onLongPress(itemId, highlight.id),+ child: Padding(+ padding: const EdgeInsets.symmetric(vertical: 10),+ child: Row(children: [+ if (selecting)+ Padding(+ padding: const EdgeInsets.only(right: 10),+ child: Icon(+ isSelected ? Icons.check_circle_rounded : Icons.circle_outlined,+ size: 20,+ color: isSelected+ ? cs.primary+ : cs.onSurfaceVariant.withValues(alpha: 0.4),+ ),+ ),+ Expanded(+ child: Container(+ padding: const EdgeInsets.only(left: 10),+ decoration: BoxDecoration(+ border: Border(left: BorderSide(color: barColor, width: 3)),+ ),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ highlight.selectedText ?? '',+ style: tt.bodyMedium,+ maxLines: 4,+ overflow: TextOverflow.ellipsis,+ ),+ if (highlight.note != null && highlight.note!.isNotEmpty)+ Padding(+ padding: const EdgeInsets.only(top: 4),+ child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [+ Icon(Icons.sticky_note_2_outlined, size: 14,+ color: cs.onSurfaceVariant.withValues(alpha: 0.7)),+ const SizedBox(width: 4),+ Expanded(+ child: Text(+ highlight.note!,+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant),+ maxLines: 2,+ overflow: TextOverflow.ellipsis,+ ),+ ),+ ]),+ ),+ const SizedBox(height: 4),+ Text(+ meta,+ style: tt.labelSmall?.copyWith(color: cs.onSurfaceVariant),+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ ),+ ],+ ),+ ),+ ),+ ]),+ ),+ );+ }+}diff --git a/lib/services/ebook_annotation_service.dart b/lib/services/ebook_annotation_service.dartindex 4e7a61bd..6650f92b 100644--- a/lib/services/ebook_annotation_service.dart+++ b/lib/services/ebook_annotation_service.dart@@ -26,6 +26,10 @@ class EbookAnnotation {final String? selectedText;final HighlightColor? color;String? note;+ /// Chapter title captured when the annotation was made. Older annotations+ /// predate this and stay null - the CFI alone can't name a chapter without+ /// reopening the book.+ final String? chapter;final DateTime createdAt;EbookAnnotation({@@ -35,6 +39,7 @@ class EbookAnnotation {this.selectedText,this.color,this.note,+ this.chapter,DateTime? createdAt,}) : createdAt = createdAt ?? DateTime.now();@@ -45,6 +50,7 @@ class EbookAnnotation {if (selectedText != null) 'text': selectedText,if (color != null) 'color': color!.name,if (note != null && note!.isNotEmpty) 'note': note,+ if (chapter != null && chapter!.isNotEmpty) 'ch': chapter,'ts': createdAt.millisecondsSinceEpoch,};@@ -58,11 +64,29 @@ class EbookAnnotation {? HighlightColor.values.byName(json['color'] as String): null,note: json['note'] as String?,+ chapter: json['ch'] as String?,createdAt: DateTime.fromMillisecondsSinceEpoch(json['ts'] as int),);}}+/// A highlight's CFI collapsed to the point where it starts.+///+/// Highlights are saved as range CFIs (`epubcfi(base,start,end)`) because+/// that's what a text selection produces. epub.js resolves a range to its+/// bounding rect, and at load time - before the section has laid out - that+/// rect is empty, so `display()` scrolls nowhere and the reader stays on+/// whatever page it was already showing. The start point alone always+/// resolves. Non-range CFIs come back untouched.+String pointCfi(String cfi) {+ final open = cfi.indexOf('(');+ final close = cfi.lastIndexOf(')');+ if (open == -1 || close <= open) return cfi;+ final parts = cfi.substring(open + 1, close).split(',');+ if (parts.length < 2) return cfi;+ return 'epubcfi(${parts[0]}${parts[1]})';+}+/// Stores per-book ebook annotations in SharedPreferences.class EbookAnnotationService {static final EbookAnnotationService _instance = EbookAnnotationService._();@@ -71,6 +95,14 @@ class EbookAnnotationService {static const _keyPrefix = 'ebook_annotations_';+ // Two annotations made in the same millisecond used to share an id, which+ // made them one row to anything that works by id - selecting, deleting,+ // noting. The counter keeps them apart.+ int _idSeq = 0;++ String _newId() =>+ '${DateTime.now().millisecondsSinceEpoch}-${_idSeq++}';+String _key(String itemId) => '$_keyPrefix$itemId';/// Get all annotations for a book.@@ -101,6 +133,21 @@ class EbookAnnotationService {return all.where((a) => a.type == AnnotationType.bookmark).toList();}+ /// Every highlight on the device, keyed by item ID. Books are ordered by+ /// their newest highlight and each book's list stays newest first.+ Future<Map<String, List<EbookAnnotation>>> getAllHighlights() async {+ final itemIds = await ScopedPrefs.suffixesWithPrefix(_keyPrefix);+ final byItem = <String, List<EbookAnnotation>>{};+ for (final itemId in itemIds) {+ if (itemId.isEmpty) continue;+ final highlights = await getHighlights(itemId);+ if (highlights.isNotEmpty) byItem[itemId] = highlights;+ }+ final ordered = byItem.entries.toList()+ ..sort((a, b) => b.value.first.createdAt.compareTo(a.value.first.createdAt));+ return {for (final e in ordered) e.key: e.value};+ }+Future<void> _save(String itemId, List<EbookAnnotation> annotations) async {final json = jsonEncode(annotations.map((a) => a.toJson()).toList());await ScopedPrefs.setString(_key(itemId), json);@@ -118,14 +165,16 @@ class EbookAnnotationService {required String selectedText,HighlightColor color = HighlightColor.yellow,String? note,+ String? chapter,}) async {final annotation = EbookAnnotation(- id: '${DateTime.now().millisecondsSinceEpoch}',+ id: _newId(),type: AnnotationType.highlight,cfi: cfi,selectedText: selectedText,color: color,note: note,+ chapter: chapter,);final annotations = await getAnnotations(itemId);annotations.insert(0, annotation);@@ -139,12 +188,14 @@ class EbookAnnotationService {required String itemId,required String cfi,String? note,+ String? chapter,}) async {final annotation = EbookAnnotation(- id: '${DateTime.now().millisecondsSinceEpoch}',+ id: _newId(),type: AnnotationType.bookmark,cfi: cfi,note: note,+ chapter: chapter,);final annotations = await getAnnotations(itemId);annotations.insert(0, annotation);diff --git a/lib/services/scoped_prefs.dart b/lib/services/scoped_prefs.dartindex b83e0801..99ed7d04 100644--- a/lib/services/scoped_prefs.dart+++ b/lib/services/scoped_prefs.dart@@ -169,6 +169,23 @@ class ScopedPrefs {// ── Convenience ──+ /// The item-keyed tails of every stored key starting with [prefix], for+ /// prefix-keyed stores like `ebook_annotations_<itemId>` that have no index+ /// of their own.+ static Future<List<String>> suffixesWithPrefix(String prefix) async {+ final prefs = await SharedPreferences.getInstance();+ final scoped = _scope(prefix);+ final out = <String>{};+ for (final key in prefs.getKeys()) {+ if (key.startsWith(scoped)) {+ out.add(key.substring(scoped.length));+ } else if (_shouldFallback && key.startsWith(prefix)) {+ out.add(key.substring(prefix.length));+ }+ }+ return out.toList();+ }+static Future<bool> containsKey(String key) async {final prefs = await SharedPreferences.getInstance();if (prefs.containsKey(_scope(key))) return true;diff --git a/lib/widgets/ebook_reader_view.dart b/lib/widgets/ebook_reader_view.dartindex 2eacf3f1..a623fb71 100644--- a/lib/widgets/ebook_reader_view.dart+++ b/lib/widgets/ebook_reader_view.dart@@ -17,6 +17,7 @@ import '../services/reader_font_service.dart';import '../services/scoped_prefs.dart';import '../services/volume_key_service.dart';import 'overlay_toast.dart';+import 'quote_share_sheet.dart';import 'card_buttons.dart' show CardSpeedSheet;/// Reader background/text presets (e-reader themes). Colors are hex so they@@ -43,12 +44,16 @@ class EbookReaderView extends StatefulWidget {final String itemId;final String title;final Map<String, dynamic> ebookFile;+ /// Opens here instead of the saved reading position, for jumping straight+ /// to a highlight from outside the reader.+ final String? openAtCfi;const EbookReaderView({super.key,required this.itemId,required this.title,required this.ebookFile,+ this.openAtCfi,});@override@@ -112,6 +117,10 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObs// per mount, or it re-triggers itself into an endless display->displayed loop// that freezes page-turn taps. Reset whenever the viewer remounts.bool _didLoadRescue = false;+ // Where an outside jump (a highlight from the list) asked to land, re-applied+ // once after the first paint - epub.js repaginates right after load and can+ // round the target away.+ String? _settleJumpCfi;// Same event, same reason: the handler/highlight/font wiring must run once// per mount, not on every chapter crossing - unguarded it stacked a new JS// relocated-listener, re-registered every highlight and re-shipped the@@ -576,9 +585,17 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObsvoid _loadInitialLocation() {final lib = context.read<LibraryProvider>();+ // A highlight jump wins over the saved reading position; the percent below+ // still comes from saved progress so the bar isn't at 0 until epub.js has+ // indexed locations.+ final target = widget.openAtCfi;+ if (target != null && target.isNotEmpty) {+ _initialCfi = pointCfi(target);+ _settleJumpCfi = _initialCfi;+ }final progressData = lib.getProgressData(widget.itemId);final loc = progressData?['ebookLocation'] as String?;- if (loc != null && loc.isNotEmpty) {+ if (_initialCfi == null && loc != null && loc.isNotEmpty) {_initialCfi = loc;}// Seed the displayed percent from saved progress so the bar shows the@@ -699,6 +716,7 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObscfi: _selectionCfi!,selectedText: _selectionText!,color: color,+ chapter: _currentChapterTitle,);_epubController?.addHighlight(cfi: annotation.cfi,@@ -709,6 +727,23 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObsif (mounted) _dismissSelection();}+ /// [onThisPage] is for a highlight tapped in the book: the reader is sitting+ /// in its chapter, so an older highlight with no recorded chapter can borrow+ /// the current one. From the list it would be a guess, so it stays blank.+ Future<void> _shareHighlight(EbookAnnotation annotation,+ {bool onThisPage = false}) async {+ final text = annotation.selectedText ?? '';+ if (text.isEmpty) return;+ await showQuoteShareSheet(+ context,+ itemId: widget.itemId,+ quote: text,+ bookTitle: widget.title,+ author: _audioAuthor.isEmpty ? null : _audioAuthor,+ chapter: annotation.chapter ?? (onThisPage ? _currentChapterTitle : null),+ );+ }+Future<void> _removeHighlight(EbookAnnotation annotation) async {_epubController?.removeHighlight(cfi: annotation.cfi);await _annotationService.delete(@@ -739,6 +774,7 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObsfinal annotation = await _annotationService.addBookmark(itemId: widget.itemId,cfi: cfi,+ chapter: _currentChapterTitle,);_annotations.insert(0, annotation);}@@ -809,7 +845,18 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObsfinal result = await showDialog<String>(context: context,builder: (ctx) => AlertDialog(- title: Text(l.readerNoteTitle),+ title: Row(children: [+ Expanded(child: Text(l.readerNoteTitle)),+ if ((annotation.selectedText ?? '').isNotEmpty)+ IconButton(+ icon: const Icon(Icons.ios_share_rounded),+ tooltip: l.quoteShareTitle,+ onPressed: () {+ Navigator.pop(ctx);+ _shareHighlight(annotation, onThisPage: true);+ },+ ),+ ]),content: TextField(controller: controller,maxLines: 5,@@ -1631,10 +1678,19 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObs? Text(h.note!, maxLines: 1, overflow: TextOverflow.ellipsis,style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)): null,+ trailing: IconButton(+ icon: const Icon(Icons.ios_share_rounded, size: 18),+ tooltip: AppLocalizations.of(ctx)!.quoteShareTitle,+ color: cs.onSurfaceVariant,+ onPressed: () {+ Navigator.pop(ctx);+ _shareHighlight(h);+ },+ ),dense: true,onTap: () {Navigator.pop(ctx);- _epubController?.display(cfi: h.cfi);+ _epubController?.display(cfi: pointCfi(h.cfi));},onLongPress: () => _addNoteToAnnotation(h),),@@ -1682,7 +1738,7 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObsdense: true,onTap: () {Navigator.pop(ctx);- _epubController?.display(cfi: bm.cfi);+ _epubController?.display(cfi: pointCfi(bm.cfi));},onLongPress: () => _addNoteToAnnotation(bm),),@@ -1961,6 +2017,15 @@ class EbookReaderViewState extends State<EbookReaderView> with WidgetsBindingObsif (once != null && once.isNotEmpty) {_initialCfi = null;_epubController?.display(cfi: once);+ // Safe to re-display: _didLoadRescue is already set, so the+ // "displayed" event this fires can't loop back in here.+ final settle = _settleJumpCfi;+ if (settle != null) {+ _settleJumpCfi = null;+ Future.delayed(const Duration(milliseconds: 700), () {+ if (mounted) _epubController?.display(cfi: settle);+ });+ }} else {// First open (no saved position) - the same blank-first-paint// can happen here, but display(cfi:) needs a target, so forcediff --git a/lib/widgets/ebook_router.dart b/lib/widgets/ebook_router.dartindex ad8eaad4..95da86ba 100644--- a/lib/widgets/ebook_router.dart+++ b/lib/widgets/ebook_router.dart@@ -19,17 +19,20 @@ bool canReadEbook(Map<String, dynamic>? ebookFile) =>ebookFile != null && readableEbookFormats.contains(ebookExt(ebookFile));/// Routes an ebook to the right reader for its format, or toasts when the-/// format isn't supported in-app.-void openEbookReader(+/// format isn't supported in-app. [openAtCfi] jumps an EPUB straight to a+/// saved location (a highlight) instead of resuming where reading left off.+Future<void> openEbookReader(BuildContext context, {required String itemId,required String title,required Map<String, dynamic> ebookFile,-}) {+ String? openAtCfi,+}) async {final ext = ebookExt(ebookFile);final Widget viewer;if (ext == 'epub') {- viewer = EbookReaderView(itemId: itemId, title: title, ebookFile: ebookFile);+ viewer = EbookReaderView(+ itemId: itemId, title: title, ebookFile: ebookFile, openAtCfi: openAtCfi);} else if (ext == 'pdf') {viewer = PdfReaderView(itemId: itemId, title: title, ebookFile: ebookFile);} else if (foliateEbookFormats.contains(ext)) {@@ -39,7 +42,7 @@ void openEbookReader(icon: Icons.menu_book_outlined);return;}- Navigator.of(context, rootNavigator: true).push(+ await Navigator.of(context, rootNavigator: true).push(MaterialPageRoute(builder: (_) => viewer),);}diff --git a/lib/widgets/quote_share_sheet.dart b/lib/widgets/quote_share_sheet.dartnew file mode 100644index 00000000..bc705c18--- /dev/null+++ b/lib/widgets/quote_share_sheet.dart@@ -0,0 +1,543 @@+import 'dart:io';+import 'dart:math' show min;+import 'dart:ui' as ui;++import 'package:cached_network_image/cached_network_image.dart';+import 'package:flutter/material.dart';+import 'package:flutter/rendering.dart';+import 'package:flutter/services.dart';+import 'package:path_provider/path_provider.dart';+import 'package:provider/provider.dart';+import 'package:share_plus/share_plus.dart';++import '../l10n/app_localizations.dart';+import '../providers/library_provider.dart';+import 'adaptive_modal.dart';+import 'overlay_toast.dart';++/// Card shapes offered for a shared quote, as width/height.+enum _QuoteShape {+ portrait(4 / 5),+ square(1),+ story(9 / 16);++ final double ratio;+ const _QuoteShape(this.ratio);+}++/// What sits between the cover and the text.+enum _QuoteBackdrop { blur, dim, none }++/// Which way the text (and the veil under it) leans, so the quote stays+/// readable on both pale and dark covers.+enum _QuoteTone { light, dark }++/// Opens the share sheet for a quote: the text laid over the book's cover,+/// exported as a PNG through the system share sheet.+Future<void> showQuoteShareSheet(+ BuildContext context, {+ required String itemId,+ required String quote,+ String? bookTitle,+ String? author,+ String? chapter,+}) {+ final text = quote.trim();+ if (text.isEmpty) return Future.value();+ final lib = context.read<LibraryProvider>();+ final coverUrl = lib.getCoverUrl(itemId, width: 800);+ final headers = lib.mediaHeaders;+ return showAdaptiveActionMenu<void>(+ context: context,+ isScrollControlled: true,+ // The sheet scrolls itself, so the desktop surface must not wrap it in a+ // second scroll view - the preview would land in unbounded height.+ desktopScrollWrap: false,+ useSafeArea: true,+ showDragHandle: true,+ backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,+ shape: const RoundedRectangleBorder(+ borderRadius: BorderRadius.vertical(top: Radius.circular(24)),+ ),+ builder: (ctx) => _QuoteShareSheet(+ quote: text,+ coverUrl: coverUrl,+ mediaHeaders: headers,+ bookTitle: bookTitle,+ author: author,+ chapter: chapter,+ ),+ );+}++class _QuoteShareSheet extends StatefulWidget {+ final String quote;+ final String? coverUrl;+ final Map<String, String> mediaHeaders;+ final String? bookTitle;+ final String? author;+ final String? chapter;++ const _QuoteShareSheet({+ required this.quote,+ required this.coverUrl,+ required this.mediaHeaders,+ this.bookTitle,+ this.author,+ this.chapter,+ });++ @override+ State<_QuoteShareSheet> createState() => _QuoteShareSheetState();+}++class _QuoteShareSheetState extends State<_QuoteShareSheet> {+ final _cardKey = GlobalKey();+ late final TextEditingController _titleController;+ late final TextEditingController _detailController;+ _QuoteShape _shape = _QuoteShape.portrait;+ _QuoteBackdrop _backdrop = _QuoteBackdrop.blur;+ _QuoteTone _tone = _QuoteTone.light;+ bool _busy = false;+ ImageProvider? _cover;+ // The export captures whatever the preview is showing, so hold the share+ // action until the cover has actually decoded.+ bool _coverSettled = false;++ @override+ void initState() {+ super.initState();+ _titleController = TextEditingController(text: widget.bookTitle ?? '');+ // Seeded with what we know, then it's the user's line: a chapter, a page,+ // whoever said it.+ _detailController = TextEditingController(+ text: [+ if ((widget.author ?? '').isNotEmpty) widget.author!,+ if ((widget.chapter ?? '').isNotEmpty) widget.chapter!,+ ].join(', '),+ );+ _prepareCover();+ }++ @override+ void dispose() {+ _titleController.dispose();+ _detailController.dispose();+ super.dispose();+ }++ Future<void> _prepareCover() async {+ final url = widget.coverUrl;+ if (url == null || url.isEmpty) {+ setState(() => _coverSettled = true);+ return;+ }+ ImageProvider? provider;+ if (url.startsWith('/')) {+ final file = File(url);+ if (file.existsSync()) provider = FileImage(file);+ } else {+ provider = CachedNetworkImageProvider(url, headers: widget.mediaHeaders);+ }+ if (provider == null) {+ setState(() => _coverSettled = true);+ return;+ }+ setState(() => _cover = provider);+ try {+ // Keep the provider even if this fails: the Image below falls back to the+ // plain background on its own, and dropping the cover here would lose it+ // over one bad request. The timeout is so a cover that never answers+ // can't leave Share disabled forever.+ await precacheImage(provider, context)+ .timeout(const Duration(seconds: 8));+ } catch (e) {+ debugPrint('[QuoteShare] Cover not ready: $e');+ }+ if (mounted) setState(() => _coverSettled = true);+ }++ Future<void> _share() async {+ final l = AppLocalizations.of(context)!;+ FocusScope.of(context).unfocus();+ setState(() => _busy = true);+ try {+ final boundary =+ _cardKey.currentContext?.findRenderObject() as RenderRepaintBoundary?;+ if (boundary == null) throw StateError('no card to capture');+ // Export at a fixed width so the picture looks the same off any phone.+ final pixelRatio = (1080 / boundary.size.width).clamp(1.0, 4.0);+ final image = await boundary.toImage(pixelRatio: pixelRatio);+ final data = await image.toByteData(format: ui.ImageByteFormat.png);+ image.dispose();+ if (data == null) throw StateError('no png bytes');++ final dir = await getTemporaryDirectory();+ final safe = (widget.bookTitle ?? 'quote')+ .replaceAll(RegExp('[<>:"/|?*]'), '_')+ .replaceAll(r'\', '_')+ .trim();+ final file =+ File('${dir.path}/${safe.isEmpty ? 'quote' : safe}_quote.png');+ await file.writeAsBytes(data.buffer.asUint8List(), flush: true);++ if (!mounted) return;+ final box = context.findRenderObject() as RenderBox?;+ final origin =+ box != null ? box.localToGlobal(Offset.zero) & box.size : null;+ await Share.shareXFiles(+ [XFile(file.path, mimeType: 'image/png')],+ sharePositionOrigin: origin,+ );+ } catch (e) {+ debugPrint('[QuoteShare] Failed: $e');+ if (mounted) {+ showOverlayToast(context, l.quoteShareFailed,+ icon: Icons.error_outline_rounded);+ }+ } finally {+ if (mounted) setState(() => _busy = false);+ }+ }++ Future<void> _copy() async {+ final l = AppLocalizations.of(context)!;+ await Clipboard.setData(ClipboardData(text: widget.quote));+ if (mounted) {+ showOverlayToast(context, l.readerCopied, icon: Icons.copy_rounded);+ }+ }++ @override+ Widget build(BuildContext context) {+ final cs = Theme.of(context).colorScheme;+ final tt = Theme.of(context).textTheme;+ final l = AppLocalizations.of(context)!;+ final media = MediaQuery.of(context);++ final maxWidth = min(media.size.width, 520.0) - 40;+ // The whole sheet - preview, chips, both fields, buttons - has to fit above+ // a keyboard or a button-nav bar without scrolling on a normal phone.+ final maxHeight =+ media.size.height * (media.viewInsets.bottom > 0 ? 0.26 : 0.36);+ var cardWidth = maxWidth;+ var cardHeight = cardWidth / _shape.ratio;+ if (cardHeight > maxHeight) {+ cardHeight = maxHeight;+ cardWidth = cardHeight * _shape.ratio;+ }++ return Padding(+ padding: EdgeInsets.only(bottom: media.viewInsets.bottom),+ child: SafeArea(+ top: false,+ child: SingleChildScrollView(+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 14),+ child: Column(mainAxisSize: MainAxisSize.min, children: [+ Align(+ alignment: Alignment.centerLeft,+ child: Text(l.quoteShareTitle,+ style: tt.titleMedium?.copyWith(fontWeight: FontWeight.w600)),+ ),+ const SizedBox(height: 12),+ Center(+ child: SizedBox(+ width: cardWidth,+ height: cardHeight,+ child: RepaintBoundary(+ key: _cardKey,+ // The system font scale must not reach the exported picture,+ // or the same quote comes out cropped on one phone and roomy+ // on another.+ child: MediaQuery(+ data: media.copyWith(textScaler: TextScaler.noScaling),+ child: _QuoteCard(+ quote: widget.quote,+ cover: _cover,+ backdrop: _backdrop,+ tone: _tone,+ title: _titleController.text.trim(),+ detail: _detailController.text.trim(),+ ),+ ),+ ),+ ),+ ),+ const SizedBox(height: 12),+ Wrap(+ spacing: 6,+ runSpacing: 6,+ alignment: WrapAlignment.center,+ children: [+ _chip(cs, l.quoteShapePortrait, _shape == _QuoteShape.portrait,+ () => setState(() => _shape = _QuoteShape.portrait)),+ _chip(cs, l.quoteShapeSquare, _shape == _QuoteShape.square,+ () => setState(() => _shape = _QuoteShape.square)),+ _chip(cs, l.quoteShapeStory, _shape == _QuoteShape.story,+ () => setState(() => _shape = _QuoteShape.story)),+ _chip(cs, l.quoteStyleBlur, _backdrop == _QuoteBackdrop.blur,+ () => setState(() => _backdrop = _QuoteBackdrop.blur)),+ _chip(cs, l.quoteStyleDim, _backdrop == _QuoteBackdrop.dim,+ () => setState(() => _backdrop = _QuoteBackdrop.dim)),+ _chip(cs, l.quoteStyleNone, _backdrop == _QuoteBackdrop.none,+ () => setState(() => _backdrop = _QuoteBackdrop.none)),+ _chip(cs, l.quoteTextLight, _tone == _QuoteTone.light,+ () => setState(() => _tone = _QuoteTone.light)),+ _chip(cs, l.quoteTextDark, _tone == _QuoteTone.dark,+ () => setState(() => _tone = _QuoteTone.dark)),+ ],+ ),+ const SizedBox(height: 12),+ TextField(+ controller: _titleController,+ textCapitalization: TextCapitalization.sentences,+ keyboardType: TextInputType.multiline,+ minLines: 1,+ maxLines: 3,+ decoration: InputDecoration(+ labelText: l.quoteFieldTitle,+ isDense: true,+ border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),+ ),+ onChanged: (_) => setState(() {}),+ ),+ const SizedBox(height: 8),+ TextField(+ controller: _detailController,+ textCapitalization: TextCapitalization.sentences,+ keyboardType: TextInputType.multiline,+ minLines: 1,+ maxLines: 4,+ decoration: InputDecoration(+ labelText: l.quoteFieldDetail,+ hintText: l.quoteFieldDetailHint,+ isDense: true,+ border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)),+ ),+ onChanged: (_) => setState(() {}),+ ),+ const SizedBox(height: 12),+ Row(children: [+ Expanded(+ child: OutlinedButton.icon(+ icon: const Icon(Icons.copy_rounded, size: 18),+ label: Text(l.readerTooltipCopy),+ onPressed: _busy ? null : _copy,+ ),+ ),+ const SizedBox(width: 10),+ Expanded(+ child: FilledButton.icon(+ icon: _busy+ ? const SizedBox(+ width: 16,+ height: 16,+ child: CircularProgressIndicator(strokeWidth: 2))+ : const Icon(Icons.ios_share_rounded, size: 18),+ label: Text(l.quoteShareAction),+ onPressed: _busy || !_coverSettled ? null : _share,+ ),+ ),+ ]),+ ]),+ ),+ ),+ );+ }++ Widget _chip(ColorScheme cs, String label, bool selected, VoidCallback onTap) {+ return GestureDetector(+ onTap: onTap,+ child: Container(+ padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 8),+ decoration: BoxDecoration(+ color: selected+ ? cs.primary.withValues(alpha: 0.16)+ : cs.onSurface.withValues(alpha: 0.06),+ borderRadius: BorderRadius.circular(10),+ border: Border.all(+ color: selected+ ? cs.primary.withValues(alpha: 0.6)+ : Colors.transparent,+ ),+ ),+ child: Text(+ label,+ style: Theme.of(context).textTheme.labelMedium?.copyWith(+ color: selected ? cs.primary : cs.onSurfaceVariant,+ fontWeight: selected ? FontWeight.w600 : FontWeight.w500,+ ),+ ),+ ),+ );+ }+}++class _QuoteCard extends StatelessWidget {+ final String quote;+ final ImageProvider? cover;+ final _QuoteBackdrop backdrop;+ final _QuoteTone tone;+ final String title;+ final String detail;++ const _QuoteCard({+ required this.quote,+ required this.cover,+ required this.backdrop,+ required this.tone,+ required this.title,+ required this.detail,+ });++ bool get _light => tone == _QuoteTone.light;++ Color get _ink => _light ? Colors.white : const Color(0xFF17130F);++ /// Long passages step down through a few sizes so a whole page worth of text+ /// still lands inside the card instead of cutting off after a few lines.+ double _quoteSize(double cardWidth) {+ final base = cardWidth / 14;+ final len = quote.length;+ if (len <= 90) return base * 1.1;+ if (len <= 180) return base * 0.92;+ if (len <= 320) return base * 0.76;+ if (len <= 520) return base * 0.62;+ return base * 0.5;+ }++ /// Veil under the text, leaning away from the ink so a pale cover can carry+ /// dark text and a dark one can carry light text. Blur already softens the+ /// art, so it needs far less than a sharp cover does.+ double _veilOpacity() {+ switch (backdrop) {+ case _QuoteBackdrop.blur:+ return 0.2;+ case _QuoteBackdrop.dim:+ return 0.45;+ case _QuoteBackdrop.none:+ return 0;+ }+ }++ Widget _plainBackground() {+ return DecoratedBox(+ decoration: BoxDecoration(+ gradient: LinearGradient(+ begin: Alignment.topLeft,+ end: Alignment.bottomRight,+ colors: _light+ ? [const Color(0xFF2A2438), const Color(0xFF120F18)]+ : [const Color(0xFFF3ECE2), const Color(0xFFD9CFC2)],+ ),+ ),+ );+ }++ @override+ Widget build(BuildContext context) {+ return LayoutBuilder(builder: (context, constraints) {+ final w = constraints.maxWidth;+ final pad = w * 0.085;+ final shadow = [+ Shadow(+ color: (_light ? Colors.black : Colors.white).withValues(alpha: 0.55),+ blurRadius: w * 0.035,+ ),+ ];+ final veil = _veilOpacity();++ return ClipRRect(+ borderRadius: BorderRadius.circular(18),+ child: Stack(fit: StackFit.expand, children: [+ if (cover != null)+ backdrop == _QuoteBackdrop.blur+ // Scaled up a touch so the blur's soft edge stays outside the+ // card, and clamped so it doesn't bleed to transparent.+ ? Transform.scale(+ scale: 1.1,+ child: ImageFiltered(+ imageFilter: ui.ImageFilter.blur(+ sigmaX: w * 0.022,+ sigmaY: w * 0.022,+ tileMode: TileMode.clamp,+ ),+ child: Image(+ image: cover!,+ fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => _plainBackground(),+ ),+ ),+ )+ : Image(+ image: cover!,+ fit: BoxFit.cover,+ errorBuilder: (_, __, ___) => _plainBackground(),+ )+ else+ _plainBackground(),+ if (veil > 0)+ ColoredBox(+ color: (_light ? Colors.black : Colors.white)+ .withValues(alpha: veil),+ ),+ Padding(+ padding: EdgeInsets.all(pad),+ child: Center(+ child: SingleChildScrollView(+ physics: const NeverScrollableScrollPhysics(),+ child: Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ Text(+ '"$quote"',+ textAlign: TextAlign.center,+ style: TextStyle(+ fontFamily: 'serif',+ fontStyle: FontStyle.italic,+ color: _ink,+ fontSize: _quoteSize(w),+ height: 1.34,+ shadows: shadow,+ ),+ ),+ if (title.isNotEmpty || detail.isNotEmpty)+ SizedBox(height: w * 0.06),+ if (title.isNotEmpty)+ Text(+ '- $title',+ textAlign: TextAlign.center,+ maxLines: 3,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: _ink,+ fontSize: w * 0.05,+ fontWeight: FontWeight.w600,+ shadows: shadow,+ ),+ ),+ if (detail.isNotEmpty)+ Padding(+ padding: EdgeInsets.only(top: w * 0.012),+ child: Text(+ detail,+ textAlign: TextAlign.center,+ maxLines: 4,+ overflow: TextOverflow.ellipsis,+ style: TextStyle(+ color: _ink.withValues(alpha: 0.82),+ fontSize: w * 0.042,+ shadows: shadow,+ ),+ ),+ ),+ ],+ ),+ ),+ ),+ ),+ ]),+ );+ });+ }+}