Skip to content

Commit

Permalink
Newly created playlists doesn't show up
Browse files Browse the repository at this point in the history
Fixes #740
  • Loading branch information
Feichtmeier committed May 15, 2024
1 parent 2e995c5 commit 1fa3a50
Showing 1 changed file with 41 additions and 26 deletions.
67 changes: 41 additions & 26 deletions lib/src/playlists/view/add_to_playlist_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:yaru/yaru.dart';

import '../../../common.dart';
import '../../../data.dart';
import '../../../get.dart';
import '../../../globals.dart';
import '../../../l10n.dart';
import '../../../library.dart';
Expand All @@ -25,38 +26,13 @@ class AddToPlaylistDialog extends StatelessWidget {
key: playlistNavigatorKey,
initialRoute: '/',
onGenerateRoute: (settings) {
final listView = ListView(
shrinkWrap: true,
children: [
ListTile(
onTap: () => playlistNavigatorKey.currentState?.pushNamed('/new'),
leading: SideBarFallBackImage(
color: Colors.transparent,
child: Icon(Iconz().plus),
),
title: Text(context.l10n.createNewPlaylist),
),
...libraryModel.getPlaylistNames().map(
(playlistId) => Builder(
builder: (context) {
return _PlaylistTile(
playlistId: playlistId,
libraryModel: libraryModel,
audio: audio,
);
},
),
),
],
);

return PageRouteBuilder(
pageBuilder: (_, __, ___) => settings.name == '/new'
? _NewView(
libraryModel: libraryModel,
audio: audio,
)
: listView,
: _PlaylistTilesList(audio: audio),
transitionDuration: const Duration(milliseconds: 500),
);
},
Expand All @@ -77,6 +53,45 @@ class AddToPlaylistDialog extends StatelessWidget {
}
}

class _PlaylistTilesList extends StatelessWidget with WatchItMixin {
const _PlaylistTilesList({
required this.audio,
});

final Audio audio;

@override
Widget build(BuildContext context) {
final playlistNames = watchPropertyValue(
(LibraryModel m) => m.playlists.keys.map((e) => e.toString()),
);
return ListView(
shrinkWrap: true,
children: [
ListTile(
onTap: () => playlistNavigatorKey.currentState?.pushNamed('/new'),
leading: SideBarFallBackImage(
color: Colors.transparent,
child: Icon(Iconz().plus),
),
title: Text(context.l10n.createNewPlaylist),
),
...playlistNames.map(
(playlistId) => Builder(
builder: (context) {
return _PlaylistTile(
playlistId: playlistId,
libraryModel: getIt<LibraryModel>(),
audio: audio,
);
},
),
),
],
);
}
}

class _PlaylistTile extends StatelessWidget {
const _PlaylistTile({
required this.libraryModel,
Expand Down

0 comments on commit 1fa3a50

Please sign in to comment.