Premium users in privacy settings

This commit is contained in:
Isaac
2024-03-15 19:29:04 +04:00
parent 2a2d468fd9
commit 925665b88b
13 changed files with 394 additions and 206 deletions

View File

@@ -190,6 +190,20 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
}
private func updateTitle() {
var updatedCount: Int = 0
switch self.contactsNode.contentNode {
case let .contacts(contactsNode):
if let selectionState = contactsNode.selectionState {
updatedCount = selectionState.selectedPeerIndices.count
}
case let .chats(chatsNode):
chatsNode.updateState { state in
updatedCount = state.selectedPeerIds.count
return state
}
break
}
switch self.mode {
case .groupCreation:
let maxCount: Int32 = self.limitsConfiguration?.maxSupergroupMemberCount ?? 5000
@@ -204,7 +218,7 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
let rightNavigationButton = UIBarButtonItem(title: self.presentationData.strings.Common_Next, style: .done, target: self, action: #selector(self.rightNavigationButtonPressed))
self.rightNavigationButton = rightNavigationButton
self.navigationItem.rightBarButtonItem = self.rightNavigationButton
rightNavigationButton.isEnabled = true //count != 0 || self.params.alwaysEnabled
rightNavigationButton.isEnabled = true
case .premiumGifting:
let maxCount: Int32 = self.limit ?? 10
var count = 0
@@ -240,6 +254,13 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
self.navigationItem.rightBarButtonItem = self.rightNavigationButton
rightNavigationButton.isEnabled = self.params.alwaysEnabled
}
switch self.mode {
case .groupCreation, .peerSelection, .chatSelection:
self.rightNavigationButton?.isEnabled = updatedCount != 0 || !self.contactsNode.editableTokens.isEmpty || self.params.alwaysEnabled
case .channelCreation, .premiumGifting, .requestedUsersSelection:
break
}
}
override func loadDisplayNode() {
@@ -340,31 +361,12 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
}
}
if let updatedCount = updatedCount {
switch strongSelf.mode {
case .groupCreation, .peerSelection, .chatSelection:
strongSelf.rightNavigationButton?.isEnabled = updatedCount != 0 || !strongSelf.contactsNode.editableTokens.isEmpty || strongSelf.params.alwaysEnabled
case .channelCreation, .premiumGifting, .requestedUsersSelection:
break
}
switch strongSelf.mode {
case .groupCreation:
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 = 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
}
}
let _ = updatedCount
strongSelf.requestLayout(transition: ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring))
strongSelf.updateTitle()
if displayCountAlert {
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.CreateGroup_SoftUserLimitAlert, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
}
@@ -481,6 +483,8 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
}
}
strongSelf.requestLayout(transition: ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring))
strongSelf.updateTitle()
}
}
@@ -508,6 +512,8 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
}
strongSelf.requestLayout(transition: ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring))
}
strongSelf.updateTitle()
}
self.contactsNode.additionalCategorySelected = { [weak self] id in
@@ -571,6 +577,8 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection
}
}
strongSelf.requestLayout(transition: ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring))
strongSelf.updateTitle()
}
}
self.contactsNode.complete = { [weak self] in