From caf3c029bf82b7208fe9923118dd00a1afb5df11 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Fri, 24 May 2024 05:17:16 +0200 Subject: [PATCH 1/2] Crop page: increase paddings --- packages/smooth_app/lib/pages/crop_page.dart | 100 ++++++++++-------- .../lib/pages/product/edit_image_button.dart | 21 ++-- 2 files changed, 68 insertions(+), 53 deletions(-) diff --git a/packages/smooth_app/lib/pages/crop_page.dart b/packages/smooth_app/lib/pages/crop_page.dart index c4afd928f5bc..9d6c6be91cce 100644 --- a/packages/smooth_app/lib/pages/crop_page.dart +++ b/packages/smooth_app/lib/pages/crop_page.dart @@ -179,47 +179,52 @@ class _CropPageState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - if (!_isErasing) - _IconButton( - iconData: Icons.rotate_90_degrees_ccw_outlined, - onPressed: () => setState( - () { - _controller.rotateLeft(); - _eraserModel.rotation = _controller.rotation; - }, + Padding( + padding: const EdgeInsetsDirectional.only( + top: SMALL_SPACE, + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + if (!_isErasing) + _IconButton( + iconData: Icons.rotate_90_degrees_ccw_outlined, + onPressed: () => setState( + () { + _controller.rotateLeft(); + _eraserModel.rotation = _controller.rotation; + }, + ), ), - ), - if (widget.cropHelper.enableEraser) - _IconButton( - iconData: _isErasing ? Icons.crop : Icons.brush, - color: _isErasing ? null : EraserPainter.color, - onPressed: () => setState( - () => _isErasing = !_isErasing, + if (widget.cropHelper.enableEraser) + _IconButton( + iconData: _isErasing ? Icons.crop : Icons.brush, + color: _isErasing ? null : EraserPainter.color, + onPressed: () => setState( + () => _isErasing = !_isErasing, + ), ), - ), - if (_isErasing) - _IconButton( - iconData: Icons.undo, - onPressed: _eraserModel.isEmpty - ? null - : () => setState( - () => _eraserModel.undo(), - ), - ), - if (!_isErasing) - _IconButton( - iconData: Icons.rotate_90_degrees_cw_outlined, - onPressed: () => setState( - () { - _controller.rotateRight(); - _eraserModel.rotation = _controller.rotation; - }, + if (_isErasing) + _IconButton( + iconData: Icons.undo, + onPressed: _eraserModel.isEmpty + ? null + : () => setState( + () => _eraserModel.undo(), + ), ), - ), - ], + if (!_isErasing) + _IconButton( + iconData: Icons.rotate_90_degrees_cw_outlined, + onPressed: () => setState( + () { + _controller.rotateRight(); + _eraserModel.rotation = _controller.rotation; + }, + ), + ), + ], + ), ), Expanded( child: Stack( @@ -275,12 +280,19 @@ class _CropPageState extends State { ], ), ), - Center( - child: EditImageButton( - iconData: widget.cropHelper.getProcessIcon(), - label: - widget.cropHelper.getProcessLabel(appLocalizations), - onPressed: () async => _saveImageAndPop(), + Padding( + padding: const EdgeInsets.symmetric( + horizontal: VERY_SMALL_SPACE, + vertical: SMALL_SPACE, + ), + child: SizedBox( + width: double.infinity, + child: EditImageButton( + iconData: widget.cropHelper.getProcessIcon(), + label: widget.cropHelper + .getProcessLabel(appLocalizations), + onPressed: () async => _saveImageAndPop(), + ), ), ), ], diff --git a/packages/smooth_app/lib/pages/product/edit_image_button.dart b/packages/smooth_app/lib/pages/product/edit_image_button.dart index e7ab6df11e32..722b8f050d47 100644 --- a/packages/smooth_app/lib/pages/product/edit_image_button.dart +++ b/packages/smooth_app/lib/pages/product/edit_image_button.dart @@ -36,17 +36,20 @@ class EditImageButton extends StatelessWidget { width: borderWidth!, ), ), + padding: MaterialStateProperty.all( + const EdgeInsets.symmetric( + vertical: LARGE_SPACE, + ), + ), + alignment: AlignmentDirectional.center, ), onPressed: onPressed, - label: SizedBox( - width: double.infinity, - child: Padding( - padding: EdgeInsets.all(borderWidth ?? 0), - child: AutoSizeText( - label, - maxLines: 2, - overflow: TextOverflow.ellipsis, - ), + label: Padding( + padding: EdgeInsets.all(borderWidth ?? 0), + child: AutoSizeText( + label, + maxLines: 2, + overflow: TextOverflow.ellipsis, ), ), ), From 8611b26025db25fb8260ae8889cd5570178b1054 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Wed, 19 Jun 2024 08:38:25 +0200 Subject: [PATCH 2/2] Fix: regression on Product image page --- packages/smooth_app/lib/pages/crop_page.dart | 2 +- .../lib/pages/product/edit_image_button.dart | 40 +++++++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/packages/smooth_app/lib/pages/crop_page.dart b/packages/smooth_app/lib/pages/crop_page.dart index 9d6c6be91cce..e7a832c5c718 100644 --- a/packages/smooth_app/lib/pages/crop_page.dart +++ b/packages/smooth_app/lib/pages/crop_page.dart @@ -287,7 +287,7 @@ class _CropPageState extends State { ), child: SizedBox( width: double.infinity, - child: EditImageButton( + child: EditImageButton.center( iconData: widget.cropHelper.getProcessIcon(), label: widget.cropHelper .getProcessLabel(appLocalizations), diff --git a/packages/smooth_app/lib/pages/product/edit_image_button.dart b/packages/smooth_app/lib/pages/product/edit_image_button.dart index 722b8f050d47..bc6441025528 100644 --- a/packages/smooth_app/lib/pages/product/edit_image_button.dart +++ b/packages/smooth_app/lib/pages/product/edit_image_button.dart @@ -9,12 +9,21 @@ class EditImageButton extends StatelessWidget { required this.label, required this.onPressed, this.borderWidth, - }); + }) : _centerContent = false; + + /// Centered version of the button. + const EditImageButton.center({ + required this.iconData, + required this.label, + required this.onPressed, + this.borderWidth, + }) : _centerContent = true; final IconData iconData; final String label; final VoidCallback onPressed; final double? borderWidth; + final bool _centerContent; @override Widget build(BuildContext context) { @@ -36,20 +45,25 @@ class EditImageButton extends StatelessWidget { width: borderWidth!, ), ), - padding: MaterialStateProperty.all( - const EdgeInsets.symmetric( - vertical: LARGE_SPACE, - ), - ), - alignment: AlignmentDirectional.center, + padding: _centerContent + ? MaterialStateProperty.all( + const EdgeInsets.symmetric( + vertical: LARGE_SPACE, + ), + ) + : null, + alignment: _centerContent ? AlignmentDirectional.center : null, ), onPressed: onPressed, - label: Padding( - padding: EdgeInsets.all(borderWidth ?? 0), - child: AutoSizeText( - label, - maxLines: 2, - overflow: TextOverflow.ellipsis, + label: SizedBox( + width: !_centerContent ? double.infinity : null, + child: Padding( + padding: EdgeInsets.all(borderWidth ?? 0), + child: AutoSizeText( + label, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), ), ), ),