Created
March 18, 2022 11:40
-
-
Save amosgyamfi/1852a73764ccc6790bed18f10057579a 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
// | |
// ChatEmojis.swift | |
// Created by Amos | |
// | |
import SwiftUI | |
struct ChatEmojis: View { | |
let letters = Array("ππ₯°ππππ€ππ€π°π₯°π") | |
@State private var enabled = false | |
@State private var dragAmount = CGSize.zero | |
var body: some View { | |
ZStack { | |
ForEach(0..<letters.count) { num in | |
Text(String(letters[num])) | |
.font(.largeTitle) | |
.offset(dragAmount) | |
.animation(.interpolatingSpring(stiffness: 170, damping: 15).delay(Double(num) / 10), value: dragAmount) | |
} | |
} | |
.scaleEffect(3) | |
.padding() | |
.gesture( | |
DragGesture() | |
.onChanged { dragAmount = $0.translation } | |
// _ ignore the value coming in this time | |
.onEnded { _ in | |
withAnimation{ | |
dragAmount = .zero | |
enabled.toggle() | |
} | |
} | |
) | |
} | |
} | |
struct ChatEmojis_Previews: PreviewProvider { | |
static var previews: some View { | |
ChatEmojis() | |
.preferredColorScheme(.dark) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment