added edit bookmark capabilities
This commit is contained in:
@@ -8,11 +8,13 @@ class CreateBookmarkDialog extends StatelessWidget {
|
||||
const CreateBookmarkDialog({
|
||||
super.key,
|
||||
required this.collectionId,
|
||||
required this.onSavePressed,
|
||||
this.onSavePressed,
|
||||
this.onDeletePressed,
|
||||
this.selectedBookmark,
|
||||
this.selectedMapsLink,
|
||||
});
|
||||
final void Function(Bookmark bookmark) onSavePressed;
|
||||
final void Function(Bookmark bookmark)? onSavePressed;
|
||||
final void Function()? onDeletePressed;
|
||||
final int collectionId;
|
||||
final Bookmark? selectedBookmark;
|
||||
final MapsLinkMetadata? selectedMapsLink;
|
||||
@@ -27,6 +29,10 @@ class CreateBookmarkDialog extends StatelessWidget {
|
||||
nameController.text = selectedMapsLink!.placeName;
|
||||
linkController.text = selectedMapsLink!.url;
|
||||
descriptionController.text = selectedMapsLink!.description;
|
||||
} else if (selectedBookmark != null) {
|
||||
nameController.text = selectedBookmark!.name;
|
||||
linkController.text = selectedBookmark!.link;
|
||||
descriptionController.text = selectedBookmark!.description;
|
||||
}
|
||||
|
||||
return AlertDialog(
|
||||
@@ -91,7 +97,7 @@ class CreateBookmarkDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
Column(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
TextButton(
|
||||
@@ -100,18 +106,31 @@ class CreateBookmarkDialog extends StatelessWidget {
|
||||
),
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
onSavePressed(
|
||||
Bookmark(
|
||||
collectionId: collectionId,
|
||||
name: nameController.text,
|
||||
link: linkController.text,
|
||||
description: descriptionController.text,
|
||||
),
|
||||
);
|
||||
final bookmark =
|
||||
selectedBookmark?.copyWith(
|
||||
name: nameController.text,
|
||||
link: linkController.text,
|
||||
description: descriptionController.text,
|
||||
) ??
|
||||
Bookmark(
|
||||
collectionId: collectionId,
|
||||
name: nameController.text,
|
||||
link: linkController.text,
|
||||
description: descriptionController.text,
|
||||
);
|
||||
onSavePressed?.call(bookmark);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Icon(Icons.save),
|
||||
),
|
||||
if (selectedBookmark != null)
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
onDeletePressed?.call();
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text('Delete'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user