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

About NavigationView conflicts with other libraries #50

Open
ByLiangCheng opened this issue Jul 15, 2024 · 2 comments
Open

About NavigationView conflicts with other libraries #50

ByLiangCheng opened this issue Jul 15, 2024 · 2 comments
Assignees

Comments

@ByLiangCheng
Copy link

Hello, when I use NavigationView 1.1.3 and https://github.com/guoyingtao/Mantis 2.21.0 at the same time, NavigationView will cause drag errors in Mantis

When NavigationView is not used:

7_1721081055.mp4

After using NavigationView:

6_1721081051.mp4

Code Sample:

import Mantis
import MijickNavigationView
import SwiftUI

@main
struct TestMantisDragApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .implementNavigationView()
                .preferredColorScheme(.light)
        }
    }
}

struct ContentView: NavigatableView {
    @State var image: UIImage? = UIImage(named: "EnglishImage")

    var body: some View {
        ImageCropper(image: $image)
            .ignoresSafeArea()
    }
}

#Preview {
    ContentView()
}


struct ImageCropper: UIViewControllerRepresentable {
    @Binding var image: UIImage?

    @Environment(\.presentationMode) var presentationMode

    class Coordinator: CropViewControllerDelegate {
        var parent: ImageCropper

        init(_ parent: ImageCropper) {
            self.parent = parent
        }

        func cropViewControllerDidCrop(_ cropViewController: Mantis.CropViewController, cropped: UIImage, transformation: Transformation, cropInfo: CropInfo) {
            parent.image = cropped
            print("transformation is \(transformation)")
            parent.presentationMode.wrappedValue.dismiss()
        }

        func cropViewControllerDidCancel(_ cropViewController: Mantis.CropViewController, original: UIImage) {
            parent.presentationMode.wrappedValue.dismiss()
        }
    }

    func makeCoordinator() -> Coordinator {
        Coordinator(self)
    }

    func makeUIViewController(context: Context) -> UIViewController {
        makeCustom(context: context)
    }

    func updateUIViewController(_ uiViewController: UIViewController, context: Context) {}
}

extension ImageCropper {
    func makeCustom(context: Context) -> UIViewController {
        var config = Mantis.Config()
        config.cropToolbarConfig.mode = .normal
        let cropViewController = Mantis.cropViewController(image: image!, config: config)
        return cropViewController
    }
}

Test image:

EnglishImage

Steps to reproduce:

When the line “.implementNavigationView()” is commented, it works fine. When it is added, the problem occurs

This problem does not appear when previewing with #Preview. I only discovered it when I was packaging the simulator or debugging on the real device. I am very confused now

@FulcrumOne
Copy link
Contributor

Hey @ByLiangCheng,

I'll check it at the beginning of next week as I'm literally swamped with work this week

Sorry for this and have a good day!

@FulcrumOne FulcrumOne self-assigned this Jul 17, 2024
@ByLiangCheng
Copy link
Author

Thank you, don't worry, I found another solution. Now there is no problem in presenting the view corresponding to the Mantis library through fullScreenCover

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants