Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created September 22, 2020 15:40
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/aa129882773f715e32f7b052220ed782 to your computer and use it in GitHub Desktop.
Save amosgyamfi/aa129882773f715e32f7b052220ed782 to your computer and use it in GitHub Desktop.
//
// ContentView.swift
// measuring_heartrate
//
// Created by Amos Gyamfi on 21.6.2020.
// Copyright © 2020 Amos Gyamfi. All rights reserved.
//
import SwiftUI
struct ContentView: View {
@State private var showRate = false
@State private var heartBeat = false
var body: some View {
ZStack {
Color(.systemBackground)
.edgesIgnoringSafeArea(.all)
Image("heart")
.scaleEffect(heartBeat ? 1 : 1.3)
.animation(Animation.interpolatingSpring(stiffness: 30, damping: 10).speed(1.3/2).repeatForever(autoreverses: false))
.onAppear() {
heartBeat.toggle()
}
Image("pulse")
.clipShape(Rectangle().offset(x: showRate ? 0 : -125))
.animation(Animation.interpolatingSpring(
stiffness: 30, damping: 10).speed(1.3).repeatForever(autoreverses: true).delay(0.2))
.offset(x: -12)
.onAppear() {
showRate.toggle()
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.colorScheme(.dark)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment