Skip to content

Commit

Permalink
fix: 4924 - OCR page minor UI improvements (#5017)
Browse files Browse the repository at this point in the history
Impacted files:
* `edit_ocr_page.dart`: uncropped the "no image" placeholder; padded the text; reshaped the "add" button
* `picture_not_found.dart`: minor refactoring
* `product_image_local_button.dart`: removed a confusing parameter
* `product_image_viewer.dart`: removed a confusing parameter
  • Loading branch information
monsieurtanuki committed Jan 29, 2024
1 parent acbe694 commit 7e711d1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import 'package:smooth_app/helpers/app_helper.dart';

/// Displays a default asset as a _picture not found_ image.
class PictureNotFound extends StatelessWidget {
const PictureNotFound();
const PictureNotFound({this.boxFit = BoxFit.cover});

static const String NOT_FOUND_ASSET = 'assets/product/product_not_found.svg';
final BoxFit boxFit;

static const String _notFoundAsset = 'assets/product/product_not_found.svg';

@override
Widget build(BuildContext context) => SvgPicture.asset(
NOT_FOUND_ASSET,
fit: BoxFit.cover,
_notFoundAsset,
fit: boxFit,
package: AppHelper.APP_PACKAGE,
);
}
15 changes: 9 additions & 6 deletions packages/smooth_app/lib/pages/product/edit_ocr_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,17 @@ class _EditOcrPageState extends State<EditOcrPage> with UpToDateMixin {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
SizedBox(
width: size.width,
height: size.height / 4,
child: const PictureNotFound(),
child: const PictureNotFound(boxFit: BoxFit.fitHeight),
),
Text(
appLocalizations.ocr_image_upload_instruction,
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
Padding(
padding: const EdgeInsets.all(LARGE_SPACE),
child: Text(
appLocalizations.ocr_image_upload_instruction,
style: Theme.of(context).textTheme.bodyMedium,
textAlign: TextAlign.center,
),
)
],
),
Expand Down Expand Up @@ -233,7 +237,6 @@ class _EditOcrPageState extends State<EditOcrPage> with UpToDateMixin {
padding:
const EdgeInsets.symmetric(horizontal: SMALL_SPACE),
child: ProductImageLocalButton(
firstPhoto: !transientFile.isImageAvailable(),
barcode: widget.product.barcode!,
imageField: _helper.getImageField(),
language: language,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import 'package:smooth_app/pages/product/edit_image_button.dart';
/// Button asking for a "local" photo (new from camera, existing from gallery).
class ProductImageLocalButton extends StatefulWidget {
const ProductImageLocalButton({
required this.firstPhoto,
required this.barcode,
required this.imageField,
required this.language,
required this.isLoggedInMandatory,
this.borderWidth,
});

final bool firstPhoto;
final String barcode;
final ImageField imageField;
final OpenFoodFactsLanguage language;
Expand All @@ -33,9 +31,8 @@ class _ProductImageLocalButtonState extends State<ProductImageLocalButton> {
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);
return EditImageButton(
iconData: widget.firstPhoto ? Icons.add : Icons.add_a_photo,
label:
widget.firstPhoto ? appLocalizations.add : appLocalizations.capture,
iconData: Icons.add_a_photo,
label: appLocalizations.capture,
onPressed: () async => _actionNewImage(context),
borderWidth: widget.borderWidth,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ class _ProductImageViewerState extends State<ProductImageViewer>
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: SMALL_SPACE),
child: ProductImageLocalButton(
firstPhoto: imageProvider == null,
barcode: barcode,
imageField: widget.imageField,
language: widget.language,
Expand Down

0 comments on commit 7e711d1

Please sign in to comment.