adding alerts

This commit is contained in:
talksik
2022-01-02 02:08:29 -08:00
parent 3df3d4a246
commit ea47ab2a0d
3 changed files with 24 additions and 10 deletions
+10 -5
View File
@@ -27,11 +27,16 @@ class ConvoViewModel: NSObject, ObservableObject {
case convoNotFound case convoNotFound
case probSettingUpConvo case probSettingUpConvo
case cantAddThirdParty case cantAddThirdParty
case friendNotOnline
case alreadyInCall
case generalError case generalError
var view: AlertToast { var view: AlertToast {
switch self { switch self {
case .alreadyInCall:
return AlertToast(displayMode: .hud, type: .error(Color.orange), title: "Leave your current convo first!")
case .friendNotOnline:
case .connecting: case .connecting:
return AlertToast(displayMode: .hud, type: .systemImage("sensor.tag.radiowaves.forward.fill", NirvanaColor.dimTeal), title: "Connecting") return AlertToast(displayMode: .hud, type: .systemImage("sensor.tag.radiowaves.forward.fill", NirvanaColor.dimTeal), title: "Connecting")
case .disconnected: case .disconnected:
@@ -47,15 +52,15 @@ class ConvoViewModel: NSObject, ObservableObject {
case .successfullyJoined: case .successfullyJoined:
return AlertToast(displayMode: .hud, type: .complete(Color.green), title: "joined convo") return AlertToast(displayMode: .hud, type: .complete(Color.green), title: "joined convo")
case .probSettingUpConvo: case .probSettingUpConvo:
return AlertToast(displayMode: .hud, type: .error(Color.red), title: "Problem setting up convo ‼️") return AlertToast(displayMode: .hud, type: .error(Color.orange), title: "Problem setting up convo ‼️")
case .maxLimitUsers: case .maxLimitUsers:
return AlertToast(displayMode: .hud, type: .error(Color.red), title: "The convo is full! Sorry! 😞") return AlertToast(displayMode: .hud, type: .error(Color.orange), title: "The convo is full! Sorry! 😞")
case .notAuthenticated: case .notAuthenticated:
return AlertToast(displayMode: .hud, type: .error(Color.red), title: "Not authenticated ‼️") return AlertToast(displayMode: .hud, type: .error(Color.orange), title: "Not authenticated ‼️")
case .generalError: case .generalError:
return AlertToast(displayMode: .hud, type: .error(Color.red), title: "Something went wrong ‼️") return AlertToast(displayMode: .hud, type: .error(Color.orange), title: "Something went wrong ‼️")
default: default:
return AlertToast(displayMode: .hud, type: .error(Color.red), title: "Something went wrong ‼️") return AlertToast(displayMode: .hud, type: .error(Color.orange), title: "Something went wrong ‼️")
} }
} }
} }
@@ -133,6 +133,9 @@ struct CircleGridView: View {
} }
} }
else {
self.convoVM.toast = .alreadyInCall
}
} }
// .animation( // .animation(
// Animation.easeInOut(duration: 4).repeatForever(autoreverses: true), // Animation.easeInOut(duration: 4).repeatForever(autoreverses: true),
@@ -183,7 +186,9 @@ struct CircleGridView: View {
.gesture( .gesture(
LongPressGesture(minimumDuration: longPressMinDuration) LongPressGesture(minimumDuration: longPressMinDuration)
.onEnded {_ in // on activation of long press .onEnded {_ in // on activation of long press
// if in a call, I cannot record or select someone...strict rules on user if in a call print("activated long press!")
// if in a convo, I don't want to have user footer show up
if self.convoVM.isInCall() { if self.convoVM.isInCall() {
print("can't select another friend because I am in a call...leave call first") print("can't select another friend because I am in a call...leave call first")
return return
@@ -192,7 +197,7 @@ struct CircleGridView: View {
// stop any player still playing of a message // stop any player still playing of a message
self.queuePlayer.removeAllItems() self.queuePlayer.removeAllItems()
print("activated long press!")
self.selectedFriendIndex = friendId self.selectedFriendIndex = friendId
// TODO: haptics stopped working again // TODO: haptics stopped working again
@@ -488,8 +493,12 @@ extension CircleGridView {
return return
} // if I am in a convo, don't allow listening to a message or expanding details of a friend in my circle } // if I am in a convo, don't allow listening to a message or expanding details of a friend in my circle
// also can't add friend who is not online
else if self.convoVM.isInCall() { else if self.convoVM.isInCall() {
print("can't select this friend as you are in a convo") print("can't select this friend as you are in a convo and they are not online")
self.convoVM.toast = .friendNotOnline
return return
} }
@@ -150,7 +150,7 @@ struct InnerCircleView: View {
// set status of user to online // set status of user to online
self.authSessionStore.updateUserStatus(userStatus: .online) self.authSessionStore.updateUserStatus(userStatus: .online)
} }
.toast(isPresenting: self.$convoViewModel.showToast) { .toast(isPresenting: self.$convoViewModel.showToast, duration: 2) {
self.convoViewModel.toast?.view ?? AlertToast(displayMode: .hud, type: .error(Color.red), title: "Something went wrong") self.convoViewModel.toast?.view ?? AlertToast(displayMode: .hud, type: .error(Color.red), title: "Something went wrong")
} }
// .onDisappear { // .onDisappear {