Various fixes

This commit is contained in:
Ilya Laktyushin 2023-02-18 00:51:36 +04:00
parent 1acde55d24
commit ef96be345c
15 changed files with 139 additions and 26 deletions

View File

@ -119,6 +119,10 @@ public struct Transition {
public static func easeInOut(duration: Double) -> Transition { public static func easeInOut(duration: Double) -> Transition {
return Transition(animation: .curve(duration: duration, curve: .easeInOut)) return Transition(animation: .curve(duration: duration, curve: .easeInOut))
} }
public static func spring(duration: Double) -> Transition {
return Transition(animation: .curve(duration: duration, curve: .spring))
}
public init(animation: Animation) { public init(animation: Animation) {
self.animation = animation self.animation = animation

View File

@ -126,7 +126,7 @@ public final class Button: Component {
alpha = 1.0 alpha = 1.0
} }
} else { } else {
alpha = 0.4 alpha = 0.3
} }
transition.setAlpha(view: self.contentView, alpha: alpha) transition.setAlpha(view: self.contentView, alpha: alpha)
} }

View File

@ -1193,22 +1193,25 @@ open class NavigationController: UINavigationController, ContainableController,
split.isInFocus = true split.isInFocus = true
} }
var masterTopHasOpaque = topHasOpaque
var detailTopHasOpaque = topHasOpaque
if let controller = split.masterControllers.last { if let controller = split.masterControllers.last {
if topHasOpaque { if masterTopHasOpaque {
controller.displayNode.accessibilityElementsHidden = true controller.displayNode.accessibilityElementsHidden = true
} else { } else {
if controller.isOpaqueWhenInOverlay || controller.blocksBackgroundWhenInOverlay { if controller.isOpaqueWhenInOverlay || controller.blocksBackgroundWhenInOverlay {
topHasOpaque = true masterTopHasOpaque = true
} }
controller.displayNode.accessibilityElementsHidden = false controller.displayNode.accessibilityElementsHidden = false
} }
} }
if let controller = split.detailControllers.last { if let controller = split.detailControllers.last {
if topHasOpaque { if detailTopHasOpaque {
controller.displayNode.accessibilityElementsHidden = true controller.displayNode.accessibilityElementsHidden = true
} else { } else {
if controller.isOpaqueWhenInOverlay || controller.blocksBackgroundWhenInOverlay { if controller.isOpaqueWhenInOverlay || controller.blocksBackgroundWhenInOverlay {
topHasOpaque = true detailTopHasOpaque = true
} }
controller.displayNode.accessibilityElementsHidden = false controller.displayNode.accessibilityElementsHidden = false
} }

View File

@ -9,7 +9,7 @@ open class SparseNode: ASDisplayNode {
if self.alpha.isZero { if self.alpha.isZero {
return nil return nil
} }
if !self.bounds.contains(point) { if !self.bounds.inset(by: self.hitTestSlop).contains(point) {
return nil return nil
} }
for view in self.view.subviews.reversed() { for view in self.view.subviews.reversed() {

View File

@ -187,8 +187,10 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
private let acceptHeaderNode: ImmediateTextNode private let acceptHeaderNode: ImmediateTextNode
private let secretChatsTitleNode: ImmediateTextNode private let secretChatsTitleNode: ImmediateTextNode
private let secretChatsSwitchNode: SwitchNode private let secretChatsSwitchNode: SwitchNode
private let secretChatsActivateAreaNode: AccessibilityAreaNode
private let incomingCallsTitleNode: ImmediateTextNode private let incomingCallsTitleNode: ImmediateTextNode
private let incomingCallsSwitchNode: SwitchNode private let incomingCallsSwitchNode: SwitchNode
private let incomingCallsActivateAreaNode: AccessibilityAreaNode
private let acceptSeparatorNode: ASDisplayNode private let acceptSeparatorNode: ASDisplayNode
private let cancelButton: HighlightableButtonNode private let cancelButton: HighlightableButtonNode
@ -264,8 +266,13 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.incomingCallsTitleNode = ImmediateTextNode() self.incomingCallsTitleNode = ImmediateTextNode()
self.incomingCallsSwitchNode = SwitchNode() self.incomingCallsSwitchNode = SwitchNode()
self.secretChatsActivateAreaNode = AccessibilityAreaNode()
self.incomingCallsActivateAreaNode = AccessibilityAreaNode()
self.cancelButton = HighlightableButtonNode() self.cancelButton = HighlightableButtonNode()
self.cancelButton.setImage(closeButtonImage(theme: self.presentationData.theme), for: .normal) self.cancelButton.setImage(closeButtonImage(theme: self.presentationData.theme), for: .normal)
self.cancelButton.accessibilityLabel = presentationData.strings.Common_Close
self.cancelButton.accessibilityTraits = [.button]
self.terminateButton = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(backgroundColor: self.presentationData.theme.list.itemBlocksBackgroundColor, foregroundColor: self.presentationData.theme.list.itemDestructiveColor), font: .regular, height: 44.0, cornerRadius: 11.0, gloss: false) self.terminateButton = SolidRoundedButtonNode(theme: SolidRoundedButtonTheme(backgroundColor: self.presentationData.theme.list.itemBlocksBackgroundColor, foregroundColor: self.presentationData.theme.list.itemDestructiveColor), font: .regular, height: 44.0, cornerRadius: 11.0, gloss: false)
@ -341,6 +348,9 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.secretChatsSwitchNode.isOn = session.flags.contains(.acceptsSecretChats) self.secretChatsSwitchNode.isOn = session.flags.contains(.acceptsSecretChats)
self.incomingCallsSwitchNode.isOn = session.flags.contains(.acceptsIncomingCalls) self.incomingCallsSwitchNode.isOn = session.flags.contains(.acceptsIncomingCalls)
self.secretChatsActivateAreaNode.accessibilityValue = self.secretChatsSwitchNode.isOn ? presentationData.strings.VoiceOver_Common_On : presentationData.strings.VoiceOver_Common_Off
self.incomingCallsActivateAreaNode.accessibilityValue = self.incomingCallsSwitchNode.isOn ? presentationData.strings.VoiceOver_Common_On : presentationData.strings.VoiceOver_Common_Off
if !session.flags.contains(.passwordPending) && session.apiId != 22 { if !session.flags.contains(.passwordPending) && session.apiId != 22 {
hasIncomingCalls = true hasIncomingCalls = true
if ![2040, 2496].contains(session.apiId) { if ![2040, 2496].contains(session.apiId) {
@ -385,24 +395,42 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
} }
self.titleNode.attributedText = NSAttributedString(string: title, font: Font.regular(30.0), textColor: textColor) self.titleNode.attributedText = NSAttributedString(string: title, font: Font.regular(30.0), textColor: textColor)
self.titleNode.accessibilityLabel = title
self.titleNode.isAccessibilityElement = true
self.textNode.attributedText = NSAttributedString(string: subtitle, font: Font.regular(17.0), textColor: subtitleActive ? accentColor : secondaryTextColor) self.textNode.attributedText = NSAttributedString(string: subtitle, font: Font.regular(17.0), textColor: subtitleActive ? accentColor : secondaryTextColor)
self.textNode.accessibilityLabel = subtitle
self.textNode.isAccessibilityElement = true
self.deviceTitleNode.attributedText = NSAttributedString(string: deviceTitle, font: Font.regular(17.0), textColor: textColor) self.deviceTitleNode.attributedText = NSAttributedString(string: deviceTitle, font: Font.regular(17.0), textColor: textColor)
self.deviceValueNode.attributedText = NSAttributedString(string: device, font: Font.regular(17.0), textColor: secondaryTextColor) self.deviceValueNode.attributedText = NSAttributedString(string: device, font: Font.regular(17.0), textColor: secondaryTextColor)
self.deviceValueNode.accessibilityLabel = deviceTitle
self.deviceValueNode.accessibilityValue = device
self.deviceValueNode.isAccessibilityElement = true
self.firstSeparatorNode = ASDisplayNode() self.firstSeparatorNode = ASDisplayNode()
self.firstSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor self.firstSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
self.ipTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_IP, font: Font.regular(17.0), textColor: textColor) self.ipTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_IP, font: Font.regular(17.0), textColor: textColor)
self.ipValueNode.attributedText = NSAttributedString(string: ip, font: Font.regular(17.0), textColor: secondaryTextColor) self.ipValueNode.attributedText = NSAttributedString(string: ip, font: Font.regular(17.0), textColor: secondaryTextColor)
self.ipValueNode.accessibilityLabel = self.presentationData.strings.AuthSessions_View_IP
self.ipValueNode.accessibilityValue = ip
self.ipValueNode.isAccessibilityElement = true
self.secondSeparatorNode = ASDisplayNode() self.secondSeparatorNode = ASDisplayNode()
self.secondSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor self.secondSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
self.locationTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_Location, font: Font.regular(17.0), textColor: textColor) self.locationTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_Location, font: Font.regular(17.0), textColor: textColor)
self.locationValueNode.attributedText = NSAttributedString(string: location, font: Font.regular(17.0), textColor: secondaryTextColor) self.locationValueNode.attributedText = NSAttributedString(string: location, font: Font.regular(17.0), textColor: secondaryTextColor)
self.locationValueNode.accessibilityLabel = self.presentationData.strings.AuthSessions_View_Location
self.locationValueNode.accessibilityValue = location
self.locationValueNode.isAccessibilityElement = true
self.locationInfoNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_LocationInfo, font: Font.regular(13.0), textColor: secondaryTextColor) self.locationInfoNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_LocationInfo, font: Font.regular(13.0), textColor: secondaryTextColor)
self.locationInfoNode.maximumNumberOfLines = 4 self.locationInfoNode.maximumNumberOfLines = 4
self.locationInfoNode.accessibilityLabel = self.presentationData.strings.AuthSessions_View_LocationInfo
self.locationInfoNode.isAccessibilityElement = true
self.acceptBackgroundNode = ASDisplayNode() self.acceptBackgroundNode = ASDisplayNode()
self.acceptBackgroundNode.clipsToBounds = true self.acceptBackgroundNode.clipsToBounds = true
@ -410,9 +438,18 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.acceptBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor self.acceptBackgroundNode.backgroundColor = self.presentationData.theme.list.itemBlocksBackgroundColor
self.acceptHeaderNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptTitle.uppercased(), font: Font.regular(17.0), textColor: textColor) self.acceptHeaderNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptTitle.uppercased(), font: Font.regular(17.0), textColor: textColor)
self.acceptHeaderNode.accessibilityLabel = self.presentationData.strings.AuthSessions_View_AcceptTitle
self.acceptHeaderNode.isAccessibilityElement = true
self.secretChatsTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptSecretChats, font: Font.regular(17.0), textColor: textColor) self.secretChatsTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptSecretChats, font: Font.regular(17.0), textColor: textColor)
self.incomingCallsTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptIncomingCalls, font: Font.regular(17.0), textColor: textColor) self.incomingCallsTitleNode.attributedText = NSAttributedString(string: self.presentationData.strings.AuthSessions_View_AcceptIncomingCalls, font: Font.regular(17.0), textColor: textColor)
self.secretChatsActivateAreaNode.accessibilityLabel = self.presentationData.strings.AuthSessions_View_AcceptSecretChats
self.secretChatsActivateAreaNode.accessibilityHint = self.presentationData.strings.VoiceOver_Common_SwitchHint
self.incomingCallsActivateAreaNode.accessibilityLabel = self.presentationData.strings.AuthSessions_View_AcceptIncomingCalls
self.incomingCallsActivateAreaNode.accessibilityHint = self.presentationData.strings.VoiceOver_Common_SwitchHint
self.acceptSeparatorNode = ASDisplayNode() self.acceptSeparatorNode = ASDisplayNode()
self.acceptSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor self.acceptSeparatorNode.backgroundColor = self.presentationData.theme.list.itemBlocksSeparatorColor
@ -463,23 +500,49 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
if hasSecretChats { if hasSecretChats {
self.contentContainerNode.addSubnode(self.secretChatsTitleNode) self.contentContainerNode.addSubnode(self.secretChatsTitleNode)
self.contentContainerNode.addSubnode(self.secretChatsSwitchNode) self.contentContainerNode.addSubnode(self.secretChatsSwitchNode)
self.contentContainerNode.addSubnode(self.secretChatsActivateAreaNode)
self.secretChatsSwitchNode.valueUpdated = { [weak self] value in self.secretChatsSwitchNode.valueUpdated = { [weak self] value in
if let strongSelf = self { if let strongSelf = self {
strongSelf.updateAcceptSecretChats?(value) strongSelf.updateAcceptSecretChats?(value)
strongSelf.secretChatsActivateAreaNode.accessibilityValue = value ? presentationData.strings.VoiceOver_Common_On : presentationData.strings.VoiceOver_Common_Off
} }
} }
self.secretChatsActivateAreaNode.activate = { [weak self] in
guard let strongSelf = self else {
return false
}
let value = !strongSelf.secretChatsSwitchNode.isOn
strongSelf.updateAcceptSecretChats?(value)
strongSelf.secretChatsActivateAreaNode.accessibilityValue = value ? presentationData.strings.VoiceOver_Common_On : presentationData.strings.VoiceOver_Common_Off
return true
}
self.contentContainerNode.addSubnode(self.acceptSeparatorNode) self.contentContainerNode.addSubnode(self.acceptSeparatorNode)
} }
self.contentContainerNode.addSubnode(self.incomingCallsTitleNode) self.contentContainerNode.addSubnode(self.incomingCallsTitleNode)
self.contentContainerNode.addSubnode(self.incomingCallsSwitchNode) self.contentContainerNode.addSubnode(self.incomingCallsSwitchNode)
self.contentContainerNode.addSubnode(self.incomingCallsActivateAreaNode)
self.incomingCallsSwitchNode.valueUpdated = { [weak self] value in self.incomingCallsSwitchNode.valueUpdated = { [weak self] value in
if let strongSelf = self { if let strongSelf = self {
strongSelf.updateAcceptIncomingCalls?(value) strongSelf.updateAcceptIncomingCalls?(value)
strongSelf.incomingCallsActivateAreaNode.accessibilityValue = value ? presentationData.strings.VoiceOver_Common_On : presentationData.strings.VoiceOver_Common_Off
} }
} }
self.incomingCallsActivateAreaNode.activate = { [weak self] in
guard let strongSelf = self else {
return false
}
let value = !strongSelf.incomingCallsSwitchNode.isOn
strongSelf.updateAcceptIncomingCalls?(value)
strongSelf.incomingCallsActivateAreaNode.accessibilityValue = value ? presentationData.strings.VoiceOver_Common_On : presentationData.strings.VoiceOver_Common_Off
return true
}
} }
self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside) self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside)
@ -800,6 +863,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
let switchSize = switchView.bounds.size let switchSize = switchView.bounds.size
self.secretChatsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.minY + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize) self.secretChatsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.minY + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize)
self.secretChatsActivateAreaNode.frame = CGRect(origin: CGPoint(x: secretFrame.minX, y: secretFrame.minY), size: CGSize(width: fieldFrame.width, height: fieldItemHeight))
} }
} }
@ -815,7 +879,8 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
} }
let switchSize = switchView.bounds.size let switchSize = switchView.bounds.size
self.incomingCallsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.maxY - fieldItemHeight + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize) self.incomingCallsSwitchNode.frame = CGRect(origin: CGPoint(x: fieldFrame.maxX - switchSize.width - inset, y: secretFrame.maxY - fieldItemHeight + floorToScreenPixels((fieldItemHeight - switchSize.height) / 2.0)), size: switchSize)
self.incomingCallsActivateAreaNode.frame = CGRect(origin: CGPoint(x: secretFrame.minX, y: secretFrame.maxY - fieldItemHeight), size: CGSize(width: fieldFrame.width, height: fieldItemHeight))
} }
if let _ = self.acceptBackgroundNode.supernode { if let _ = self.acceptBackgroundNode.supernode {
@ -833,8 +898,10 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
if isCurrent { if isCurrent {
contentHeight -= 68.0 contentHeight -= 68.0
self.terminateButton.isHidden = true self.terminateButton.isHidden = true
self.terminateButton.isAccessibilityElement = false
} else { } else {
self.terminateButton.isHidden = false self.terminateButton.isHidden = false
self.terminateButton.isAccessibilityElement = true
} }
let sideInset = floor((layout.size.width - width) / 2.0) let sideInset = floor((layout.size.width - width) / 2.0)

View File

@ -7203,8 +7203,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
} }
mappedTransition = (ChatHistoryListViewTransition(historyView: transition.historyView, deleteItems: deleteItems, insertItems: insertItems, updateItems: transition.updateItems, options: options, scrollToItem: scrollToItem, stationaryItemRange: stationaryItemRange, initialData: transition.initialData, keyboardButtonsMessage: transition.keyboardButtonsMessage, cachedData: transition.cachedData, cachedDataMessages: transition.cachedDataMessages, readStateData: transition.readStateData, scrolledToIndex: transition.scrolledToIndex, scrolledToSomeIndex: transition.scrolledToSomeIndex, peerType: transition.peerType, networkType: transition.networkType, animateIn: false, reason: transition.reason, flashIndicators: transition.flashIndicators), updateSizeAndInsets) mappedTransition = (ChatHistoryListViewTransition(historyView: transition.historyView, deleteItems: deleteItems, insertItems: insertItems, updateItems: transition.updateItems, options: options, scrollToItem: scrollToItem, stationaryItemRange: stationaryItemRange, initialData: transition.initialData, keyboardButtonsMessage: transition.keyboardButtonsMessage, cachedData: transition.cachedData, cachedDataMessages: transition.cachedDataMessages, readStateData: transition.readStateData, scrolledToIndex: transition.scrolledToIndex, scrolledToSomeIndex: transition.scrolledToSomeIndex, peerType: transition.peerType, networkType: transition.networkType, animateIn: false, reason: transition.reason, flashIndicators: transition.flashIndicators), updateSizeAndInsets)
}, updateExtraNavigationBarBackgroundHeight: { value, _ in }, updateExtraNavigationBarBackgroundHeight: { value, hitTestSlop, _ in
strongSelf.additionalNavigationBarBackgroundHeight = value strongSelf.additionalNavigationBarBackgroundHeight = value
strongSelf.additionalNavigationBarHitTestSlop = hitTestSlop
}) })
if let mappedTransition = mappedTransition { if let mappedTransition = mappedTransition {
@ -11064,6 +11065,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
private var suspendNavigationBarLayout: Bool = false private var suspendNavigationBarLayout: Bool = false
private var suspendedNavigationBarLayout: ContainerViewLayout? private var suspendedNavigationBarLayout: ContainerViewLayout?
private var additionalNavigationBarBackgroundHeight: CGFloat = 0.0 private var additionalNavigationBarBackgroundHeight: CGFloat = 0.0
private var additionalNavigationBarHitTestSlop: CGFloat = 0.0
override public func updateNavigationBarLayout(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { override public func updateNavigationBarLayout(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
if self.suspendNavigationBarLayout { if self.suspendNavigationBarLayout {
@ -11100,9 +11102,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
var navigationBarTransition = transition var navigationBarTransition = transition
self.chatDisplayNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition, listViewTransaction: { updateSizeAndInsets, additionalScrollDistance, scrollToTop, completion in self.chatDisplayNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition, listViewTransaction: { updateSizeAndInsets, additionalScrollDistance, scrollToTop, completion in
self.chatDisplayNode.historyNode.updateLayout(transition: transition, updateSizeAndInsets: updateSizeAndInsets, additionalScrollDistance: additionalScrollDistance, scrollToTop: scrollToTop, completion: completion) self.chatDisplayNode.historyNode.updateLayout(transition: transition, updateSizeAndInsets: updateSizeAndInsets, additionalScrollDistance: additionalScrollDistance, scrollToTop: scrollToTop, completion: completion)
}, updateExtraNavigationBarBackgroundHeight: { value, extraNavigationTransition in }, updateExtraNavigationBarBackgroundHeight: { value, hitTestSlop, extraNavigationTransition in
navigationBarTransition = extraNavigationTransition navigationBarTransition = extraNavigationTransition
self.additionalNavigationBarBackgroundHeight = value self.additionalNavigationBarBackgroundHeight = value
self.additionalNavigationBarHitTestSlop = hitTestSlop
}) })
if case .compact = layout.metrics.widthClass { if case .compact = layout.metrics.widthClass {
@ -11123,6 +11126,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self.suspendedNavigationBarLayout = suspendedNavigationBarLayout self.suspendedNavigationBarLayout = suspendedNavigationBarLayout
self.applyNavigationBarLayout(suspendedNavigationBarLayout, navigationLayout: self.navigationLayout(layout: layout), additionalBackgroundHeight: self.additionalNavigationBarBackgroundHeight, transition: navigationBarTransition) self.applyNavigationBarLayout(suspendedNavigationBarLayout, navigationLayout: self.navigationLayout(layout: layout), additionalBackgroundHeight: self.additionalNavigationBarBackgroundHeight, transition: navigationBarTransition)
} }
self.navigationBar?.additionalContentNode.hitTestSlop = UIEdgeInsets(top: 0.0, left: 0.0, bottom: self.additionalNavigationBarHitTestSlop, right: 0.0)
} }
func updateChatPresentationInterfaceState(animated: Bool = true, interactive: Bool, saveInterfaceState: Bool = false, _ f: (ChatPresentationInterfaceState) -> ChatPresentationInterfaceState, completion: @escaping (ContainedViewLayoutTransition) -> Void = { _ in }) { func updateChatPresentationInterfaceState(animated: Bool = true, interactive: Bool, saveInterfaceState: Bool = false, _ f: (ChatPresentationInterfaceState) -> ChatPresentationInterfaceState, completion: @escaping (ContainedViewLayoutTransition) -> Void = { _ in }) {

View File

@ -259,7 +259,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
if let (layout, navigationHeight) = self.validLayout { if let (layout, navigationHeight) = self.validLayout {
self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: .immediate, listViewTransaction: { _, _, _, _ in self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: .immediate, listViewTransaction: { _, _, _, _ in
}, updateExtraNavigationBarBackgroundHeight: { _, _ in }, updateExtraNavigationBarBackgroundHeight: { _, _, _ in
}) })
} }
} }
@ -829,7 +829,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
} }
} }
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition protoTransition: ContainedViewLayoutTransition, listViewTransaction: (ListViewUpdateSizeAndInsets, CGFloat, Bool, @escaping () -> Void) -> Void, updateExtraNavigationBarBackgroundHeight: (CGFloat, ContainedViewLayoutTransition) -> Void) { func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition protoTransition: ContainedViewLayoutTransition, listViewTransaction: (ListViewUpdateSizeAndInsets, CGFloat, Bool, @escaping () -> Void) -> Void, updateExtraNavigationBarBackgroundHeight: (CGFloat, CGFloat, ContainedViewLayoutTransition) -> Void) {
let transition: ContainedViewLayoutTransition let transition: ContainedViewLayoutTransition
if let _ = self.scheduledAnimateInAsOverlayFromNode { if let _ = self.scheduledAnimateInAsOverlayFromNode {
transition = .immediate transition = .immediate
@ -1068,6 +1068,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
var immediatelyLayoutTitleAccessoryPanelNodeAndAnimateAppearance = false var immediatelyLayoutTitleAccessoryPanelNodeAndAnimateAppearance = false
var titleAccessoryPanelHeight: CGFloat? var titleAccessoryPanelHeight: CGFloat?
var titleAccessoryPanelBackgroundHeight: CGFloat? var titleAccessoryPanelBackgroundHeight: CGFloat?
var titleAccessoryPanelHitTestSlop: CGFloat?
var extraTransition = transition var extraTransition = transition
if let titleAccessoryPanelNode = titlePanelForChatPresentationInterfaceState(self.chatPresentationInterfaceState, context: self.context, currentPanel: self.titleAccessoryPanelNode, controllerInteraction: self.controllerInteraction, interfaceInteraction: self.interfaceInteraction) { if let titleAccessoryPanelNode = titlePanelForChatPresentationInterfaceState(self.chatPresentationInterfaceState, context: self.context, currentPanel: self.titleAccessoryPanelNode, controllerInteraction: self.controllerInteraction, interfaceInteraction: self.interfaceInteraction) {
if self.titleAccessoryPanelNode != titleAccessoryPanelNode { if self.titleAccessoryPanelNode != titleAccessoryPanelNode {
@ -1085,6 +1086,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
let layoutResult = titleAccessoryPanelNode.updateLayout(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: immediatelyLayoutTitleAccessoryPanelNodeAndAnimateAppearance ? .immediate : transition, interfaceState: self.chatPresentationInterfaceState) let layoutResult = titleAccessoryPanelNode.updateLayout(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: immediatelyLayoutTitleAccessoryPanelNodeAndAnimateAppearance ? .immediate : transition, interfaceState: self.chatPresentationInterfaceState)
titleAccessoryPanelHeight = layoutResult.insetHeight titleAccessoryPanelHeight = layoutResult.insetHeight
titleAccessoryPanelBackgroundHeight = layoutResult.backgroundHeight titleAccessoryPanelBackgroundHeight = layoutResult.backgroundHeight
titleAccessoryPanelHitTestSlop = layoutResult.hitTestSlop
if immediatelyLayoutTitleAccessoryPanelNodeAndAnimateAppearance { if immediatelyLayoutTitleAccessoryPanelNodeAndAnimateAppearance {
titleAccessoryPanelNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) titleAccessoryPanelNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
titleAccessoryPanelNode.subnodeTransform = CATransform3DMakeTranslation(0.0, -layoutResult.backgroundHeight, 0.0) titleAccessoryPanelNode.subnodeTransform = CATransform3DMakeTranslation(0.0, -layoutResult.backgroundHeight, 0.0)
@ -1460,11 +1462,13 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
transition.updateFrame(node: self.inputContextOverTextPanelContainer, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: layout.size.height))) transition.updateFrame(node: self.inputContextOverTextPanelContainer, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: layout.size.height)))
var extraNavigationBarHeight: CGFloat = 0.0 var extraNavigationBarHeight: CGFloat = 0.0
var extraNavigationBarHitTestSlop: CGFloat = 0.0
var titleAccessoryPanelFrame: CGRect? var titleAccessoryPanelFrame: CGRect?
if let _ = self.titleAccessoryPanelNode, let panelHeight = titleAccessoryPanelHeight { if let _ = self.titleAccessoryPanelNode, let panelHeight = titleAccessoryPanelHeight {
titleAccessoryPanelFrame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: panelHeight)) titleAccessoryPanelFrame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: layout.size.width, height: panelHeight))
insets.top += panelHeight insets.top += panelHeight
extraNavigationBarHeight += titleAccessoryPanelBackgroundHeight ?? 0.0 extraNavigationBarHeight += titleAccessoryPanelBackgroundHeight ?? 0.0
extraNavigationBarHitTestSlop = titleAccessoryPanelHitTestSlop ?? 0.0
} }
var translationPanelFrame: CGRect? var translationPanelFrame: CGRect?
@ -1474,7 +1478,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
extraNavigationBarHeight += panelHeight extraNavigationBarHeight += panelHeight
} }
updateExtraNavigationBarBackgroundHeight(extraNavigationBarHeight, extraTransition) updateExtraNavigationBarBackgroundHeight(extraNavigationBarHeight, extraNavigationBarHitTestSlop, extraTransition)
var importStatusPanelFrame: CGRect? var importStatusPanelFrame: CGRect?
if let _ = self.chatImportStatusPanel, let panelHeight = importStatusPanelHeight { if let _ = self.chatImportStatusPanel, let panelHeight = importStatusPanelHeight {
@ -3029,7 +3033,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
if let (layout, navigationHeight) = self.validLayout { if let (layout, navigationHeight) = self.validLayout {
self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: transition, listViewTransaction: { updateSizeAndInsets, additionalScrollDistance, scrollToTop, completion in self.containerLayoutUpdated(layout, navigationBarHeight: navigationHeight, transition: transition, listViewTransaction: { updateSizeAndInsets, additionalScrollDistance, scrollToTop, completion in
self.historyNode.updateLayout(transition: transition, updateSizeAndInsets: updateSizeAndInsets, additionalScrollDistance: additionalScrollDistance, scrollToTop: scrollToTop, completion: completion) self.historyNode.updateLayout(transition: transition, updateSizeAndInsets: updateSizeAndInsets, additionalScrollDistance: additionalScrollDistance, scrollToTop: scrollToTop, completion: completion)
}, updateExtraNavigationBarBackgroundHeight: { _, _ in }, updateExtraNavigationBarBackgroundHeight: { _, _, _ in
}) })
} }
} }

View File

@ -52,6 +52,9 @@ func titlePanelForChatPresentationInterfaceState(_ chatPresentationInterfaceStat
if inhibitTitlePanelDisplay, let selectedContextValue = selectedContext { if inhibitTitlePanelDisplay, let selectedContextValue = selectedContext {
switch selectedContextValue { switch selectedContextValue {
case .pinnedMessage: case .pinnedMessage:
if case .peer = chatPresentationInterfaceState.chatLocation {
selectedContext = nil
}
break break
default: default:
selectedContext = nil selectedContext = nil

View File

@ -208,7 +208,7 @@ final class ChatInviteRequestsTitlePanelNode: ChatTitleAccessoryPanelNode {
self.activateAreaNode.frame = CGRect(origin: .zero, size: CGSize(width: width, height: panelHeight)) self.activateAreaNode.frame = CGRect(origin: .zero, size: CGSize(width: width, height: panelHeight))
self.activateAreaNode.accessibilityLabel = interfaceState.strings.Conversation_RequestsToJoin(self.count) self.activateAreaNode.accessibilityLabel = interfaceState.strings.Conversation_RequestsToJoin(self.count)
return LayoutResult(backgroundHeight: initialPanelHeight, insetHeight: panelHeight) return LayoutResult(backgroundHeight: initialPanelHeight, insetHeight: panelHeight, hitTestSlop: 0.0)
} }
@objc func buttonPressed() { @objc func buttonPressed() {

View File

@ -522,7 +522,7 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
} }
}*/ }*/
return LayoutResult(backgroundHeight: panelHeight, insetHeight: panelHeight) return LayoutResult(backgroundHeight: panelHeight, insetHeight: panelHeight, hitTestSlop: 0.0)
} }
private func enqueueTransition(width: CGFloat, panelHeight: CGFloat, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition, animation: PinnedMessageAnimation?, pinnedMessage: ChatPinnedMessage, theme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, dateTimeFormat: PresentationDateTimeFormat, accountPeerId: PeerId, firstTime: Bool, isReplyThread: Bool, translateToLanguage: String?) { private func enqueueTransition(width: CGFloat, panelHeight: CGFloat, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition, animation: PinnedMessageAnimation?, pinnedMessage: ChatPinnedMessage, theme: PresentationTheme, strings: PresentationStrings, nameDisplayOrder: PresentationPersonNameOrder, dateTimeFormat: PresentationDateTimeFormat, accountPeerId: PeerId, firstTime: Bool, isReplyThread: Bool, translateToLanguage: String?) {

View File

@ -168,6 +168,14 @@ private final class ChatInfoTitlePanelInviteInfoNode: ASDisplayNode {
} }
} }
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let result = super.hitTest(point, with: event)
if result == self.view {
return nil
}
return result
}
func update(width: CGFloat, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, chatPeer: Peer, invitedBy: Peer, transition: ContainedViewLayoutTransition) -> CGFloat { func update(width: CGFloat, theme: PresentationTheme, strings: PresentationStrings, wallpaper: TelegramWallpaper, chatPeer: Peer, invitedBy: Peer, transition: ContainedViewLayoutTransition) -> CGFloat {
let primaryTextColor = serviceMessageColorComponents(theme: theme, wallpaper: wallpaper).primaryText let primaryTextColor = serviceMessageColorComponents(theme: theme, wallpaper: wallpaper).primaryText
@ -603,6 +611,7 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
if let renderedPeer = interfaceState.renderedPeer { if let renderedPeer = interfaceState.renderedPeer {
chatPeer = renderedPeer.peers[renderedPeer.peerId] chatPeer = renderedPeer.peers[renderedPeer.peerId]
} }
var hitTestSlop: CGFloat = 0.0
if let chatPeer = chatPeer, (updatedButtons.contains(.block) || updatedButtons.contains(.reportSpam) || updatedButtons.contains(.reportUserSpam)), let invitedBy = interfaceState.contactStatus?.invitedBy { if let chatPeer = chatPeer, (updatedButtons.contains(.block) || updatedButtons.contains(.reportSpam) || updatedButtons.contains(.reportUserSpam)), let invitedBy = interfaceState.contactStatus?.invitedBy {
var inviteInfoTransition = transition var inviteInfoTransition = transition
let inviteInfoNode: ChatInfoTitlePanelInviteInfoNode let inviteInfoNode: ChatInfoTitlePanelInviteInfoNode
@ -623,6 +632,7 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
let inviteHeight = inviteInfoNode.update(width: width, theme: interfaceState.theme, strings: interfaceState.strings, wallpaper: interfaceState.chatWallpaper, chatPeer: chatPeer, invitedBy: invitedBy, transition: inviteInfoTransition) let inviteHeight = inviteInfoNode.update(width: width, theme: interfaceState.theme, strings: interfaceState.strings, wallpaper: interfaceState.chatWallpaper, chatPeer: chatPeer, invitedBy: invitedBy, transition: inviteInfoTransition)
inviteInfoTransition.updateFrame(node: inviteInfoNode, frame: CGRect(origin: CGPoint(x: 0.0, y: panelHeight + panelInset), size: CGSize(width: width, height: inviteHeight))) inviteInfoTransition.updateFrame(node: inviteInfoNode, frame: CGRect(origin: CGPoint(x: 0.0, y: panelHeight + panelInset), size: CGSize(width: width, height: inviteHeight)))
panelHeight += inviteHeight panelHeight += inviteHeight
hitTestSlop = -inviteHeight
} }
} else if let inviteInfoNode = self.inviteInfoNode { } else if let inviteInfoNode = self.inviteInfoNode {
self.inviteInfoNode = nil self.inviteInfoNode = nil
@ -658,7 +668,7 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
peerNearbyInfoNode?.removeFromSupernode() peerNearbyInfoNode?.removeFromSupernode()
}) })
} }
return LayoutResult(backgroundHeight: initialPanelHeight, insetHeight: panelHeight + panelInset) return LayoutResult(backgroundHeight: initialPanelHeight, insetHeight: panelHeight + panelInset, hitTestSlop: hitTestSlop)
} }
@objc func buttonPressed(_ view: UIButton) { @objc func buttonPressed(_ view: UIButton) {
@ -698,6 +708,9 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
return result return result
} }
} }
if point.y > 40.0 {
return nil
}
return super.hitTest(point, with: event) return super.hitTest(point, with: event)
} }
} }

View File

@ -56,6 +56,6 @@ final class ChatRequestInProgressTitlePanelNode: ChatTitleAccessoryPanelNode {
self.activateAreaNode.frame = CGRect(origin: .zero, size: CGSize(width: width, height: panelHeight)) self.activateAreaNode.frame = CGRect(origin: .zero, size: CGSize(width: width, height: panelHeight))
self.activateAreaNode.accessibilityLabel = interfaceState.strings.Channel_NotificationLoading self.activateAreaNode.accessibilityLabel = interfaceState.strings.Channel_NotificationLoading
return LayoutResult(backgroundHeight: panelHeight, insetHeight: panelHeight) return LayoutResult(backgroundHeight: panelHeight, insetHeight: panelHeight, hitTestSlop: 0.0)
} }
} }

View File

@ -8,6 +8,7 @@ class ChatTitleAccessoryPanelNode: ASDisplayNode {
struct LayoutResult { struct LayoutResult {
var backgroundHeight: CGFloat var backgroundHeight: CGFloat
var insetHeight: CGFloat var insetHeight: CGFloat
var hitTestSlop: CGFloat
} }
var interfaceInteraction: ChatPanelInterfaceInteraction? var interfaceInteraction: ChatPanelInterfaceInteraction?

View File

@ -59,6 +59,6 @@ final class ChatToastAlertPanelNode: ChatTitleAccessoryPanelNode {
self.activateAreaNode.frame = CGRect(origin: .zero, size: CGSize(width: width, height: panelHeight)) self.activateAreaNode.frame = CGRect(origin: .zero, size: CGSize(width: width, height: panelHeight))
self.activateAreaNode.accessibilityLabel = self.titleNode.attributedText?.string ?? "" self.activateAreaNode.accessibilityLabel = self.titleNode.attributedText?.string ?? ""
return LayoutResult(backgroundHeight: panelHeight, insetHeight: panelHeight) return LayoutResult(backgroundHeight: panelHeight, insetHeight: panelHeight, hitTestSlop: 0.0)
} }
} }

View File

@ -634,13 +634,13 @@ private final class TranslationLanguagesContextMenuContent: ContextControllerIte
if minVisibleIndex <= maxVisibleIndex { if minVisibleIndex <= maxVisibleIndex {
for index in minVisibleIndex ... maxVisibleIndex { for index in minVisibleIndex ... maxVisibleIndex {
let height = self.languages[index].0.isEmpty ? separatorHeight : itemHeight
var itemFrame = CGRect(origin: CGPoint(x: 0.0, y: CGFloat(index) * itemHeight), size: CGSize(width: size.width, height: height))
if index > separatorIndex {
itemFrame.origin.y += separatorHeight - itemHeight
}
if index < self.languages.count { if index < self.languages.count {
let height = self.languages[index].0.isEmpty ? separatorHeight : itemHeight
var itemFrame = CGRect(origin: CGPoint(x: 0.0, y: CGFloat(index) * itemHeight), size: CGSize(width: size.width, height: height))
if index > separatorIndex {
itemFrame.origin.y += separatorHeight - itemHeight
}
let (languageCode, displayTitle) = self.languages[index] let (languageCode, displayTitle) = self.languages[index]
validIds.insert(index) validIds.insert(index)
@ -690,7 +690,21 @@ private final class TranslationLanguagesContextMenuContent: ContextControllerIte
self.presentationData = presentationData self.presentationData = presentationData
let size = CGSize(width: constrainedSize.width, height: CGFloat(self.languages.count) * itemHeight) var separatorIndex = 0
for i in 0 ..< self.languages.count {
if self.languages[i].0.isEmpty {
separatorIndex = i
break
}
}
var contentHeight: CGFloat
if separatorIndex != 0 {
contentHeight = CGFloat(self.languages.count - 1) * itemHeight + separatorHeight
} else {
contentHeight = CGFloat(self.languages.count) * itemHeight
}
let size = CGSize(width: constrainedSize.width, height: contentHeight)
let containerSize = CGSize(width: size.width, height: min(constrainedSize.height, size.height)) let containerSize = CGSize(width: size.width, height: min(constrainedSize.height, size.height))
self.currentSize = containerSize self.currentSize = containerSize