added abilty to edit and delete collections
This commit is contained in:
@@ -1,18 +1,35 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../model/collection.dart';
|
||||
import 'edit_dialog_widgets/edit_dialog_actions.dart' show EditDialogActions;
|
||||
import 'edit_dialog_widgets/edit_dialog_title.dart';
|
||||
|
||||
class CreateBookmarkCollectionDialog extends StatelessWidget {
|
||||
const CreateBookmarkCollectionDialog({
|
||||
super.key,
|
||||
required this.onSavePressed,
|
||||
this.onDeletePressed,
|
||||
this.selectedCollection,
|
||||
});
|
||||
final void Function(String name) onSavePressed;
|
||||
|
||||
final void Function()? onDeletePressed;
|
||||
final void Function(Collection collection) onSavePressed;
|
||||
final Collection? selectedCollection;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final nameController = TextEditingController();
|
||||
|
||||
if (selectedCollection != null) {
|
||||
nameController.text = selectedCollection!.name;
|
||||
}
|
||||
|
||||
return AlertDialog(
|
||||
title: Text('Create Collection'),
|
||||
title: EditDialogTitle(
|
||||
dialogType: DialogType.collection,
|
||||
onDeletePressed: onDeletePressed,
|
||||
),
|
||||
content: TextField(
|
||||
controller: nameController,
|
||||
autofocus: true,
|
||||
@@ -23,17 +40,20 @@ class CreateBookmarkCollectionDialog extends StatelessWidget {
|
||||
FilteringTextInputFormatter.deny(RegExp(r'\s\s+')),
|
||||
],
|
||||
decoration: InputDecoration(
|
||||
// TODO: Localize
|
||||
labelText: 'Collection Name',
|
||||
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
FloatingActionButton(
|
||||
onPressed: () {
|
||||
onSavePressed(nameController.text);
|
||||
EditDialogActions(
|
||||
onSavePressed: () {
|
||||
final bookmark =
|
||||
selectedCollection?.copyWith(name: nameController.text) ??
|
||||
Collection(name: nameController.text);
|
||||
onSavePressed(bookmark);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Icon(Icons.save),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user