From 17595d72ddc274675af8272567f37732301ac173 Mon Sep 17 00:00:00 2001 From: Peter <> Date: Tue, 18 Jun 2019 16:04:59 +0100 Subject: [PATCH] iOS 13: temporary fix for status bar color iOS 13: fix chat input field --- .../TelegramUI/TelegramUI/AppDelegate.swift | 7 +++++ .../TelegramUI/ChatTextInputPanelNode.swift | 26 ++++++++++--------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/submodules/TelegramUI/TelegramUI/AppDelegate.swift b/submodules/TelegramUI/TelegramUI/AppDelegate.swift index b0e5210975..847e73a19e 100644 --- a/submodules/TelegramUI/TelegramUI/AppDelegate.swift +++ b/submodules/TelegramUI/TelegramUI/AppDelegate.swift @@ -28,6 +28,7 @@ private func encodeText(_ string: String, _ key: Int) -> String { } private let statusBarRootViewClass: AnyClass = NSClassFromString("UIStatusBar")! +private let statusBarPlaceholderClass: AnyClass? = NSClassFromString("UIStatusBar_Placeholder") private let cutoutStatusBarForegroundClass: AnyClass? = NSClassFromString("_UIStatusBar") private let keyboardViewClass: AnyClass? = NSClassFromString(encodeText("VJJoqvuTfuIptuWjfx", -1))! private let keyboardViewContainerClass: AnyClass? = NSClassFromString(encodeText("VJJoqvuTfuDpoubjofsWjfx", -1))! @@ -65,6 +66,12 @@ private class ApplicationStatusBarHost: StatusBarHost { if containerView.isKind(of: statusBarRootViewClass) { return containerView } + if let statusBarPlaceholderClass = statusBarPlaceholderClass { + if containerView.isKind(of: statusBarPlaceholderClass) { + return containerView + } + } + for subview in containerView.subviews { if let cutoutStatusBarForegroundClass = cutoutStatusBarForegroundClass, subview.isKind(of: cutoutStatusBarForegroundClass) { diff --git a/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift b/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift index 26fb45b7d4..ae04d17996 100644 --- a/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatTextInputPanelNode.swift @@ -202,7 +202,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { let textInputContainer: ASDisplayNode var textInputNode: EditableTextNode? - let textInputBackgroundView: UIImageView + let textInputBackgroundNode: ASImageNode let actionButtons: ChatTextInputActionButtonsNode var mediaRecordingAccessibilityArea: AccessibilityAreaNode? @@ -322,7 +322,9 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { self.textInputContainer.clipsToBounds = true self.textInputContainer.backgroundColor = theme.chat.inputPanel.inputBackgroundColor - self.textInputBackgroundView = UIImageView() + self.textInputBackgroundNode = ASImageNode() + self.textInputBackgroundNode.displaysAsynchronously = false + self.textInputBackgroundNode.displayWithoutProcessing = true self.textPlaceholderNode = ImmediateTextNode() self.textPlaceholderNode.maximumNumberOfLines = 1 self.textPlaceholderNode.isUserInteractionEnabled = false @@ -407,21 +409,21 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { self.searchLayoutClearButton.addSubview(self.searchLayoutProgressView) self.addSubnode(self.textInputContainer) - self.view.addSubview(self.textInputBackgroundView) + self.addSubnode(self.textInputBackgroundNode) self.addSubnode(self.textPlaceholderNode) self.view.addSubview(self.searchLayoutClearButton) - self.textInputBackgroundView.clipsToBounds = true + self.textInputBackgroundNode.clipsToBounds = true let recognizer = TouchDownGestureRecognizer(target: self, action: #selector(self.textInputBackgroundViewTap(_:))) recognizer.touchDown = { [weak self] in if let strongSelf = self { strongSelf.ensureFocused() } } - self.textInputBackgroundView.addGestureRecognizer(recognizer) - self.textInputBackgroundView.isUserInteractionEnabled = true + self.textInputBackgroundNode.isUserInteractionEnabled = true + self.textInputBackgroundNode.view.addGestureRecognizer(recognizer) } required init?(coder aDecoder: NSCoder) { @@ -490,8 +492,8 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { textInputNode.frame = CGRect(origin: CGPoint(x: self.textInputViewInternalInsets.left, y: self.textInputViewInternalInsets.top), size: CGSize(width: textInputFrame.size.width - (self.textInputViewInternalInsets.left + self.textInputViewInternalInsets.right + accessoryButtonsWidth), height: textInputFrame.size.height - self.textInputViewInternalInsets.top - self.textInputViewInternalInsets.bottom)) } - self.textInputBackgroundView.isUserInteractionEnabled = false - self.textInputBackgroundView.removeGestureRecognizer(self.textInputBackgroundView.gestureRecognizers![0]) + self.textInputBackgroundNode.isUserInteractionEnabled = false + self.textInputBackgroundNode.view.removeGestureRecognizer(self.textInputBackgroundNode.view.gestureRecognizers![0]) let recognizer = TouchDownGestureRecognizer(target: self, action: #selector(self.textInputBackgroundViewTap(_:))) recognizer.touchDown = { [weak self] in @@ -647,7 +649,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { let textFieldMinHeight = calclulateTextFieldMinHeight(interfaceState, metrics: metrics) let minimalInputHeight: CGFloat = 2.0 + textFieldMinHeight - self.textInputBackgroundView.image = textInputBackgroundImage(backgroundColor: interfaceState.theme.chat.inputPanel.panelBackgroundColor, strokeColor: interfaceState.theme.chat.inputPanel.inputStrokeColor, diameter: minimalInputHeight) + self.textInputBackgroundNode.image = textInputBackgroundImage(backgroundColor: interfaceState.theme.chat.inputPanel.panelBackgroundColor, strokeColor: interfaceState.theme.chat.inputPanel.inputStrokeColor, diameter: minimalInputHeight) self.searchLayoutClearButton.setImage(PresentationResourcesChat.chatInputTextFieldClearImage(interfaceState.theme), for: []) @@ -799,7 +801,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { var audioRecordingItemsVerticalOffset: CGFloat = 0.0 if let mediaRecordingState = interfaceState.inputTextPanelState.mediaRecordingState { audioRecordingItemsVerticalOffset = panelHeight * 2.0 - transition.updateAlpha(layer: self.textInputBackgroundView.layer, alpha: 0.0) + transition.updateAlpha(layer: self.textInputBackgroundNode.layer, alpha: 0.0) if let textInputNode = self.textInputNode { transition.updateAlpha(node: textInputNode, alpha: 0.0) } @@ -908,7 +910,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } else { self.actionButtons.micButton.audioRecorder = nil self.actionButtons.micButton.videoRecordingStatus = nil - transition.updateAlpha(layer: self.textInputBackgroundView.layer, alpha: 1.0) + transition.updateAlpha(layer: self.textInputBackgroundNode.layer, alpha: 1.0) if let textInputNode = self.textInputNode { transition.updateAlpha(node: textInputNode, alpha: 1.0) } @@ -1056,7 +1058,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { transition.updateFrame(node: self.textPlaceholderNode, frame: CGRect(origin: CGPoint(x: leftInset + textFieldInsets.left + self.textInputViewInternalInsets.left, y: textFieldInsets.top + self.textInputViewInternalInsets.top + self.textInputViewRealInsets.top + audioRecordingItemsVerticalOffset + UIScreenPixel), size: self.textPlaceholderNode.frame.size)) - transition.updateFrame(layer: self.textInputBackgroundView.layer, frame: CGRect(x: leftInset + textFieldInsets.left, y: textFieldInsets.top + audioRecordingItemsVerticalOffset, width: baseWidth - textFieldInsets.left - textFieldInsets.right + textInputBackgroundWidthOffset, height: panelHeight - textFieldInsets.top - textFieldInsets.bottom)) + transition.updateFrame(layer: self.textInputBackgroundNode.layer, frame: CGRect(x: leftInset + textFieldInsets.left, y: textFieldInsets.top + audioRecordingItemsVerticalOffset, width: baseWidth - textFieldInsets.left - textFieldInsets.right + textInputBackgroundWidthOffset, height: panelHeight - textFieldInsets.top - textFieldInsets.bottom)) var nextButtonTopRight = CGPoint(x: width - rightInset - textFieldInsets.right - accessoryButtonInset, y: panelHeight - textFieldInsets.bottom - minimalInputHeight + audioRecordingItemsVerticalOffset) for (_, button) in self.accessoryItemButtons.reversed() {