From d28afccd9a668bb210a7e6260045fca99268450f Mon Sep 17 00:00:00 2001 From: Diogo Date: Tue, 27 Aug 2024 10:52:53 +0100 Subject: [PATCH] add unread count badge --- .../Shared/Views/ChatList/UserPicker.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/ios/Shared/Views/ChatList/UserPicker.swift b/apps/ios/Shared/Views/ChatList/UserPicker.swift index 56f0806875..62d6876af8 100644 --- a/apps/ios/Shared/Views/ChatList/UserPicker.swift +++ b/apps/ios/Shared/Views/ChatList/UserPicker.swift @@ -188,7 +188,12 @@ struct UserPicker: View { } } }, label: { - ProfileImage(imageStr: u.user.image, size: 32) + ZStack(alignment: .topTrailing) { + ProfileImage(imageStr: u.user.image, size: 32) + if (u.unreadCount > 0) { + unreadCounter(u.unreadCount, color: user.showNtfs ? theme.colors.primary : theme.colors.secondary).offset(x: 8, y: -4) + } + } }) .buttonStyle(PressedButtonStyle(defaultColor: theme.colors.surface, pressedColor: Color(uiColor: .secondarySystemFill))) } @@ -218,12 +223,12 @@ struct UserPicker: View { private func unreadCounter(_ unread: Int, color: Color) -> some View { unreadCountText(unread) - .font(.caption) - .foregroundColor(.white) - .padding(.horizontal, 4) - .frame(minWidth: 18, minHeight: 18) - .background(color) - .cornerRadius(10) + .font(.caption) + .foregroundColor(.white) + .padding(.horizontal, 4) + .frame(minWidth: 18, minHeight: 18) + .background(color) + .cornerRadius(10) } struct UserPicker_Previews: PreviewProvider {