diff --git a/Flipcash/Core/Screens/Members/GroupMembersScreen.swift b/Flipcash/Core/Screens/Members/GroupMembersScreen.swift index 818fce922..300b95256 100644 --- a/Flipcash/Core/Screens/Members/GroupMembersScreen.swift +++ b/Flipcash/Core/Screens/Members/GroupMembersScreen.swift @@ -18,8 +18,12 @@ struct GroupMembersScreen: View { @Environment(SessionContainer.self) private var sessionContainer @Environment(AppRouter.self) private var router + private var conversation: Conversation? { + conversationController.conversation(withID: conversationID) + } + private var creator: UserID? { - conversationController.conversation(withID: conversationID)?.creator + conversation?.creator } private var members: [(portrait: GroupPortrait, joinedAt: Date?)] { @@ -31,6 +35,12 @@ struct GroupMembersScreen: View { var body: some View { Background(color: .backgroundMain) { List { + Text(PrivateGroupCopy.memberCount(conversation?.rosterSummary.memberCount ?? UInt64(members.count))) + .font(.appTextCaption) + .foregroundStyle(Color.textSecondary) + .listRowInsets(EdgeInsets(top: 8, leading: 20, bottom: 4, trailing: 20)) + .listRowBackground(Color.clear) + .listRowSeparator(.hidden) ForEach(members, id: \.portrait.userID) { entry in row(entry.portrait, joinedAt: entry.joinedAt) .listRowInsets(EdgeInsets(top: 10, leading: 20, bottom: 10, trailing: 20)) @@ -66,8 +76,11 @@ struct GroupMembersScreen: View { .foregroundStyle(Color.textMain) if portrait.isHost { Text("Host") - .font(.appTextSmall) - .foregroundStyle(Color.textSecondary) + .font(.appTextCaption) + .foregroundStyle(Color.textMain) + .padding(.horizontal, 6) + .padding(.vertical, 2) + .background(Color.white.opacity(0.1), in: RoundedRectangle(cornerRadius: 6)) } else if let joinedAt { TimelineView(.everyMinute) { context in Text(PrivateGroupCopy.joinedAge(joinedAt: joinedAt, now: context.date)) diff --git a/Flipcash/Core/Screens/Profile/PrivateGroupCopy.swift b/Flipcash/Core/Screens/Profile/PrivateGroupCopy.swift index 2b32e5578..ee361b9ba 100644 --- a/Flipcash/Core/Screens/Profile/PrivateGroupCopy.swift +++ b/Flipcash/Core/Screens/Profile/PrivateGroupCopy.swift @@ -26,6 +26,11 @@ enum PrivateGroupCopy { } } + /// The member list's header: "1 member" or "48 members". + static func memberCount(_ count: UInt64) -> String { + count == 1 ? "1 member" : "\(count) members" + } + /// The disabled button's title while a request waits: "Request Sent" for its first minute, /// then its age, "Requested 10m ago", "Requested 2h ago" or "Requested 3d ago". static func pendingTitle(requestedAt: Date, now: Date) -> String { diff --git a/FlipcashTests/Chat/LobbyRequestsTests.swift b/FlipcashTests/Chat/LobbyRequestsTests.swift index 3e99c3f9b..8eae8e80c 100644 --- a/FlipcashTests/Chat/LobbyRequestsTests.swift +++ b/FlipcashTests/Chat/LobbyRequestsTests.swift @@ -173,6 +173,12 @@ struct PrivateGroupCopyTests { #expect(PrivateGroupCopy.summary(memberCount: 48) == "Private group ยท 48 members") } + @Test("Member list header counts members") + func memberCount() { + #expect(PrivateGroupCopy.memberCount(1) == "1 member") + #expect(PrivateGroupCopy.memberCount(48) == "48 members") + } + @Test("A request's age on the host's list") func requestAge() { let now = Date(timeIntervalSince1970: 1_000_000)