Various fixes

This commit is contained in:
Ilya Laktyushin 2024-05-31 19:06:26 +04:00
parent 9ea80ff9dc
commit 8cd037bf74
5 changed files with 103 additions and 62 deletions

View File

@ -2074,6 +2074,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
} }
} }
private weak var storyTooltip: TooltipScreen?
fileprivate func maybeDisplayStoryTooltip() { fileprivate func maybeDisplayStoryTooltip() {
let content = self.updateHeaderContent() let content = self.updateHeaderContent()
if content.secondaryContent != nil { if content.secondaryContent != nil {
@ -2128,6 +2129,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
} }
) )
self.present(tooltipScreen, in: .current) self.present(tooltipScreen, in: .current)
self.storyTooltip = tooltipScreen
#if !DEBUG #if !DEBUG
let _ = ApplicationSpecificNotice.setDisplayChatListStoriesTooltip(accountManager: self.context.sharedContext.accountManager).startStandalone() let _ = ApplicationSpecificNotice.setDisplayChatListStoriesTooltip(accountManager: self.context.sharedContext.accountManager).startStandalone()
@ -4345,7 +4347,18 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
self.activateSearch(filter: filter, query: query) self.activateSearch(filter: filter, query: query)
} }
private var previousSearchToggleTimestamp: Double?
func activateSearch(filter: ChatListSearchFilter = .chats, query: String? = nil, skipScrolling: Bool = false, searchContentNode: NavigationBarSearchContentNode) { func activateSearch(filter: ChatListSearchFilter = .chats, query: String? = nil, skipScrolling: Bool = false, searchContentNode: NavigationBarSearchContentNode) {
let currentTimestamp = CACurrentMediaTime()
if let previousSearchActivationTimestamp = self.previousSearchToggleTimestamp, currentTimestamp < previousSearchActivationTimestamp + 0.6 {
return
}
self.previousSearchToggleTimestamp = currentTimestamp
if let storyTooltip = self.storyTooltip {
storyTooltip.dismiss()
}
var filter = filter var filter = filter
if case .forum = self.chatListDisplayNode.effectiveContainerNode.location { if case .forum = self.chatListDisplayNode.effectiveContainerNode.location {
filter = .topics filter = .topics
@ -4420,46 +4433,53 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
} }
public func deactivateSearch(animated: Bool) { public func deactivateSearch(animated: Bool) {
if !self.displayNavigationBar { guard !self.displayNavigationBar else {
var completion: (() -> Void)? return
}
let currentTimestamp = CACurrentMediaTime()
if let previousSearchActivationTimestamp = self.previousSearchToggleTimestamp, currentTimestamp < previousSearchActivationTimestamp + 0.6 {
return
}
self.previousSearchToggleTimestamp = currentTimestamp
self.searchTabsNode = nil var completion: (() -> Void)?
var searchContentNode: NavigationBarSearchContentNode? self.searchTabsNode = nil
if let navigationBarView = self.chatListDisplayNode.navigationBarView.view as? ChatListNavigationBar.View {
searchContentNode = navigationBarView.searchContentNode var searchContentNode: NavigationBarSearchContentNode?
if let navigationBarView = self.chatListDisplayNode.navigationBarView.view as? ChatListNavigationBar.View {
searchContentNode = navigationBarView.searchContentNode
}
if let searchContentNode {
let previousFrame = searchContentNode.placeholderNode.frame
if case .chatList(.root) = self.location {
searchContentNode.placeholderNode.frame = previousFrame.offsetBy(dx: 0.0, dy: 79.0)
} }
completion = self.chatListDisplayNode.deactivateSearch(placeholderNode: searchContentNode.placeholderNode, animated: animated)
searchContentNode.placeholderNode.frame = previousFrame
}
if let searchContentNode { self.chatListDisplayNode.tempAllowAvatarExpansion = true
let previousFrame = searchContentNode.placeholderNode.frame self.requestLayout(transition: .animated(duration: 0.5, curve: .spring))
if case .chatList(.root) = self.location { self.chatListDisplayNode.tempAllowAvatarExpansion = false
searchContentNode.placeholderNode.frame = previousFrame.offsetBy(dx: 0.0, dy: 79.0)
}
completion = self.chatListDisplayNode.deactivateSearch(placeholderNode: searchContentNode.placeholderNode, animated: animated)
searchContentNode.placeholderNode.frame = previousFrame
}
self.chatListDisplayNode.tempAllowAvatarExpansion = true //TODO:swap tabs
self.requestLayout(transition: .animated(duration: 0.5, curve: .spring))
self.chatListDisplayNode.tempAllowAvatarExpansion = false
//TODO:swap tabs let transition: ContainedViewLayoutTransition = animated ? .animated(duration: 0.4, curve: .spring) : .immediate
//transition.updateAlpha(node: self.tabContainerNode, alpha: tabsIsEmpty ? 0.0 : 1.0)
self.setDisplayNavigationBar(true, transition: transition)
let transition: ContainedViewLayoutTransition = animated ? .animated(duration: 0.4, curve: .spring) : .immediate completion?()
//transition.updateAlpha(node: self.tabContainerNode, alpha: tabsIsEmpty ? 0.0 : 1.0)
self.setDisplayNavigationBar(true, transition: transition)
completion?() (self.parent as? TabBarController)?.updateIsTabBarHidden(false, transition: .animated(duration: 0.4, curve: .spring))
(self.parent as? TabBarController)?.updateIsTabBarHidden(false, transition: .animated(duration: 0.4, curve: .spring)) self.isSearchActive = false
if let navigationController = self.navigationController as? NavigationController {
self.isSearchActive = false for controller in navigationController.globalOverlayControllers {
if let navigationController = self.navigationController as? NavigationController { if let controller = controller as? VoiceChatOverlayController {
for controller in navigationController.globalOverlayControllers { controller.updateVisibility()
if let controller = controller as? VoiceChatOverlayController { break
controller.updateVisibility()
break
}
} }
} }
} }

View File

@ -20,6 +20,10 @@ private func generateHashtagIcon(color: UIColor) -> UIImage? {
return generateTintedImage(image: UIImage(bundleImageName: "Components/Search Bar/Hashtag"), color: color) return generateTintedImage(image: UIImage(bundleImageName: "Components/Search Bar/Hashtag"), color: color)
} }
private func generateCashtagIcon(color: UIColor) -> UIImage? {
return generateTintedImage(image: UIImage(bundleImageName: "Components/Search Bar/Cashtag"), color: color)
}
private func generateClearIcon(color: UIColor) -> UIImage? { private func generateClearIcon(color: UIColor) -> UIImage? {
return generateTintedImage(image: UIImage(bundleImageName: "Components/Search Bar/Clear"), color: color) return generateTintedImage(image: UIImage(bundleImageName: "Components/Search Bar/Clear"), color: color)
} }
@ -851,6 +855,7 @@ public class SearchBarNode: ASDisplayNode, UITextFieldDelegate {
public enum Icon { public enum Icon {
case loupe case loupe
case hashtag case hashtag
case cashtag
} }
public let icon: Icon public let icon: Icon
@ -1062,6 +1067,8 @@ public class SearchBarNode: ASDisplayNode, UITextFieldDelegate {
icon = generateLoupeIcon(color: theme.inputIcon) icon = generateLoupeIcon(color: theme.inputIcon)
case .hashtag: case .hashtag:
icon = generateHashtagIcon(color: theme.inputIcon) icon = generateHashtagIcon(color: theme.inputIcon)
case .cashtag:
icon = generateCashtagIcon(color: theme.inputIcon)
} }
self.iconNode.image = icon self.iconNode.image = icon
self.textField.keyboardAppearance = theme.keyboard.keyboardAppearance self.textField.keyboardAppearance = theme.keyboard.keyboardAppearance
@ -1150,6 +1157,11 @@ public class SearchBarNode: ASDisplayNode, UITextFieldDelegate {
} }
self.textBackgroundNode.layer.animateFrame(from: initialTextBackgroundFrame, to: self.textBackgroundNode.frame, duration: duration, timingFunction: timingFunction) self.textBackgroundNode.layer.animateFrame(from: initialTextBackgroundFrame, to: self.textBackgroundNode.frame, duration: duration, timingFunction: timingFunction)
if initialTextBackgroundFrame.height.isZero {
self.iconNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
self.textField.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25)
}
let textFieldFrame = self.textField.frame let textFieldFrame = self.textField.frame
var tokensWidth = self.textField.tokensWidth var tokensWidth = self.textField.tokensWidth
if tokensWidth > 0.0 { if tokensWidth > 0.0 {
@ -1268,19 +1280,19 @@ public class SearchBarNode: ASDisplayNode, UITextFieldDelegate {
self.textBackgroundNode.isHidden = true self.textBackgroundNode.isHidden = true
/*if let accessoryComponentView = node.accessoryComponentView { /*if let accessoryComponentView = node.accessoryComponentView {
let tempContainer = UIView() let tempContainer = UIView()
let accessorySize = accessoryComponentView.bounds.size let accessorySize = accessoryComponentView.bounds.size
tempContainer.frame = CGRect(origin: CGPoint(x: self.textBackgroundNode.frame.maxX - accessorySize.width - 4.0, y: floor((self.textBackgroundNode.frame.minY + self.textBackgroundNode.frame.height - accessorySize.height) / 2.0)), size: accessorySize) tempContainer.frame = CGRect(origin: CGPoint(x: self.textBackgroundNode.frame.maxX - accessorySize.width - 4.0, y: floor((self.textBackgroundNode.frame.minY + self.textBackgroundNode.frame.height - accessorySize.height) / 2.0)), size: accessorySize)
let targetTempContainerFrame = CGRect(origin: CGPoint(x: targetTextBackgroundFrame.maxX - accessorySize.width - 4.0, y: floor((targetTextBackgroundFrame.minY + 8.0 + targetTextBackgroundFrame.height - accessorySize.height) / 2.0)), size: accessorySize) let targetTempContainerFrame = CGRect(origin: CGPoint(x: targetTextBackgroundFrame.maxX - accessorySize.width - 4.0, y: floor((targetTextBackgroundFrame.minY + 8.0 + targetTextBackgroundFrame.height - accessorySize.height) / 2.0)), size: accessorySize)
tempContainer.layer.animateFrame(from: tempContainer.frame, to: targetTempContainerFrame, duration: duration, timingFunction: timingFunction, removeOnCompletion: false) tempContainer.layer.animateFrame(from: tempContainer.frame, to: targetTempContainerFrame, duration: duration, timingFunction: timingFunction, removeOnCompletion: false)
accessoryComponentView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) accessoryComponentView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
tempContainer.addSubview(accessoryComponentView) tempContainer.addSubview(accessoryComponentView)
self.view.addSubview(tempContainer) self.view.addSubview(tempContainer)
}*/ }*/
self.textBackgroundNode.layer.animateFrame(from: self.textBackgroundNode.frame, to: targetTextBackgroundFrame, duration: duration, timingFunction: timingFunction, removeOnCompletion: false, completion: { [weak node] _ in self.textBackgroundNode.layer.animateFrame(from: self.textBackgroundNode.frame, to: targetTextBackgroundFrame, duration: duration, timingFunction: timingFunction, removeOnCompletion: false, completion: { [weak node] _ in
textBackgroundCompleted = true textBackgroundCompleted = true
@ -1301,7 +1313,10 @@ public class SearchBarNode: ASDisplayNode, UITextFieldDelegate {
transitionBackgroundNode.layer.animateFrame(from: self.textBackgroundNode.frame, to: targetTextBackgroundFrame, duration: duration, timingFunction: timingFunction, removeOnCompletion: false) transitionBackgroundNode.layer.animateFrame(from: self.textBackgroundNode.frame, to: targetTextBackgroundFrame, duration: duration, timingFunction: timingFunction, removeOnCompletion: false)
if let snapshot = node.labelNode.layer.snapshotContentTree() { if targetTextBackgroundFrame.height.isZero {
self.iconNode.layer.animateAlpha(from: self.iconNode.alpha, to: 0.0, duration: 0.2, removeOnCompletion: false)
self.textField.layer.animateAlpha(from: self.textField.alpha, to: 0.0, duration: 0.2, removeOnCompletion: false)
} else if let snapshot = node.labelNode.layer.snapshotContentTree() {
snapshot.frame = CGRect(origin: self.textField.placeholderLabel.frame.origin.offsetBy(dx: 0.0, dy: UIScreenPixel), size: node.labelNode.frame.size) snapshot.frame = CGRect(origin: self.textField.placeholderLabel.frame.origin.offsetBy(dx: 0.0, dy: UIScreenPixel), size: node.labelNode.frame.size)
self.textField.layer.addSublayer(snapshot) self.textField.layer.addSublayer(snapshot)
snapshot.animateAlpha(from: 0.0, to: 1.0, duration: duration * 2.0 / 3.0, timingFunction: CAMediaTimingFunctionName.linear.rawValue) snapshot.animateAlpha(from: 0.0, to: 1.0, duration: duration * 2.0 / 3.0, timingFunction: CAMediaTimingFunctionName.linear.rawValue)

View File

@ -268,16 +268,20 @@ public final class SearchDisplayController {
searchBar?.removeFromSupernode() searchBar?.removeFromSupernode()
}) })
} else { } else {
searchBar.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak searchBar] _ in searchBar.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak searchBar] finished in
searchBar?.removeFromSupernode() if finished {
searchBar?.removeFromSupernode()
}
}) })
} }
let backgroundNode = self.backgroundNode let backgroundNode = self.backgroundNode
let contentNode = self.contentNode let contentNode = self.contentNode
if animated { if animated {
backgroundNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak backgroundNode] _ in backgroundNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak backgroundNode] finished in
backgroundNode?.removeFromSupernode() if finished {
backgroundNode?.removeFromSupernode()
}
}) })
} else { } else {
backgroundNode.removeFromSupernode() backgroundNode.removeFromSupernode()

View File

@ -727,6 +727,8 @@ public class StarsTransactionScreen: ViewControllerComponentContainer {
let presentationData = context.sharedContext.currentPresentationData.with { $0 } let presentationData = context.sharedContext.currentPresentationData.with { $0 }
self.present(UndoOverlayController(presentationData: presentationData, content: .copy(text: presentationData.strings.Stars_Transaction_CopiedId), elevatedLayout: false, position: .bottom, action: { _ in return true }), in: .current) self.present(UndoOverlayController(presentationData: presentationData, content: .copy(text: presentationData.strings.Stars_Transaction_CopiedId), elevatedLayout: false, position: .bottom, action: { _ in return true }), in: .current)
HapticFeedback().tap()
} }
} }

View File

@ -2816,8 +2816,8 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
} }
self.skippedShowSearchResultsAsListAnimationOnce = true self.skippedShowSearchResultsAsListAnimationOnce = true
inlineSearchResultsView.layer.allowsGroupOpacity = true inlineSearchResultsView.layer.allowsGroupOpacity = true
if let inlineSearchResultsView = self.inlineSearchResults?.view { if let emptyNode = self.emptyNode {
self.contentContainerNode.view.insertSubview(inlineSearchResultsView, aboveSubview: inlineSearchResultsView) self.contentContainerNode.view.insertSubview(inlineSearchResultsView, aboveSubview: emptyNode.view)
} else { } else {
self.contentContainerNode.view.insertSubview(inlineSearchResultsView, aboveSubview: self.historyNodeContainer.view) self.contentContainerNode.view.insertSubview(inlineSearchResultsView, aboveSubview: self.historyNodeContainer.view)
} }