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

feat: Crop page: increase paddings #5279

Merged
merged 2 commits into from
Jun 20, 2024
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
100 changes: 56 additions & 44 deletions packages/smooth_app/lib/pages/crop_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,47 +179,52 @@ class _CropPageState extends State<CropPage> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
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: <Widget>[
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(
Expand Down Expand Up @@ -275,12 +280,19 @@ class _CropPageState extends State<CropPage> {
],
),
),
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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it's a good idea to add a padding there, as it means less space for the image, that is already not that big.

),
child: SizedBox(
width: double.infinity,
child: EditImageButton.center(
iconData: widget.cropHelper.getProcessIcon(),
label: widget.cropHelper
.getProcessLabel(appLocalizations),
onPressed: () async => _saveImageAndPop(),
),
),
),
],
Expand Down
21 changes: 19 additions & 2 deletions packages/smooth_app/lib/pages/product/edit_image_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines +12 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't a unique constructor with this.centerContent = false be easier to maintain?


final IconData iconData;
final String label;
final VoidCallback onPressed;
final double? borderWidth;
final bool _centerContent;

@override
Widget build(BuildContext context) {
Expand All @@ -36,10 +45,18 @@ class EditImageButton extends StatelessWidget {
width: borderWidth!,
),
),
padding: _centerContent
? MaterialStateProperty.all(
const EdgeInsets.symmetric(
vertical: LARGE_SPACE,
),
)
: null,
alignment: _centerContent ? AlignmentDirectional.center : null,
),
onPressed: onPressed,
label: SizedBox(
width: double.infinity,
width: !_centerContent ? double.infinity : null,
child: Padding(
padding: EdgeInsets.all(borderWidth ?? 0),
child: AutoSizeText(
Expand Down
Loading