Last active
November 18, 2022 18:04
-
-
Save alpennec/4a794d793ce3cab03c194fccf9e91740 to your computer and use it in GitHub Desktop.
For Christian
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@State var show: Bool = false | |
var body: some View { | |
ZStack { | |
Button { | |
withAnimation(.easeInOut(duration: 3)) { | |
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() | |
.padding(.bottom, proxy.safeAreaInsets.bottom) | |
.background( | |
Color.green | |
.cornerRadius(20.0) | |
) | |
.frame(maxWidth: .infinity) | |
.transition(.move(edge: .bottom)) | |
} | |
} | |
.ignoresSafeArea() | |
} | |
} | |
} | |
} | |
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