chore: migrate to new version + fixed several critical bugs

- Migrated project to latest Telegram iOS base (v12.3.2+)
- Fixed circular dependency between GhostModeManager and MiscSettingsManager
- Fixed multiple Bazel build configuration errors (select() default conditions)
- Fixed duplicate type definitions in PeerInfoScreen
- Fixed swiftmodule directory resolution in build scripts
- Added Ghostgram Settings tab in main Settings menu with all 5 features
- Cleared sensitive credentials from config.json (template-only now)
- Excluded bazel-cache from version control
This commit is contained in:
ichmagmaus 812
2026-02-23 23:04:32 +01:00
parent 703e291bcb
commit db53826061
1017 changed files with 62337 additions and 40559 deletions
+10 -6
View File
@@ -10,12 +10,16 @@ swift_library(
"-warnings-as-errors",
],
deps = [
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
"//submodules/Display:Display",
"//submodules/TelegramPresentationData:TelegramPresentationData",
"//submodules/SearchBarNode:SearchBarNode",
"//submodules/ChatListSearchItemNode:ChatListSearchItemNode",
"//submodules/SSignalKit/SwiftSignalKit",
"//submodules/AsyncDisplayKit",
"//submodules/Display",
"//submodules/TelegramPresentationData",
"//submodules/SearchBarNode",
"//submodules/TelegramUI/Components/GlassBackgroundComponent",
"//submodules/ComponentFlow",
"//submodules/Components/ComponentDisplayAdapters",
"//submodules/AppBundle",
"//submodules/ActivityIndicator",
],
visibility = [
"//visibility:public",
@@ -1,33 +1,6 @@
import Foundation
import AsyncDisplayKit
import Display
import ChatListSearchItemNode
public func fixSearchableListNodeScrolling(_ listNode: ListView) {
var searchItemNode: ListViewItemNode?
var nextItemNode: ListViewItemNode?
listNode.forEachItemNode { itemNode in
if let itemNode = itemNode as? ChatListSearchItemNode {
searchItemNode = itemNode
} else if searchItemNode != nil && nextItemNode == nil {
nextItemNode = itemNode as? ListViewItemNode
}
}
if let searchItemNode = searchItemNode {
let itemFrame = searchItemNode.apparentFrame
if itemFrame.contains(CGPoint(x: 0.0, y: listNode.insets.top)) {
if itemFrame.minY + itemFrame.height * 0.6 < listNode.insets.top {
if let nextItemNode = nextItemNode {
listNode.ensureItemNodeVisibleAtTopInset(nextItemNode)
}
} else {
listNode.ensureItemNodeVisibleAtTopInset(searchItemNode)
}
}
}
}
public func fixNavigationSearchableListNodeScrolling(_ listNode: ListView, searchNode: NavigationBarSearchContentNode) -> Bool {
if searchNode.expansionProgress > 0.0 && searchNode.expansionProgress < 1.0 {
@@ -47,22 +20,3 @@ public func fixNavigationSearchableListNodeScrolling(_ listNode: ListView, searc
}
return false
}
func fixNavigationSearchableGridNodeScrolling(_ gridNode: GridNode, searchNode: NavigationBarSearchContentNode) -> Bool {
if searchNode.expansionProgress > 0.0 && searchNode.expansionProgress < 1.0 {
let scrollToItem: GridNodeScrollToItem
let targetProgress: CGFloat
if searchNode.expansionProgress < 0.6 {
scrollToItem = GridNodeScrollToItem(index: 0, position: .top(-navigationBarSearchContentHeight), transition: .animated(duration: 0.3, curve: .easeInOut), directionHint: .up, adjustForSection: true, adjustForTopInset: true)
targetProgress = 0.0
} else {
scrollToItem = GridNodeScrollToItem(index: 0, position: .top(0.0), transition: .animated(duration: 0.3, curve: .easeInOut), directionHint: .up, adjustForSection: true, adjustForTopInset: true)
targetProgress = 1.0
}
searchNode.updateExpansionProgress(targetProgress, animated: true)
gridNode.transaction(GridNodeTransaction(deleteItems: [], insertItems: [], updateItems: [], scrollToItem: scrollToItem, updateLayout: nil, itemTransition: .immediate, stationaryItems: .none, updateFirstIndexInSectionOffset: nil, updateOpaqueState: nil, synchronousLoads: false), completion: { _ in })
return true
}
return false
}
@@ -4,11 +4,28 @@ import AsyncDisplayKit
import Display
import TelegramPresentationData
import SearchBarNode
import GlassBackgroundComponent
import ComponentFlow
import ComponentDisplayAdapters
import AppBundle
import ActivityIndicator
private let searchBarFont = Font.regular(17.0)
public let navigationBarSearchContentHeight: CGFloat = 54.0
public let navigationBarSearchContentHeight: CGFloat = 60.0
public class NavigationBarSearchContentNode: NavigationBarContentNode {
private struct Params: Equatable {
let size: CGSize
let leftInset: CGFloat
let rightInset: CGFloat
init(size: CGSize, leftInset: CGFloat, rightInset: CGFloat) {
self.size = size
self.leftInset = leftInset
self.rightInset = rightInset
}
}
public var theme: PresentationTheme?
public var placeholder: String
public var compactPlaceholder: String
@@ -19,8 +36,6 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode {
private var disabledOverlay: ASDisplayNode?
public var expansionProgress: CGFloat = 1.0
public var additionalHeight: CGFloat = 0.0
private var validLayout: (CGSize, CGFloat, CGFloat)?
@@ -30,7 +45,7 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode {
self.compactPlaceholder = compactPlaceholder ?? placeholder
self.inline = inline
self.placeholderNode = SearchBarPlaceholderNode(fieldStyle: .modern)
self.placeholderNode = SearchBarPlaceholderNode(fieldStyle: .glass)
self.placeholderNode.labelNode.displaysAsynchronously = false
super.init()
@@ -41,6 +56,8 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode {
self.addSubnode(self.placeholderNode)
self.placeholderNode.activate = activate
//self.backgroundColor = .red
}
public func updateThemeAndPlaceholder(theme: PresentationTheme, placeholder: String, compactPlaceholder: String? = nil) {
@@ -102,10 +119,10 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode {
}
private func updatePlaceholder(_ progress: CGFloat, size: CGSize, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition) {
let padding: CGFloat = 10.0
let padding: CGFloat = 16.0
let baseWidth = size.width - padding * 2.0 - leftInset - rightInset
let fieldHeight: CGFloat = 36.0
let fieldHeight: CGFloat = 44.0
let fraction = fieldHeight / self.nominalHeight
let fullFraction = navigationBarSearchContentHeight / self.nominalHeight
@@ -116,21 +133,19 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode {
var visibleProgress: CGFloat = toLow + (self.expansionProgress - fromLow) * (toHigh - toLow) / (fromHigh - fromLow)
visibleProgress = max(0.0, min(1.0, visibleProgress))
let searchBarNodeLayout = self.placeholderNode.asyncLayout()
let textColor = self.theme?.rootController.navigationSearchBar.inputPlaceholderTextColor ?? UIColor(rgb: 0x8e8e93)
var fillColor = self.theme?.rootController.navigationSearchBar.inputFillColor ?? .clear
if self.inline, let theme = self.theme, fillColor.distance(to: theme.list.blocksBackgroundColor) < 100 {
fillColor = fillColor.withMultipliedBrightnessBy(0.8)
}
let backgroundColor = self.theme?.rootController.navigationBar.opaqueBackgroundColor ?? .clear
let backgroundColor = self.theme?.chatList.regularSearchBarColor ?? .clear
let controlColor = self.theme?.chat.inputPanel.panelControlColor ?? .black
let placeholderString = NSAttributedString(string: self.placeholder, font: searchBarFont, textColor: textColor)
let compactPlaceholderString = NSAttributedString(string: self.compactPlaceholder, font: searchBarFont, textColor: textColor)
let (searchBarHeight, searchBarApply) = searchBarNodeLayout(placeholderString, compactPlaceholderString, CGSize(width: baseWidth, height: fieldHeight), visibleProgress, textColor, fillColor, backgroundColor, transition)
searchBarApply()
let searchBarHeight = self.placeholderNode.updateLayout(placeholderString: placeholderString, compactPlaceholderString: compactPlaceholderString, constrainedSize: CGSize(width: baseWidth, height: fieldHeight), expansionProgress: visibleProgress, iconColor: textColor, foregroundColor: fillColor, backgroundColor: backgroundColor, controlColor: controlColor, transition: transition)
let searchBarFrame = CGRect(origin: CGPoint(x: padding + leftInset, y: size.height + (1.0 - visibleProgress) * fieldHeight - 8.0 - fieldHeight), size: CGSize(width: baseWidth, height: fieldHeight))
transition.updateFrame(node: self.placeholderNode, frame: searchBarFrame)
@@ -143,10 +158,12 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode {
}
}
override public func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition) {
override public func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition) -> CGSize {
self.validLayout = (size, leftInset, rightInset)
self.updatePlaceholder(self.expansionProgress, size: size, leftInset: leftInset, rightInset: rightInset, transition: transition)
return size
}
override public var height: CGFloat {
@@ -158,7 +175,7 @@ public class NavigationBarSearchContentNode: NavigationBarContentNode {
}
override public var nominalHeight: CGFloat {
return navigationBarSearchContentHeight + self.additionalHeight
return 60.0
}
override public var mode: NavigationBarContentMode {
@@ -25,12 +25,14 @@ public final class SearchDisplayController {
}
}
private let searchBar: SearchBarNode
private var searchBar: SearchBarNode?
private let searchBarIsExternal: Bool
private let mode: SearchDisplayControllerMode
private let backgroundNode: BackgroundNode
public let contentNode: SearchDisplayControllerContentNode
private var hasSeparator: Bool
private let inline: Bool
private let cancel: () -> Void
private var containerLayout: (ContainerViewLayout, CGFloat)?
@@ -38,71 +40,75 @@ public final class SearchDisplayController {
private var isSearchingDisposable: Disposable?
public init(presentationData: PresentationData, mode: SearchDisplayControllerMode = .navigation, placeholder: String? = nil, hasBackground: Bool = false, hasSeparator: Bool = false, contentNode: SearchDisplayControllerContentNode, inline: Bool = false, cancel: @escaping () -> Void) {
public init(
presentationData: PresentationData,
mode: SearchDisplayControllerMode = .navigation,
placeholder: String? = nil,
hasBackground: Bool = false,
hasSeparator: Bool = false,
contentNode: SearchDisplayControllerContentNode,
inline: Bool = false,
cancel: @escaping () -> Void,
fieldStyle: SearchBarStyle = .modern,
searchBarIsExternal: Bool = false
) {
self.inline = inline
self.searchBar = SearchBarNode(theme: SearchBarNodeTheme(theme: presentationData.theme, hasBackground: hasBackground, hasSeparator: hasSeparator, inline: inline), strings: presentationData.strings, fieldStyle: .modern, forceSeparator: hasSeparator, displayBackground: hasBackground)
self.cancel = cancel
self.searchBarIsExternal = searchBarIsExternal
if !searchBarIsExternal {
self.searchBar = SearchBarNode(theme: SearchBarNodeTheme(theme: presentationData.theme, hasBackground: hasBackground, hasSeparator: hasSeparator, inline: inline), presentationTheme: presentationData.theme, strings: presentationData.strings, fieldStyle: fieldStyle, forceSeparator: hasSeparator, displayBackground: hasBackground)
}
self.backgroundNode = BackgroundNode()
self.backgroundNode.allowsGroupOpacity = true
self.mode = mode
self.contentNode = contentNode
self.hasSeparator = hasSeparator
if let searchBar = self.searchBar {
self.setSearchBar(searchBar)
}
self.searchBar.textUpdated = { [weak contentNode] text, _ in
contentNode?.searchTextUpdated(text: text)
}
self.searchBar.tokensUpdated = { [weak contentNode] tokens in
contentNode?.searchTokensUpdated(tokens: tokens)
}
self.searchBar.cancel = { [weak self] in
self?.isDeactivating = true
cancel()
}
self.searchBar.clearPrefix = { [weak contentNode] in
contentNode?.searchTextClearPrefix()
}
self.searchBar.clearTokens = { [weak contentNode] in
contentNode?.searchTextClearTokens()
}
self.contentNode.cancel = { [weak self] in
self?.isDeactivating = true
cancel()
}
self.contentNode.dismissInput = { [weak self] in
self?.searchBar.deactivate(clear: false)
self?.searchBar?.deactivate(clear: false)
}
var isFirstTime = true
self.contentNode.setQuery = { [weak self] prefix, tokens, query in
if let strongSelf = self {
strongSelf.searchBar.prefixString = prefix
let previousTokens = strongSelf.searchBar.tokens
strongSelf.searchBar.tokens = tokens
strongSelf.searchBar.text = query
if let strongSelf = self, let searchBar = strongSelf.searchBar {
searchBar.prefixString = prefix
let previousTokens = searchBar.tokens
searchBar.tokens = tokens
searchBar.text = query
if previousTokens.count < tokens.count && !isFirstTime {
if let lastToken = tokens.last, !lastToken.permanent {
strongSelf.searchBar.selectLastToken()
searchBar.selectLastToken()
}
}
isFirstTime = false
}
}
if let placeholder = placeholder {
self.searchBar.placeholderString = NSAttributedString(string: placeholder, font: Font.regular(17.0), textColor: presentationData.theme.rootController.navigationSearchBar.inputPlaceholderTextColor)
self.searchBar?.placeholderString = NSAttributedString(string: placeholder, font: Font.regular(17.0), textColor: presentationData.theme.rootController.navigationSearchBar.inputPlaceholderTextColor)
}
self.contentNode.setPlaceholder = { [weak self] string in
guard string != self?.searchBar.placeholderString?.string else {
guard string != self?.searchBar?.placeholderString?.string else {
return
}
if let mutableAttributedString = self?.searchBar.placeholderString?.mutableCopy() as? NSMutableAttributedString {
if let mutableAttributedString = self?.searchBar?.placeholderString?.mutableCopy() as? NSMutableAttributedString {
mutableAttributedString.mutableString.setString(string)
self?.searchBar.placeholderString = mutableAttributedString
self?.searchBar?.placeholderString = mutableAttributedString
}
}
self.isSearchingDisposable = (contentNode.isSearching
|> deliverOnMainQueue).start(next: { [weak self] value in
self?.searchBar.activity = value
self?.searchBar?.activity = value
})
if self.contentNode.hasDim {
@@ -113,9 +119,32 @@ public final class SearchDisplayController {
self.backgroundNode.isTransparent = false
}
}
public func setSearchBar(_ searchBar: SearchBarNode) {
self.searchBar = searchBar
searchBar.textUpdated = { [weak contentNode] text, _ in
contentNode?.searchTextUpdated(text: text)
}
searchBar.tokensUpdated = { [weak contentNode] tokens in
contentNode?.searchTokensUpdated(tokens: tokens)
}
searchBar.cancel = { [weak self] in
self?.isDeactivating = true
self?.cancel()
}
searchBar.clearPrefix = { [weak contentNode] in
contentNode?.searchTextClearPrefix()
}
searchBar.clearTokens = { [weak contentNode] in
contentNode?.searchTextClearTokens()
}
}
public func updatePresentationData(_ presentationData: PresentationData) {
self.searchBar.updateThemeAndStrings(theme: SearchBarNodeTheme(theme: presentationData.theme, hasSeparator: self.hasSeparator, inline: self.inline), strings: presentationData.strings)
if !self.searchBarIsExternal {
self.searchBar?.updateThemeAndStrings(theme: SearchBarNodeTheme(theme: presentationData.theme, hasSeparator: self.hasSeparator, inline: self.inline), presentationTheme: presentationData.theme, strings: presentationData.strings)
}
self.contentNode.updatePresentationData(presentationData)
if self.contentNode.hasDim {
@@ -128,6 +157,8 @@ public final class SearchDisplayController {
}
public func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
let defaultNavigationBarHeight = navigationBarHeight
let statusBarHeight: CGFloat = layout.statusBarHeight ?? 0.0
let searchBarHeight: CGFloat = max(20.0, statusBarHeight) + 44.0
let navigationBarOffset: CGFloat
@@ -137,32 +168,44 @@ public final class SearchDisplayController {
navigationBarOffset = 0.0
}
var navigationBarFrame = CGRect(origin: CGPoint(x: 0.0, y: navigationBarOffset), size: CGSize(width: layout.size.width, height: searchBarHeight))
if self.searchBarIsExternal {
navigationBarFrame.size.height -= 50.0
}
if layout.statusBarHeight == nil {
navigationBarFrame.size.height = 64.0
}
navigationBarFrame.size.height += 10.0
var navigationBarHeight = navigationBarFrame.maxY
let searchBarFrame: CGRect
if case .navigation = self.mode {
searchBarFrame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: 54.0)
} else {
searchBarFrame = navigationBarFrame
if !self.searchBarIsExternal, let searchBar = self.searchBar {
let searchBarFrame: CGRect
if case .navigation = self.mode {
if case .glass = searchBar.fieldStyle {
navigationBarHeight = defaultNavigationBarHeight
searchBarFrame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: 44.0)
} else {
searchBarFrame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: 54.0)
}
} else {
searchBarFrame = navigationBarFrame
navigationBarHeight = navigationBarFrame.maxY + 8.0
}
transition.updateFrame(node: searchBar, frame: searchBarFrame)
searchBar.updateLayout(boundingSize: searchBarFrame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: transition)
}
transition.updateFrame(node: self.searchBar, frame: searchBarFrame)
self.searchBar.updateLayout(boundingSize: searchBarFrame.size, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, transition: transition)
self.containerLayout = (layout, navigationBarFrame.maxY)
self.containerLayout = (layout, navigationBarHeight)
let bounds = CGRect(origin: CGPoint(), size: layout.size)
transition.updateFrame(node: self.backgroundNode, frame: bounds.insetBy(dx: -20.0, dy: -20.0))
transition.updateFrame(node: self.backgroundNode, frame: bounds)//.insetBy(dx: -20.0, dy: -20.0))
var size = layout.size
size.width += 20.0 * 2.0
transition.updateFrame(node: self.contentNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 20.0), size: size))
let size = layout.size
//size.width += 20.0 * 2.0
transition.updateFrame(node: self.contentNode, frame: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size))
var safeInsets = layout.safeInsets
safeInsets.left += 20.0
safeInsets.right += 20.0
let safeInsets = layout.safeInsets
//safeInsets.left += 20.0
//safeInsets.right += 20.0
self.contentNode.containerLayoutUpdated(ContainerViewLayout(size: size, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: layout.intrinsicInsets, safeInsets: safeInsets, additionalInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: layout.inputHeight, inputHeightIsInteractivellyChanging: layout.inputHeightIsInteractivellyChanging, inVoiceOver: layout.inVoiceOver), navigationBarHeight: navigationBarHeight, transition: transition)
}
@@ -183,14 +226,14 @@ public final class SearchDisplayController {
self.backgroundNode.isTransparent = false
}
var size = layout.size
size.width += 20.0 * 2.0
let size = layout.size
//size.width += 20.0 * 2.0
self.contentNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 20.0), size: size)
self.contentNode.frame = CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: size)
var safeInsets = layout.safeInsets
safeInsets.left += 20.0
safeInsets.right += 20.0
let safeInsets = layout.safeInsets
//safeInsets.left += 20.0
//safeInsets.right += 20.0
self.contentNode.containerLayoutUpdated(ContainerViewLayout(size: size, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: UIEdgeInsets(), safeInsets: safeInsets, additionalInsets: UIEdgeInsets(), statusBarHeight: nil, inputHeight: nil, inputHeightIsInteractivellyChanging: false, inVoiceOver: false), navigationBarHeight: navigationBarHeight, transition: .immediate)
var contentNavigationBarHeight = navigationBarHeight
@@ -201,22 +244,22 @@ public final class SearchDisplayController {
if !self.contentNode.hasDim {
self.backgroundNode.alpha = 1.0
self.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2, timingFunction: CAMediaTimingFunctionName.linear.rawValue)
self.backgroundNode.layer.animateScale(from: 0.85, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
}
if !self.contentNode.hasDim {
if let placeholder = placeholder {
self.searchBar.placeholderString = placeholder.placeholderString
}
} else {
if let placeholder = placeholder {
let initialTextBackgroundFrame = placeholder.convert(placeholder.backgroundNode.frame, to: nil)
let contentNodePosition = self.backgroundNode.layer.position
if contentNode.animateBackgroundAppearance {
self.backgroundNode.layer.animatePosition(from: CGPoint(x: contentNodePosition.x, y: contentNodePosition.y + (initialTextBackgroundFrame.maxY + 8.0 - contentNavigationBarHeight)), to: contentNodePosition, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
if !self.searchBarIsExternal {
if !self.contentNode.hasDim {
if let placeholder = placeholder {
self.searchBar?.placeholderString = placeholder.placeholderString
}
} else {
if let placeholder = placeholder {
let initialTextBackgroundFrame = placeholder.convert(placeholder.backgroundView.frame, to: nil)
let contentNodePosition = self.backgroundNode.layer.position
if contentNode.animateBackgroundAppearance {
self.backgroundNode.layer.animatePosition(from: CGPoint(x: contentNodePosition.x, y: contentNodePosition.y + (initialTextBackgroundFrame.maxY + 8.0 - contentNavigationBarHeight)), to: contentNodePosition, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
}
self.searchBar?.placeholderString = placeholder.placeholderString
}
self.searchBar.placeholderString = placeholder.placeholderString
}
}
@@ -240,39 +283,49 @@ public final class SearchDisplayController {
navigationBarFrame = CGRect(x: 0.0, y: 0.0, width: layout.size.width, height: 54.0)
}
self.searchBar.frame = navigationBarFrame
insertSubnode(self.searchBar, true)
self.searchBar.layout()
if focus {
self.searchBar.activate()
if !self.searchBarIsExternal, let searchBar = self.searchBar {
searchBar.frame = navigationBarFrame
insertSubnode(searchBar, true)
searchBar.layout()
if focus {
searchBar.activate()
}
}
if let placeholder = placeholder {
self.searchBar.animateIn(from: placeholder, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
if !self.searchBarIsExternal, let searchBar = self.searchBar {
searchBar.animateIn(from: placeholder, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring)
}
if self.contentNode.hasDim {
self.contentNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
}
} else {
self.searchBar.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
if !self.searchBarIsExternal, let searchBar = self.searchBar {
searchBar.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
}
self.contentNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3, timingFunction: CAMediaTimingFunctionName.easeOut.rawValue)
}
}
public func deactivate(placeholder: SearchBarPlaceholderNode?, animated: Bool = true) {
self.searchBar.deactivate(clear: false)
public func deactivate(placeholder: SearchBarPlaceholderNode?, animated: Bool = true, completion: (() -> Void)? = nil) {
if let searchBar = self.searchBar {
searchBar.deactivate(clear: false)
}
let searchBar = self.searchBar
if let placeholder = placeholder {
searchBar.transitionOut(to: placeholder, transition: animated ? .animated(duration: 0.5, curve: .spring) : .immediate, completion: {
[weak searchBar] in
searchBar?.removeFromSupernode()
})
} else {
searchBar.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak searchBar] finished in
if finished {
if !self.searchBarIsExternal, let searchBar = self.searchBar {
if let placeholder = placeholder {
searchBar.transitionOut(to: placeholder, transition: animated ? .animated(duration: 0.5, curve: .spring) : .immediate, completion: {
[weak searchBar] in
searchBar?.removeFromSupernode()
}
})
})
} else {
searchBar.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak searchBar] finished in
if finished {
searchBar?.removeFromSupernode()
}
})
}
}
let backgroundNode = self.backgroundNode
@@ -282,10 +335,12 @@ public final class SearchDisplayController {
if finished {
backgroundNode?.removeFromSupernode()
}
completion?()
})
} else {
backgroundNode.removeFromSupernode()
contentNode.removeFromSupernode()
completion?()
}
}