adding alerts
This commit is contained in:
@@ -27,11 +27,16 @@ class ConvoViewModel: NSObject, ObservableObject {
|
||||
case convoNotFound
|
||||
case probSettingUpConvo
|
||||
case cantAddThirdParty
|
||||
case friendNotOnline
|
||||
case alreadyInCall
|
||||
|
||||
case generalError
|
||||
|
||||
var view: AlertToast {
|
||||
switch self {
|
||||
case .alreadyInCall:
|
||||
return AlertToast(displayMode: .hud, type: .error(Color.orange), title: "Leave your current convo first!")
|
||||
case .friendNotOnline:
|
||||
case .connecting:
|
||||
return AlertToast(displayMode: .hud, type: .systemImage("sensor.tag.radiowaves.forward.fill", NirvanaColor.dimTeal), title: "Connecting")
|
||||
case .disconnected:
|
||||
@@ -47,15 +52,15 @@ class ConvoViewModel: NSObject, ObservableObject {
|
||||
case .successfullyJoined:
|
||||
return AlertToast(displayMode: .hud, type: .complete(Color.green), title: "joined convo")
|
||||
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:
|
||||
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:
|
||||
return AlertToast(displayMode: .hud, type: .error(Color.red), title: "Not authenticated ‼️")
|
||||
return AlertToast(displayMode: .hud, type: .error(Color.orange), title: "Not authenticated ‼️")
|
||||
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:
|
||||
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.easeInOut(duration: 4).repeatForever(autoreverses: true),
|
||||
@@ -183,7 +186,9 @@ struct CircleGridView: View {
|
||||
.gesture(
|
||||
LongPressGesture(minimumDuration: longPressMinDuration)
|
||||
.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() {
|
||||
print("can't select another friend because I am in a call...leave call first")
|
||||
return
|
||||
@@ -192,7 +197,7 @@ struct CircleGridView: View {
|
||||
// stop any player still playing of a message
|
||||
self.queuePlayer.removeAllItems()
|
||||
|
||||
print("activated long press!")
|
||||
|
||||
self.selectedFriendIndex = friendId
|
||||
|
||||
// TODO: haptics stopped working again
|
||||
@@ -466,7 +471,7 @@ extension CircleGridView {
|
||||
extension CircleGridView {
|
||||
// listening to messages
|
||||
private func handleTap(gridItemIndex: Int, friendId: String) {
|
||||
print("tap gesture activated")
|
||||
print("tap gesture activated")
|
||||
|
||||
// if friend and I are online, and I am not in a convo, start convo immediately with them
|
||||
if self.authSessionStore.relevantUsersDict[friendId]?.userStatus == .online
|
||||
@@ -488,8 +493,12 @@ extension CircleGridView {
|
||||
|
||||
return
|
||||
} // 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() {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ struct InnerCircleView: View {
|
||||
// set status of user to 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")
|
||||
}
|
||||
// .onDisappear {
|
||||
|
||||
Reference in New Issue
Block a user