Skip to content

Instantly share code, notes, and snippets.

@robb
Forked from christianselig/BottomSheet.swift
Last active November 18, 2022 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robb/ea3cb47136ee8e01faf4527f47833b16 to your computer and use it in GitHub Desktop.
Save robb/ea3cb47136ee8e01faf4527f47833b16 to your computer and use it in GitHub Desktop.
import SwiftUI
struct ContentView: View {
@State var show: Bool = false
var body: some View {
ZStack {
Button {
show.toggle()
} label: {
Text("Show")
}
GeometryReader { proxy in
ZStack(alignment: .bottom) {
Color.clear
if show {
Text("Hello once upon a time there was a duck named Ducky who went on to drink lots of juice boxes and live happily ever after")
.padding()
.frame(maxWidth: .infinity, alignment: .center)
.padding(.bottom, proxy.safeAreaInsets.bottom)
.background(
Color.green
.cornerRadius(20.0)
)
.transition(.move(edge: .bottom))
.zIndex(1)
}
}
.edgesIgnoringSafeArea(.bottom)
}
.border(.red)
.animation(.linear(duration: 1.0), value: show)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment