From 2eb37549532e8de60c5a839f5f8c814edf0c5310 Mon Sep 17 00:00:00 2001 From: Kingkor Roy Tirtho Date: Wed, 27 Sep 2023 12:27:32 +0600 Subject: [PATCH] refactor: playlist editor dialog --- .../playlist/playlist_create_dialog.dart | 90 +++++++++---------- lib/l10n/app_en.arb | 4 +- untranslated_messages.json | 52 ++++++++--- 3 files changed, 86 insertions(+), 60 deletions(-) diff --git a/lib/components/playlist/playlist_create_dialog.dart b/lib/components/playlist/playlist_create_dialog.dart index 53424914..2e11a209 100644 --- a/lib/components/playlist/playlist_create_dialog.dart +++ b/lib/components/playlist/playlist_create_dialog.dart @@ -170,30 +170,27 @@ class PlaylistCreateDialog extends HookConsumerWidget { return null; }, builder: (field) { - return Center( - child: Stack( - children: [ - UniversalImage( - path: field.value?.path ?? - TypeConversionUtils.image_X_UrlString( - updatingPlaylist?.images, - placeholder: - ImagePlaceholder.collection, - ), - height: 200, - ), - Positioned( - bottom: 20, - right: 20, - child: IconButton.filled( + return Column( + children: [ + UniversalImage( + path: field.value?.path ?? + TypeConversionUtils.image_X_UrlString( + updatingPlaylist?.images, + placeholder: ImagePlaceholder.collection, + ), + height: 200, + ), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + FilledButton.icon( icon: const Icon(SpotubeIcons.edit), - style: IconButton.styleFrom( - backgroundColor: - theme.colorScheme.surface, - foregroundColor: - theme.colorScheme.primary, - elevation: 2, - shadowColor: theme.colorScheme.onSurface, + label: Text( + field.value?.path != null || + updatingPlaylist?.images != null + ? context.l10n.change_cover + : context.l10n.add_cover, ), onPressed: () async { final imageFile = await ImagePicker() @@ -207,31 +204,32 @@ class PlaylistCreateDialog extends HookConsumerWidget { } }, ), - ), - if (field.hasError) - Positioned( - bottom: 20, - left: 20, - child: Container( - padding: const EdgeInsets.symmetric( - horizontal: 8, - vertical: 4, - ), - decoration: BoxDecoration( - color: theme.colorScheme.error, - borderRadius: BorderRadius.circular(4), - ), - child: Text( - field.errorText ?? "", - style: theme.textTheme.bodyMedium! - .copyWith( - color: theme.colorScheme.onError, - ), - ), + const SizedBox(width: 10), + IconButton.filled( + icon: const Icon(SpotubeIcons.trash), + style: IconButton.styleFrom( + backgroundColor: + theme.colorScheme.errorContainer, + foregroundColor: theme.colorScheme.error, ), + onPressed: field.value == null + ? null + : () { + field.didChange(null); + field.validate(); + field.save(); + }, ), - ], - ), + ], + ), + if (field.hasError) + Text( + field.errorText ?? "", + style: theme.textTheme.bodyMedium!.copyWith( + color: theme.colorScheme.error, + ), + ) + ], ); }), const SizedBox(height: 10), diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index c58678fd..926bb684 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -265,5 +265,7 @@ "crunching_results": "Crunching results...", "search_to_get_results": "Search to get results", "use_amoled_dark_theme": "Use AMOLED (Pitch Black) dark theme", - "normalize_audio": "Normalize audio" + "normalize_audio": "Normalize audio", + "change_cover": "Change cover", + "add_cover": "Add cover" } \ No newline at end of file diff --git a/untranslated_messages.json b/untranslated_messages.json index ebcc49ee..a0980aab 100644 --- a/untranslated_messages.json +++ b/untranslated_messages.json @@ -1,66 +1,92 @@ { "ar": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "bn": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "ca": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "de": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "es": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "fr": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "hi": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "ja": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "pl": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "pt": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "ru": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "uk": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ], "zh": [ "use_amoled_dark_theme", - "normalize_audio" + "normalize_audio", + "change_cover", + "add_cover" ] }