mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Update loop count
This commit is contained in:
parent
3a8ded1639
commit
1cbe7cdd29
@ -60,6 +60,7 @@ public enum AnimatedStickerPlaybackPosition {
|
||||
|
||||
public enum AnimatedStickerPlaybackMode {
|
||||
case once
|
||||
case count(Int)
|
||||
case loop
|
||||
case still(AnimatedStickerPlaybackPosition)
|
||||
}
|
||||
@ -757,6 +758,7 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
private var renderer: (AnimationRenderer & ASDisplayNode)?
|
||||
|
||||
public var isPlaying: Bool = false
|
||||
private var currentLoopCount: Int = 0
|
||||
private var canDisplayFirstFrame: Bool = false
|
||||
private var playbackMode: AnimatedStickerPlaybackMode = .loop
|
||||
|
||||
@ -910,8 +912,14 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
private var isSetUpForPlayback = false
|
||||
|
||||
public func play(firstFrame: Bool = false) {
|
||||
if case .once = self.playbackMode {
|
||||
switch self.playbackMode {
|
||||
case .once:
|
||||
self.isPlaying = true
|
||||
case .count:
|
||||
self.currentLoopCount = 0
|
||||
self.isPlaying = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
if self.isSetUpForPlayback {
|
||||
let directData = self.directData
|
||||
@ -976,6 +984,11 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
var stopNow = false
|
||||
if case .once = strongSelf.playbackMode {
|
||||
stopNow = true
|
||||
} else if case let .count(count) = strongSelf.playbackMode {
|
||||
strongSelf.currentLoopCount += 1
|
||||
if count <= strongSelf.currentLoopCount {
|
||||
stopNow = true
|
||||
}
|
||||
} else if strongSelf.stopAtNearestLoop {
|
||||
stopNow = true
|
||||
}
|
||||
@ -1061,6 +1074,11 @@ public final class AnimatedStickerNode: ASDisplayNode {
|
||||
var stopNow = false
|
||||
if case .once = strongSelf.playbackMode {
|
||||
stopNow = true
|
||||
} else if case let .count(count) = strongSelf.playbackMode {
|
||||
strongSelf.currentLoopCount += 1
|
||||
if count <= strongSelf.currentLoopCount {
|
||||
stopNow = true
|
||||
}
|
||||
} else if strongSelf.stopAtNearestLoop {
|
||||
stopNow = true
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ class ChatListFilterSettingsHeaderItemNode: ListViewItemNode {
|
||||
animationName = "MessageAutoRemove"
|
||||
size = 260
|
||||
insetDifference = 120
|
||||
playbackMode = .once
|
||||
playbackMode = .count(2)
|
||||
additionalBottomInset = isHidden ? 8.0 : 16.0
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user