Skip to content

Commit

Permalink
fix: #1376 - fit/zoom ingredient extraction photo (#1522)
Browse files Browse the repository at this point in the history
  • Loading branch information
cli1005 authored Apr 9, 2022
1 parent 04cf585 commit 9eb925e
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/smooth_app/lib/pages/product/edit_ingredients_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,17 @@ class _EditIngredientsPageState extends State<EditIngredientsPage> {
final List<Widget> children = <Widget>[];

if (_imageProvider != null) {
children.add(ConstrainedBox(
constraints: const BoxConstraints.expand(),
child: Image(
image: _imageProvider!,
fit: BoxFit.cover,
children.add(
ConstrainedBox(
constraints: const BoxConstraints.expand(),
child: _buildZoomableImage(_imageProvider!),
),
));
);
} else {
if (widget.imageIngredientsUrl != null) {
children.add(ConstrainedBox(
constraints: const BoxConstraints.expand(),
child: Image(
fit: BoxFit.cover,
image: NetworkImage(widget.imageIngredientsUrl!),
),
child: _buildZoomableImage(NetworkImage(widget.imageIngredientsUrl!)),
));
} else {
children.add(Container(color: Colors.white));
Expand Down Expand Up @@ -231,6 +227,15 @@ class _EditIngredientsPageState extends State<EditIngredientsPage> {
),
);
}

Widget _buildZoomableImage(ImageProvider imageSource) {
return InteractiveViewer(
boundaryMargin: const EdgeInsets.fromLTRB(20, 10, 20, 200),
minScale: 0.1,
maxScale: 5,
child: Image(fit: BoxFit.contain, image: imageSource),
);
}
}

class _EditIngredientsBody extends StatelessWidget {
Expand Down

0 comments on commit 9eb925e

Please sign in to comment.