decent place with overall flow

This commit is contained in:
talksik
2021-12-21 17:17:44 -08:00
parent 43d9a2059f
commit fe83e2c3c2
@@ -42,7 +42,6 @@ struct CircleGridView: View {
gridContent gridContent
} }
private var gridContent: some View { private var gridContent: some View {
// main communication hub // main communication hub
// TODO: client side, sort the honeycomb from top left to bottom right // TODO: client side, sort the honeycomb from top left to bottom right
@@ -60,7 +59,7 @@ struct CircleGridView: View {
let scale = getScale(proxy: gridProxy, itemNumber: value) let scale = getScale(proxy: gridProxy, itemNumber: value)
let messagesRelatedToFriend = self.authSessionStore.friendMessagesDict[friend.id!] let messagesRelatedToFriend = self.authSessionStore.friendMessagesDict[friend.id!]
// sort the list // TODO: sort the list but may already be sorted from the query and creation of the array of messages?
// shouldn't be nil...hopefully // shouldn't be nil...hopefully
let userId = self.authSessionStore.user!.id let userId = self.authSessionStore.user!.id
@@ -68,13 +67,13 @@ struct CircleGridView: View {
// check if the last message in the conversation between me and my friend was me talking or him // check if the last message in the conversation between me and my friend was me talking or him
// also check if I have listened to it once or twice // also check if I have listened to it once or twice
if messagesRelatedToFriend?.last?.receiverId == userId && messagesRelatedToFriend?.last?.listenCount == 0 { // him talking if messagesRelatedToFriend?.last?.receiverId == userId && messagesRelatedToFriend?.last?.listenCount == 0 { // him talking
Image(systemName: "wave.3.right.circle") Image(systemName: "wave.3.right.circle.fill")
.foregroundColor(Color.orange) .foregroundColor(Color.orange)
.font(.title) .font(.title)
} }
Circle() Circle()
.foregroundColor(self.getBubbleTint(userIndex: value)) // different color for a selected user .foregroundColor(self.getBubbleTint(friendIndex: value, friendDbId: friend.id!)) // different color for a selected user
.blur(radius: 8) .blur(radius: 8)
.cornerRadius(100) .cornerRadius(100)
@@ -129,13 +128,23 @@ struct CircleGridView: View {
} // scrollview reader } // scrollview reader
} }
private func getBubbleTint(userIndex: Int) -> Color { private func haveNewMessageFromFriend(friendDbId: String) -> Bool {
if (userIndex == self.selectedFriendIndex) { // user clicked on this user let userId = self.authSessionStore.user!.id // O(1)
if let messagesRelatedToFriend = self.authSessionStore.friendMessagesDict[friendDbId] { // O(1)
return messagesRelatedToFriend.last?.receiverId == userId && messagesRelatedToFriend.last?.listenCount == 0
}
return false
}
private func getBubbleTint(friendIndex: Int, friendDbId: String) -> Color {
if (friendIndex == self.selectedFriendIndex) { // user clicked on this user
return NirvanaColor.dimTeal.opacity(0.4) return NirvanaColor.dimTeal.opacity(0.4)
} }
// else if self.usersWithNewMessage.contains(userIndex) { // this user has a message else if self.haveNewMessageFromFriend(friendDbId: friendDbId) { // this user has a message
// return Color.orange.opacity(0.8) return Color.orange.opacity(0.8)
// } }
return Color.white.opacity(0.4) return Color.white.opacity(0.4)
} }