mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-08-29 07:38:54 +00:00
ui: show subsriber roles in list; contributor list for subscribers (#7126)
This commit is contained in:
@@ -131,6 +131,15 @@ public func subscriberCountStr(_ count: Int64) -> String {
|
||||
: String.localizedStringWithFormat(NSLocalizedString("%d subscribers", comment: "channel subscriber count"), count)
|
||||
}
|
||||
|
||||
public func ownersContributorsCountStr(_ count: Int, withContributors: Bool) -> String {
|
||||
if withContributors {
|
||||
return String.localizedStringWithFormat(NSLocalizedString("%d owners & contributors", comment: "channel members count"), count)
|
||||
}
|
||||
return count == 1
|
||||
? String.localizedStringWithFormat(NSLocalizedString("%d owner", comment: "channel owners count"), count)
|
||||
: String.localizedStringWithFormat(NSLocalizedString("%d owners", comment: "channel owners count"), count)
|
||||
}
|
||||
|
||||
struct ChatInfoToolbar_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
ChatInfoToolbar(chat: Chat(chatInfo: ChatInfo.sampleData.direct, chatItems: []))
|
||||
|
||||
@@ -21,22 +21,29 @@ struct ChannelMembersView: View {
|
||||
let s = m.wrapped.memberStatus
|
||||
return s != .memLeft && s != .memRemoved && m.wrapped.memberRole != .relay
|
||||
}
|
||||
.sorted { $0.wrapped.memberRole > $1.wrapped.memberRole }
|
||||
let subscriberCount = groupInfo.groupSummary.publicMemberCount ?? Int64(members.count + 1)
|
||||
if groupInfo.isOwner {
|
||||
let subscriberCount = groupInfo.groupSummary.publicMemberCount ?? Int64(members.count + 1)
|
||||
List {
|
||||
Section(header: Text(subscriberCountStr(subscriberCount)).foregroundColor(theme.colors.secondary)) {
|
||||
memberRow(GMember(groupInfo.membership), user: true, showRole: true)
|
||||
ForEach(members) { member in
|
||||
memberRow(member, user: false, showRole: member.wrapped.memberRole >= .owner)
|
||||
memberRow(member, user: false, showRole: member.wrapped.memberRole >= .member)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let owners = members.filter { $0.wrapped.memberRole >= .owner }
|
||||
let contributors = members.filter { $0.wrapped.memberRole >= .member && $0.wrapped.memberStatus != .memUnknown }
|
||||
let contributorCount = contributors.count + (groupInfo.membership.memberRole >= .member ? 1 : 0)
|
||||
let withContributors = contributors.contains { $0.wrapped.memberRole < .owner }
|
||||
|| groupInfo.membership.memberRole >= .member
|
||||
List {
|
||||
Section(header: Text("Owners").foregroundColor(theme.colors.secondary)) {
|
||||
ForEach(owners) { member in
|
||||
memberRow(member, user: false, showRole: false)
|
||||
Section(header: Text(ownersContributorsCountStr(contributorCount, withContributors: withContributors)).foregroundColor(theme.colors.secondary)) {
|
||||
if groupInfo.membership.memberRole >= .member {
|
||||
memberRow(GMember(groupInfo.membership), user: true, showRole: true)
|
||||
}
|
||||
ForEach(contributors) { member in
|
||||
memberRow(member, user: false, showRole: member.wrapped.memberRole >= .moderator)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ struct GroupChatInfoView: View {
|
||||
}
|
||||
|
||||
private func channelMembersButton() -> some View {
|
||||
let label: LocalizedStringKey = groupInfo.isOwner ? "Subscribers" : "Owners"
|
||||
let label: LocalizedStringKey = groupInfo.isOwner ? "Subscribers" : "Owners & contributors"
|
||||
return NavigationLink {
|
||||
ChannelMembersView(chat: chat, groupInfo: groupInfo)
|
||||
.navigationTitle(label)
|
||||
|
||||
Reference in New Issue
Block a user