From 1da04e29d25955dbd0f9e8f59412f14e195a894f Mon Sep 17 00:00:00 2001 From: Max Pylypenko <3mpee3mpee@gmail.com> Date: Mon, 13 Oct 2025 00:14:49 +0700 Subject: [PATCH] avif: updated images to display generic error for non supported image types + translations --- lib/l10n/app_ca.arb | 24 ++++++++++--- lib/l10n/app_cs.arb | 24 ++++++++++--- lib/l10n/app_de.arb | 24 ++++++++++--- lib/l10n/app_en.arb | 42 +++++++++++++++++++--- lib/l10n/app_es.arb | 24 ++++++++++--- lib/l10n/app_fr.arb | 24 ++++++++++--- lib/l10n/app_ja.arb | 24 ++++++++++--- lib/l10n/app_uk.arb | 24 ++++++++++--- lib/widgets/gallery/overview.dart | 60 ++++++++++++++++++++++--------- 9 files changed, 220 insertions(+), 50 deletions(-) diff --git a/lib/l10n/app_ca.arb b/lib/l10n/app_ca.arb index 5c32c040..f327fc76 100644 --- a/lib/l10n/app_ca.arb +++ b/lib/l10n/app_ca.arb @@ -471,10 +471,26 @@ }, "gallery": "Galeria", "@gallery": {}, - "galleryAvifNotSupported": "AVIF no és compatible", - "@galleryAvifNotSupported": {}, - "galleryAvifNotSupportedDetail": "Les imatges AVIF encara no són compatibles.", - "@galleryAvifNotSupportedDetail": {}, + "imageFormatNotSupported": "{imageFormat} no és compatible", + "@imageFormatNotSupported": { + "description": "Label shown on the error container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, + "imageFormatNotSupportedDetail": "Les imatges {imageFormat} encara no són compatibles.", + "@imageFormatNotSupportedDetail": { + "description": "Label shown on the image preview container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, "addImage": "Afegeix imatge", "@addImage": {}, "dataCopied": "Dades copiades a una nova entrada", diff --git a/lib/l10n/app_cs.arb b/lib/l10n/app_cs.arb index 201b505e..0ec42751 100644 --- a/lib/l10n/app_cs.arb +++ b/lib/l10n/app_cs.arb @@ -508,10 +508,26 @@ "@takePicture": {}, "gallery": "Galerie", "@gallery": {}, - "galleryAvifNotSupported": "AVIF není podporován", - "@galleryAvifNotSupported": {}, - "galleryAvifNotSupportedDetail": "Obrazy AVIF zatím nejsou podporovány.", - "@galleryAvifNotSupportedDetail": {}, + "imageFormatNotSupported": "{imageFormat} není podporován", + "@imageFormatNotSupported": { + "description": "Label shown on the error container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, + "imageFormatNotSupportedDetail": "Obrazy {imageFormat} zatím nejsou podporovány.", + "@imageFormatNotSupportedDetail": { + "description": "Label shown on the image preview container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, "productFound": "Produkt nalezen", "@productFound": { "description": "Header label for dialog when product is found with barcode" diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index c8b20b33..cf4ff4e0 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -357,10 +357,26 @@ "@addImage": {}, "gallery": "Galerie", "@gallery": {}, - "galleryAvifNotSupported": "AVIF wird nicht unterstützt", - "@galleryAvifNotSupported": {}, - "galleryAvifNotSupportedDetail": "AVIF-Bilder werden noch nicht unterstützt.", - "@galleryAvifNotSupportedDetail": {}, + "imageFormatNotSupported": "{imageFormat} wird nicht unterstützt", + "@imageFormatNotSupported": { + "description": "Label shown on the error container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, + "imageFormatNotSupportedDetail": "{imageFormat}-Bilder werden noch nicht unterstützt.", + "@imageFormatNotSupportedDetail": { + "description": "Label shown on the image preview container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, "chooseFromLibrary": "Wähle aus der Bibliothek", "@chooseFromLibrary": {}, "takePicture": "Bild aufnehmen", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index e56969f3..eeb709ac 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -680,10 +680,6 @@ "@chooseFromLibrary": {}, "gallery": "Gallery", "@gallery": {}, - "galleryAvifNotSupported": "AVIF not supported", - "@galleryAvifNotSupported": {}, - "galleryAvifNotSupportedDetail": "AVIF images are not supported yet.", - "@galleryAvifNotSupportedDetail": {}, "addImage": "Add image", "@addImage": {}, "dataCopied": "Data copied to new entry", @@ -775,6 +771,26 @@ }, "imageDetailsLicenseNotice": "By submitting this image, you agree to release it under the CC-BY-SA-4. The image must be either your own work or the author must have released it under a license compatible with it.", "imageDetailsLicenseNoticeLinkToLicense": "See license text.", + "imageFormatNotSupported": "{imageFormat} not supported", + "@imageFormatNotSupported": { + "description": "Label shown on the error container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, + "imageFormatNotSupportedDetail": "{imageFormat} images are not supported yet.", + "@imageFormatNotSupportedDetail": { + "description": "Label shown on the image preview container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, "add": "add", "@add": { "description": "Add button text" @@ -1035,5 +1051,21 @@ "themeMode": "Theme mode", "darkMode": "Always dark mode", "lightMode": "Always light mode", - "systemMode": "System settings" + "systemMode": "System settings", + "galleryImageTypeNotSupported": "{imageType} images are currently not supported on this platform.", + "@galleryImageTypeNotSupported": { + "placeholders": { + "imageType": { + "type": "String" + } + } + }, + "galleryImageTypeNotSupportedDetail": "This image is in {imageType} format, which is currently not supported on this platform.", + "@galleryImageTypeNotSupportedDetail": { + "placeholders": { + "imageType": { + "type": "String" + } + } + } } diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 5e20f6f2..312bb16a 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -344,10 +344,26 @@ "@addImage": {}, "gallery": "Galería", "@gallery": {}, - "galleryAvifNotSupported": "AVIF no compatible", - "@galleryAvifNotSupported": {}, - "galleryAvifNotSupportedDetail": "Las imágenes AVIF aún no son compatibles.", - "@galleryAvifNotSupportedDetail": {}, + "imageFormatNotSupported": "{imageFormat} no compatible", + "@imageFormatNotSupported": { + "description": "Label shown on the error container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, + "imageFormatNotSupportedDetail": "Las imágenes {imageFormat} aún no son compatibles.", + "@imageFormatNotSupportedDetail": { + "description": "Label shown on the image preview container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, "chooseFromLibrary": "Elije de la biblioteca de fotos", "@chooseFromLibrary": {}, "takePicture": "Toma una foto", diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 54d285c3..eb6637b6 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -354,10 +354,26 @@ "@addImage": {}, "gallery": "Galerie", "@gallery": {}, - "galleryAvifNotSupported": "AVIF non pris en charge", - "@galleryAvifNotSupported": {}, - "galleryAvifNotSupportedDetail": "AVIF non pris en charge", - "@galleryAvifNotSupportedDetail": {}, + "imageFormatNotSupported": "{imageFormat} non pris en charge", + "@imageFormatNotSupported": { + "description": "Label shown on the error container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, + "imageFormatNotSupportedDetail": "{imageFormat} non pris en charge", + "@imageFormatNotSupportedDetail": { + "description": "Label shown on the image preview container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, "chooseFromLibrary": "Choisir depuis la bibliothèque", "@chooseFromLibrary": {}, "takePicture": "Prendre une photo", diff --git a/lib/l10n/app_ja.arb b/lib/l10n/app_ja.arb index dec14603..7f6ddf35 100644 --- a/lib/l10n/app_ja.arb +++ b/lib/l10n/app_ja.arb @@ -473,10 +473,26 @@ "@chooseFromLibrary": {}, "gallery": "Gallery", "@gallery": {}, - "galleryAvifNotSupported": "AVIFはサポートされていません", - "@galleryAvifNotSupported": {}, - "galleryAvifNotSupportedDetail": "AVIF形式の画像はまだサポートされていません。", - "@galleryAvifNotSupportedDetail": {}, + "imageFormatNotSupported": "{imageFormat}はサポートされていません", + "@imageFormatNotSupported": { + "description": "Label shown on the error container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, + "imageFormatNotSupportedDetail": "{imageFormat}形式の画像はまだサポートされていません。", + "@imageFormatNotSupportedDetail": { + "description": "Label shown on the image preview container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, "addImage": "Add image", "@addImage": {}, "dataCopied": "Data copied to new entry", diff --git a/lib/l10n/app_uk.arb b/lib/l10n/app_uk.arb index 5490c589..ca28df05 100644 --- a/lib/l10n/app_uk.arb +++ b/lib/l10n/app_uk.arb @@ -479,10 +479,26 @@ "@chooseFromLibrary": {}, "gallery": "Галерея", "@gallery": {}, - "galleryAvifNotSupported": "AVIF не підтримується", - "@galleryAvifNotSupported": {}, - "galleryAvifNotSupportedDetail": "Зображення AVIF поки що не підтримуються.", - "@galleryAvifNotSupportedDetail": {}, + "imageFormatNotSupported": "{imageFormat} не підтримується", + "@imageFormatNotSupported": { + "description": "Label shown on the error container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, + "imageFormatNotSupportedDetail": "Зображення {imageFormat} поки що не підтримуються.", + "@imageFormatNotSupportedDetail": { + "description": "Label shown on the image preview container when image format is not supported", + "type": "text", + "placeholders": { + "imageFormat": { + "type": "String" + } + } + }, "addImage": "Додати зображення", "@addImage": {}, "dataCopied": "Дані скопійовано до нового запису", diff --git a/lib/widgets/gallery/overview.dart b/lib/widgets/gallery/overview.dart index f66e0508..3c2bb5d9 100644 --- a/lib/widgets/gallery/overview.dart +++ b/lib/widgets/gallery/overview.dart @@ -36,6 +36,7 @@ class Gallery extends StatelessWidget { Widget build(BuildContext context) { final provider = Provider.of(context); final i18n = AppLocalizations.of(context); + final theme = Theme.of(context); return Padding( padding: const EdgeInsets.all(5), @@ -58,20 +59,30 @@ class Gallery extends StatelessWidget { context: context, ); }, - child: currentImage.url!.toLowerCase().endsWith('.avif') - ? AspectRatio( - aspectRatio: 1, - child: Center( - child: Text(i18n.galleryAvifNotSupported), + child: FadeInImage( + key: Key('image-${currentImage.id!}'), + placeholder: const AssetImage('assets/images/placeholder.png'), + image: NetworkImage(currentImage.url!), + fit: BoxFit.cover, + imageSemanticLabel: currentImage.description, + imageErrorBuilder: (context, error, stackTrace) { + final imageFormat = currentImage.url!.split('.').last.toUpperCase(); + return AspectRatio( + aspectRatio: 1, + child: Container( + color: theme.colorScheme.errorContainer, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 8, + children: [ + Icon(Icons.broken_image), + Text(i18n.imageFormatNotSupported(imageFormat)), + ] ), - ) - : FadeInImage( - key: Key('image-${currentImage.id!}'), - placeholder: const AssetImage('assets/images/placeholder.png'), - image: NetworkImage(currentImage.url!), - fit: BoxFit.cover, - imageSemanticLabel: currentImage.description, ), + ); + }, + ), ); }, ), @@ -91,6 +102,7 @@ class ImageDetail extends StatelessWidget { @override Widget build(BuildContext context) { final i18n = AppLocalizations.of(context); + final theme = Theme.of(context); return Container( key: Key('image-${image.id!}-detail'), padding: const EdgeInsets.all(10), @@ -101,11 +113,25 @@ class ImageDetail extends StatelessWidget { style: Theme.of(context).textTheme.headlineSmall, ), Expanded( - child: image.url!.toLowerCase().endsWith('.avif') - ? Center( - child: Text(i18n.galleryAvifNotSupportedDetail), - ) - : Image.network(image.url!, semanticLabel: image.description), + child: Image.network( + image.url!, + semanticLabel: image.description, + errorBuilder: (context, error, stackTrace) { + final imageFormat = image.url!.split('.').last.toUpperCase(); + + return Container( + color: theme.colorScheme.errorContainer, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + spacing: 8, + children: [ + Icon(Icons.broken_image), + Text(i18n.imageFormatNotSupportedDetail(imageFormat)) + ] + ), + ); + }, + ), ), Padding( padding: const EdgeInsets.symmetric(vertical: 8),