showing audio waves while recording and stuff

This commit is contained in:
talksik
2022-01-02 18:27:33 -08:00
parent a1927814a5
commit fa3b11048d
3 changed files with 68 additions and 28 deletions
@@ -13,10 +13,6 @@ struct CircleNavigationView: View {
@EnvironmentObject var navigationStack: NavigationStack @EnvironmentObject var navigationStack: NavigationStack
@EnvironmentObject var authSessionStore: AuthSessionStore @EnvironmentObject var authSessionStore: AuthSessionStore
@Binding var alertActive: Bool
@Binding var alertText: String
@Binding var alertSubtext: String
var body: some View { var body: some View {
HStack(alignment: .center) { HStack(alignment: .center) {
Menu { Menu {
@@ -94,17 +90,45 @@ struct CircleNavigationView: View {
} }
} }
} else { } else {
Image((self.authSessionStore.user?.avatar)!) ZStack {
.resizable() // more animations on recording
.scaledToFit() Circle()
.background(self.innerCircleVM.isRecording ? Color.orange : Color.teal.opacity(0.5)) .foregroundColor(Color.orange.opacity(0.3))
.frame(width: 40, height: 40) .frame(width: 39, height: 39)
.clipShape(Circle()) .scaleEffect(self.innerCircleVM.isRecording ? 1.3: 1)
.shadow(radius: 10) .animation(self.innerCircleVM.isRecording ? Animation.easeIn(duration: 2).repeatForever(autoreverses: true) : .default, value: self.innerCircleVM.isRecording)
.overlay(alignment: .topTrailing) { Circle()
// user status .foregroundColor(Color.orange.opacity(0.5))
UserStatusView(status: self.authSessionStore.user?.userStatus, size: 10) .frame(width: 39, height: 39)
} .scaleEffect(self.innerCircleVM.isRecording ? 1.2: 1)
.animation(self.innerCircleVM.isRecording ? Animation.easeOut(duration: 2).repeatForever(autoreverses: true) : .default, value: self.innerCircleVM.isRecording)
Circle()
.foregroundColor(Color.orange)
.frame(width: 40, height: 40)
.scaleEffect(self.innerCircleVM.isRecording ? 1.1: 1)
.animation(self.innerCircleVM.isRecording ? Animation.easeInOut.repeatForever(autoreverses: false) : .default, value: self.innerCircleVM.isRecording)
Image((self.authSessionStore.user?.avatar)!)
.resizable()
.scaledToFit()
.background(Color.teal.opacity(0.5))
.frame(width: 40, height: 40)
.clipShape(Circle())
.shadow(radius: 10)
.overlay(alignment: .topTrailing) {
// user status
UserStatusView(status: self.authSessionStore.user?.userStatus, size: 10)
.scaleEffect(self.innerCircleVM.isRecording ? 0: 1)
// animation on recording
Image(systemName: "waveform.circle.fill")
.scaleEffect(self.innerCircleVM.isRecording ? 1: 0)
.frame(width: 10)
.foregroundColor(Color.orange)
.animation(.spring())
}
}
} }
} }
@@ -129,11 +153,7 @@ struct CircleNavigationView: View {
Button { Button {
self.alertActive.toggle() self.innerCircleVM.toast = .circlesPreview
self.alertText = "❄️ Coming Soon!"
self.alertSubtext = "Stay posted for buttery smooth convos with groups! We will be limiting you to 3 circles!"
} label: { } label: {
Label("circles", systemImage: "circle.hexagongrid") Label("circles", systemImage: "circle.hexagongrid")
.font(.caption2) .font(.caption2)
@@ -147,11 +167,7 @@ struct CircleNavigationView: View {
} }
Button { Button {
self.alertActive.toggle() self.innerCircleVM.toast = .remoteWorkPreview
self.alertText = "💼 Coming Soon!"
self.alertSubtext = "Efficient and more authentic communication for teams! Contact us for more info."
} label: { } label: {
Label("work", systemImage: "suitcase") Label("work", systemImage: "suitcase")
@@ -164,6 +180,22 @@ struct CircleNavigationView: View {
.strokeBorder(Color.white.opacity(1), lineWidth: 1) .strokeBorder(Color.white.opacity(1), lineWidth: 1)
) )
} }
Button {
self.innerCircleVM.toast = .moreSpacesPreview
} label: {
Label("more spaces", systemImage: "plus")
.labelStyle(.iconOnly)
.font(.caption2)
.foregroundColor(Color.gray)
.padding(.vertical, 10)
.padding(.horizontal, 8)
.overlay(
RoundedRectangle(cornerRadius: 20, style: .continuous)
.strokeBorder(Color.white.opacity(1), lineWidth: 1)
)
}
} }
} }
} }
@@ -96,7 +96,7 @@ struct InnerCircleView: View {
ZStack(alignment: .topLeading) { ZStack(alignment: .topLeading) {
Color.clear Color.clear
CircleNavigationView(alertActive: self.$alertActive, alertText: self.$alertText, alertSubtext: self.$alertSubtext).environmentObject(innerCircleVM) CircleNavigationView().environmentObject(innerCircleVM)
} }
CircleFooterView(selectedFriendIndex: self.$selectedFriendIndex) CircleFooterView(selectedFriendIndex: self.$selectedFriendIndex)
@@ -31,11 +31,21 @@ class InnerCircleViewModel: ObservableObject {
case addedFriend case addedFriend
case removedFriend case removedFriend
case circlesPreview
case remoteWorkPreview
case moreSpacesPreview
case generalError case generalError
var view: AlertToast { var view: AlertToast {
switch self { switch self {
case .moreSpacesPreview:
return AlertToast(displayMode: .hud, type: .systemImage("command.circle", NirvanaColor.dimTeal), title: "coming soon", subTitle: "more spaces")
case .remoteWorkPreview:
return AlertToast(displayMode: .hud, type: .systemImage("suitcase.fill", NirvanaColor.dimTeal), title: "coming soon", subTitle: "remote work productivity at it's best")
case .circlesPreview:
return AlertToast(displayMode: .hud, type: .systemImage("snowflake", NirvanaColor.dimTeal), title: "coming soon", subTitle: "group convos reinvented")
case .removedFriend: case .removedFriend:
return AlertToast(displayMode: .alert, type: .complete(Color.green), title: "Done", subTitle: "removed friend") return AlertToast(displayMode: .alert, type: .complete(Color.green), title: "Done", subTitle: "removed friend")
case .addedFriend: case .addedFriend:
@@ -107,8 +117,6 @@ extension InnerCircleViewModel {
audioRecorder.record() audioRecorder.record()
isRecording = true isRecording = true
self.toast = .startedClip
self.audioLocalUrl = filePath // setting this for later use when recording is stopped self.audioLocalUrl = filePath // setting this for later use when recording is stopped
} catch { } catch {