From cb5f26d354b3c16c5cfd93419bd5c9366eb18dfa Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Fri, 20 Jan 2023 13:17:41 +0000 Subject: [PATCH] ios: only show menu if there is more than 1 user, do not show unread count (only badge) --- .../Shared/Views/ChatList/ChatListView.swift | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index bd50a5d707..ef485f3085 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -66,24 +66,25 @@ struct ChatListView: View { .toolbar { ToolbarItem(placement: .navigationBarLeading) { Button { - withAnimation { - userPickerVisible.toggle() + if chatModel.users.count > 1 { + withAnimation { + userPickerVisible.toggle() + } + } else { + showSettings = true } } label: { let user = chatModel.currentUser ?? User.sampleData let color = Color(uiColor: .tertiarySystemGroupedBackground) - HStack(spacing: 0) { + ZStack(alignment: .topTrailing) { ProfileImage(imageStr: user.image, color: color) .frame(width: 32, height: 32) - .padding(.trailing, 6) - .padding(.vertical, 6) - let unread = chatModel.users + .padding(.trailing, 4) + let allRead = chatModel.users .filter { !$0.user.activeUser } - .reduce(0, {cnt, u in cnt + u.unreadCount}) - if unread > 0 { - unreadCounter(unread) - .padding(.leading, -12) - .padding(.top, -16) + .allSatisfy { u in u.unreadCount == 0 } + if !allRead { + unreadBadge(size: 12) } } } @@ -121,6 +122,12 @@ struct ChatListView: View { ) } + private func unreadBadge(_ text: Text? = Text(" "), size: CGFloat = 18) -> some View { + Circle() + .frame(width: size, height: size) + .foregroundColor(.accentColor) + } + private func onboardingButtons() -> some View { VStack(alignment: .trailing, spacing: 0) { Path { p in