From 69ee217fd7b4fcf718a2cb8da7351d78c2f32590 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Sat, 2 Nov 2019 23:02:42 +0400 Subject: [PATCH] Support input dismissal in controllers that use member search node --- .../Sources/ChannelAdminsController.swift | 36 +++++++++++-------- .../Sources/ChannelBlacklistController.swift | 6 ++++ .../Sources/ChannelMembersController.swift | 6 ++++ .../ChannelPermissionsController.swift | 6 ++++ 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift b/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift index ffd3b14477..121b8bb980 100644 --- a/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelAdminsController.swift @@ -498,6 +498,7 @@ public func channelAdminsController(context: AccountContext, peerId: PeerId, loa var pushControllerImpl: ((ViewController) -> Void)? var presentControllerImpl: ((ViewController, Any?) -> Void)? + var dismissInputImpl: (() -> Void)? let actionsDisposable = DisposableSet() @@ -584,24 +585,24 @@ public func channelAdminsController(context: AccountContext, peerId: PeerId, loa } if let participant = participant { switch participant.participant { - case .creator: - return - case let .member(_, _, _, banInfo, _): - if let banInfo = banInfo { - var canUnban = false - if banInfo.restrictedBy != context.account.peerId { + case .creator: + return + case let .member(_, _, _, banInfo, _): + if let banInfo = banInfo { + var canUnban = false + if banInfo.restrictedBy != context.account.peerId { + canUnban = true + } + if let channel = peerView.peers[peerId] as? TelegramChannel { + if channel.hasPermission(.banMembers) { canUnban = true } - if let channel = peerView.peers[peerId] as? TelegramChannel { - if channel.hasPermission(.banMembers) { - canUnban = true - } - } - if !canUnban { - presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Channel_Members_AddAdminErrorBlacklisted, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) - return - } } + if !canUnban { + presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Channel_Members_AddAdminErrorBlacklisted, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil) + return + } + } } } pushControllerImpl?(channelAdminController(context: context, peerId: peerId, adminId: peer.id, initialParticipant: participant?.participant, updated: { _ in @@ -746,6 +747,8 @@ public func channelAdminsController(context: AccountContext, peerId: PeerId, loa } }, pushController: { c in pushControllerImpl?(c) + }, dismissInput: { + dismissInputImpl?() }) } @@ -772,6 +775,9 @@ public func channelAdminsController(context: AccountContext, peerId: PeerId, loa controller.view.endEditing(true) } } + dismissInputImpl = { [weak controller] in + controller?.view.endEditing(true) + } upgradedToSupergroupImpl = { [weak controller] upgradedPeerId, f in guard let controller = controller, let navigationController = controller.navigationController as? NavigationController else { return diff --git a/submodules/PeerInfoUI/Sources/ChannelBlacklistController.swift b/submodules/PeerInfoUI/Sources/ChannelBlacklistController.swift index f4e88773b3..400d178646 100644 --- a/submodules/PeerInfoUI/Sources/ChannelBlacklistController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelBlacklistController.swift @@ -277,6 +277,7 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId) var presentControllerImpl: ((ViewController, Any?) -> Void)? var pushControllerImpl: ((ViewController) -> Void)? + var dismissInputImpl: (() -> Void)? let actionsDisposable = DisposableSet() @@ -492,6 +493,8 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId) } }, pushController: { c in pushControllerImpl?(c) + }, dismissInput: { + dismissInputImpl?() }) } @@ -517,6 +520,9 @@ public func channelBlacklistController(context: AccountContext, peerId: PeerId) (controller.navigationController as? NavigationController)?.pushViewController(c) } } + dismissInputImpl = { [weak controller] in + controller?.view.endEditing(true) + } controller.visibleBottomContentOffsetChanged = { offset in if case let .known(value) = offset, value < 40.0 { context.peerChannelMemberCategoriesContextsManager.loadMore(peerId: peerId, control: loadMoreControl) diff --git a/submodules/PeerInfoUI/Sources/ChannelMembersController.swift b/submodules/PeerInfoUI/Sources/ChannelMembersController.swift index a7b285875b..05e0c8f130 100644 --- a/submodules/PeerInfoUI/Sources/ChannelMembersController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelMembersController.swift @@ -339,6 +339,7 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) -> var presentControllerImpl: ((ViewController, Any?) -> Void)? var pushControllerImpl: ((ViewController) -> Void)? + var dismissInputImpl: (() -> Void)? let actionsDisposable = DisposableSet() @@ -506,6 +507,8 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) -> } }, pushController: { c in pushControllerImpl?(c) + }, dismissInput: { + dismissInputImpl?() }) } @@ -537,6 +540,9 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) -> (controller.navigationController as? NavigationController)?.pushViewController(c) } } + dismissInputImpl = { [weak controller] in + controller?.view.endEditing(true) + } controller.visibleBottomContentOffsetChanged = { offset in if let loadMoreControl = loadMoreControl, case let .known(value) = offset, value < 40.0 { context.peerChannelMemberCategoriesContextsManager.loadMore(peerId: peerId, control: loadMoreControl) diff --git a/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift b/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift index 48e544fd06..3a9dde05fe 100644 --- a/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift @@ -466,6 +466,7 @@ public func channelPermissionsController(context: AccountContext, peerId origina var presentControllerImpl: ((ViewController, Any?) -> Void)? var pushControllerImpl: ((ViewController) -> Void)? + var dismissInputImpl: (() -> Void)? let actionsDisposable = DisposableSet() @@ -803,6 +804,8 @@ public func channelPermissionsController(context: AccountContext, peerId origina } }, pushController: { c in pushControllerImpl?(c) + }, dismissInput: { + dismissInputImpl?() }) } @@ -828,6 +831,9 @@ public func channelPermissionsController(context: AccountContext, peerId origina (controller.navigationController as? NavigationController)?.pushViewController(c) } } + dismissInputImpl = { [weak controller] in + controller?.view.endEditing(true) + } upgradedToSupergroupImpl = { [weak controller] upgradedPeerId, f in guard let controller = controller, let navigationController = controller.navigationController as? NavigationController else { return