Created
October 21, 2022 18:59
-
-
Save amosgyamfi/71546754e7b04a152bbe57ec0708b338 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
// Hamburger to Back | |
// | |
import SwiftUI | |
struct HamburgerToBack: View { | |
@State private var isChanging = false | |
var body: some View { | |
VStack(spacing: isChanging ? -12 : 14){ | |
RoundedRectangle(cornerRadius: 5) | |
.frame(width: isChanging ? 48 : 64, height: 10) | |
.rotationEffect(.degrees(isChanging ? -30 : 0), anchor: .leading) | |
.offset(x: isChanging ? -16 : 0) | |
RoundedRectangle(cornerRadius: 5) | |
.frame(width: 64, height: 10) | |
.scaleEffect(x: isChanging ? 1.2 : 1, anchor: .leading) | |
RoundedRectangle(cornerRadius: 5) | |
.frame(width: isChanging ? 48 : 64, height: 10) | |
.rotationEffect(.degrees(isChanging ? 30 : 0), anchor: .leading) | |
.offset(x: isChanging ? -16 : 0) | |
} | |
.onTapGesture { | |
withAnimation(.interpolatingSpring(stiffness: 300, damping: 15)){ | |
isChanging.toggle() | |
} | |
} | |
} | |
} | |
struct HamburgerToBack_Previews: PreviewProvider { | |
static var previews: some View { | |
HamburgerToBack() | |
.preferredColorScheme(.dark) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment