Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save and edit notes in book detail #98

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 60 additions & 54 deletions assets/translations/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"share": "Teilen",
"suggest": "Vorschlagen"
},
"share-book": "Hi! Ich lese gerade {title} von {author} und finde es großartig!",
"book_detail": {
"label": "Labels",
"notes": "Notizen",
Expand All @@ -48,6 +47,11 @@
"restore_strategy": "Wiederherstellungsstrategie",
"title": "Bücherverwaltung"
},
"book_notes": {
"my_notes": "",
"my_thoughts": "",
"subtitle": "Write down your thoughts, feelings or some general remarks about {title}"
},
"cancel": "Zurück",
"change": "Ändern",
"change_password": "Passwort ändern",
Expand Down Expand Up @@ -85,59 +89,6 @@
"timeline": "Timeline",
"wishlist": "Wunschliste"
},
"stats": {
"books-and-pages": {
"title": "Bücher & Seiten",
"empty": "Es liegen keine Daten vor.",
"books": "Bücher",
"books-waiting": "{} Bücher warten",
"books-reading": "{} Bücher werden gelesen",
"books-read": "{} Bücher gelesen",
"pages": "Seiten",
"pages-waiting": "{} Seiten warten",
"pages-read": "{} Seiten gelesen"
},
"label": {
"title": "Labels",
"empty": "Es liegen keine Daten für Labels vor.",
"na": "NA"
},
"language": {
"title": "Sprachen",
"empty": "Es liegen keine Daten für Sprachen vor."
},
"reading-time": {
"title": "Lesezeit",
"empty": "Es liegen keine Daten vor.",
"fastest-book": "Schnellstes Buch",
"slowest-book": "Langsamstes Buch",
"days": "{} Tage"
},
"misc": {
"title": "Verschiedenes",
"empty": "Keine Daten verfügbar.",
"average-books": {
"description": "Bücher pro Monat"
},
"most-read-month": {
"description": "Bücher im {}"
}
},
"favorites": {
"title": "Favoriten",
"empty": "Keine Daten für Favoriten vorhanden.",
"favorite-author": "Liebingsautor",
"first-five-star-book": "Erstes 5-Sterne Buch"
},
"books-per-year": {
"title": "Bücher pro Jahr",
"empty": "Es liegen keine Daten vor."
},
"books-per-month": {
"title": "Bücher pro Monat",
"empty": "Es liegen keine Daten vor."
}
},
"no_thanks": "Nein danke",
"not_my_book": "Nicht mein Buch",
"password": "Passwort",
Expand Down Expand Up @@ -170,6 +121,7 @@
"reset": "Zurücksetzen",
"reset_password": "Password zurücksetzen",
"reset_password_text": "Wir versenden ein Email an deine registrierte Adresse, wo du weitere Instruktionen zum Zurücksetzen findest.",
"save": "",
"search": {
"empty": {
"action": "Online suchen",
Expand Down Expand Up @@ -229,8 +181,62 @@
},
"title": "Einstellungen"
},
"share-book": "Hi! Ich lese gerade {title} von {author} und finde es großartig!",
"sign_in": "Anmelden",
"sign_up_with_mail": "Anmelden mit Email",
"stats": {
"books-and-pages": {
"books": "Bücher",
"books-read": "{} Bücher gelesen",
"books-reading": "{} Bücher werden gelesen",
"books-waiting": "{} Bücher warten",
"empty": "Es liegen keine Daten vor.",
"pages": "Seiten",
"pages-read": "{} Seiten gelesen",
"pages-waiting": "{} Seiten warten",
"title": "Bücher & Seiten"
},
"books-per-month": {
"empty": "Es liegen keine Daten vor.",
"title": "Bücher pro Monat"
},
"books-per-year": {
"empty": "Es liegen keine Daten vor.",
"title": "Bücher pro Jahr"
},
"favorites": {
"empty": "Keine Daten für Favoriten vorhanden.",
"favorite-author": "Liebingsautor",
"first-five-star-book": "Erstes 5-Sterne Buch",
"title": "Favoriten"
},
"label": {
"empty": "Es liegen keine Daten für Labels vor.",
"na": "NA",
"title": "Labels"
},
"language": {
"empty": "Es liegen keine Daten für Sprachen vor.",
"title": "Sprachen"
},
"misc": {
"average-books": {
"description": "Bücher pro Monat"
},
"empty": "Keine Daten verfügbar.",
"most-read-month": {
"description": "Bücher im {}"
},
"title": "Verschiedenes"
},
"reading-time": {
"days": "{} Tage",
"empty": "Es liegen keine Daten vor.",
"fastest-book": "Schnellstes Buch",
"slowest-book": "Langsamstes Buch",
"title": "Lesezeit"
}
},
"stay_anonymous": "Anonym bleiben",
"tabs": {
"for_later": "Für später",
Expand Down
114 changes: 60 additions & 54 deletions assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"share": "Share",
"suggest": "Suggest"
},
"share-book": "Hey! I am currently reading {title} from {author} and I find it awesome!",
"book_detail": {
"label": "Label",
"notes": "Notes",
Expand All @@ -47,6 +46,11 @@
"restore_strategy": "Restore strategy",
"title": "Book management"
},
"book_notes": {
"my_notes": "My notes",
"my_thoughts": "My thoughts belong here...",
"subtitle": "Write down your thoughts, feelings or some general remarks about {title}"
},
"cancel": "Cancel",
"change": "Change",
"change_password": "Change password",
Expand Down Expand Up @@ -84,59 +88,6 @@
"timeline": "Timeline",
"wishlist": "Wishlist"
},
"stats": {
"books-and-pages": {
"title": "Books & Pages",
"empty": "No data available.",
"books": "Books",
"books-waiting": "{} books waiting",
"books-reading": "{} books reading",
"books-read": "{} books read",
"pages": "Pages",
"pages-waiting": "{} pages waiting",
"pages-read": "{} pages read"
},
"label": {
"title": "Labels",
"empty": "No data for label distribution."
},
"language": {
"title": "Languages",
"empty": "No data for language distribution.",
"na": "NA"
},
"reading-time": {
"title": "Reading time",
"empty": "No data available.",
"fastest-book": "Fastest book",
"slowest-book": "Slowest book",
"days": "{} days"
},
"misc": {
"title": "Misc",
"empty": "No data available.",
"average-books": {
"description": "Books per Month"
},
"most-read-month": {
"description": "Books in {}"
}
},
"favorites": {
"title": "Favorites",
"empty": "No data for favorites available.",
"favorite-author": "Favorite Author",
"first-five-star-book": "First 5-star rating"
},
"books-per-year": {
"title": "Books per year",
"empty": "No data available"
},
"books-per-month": {
"title": "Books per month",
"empty": "No data available"
}
},
"no_thanks": "No thanks",
"not_my_book": "Not my book",
"password": "Password",
Expand Down Expand Up @@ -169,6 +120,7 @@
"reset": "Reset",
"reset_password": "Reset Password",
"reset_password_text": "A link will be sent to your registered email address with instructions on how to reset your password.",
"save": "Save",
"search": {
"empty": {
"action": "Search online",
Expand Down Expand Up @@ -228,8 +180,62 @@
},
"title": "Settings"
},
"share-book": "Hey! I am currently reading {title} from {author} and I find it awesome!",
"sign_in": "Sign in",
"sign_up_with_mail": "Sign up with email",
"stats": {
"books-and-pages": {
"books": "Books",
"books-read": "{} books read",
"books-reading": "{} books reading",
"books-waiting": "{} books waiting",
"empty": "No data available.",
"pages": "Pages",
"pages-read": "{} pages read",
"pages-waiting": "{} pages waiting",
"title": "Books & Pages"
},
"books-per-month": {
"empty": "No data available",
"title": "Books per month"
},
"books-per-year": {
"empty": "No data available",
"title": "Books per year"
},
"favorites": {
"empty": "No data for favorites available.",
"favorite-author": "Favorite Author",
"first-five-star-book": "First 5-star rating",
"title": "Favorites"
},
"label": {
"empty": "No data for label distribution.",
"title": "Labels"
},
"language": {
"empty": "No data for language distribution.",
"na": "NA",
"title": "Languages"
},
"misc": {
"average-books": {
"description": "Books per Month"
},
"empty": "No data available.",
"most-read-month": {
"description": "Books in {}"
},
"title": "Misc"
},
"reading-time": {
"days": "{} days",
"empty": "No data available.",
"fastest-book": "Fastest book",
"slowest-book": "Slowest book",
"title": "Reading time"
}
},
"stay_anonymous": "Stay Anonymous",
"tabs": {
"for_later": "For later",
Expand Down
4 changes: 4 additions & 0 deletions lib/src/data/book/book_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ abstract class BookRepository {
Future<void> overwriteBooks(List<Book> books);

Future<void> mergeBooks(List<Book> books);

Future<void> deleteNotes(String bookId);

Future<void> saveNotes(String bookId, String notes);
}
10 changes: 10 additions & 0 deletions lib/src/data/book/firebase_book_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ class FirebaseBookRepository implements BookRepository {
}
}
}

@override
Future<void> deleteNotes(String bookId) async {
return _booksRef().child(bookId).update({'notes': null});
}

@override
Future<void> saveNotes(String bookId, String notes) {
return _booksRef().child(bookId).update({'notes': notes});
}
}

extension DataSnapshotExtension on DataSnapshot {
Expand Down
13 changes: 13 additions & 0 deletions lib/src/providers/app_router.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:dantex/src/providers/authentication.dart';
import 'package:dantex/src/ui/add/scan_book_page.dart';
import 'package:dantex/src/ui/book/book_detail_page.dart';
import 'package:dantex/src/ui/book/book_notes_page.dart';
import 'package:dantex/src/ui/boot_page.dart';
import 'package:dantex/src/ui/core/dante_page_scaffold.dart';
import 'package:dantex/src/ui/login/email_login_page.dart';
Expand Down Expand Up @@ -163,6 +164,13 @@ List<RouteBase> _mainRoutes = [
return BookDetailPage(id: bookId);
},
),
GoRoute(
path: DanteRoute.bookNotes.url,
builder: (context, state) {
final bookId = state.pathParameters['bookId'] ?? '';
return BookNotesPage(id: bookId);
},
),
];

enum DanteRoute {
Expand Down Expand Up @@ -240,6 +248,11 @@ enum DanteRoute {
webUrl: '/book/:bookId',
mobileUrl: 'book/:bookId',
navigationUrl: '/book/:bookId',
),
bookNotes(
webUrl: '/book/:bookId/notes',
mobileUrl: 'book/:bookId/notes',
navigationUrl: '/book/:bookId/notes',
);

/// Url used for registering the route in the [_router] field for Web.
Expand Down
Loading
Loading