Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Image extraction screen #3026

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1653,5 +1653,13 @@
"offline_data": "Offline Data",
"@offline_data": {
"description": "App bar tile for offline data page"
},
"ocr_image_upload_instruction" : "Upload an image to automatically extract the provided information",
"@ocr_image_upload_instruction" : {
"description" : "Message shown when there is no image on ocr extraction page"
},
"upload_image" : "Upload Photo",
"@upload_image" : {
"description" : "Message shown on asking to upload image"
}
}
29 changes: 26 additions & 3 deletions packages/smooth_app/lib/pages/product/edit_ingredients_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class _EditOcrPageState extends State<EditOcrPage> {
@override
Widget build(BuildContext context) {
final AppLocalizations appLocalizations = AppLocalizations.of(context);

final Size size = MediaQuery.of(context).size;
final List<Widget> children = <Widget>[];

if (_imageProvider != null) {
Expand All @@ -178,7 +178,27 @@ class _EditOcrPageState extends State<EditOcrPage> {
),
);
} else {
children.add(Container(color: Colors.white));
children.add(
Container(
alignment: Alignment.center,
margin: EdgeInsets.only(bottom: size.height * 0.25),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(
Icons.image_not_supported,
size: size.height / 4,
),
Text(
appLocalizations.ocr_image_upload_instruction,
style: Theme.of(context).textTheme.bodyText2,
textAlign: TextAlign.center,
)
],
),
),
);
}
}

Expand Down Expand Up @@ -292,7 +312,10 @@ class _OcrWidget extends StatelessWidget {
),
child: SmoothActionButtonsBar(
positiveAction: SmoothActionButton(
text: helper.getActionRefreshPhoto(appLocalizations),
text: (hasImageProvider ||
helper.getImageUrl(product) != null)
? helper.getActionRefreshPhoto(appLocalizations)
: appLocalizations.upload_image,
onPressed: () => onTapGetImage(true),
),
),
Expand Down