@@ -74,111 +74,116 @@ void showCreatePlaylistDialog(BuildContext context, {dynamic songToAdd}) {
7474 child: Column (
7575 mainAxisSize: MainAxisSize .min,
7676 children: < Widget > [
77- Container (
78- decoration: BoxDecoration (
79- color: colorScheme.surfaceContainerLow,
80- borderRadius: BorderRadius .circular (16 ),
81- ),
82- padding: const EdgeInsets .all (4 ),
83- child: Row (
84- children: [
85- Expanded (
86- child: GestureDetector (
87- onTap: () {
88- dialogSetState (() {
89- isYouTubeMode = true ;
90- id = '' ;
91- customPlaylistName = '' ;
92- imageUrl = null ;
93- imageBase64 = null ;
94- });
95- },
96- child: AnimatedContainer (
97- duration: const Duration (milliseconds: 200 ),
98- padding: const EdgeInsets .symmetric (vertical: 12 ),
99- decoration: BoxDecoration (
100- color: isYouTubeMode
101- ? colorScheme.primaryContainer
102- : Colors .transparent,
103- borderRadius: BorderRadius .circular (12 ),
104- ),
105- child: Row (
106- mainAxisAlignment: MainAxisAlignment .center,
107- children: [
108- Icon (
109- FluentIcons .globe_20_filled,
110- size: 20 ,
111- color: isYouTubeMode
112- ? colorScheme.onPrimaryContainer
113- : colorScheme.onSurfaceVariant,
114- ),
115- const SizedBox (width: 8 ),
116- Text (
117- 'YouTube' ,
118- style: TextStyle (
77+ if (songToAdd == null )
78+ Container (
79+ decoration: BoxDecoration (
80+ color: colorScheme.surfaceContainerLow,
81+ borderRadius: BorderRadius .circular (16 ),
82+ ),
83+ padding: const EdgeInsets .all (4 ),
84+ child: Row (
85+ children: [
86+ Expanded (
87+ child: GestureDetector (
88+ onTap: () {
89+ dialogSetState (() {
90+ isYouTubeMode = true ;
91+ id = '' ;
92+ customPlaylistName = '' ;
93+ imageUrl = null ;
94+ imageBase64 = null ;
95+ });
96+ },
97+ child: AnimatedContainer (
98+ duration: const Duration (milliseconds: 200 ),
99+ padding: const EdgeInsets .symmetric (
100+ vertical: 12 ,
101+ ),
102+ decoration: BoxDecoration (
103+ color: isYouTubeMode
104+ ? colorScheme.primaryContainer
105+ : Colors .transparent,
106+ borderRadius: BorderRadius .circular (12 ),
107+ ),
108+ child: Row (
109+ mainAxisAlignment: MainAxisAlignment .center,
110+ children: [
111+ Icon (
112+ FluentIcons .globe_20_filled,
113+ size: 20 ,
119114 color: isYouTubeMode
120115 ? colorScheme.onPrimaryContainer
121116 : colorScheme.onSurfaceVariant,
122- fontWeight: isYouTubeMode
123- ? FontWeight .w600
124- : FontWeight .w500,
125117 ),
126- ),
127- ],
118+ const SizedBox (width: 8 ),
119+ Text (
120+ 'YouTube' ,
121+ style: TextStyle (
122+ color: isYouTubeMode
123+ ? colorScheme.onPrimaryContainer
124+ : colorScheme.onSurfaceVariant,
125+ fontWeight: isYouTubeMode
126+ ? FontWeight .w600
127+ : FontWeight .w500,
128+ ),
129+ ),
130+ ],
131+ ),
128132 ),
129133 ),
130134 ),
131- ),
132- Expanded (
133- child: GestureDetector (
134- onTap: () {
135- dialogSetState (() {
136- isYouTubeMode = false ;
137- id = '' ;
138- customPlaylistName = '' ;
139- imageUrl = null ;
140- imageBase64 = null ;
141- });
142- },
143- child: AnimatedContainer (
144- duration: const Duration (milliseconds: 200 ),
145- padding: const EdgeInsets .symmetric (vertical: 12 ),
146- decoration: BoxDecoration (
147- color: ! isYouTubeMode
148- ? colorScheme.primaryContainer
149- : Colors .transparent,
150- borderRadius: BorderRadius .circular (12 ),
151- ),
152- child: Row (
153- mainAxisAlignment: MainAxisAlignment .center,
154- children: [
155- Icon (
156- FluentIcons .person_20_filled,
157- size: 20 ,
158- color: ! isYouTubeMode
159- ? colorScheme.onPrimaryContainer
160- : colorScheme.onSurfaceVariant,
161- ),
162- const SizedBox (width: 8 ),
163- Text (
164- context.l10n! .custom,
165- style: TextStyle (
135+ Expanded (
136+ child: GestureDetector (
137+ onTap: () {
138+ dialogSetState (() {
139+ isYouTubeMode = false ;
140+ id = '' ;
141+ customPlaylistName = '' ;
142+ imageUrl = null ;
143+ imageBase64 = null ;
144+ });
145+ },
146+ child: AnimatedContainer (
147+ duration: const Duration (milliseconds: 200 ),
148+ padding: const EdgeInsets .symmetric (
149+ vertical: 12 ,
150+ ),
151+ decoration: BoxDecoration (
152+ color: ! isYouTubeMode
153+ ? colorScheme.primaryContainer
154+ : Colors .transparent,
155+ borderRadius: BorderRadius .circular (12 ),
156+ ),
157+ child: Row (
158+ mainAxisAlignment: MainAxisAlignment .center,
159+ children: [
160+ Icon (
161+ FluentIcons .person_20_filled,
162+ size: 20 ,
166163 color: ! isYouTubeMode
167164 ? colorScheme.onPrimaryContainer
168165 : colorScheme.onSurfaceVariant,
169- fontWeight: ! isYouTubeMode
170- ? FontWeight .w600
171- : FontWeight .w500,
172166 ),
173- ),
174- ],
167+ const SizedBox (width: 8 ),
168+ Text (
169+ context.l10n! .custom,
170+ style: TextStyle (
171+ color: ! isYouTubeMode
172+ ? colorScheme.onPrimaryContainer
173+ : colorScheme.onSurfaceVariant,
174+ fontWeight: ! isYouTubeMode
175+ ? FontWeight .w600
176+ : FontWeight .w500,
177+ ),
178+ ),
179+ ],
180+ ),
175181 ),
176182 ),
177183 ),
178- ) ,
179- ] ,
184+ ] ,
185+ ) ,
180186 ),
181- ),
182187 const SizedBox (height: 20 ),
183188 if (isYouTubeMode)
184189 TextField (
@@ -265,25 +270,22 @@ void showCreatePlaylistDialog(BuildContext context, {dynamic songToAdd}) {
265270 if (isYouTubeMode && id.isNotEmpty) {
266271 final result = await addUserPlaylist (id, context);
267272 if (context.mounted) showToast (context, result);
268-
273+
269274 if (! context.mounted) return ;
270275 Navigator .pop (context);
271276 } else if (! isYouTubeMode && customPlaylistName.isNotEmpty) {
272- final result = createCustomPlaylist (
277+ final ( result, newPlaylistId) = createCustomPlaylist (
273278 customPlaylistName.trim (),
274279 imageBase64 ?? imageUrl,
275280 context,
276281 );
277- if (context.mounted && songToAdd == null ) {
278- showToast (context, result);
279- }
280-
281- if (songToAdd != null && userCustomPlaylists.value.isNotEmpty) {
282- final newPlaylist = userCustomPlaylists.value.last;
282+ if (context.mounted) showToast (context, result);
283+
284+ if (songToAdd != null ) {
283285 if (context.mounted) {
284286 final addResult = addSongInCustomPlaylist (
285287 context,
286- newPlaylist[ 'ytid' ] ,
288+ newPlaylistId ,
287289 songToAdd,
288290 );
289291 showToast (context, addResult);
0 commit comments