struct ContentView: View {
    @State private var isPresented = false

    var body: some View {
        Button("Present!") {
            self.isPresented.toggle()
        }
        // Full Screen Present
        .fullScreenCover(isPresented: $isPresented,
                         onDismiss: didDismiss,
                         content: {
            SubView()
        })
    }
    
    // View Dismiss Closer
    func didDismiss() {
        print("didDismiss!!")
    }
}

struct SubView: View {
    @Environment(\.presentationMode) var presentationMode // < IOS 15
    //@Environment(\.dismiss) var dismiss // >= IOS 15
    
    init() {
        print("SubView Init")
    }
    
    var body: some View {
        Text("SubView Sub View!!")
            .onTapGesture {
                presentationMode.wrappedValue.dismiss()
                //dismiss()
            }
    }
}

+ Recent posts