Various fixes

This commit is contained in:
Ilya Laktyushin 2022-12-19 17:04:37 +04:00
parent 8a9a557870
commit 84bbf58e88
11 changed files with 54 additions and 18 deletions

View File

@ -8535,3 +8535,6 @@ Sorry for the inconvenience.";
"Privacy.Exceptions.DeleteAll" = "Delete All"; "Privacy.Exceptions.DeleteAll" = "Delete All";
"Privacy.Exceptions.DeleteAllConfirmation" = "Are you sure you want to delete all exceptions?"; "Privacy.Exceptions.DeleteAllConfirmation" = "Are you sure you want to delete all exceptions?";
"Attachment.EnableSpoiler" = "Hide With Spoiler";
"Attachment.DisableSpoiler" = "Disable Spoiler";

View File

@ -169,9 +169,13 @@ public final class AnimationNode : ASDisplayNode {
} }
} }
public func loop() { public func loop(count: Int? = nil) {
if let animationView = self.animationView() { if let animationView = self.animationView() {
animationView.loopMode = .loop if let count = count {
animationView.loopMode = .repeat(Float(count))
} else {
animationView.loopMode = .loop
}
animationView.play() animationView.play()
} }
} }

View File

@ -187,6 +187,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
public let isTopPanelExpandedUpdated: (Bool, Transition) -> Void public let isTopPanelExpandedUpdated: (Bool, Transition) -> Void
public let isTopPanelHiddenUpdated: (Bool, Transition) -> Void public let isTopPanelHiddenUpdated: (Bool, Transition) -> Void
public let panelHideBehavior: PagerComponentPanelHideBehavior public let panelHideBehavior: PagerComponentPanelHideBehavior
public let clipContentToTopPanel: Bool
public init( public init(
contentInsets: UIEdgeInsets, contentInsets: UIEdgeInsets,
@ -204,7 +205,8 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
panelStateUpdated: ((PagerComponentPanelState, Transition) -> Void)?, panelStateUpdated: ((PagerComponentPanelState, Transition) -> Void)?,
isTopPanelExpandedUpdated: @escaping (Bool, Transition) -> Void, isTopPanelExpandedUpdated: @escaping (Bool, Transition) -> Void,
isTopPanelHiddenUpdated: @escaping (Bool, Transition) -> Void, isTopPanelHiddenUpdated: @escaping (Bool, Transition) -> Void,
panelHideBehavior: PagerComponentPanelHideBehavior panelHideBehavior: PagerComponentPanelHideBehavior,
clipContentToTopPanel: Bool
) { ) {
self.contentInsets = contentInsets self.contentInsets = contentInsets
self.contents = contents self.contents = contents
@ -222,6 +224,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
self.isTopPanelExpandedUpdated = isTopPanelExpandedUpdated self.isTopPanelExpandedUpdated = isTopPanelExpandedUpdated
self.isTopPanelHiddenUpdated = isTopPanelHiddenUpdated self.isTopPanelHiddenUpdated = isTopPanelHiddenUpdated
self.panelHideBehavior = panelHideBehavior self.panelHideBehavior = panelHideBehavior
self.clipContentToTopPanel = clipContentToTopPanel
} }
public static func ==(lhs: PagerComponent, rhs: PagerComponent) -> Bool { public static func ==(lhs: PagerComponent, rhs: PagerComponent) -> Bool {
@ -258,6 +261,9 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
if lhs.panelHideBehavior != rhs.panelHideBehavior { if lhs.panelHideBehavior != rhs.panelHideBehavior {
return false return false
} }
if lhs.clipContentToTopPanel != rhs.clipContentToTopPanel {
return false
}
return true return true
} }
@ -282,6 +288,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
var fraction: CGFloat = 0.0 var fraction: CGFloat = 0.0
} }
private var contentClippingView: UIView
private var contentViews: [AnyHashable: ContentView] = [:] private var contentViews: [AnyHashable: ContentView] = [:]
private var contentBackgroundView: ComponentHostView<Empty>? private var contentBackgroundView: ComponentHostView<Empty>?
private let topPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, Transition)>() private let topPanelVisibilityFractionUpdated = ActionSlot<(CGFloat, Transition)>()
@ -307,8 +314,13 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
} }
override init(frame: CGRect) { override init(frame: CGRect) {
self.contentClippingView = UIView()
self.contentClippingView.clipsToBounds = true
super.init(frame: frame) super.init(frame: frame)
self.addSubview(self.contentClippingView)
self.disablesInteractiveTransitionGestureRecognizer = true self.disablesInteractiveTransitionGestureRecognizer = true
let panRecognizer = PagerPanGestureRecognizerImpl(target: self, action: #selector(self.panGesture(_:))) let panRecognizer = PagerPanGestureRecognizerImpl(target: self, action: #selector(self.panGesture(_:)))
@ -444,6 +456,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
self.centralId = centralId self.centralId = centralId
} }
let contentSize = CGSize(width: availableSize.width, height: availableSize.height)
var contentInsets = component.contentInsets var contentInsets = component.contentInsets
contentInsets.bottom = 0.0 contentInsets.bottom = 0.0
var contentInsetTopPanelValue: CGFloat = 0.0 var contentInsetTopPanelValue: CGFloat = 0.0
@ -530,6 +543,10 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
panelStateTransition.setFrame(view: topPanelView, frame: CGRect(origin: CGPoint(), size: CGSize(width: topPanelSize.width, height: visibleTopPanelHeight))) panelStateTransition.setFrame(view: topPanelView, frame: CGRect(origin: CGPoint(), size: CGSize(width: topPanelSize.width, height: visibleTopPanelHeight)))
} else { } else {
panelStateTransition.setFrame(view: topPanelView, frame: CGRect(origin: CGPoint(x: 0.0, y: -topPanelOffset), size: topPanelSize)) panelStateTransition.setFrame(view: topPanelView, frame: CGRect(origin: CGPoint(x: 0.0, y: -topPanelOffset), size: topPanelSize))
let clippingOffset: CGFloat = component.clipContentToTopPanel ? topPanelSize.height - topPanelOffset : 0.0
panelStateTransition.setFrame(view: self.contentClippingView, frame: CGRect(origin: CGPoint(x: 0.0, y: clippingOffset), size: contentSize))
panelStateTransition.setBounds(view: self.contentClippingView, bounds: CGRect(origin: CGPoint(x: 0.0, y: clippingOffset), size: contentSize))
} }
contentInsetTopPanelValue = topPanelSize.height contentInsetTopPanelValue = topPanelSize.height
@ -623,7 +640,7 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
contentBackgroundTransition = .immediate contentBackgroundTransition = .immediate
contentBackgroundView = ComponentHostView<Empty>() contentBackgroundView = ComponentHostView<Empty>()
self.contentBackgroundView = contentBackgroundView self.contentBackgroundView = contentBackgroundView
self.insertSubview(contentBackgroundView, at: 0) self.contentClippingView.insertSubview(contentBackgroundView, at: 0)
} }
let _ = contentBackgroundView.update( let _ = contentBackgroundView.update(
transition: contentBackgroundTransition, transition: contentBackgroundTransition,
@ -638,11 +655,9 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
contentBackgroundView.removeFromSuperview() contentBackgroundView.removeFromSuperview()
} }
} }
var validIds: [AnyHashable] = [] var validIds: [AnyHashable] = []
if let centralId = self.centralId, let centralIndex = component.contents.firstIndex(where: { $0.id == centralId }) { if let centralId = self.centralId, let centralIndex = component.contents.firstIndex(where: { $0.id == centralId }) {
let contentSize = CGSize(width: availableSize.width, height: availableSize.height)
var referenceFrames: [AnyHashable: CGRect] = [:] var referenceFrames: [AnyHashable: CGRect] = [:]
if case .none = transition.animation { if case .none = transition.animation {
} else { } else {
@ -686,9 +701,9 @@ public final class PagerComponent<ChildEnvironmentType: Equatable, TopPanelEnvir
contentTransition = transition.withAnimation(.none) contentTransition = transition.withAnimation(.none)
self.contentViews[content.id] = contentView self.contentViews[content.id] = contentView
if let contentBackgroundView = self.contentBackgroundView { if let contentBackgroundView = self.contentBackgroundView {
self.insertSubview(contentView.view, aboveSubview: contentBackgroundView) self.contentClippingView.insertSubview(contentView.view, aboveSubview: contentBackgroundView)
} else { } else {
self.insertSubview(contentView.view, at: 0) self.contentClippingView.insertSubview(contentView.view, at: 0)
} }
} }

View File

@ -280,7 +280,7 @@ private final class ContextControllerActionsListActionItemNode: HighlightTrackin
} else if let animationName = self.item.animationName { } else if let animationName = self.item.animationName {
if self.animationNode == nil { if self.animationNode == nil {
let animationNode = AnimationNode(animation: animationName, colors: ["__allcolors__": titleColor], scale: 1.0) let animationNode = AnimationNode(animation: animationName, colors: ["__allcolors__": titleColor], scale: 1.0)
animationNode.loop() animationNode.loop(count: 3)
self.addSubnode(animationNode) self.addSubnode(animationNode)
self.animationNode = animationNode self.animationNode = animationNode
} }

View File

@ -156,7 +156,8 @@ private final class StickerSelectionComponent: Component {
hiddenInputHeight: 0.0, hiddenInputHeight: 0.0,
inputHeight: 0.0, inputHeight: 0.0,
displayBottomPanel: true, displayBottomPanel: true,
isExpanded: true isExpanded: true,
clipContentToTopPanel: false
)), )),
environment: {}, environment: {},
containerSize: availableSize containerSize: availableSize

View File

@ -1567,7 +1567,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
if !items.isEmpty { if !items.isEmpty {
items.append(.separator) items.append(.separator)
} }
items.append(.action(ContextMenuActionItem(text: hasSpoilers ? "Disable Spoiler Effect" : "Spoiler Effect", icon: { _ in return nil }, animationName: "anim_spoiler", action: { [weak self] _, f in items.append(.action(ContextMenuActionItem(text: hasSpoilers ? strings.Attachment_DisableSpoiler : strings.Attachment_EnableSpoiler, icon: { _ in return nil }, animationName: "anim_spoiler", action: { [weak self] _, f in
f(.default) f(.default)
guard let strongSelf = self else { guard let strongSelf = self else {
return return

View File

@ -256,6 +256,8 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
} }
} }
fileprivate var clipContentToTopPanel: Bool = false
var externalTopPanelContainerImpl: PagerExternalTopPanelContainer? var externalTopPanelContainerImpl: PagerExternalTopPanelContainer?
public override var externalTopPanelContainer: UIView? { public override var externalTopPanelContainer: UIView? {
return self.externalTopPanelContainerImpl return self.externalTopPanelContainerImpl
@ -1417,7 +1419,8 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
hiddenInputHeight: hiddenInputHeight, hiddenInputHeight: hiddenInputHeight,
inputHeight: inputHeight, inputHeight: inputHeight,
displayBottomPanel: true, displayBottomPanel: true,
isExpanded: isExpanded && !self.isEmojiSearchActive isExpanded: isExpanded && !self.isEmojiSearchActive,
clipContentToTopPanel: self.clipContentToTopPanel
)), )),
environment: {}, environment: {},
containerSize: CGSize(width: width, height: expandedHeight) containerSize: CGSize(width: width, height: expandedHeight)
@ -1895,6 +1898,7 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi
chatPeerId: nil chatPeerId: nil
) )
self.inputNode = inputNode self.inputNode = inputNode
inputNode.clipContentToTopPanel = hideBackground
inputNode.emojiInputInteraction = inputInteraction inputNode.emojiInputInteraction = inputInteraction
inputNode.externalTopPanelContainerImpl = nil inputNode.externalTopPanelContainerImpl = nil
inputNode.switchToTextInput = { [weak self] in inputNode.switchToTextInput = { [weak self] in

View File

@ -189,7 +189,8 @@ public final class EmojiStatusSelectionComponent: Component {
hiddenInputHeight: 0.0, hiddenInputHeight: 0.0,
inputHeight: 0.0, inputHeight: 0.0,
displayBottomPanel: false, displayBottomPanel: false,
isExpanded: false isExpanded: false,
clipContentToTopPanel: false
)), )),
environment: {}, environment: {},
containerSize: availableSize containerSize: availableSize

View File

@ -113,6 +113,7 @@ public final class EntityKeyboardComponent: Component {
public let inputHeight: CGFloat public let inputHeight: CGFloat
public let displayBottomPanel: Bool public let displayBottomPanel: Bool
public let isExpanded: Bool public let isExpanded: Bool
public let clipContentToTopPanel: Bool
public init( public init(
theme: PresentationTheme, theme: PresentationTheme,
@ -141,7 +142,8 @@ public final class EntityKeyboardComponent: Component {
hiddenInputHeight: CGFloat, hiddenInputHeight: CGFloat,
inputHeight: CGFloat, inputHeight: CGFloat,
displayBottomPanel: Bool, displayBottomPanel: Bool,
isExpanded: Bool isExpanded: Bool,
clipContentToTopPanel: Bool
) { ) {
self.theme = theme self.theme = theme
self.strings = strings self.strings = strings
@ -170,6 +172,7 @@ public final class EntityKeyboardComponent: Component {
self.inputHeight = inputHeight self.inputHeight = inputHeight
self.displayBottomPanel = displayBottomPanel self.displayBottomPanel = displayBottomPanel
self.isExpanded = isExpanded self.isExpanded = isExpanded
self.clipContentToTopPanel = clipContentToTopPanel
} }
public static func ==(lhs: EntityKeyboardComponent, rhs: EntityKeyboardComponent) -> Bool { public static func ==(lhs: EntityKeyboardComponent, rhs: EntityKeyboardComponent) -> Bool {
@ -230,6 +233,9 @@ public final class EntityKeyboardComponent: Component {
if lhs.isExpanded != rhs.isExpanded { if lhs.isExpanded != rhs.isExpanded {
return false return false
} }
if lhs.clipContentToTopPanel != rhs.clipContentToTopPanel {
return false
}
return true return true
} }
@ -738,7 +744,8 @@ public final class EntityKeyboardComponent: Component {
} }
strongSelf.isTopPanelHiddenUpdated(isTopPanelHidden: isTopPanelHidden, transition: transition) strongSelf.isTopPanelHiddenUpdated(isTopPanelHidden: isTopPanelHidden, transition: transition)
}, },
panelHideBehavior: panelHideBehavior panelHideBehavior: panelHideBehavior,
clipContentToTopPanel: component.clipContentToTopPanel
)), )),
environment: { environment: {
EntityKeyboardChildEnvironment( EntityKeyboardChildEnvironment(

View File

@ -420,7 +420,8 @@ private final class TopicIconSelectionComponent: Component {
hiddenInputHeight: 0.0, hiddenInputHeight: 0.0,
inputHeight: 0.0, inputHeight: 0.0,
displayBottomPanel: false, displayBottomPanel: false,
isExpanded: true isExpanded: true,
clipContentToTopPanel: false
)), )),
environment: {}, environment: {},
containerSize: availableSize containerSize: availableSize

File diff suppressed because one or more lines are too long