Just tried out the modal and seems really nice to work with. Kind of new to SwiftUI (and iOS development in general) and having some issues getting the preview to work when I extract the MyModalView struct to a separate file.
Getting Missing argument for parameter 'dismiss' in call and unsure how to resolve this in the preview.
// MyModalView.swift
import SwiftUI
struct MyModalView: View {
var dismiss: () -> ()
var body: some View {
Button(action: dismiss) {
Text("Dismiss")
}
}
}
struct MyModalView_Previews: PreviewProvider {
static var previews: some View {
MyModalView() // Missing argument for parameter 'dismiss' in call
}
}
// ContentView.swift
import SwiftUI
import ModalView
struct ContentView: View {
var body: some View {
ModalPresenter {
ModalLink(destination: MyModalView.init(dismiss:)) {
Text("Main view")
}
}
}
}
struct MyModalView: View {
var dismiss: () -> ()
var body: some View {
Button(action: dismiss) {
Text("Dismiss")
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Hey,
Just tried out the modal and seems really nice to work with. Kind of new to SwiftUI (and iOS development in general) and having some issues getting the preview to work when I extract the
MyModalView
struct to a separate file.Getting
Missing argument for parameter 'dismiss' in call
and unsure how to resolve this in the preview.