Created
September 23, 2022 07:06
-
-
Save allfinlir/97d01aedae44f83006de09b80b0f5782 to your computer and use it in GitHub Desktop.
This file contains 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 BoxesLoadingView: View { | |
@State private var moveBoxeDown = false | |
@State private var moveBoxRight = false | |
@State private var moveBoxUp = false | |
@State private var moveAllBoxesLeft = false | |
@State private var refreshPage = false | |
var body: some View { | |
ZStack { | |
VStack(spacing: 0) { | |
HStack(spacing: 8) { | |
Rectangle() | |
.frame(width: 30, height: 30) | |
.foregroundColor(.gray) | |
.offset(y: moveBoxeDown ? 38 : 0) | |
.offset(x: moveBoxRight ? 114 : 0) | |
.offset(y: moveBoxUp ? -38 : 0) | |
Rectangle() | |
.frame(width: 30, height: 30) | |
.foregroundColor(.gray) | |
Rectangle() | |
.frame(width: 30, height: 30) | |
.foregroundColor(.gray) | |
} | |
.offset(x: moveAllBoxesLeft ? -38 : 0) | |
} | |
} | |
.onTapGesture { | |
withAnimation(.easeInOut(duration: 0.6).delay(0.3)) { | |
moveBoxeDown = true | |
} | |
withAnimation(.easeInOut(duration: 1.4).delay(0.9)) { | |
moveBoxRight = true | |
} | |
withAnimation(.easeInOut(duration: 0.6).delay(2.3)) { | |
moveBoxUp = true | |
} | |
withAnimation(.easeInOut(duration: 1).delay(2.9)) { | |
moveAllBoxesLeft = true | |
} | |
DispatchQueue.main.asyncAfter(deadline: .now() + 3) { | |
moveBoxeDown = false | |
moveBoxRight = false | |
moveBoxUp = false | |
moveAllBoxesLeft = false | |
} | |
} | |
} | |
} | |
struct BoxesLoadingView_Previews: PreviewProvider { | |
static var previews: some View { | |
BoxesLoadingView() | |
} | |
} |
akardas16
commented
Sep 23, 2022
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment