Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created March 18, 2022 11:40
Show Gist options
  • Save amosgyamfi/1852a73764ccc6790bed18f10057579a to your computer and use it in GitHub Desktop.
Save amosgyamfi/1852a73764ccc6790bed18f10057579a to your computer and use it in GitHub Desktop.
//
// 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