Skip to content

Commit

Permalink
updated: changed image crop screen to image preview screen full heigh…
Browse files Browse the repository at this point in the history
…t and width
  • Loading branch information
YeLwinOo-Steve committed Feb 5, 2024
1 parent 0f42167 commit c175128
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 40 deletions.
72 changes: 33 additions & 39 deletions lib/src/camera_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,13 @@ class CustomCameraDisplayState extends State<CustomCameraDisplay> {
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),
)
],

],
),
),
Expand Down Expand Up @@ -233,22 +229,24 @@ class CustomCameraDisplayState extends State<CustomCameraDisplay> {
);
}

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,
Expand All @@ -258,17 +256,17 @@ class CustomCameraDisplayState extends State<CustomCameraDisplay> {
Navigator.of(context).maybePop(null);
},
),
title: selectedImage == null ? null: const Text('Crop Image'),
title: selectedImage == null ? null: const Text('Preview Image'),
centerTitle: true,
actions: <Widget>[
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();
Expand All @@ -290,29 +288,25 @@ class CustomCameraDisplayState extends State<CustomCameraDisplay> {
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);
// }
}
},
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/custom_packages/crop_image/crop_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class CustomCropState extends State<CustomCrop> 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(
Expand Down

0 comments on commit c175128

Please sign in to comment.