Merge commit '0c9eb7006c00999d5a2d894393444fe94f347493'

This commit is contained in:
Ali 2021-08-29 23:28:35 +04:00
commit 9a848cf51c
10 changed files with 68 additions and 23 deletions

View File

@ -131,39 +131,31 @@ public enum ChatControllerInteractionNavigateToPeer {
}
public struct ChatInterfaceForwardOptionsState: Codable, Equatable {
public var deselectedIds: Set<EngineMessage.Id>
public var hideNames: Bool
public var hideCaptions: Bool
public var unhideNamesOnCaptionChange: Bool
public static func ==(lhs: ChatInterfaceForwardOptionsState, rhs: ChatInterfaceForwardOptionsState) -> Bool {
return lhs.deselectedIds == rhs.deselectedIds && lhs.hideNames == rhs.hideNames && lhs.hideCaptions == rhs.hideCaptions
return lhs.hideNames == rhs.hideNames && lhs.hideCaptions == rhs.hideCaptions && lhs.unhideNamesOnCaptionChange == rhs.unhideNamesOnCaptionChange
}
public init(deselectedIds: Set<EngineMessage.Id>, hideNames: Bool, hideCaptions: Bool) {
self.deselectedIds = deselectedIds
public init(hideNames: Bool, hideCaptions: Bool, unhideNamesOnCaptionChange: Bool) {
self.hideNames = hideNames
self.hideCaptions = hideCaptions
self.unhideNamesOnCaptionChange = unhideNamesOnCaptionChange
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringCodingKey.self)
if let data = try? container.decodeIfPresent(Data.self, forKey: "i") {
self.deselectedIds = Set(EngineMessage.Id.decodeArrayFromData(data))
} else {
self.deselectedIds = Set()
}
self.hideNames = (try? container.decodeIfPresent(Bool.self, forKey: "hn")) ?? false
self.hideCaptions = (try? container.decodeIfPresent(Bool.self, forKey: "hc")) ?? false
self.unhideNamesOnCaptionChange = false
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StringCodingKey.self)
let data = EngineMessage.Id.encodeArrayToData(Array(self.deselectedIds))
try container.encode(data, forKey: "i")
try container.encode(self.hideNames, forKey: "hn")
try container.encode(self.hideCaptions, forKey: "hc")
}

View File

@ -34,7 +34,11 @@ public func customizePresentationTheme(_ theme: PresentationTheme, specialMode:
}
public func makePresentationTheme(settings: TelegramThemeSettings, specialMode: Bool = false, title: String? = nil, serviceBackgroundColor: UIColor? = nil) -> PresentationTheme? {
let defaultTheme = makeDefaultPresentationTheme(reference: PresentationBuiltinThemeReference(baseTheme: settings.baseTheme), extendingThemeReference: nil, serviceBackgroundColor: serviceBackgroundColor, preview: false)
var baseTheme: TelegramBaseTheme = settings.baseTheme
if specialMode && baseTheme == .night {
baseTheme = .tinted
}
let defaultTheme = makeDefaultPresentationTheme(reference: PresentationBuiltinThemeReference(baseTheme: baseTheme), extendingThemeReference: nil, serviceBackgroundColor: serviceBackgroundColor, preview: false)
return customizePresentationTheme(defaultTheme, specialMode: specialMode, editing: true, title: title, accentColor: UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: settings.messageColors, animateBubbleColors: settings.animateMessageColors, wallpaper: settings.wallpaper)
}

View File

@ -13,4 +13,10 @@ class AccessoryPanelNode: ASDisplayNode {
func updateState(size: CGSize, inset: CGFloat, interfaceState: ChatPresentationInterfaceState) {
}
func animateIn() {
}
func animateOut() {
}
}

View File

@ -5484,7 +5484,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}
}, updateForwardOptionsState: { [weak self] f in
if let strongSelf = self {
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState({ $0.withUpdatedForwardOptionsState(f($0.forwardOptionsState ?? ChatInterfaceForwardOptionsState(deselectedIds: Set(), hideNames: false, hideCaptions: false))) }) })
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState({ $0.withUpdatedForwardOptionsState(f($0.forwardOptionsState ?? ChatInterfaceForwardOptionsState(hideNames: false, hideCaptions: false, unhideNamesOnCaptionChange: false))) }) })
}
}, presentForwardOptions: { [weak self] sourceNode in
if let strongSelf = self, case let .peer(peerId) = strongSelf.chatLocation {
@ -5557,6 +5557,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
var updated = current
updated.hideNames = false
updated.hideCaptions = false
updated.unhideNamesOnCaptionChange = false
return updated
})
})))
@ -5571,6 +5572,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current
updated.hideNames = true
updated.unhideNamesOnCaptionChange = false
return updated
})
})))
@ -5589,7 +5591,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current
updated.hideCaptions = false
if updated.unhideNamesOnCaptionChange {
updated.unhideNamesOnCaptionChange = false
updated.hideNames = false
}
return updated
})
})))
@ -5604,7 +5609,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
self?.interfaceInteraction?.updateForwardOptionsState({ current in
var updated = current
updated.hideCaptions = true
updated.hideNames = true
if !updated.hideNames {
updated.hideNames = true
updated.unhideNamesOnCaptionChange = true
}
return updated
})
})))

View File

@ -1058,6 +1058,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
accessoryPanelSize = accessoryPanelNode.measure(CGSize(width: layout.size.width, height: layout.size.height))
accessoryPanelNode.updateState(size: layout.size, inset: layout.safeInsets.left, interfaceState: self.chatPresentationInterfaceState)
accessoryPanelNode.animateIn()
if accessoryPanelNode !== self.accessoryPanelNode {
dismissedAccessoryPanelNode = self.accessoryPanelNode
@ -1519,6 +1520,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
transitionTargetY = inputPanelFrame.minY
}
dismissedAccessoryPanelNode.animateOut()
dismissedAccessoryPanelNode.originalFrameBeforeDismissed = dismissedAccessoryPanelNode.frame
transition.updateFrame(node: dismissedAccessoryPanelNode, frame: CGRect(origin: CGPoint(x: 0.0, y: transitionTargetY), size: dismissedAccessoryPanelNode.frame.size), completion: { _ in

View File

@ -303,6 +303,14 @@ final class EditAccessoryPanelNode: AccessoryPanelNode {
}
}
override func animateIn() {
self.iconNode.layer.animateScale(from: 0.001, to: 1.0, duration: 0.2)
}
override func animateOut() {
self.iconNode.layer.animateScale(from: 1.0, to: 0.001, duration: 0.2, removeOnCompletion: false)
}
override func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
if self.theme !== theme {
self.theme = theme

View File

@ -769,7 +769,7 @@ final class FeaturedStickersScreen: ViewController {
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBarStyle.style
let searchNavigationNode = SearchNavigationContentNode(theme: self.presentationData.theme, strings: self.presentationData.strings, cancel: { [weak self] in
let searchNavigationNode = SearchNavigationContentNode(theme: self.presentationData.theme, strings: self.presentationData.strings, placeholder: { strings in return strings.Stickers_Search }, cancel: { [weak self] in
self?.dismiss()
})
self.searchNavigationNode = searchNavigationNode
@ -852,15 +852,17 @@ private final class SearchNavigationContentNode: NavigationBarContentNode {
private let searchBar: SearchBarNode
private var queryUpdated: ((String, String?) -> Void)?
private var placeholder: ((PresentationStrings) -> String)?
init(theme: PresentationTheme, strings: PresentationStrings, cancel: @escaping () -> Void) {
init(theme: PresentationTheme, strings: PresentationStrings, placeholder: ((PresentationStrings) -> String)? = nil, cancel: @escaping () -> Void) {
self.theme = theme
self.strings = strings
self.placeholder = placeholder
self.cancel = cancel
self.searchBar = SearchBarNode(theme: SearchBarNodeTheme(theme: theme), strings: strings, fieldStyle: .modern, cancelText: strings.Common_Done)
let placeholderText = strings.Common_Search
let placeholderText = placeholder?(strings) ?? strings.Common_Search
let searchBarFont = Font.regular(17.0)
self.searchBar.placeholderString = NSAttributedString(string: placeholderText, font: searchBarFont, textColor: theme.rootController.navigationSearchBar.inputPlaceholderTextColor)
@ -883,7 +885,7 @@ private final class SearchNavigationContentNode: NavigationBarContentNode {
self.theme = theme
self.strings = strings
self.searchBar.updateThemeAndStrings(theme: SearchBarNodeTheme(theme: theme), strings: strings)
self.searchBar.updateThemeAndStrings(theme: SearchBarNodeTheme(theme: theme), strings: strings)
}
func setQueryUpdated(_ f: @escaping (String, String?) -> Void) {

View File

@ -244,6 +244,14 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode {
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))))
}
override func animateIn() {
self.iconNode.layer.animateScale(from: 0.001, to: 1.0, duration: 0.2)
}
override func animateOut() {
self.iconNode.layer.animateScale(from: 1.0, to: 0.001, duration: 0.2, removeOnCompletion: false)
}
override func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
self.updateThemeAndStrings(theme: theme, strings: strings, forwardOptionsState: self.forwardOptionsState)
}
@ -260,8 +268,7 @@ final class ForwardAccessoryPanelNode: AccessoryPanelNode {
self.iconNode.image = PresentationResourcesChat.chatInputPanelForwardIconImage(theme)
}
let deselectedIds = forwardOptionsState?.deselectedIds ?? Set()
let filteredMessages = self.messages.filter { !deselectedIds.contains($0.id) }
let filteredMessages = self.messages
var title = ""
var text = ""

View File

@ -223,6 +223,14 @@ final class ReplyAccessoryPanelNode: AccessoryPanelNode {
self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))))
}
override func animateIn() {
self.iconNode.layer.animateScale(from: 0.001, to: 1.0, duration: 0.2)
}
override func animateOut() {
self.iconNode.layer.animateScale(from: 1.0, to: 0.001, duration: 0.2, removeOnCompletion: false)
}
override func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
if self.theme !== theme {
self.theme = theme

View File

@ -72,6 +72,14 @@ final class WebpagePreviewAccessoryPanelNode: AccessoryPanelNode {
self.webpageDisposable.dispose()
}
override func animateIn() {
self.iconNode.layer.animateScale(from: 0.001, to: 1.0, duration: 0.2)
}
override func animateOut() {
self.iconNode.layer.animateScale(from: 1.0, to: 0.001, duration: 0.2, removeOnCompletion: false)
}
override func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
if self.theme !== theme || self.strings !== strings {
self.strings = strings