WIP: allow editing the name of library lists

This commit is contained in:
2026-02-24 16:37:48 +09:00
parent 0bf0764f91
commit 1c746a3bbf
2 changed files with 16 additions and 7 deletions
+14 -4
View File
@@ -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
+2 -3
View File
@@ -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(),