Skip to content

Commit 2eb3754

Browse files
committed
refactor: playlist editor dialog
1 parent 460f347 commit 2eb3754

File tree

3 files changed

+86
-60
lines changed

3 files changed

+86
-60
lines changed

lib/components/playlist/playlist_create_dialog.dart

+44-46
Original file line numberDiff line numberDiff line change
@@ -170,30 +170,27 @@ class PlaylistCreateDialog extends HookConsumerWidget {
170170
return null;
171171
},
172172
builder: (field) {
173-
return Center(
174-
child: Stack(
175-
children: [
176-
UniversalImage(
177-
path: field.value?.path ??
178-
TypeConversionUtils.image_X_UrlString(
179-
updatingPlaylist?.images,
180-
placeholder:
181-
ImagePlaceholder.collection,
182-
),
183-
height: 200,
184-
),
185-
Positioned(
186-
bottom: 20,
187-
right: 20,
188-
child: IconButton.filled(
173+
return Column(
174+
children: [
175+
UniversalImage(
176+
path: field.value?.path ??
177+
TypeConversionUtils.image_X_UrlString(
178+
updatingPlaylist?.images,
179+
placeholder: ImagePlaceholder.collection,
180+
),
181+
height: 200,
182+
),
183+
const SizedBox(height: 10),
184+
Row(
185+
mainAxisAlignment: MainAxisAlignment.center,
186+
children: [
187+
FilledButton.icon(
189188
icon: const Icon(SpotubeIcons.edit),
190-
style: IconButton.styleFrom(
191-
backgroundColor:
192-
theme.colorScheme.surface,
193-
foregroundColor:
194-
theme.colorScheme.primary,
195-
elevation: 2,
196-
shadowColor: theme.colorScheme.onSurface,
189+
label: Text(
190+
field.value?.path != null ||
191+
updatingPlaylist?.images != null
192+
? context.l10n.change_cover
193+
: context.l10n.add_cover,
197194
),
198195
onPressed: () async {
199196
final imageFile = await ImagePicker()
@@ -207,31 +204,32 @@ class PlaylistCreateDialog extends HookConsumerWidget {
207204
}
208205
},
209206
),
210-
),
211-
if (field.hasError)
212-
Positioned(
213-
bottom: 20,
214-
left: 20,
215-
child: Container(
216-
padding: const EdgeInsets.symmetric(
217-
horizontal: 8,
218-
vertical: 4,
219-
),
220-
decoration: BoxDecoration(
221-
color: theme.colorScheme.error,
222-
borderRadius: BorderRadius.circular(4),
223-
),
224-
child: Text(
225-
field.errorText ?? "",
226-
style: theme.textTheme.bodyMedium!
227-
.copyWith(
228-
color: theme.colorScheme.onError,
229-
),
230-
),
207+
const SizedBox(width: 10),
208+
IconButton.filled(
209+
icon: const Icon(SpotubeIcons.trash),
210+
style: IconButton.styleFrom(
211+
backgroundColor:
212+
theme.colorScheme.errorContainer,
213+
foregroundColor: theme.colorScheme.error,
231214
),
215+
onPressed: field.value == null
216+
? null
217+
: () {
218+
field.didChange(null);
219+
field.validate();
220+
field.save();
221+
},
222+
),
223+
],
224+
),
225+
if (field.hasError)
226+
Text(
227+
field.errorText ?? "",
228+
style: theme.textTheme.bodyMedium!.copyWith(
229+
color: theme.colorScheme.error,
232230
),
233-
],
234-
),
231+
)
232+
],
235233
);
236234
}),
237235
const SizedBox(height: 10),

lib/l10n/app_en.arb

+3-1
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,7 @@
265265
"crunching_results": "Crunching results...",
266266
"search_to_get_results": "Search to get results",
267267
"use_amoled_dark_theme": "Use AMOLED (Pitch Black) dark theme",
268-
"normalize_audio": "Normalize audio"
268+
"normalize_audio": "Normalize audio",
269+
"change_cover": "Change cover",
270+
"add_cover": "Add cover"
269271
}

untranslated_messages.json

+39-13
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,92 @@
11
{
22
"ar": [
33
"use_amoled_dark_theme",
4-
"normalize_audio"
4+
"normalize_audio",
5+
"change_cover",
6+
"add_cover"
57
],
68

79
"bn": [
810
"use_amoled_dark_theme",
9-
"normalize_audio"
11+
"normalize_audio",
12+
"change_cover",
13+
"add_cover"
1014
],
1115

1216
"ca": [
1317
"use_amoled_dark_theme",
14-
"normalize_audio"
18+
"normalize_audio",
19+
"change_cover",
20+
"add_cover"
1521
],
1622

1723
"de": [
1824
"use_amoled_dark_theme",
19-
"normalize_audio"
25+
"normalize_audio",
26+
"change_cover",
27+
"add_cover"
2028
],
2129

2230
"es": [
2331
"use_amoled_dark_theme",
24-
"normalize_audio"
32+
"normalize_audio",
33+
"change_cover",
34+
"add_cover"
2535
],
2636

2737
"fr": [
2838
"use_amoled_dark_theme",
29-
"normalize_audio"
39+
"normalize_audio",
40+
"change_cover",
41+
"add_cover"
3042
],
3143

3244
"hi": [
3345
"use_amoled_dark_theme",
34-
"normalize_audio"
46+
"normalize_audio",
47+
"change_cover",
48+
"add_cover"
3549
],
3650

3751
"ja": [
3852
"use_amoled_dark_theme",
39-
"normalize_audio"
53+
"normalize_audio",
54+
"change_cover",
55+
"add_cover"
4056
],
4157

4258
"pl": [
4359
"use_amoled_dark_theme",
44-
"normalize_audio"
60+
"normalize_audio",
61+
"change_cover",
62+
"add_cover"
4563
],
4664

4765
"pt": [
4866
"use_amoled_dark_theme",
49-
"normalize_audio"
67+
"normalize_audio",
68+
"change_cover",
69+
"add_cover"
5070
],
5171

5272
"ru": [
5373
"use_amoled_dark_theme",
54-
"normalize_audio"
74+
"normalize_audio",
75+
"change_cover",
76+
"add_cover"
5577
],
5678

5779
"uk": [
5880
"use_amoled_dark_theme",
59-
"normalize_audio"
81+
"normalize_audio",
82+
"change_cover",
83+
"add_cover"
6084
],
6185

6286
"zh": [
6387
"use_amoled_dark_theme",
64-
"normalize_audio"
88+
"normalize_audio",
89+
"change_cover",
90+
"add_cover"
6591
]
6692
}

0 commit comments

Comments
 (0)