Skip to content

Instantly share code, notes, and snippets.

@Plnda
Last active September 1, 2020 17:45
Show Gist options
  • Save Plnda/a0734a72ef463828a69837b63fb7fdce to your computer and use it in GitHub Desktop.
Save Plnda/a0734a72ef463828a69837b63fb7fdce to your computer and use it in GitHub Desktop.
struct ContentView: View {
@State private var initialOffset: CGFloat = 350.0
@State private var initialOpacity: Double = 0.0
private let duration = 5.0
@ObservedObject var manager = MotionManager()
var body: some View {
GeometryReader(content: { geometry in
ZStack {
Image("background")
.resizable()
.scaledToFill()
.frame(width: geometry.size.width * 1.2, height: geometry.size.height * 1.2, alignment: .center)
.modifier(ParallaxModifier(magnitude: 20))
.ignoresSafeArea()
LinearGradient(gradient: Gradient(colors: [.clear, .black]), startPoint: UnitPoint(x: 0.5, y: 0.35), endPoint: UnitPoint(x: 0.5, y: 1))
VStack {
Spacer()
Text("Enjoy the world")
.font(.largeTitle)
.fontWeight(.semibold)
.foregroundColor(.white)
.padding(.bottom, 16)
.offset(x: initialOffset, y: 0)
.opacity(initialOpacity)
Text("We'll help you find the best experiences & adventures.")
.font(.headline)
.fontWeight(.light)
.foregroundColor(.white)
.multilineTextAlignment(.center)
.lineLimit(2)
.padding(.horizontal, 32.0)
.offset(x: initialOffset * 2.5, y: 0)
.opacity(initialOpacity)
Button("Continue", action: {})
.frame(width: 65, height: 65, alignment: .center)
.foregroundColor(.accentColor)
.background(Color.white)
.cornerRadius(8)
.opacity(initialOpacity)
.padding(.all, 16)
}
.modifier(ParallaxModifier(magnitude: 30))
.padding()
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .bottom)
}
.frame(width: geometry.size.width, height: geometry.size.height, alignment: .center)
})
.onAppear {
withAnimation(.easeInOut(duration: 1)) {
self.initialOffset = 0
self.initialOpacity = 1
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment