Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created September 10, 2021 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amosgyamfi/98754f6f328b2c0cdd69d04933ec718c to your computer and use it in GitHub Desktop.
Save amosgyamfi/98754f6f328b2c0cdd69d04933ec718c to your computer and use it in GitHub Desktop.
//
// ContentView.swift
// AnimatedEmojis
//
// Created by Amos Gyamfi on 5.9.2021.
//
import SwiftUI
struct BeatingHeart: View {
@State private var beating = false
var body: some View {
VStack {
Text("Beating Heart")
.font(.title)
Text("A heart with vibration / movement lines above it, indicating it is a beating heart. This emoji is intended to be used as a beating heart representing either life, or love.")
.multilineTextAlignment(.center)
Spacer()
VStack(spacing: -20) {
if #available(iOS 15.0, *) {
HStack {
Image("left_signal")
.offset(x: beating ? -5 : 0, y: beating ? -20 : 0)
Image("right_signal")
.offset(x: beating ? 5 : 0, y: beating ? -20 : 0)
}
.clipShape(Rectangle()
.offset(y: beating ? 0 : -25)
)
.animation(.easeInOut(duration: 0.5).repeatForever(autoreverses: false), value: beating)
Image("front")
.scaleEffect(beating ? 1.2 : 1.5, anchor: .bottom)
.offset(y: 16)
.animation(.timingCurve(0.68, -0.6, 0.32, 1.6).repeatForever(autoreverses: false).speed(0.8), value: beating)
.task{
beating.toggle()
}
} else {
// Fallback on earlier versions
}
}
Spacer()
}
.padding()
}
}
struct BeatingHeart_Previews: PreviewProvider {
static var previews: some View {
BeatingHeart()
.preferredColorScheme(.dark)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment