diff --git a/submodules/AccountContext/Sources/ContactMultiselectionController.swift b/submodules/AccountContext/Sources/ContactMultiselectionController.swift index fc3ea9691c..3c0720a145 100644 --- a/submodules/AccountContext/Sources/ContactMultiselectionController.swift +++ b/submodules/AccountContext/Sources/ContactMultiselectionController.swift @@ -77,7 +77,7 @@ public enum ContactMultiselectionControllerMode { } } - case groupCreation + case groupCreation(isCall: Bool) case peerSelection(searchChatList: Bool, searchGroups: Bool, searchChannels: Bool) case channelCreation case chatSelection(ChatSelection) @@ -110,7 +110,23 @@ public final class ContactMultiselectionControllerParams { public let openProfile: ((EnginePeer) -> Void)? public let sendMessage: ((EnginePeer) -> Void)? - public init(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, title: String? = nil, mode: ContactMultiselectionControllerMode, options: Signal<[ContactListAdditionalOption], NoError> = .single([]), filters: [ContactListFilter] = [.excludeSelf], onlyWriteable: Bool = false, isGroupInvitation: Bool = false, isPeerEnabled: ((EnginePeer) -> Bool)? = nil, attemptDisabledItemSelection: ((EnginePeer, ChatListDisabledPeerReason) -> Void)? = nil, alwaysEnabled: Bool = false, limit: Int32? = nil, reachedLimit: ((Int32) -> Void)? = nil, openProfile: ((EnginePeer) -> Void)? = nil, sendMessage: ((EnginePeer) -> Void)? = nil) { + public init( + context: AccountContext, + updatedPresentationData: (initial: PresentationData, signal: Signal)? = nil, + title: String? = nil, + mode: ContactMultiselectionControllerMode, + options: Signal<[ContactListAdditionalOption], NoError> = .single([]), + filters: [ContactListFilter] = [.excludeSelf], + onlyWriteable: Bool = false, + isGroupInvitation: Bool = false, + isPeerEnabled: ((EnginePeer) -> Bool)? = nil, + attemptDisabledItemSelection: ((EnginePeer, ChatListDisabledPeerReason) -> Void)? = nil, + alwaysEnabled: Bool = false, + limit: Int32? = nil, + reachedLimit: ((Int32) -> Void)? = nil, + openProfile: ((EnginePeer) -> Void)? = nil, + sendMessage: ((EnginePeer) -> Void)? = nil + ) { self.context = context self.updatedPresentationData = updatedPresentationData self.title = title diff --git a/submodules/AccountContext/Sources/PresentationCallManager.swift b/submodules/AccountContext/Sources/PresentationCallManager.swift index e47d704bbf..4ababaca46 100644 --- a/submodules/AccountContext/Sources/PresentationCallManager.swift +++ b/submodules/AccountContext/Sources/PresentationCallManager.swift @@ -569,6 +569,7 @@ public protocol PresentationCallManager: AnyObject { accountContext: AccountContext, initialCall: EngineGroupCallDescription, reference: InternalGroupCallReference, - beginWithVideo: Bool + beginWithVideo: Bool, + invitePeerIds: [EnginePeer.Id] ) } diff --git a/submodules/CallListUI/Sources/CallListController.swift b/submodules/CallListUI/Sources/CallListController.swift index d8df9577a9..7c155f916d 100644 --- a/submodules/CallListUI/Sources/CallListController.swift +++ b/submodules/CallListUI/Sources/CallListController.swift @@ -208,7 +208,7 @@ public final class CallListController: TelegramBaseController { } } - private func createGroupCall() { + private func createGroupCall(peerIds: [EnginePeer.Id], completion: (() -> Void)? = nil) { self.view.endEditing(true) guard !self.presentAccountFrozenInfoIfNeeded() else { @@ -274,38 +274,44 @@ public final class CallListController: TelegramBaseController { isStream: false ), reference: .id(id: call.callInfo.id, accessHash: call.callInfo.accessHash), - beginWithVideo: false + beginWithVideo: false, + invitePeerIds: peerIds ) + completion?() } - let controller = InviteLinkInviteController( - context: self.context, - updatedPresentationData: nil, - mode: .groupCall(InviteLinkInviteController.Mode.GroupCall(callId: call.callInfo.id, accessHash: call.callInfo.accessHash, isRecentlyCreated: true, canRevoke: true)), - initialInvite: .link(link: call.link, title: nil, isPermanent: true, requestApproval: false, isRevoked: false, adminId: self.context.account.peerId, date: 0, startDate: nil, expireDate: nil, usageLimit: nil, count: nil, requestedCount: nil, pricing: nil), - parentNavigationController: self.navigationController as? NavigationController, - completed: { [weak self] result in - guard let self else { - return - } - if let result { - switch result { - case .linkCopied: - //TODO:localize - let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } - self.present(UndoOverlayController(presentationData: presentationData, content: .universal(animation: "anim_linkcopied", scale: 0.08, colors: ["info1.info1.stroke": UIColor.clear, "info2.info2.Fill": UIColor.clear], title: nil, text: "Call link copied.", customUndoText: "View Call", timeout: nil), elevatedLayout: false, animateInAsReplacement: false, action: { action in - if case .undo = action { - openCall() - } - return false - }), in: .window(.root)) - case .openCall: - openCall() + if !peerIds.isEmpty { + openCall() + } else { + let controller = InviteLinkInviteController( + context: self.context, + updatedPresentationData: nil, + mode: .groupCall(InviteLinkInviteController.Mode.GroupCall(callId: call.callInfo.id, accessHash: call.callInfo.accessHash, isRecentlyCreated: true, canRevoke: true)), + initialInvite: .link(link: call.link, title: nil, isPermanent: true, requestApproval: false, isRevoked: false, adminId: self.context.account.peerId, date: 0, startDate: nil, expireDate: nil, usageLimit: nil, count: nil, requestedCount: nil, pricing: nil), + parentNavigationController: self.navigationController as? NavigationController, + completed: { [weak self] result in + guard let self else { + return + } + if let result { + switch result { + case .linkCopied: + //TODO:localize + let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } + self.present(UndoOverlayController(presentationData: presentationData, content: .universal(animation: "anim_linkcopied", scale: 0.08, colors: ["info1.info1.stroke": UIColor.clear, "info2.info2.Fill": UIColor.clear], title: nil, text: "Call link copied.", customUndoText: "View Call", timeout: nil), elevatedLayout: false, animateInAsReplacement: false, action: { action in + if case .undo = action { + openCall() + } + return false + }), in: .window(.root)) + case .openCall: + openCall() + } } } - } - ) - self.present(controller, in: .window(.root), with: nil) + ) + self.present(controller, in: .window(.root), with: nil) + } }) } @@ -395,7 +401,7 @@ public final class CallListController: TelegramBaseController { } }, createGroupCall: { [weak self] in if let strongSelf = self { - strongSelf.createGroupCall() + strongSelf.createGroupCall(peerIds: []) } }) @@ -508,21 +514,69 @@ public final class CallListController: TelegramBaseController { guard !self.presentAccountFrozenInfoIfNeeded() else { return } - let controller = self.context.sharedContext.makeContactSelectionController(ContactSelectionControllerParams(context: self.context, title: { $0.Calls_NewCall }, displayCallIcons: true)) + + //TODO:localize + let options = [ContactListAdditionalOption(title: "New Call Link", icon: .generic(PresentationResourcesItemList.linkIcon(presentationData.theme)!), action: { [weak self] in + guard let self else { + return + } + self.createGroupCall(peerIds: []) + }, clearHighlightAutomatically: true)] + + let controller = self.context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams( + context: self.context, + title: self.presentationData.strings.Calls_NewCall, + mode: .groupCreation(isCall: true), + options: .single(options), + filters: [.excludeSelf], + onlyWriteable: true, + isGroupInvitation: false, + isPeerEnabled: nil, + attemptDisabledItemSelection: nil, + alwaysEnabled: false, + limit: nil, + reachedLimit: nil, + openProfile: nil, + sendMessage: nil + )) controller.navigationPresentation = .modal - self.createActionDisposable.set((controller.result + if let navigationController = self.context.sharedContext.mainWindow?.viewController as? NavigationController { + navigationController.pushViewController(controller) + } + + let _ = (controller.result |> take(1) - |> deliverOnMainQueue).startStrict(next: { [weak controller, weak self] result in - controller?.dismissSearch() - if let strongSelf = self, let (contactPeers, action, _, _, _, _) = result, let contactPeer = contactPeers.first, case let .peer(peer, _, _) = contactPeer { - strongSelf.call(peer.id, isVideo: action == .videoCall, began: { + |> deliverOnMainQueue).startStandalone(next: { [weak controller, weak self] result in + guard let self else { + controller?.dismiss() + return + } + guard case let .result(rawPeerIds, _) = result else { + controller?.dismiss() + return + } + let peerIds = rawPeerIds.compactMap { id -> EnginePeer.Id? in + if case let .peer(id) = id { + return id + } + return nil + } + if peerIds.isEmpty { + controller?.dismiss() + return + } + + if peerIds.count == 1 { + //TODO:release isVideo + controller?.dismiss() + self.call(peerIds[0], isVideo: false, began: { [weak self] in if let strongSelf = self { let _ = (strongSelf.context.sharedContext.hasOngoingCall.get() |> filter { $0 } |> timeout(1.0, queue: Queue.mainQueue(), alternate: .single(true)) |> delay(0.5, queue: Queue.mainQueue()) |> take(1) - |> deliverOnMainQueue).startStandalone(next: { _ in + |> deliverOnMainQueue).startStandalone(next: { [weak self] _ in if let _ = self, let controller = controller, let navigationController = controller.navigationController as? NavigationController { if navigationController.viewControllers.last === controller { let _ = navigationController.popViewController(animated: true) @@ -531,11 +585,12 @@ public final class CallListController: TelegramBaseController { }) } }) + } else { + self.createGroupCall(peerIds: peerIds, completion: { + controller?.dismiss() + }) } - })) - if let navigationController = self.context.sharedContext.mainWindow?.viewController as? NavigationController { - navigationController.pushViewController(controller) - } + }) } private func presentAccountFrozenInfoIfNeeded(delay: Bool = false) -> Bool { @@ -670,7 +725,8 @@ public final class CallListController: TelegramBaseController { isStream: false ), reference: .message(id: message.id), - beginWithVideo: conferenceCall.flags.contains(.isVideo) + beginWithVideo: conferenceCall.flags.contains(.isVideo), + invitePeerIds: [] ) }) } diff --git a/submodules/CounterControllerTitleView/Sources/CounterControllerTitleView.swift b/submodules/CounterControllerTitleView/Sources/CounterControllerTitleView.swift index 117417dc7e..5685a37fcf 100644 --- a/submodules/CounterControllerTitleView/Sources/CounterControllerTitleView.swift +++ b/submodules/CounterControllerTitleView/Sources/CounterControllerTitleView.swift @@ -6,9 +6,9 @@ import TelegramPresentationData public struct CounterControllerTitle: Equatable { public var title: String - public var counter: String + public var counter: String? - public init(title: String, counter: String) { + public init(title: String, counter: String?) { self.title = title self.counter = counter } @@ -18,7 +18,7 @@ public final class CounterControllerTitleView: UIView { private let titleNode: ImmediateTextNode private let subtitleNode: ImmediateTextNode - public var title: CounterControllerTitle = CounterControllerTitle(title: "", counter: "") { + public var title: CounterControllerTitle = CounterControllerTitle(title: "", counter: nil) { didSet { if self.title != oldValue { self.update() @@ -59,7 +59,7 @@ public final class CounterControllerTitleView: UIView { let primaryTextColor = self.primaryTextColor ?? self.theme.rootController.navigationBar.primaryTextColor let secondaryTextColor = self.secondaryTextColor ?? self.theme.rootController.navigationBar.secondaryTextColor self.titleNode.attributedText = NSAttributedString(string: self.title.title, font: Font.semibold(17.0), textColor: primaryTextColor) - self.subtitleNode.attributedText = NSAttributedString(string: self.title.counter, font: Font.with(size: 13.0, traits: .monospacedNumbers), textColor: secondaryTextColor) + self.subtitleNode.attributedText = NSAttributedString(string: self.title.counter ?? "", font: Font.with(size: 13.0, traits: .monospacedNumbers), textColor: secondaryTextColor) self.accessibilityLabel = self.title.title self.accessibilityValue = self.title.counter @@ -103,7 +103,13 @@ public final class CounterControllerTitleView: UIView { let titleSize = self.titleNode.updateLayout(CGSize(width: max(1.0, size.width), height: size.height)) let subtitleSize = self.subtitleNode.updateLayout(CGSize(width: max(1.0, size.width), height: size.height)) - let combinedHeight = titleSize.height + subtitleSize.height + spacing + + let combinedHeight: CGFloat + if self.title.counter != nil { + combinedHeight = titleSize.height + subtitleSize.height + spacing + } else { + combinedHeight = titleSize.height + } let titleFrame = CGRect(origin: CGPoint(x: floor((size.width - titleSize.width) / 2.0), y: floor((size.height - combinedHeight) / 2.0)), size: titleSize) self.titleNode.frame = titleFrame diff --git a/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift b/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift index b881c0d803..cf901db89a 100644 --- a/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift +++ b/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift @@ -427,7 +427,7 @@ public final class InviteLinkInviteController: ViewController { strongSelf.controller?.present(controller, in: .window(.root)) }) } else if case .groupCall = self.mode { - let controller = QrCodeScreen(context: context, updatedPresentationData: (self.presentationData, self.presentationDataPromise.get()), subject: .invite(invite: invite, type: .channel)) + let controller = QrCodeScreen(context: context, updatedPresentationData: (self.presentationData, self.presentationDataPromise.get()), subject: .invite(invite: invite, type: .groupCall)) self.controller?.present(controller, in: .window(.root)) } } diff --git a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift index e7b6433db6..57b06878a5 100644 --- a/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift +++ b/submodules/TelegramCallsUI/Sources/PresentationCallManager.swift @@ -1083,7 +1083,8 @@ public final class PresentationCallManagerImpl: PresentationCallManager { accountContext: AccountContext, initialCall: EngineGroupCallDescription, reference: InternalGroupCallReference, - beginWithVideo: Bool + beginWithVideo: Bool, + invitePeerIds: [EnginePeer.Id] ) { let keyPair: TelegramKeyPair guard let keyPairValue = TelegramE2EEncryptionProviderImpl.shared.generateKeyPair() else { @@ -1109,6 +1110,9 @@ public final class PresentationCallManagerImpl: PresentationCallManager { beginWithVideo: beginWithVideo, sharedAudioContext: nil ) + for peerId in invitePeerIds { + let _ = call.invitePeer(peerId, isVideo: beginWithVideo) + } self.updateCurrentGroupCall(.group(call)) } } diff --git a/submodules/TelegramCore/Sources/State/UserLimitsConfiguration.swift b/submodules/TelegramCore/Sources/State/UserLimitsConfiguration.swift index fc245b1f57..7c1fc58584 100644 --- a/submodules/TelegramCore/Sources/State/UserLimitsConfiguration.swift +++ b/submodules/TelegramCore/Sources/State/UserLimitsConfiguration.swift @@ -28,6 +28,7 @@ public struct UserLimitsConfiguration: Equatable { public var maxGiveawayCountriesCount: Int32 public var maxGiveawayPeriodSeconds: Int32 public var maxChannelRecommendationsCount: Int32 + public var maxConferenceParticipantCount: Int32 public static var defaultValue: UserLimitsConfiguration { return UserLimitsConfiguration( @@ -56,7 +57,8 @@ public struct UserLimitsConfiguration: Equatable { maxGiveawayChannelsCount: 10, maxGiveawayCountriesCount: 10, maxGiveawayPeriodSeconds: 86400 * 31, - maxChannelRecommendationsCount: 10 + maxChannelRecommendationsCount: 10, + maxConferenceParticipantCount: 100 ) } @@ -86,7 +88,8 @@ public struct UserLimitsConfiguration: Equatable { maxGiveawayChannelsCount: Int32, maxGiveawayCountriesCount: Int32, maxGiveawayPeriodSeconds: Int32, - maxChannelRecommendationsCount: Int32 + maxChannelRecommendationsCount: Int32, + maxConferenceParticipantCount: Int32 ) { self.maxPinnedChatCount = maxPinnedChatCount self.maxPinnedSavedChatCount = maxPinnedSavedChatCount @@ -114,6 +117,7 @@ public struct UserLimitsConfiguration: Equatable { self.maxGiveawayCountriesCount = maxGiveawayCountriesCount self.maxGiveawayPeriodSeconds = maxGiveawayPeriodSeconds self.maxChannelRecommendationsCount = maxChannelRecommendationsCount + self.maxConferenceParticipantCount = maxConferenceParticipantCount } } @@ -167,5 +171,6 @@ extension UserLimitsConfiguration { self.maxGiveawayCountriesCount = getGeneralValue("giveaway_countries_max", orElse: defaultValue.maxGiveawayCountriesCount) self.maxGiveawayPeriodSeconds = getGeneralValue("giveaway_period_max", orElse: defaultValue.maxGiveawayPeriodSeconds) self.maxChannelRecommendationsCount = getValue("recommended_channels_limit", orElse: defaultValue.maxChannelRecommendationsCount) + self.maxConferenceParticipantCount = getGeneralValue("conference_call_size_limit", orElse: defaultValue.maxConferenceParticipantCount) } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Data/ConfigurationData.swift b/submodules/TelegramCore/Sources/TelegramEngine/Data/ConfigurationData.swift index 7a04b9c3d1..e9d24a6cef 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Data/ConfigurationData.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Data/ConfigurationData.swift @@ -62,6 +62,7 @@ public enum EngineConfiguration { public let maxGiveawayCountriesCount: Int32 public let maxGiveawayPeriodSeconds: Int32 public let maxChannelRecommendationsCount: Int32 + public let maxConferenceParticipantCount: Int32 public static var defaultValue: UserLimits { return UserLimits(UserLimitsConfiguration.defaultValue) @@ -93,7 +94,8 @@ public enum EngineConfiguration { maxGiveawayChannelsCount: Int32, maxGiveawayCountriesCount: Int32, maxGiveawayPeriodSeconds: Int32, - maxChannelRecommendationsCount: Int32 + maxChannelRecommendationsCount: Int32, + maxConferenceParticipantCount: Int32 ) { self.maxPinnedChatCount = maxPinnedChatCount self.maxPinnedSavedChatCount = maxPinnedSavedChatCount @@ -121,6 +123,7 @@ public enum EngineConfiguration { self.maxGiveawayCountriesCount = maxGiveawayCountriesCount self.maxGiveawayPeriodSeconds = maxGiveawayPeriodSeconds self.maxChannelRecommendationsCount = maxChannelRecommendationsCount + self.maxConferenceParticipantCount = maxConferenceParticipantCount } } } @@ -183,7 +186,8 @@ public extension EngineConfiguration.UserLimits { maxGiveawayChannelsCount: userLimitsConfiguration.maxGiveawayChannelsCount, maxGiveawayCountriesCount: userLimitsConfiguration.maxGiveawayCountriesCount, maxGiveawayPeriodSeconds: userLimitsConfiguration.maxGiveawayPeriodSeconds, - maxChannelRecommendationsCount: userLimitsConfiguration.maxChannelRecommendationsCount + maxChannelRecommendationsCount: userLimitsConfiguration.maxChannelRecommendationsCount, + maxConferenceParticipantCount: userLimitsConfiguration.maxConferenceParticipantCount ) } } diff --git a/submodules/TelegramUI/BUILD b/submodules/TelegramUI/BUILD index 11349d0ca7..e0c228ffef 100644 --- a/submodules/TelegramUI/BUILD +++ b/submodules/TelegramUI/BUILD @@ -469,6 +469,9 @@ swift_library( "//submodules/TelegramUI/Components/Settings/AccountFreezeInfoScreen", "//submodules/TelegramUI/Components/JoinSubjectScreen", "//submodules/TelegramUI/Components/Chat/QuickShareScreen", + "//submodules/TelegramUI/Components/ButtonComponent", + "//submodules/Components/BlurredBackgroundComponent", + "//submodules/TelegramUI/Components/CheckComponent", "//third-party/recaptcha:RecaptchaEnterprise", ] + select({ "@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets, diff --git a/submodules/TelegramUI/Components/JoinSubjectScreen/Sources/JoinSubjectScreen.swift b/submodules/TelegramUI/Components/JoinSubjectScreen/Sources/JoinSubjectScreen.swift index 467fe9e858..5f03c035fe 100644 --- a/submodules/TelegramUI/Components/JoinSubjectScreen/Sources/JoinSubjectScreen.swift +++ b/submodules/TelegramUI/Components/JoinSubjectScreen/Sources/JoinSubjectScreen.swift @@ -405,7 +405,8 @@ private final class JoinSubjectScreenComponent: Component { isStream: false ), reference: .link(slug: groupCall.slug), - beginWithVideo: false + beginWithVideo: false, + invitePeerIds: [] ) self.environment?.controller()?.dismiss() diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index f2c780dd82..fbcec4709f 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -2919,7 +2919,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G isStream: false ), reference: .message(id: message.id), - beginWithVideo: conferenceCall.flags.contains(.isVideo) + beginWithVideo: conferenceCall.flags.contains(.isVideo), + invitePeerIds: [] ) }) }, longTap: { [weak self] action, params in diff --git a/submodules/TelegramUI/Sources/ComposeController.swift b/submodules/TelegramUI/Sources/ComposeController.swift index 8700b655e6..1738e15ebf 100644 --- a/submodules/TelegramUI/Sources/ComposeController.swift +++ b/submodules/TelegramUI/Sources/ComposeController.swift @@ -125,7 +125,7 @@ public class ComposeControllerImpl: ViewController, ComposeController { self.contactsNode.openCreateNewGroup = { [weak self] in if let strongSelf = self { - let controller = strongSelf.context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams(context: strongSelf.context, mode: .groupCreation, onlyWriteable: true)) + let controller = strongSelf.context.sharedContext.makeContactMultiselectionController(ContactMultiselectionControllerParams(context: strongSelf.context, mode: .groupCreation(isCall: false), onlyWriteable: true)) (strongSelf.navigationController as? NavigationController)?.pushViewController(controller, completion: { [weak self] in if let strongSelf = self { strongSelf.contactsNode.contactListNode.listNode.clearHighlightAnimated(true) diff --git a/submodules/TelegramUI/Sources/ContactMultiselectionController.swift b/submodules/TelegramUI/Sources/ContactMultiselectionController.swift index bce2a49f12..94131b233b 100644 --- a/submodules/TelegramUI/Sources/ContactMultiselectionController.swift +++ b/submodules/TelegramUI/Sources/ContactMultiselectionController.swift @@ -241,8 +241,13 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection } switch self.mode { - case .groupCreation: - let maxCount: Int32 = self.limitsConfiguration?.maxSupergroupMemberCount ?? 5000 + case let .groupCreation(isCall): + let maxCount: Int32 + if isCall { + maxCount = self.context.userLimits.maxConferenceParticipantCount + } else { + maxCount = self.limitsConfiguration?.maxSupergroupMemberCount ?? 5000 + } let count: Int switch self.contactsNode.contentNode { case let .contacts(contactsNode): @@ -250,8 +255,12 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection case let .chats(chatsNode): count = chatsNode.currentState.selectedPeerIds.count } - self.titleView.title = CounterControllerTitle(title: self.params.title ?? self.presentationData.strings.Compose_NewGroupTitle, counter: "\(count)/\(maxCount)") - if self.rightNavigationButton == nil { + if isCall && count == 0 { + self.titleView.title = CounterControllerTitle(title: self.params.title ?? self.presentationData.strings.Compose_NewGroupTitle, counter: nil) + } else { + self.titleView.title = CounterControllerTitle(title: self.params.title ?? self.presentationData.strings.Compose_NewGroupTitle, counter: "\(count)/\(maxCount)") + } + if self.rightNavigationButton == nil && !isCall { 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 @@ -349,6 +358,10 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection if updatedState.selectedPeerIndices[.peer(peer.id)] == nil { removedTokenId = peer.id } else { + var selectedPeerMap = updatedState.selectedPeerMap + selectedPeerMap[.peer(peer.id)] = .peer(peer: peer, isGlobal: false, participantCount: nil) + updatedState = updatedState.withSelectedPeerMap(selectedPeerMap) + if updatedState.selectedPeerIndices.count >= maxRegularCount { displayCountAlert = true updatedState = updatedState.withToggledPeerId(.peer(peer.id)) @@ -538,8 +551,13 @@ class ContactMultiselectionControllerImpl: ViewController, ContactMultiselection break } switch strongSelf.mode { - case .groupCreation: - let maxCount: Int32 = strongSelf.limitsConfiguration?.maxSupergroupMemberCount ?? 5000 + case let .groupCreation(isCall): + let maxCount: Int32 + if isCall { + maxCount = strongSelf.context.userLimits.maxConferenceParticipantCount + } else { + maxCount = strongSelf.limitsConfiguration?.maxSupergroupMemberCount ?? 5000 + } strongSelf.titleView.title = CounterControllerTitle(title: strongSelf.presentationData.strings.Compose_NewGroupTitle, counter: "\(updatedCount)/\(maxCount)") case .premiumGifting: let maxCount: Int32 = strongSelf.limit ?? 10 diff --git a/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift b/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift index d2c4b95f4c..e555404005 100644 --- a/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift +++ b/submodules/TelegramUI/Sources/ContactMultiselectionControllerNode.swift @@ -14,6 +14,7 @@ import MultiAnimationRenderer import EditableTokenListNode import SolidRoundedButtonNode import ContextUI +import ComponentFlow private struct SearchResultEntry: Identifiable { let index: Int @@ -53,6 +54,7 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { var searchResultsNode: ContactListNode? private let context: AccountContext + private let mode: ContactMultiselectionControllerMode private var containerLayout: (ContainerViewLayout, CGFloat, CGFloat)? @@ -81,12 +83,15 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { private let isPeerEnabled: ((EnginePeer) -> Bool)? private let onlyWriteable: Bool private let isGroupInvitation: Bool + + private var bottomPanel: ComponentView? init(navigationBar: NavigationBar?, context: AccountContext, presentationData: PresentationData, updatedPresentationData: (initial: PresentationData, signal: Signal)?, mode: ContactMultiselectionControllerMode, isPeerEnabled: ((EnginePeer) -> Bool)?, attemptDisabledItemSelection: ((EnginePeer, ChatListDisabledPeerReason) -> Void)?, options: Signal<[ContactListAdditionalOption], NoError>, filters: [ContactListFilter], onlyWriteable: Bool, isGroupInvitation: Bool, limit: Int32?, reachedSelectionLimit: ((Int32) -> Void)?, present: @escaping (ViewController, Any?) -> Void) { self.navigationBar = navigationBar self.context = context self.presentationData = presentationData + self.mode = mode self.animationCache = context.animationCache self.animationRenderer = context.animationRenderer @@ -120,6 +125,17 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { self.footerPanelNode = FooterPanelNode(theme: self.presentationData.theme, strings: self.presentationData.strings, action: { proceedImpl?() }) + case let .groupCreation(isCall): + if isCall { + //TODO:localize + placeholder = "Search for contacts or usernames" + self.footerPanelNode = FooterPanelNode(theme: self.presentationData.theme, strings: self.presentationData.strings, action: { + proceedImpl?() + }) + } else { + placeholder = self.presentationData.strings.Compose_TokenListPlaceholder + self.footerPanelNode = nil + } default: placeholder = self.presentationData.strings.Compose_TokenListPlaceholder self.footerPanelNode = nil @@ -462,7 +478,24 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { if case let .contacts(contactListNode) = self.contentNode { count = contactListNode.selectionState?.selectedPeerIndices.count ?? 0 } - footerPanelNode.count = count + if case let .groupCreation(isCall) = self.mode, isCall { + //TODO:localize + if count == 0 { + // Don't set anything to prevent state update + } else if count <= 1 { + let callTitle: String + if case let .contacts(contactListNode) = self.contentNode, let peer = contactListNode.selectedPeers.first, case let .peer(peer, _, _) = peer { + callTitle = "Call \(EnginePeer(peer).compactDisplayTitle)" + } else { + callTitle = "Call" + } + footerPanelNode.content = FooterPanelNode.Content(title: callTitle, badge: "") + } else { + footerPanelNode.content = FooterPanelNode.Content(title: "Call", badge: "\(count)") + } + } else { + footerPanelNode.content = FooterPanelNode.Content(title: self.presentationData.strings.Premium_Gift_ContactSelection_Proceed, badge: count == 0 ? "" : "\(count)") + } let panelHeight = footerPanelNode.updateLayout(width: layout.size.width, sideInset: layout.safeInsets.left, bottomInset: headerInsets.bottom, transition: transition) if count == 0 { transition.updateFrame(node: footerPanelNode, frame: CGRect(origin: CGPoint(x: 0.0, y: layout.size.height), size: CGSize(width: layout.size.width, height: panelHeight))) @@ -509,6 +542,16 @@ final class ContactMultiselectionControllerNode: ASDisplayNode { private final class FooterPanelNode: ASDisplayNode { + struct Content: Equatable { + let title: String + let badge: String + + init(title: String, badge: String) { + self.title = title + self.badge = badge + } + } + private let theme: PresentationTheme private let strings: PresentationStrings @@ -517,11 +560,11 @@ private final class FooterPanelNode: ASDisplayNode { private var validLayout: (CGFloat, CGFloat, CGFloat)? - var count: Int = 0 { + var content: Content { didSet { - if self.count != oldValue && self.count > 0 { - self.button.title = self.strings.Premium_Gift_ContactSelection_Proceed - self.button.badge = "\(self.count)" + if self.content != oldValue { + self.button.title = content.title + self.button.badge = content.badge.isEmpty ? nil : content.badge if let (width, sideInset, bottomInset) = self.validLayout { let _ = self.updateLayout(width: width, sideInset: sideInset, bottomInset: bottomInset, transition: .immediate) @@ -538,6 +581,8 @@ private final class FooterPanelNode: ASDisplayNode { self.separatorNode.backgroundColor = theme.rootController.navigationBar.separatorColor self.button = SolidRoundedButtonView(theme: SolidRoundedButtonTheme(theme: theme), height: 48.0, cornerRadius: 10.0) + + self.content = Content(title: self.strings.Premium_Gift_ContactSelection_Proceed, badge: "") super.init()