nice color background based on isrecording or not

This commit is contained in:
talksik
2021-12-22 18:01:06 -08:00
parent 33a4241780
commit f21faa38d5
4 changed files with 10 additions and 5 deletions
@@ -9,6 +9,7 @@ import SwiftUI
import NavigationStack import NavigationStack
struct CircleNavigationView: View { struct CircleNavigationView: View {
@EnvironmentObject var innerCircleVM: InnerCircleViewModel
@EnvironmentObject var navigationStack: NavigationStack @EnvironmentObject var navigationStack: NavigationStack
@EnvironmentObject var authSessionStore: AuthSessionStore @EnvironmentObject var authSessionStore: AuthSessionStore
@@ -83,7 +84,7 @@ struct CircleNavigationView: View {
Image((self.authSessionStore.user?.avatar)!) Image((self.authSessionStore.user?.avatar)!)
.resizable() .resizable()
.scaledToFit() .scaledToFit()
.background(NirvanaColor.teal.opacity(0.5)) .background(self.innerCircleVM.isRecording ? Color.orange : NirvanaColor.teal.opacity(0.5))
.frame(width: 40, height: 40) .frame(width: 40, height: 40)
.clipShape(Circle()) .clipShape(Circle())
.padding(5) .padding(5)
@@ -28,7 +28,7 @@ struct InnerCircleView: View {
var body: some View { var body: some View {
ZStack { ZStack {
// background // background
WavesGlassBackgroundView() WavesGlassBackgroundView(isRecording: self.innerCircleVM.isRecording)
// content // content
CircleGridView(selectedFriendIndex: self.$selectedFriendIndex) CircleGridView(selectedFriendIndex: self.$selectedFriendIndex)
@@ -37,7 +37,7 @@ struct InnerCircleView: View {
// header // header
VStack(alignment: .leading) { VStack(alignment: .leading) {
CircleNavigationView(sheetView: self.$sheetView) CircleNavigationView(sheetView: self.$sheetView).environmentObject(innerCircleVM)
Spacer() Spacer()
} }
@@ -69,7 +69,7 @@ class InnerCircleViewModel: ObservableObject {
} }
let newMessage = Message(sendId: senderId, receivId: receiverId, audioDUrl: audioDataUrl!.absoluteString) let newMessage = Message(sendId: senderId, receivId: receiverId, audioDUrl: audioDataUrl!.absoluteString)
print(newMessage)
// create a new message in firestore with the url for receiving user to automatically get notified // create a new message in firestore with the url for receiving user to automatically get notified
self?.firestoreService.createMessage(message: newMessage) {[weak self] res in self?.firestoreService.createMessage(message: newMessage) {[weak self] res in
print(res) print(res)
@@ -12,13 +12,17 @@ struct WavesGlassBackgroundView: View {
// y position of where waves should start // y position of where waves should start
let baseLineY = UIScreen.main.bounds.height * 0.95 let baseLineY = UIScreen.main.bounds.height * 0.95
var isRecording: Bool = false
@State var animateWaves = false @State var animateWaves = false
var body: some View { var body: some View {
let recordingColors = [NirvanaColor.solidBlue, NirvanaColor.dimTeal, Color.orange.opacity(0.8), NirvanaColor.teal.opacity(0.7), NirvanaColor.teal.opacity(0.7), NirvanaColor.solidTeal.opacity(0.7), NirvanaColor.solidBlue]
let normalColors = [NirvanaColor.solidBlue, NirvanaColor.dimTeal, Color.orange.opacity(0.4), NirvanaColor.teal.opacity(0.5), NirvanaColor.teal.opacity(0.3), NirvanaColor.solidTeal.opacity(0.3), NirvanaColor.solidBlue]
ZStack { ZStack {
AngularGradient( AngularGradient(
gradient: Gradient( gradient: Gradient(
colors: [NirvanaColor.solidBlue, NirvanaColor.dimTeal, Color.orange.opacity(0.4), NirvanaColor.teal.opacity(0.5), NirvanaColor.teal.opacity(0.3), NirvanaColor.solidTeal.opacity(0.3), NirvanaColor.solidBlue]), colors: self.isRecording ? recordingColors : normalColors),
center: .bottom, center: .bottom,
angle: .degrees(120)) angle: .degrees(120))