Add support for multiple users selection in bots peer requests

This commit is contained in:
Ilya Laktyushin
2023-12-21 04:04:17 +04:00
parent c3f15c4914
commit 6795603c4e
26 changed files with 247 additions and 124 deletions

View File

@@ -202,12 +202,19 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
self.navigationItem.rightBarButtonItem = self.rightNavigationButton
rightNavigationButton.isEnabled = true //count != 0 || self.params.alwaysEnabled
case .premiumGifting:
let maxCount: Int32 = 10
let maxCount: Int32 = self.limit ?? 10
var count = 0
if case let .contacts(contactsNode) = self.contactsNode.contentNode {
count = contactsNode.selectionState?.selectedPeerIndices.count ?? 0
}
self.titleView.title = CounterContollerTitle(title: self.presentationData.strings.Premium_Gift_ContactSelection_Title, counter: "\(count)/\(maxCount)")
case .requestedUsersSelection:
let maxCount: Int32 = self.limit ?? 10
var count = 0
if case let .contacts(contactsNode) = self.contactsNode.contentNode {
count = contactsNode.selectionState?.selectedPeerIndices.count ?? 0
}
self.titleView.title = CounterContollerTitle(title: self.presentationData.strings.RequestPeer_SelectUsers, counter: "\(count)/\(maxCount)")
case .channelCreation:
self.titleView.title = CounterContollerTitle(title: self.presentationData.strings.GroupInfo_AddParticipantTitle, counter: "")
let rightNavigationButton = UIBarButtonItem(title: self.presentationData.strings.Common_Next, style: .done, target: self, action: #selector(self.rightNavigationButtonPressed))
@@ -325,7 +332,7 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
switch strongSelf.mode {
case .groupCreation, .peerSelection, .chatSelection:
strongSelf.rightNavigationButton?.isEnabled = updatedCount != 0 || strongSelf.params.alwaysEnabled
case .channelCreation, .premiumGifting:
case .channelCreation, .premiumGifting, .requestedUsersSelection:
break
}
@@ -334,8 +341,11 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
let maxCount: Int32 = strongSelf.limitsConfiguration?.maxSupergroupMemberCount ?? 5000
strongSelf.titleView.title = CounterContollerTitle(title: strongSelf.presentationData.strings.Compose_NewGroupTitle, counter: "\(updatedCount)/\(maxCount)")
case .premiumGifting:
let maxCount: Int32 = 10
let maxCount: Int32 = strongSelf.limit ?? 10
strongSelf.titleView.title = CounterContollerTitle(title: strongSelf.presentationData.strings.Premium_Gift_ContactSelection_Title, counter: "\(updatedCount)/\(maxCount)")
case .requestedUsersSelection:
let maxCount: Int32 = strongSelf.limit ?? 10
strongSelf.titleView.title = CounterContollerTitle(title: strongSelf.presentationData.strings.RequestPeer_SelectUsers, counter: "\(updatedCount)/\(maxCount)")
case .peerSelection, .channelCreation, .chatSelection:
break
}
@@ -407,7 +417,7 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
switch strongSelf.mode {
case .groupCreation, .peerSelection, .chatSelection:
strongSelf.rightNavigationButton?.isEnabled = updatedCount != 0 || strongSelf.params.alwaysEnabled
case .channelCreation, .premiumGifting:
case .channelCreation, .premiumGifting, .requestedUsersSelection:
break
}
switch strongSelf.mode {
@@ -415,8 +425,11 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
let maxCount: Int32 = strongSelf.limitsConfiguration?.maxSupergroupMemberCount ?? 5000
strongSelf.titleView.title = CounterContollerTitle(title: strongSelf.presentationData.strings.Compose_NewGroupTitle, counter: "\(updatedCount)/\(maxCount)")
case .premiumGifting:
let maxCount: Int32 = 10
let maxCount: Int32 = strongSelf.limit ?? 10
strongSelf.titleView.title = CounterContollerTitle(title: strongSelf.presentationData.strings.Premium_Gift_ContactSelection_Title, counter: "\(updatedCount)/\(maxCount)")
case .requestedUsersSelection:
let maxCount: Int32 = strongSelf.limit ?? 10
strongSelf.titleView.title = CounterContollerTitle(title: strongSelf.presentationData.strings.RequestPeer_SelectUsers, counter: "\(updatedCount)/\(maxCount)")
case .peerSelection, .channelCreation, .chatSelection:
break
}