Skip to content

Instantly share code, notes, and snippets.

@byaruhaf
Created September 26, 2023 02:24
Show Gist options
  • Save byaruhaf/f9e0ea605df8381e4997db15f28ff822 to your computer and use it in GitHub Desktop.
Save byaruhaf/f9e0ea605df8381e4997db15f28ff822 to your computer and use it in GitHub Desktop.
import SwiftUI
struct FullScreenView: View {
@Environment(\.dismiss) var dismiss
@State private var name = "Taylor"
var body: some View {
ZStack {
Color.primary.edgesIgnoringSafeArea(.all)
VStack {
TextField("Enter your name", text: $name)
.textFieldStyle(.roundedBorder)
.toolbar {
ToolbarItemGroup(placement: .keyboard) {
Button("Click me!") {
print("Clicked")
}
}
}
Button("Dismiss Modal") {
dismiss()
}
}
}
}
}
struct ContentView: View {
@State private var isPresented = false
var body: some View {
Button("Present!") {
isPresented.toggle()
}
.fullScreenCover(isPresented: $isPresented, content: FullScreenView.init)
}
}
#Preview {
ContentView()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment