mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 05:23:41 +00:00
Interface tweaks for SponsorBlock during playback
Show/Hide categories in timeline. Show/Hide notice after skip. Show adjusted or actual total time.
This commit is contained in:
parent
b5ac760af2
commit
ae65acdd16
@ -71,13 +71,13 @@ final class SeekModel: ObservableObject {
|
||||
func showOSD() {
|
||||
guard !presentingOSD else { return }
|
||||
|
||||
withAnimation(.easeIn(duration: 0.1)) { self.presentingOSD = true }
|
||||
presentingOSD = true
|
||||
}
|
||||
|
||||
func hideOSD() {
|
||||
guard presentingOSD else { return }
|
||||
|
||||
withAnimation(.easeIn(duration: 0.1)) { self.presentingOSD = false }
|
||||
presentingOSD = false
|
||||
}
|
||||
|
||||
func hideOSDWithDelay() {
|
||||
|
@ -244,6 +244,9 @@ extension Defaults.Keys {
|
||||
static let sponsorBlockInstance = Key<String>("sponsorBlockInstance", default: "https://sponsor.ajay.app")
|
||||
static let sponsorBlockCategories = Key<Set<String>>("sponsorBlockCategories", default: Set(SponsorBlockAPI.categories))
|
||||
static let sponsorBlockColors = Key<[String: String]>("sponsorBlockColors", default: SponsorBlockColors.dictionary)
|
||||
static let sponsorBlockShowTimeWithSkipsRemoved = Key<Bool>("sponsorBlockShowTimeWithSkipsRemoved", default: false)
|
||||
static let sponsorBlockShowCategoriesInTimeline = Key<Bool>("sponsorBlockShowCategoriesInTimeline", default: true)
|
||||
static let sponsorBlockShowNoticeAfterSkip = Key<Bool>("sponsorBlockShowNoticeAfterSkip", default: true)
|
||||
|
||||
// MARK: GROUP - Locations
|
||||
|
||||
|
@ -14,6 +14,7 @@ struct Seek: View {
|
||||
@Default(.playerControlsLayout) private var regularPlayerControlsLayout
|
||||
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
|
||||
@Default(.sponsorBlockColors) private var sponsorBlockColors
|
||||
@Default(.sponsorBlockShowNoticeAfterSkip) private var showNoticeAfterSkip
|
||||
|
||||
private func getColor(for category: String) -> Color {
|
||||
if let hexString = sponsorBlockColors[category], let rgbValue = Int(hexString.dropFirst(), radix: 16) {
|
||||
@ -36,6 +37,7 @@ struct Seek: View {
|
||||
#endif
|
||||
}
|
||||
.opacity(visible || YatteeApp.isForPreviews ? 1 : 0)
|
||||
.animation(.easeIn)
|
||||
}
|
||||
|
||||
var content: some View {
|
||||
@ -130,6 +132,7 @@ struct Seek: View {
|
||||
var visible: Bool {
|
||||
guard !(model.lastSeekTime.isNil && !model.isSeeking) else { return false }
|
||||
if let type = model.lastSeekType, !type.presentable { return false }
|
||||
if !showNoticeAfterSkip { if case .segmentSkip? = model.lastSeekType { return false }}
|
||||
|
||||
return !controls.presentingControls && !controls.presentingOverlays && model.presentingOSD
|
||||
}
|
||||
|
@ -52,6 +52,8 @@ struct TimelineView: View {
|
||||
@Default(.playerControlsLayout) private var regularPlayerControlsLayout
|
||||
@Default(.fullScreenPlayerControlsLayout) private var fullScreenPlayerControlsLayout
|
||||
@Default(.sponsorBlockColors) private var sponsorBlockColors
|
||||
@Default(.sponsorBlockShowTimeWithSkipsRemoved) private var showTimeWithSkipsRemoved
|
||||
@Default(.sponsorBlockShowCategoriesInTimeline) private var showCategoriesInTimeline
|
||||
|
||||
var playerControlsLayout: PlayerControlsLayout {
|
||||
player.playingFullScreen ? fullScreenPlayerControlsLayout : regularPlayerControlsLayout
|
||||
@ -84,13 +86,15 @@ struct TimelineView: View {
|
||||
Group {
|
||||
VStack(spacing: 3) {
|
||||
if dragging {
|
||||
if let segment = projectedSegment,
|
||||
let description = SponsorBlockAPI.categoryDescription(segment.category)
|
||||
{
|
||||
Text(description)
|
||||
.font(.system(size: playerControlsLayout.segmentFontSize))
|
||||
.fixedSize()
|
||||
.foregroundColor(getColor(for: segment.category))
|
||||
if showCategoriesInTimeline {
|
||||
if let segment = projectedSegment,
|
||||
let description = SponsorBlockAPI.categoryDescription(segment.category)
|
||||
{
|
||||
Text(description)
|
||||
.font(.system(size: playerControlsLayout.segmentFontSize))
|
||||
.fixedSize()
|
||||
.foregroundColor(getColor(for: segment.category))
|
||||
}
|
||||
}
|
||||
if let chapter = projectedChapter {
|
||||
Text(chapter.title)
|
||||
@ -156,8 +160,10 @@ struct TimelineView: View {
|
||||
.frame(width: (dragging ? projectedValue : current) * oneUnitWidth)
|
||||
.zIndex(1)
|
||||
|
||||
segmentsLayers
|
||||
.zIndex(2)
|
||||
if showCategoriesInTimeline {
|
||||
segmentsLayers
|
||||
.zIndex(2)
|
||||
}
|
||||
}
|
||||
.clipShape(RoundedRectangle(cornerRadius: cornerRadius))
|
||||
|
||||
@ -247,7 +253,7 @@ struct TimelineView: View {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Text(dragging ? playerTime.durationPlaybackTime : playerTime.withoutSegmentsPlaybackTime)
|
||||
Text(dragging || !showTimeWithSkipsRemoved ? playerTime.durationPlaybackTime : playerTime.withoutSegmentsPlaybackTime)
|
||||
.clipShape(RoundedRectangle(cornerRadius: 3))
|
||||
.frame(minWidth: 35)
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ struct SponsorBlockSettings: View {
|
||||
@Default(.sponsorBlockInstance) private var sponsorBlockInstance
|
||||
@Default(.sponsorBlockCategories) private var sponsorBlockCategories
|
||||
@Default(.sponsorBlockColors) private var sponsorBlockColors
|
||||
@Default(.sponsorBlockShowTimeWithSkipsRemoved) private var showTimeWithSkipsRemoved
|
||||
@Default(.sponsorBlockShowCategoriesInTimeline) private var showCategoriesInTimeline
|
||||
@Default(.sponsorBlockShowNoticeAfterSkip) private var showNoticeAfterSkip
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
@ -42,6 +45,13 @@ struct SponsorBlockSettings: View {
|
||||
.keyboardType(.URL)
|
||||
#endif
|
||||
}
|
||||
|
||||
Section(header: Text("Playback")) {
|
||||
Toggle("Categories in timeline", isOn: $showCategoriesInTimeline)
|
||||
Toggle("Post-skip notice", isOn: $showNoticeAfterSkip)
|
||||
Toggle("Adjusted total time", isOn: $showTimeWithSkipsRemoved)
|
||||
}
|
||||
|
||||
Section(header: SettingsHeader(text: "Categories to Skip".localized())) {
|
||||
categoryRows
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user