mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Various fixes
This commit is contained in:
parent
6266e0302a
commit
d86112541f
@ -653,7 +653,7 @@ public final class DefaultAnimatedStickerNodeImpl: ASDisplayNode, AnimatedSticke
|
||||
|
||||
strongSelf.frameUpdated(frame.index, frame.totalFrames)
|
||||
strongSelf.currentFrameIndex = frame.index
|
||||
strongSelf.currentFrameCount = frame.totalFrames;
|
||||
strongSelf.currentFrameCount = frame.totalFrames
|
||||
strongSelf.currentFrameRate = frameRate
|
||||
|
||||
if frame.isLastFrame {
|
||||
|
@ -1328,7 +1328,8 @@ public class BrowserScreen: ViewController, MinimizableController {
|
||||
right: layout.safeInsets.right
|
||||
),
|
||||
navigationBarHeight: navigationBarHeight,
|
||||
scrollingPanelOffsetFraction: self.scrollingPanelOffsetFraction
|
||||
scrollingPanelOffsetFraction: self.scrollingPanelOffsetFraction,
|
||||
hasBottomPanel: !layout.metrics.isTablet || self.presentationState.isSearching
|
||||
)
|
||||
))
|
||||
)
|
||||
@ -1539,17 +1540,20 @@ private final class BrowserContentComponent: Component {
|
||||
let insets: UIEdgeInsets
|
||||
let navigationBarHeight: CGFloat
|
||||
let scrollingPanelOffsetFraction: CGFloat
|
||||
let hasBottomPanel: Bool
|
||||
|
||||
init(
|
||||
content: BrowserContent,
|
||||
insets: UIEdgeInsets,
|
||||
navigationBarHeight: CGFloat,
|
||||
scrollingPanelOffsetFraction: CGFloat
|
||||
scrollingPanelOffsetFraction: CGFloat,
|
||||
hasBottomPanel: Bool
|
||||
) {
|
||||
self.content = content
|
||||
self.insets = insets
|
||||
self.navigationBarHeight = navigationBarHeight
|
||||
self.scrollingPanelOffsetFraction = scrollingPanelOffsetFraction
|
||||
self.hasBottomPanel = hasBottomPanel
|
||||
}
|
||||
|
||||
static func ==(lhs: BrowserContentComponent, rhs: BrowserContentComponent) -> Bool {
|
||||
@ -1565,6 +1569,9 @@ private final class BrowserContentComponent: Component {
|
||||
if lhs.scrollingPanelOffsetFraction != rhs.scrollingPanelOffsetFraction {
|
||||
return false
|
||||
}
|
||||
if lhs.hasBottomPanel != rhs.hasBottomPanel {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@ -1584,9 +1591,9 @@ private final class BrowserContentComponent: Component {
|
||||
|
||||
let collapsedHeight: CGFloat = 24.0
|
||||
let topInset: CGFloat = component.navigationBarHeight * (1.0 - component.scrollingPanelOffsetFraction) + (component.insets.top + collapsedHeight) * component.scrollingPanelOffsetFraction
|
||||
let bottomInset = (49.0 + component.insets.bottom) * (1.0 - component.scrollingPanelOffsetFraction)
|
||||
let bottomInset = component.hasBottomPanel ? (49.0 + component.insets.bottom) * (1.0 - component.scrollingPanelOffsetFraction) : 0.0
|
||||
let insets = UIEdgeInsets(top: topInset, left: component.insets.left, bottom: bottomInset, right: component.insets.right)
|
||||
let fullInsets = UIEdgeInsets(top: component.insets.top + component.navigationBarHeight, left: component.insets.left, bottom: 49.0 + component.insets.bottom, right: component.insets.right)
|
||||
let fullInsets = UIEdgeInsets(top: component.insets.top + component.navigationBarHeight, left: component.insets.left, bottom: component.hasBottomPanel ? 49.0 + component.insets.bottom : 0.0, right: component.insets.right)
|
||||
|
||||
component.content.updateLayout(size: availableSize, insets: insets, fullInsets: fullInsets, safeInsets: component.insets, transition: transition)
|
||||
transition.setFrame(view: component.content, frame: CGRect(origin: .zero, size: availableSize))
|
||||
|
@ -624,6 +624,15 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
|
||||
}
|
||||
|
||||
func getRenderSubEntities() -> [DrawingEntity] {
|
||||
var explicitlyStaticStickers = Set<Int64>()
|
||||
if let customEmojiContainerView = self.customEmojiContainerView {
|
||||
for (key, view) in customEmojiContainerView.emojiLayers {
|
||||
if let view = view as? EmojiTextAttachmentView, let numFrames = view.contentLayer.numFrames, numFrames == 1 {
|
||||
explicitlyStaticStickers.insert(key.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let textSize = self.textView.bounds.size
|
||||
let textPosition = self.textEntity.position
|
||||
let scale = self.textEntity.scale
|
||||
@ -638,6 +647,9 @@ public final class DrawingTextEntityView: DrawingEntityView, UITextViewDelegate
|
||||
let emojiTextPosition = emojiRect.center.offsetBy(dx: -textSize.width / 2.0, dy: -textSize.height / 2.0)
|
||||
|
||||
let entity = DrawingStickerEntity(content: .file(.standalone(media: file), .sticker))
|
||||
if explicitlyStaticStickers.contains(file.fileId.id) {
|
||||
entity.isExplicitlyStatic = true
|
||||
}
|
||||
entity.referenceDrawingSize = CGSize(width: itemSize * 4.0, height: itemSize * 4.0)
|
||||
entity.scale = scale
|
||||
entity.position = textPosition.offsetBy(
|
||||
|
@ -477,6 +477,8 @@ public final class LegacyPaintEntityRenderer: NSObject, TGPhotoPaintEntityRender
|
||||
}
|
||||
|
||||
func lcm(_ x: Int64, _ y: Int64) -> Int64 {
|
||||
let x = max(x, 1)
|
||||
let y = max(y, 1)
|
||||
return x / gcd(x, y) * y
|
||||
}
|
||||
|
||||
@ -486,7 +488,7 @@ public final class LegacyPaintEntityRenderer: NSObject, TGPhotoPaintEntityRender
|
||||
let minDuration: Double = 3.0
|
||||
if durations.count > 1 {
|
||||
let reduced = durations.reduce(1.0) { lhs, rhs -> Double in
|
||||
return Double(lcm(Int64(lhs * 10.0), Int64(rhs * 10.0)))
|
||||
return Double(lcm(Int64(lhs * 100.0), Int64(rhs * 100.0)))
|
||||
}
|
||||
result = min(6.0, Double(reduced) / 10.0)
|
||||
} else if let duration = durations.first {
|
||||
|
@ -776,7 +776,7 @@ public final class InlineStickerItemLayer: MultiAnimationRenderTarget {
|
||||
}
|
||||
|
||||
public final class EmojiTextAttachmentView: UIView {
|
||||
private let contentLayer: InlineStickerItemLayer
|
||||
public let contentLayer: InlineStickerItemLayer
|
||||
|
||||
public var isActive: Bool = true {
|
||||
didSet {
|
||||
@ -826,7 +826,7 @@ public final class EmojiTextAttachmentView: UIView {
|
||||
public final class CustomEmojiContainerView: UIView {
|
||||
private let emojiViewProvider: (ChatTextInputTextCustomEmojiAttribute) -> UIView?
|
||||
|
||||
private var emojiLayers: [InlineStickerItemLayer.Key: UIView] = [:]
|
||||
public private(set) var emojiLayers: [InlineStickerItemLayer.Key: UIView] = [:]
|
||||
|
||||
public init(emojiViewProvider: @escaping (ChatTextInputTextCustomEmojiAttribute) -> UIView?) {
|
||||
self.emojiViewProvider = emojiViewProvider
|
||||
|
@ -88,11 +88,15 @@ public final class DrawingTextEntity: DrawingEntity, Codable {
|
||||
return true
|
||||
}
|
||||
var isAnimated = false
|
||||
self.text.enumerateAttributes(in: NSMakeRange(0, self.text.length), options: [], using: { attributes, range, _ in
|
||||
if let _ = attributes[ChatTextInputAttributes.customEmoji] as? ChatTextInputTextCustomEmojiAttribute {
|
||||
isAnimated = true
|
||||
|
||||
if let renderSubEntities = self.renderSubEntities {
|
||||
for entity in renderSubEntities {
|
||||
if entity.isAnimated {
|
||||
isAnimated = true
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return isAnimated
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ private var nextRenderTargetId: Int64 = 1
|
||||
|
||||
open class MultiAnimationRenderTarget: SimpleLayer {
|
||||
public let id: Int64
|
||||
public var numFrames: Int?
|
||||
|
||||
let deinitCallbacks = Bag<() -> Void>()
|
||||
let updateStateCallbacks = Bag<() -> Void>()
|
||||
@ -545,6 +546,7 @@ public final class MultiAnimationRendererImpl: MultiAnimationRenderer {
|
||||
}
|
||||
|
||||
target.contents = loadedFrame.image.cgImage
|
||||
target.numFrames = item.numFrames
|
||||
|
||||
if let blurredRepresentationTarget = target.blurredRepresentationTarget {
|
||||
blurredRepresentationTarget.contents = loadedFrame.blurredRepresentation(color: target.blurredRepresentationBackgroundColor)?.cgImage
|
||||
@ -580,6 +582,7 @@ public final class MultiAnimationRendererImpl: MultiAnimationRenderer {
|
||||
completion(false, true)
|
||||
return
|
||||
}
|
||||
target.numFrames = item.numFrames
|
||||
if let loadedFrame = loadedFrame {
|
||||
if let cgImage = loadedFrame.image.cgImage {
|
||||
if hadIntermediateUpdate {
|
||||
|
Loading…
x
Reference in New Issue
Block a user