Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Flipcash/Core/Screens/Members/GroupMembersScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?)] {
Expand All @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
5 changes: 5 additions & 0 deletions Flipcash/Core/Screens/Profile/PrivateGroupCopy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions FlipcashTests/Chat/LobbyRequestsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading