From a59f9e196958cec899caf6b9a5df1299fdc7ccd1 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 18 Jan 2021 11:38:07 +0300 Subject: [PATCH] Invite Links Fixes --- .../Sources/InviteLinkInviteController.swift | 8 +++++--- .../Sources/InviteLinkQRCodeController.swift | 10 +++++----- .../PeerInfoUI/Sources/ChannelMembersController.swift | 9 ++++++++- .../TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift b/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift index df21bef2fb..8a0428d476 100644 --- a/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift +++ b/submodules/InviteLinksUI/Sources/InviteLinkInviteController.swift @@ -178,12 +178,14 @@ public final class InviteLinkInviteController: ViewController { private let context: AccountContext private let peerId: PeerId + private weak var parentNavigationController: NavigationController? private var presentationDataDisposable: Disposable? - public init(context: AccountContext, peerId: PeerId) { + public init(context: AccountContext, peerId: PeerId, parentNavigationController: NavigationController?) { self.context = context self.peerId = peerId + self.parentNavigationController = parentNavigationController super.init(navigationBarPresentationData: nil) @@ -389,7 +391,7 @@ public final class InviteLinkInviteController: ViewController { self?.controller?.present(shareController, in: .window(.root)) }, manageLinks: { [weak self] in let controller = inviteLinkListController(context: context, peerId: peerId) - self?.controller?.push(controller) + self?.controller?.parentNavigationController?.pushViewController(controller) self?.controller?.dismiss() }) @@ -558,7 +560,7 @@ public final class InviteLinkInviteController: ViewController { let listTopInset = layoutTopInset + headerHeight let listNodeSize = CGSize(width: layout.size.width, height: layout.size.height - listTopInset) - insets.top = max(0.0, listNodeSize.height - visibleItemsHeight) + insets.top = max(0.0, listNodeSize.height - visibleItemsHeight - insets.bottom) let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition) let updateSizeAndInsets = ListViewUpdateSizeAndInsets(size: listNodeSize, insets: insets, duration: duration, curve: curve) diff --git a/submodules/InviteLinksUI/Sources/InviteLinkQRCodeController.swift b/submodules/InviteLinksUI/Sources/InviteLinkQRCodeController.swift index 7dc743a424..4064450726 100644 --- a/submodules/InviteLinksUI/Sources/InviteLinkQRCodeController.swift +++ b/submodules/InviteLinksUI/Sources/InviteLinkQRCodeController.swift @@ -209,7 +209,7 @@ public final class InviteLinkQRCodeController: ViewController { self.contentContainerNode.addSubnode(self.qrIconNode) self.contentContainerNode.addSubnode(self.qrButtonNode) - let textFont = Font.regular(16.0) + let textFont = Font.regular(13.0) self.textNode.attributedText = NSAttributedString(string: self.presentationData.strings.InviteLink_QRCode_Info, font: textFont, textColor: secondaryTextColor) self.buttonNode.title = self.presentationData.strings.InviteLink_QRCode_Share @@ -352,7 +352,7 @@ public final class InviteLinkQRCodeController: ViewController { let _ = imageApply() - let imageFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - imageSize.width) / 2.0), y: insets.top + 24.0), size: imageSize) + let imageFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - imageSize.width) / 2.0), y: insets.top + 16.0), size: imageSize) transition.updateFrame(node: self.qrImageNode, frame: imageFrame) transition.updateFrame(node: self.qrButtonNode, frame: imageFrame) @@ -365,7 +365,7 @@ public final class InviteLinkQRCodeController: ViewController { let inset: CGFloat = 22.0 let textSize = self.textNode.updateLayout(CGSize(width: layout.size.width - inset * 2.0, height: CGFloat.greatestFiniteMagnitude)) - let textFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - textSize.width) / 2.0), y: imageFrame.maxX + 20.0), size: textSize) + let textFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - textSize.width) / 2.0), y: imageFrame.maxY + 20.0), size: textSize) transition.updateFrame(node: self.textNode, frame: textFrame) let buttonSideInset: CGFloat = 16.0 @@ -379,7 +379,7 @@ public final class InviteLinkQRCodeController: ViewController { let titleHeight: CGFloat = 54.0 - let contentHeight = titleHeight + textSize.height + imageSize.height + bottomInset + 52.0 + 77.0 + let contentHeight = titleHeight + textSize.height + imageSize.height + bottomInset + 121.0 let width = horizontalContainerFillingSizeForLayout(layout: layout, sideInset: layout.safeInsets.left) @@ -401,7 +401,7 @@ public final class InviteLinkQRCodeController: ViewController { transition.updateFrame(node: self.titleNode, frame: titleFrame) let cancelSize = self.cancelButton.measure(CGSize(width: width, height: titleHeight)) - let cancelFrame = CGRect(origin: CGPoint(x: width - cancelSize.width - 16.0, y: 16.0), size: cancelSize) + let cancelFrame = CGRect(origin: CGPoint(x: width - cancelSize.width - 16.0, y: 18.0), size: cancelSize) transition.updateFrame(node: self.cancelButton, frame: cancelFrame) let buttonInset: CGFloat = 16.0 diff --git a/submodules/PeerInfoUI/Sources/ChannelMembersController.swift b/submodules/PeerInfoUI/Sources/ChannelMembersController.swift index 7de336d97f..6cdbcbca62 100644 --- a/submodules/PeerInfoUI/Sources/ChannelMembersController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelMembersController.swift @@ -342,6 +342,8 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) -> var pushControllerImpl: ((ViewController) -> Void)? var dismissInputImpl: (() -> Void)? + var getControllerImpl: (() -> ViewController?)? + let actionsDisposable = DisposableSet() let addMembersDisposable = MetaDisposable() @@ -462,7 +464,9 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) -> pushControllerImpl?(controller) } }, inviteViaLink: { - presentControllerImpl?(InviteLinkInviteController(context: context, peerId: peerId), nil) + if let controller = getControllerImpl?() { + presentControllerImpl?(InviteLinkInviteController(context: context, peerId: peerId, parentNavigationController: controller.navigationController as? NavigationController), nil) + } }) let peerView = context.account.viewTracker.peerView(peerId) @@ -551,6 +555,9 @@ public func channelMembersController(context: AccountContext, peerId: PeerId) -> dismissInputImpl = { [weak controller] in controller?.view.endEditing(true) } + getControllerImpl = { [weak controller] in + return controller + } 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/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 8a4f3bc6ec..824140d686 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -4551,7 +4551,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD contactsController?.push(visibilityController) } else { - contactsController?.present(InviteLinkInviteController(context: context, peerId: groupPeer.id), in: .window(.root)) + contactsController?.present(InviteLinkInviteController(context: context, peerId: groupPeer.id, parentNavigationController: contactsController?.navigationController as? NavigationController), in: .window(.root)) } }