From c1751286525398c958d39aaefb1a60deb1155756 Mon Sep 17 00:00:00 2001 From: Ye Lwin Oo Date: Mon, 5 Feb 2024 10:17:27 +0630 Subject: [PATCH] updated: changed image crop screen to image preview screen full height and width --- lib/src/camera_display.dart | 72 +++++++++---------- .../crop_image/crop_image.dart | 2 +- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/lib/src/camera_display.dart b/lib/src/camera_display.dart index 3e99805..330a2b4 100644 --- a/lib/src/camera_display.dart +++ b/lib/src/camera_display.dart @@ -144,17 +144,13 @@ class CustomCameraDisplayState extends State { buildFlashIcons(), buildPickImageContainer(whiteColor, context), ] else ...[ - Align( - alignment: Alignment.topCenter, - child: Container( - color: whiteColor, - height: double.infinity, - width: double.infinity, - child: buildCrop(selectedImage), - ), + Container( + color: whiteColor, + height: double.infinity, + width: double.infinity, + child: Image.file(selectedImage), ) ], - ], ), ), @@ -233,22 +229,24 @@ class CustomCameraDisplayState extends State { ); } - CustomCrop buildCrop(File selectedImage) { - String path = selectedImage.path; - bool isThatVideo = path.contains("mp4", path.length - 5); - return CustomCrop( - image: selectedImage, - isThatImage: !isThatVideo, - key: cropKey, - alwaysShowGrid: true, - paintColor: widget.appTheme.primaryColor, - ); - } + // CustomCrop buildCrop(File selectedImage) { + // String path = selectedImage.path; + // bool isThatVideo = path.contains("mp4", path.length - 5); + // return CustomCrop( + // image: selectedImage, + // isThatImage: !isThatVideo, + // key: cropKey, + // alwaysShowGrid: false, + // paintColor: widget.appTheme.primaryColor, + // ); + // } AppBar appBar() { Color whiteColor = widget.appTheme.primaryColor; Color blackColor = widget.appTheme.focusColor; File? selectedImage = widget.selectedCameraImage.value; + double width = MediaQuery.sizeOf(context).width; + double height = MediaQuery.sizeOf(context).height; return AppBar( backgroundColor: whiteColor, elevation: 0, @@ -258,17 +256,17 @@ class CustomCameraDisplayState extends State { Navigator.of(context).maybePop(null); }, ), - title: selectedImage == null ? null: const Text('Crop Image'), + title: selectedImage == null ? null: const Text('Preview Image'), centerTitle: true, actions: [ - AnimatedSwitcher( + if(selectedImage != null ) AnimatedSwitcher( duration: const Duration(seconds: 1), switchInCurve: Curves.easeIn, child: Visibility( visible: videoRecordFile != null || selectedImage != null, child: IconButton( - icon: const Icon(Icons.arrow_forward_rounded, - color: Colors.blue, size: 30), + icon: Icon(Icons.check, + color: blackColor, size: 30), onPressed: () async { if (videoRecordFile != null) { Uint8List byte = await videoRecordFile!.readAsBytes(); @@ -290,29 +288,25 @@ class CustomCameraDisplayState extends State { Navigator.of(context).maybePop(details); } } else if (selectedImage != null) { - File? croppedByte = await cropImage(selectedImage); - if (croppedByte != null) { - Uint8List byte = await croppedByte.readAsBytes(); - - SelectedByte selectedByte = SelectedByte( + Uint8List imageByte = await selectedImage.readAsBytes(); + SelectedByte selectedByte = SelectedByte( isThatImage: true, - selectedFile: croppedByte, - selectedByte: byte, + selectedFile: selectedImage, + selectedByte: imageByte, ); SelectedImagesDetails details = SelectedImagesDetails( selectedFiles: [selectedByte], multiSelectionMode: false, - aspectRatio: 1.0, + aspectRatio: width / height, ); if (!mounted) return; - - if (widget.callbackFunction != null) { - await widget.callbackFunction!(details); - } else { - Navigator.of(context).maybePop(details); - } - } + Navigator.of(context).maybePop(details); + // if (widget.callbackFunction != null) { + // await widget.callbackFunction!(details); + // } else { + // Navigator.of(context).maybePop(details); + // } } }, ), diff --git a/lib/src/custom_packages/crop_image/crop_image.dart b/lib/src/custom_packages/crop_image/crop_image.dart index 9c9b0fa..769d86f 100644 --- a/lib/src/custom_packages/crop_image/crop_image.dart +++ b/lib/src/custom_packages/crop_image/crop_image.dart @@ -158,7 +158,7 @@ class CustomCropState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { - double width = MediaQuery.of(context).size.width; + double width = MediaQuery.sizeOf(context).width; return SizedBox( width: width, child: ConstrainedBox(