Various Improvements

This commit is contained in:
Ilya Laktyushin 2021-11-26 21:39:39 +04:00
parent 989ef5d6a0
commit 5aeef57fc9
5 changed files with 25 additions and 9 deletions

View File

@ -47,7 +47,7 @@ open class GalleryOverlayContentNode: ASDisplayNode {
self.visibilityAlpha = alpha
}
open func updateLayout(size: CGSize, metrics: LayoutMetrics, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, transition: ContainedViewLayoutTransition) {
open func updateLayout(size: CGSize, metrics: LayoutMetrics, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, isHidden: Bool, transition: ContainedViewLayoutTransition) {
}
open func animateIn(previousContentNode: GalleryOverlayContentNode?, transition: ContainedViewLayoutTransition) {

View File

@ -101,7 +101,7 @@ public final class GalleryFooterNode: ASDisplayNode {
let contentTransition = ContainedViewLayoutTransition.animated(duration: 0.4, curve: .spring)
if let overlayContentNode = self.currentOverlayContentNode {
overlayContentNode.updateLayout(size: layout.size, metrics: layout.metrics, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, bottomInset: backgroundHeight, transition: transition)
overlayContentNode.updateLayout(size: layout.size, metrics: layout.metrics, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, bottomInset: isHidden ? layout.intrinsicInsets.bottom : backgroundHeight, isHidden: isHidden, transition: transition)
transition.updateFrame(node: overlayContentNode, frame: CGRect(origin: CGPoint(), size: layout.size))
if animateOverlayIn {

View File

@ -1141,6 +1141,11 @@ private class ImageRecognitionOverlayContentNode: GalleryOverlayContentNode {
self.action?(newValue)
self.buttonNode.isSelected = newValue
self.selectedBackgroundNode.isHidden = !newValue
if self.interfaceIsHidden && !newValue {
let transition = ContainedViewLayoutTransition.animated(duration: 0.2, curve: .easeInOut)
transition.updateAlpha(node: self.buttonNode, alpha: 0.0)
}
}
func transitionIn() {
@ -1152,17 +1157,28 @@ private class ImageRecognitionOverlayContentNode: GalleryOverlayContentNode {
self.buttonNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
}
override func updateLayout(size: CGSize, metrics: LayoutMetrics, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, transition: ContainedViewLayoutTransition) {
private var interfaceIsHidden: Bool = false
override func updateLayout(size: CGSize, metrics: LayoutMetrics, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, isHidden: Bool, transition: ContainedViewLayoutTransition) {
self.interfaceIsHidden = isHidden
let buttonSize = CGSize(width: 32.0, height: 32.0)
self.backgroundNode.frame = CGRect(origin: CGPoint(), size: buttonSize)
self.selectedBackgroundNode.frame = CGRect(origin: CGPoint(), size: buttonSize)
self.iconNode.frame = CGRect(origin: CGPoint(), size: buttonSize)
if self.appeared {
if !self.buttonNode.isSelected && isHidden {
transition.updateAlpha(node: self.buttonNode, alpha: 0.0)
} else {
transition.updateAlpha(node: self.buttonNode, alpha: 1.0)
}
}
transition.updateFrame(node: self.buttonNode, frame: CGRect(x: size.width - rightInset - buttonSize.width - 12.0, y: size.height - bottomInset - buttonSize.height - 12.0, width: buttonSize.width, height: buttonSize.height))
}
override func animateIn(previousContentNode: GalleryOverlayContentNode?, transition: ContainedViewLayoutTransition) {
guard self.appeared else {
guard self.appeared && (!self.interfaceIsHidden || self.buttonNode.isSelected) else {
return
}
self.buttonNode.alpha = 1.0

View File

@ -203,7 +203,7 @@ private final class UniversalVideoGalleryItemOverlayNode: GalleryOverlayContentN
self.fullscreenNode.addTarget(self, action: #selector(self.toggleFullscreenPressed), forControlEvents: .touchUpInside)
}
override func updateLayout(size: CGSize, metrics: LayoutMetrics, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, transition: ContainedViewLayoutTransition) {
override func updateLayout(size: CGSize, metrics: LayoutMetrics, leftInset: CGFloat, rightInset: CGFloat, bottomInset: CGFloat, isHidden: Bool, transition: ContainedViewLayoutTransition) {
self.validLayout = (size, metrics, leftInset, rightInset, bottomInset)
let isLandscape = size.width > size.height
@ -235,7 +235,7 @@ private final class UniversalVideoGalleryItemOverlayNode: GalleryOverlayContentN
self.wrapperNode.alpha = self.visibilityAlpha
if let validLayout = self.validLayout {
self.updateLayout(size: validLayout.0, metrics: validLayout.1, leftInset: validLayout.2, rightInset: validLayout.3, bottomInset: validLayout.4, transition: .animated(duration: 0.3, curve: .easeInOut))
self.updateLayout(size: validLayout.0, metrics: validLayout.1, leftInset: validLayout.2, rightInset: validLayout.3, bottomInset: validLayout.4, isHidden: false, transition: .animated(duration: 0.3, curve: .easeInOut))
}
}

View File

@ -716,7 +716,7 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
}
private func updateCounterTextNode(transition: ContainedViewLayoutTransition) {
let inputTextMaxLength: Int?
let inputTextMaxLength: Int32?
if self.isCaption {
inputTextMaxLength = self.context?.currentLimitsConfiguration.with { $0 }.maxMediaCaptionLength
} else {
@ -1034,13 +1034,13 @@ class PeerSelectionTextInputPanelNode: ChatInputPanelNode, TGCaptionPanelView, A
sendPressed(effectiveInputText)
return
}
let inputTextMaxLength: Int?
let inputTextMaxLength: Int32?
if self.isCaption {
inputTextMaxLength = self.context?.currentLimitsConfiguration.with { $0 }.maxMediaCaptionLength
} else {
inputTextMaxLength = nil
}
if let textInputNode = self.textInputNode, let presentationInterfaceState = self.presentationInterfaceState, let inputTextMaxLength = inputTextMaxLength {
if let textInputNode = self.textInputNode, let inputTextMaxLength = inputTextMaxLength {
let textCount = Int32(textInputNode.textView.text.count)
let remainingCount = inputTextMaxLength - textCount