@@ -19,117 +19,121 @@ class DetailedPlaylistPage extends StatefulWidget {
1919}
2020
2121class _DetailedPlaylistPageState extends State <DetailedPlaylistPage > {
22-
23-
2422 @override
2523 Widget build (BuildContext context) {
2624 return StreamBuilder (
27- stream: Provider .of <ProfileState >(context).playlistsRef! .doc (widget.playlistId).snapshots (),
28- builder: (context, playlistSnap) {
29- var playlist = playlistSnap.data? .data ();
25+ stream: Provider .of <ProfileState >(context)
26+ .playlistsRef!
27+ .doc (widget.playlistId)
28+ .snapshots (),
29+ builder: (context, playlistSnap) {
30+ var playlist = playlistSnap.data? .data ();
3031
31- if (playlist == null ) {
32- return const Center (child: CircularProgressIndicator (),);
33- }
34-
35- return Scaffold (
36- appBar: AppBar (
37- title: Text (playlist.title ?? AppLocalizations .of (context)! .noTitle,
38- style: const TextStyle (fontSize: 24 , color: Colors .white)),
39- actions: [
40- PopupMenuButton (
41- offset: const Offset (0 , 40 ),
42- icon: const Icon (Icons .more_vert),
43- itemBuilder: (context) => [
44- PopupMenuItem (
45- onTap: () {
46- Navigator .push (
47- context,
48- MaterialPageRoute (
49- builder: (context) => EditPlaylistPage (
50- playlist: playlist,
32+ if (playlist == null ) {
33+ return const Center (
34+ child: CircularProgressIndicator (),
35+ );
36+ }
37+
38+ return Scaffold (
39+ appBar: AppBar (
40+ title: Text (
41+ playlist.title ?? AppLocalizations .of (context)! .noTitle,
42+ style: const TextStyle (fontSize: 24 , color: Colors .white)),
43+ actions: [
44+ PopupMenuButton (
45+ offset: const Offset (0 , 40 ),
46+ icon: const Icon (Icons .more_vert),
47+ itemBuilder: (context) => [
48+ PopupMenuItem (
49+ onTap: () {
50+ Navigator .push (
51+ context,
52+ MaterialPageRoute (
53+ builder: (context) => EditPlaylistPage (
54+ playlist: playlist,
55+ ),
5156 ),
52- ),
53- );
54- },
55- value: AppLocalizations .of (context)! .edit,
56- child: Text (AppLocalizations .of (context)! .edit),
57+ );
58+ },
59+ value: AppLocalizations .of (context)! .edit,
60+ child: Text (AppLocalizations .of (context)! .edit),
61+ ),
62+ PopupMenuItem (
63+ onTap: () {
64+ Provider .of <ProfileState >(context, listen: false )
65+ .playlistsRef
66+ ? .doc (playlist.id)
67+ .delete ();
68+ Navigator .pop (context);
69+ },
70+ value: AppLocalizations .of (context)! .delete,
71+ child: Text (AppLocalizations .of (context)! .delete),
72+ ),
73+ ],
74+ ),
75+ ],
76+ ),
77+ body: Padding (
78+ padding: const EdgeInsets .all (8.0 ),
79+ child: Column (
80+ mainAxisAlignment: MainAxisAlignment .start,
81+ crossAxisAlignment: CrossAxisAlignment .start,
82+ children: [
83+ Text (
84+ playlist.description ??
85+ AppLocalizations .of (context)! .noDescriptionAvailable,
86+ textAlign: TextAlign .left,
87+ softWrap: true ,
88+ style: const TextStyle (fontSize: 16 , color: Colors .black45),
5789 ),
58- PopupMenuItem (
59- onTap: () {
60- Provider .of <ProfileState >(context, listen: false )
61- .playlistsRef
62- ? .doc (playlist.id)
63- .delete ();
64- Navigator .pop (context);
65- },
66- value: AppLocalizations .of (context)! .delete,
67- child: Text (AppLocalizations .of (context)! .delete),
90+ const SizedBox (width: 8.0 ),
91+ Text (AppLocalizations .of (context)! .stories,
92+ textAlign: TextAlign .center,
93+ style:
94+ const TextStyle (fontSize: 24 , color: Colors .black)),
95+ Expanded (
96+ child: ListView .builder (
97+ itemCount: playlist.stories != null
98+ ? playlist.stories! .length
99+ : 0 ,
100+ itemBuilder: (context, index) {
101+ return Padding (
102+ padding: const EdgeInsets .all (8.0 ),
103+ child: StoryListItem (
104+ story: playlist.stories! [index],
105+ buttons: [
106+ StoryActionButton (
107+ icon: Icons .play_arrow,
108+ onTap: () {
109+ if (playlist.stories == null ) return ;
110+ if (audioHandler.customState.value
111+ is CustomPlayerState ) {
112+ var state = audioHandler.customState.value
113+ as CustomPlayerState ;
114+ state.setPlaylist (playlist.stories! );
115+ state.currentStoryPlayed = index;
116+ }
117+ StoryPlayer .playStory (
118+ context, playlist.stories! [index]);
119+
120+ Navigator .of (context).push (
121+ MaterialPageRoute (
122+ builder: (context) => const StoryPlayer (),
123+ ),
124+ );
125+ },
126+ ),
127+ ],
128+ ),
129+ );
130+ },
131+ ),
68132 ),
69133 ],
70134 ),
71- ],
72- ),
73- body: Padding (
74- padding: const EdgeInsets .all (8.0 ),
75- child: Column (
76- mainAxisAlignment: MainAxisAlignment .start,
77- crossAxisAlignment: CrossAxisAlignment .start,
78- children: [
79- Text (
80- playlist.description ??
81- AppLocalizations .of (context)! .noDescriptionAvailable,
82- textAlign: TextAlign .left,
83- softWrap: true ,
84- style: const TextStyle (fontSize: 16 , color: Colors .black45),
85- ),
86- const SizedBox (width: 8.0 ),
87- Text (AppLocalizations .of (context)! .stories,
88- textAlign: TextAlign .center,
89- style: const TextStyle (fontSize: 24 , color: Colors .black)),
90- Expanded (
91- child: ListView .builder (
92-
93- itemCount:
94- playlist.stories != null ? playlist.stories! .length : 0 ,
95- itemBuilder: (context, index) {
96- return Padding (
97- padding: const EdgeInsets .all (8.0 ),
98- child: StoryListItem (
99- story: playlist.stories! [index],
100- buttons: [
101- StoryActionButton (
102- icon: Icons .play_arrow,
103- onTap: () {
104- if (playlist.stories == null ) return ;
105- if (audioHandler.customState.value
106- is CustomPlayerState ) {
107- var state = audioHandler.customState.value
108- as CustomPlayerState ;
109- state.setPlaylist (playlist.stories! );
110- state.currentStoryPlayed = index;
111- }
112- StoryPlayer .playStory (
113- context, playlist.stories! [index]);
114-
115- Navigator .of (context).push (
116- MaterialPageRoute (
117- builder: (context) => const StoryPlayer (),
118- ),
119- );
120- },
121- ),
122- ],
123- ),
124- );
125- },
126- ),
127- ),
128- ],
129135 ),
130- ),
131- );
132- }
133- );
136+ );
137+ });
134138 }
135139}
0 commit comments