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

Crop area is not displayed in a sheet view #13

Closed
pavelpugachh opened this issue May 18, 2024 · 6 comments
Closed

Crop area is not displayed in a sheet view #13

pavelpugachh opened this issue May 18, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@pavelpugachh
Copy link

pavelpugachh commented May 18, 2024

Hi!

When I use SwiftyCropView inside a sheet view like in the picture below, the crop area is almost always not displayed (but has been shown a few times).

Screenshot 2024-05-18 at 16 08 31

But it works fine if I use it in a sheet view hierarchy like this.

Screenshot 2024-05-18 at 16 10 44
@benedom
Copy link
Owner

benedom commented May 21, 2024

Hi, can you specify the issue a little bit more?

  • Device you are using
  • iOS-Version
  • Swift-Version
  • Xcode-Version

Does the issue also persist when you use the demo of SwiftyCrop? In the demo it is presented as fullScreenCover just like in your example.

@benedom benedom added the bug Something isn't working label May 21, 2024
@pavelpugachh
Copy link
Author

pavelpugachh commented May 21, 2024

  • iPhone 14 Pro
  • 17.4.1 (real device) / 17.2 (simulator)
  • Swift 5
  • Xcode 15.3 (15E204a)

To reproduce the issue:

  1. Create view just like in the demo
  2. Display created view using sheet modifier

When I use it like in the demo it's OK.

@benedom
Copy link
Owner

benedom commented May 21, 2024

It seems that SwiftUI is having problems displaying the mask of the ZStack when using the .sheet modifier. To solve this you can wrap the SwiftyCropView inside a NavigationView or NavigationStack when presented. This will show the cropping mask.

I suggest something like this:

.sheet(isPresented: $showImageCropper) {
            NavigationView {
                if let selectedImage = selectedImage {
                    SwiftyCropView(
                        imageToCrop: selectedImage,
                        maskShape: selectedShape,
                        configuration: SwiftyCropConfiguration(
                            maxMagnificationScale: maxMagnificationScale,
                            maskRadius: maskRadius,
                            cropImageCircular: cropImageCircular,
                            rotateImage: rotateImage,
                            zoomSensitivity: zoomSensitivity
                        )
                    ) { croppedImage in
                        // Do something with the returned, cropped image
                        self.selectedImage = croppedImage
                    }
                    .interactiveDismissDisabled()
                }
            }
        }

@benedom benedom closed this as completed May 21, 2024
@g3rd
Copy link

g3rd commented Jun 13, 2024

FYI: the bug is still present with the NavigationStack you must use a NavigationView

@benedom
Copy link
Owner

benedom commented Jun 13, 2024

@g3rd I will add this as an info in the README

@g3rd
Copy link

g3rd commented Jun 13, 2024

@benedom thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants