Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created February 14, 2021 01:56
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/cdd523f41c4b2f56091f4b3ccae31591 to your computer and use it in GitHub Desktop.
Save amosgyamfi/cdd523f41c4b2f56091f4b3ccae31591 to your computer and use it in GitHub Desktop.
//
// ContentView.swift
// AudioMetering
//
// Created by Amos Gyamfi on 13.2.2021.
//
import SwiftUI
struct ContentView: View {
@State var toggleRecordStop = "Record"
@State var scaleBigger = 0.5
@State var scaleMedium = 0.5
@State var scaleSmaller = 0.5
@State var counter = Text("0:00")
var body: some View {
VStack {
Spacer()
Text("Audio Metering")
.font(/*@START_MENU_TOKEN@*/.title/*@END_MENU_TOKEN@*/)
Spacer()
Spacer()
counter
.font(.system(size: 64))
.fontWeight(.ultraLight)
Spacer()
ZStack {
Circle()
.frame(width: 250, height: 250, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.scaleEffect(CGFloat(scaleBigger))
.foregroundColor(Color(.systemGray6))
.animation(Animation.easeOut(duration: 1).repeatForever(autoreverses: true))
Circle()
.frame(width: 200, height: 200, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.scaleEffect(CGFloat(scaleMedium))
.foregroundColor(Color(.systemGray5))
.animation(Animation.default.repeatForever(autoreverses: true))
Circle()
.frame(width: 150, height: 150, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.scaleEffect(CGFloat(scaleSmaller))
.foregroundColor(Color(.systemGray4))
.animation(Animation.easeInOut(duration: 1).repeatForever(autoreverses: true))
Circle()
.frame(width: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/, height: /*@START_MENU_TOKEN@*/100/*@END_MENU_TOKEN@*/, alignment: /*@START_MENU_TOKEN@*/.center/*@END_MENU_TOKEN@*/)
.foregroundColor(Color(.systemRed))
.overlay(Text(toggleRecordStop))
}
.onTapGesture {
toggleRecordStop = "Stop"
scaleBigger = 1.2
scaleMedium = 1.2
scaleSmaller = 1.2
counter = Text(Date().addingTimeInterval(0.0), style: .timer)
.font(.system(size: 64))
.fontWeight(.ultraLight)
}
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.preferredColorScheme(/*@START_MENU_TOKEN@*/.dark/*@END_MENU_TOKEN@*/)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment