Added share bookmark to form

This commit is contained in:
Juan Gilsanz Polo
2024-04-14 20:44:34 +02:00
parent d42b960381
commit ca74c53ad2
7 changed files with 54 additions and 7 deletions

View File

@@ -16,6 +16,7 @@ class BookmarkFormModel {
List<String> tags;
final TextEditingController notesController;
int? editBookmarkId;
bool share;
BookmarkFormModel({
required this.urlController,
@@ -30,5 +31,6 @@ class BookmarkFormModel {
required this.tags,
required this.notesController,
this.editBookmarkId,
this.share = false,
});
}

View File

@@ -63,6 +63,7 @@ class BookmarkForm extends _$BookmarkForm {
state.tags = bookmark.tagNames ?? [];
state.notesController.text = bookmark.notes ?? '';
state.markAsUnread = bookmark.unread ?? false;
state.share = bookmark.shared ?? false;
}
void initializeProviderUrl(String url) {
@@ -112,6 +113,11 @@ class BookmarkForm extends _$BookmarkForm {
ref.notifyListeners();
}
void updateShare(bool value) {
state.share = value;
ref.notifyListeners();
}
void saveBookmark() async {
final newBookmark = SetBookmarkData(
url: state.urlController.text,
@@ -121,7 +127,7 @@ class BookmarkForm extends _$BookmarkForm {
: state.checkBookmark?.metadata?.description ?? '',
isArchived: false,
unread: state.markAsUnread,
shared: false,
shared: state.share,
tagNames: state.tags.join(","),
notes: state.notesController.text,
);

View File

@@ -133,7 +133,10 @@ class BookmarkFormModalState extends ConsumerState<BookmarkFormModal> {
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
),
SliverList.list(
children: const [_ModalContent()],
children: const [
_ModalContent(),
SizedBox(height: 16),
],
),
],
),
@@ -412,11 +415,20 @@ class _ModalContent extends ConsumerWidget {
SwitchListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
title: Text(t.bookmarks.addBookmark.markAsUnread),
subtitle: Text(t.bookmarks.addBookmark.markAsUnreadDescription),
value: provider.markAsUnread,
onChanged: provider.checkBookmark != null
? (v) => ref.read(bookmarkFormProvider.notifier).updateMarkAsUnread(v)
: null,
),
SwitchListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
title: Text(t.bookmarks.addBookmark.share),
subtitle: Text(t.bookmarks.addBookmark.shareDescription),
value: provider.share,
onChanged:
provider.checkBookmark != null ? (v) => ref.read(bookmarkFormProvider.notifier).updateShare(v) : null,
),
const SizedBox(height: 16),
],
);