WIP: allow editing the name of library lists
This commit is contained in:
@@ -10,7 +10,7 @@ class LibraryListTile extends StatelessWidget {
|
||||
final Widget? leading;
|
||||
final LibraryList library;
|
||||
final void Function()? onDelete;
|
||||
final void Function()? onUpdate;
|
||||
final void Function(String, String)? onRename;
|
||||
final bool isEditable;
|
||||
|
||||
const LibraryListTile({
|
||||
@@ -18,7 +18,7 @@ class LibraryListTile extends StatelessWidget {
|
||||
required this.library,
|
||||
this.leading,
|
||||
this.onDelete,
|
||||
this.onUpdate,
|
||||
this.onRename,
|
||||
this.isEditable = true,
|
||||
});
|
||||
|
||||
@@ -34,8 +34,18 @@ class LibraryListTile extends StatelessWidget {
|
||||
backgroundColor: Colors.blue,
|
||||
icon: Icons.edit,
|
||||
onPressed: (_) async {
|
||||
// TODO: update name
|
||||
onUpdate?.call();
|
||||
final String oldName = library.name;
|
||||
|
||||
// TODO: dialog
|
||||
|
||||
final String? newName = null;
|
||||
|
||||
if (newName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await GetIt.instance.get<Database>().libraryListRenameList(oldName, newName);
|
||||
onRename?.call(oldName, newName);
|
||||
},
|
||||
),
|
||||
// TODO: ask for confirmation before deleting
|
||||
|
||||
@@ -33,10 +33,9 @@ class _LibraryViewState extends State<LibraryView> {
|
||||
return Column(
|
||||
children: [
|
||||
LibraryListTile(
|
||||
key: ValueKey(libraries!.first.name),
|
||||
library: libraries!.first,
|
||||
leading: const Icon(Icons.star),
|
||||
onDelete: getEntriesFromDatabase,
|
||||
onUpdate: getEntriesFromDatabase,
|
||||
isEditable: false,
|
||||
),
|
||||
Expanded(
|
||||
@@ -49,7 +48,7 @@ class _LibraryViewState extends State<LibraryView> {
|
||||
key: ValueKey(e.name),
|
||||
library: e,
|
||||
onDelete: getEntriesFromDatabase,
|
||||
onUpdate: getEntriesFromDatabase,
|
||||
onRename: (_, _) => getEntriesFromDatabase(),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
|
||||
Reference in New Issue
Block a user