Last active
May 17, 2021 13:05
-
-
Save serdarkaracay/2ef3bb934b4763e24a27ddd9415ece10 to your computer and use it in GitHub Desktop.
Voice Button
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
import SwiftUI | |
struct voice: View { | |
var body: some View { | |
voiceHome() | |
} | |
} | |
struct voiceHome : View { | |
@State var pulse = false | |
var body: some View{ | |
VStack{ | |
HStack{} | |
ZStack{ | |
Circle() | |
.fill( | |
LinearGradient(gradient: Gradient(colors: [Color.green.opacity(0.5), Color.green]), startPoint: .top, endPoint: .bottom) | |
) | |
.frame(width: 100, height: 100) | |
.shadow(color: Color.black.opacity(0.07), radius: 5, x: 5, y: 5) | |
Circle() | |
.stroke(Color.blue.opacity(0.6)) | |
.frame(width: 50, height: 50) | |
.scaleEffect(pulse ? 3.3 : 0) | |
.opacity(pulse ? 0 : 1) | |
Image(systemName: "mic.fill") | |
.font(.largeTitle) | |
.foregroundColor(.white) | |
} | |
.frame(width: 50, height: 50) | |
} | |
.ignoresSafeArea() | |
.background(Color.black.opacity(0.05).ignoresSafeArea()) | |
.onAppear(perform: { | |
animate() | |
}) | |
} | |
func animate() { | |
withAnimation(Animation.linear(duration: 1.0).repeatForever(autoreverses: false)){ | |
pulse.toggle() | |
} | |
} | |
} | |
extension View{ | |
func getSafeAreay()->UIEdgeInsets{ | |
return UIApplication.shared.windows.first?.safeAreaInsets ?? UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) | |
} | |
func getRecty()->CGRect{ | |
return UIScreen.main.bounds | |
} | |
} | |
struct voice_Previews: PreviewProvider { | |
static var previews: some View { | |
voice() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment