Skip to content

About NavigationView conflicts with other libraries #50

Description

@ByLiangCheng

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions