Move channel members back to profile screen

This commit is contained in:
Ilya Laktyushin 2022-04-21 03:50:32 +04:00
parent 61136bedc8
commit a64d0f40b7
2 changed files with 34 additions and 1 deletions

View File

@ -32,7 +32,11 @@ extension UIKeyModifierFlags: Hashable {
extension KeyShortcut { extension KeyShortcut {
var uiKeyCommand: UIKeyCommand { var uiKeyCommand: UIKeyCommand {
if #available(iOSApplicationExtension 9.0, iOS 9.0, *), !self.title.isEmpty { if #available(iOSApplicationExtension 9.0, iOS 9.0, *), !self.title.isEmpty {
return UIKeyCommand(input: self.input, modifierFlags: self.modifiers, action: #selector(KeyShortcutsController.handleKeyCommand(_:)), discoverabilityTitle: self.title) let command = UIKeyCommand(input: self.input, modifierFlags: self.modifiers, action: #selector(KeyShortcutsController.handleKeyCommand(_:)), discoverabilityTitle: self.title)
if #available(iOS 15.0, *), ["\t", UIKeyCommand.inputUpArrow].contains(command.input) {
command.wantsPriorityOverSystemBehavior = true
}
return command
} else { } else {
return UIKeyCommand(input: self.input, modifierFlags: self.modifiers, action: #selector(KeyShortcutsController.handleKeyCommand(_:))) return UIKeyCommand(input: self.input, modifierFlags: self.modifiers, action: #selector(KeyShortcutsController.handleKeyCommand(_:)))
} }

View File

@ -955,6 +955,9 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
let ItemAbout = 2 let ItemAbout = 2
let ItemLocationHeader = 3 let ItemLocationHeader = 3
let ItemLocation = 4 let ItemLocation = 4
let ItemAdmins = 5
let ItemMembers = 6
let ItemMemberRequests = 7
if let location = (data.cachedData as? CachedChannelData)?.peerGeoLocation { if let location = (data.cachedData as? CachedChannelData)?.peerGeoLocation {
items[.groupLocation]!.append(PeerInfoScreenHeaderItem(id: ItemLocationHeader, text: presentationData.strings.GroupInfo_Location.uppercased())) items[.groupLocation]!.append(PeerInfoScreenHeaderItem(id: ItemLocationHeader, text: presentationData.strings.GroupInfo_Location.uppercased()))
@ -1011,6 +1014,32 @@ private func infoItems(data: PeerInfoScreenData?, context: AccountContext, prese
interaction.requestLayout() interaction.requestLayout()
})) }))
} }
if case .broadcast = channel.info {
var canEditMembers = false
if channel.hasPermission(.banMembers) {
canEditMembers = true
}
if canEditMembers {
if channel.adminRights != nil || channel.flags.contains(.isCreator) {
let adminCount = cachedData.participantsSummary.adminCount ?? 0
let memberCount = cachedData.participantsSummary.memberCount ?? 0
items[.peerMembers]!.append(PeerInfoScreenDisclosureItem(id: ItemAdmins, label: .text("\(adminCount == 0 ? "" : "\(presentationStringsFormattedNumber(adminCount, presentationData.dateTimeFormat.groupingSeparator))")"), text: presentationData.strings.GroupInfo_Administrators, icon: UIImage(bundleImageName: "Chat/Info/GroupAdminsIcon"), action: {
interaction.openParticipantsSection(.admins)
}))
items[.peerMembers]!.append(PeerInfoScreenDisclosureItem(id: ItemMembers, label: .text("\(memberCount == 0 ? "" : "\(presentationStringsFormattedNumber(memberCount, presentationData.dateTimeFormat.groupingSeparator))")"), text: presentationData.strings.Channel_Info_Subscribers, icon: UIImage(bundleImageName: "Chat/Info/GroupMembersIcon"), action: {
interaction.openParticipantsSection(.members)
}))
if let count = data.requests?.count, count > 0 {
items[.peerMembers]!.append(PeerInfoScreenDisclosureItem(id: ItemMemberRequests, label: .badge(presentationStringsFormattedNumber(count, presentationData.dateTimeFormat.groupingSeparator), presentationData.theme.list.itemAccentColor), text: presentationData.strings.GroupInfo_MemberRequests, icon: UIImage(bundleImageName: "Chat/Info/GroupRequestsIcon"), action: {
interaction.openParticipantsSection(.memberRequests)
}))
}
}
}
}
} }
} else if let group = data.peer as? TelegramGroup { } else if let group = data.peer as? TelegramGroup {
if let cachedData = data.cachedData as? CachedGroupData { if let cachedData = data.cachedData as? CachedGroupData {