CustomModalView icon indicating copy to clipboard operation
CustomModalView copied to clipboard

Strange behavior within NavigationViews

Open tiltowait opened this issue 4 years ago • 2 comments

First off, I really like this package. Unfortunately, it behaves strangely with NavigationViews: content appears to "fly in" from off the screen. Demo code:

import SwiftUI
import CustomModalView

struct Tester: View {
  
  @State private var customModal = false
  
  var body: some View {
    NavigationView {
      List {
        Button("Click me") {
          customModal.toggle()
        }
      }
      .listStyle(InsetGroupedListStyle())
      .navigationTitle("Hi")
    }
    .modal(isPresented: $customModal) {
      Text("Hi")
        .padding()
    }
  }
}

Moving the view modifier somewhere else—such as attaching it to the Button fixes the "fly in" issue, but then the modal only displays over the button, not the full screen.

Tested on Xcode 12.5 and iOS 14.6.

tiltowait avatar Jun 18 '21 06:06 tiltowait

I'm getting several [LayoutConstraints] Unable to simultaneously satisfy constraints. warnings when a modal displays a VStack > NavigationView > Form

saul-melo avatar Mar 12 '22 22:03 saul-melo

Setting the NavigationView .navigationViewStyle(.stack) property got rid of the layout warnings I mentioned - perhaps this will work with your problem

https://developer.apple.com/forums/thread/673113

saul-melo avatar Mar 12 '22 22:03 saul-melo