- PlaylistsScreen: Favoriten-ListTile oben (watchFavorites, pusht FavoritesListScreen), darunter alle Playlisten (watchPlaylists) mit Songanzahl, Löschen via Icon/Long-Press + Bestätigungsdialog - CreatePlaylistDialog: Name-Eingabe, Erstellen-Button erst aktiv bei nicht-leerem Text, gibt die neue Playlist-ID zurück - Leer-Zustand "Noch keine Playlisten" nach Vorbild von library_screen.dart - main.dart: Playlisten-Platzhalter durch PlaylistsScreen ersetzt Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
56 lines
1.6 KiB
Dart
56 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../library/playlist_service.dart';
|
|
|
|
/// Dialog zum Anlegen einer neuen Playlist. Gibt bei Erfolg die neue
|
|
/// Playlist-ID zurück (z.B. um direkt danach einen Song hinzuzufügen).
|
|
class CreatePlaylistDialog extends StatefulWidget {
|
|
const CreatePlaylistDialog({super.key});
|
|
|
|
@override
|
|
State<CreatePlaylistDialog> createState() => _CreatePlaylistDialogState();
|
|
}
|
|
|
|
class _CreatePlaylistDialogState extends State<CreatePlaylistDialog> {
|
|
final _controller = TextEditingController();
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
Future<void> _create() async {
|
|
final name = _controller.text.trim();
|
|
if (name.isEmpty) return;
|
|
final id = await context.read<PlaylistService>().createPlaylist(name);
|
|
if (mounted) Navigator.pop(context, id);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final canCreate = _controller.text.trim().isNotEmpty;
|
|
return AlertDialog(
|
|
title: const Text('Neue Playlist'),
|
|
content: TextField(
|
|
controller: _controller,
|
|
autofocus: true,
|
|
decoration: const InputDecoration(hintText: 'Name der Playlist'),
|
|
onChanged: (_) => setState(() {}),
|
|
onSubmitted: (_) => canCreate ? _create() : null,
|
|
),
|
|
actions: [
|
|
TextButton(
|
|
onPressed: () => Navigator.pop(context),
|
|
child: const Text('Abbrechen'),
|
|
),
|
|
TextButton(
|
|
onPressed: canCreate ? _create : null,
|
|
child: const Text('Erstellen'),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|