Various fixes

This commit is contained in:
Ilya Laktyushin
2022-05-03 05:44:58 +04:00
parent be662de71d
commit b317ba1ee7
33 changed files with 260 additions and 85 deletions

View File

@@ -18,7 +18,7 @@ private func generateHandleBackground(color: UIColor) -> UIImage? {
})?.stretchableImage(withLeftCapWidth: 0, topCapHeight: 2)
}
public struct MediaPlayerScrubbingChapter {
public struct MediaPlayerScrubbingChapter: Equatable {
public let title: String
public let start: Double
@@ -37,7 +37,7 @@ private final class MediaPlayerScrubbingNodeButton: ASDisplayNode, UIGestureReco
var highlighted: ((Bool) -> Void)?
var verticalPanEnabled = false
var hapticFeedback = HapticFeedback()
private let hapticFeedback = HapticFeedback()
private var scrubbingMultiplier: Double = 1.0
private var scrubbingStartLocation: CGPoint?
@@ -287,6 +287,10 @@ public final class MediaPlayerScrubbingNode: ASDisplayNode {
return self._scrubbingPosition.get()
}
public var isScrubbing: Bool {
return self.scrubbingTimestampValue != nil
}
public var ignoreSeekId: Int?
public var enableScrubbing: Bool = true {
@@ -853,20 +857,28 @@ public final class MediaPlayerScrubbingNode: ASDisplayNode {
chapterNodesContainer.frame = backgroundFrame
var addedBeginning = false
for i in 1 ..< node.chapterNodes.count {
let (previousChapter, previousChapterNode) = node.chapterNodes[i - 1]
let (chapter, chapterNode) = node.chapterNodes[i]
let lineWidth: CGFloat = 1.0 + UIScreenPixel * 2.0
let startPosition: CGFloat
if i == 1 {
if !addedBeginning {
startPosition = 0.0
} else {
startPosition = floor(backgroundFrame.width * CGFloat(previousChapter.start / duration)) + lineWidth / 2.0
}
let endPosition: CGFloat = max(startPosition, floor(backgroundFrame.width * CGFloat(chapter.start / duration)) - lineWidth / 2.0)
let width = endPosition - startPosition
if width < lineWidth * 2.0 {
previousChapterNode.frame = CGRect()
continue
}
previousChapterNode.frame = CGRect(x: startPosition, y: 0.0, width: endPosition - startPosition, height: backgroundFrame.size.height)
addedBeginning = true
if i == node.chapterNodes.count - 1 {
let startPosition = endPosition + lineWidth
chapterNode.frame = CGRect(x: startPosition, y: 0.0, width: backgroundFrame.size.width - startPosition, height: backgroundFrame.size.height)
@@ -877,7 +889,6 @@ public final class MediaPlayerScrubbingNode: ASDisplayNode {
}
}
if let handleNode = node.handleNode {
var handleSize: CGSize = CGSize(width: 2.0, height: bounds.size.height)
var handleOffset: CGFloat = 0.0