Skip to content

Instantly share code, notes, and snippets.

@allfinlir
Created January 15, 2023 19:48
Show Gist options
  • Save allfinlir/2418be7f4029a589ad99c96dd2bc1c6c to your computer and use it in GitHub Desktop.
Save allfinlir/2418be7f4029a589ad99c96dd2bc1c6c to your computer and use it in GitHub Desktop.
struct WithAnimationPaymentChallenge: View {
@State private var scalePayment: Bool = false
@State private var moveUpAndRight: Bool = false
@State private var moveDownAndRight: Bool = false
var body: some View {
VStack {
Text("Payment App")
.font(.largeTitle)
.fontWeight(.semibold)
.padding(.bottom, 40)
RoundedRectangle(cornerRadius: 20)
.frame(width: 350, height: 150)
.foregroundColor(.gray)
.opacity(0.2)
.overlay(content: {
VStack(alignment: .leading, spacing: 15) {
Text("Payment Request")
.font(.title2)
.fontWeight(.semibold)
Text("Person XYZ wants you to transfer 100 dollars to their account.")
.font(.title3)
}
.padding()
})
.scaleEffect(scalePayment ? 0 : 1)
.offset(x: moveUpAndRight ? 45 : 0, y: moveUpAndRight ? -50 : 0)
.offset(x: moveDownAndRight ? 90 : 0, y: moveDownAndRight ? 650 : 0)
Spacer()
Button(action: {
withAnimation(.easeInOut(duration: 6)) {
scalePayment = true
}
withAnimation(.easeInOut(duration: 2)) {
moveUpAndRight = true
}
withAnimation(.easeInOut(duration: 4).delay(2)) {
moveDownAndRight = true
}
}, label: {
Text("Accept Request")
.font(.title)
.foregroundColor(.white)
.background(
Color.green
.frame(width: 230, height: 55)
.cornerRadius(10)
)
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment