mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
SponsorBlock set colors for each category
Default colors are defined in alignment to upstream. These can be changed by the user. The colors are also used in the Timeline and the seek view.
This commit is contained in:
@@ -51,11 +51,22 @@ struct TimelineView: View {
|
||||
|
||||
@Default(.playerControlsLayout) private var regularPlayerControlsLayout
|
||||
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
|
||||
@Default(.sponsorBlockColors) private var sponsorBlockColors
|
||||
|
||||
var playerControlsLayout: PlayerControlsLayout {
|
||||
player.playingFullScreen ? fullScreenPlayerControlsLayout : regularPlayerControlsLayout
|
||||
}
|
||||
|
||||
private func getColor(for category: String) -> Color {
|
||||
if let hexString = sponsorBlockColors[category], let rgbValue = Int(hexString.dropFirst(), radix: 16) {
|
||||
let r = Double((rgbValue >> 16) & 0xFF) / 255.0
|
||||
let g = Double((rgbValue >> 8) & 0xFF) / 255.0
|
||||
let b = Double(rgbValue & 0xFF) / 255.0
|
||||
return Color(red: r, green: g, blue: b)
|
||||
}
|
||||
return Color("AppRedColor") // Fallback color if no match found
|
||||
}
|
||||
|
||||
var chapters: [Chapter] {
|
||||
player.currentVideo?.chapters ?? []
|
||||
}
|
||||
@@ -79,7 +90,7 @@ struct TimelineView: View {
|
||||
Text(description)
|
||||
.font(.system(size: playerControlsLayout.segmentFontSize))
|
||||
.fixedSize()
|
||||
.foregroundColor(Color("AppRedColor"))
|
||||
.foregroundColor(getColor(for: segment.category))
|
||||
}
|
||||
if let chapter = projectedChapter {
|
||||
Text(chapter.title)
|
||||
@@ -299,7 +310,7 @@ struct TimelineView: View {
|
||||
ForEach(segments, id: \.uuid) { segment in
|
||||
Rectangle()
|
||||
.offset(x: segmentLayerHorizontalOffset(segment))
|
||||
.foregroundColor(Color("AppRedColor"))
|
||||
.foregroundColor(getColor(for: segment.category))
|
||||
.frame(maxHeight: height)
|
||||
.frame(width: segmentLayerWidth(segment))
|
||||
}
|
||||
|
Reference in New Issue
Block a user