Skip to content

Commit

Permalink
Allow to retake a picture
Browse files Browse the repository at this point in the history
  • Loading branch information
g123k committed Jan 17, 2025
1 parent 8d3344a commit af8adc6
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 3 deletions.
Binary file modified packages/smooth_app/assets/fonts/SmoothIcons.ttf
Binary file not shown.
7 changes: 7 additions & 0 deletions packages/smooth_app/assets/fonts/icons/camera_restart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions packages/smooth_app/assets/fonts/icons/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1831,6 +1831,20 @@
"search": [
"pinch_to_zoom"
]
},
{
"uid": "96b379370af441badd08ee4d3350df1f",
"css": "camera_restart",
"code": 59522,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M606 50C634 50 660.7 61.7 679.7 82.3L742.1 150.1 900 150.1C955 150.1 1000 195.1 1000 250.1L1000 850.1C1000 905.1 955 950.1 900 950.1L100 950.1C45 950.1 0 905.1 0 850.1L0 250.1C0 195.1 45 150.1 100 150.1L258.2 150.1 320.2 82.5C339.2 61.9 365.9 50.2 393.8 50.2ZM454.1 260.4L454.1 314.3C406.8 323.2 361.6 345.9 325.2 382.3 228.8 478.7 228.8 636.2 325.2 732.6 421.6 829 579.1 829 675.5 732.6 760 648.2 770.8 517 707 420.8 698.9 408.5 684.8 401.5 670.1 402.4 655.3 403.3 642.2 412 635.6 425.2 629 438.4 630 454.1 638.2 466.4 680.6 530.4 673.9 617.4 617.1 674.2 552.3 739.1 448.4 739.1 383.6 674.2 318.8 609.4 318.8 505.5 383.6 440.7 404 420.2 428.4 406.5 454.1 399L454.1 445.8C454.1 460.9 472.5 468.5 483.2 457.8L551.4 389.6C564.4 382.5 572.5 369 572.8 354.3 573.1 339.5 565.5 325.7 552.9 318.1L483.2 248.4C472.4 237.6 454.1 245.3 454.1 260.4Z",
"width": 1000
},
"search": [
"camera_restart"
]
}
]
}
Binary file modified packages/smooth_app/assets/fonts/icons/icons.sketch
Binary file not shown.
4 changes: 4 additions & 0 deletions packages/smooth_app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,10 @@
"@crop_page_action_local_message": {
"description": "The save of the picture locally failed - error dialog message"
},
"crop_page_action_retake": "Retake a photo",
"@crop_page_action_retake": {
"description": "Button which allows users to retake a photo."
},
"crop_page_too_small_image_title": "The image is too small!",
"@crop_page_too_small_image_title": {
"description": "Title of a dialog warning the user that the image is too small for upload"
Expand Down
30 changes: 30 additions & 0 deletions packages/smooth_app/lib/pages/crop_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import 'package:smooth_app/pages/prices/eraser_painter.dart';
import 'package:smooth_app/pages/product/common/product_refresher.dart';
import 'package:smooth_app/pages/product/edit_image_button.dart';
import 'package:smooth_app/pages/product/may_exit_page_helper.dart';
import 'package:smooth_app/resources/app_icons.dart' as icons;
import 'package:smooth_app/widgets/smooth_app_bar.dart';
import 'package:smooth_app/widgets/smooth_scaffold.dart';
import 'package:smooth_app/widgets/will_pop_scope.dart';
Expand All @@ -39,6 +40,7 @@ class CropPage extends StatefulWidget {
required this.isLoggedInMandatory,
this.initialCropRect,
this.initialRotation,
this.onRetakePhoto,
});

/// The initial input file we start with.
Expand All @@ -55,6 +57,8 @@ class CropPage extends StatefulWidget {

final CropHelper cropHelper;

final Future<File?> Function()? onRetakePhoto;

@override
State<CropPage> createState() => _CropPageState();
}
Expand Down Expand Up @@ -166,6 +170,32 @@ class _CropPageState extends State<CropPage> {
widget.cropHelper.getPageTitle(appLocalizations),
maxLines: 2,
),
actions: <Widget>[
if (widget.onRetakePhoto != null)
Padding(
padding: const EdgeInsetsDirectional.only(end: 8.5),
child: IconButton(
icon: const icons.Camera.restart(),
tooltip: appLocalizations.crop_page_action_retake,
onPressed: () async {
final File? file = await widget.onRetakePhoto?.call();
if (file != null && context.mounted) {
Navigator.of(context).pushReplacement(
MaterialPageRoute<CropParameters>(
builder: (BuildContext context) => CropPage(
inputFile: file,
initiallyDifferent: widget.initiallyDifferent,
cropHelper: widget.cropHelper,
isLoggedInMandatory: widget.isLoggedInMandatory,
onRetakePhoto: widget.onRetakePhoto,
),
),
);
}
},
),
),
],
),
backgroundColor: Colors.black,
body: _progress != null
Expand Down
7 changes: 5 additions & 2 deletions packages/smooth_app/lib/pages/image_crop_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,17 @@ Future<CropParameters?> confirmAndUploadNewImage(
if (!context.mounted) {
return null;
}
return Navigator.push<CropParameters>(
context,
return Navigator.of(context).push<CropParameters>(
MaterialPageRoute<CropParameters>(
builder: (BuildContext context) => CropPage(
inputFile: File(fullPhoto.path),
initiallyDifferent: true,
isLoggedInMandatory: isLoggedInMandatory,
cropHelper: cropHelper,
onRetakePhoto: () => pickImageFile(
context,
forcedSource: forcedSource,
).then((XFile? file) => file != null ? File(file.path) : null),
),
fullscreenDialog: true,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class _PhotoRowDate extends StatelessWidget {

@override
Widget build(BuildContext context) {
if (!transientFile.isImageAvailable()) {
if (!transientFile.isImageAvailable() ||
transientFile.uploadedDate == null) {
return EMPTY_WIDGET;
}

Expand Down
8 changes: 8 additions & 0 deletions packages/smooth_app/lib/resources/app_icons.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,14 @@ class Camera extends AppIcon {
super.semanticLabel,
super.key,
}) : super._(_IconsFont.camera_happy);

const Camera.restart({
super.color,
super.size,
super.shadow,
super.semanticLabel,
super.key,
}) : super._(_IconsFont.camera_restart);
}

class Categories extends AppIcon {
Expand Down
2 changes: 2 additions & 0 deletions packages/smooth_app/lib/resources/app_icons_font.dart
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ class _IconsFont {
IconData(0xe880, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData pinch_to_zoom =
IconData(0xe881, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData camera_restart =
IconData(0xe882, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData share_cupertino =
IconData(0xe8a4, fontFamily: _kFontFam, fontPackage: _kFontPkg);
static const IconData share_material =
Expand Down

0 comments on commit af8adc6

Please sign in to comment.