mirror of
https://github.com/yattee/yattee.git
synced 2024-11-14 01:58:24 +00:00
Improve controls overlays performance
This commit is contained in:
parent
33d52aeed3
commit
fb40f42c6c
@ -39,7 +39,7 @@ struct PlayerControls: View {
|
|||||||
OpeningStream()
|
OpeningStream()
|
||||||
NetworkState()
|
NetworkState()
|
||||||
|
|
||||||
Group {
|
if model.presentingControls && !model.presentingOverlays {
|
||||||
VStack(spacing: 4) {
|
VStack(spacing: 4) {
|
||||||
buttonsBar
|
buttonsBar
|
||||||
|
|
||||||
@ -80,9 +80,10 @@ struct PlayerControls: View {
|
|||||||
}
|
}
|
||||||
.padding(.top, 2)
|
.padding(.top, 2)
|
||||||
.padding(.horizontal, 2)
|
.padding(.horizontal, 2)
|
||||||
|
.transition(.opacity)
|
||||||
}
|
}
|
||||||
.opacity(model.presentingOverlays ? 0 : model.presentingControls ? 1 : 0)
|
|
||||||
}
|
}
|
||||||
|
.frame(maxHeight: .infinity)
|
||||||
}
|
}
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
.onChange(of: model.presentingControls) { _ in
|
.onChange(of: model.presentingControls) { _ in
|
||||||
@ -98,39 +99,53 @@ struct PlayerControls: View {
|
|||||||
.background(controlsBackground)
|
.background(controlsBackground)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ControlsOverlay()
|
if model.presentingControlsOverlay {
|
||||||
.frame(height: overlayHeight)
|
ControlsOverlay()
|
||||||
.padding()
|
.frame(height: overlayHeight)
|
||||||
.modifier(ControlBackgroundModifier())
|
.padding()
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
.modifier(ControlBackgroundModifier())
|
||||||
.opacity(model.presentingControlsOverlay ? 1 : 0)
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||||
|
.transition(.opacity)
|
||||||
|
}
|
||||||
|
|
||||||
VideoDetailsOverlay()
|
if model.presentingDetailsOverlay {
|
||||||
.frame(maxWidth: detailsWidth, maxHeight: detailsHeight)
|
VideoDetailsOverlay()
|
||||||
.modifier(ControlBackgroundModifier())
|
.frame(maxWidth: detailsWidth, maxHeight: detailsHeight)
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 4))
|
.modifier(ControlBackgroundModifier())
|
||||||
.opacity(model.presentingDetailsOverlay ? 1 : 0)
|
.clipShape(RoundedRectangle(cornerRadius: 4))
|
||||||
|
.transition(.opacity)
|
||||||
|
}
|
||||||
|
|
||||||
Button {
|
if !model.presentingControls,
|
||||||
player.restoreLastSkippedSegment()
|
!model.presentingControls,
|
||||||
} label: {
|
let segment = player.lastSkipped
|
||||||
HStack(spacing: 10) {
|
{
|
||||||
if let segment = player.lastSkipped {
|
Button {
|
||||||
|
player.restoreLastSkippedSegment()
|
||||||
|
} label: {
|
||||||
|
HStack(spacing: 10) {
|
||||||
Image(systemName: "arrow.counterclockwise")
|
Image(systemName: "arrow.counterclockwise")
|
||||||
|
|
||||||
Text("Skipped \(segment.durationText) seconds of \(SponsorBlockAPI.categoryDescription(segment.category)?.lowercased() ?? "segment")")
|
Text("Skipped \(segment.durationText) seconds of \(SponsorBlockAPI.categoryDescription(segment.category)?.lowercased() ?? "segment")")
|
||||||
.frame(alignment: .bottomLeading)
|
.frame(alignment: .bottomLeading)
|
||||||
}
|
}
|
||||||
|
.padding(.vertical, 4)
|
||||||
|
.padding(.horizontal, 5)
|
||||||
|
.font(.system(size: 10))
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
.modifier(ControlBackgroundModifier())
|
||||||
|
.clipShape(RoundedRectangle(cornerRadius: 2))
|
||||||
}
|
}
|
||||||
.padding(.vertical, 4)
|
.buttonStyle(.plain)
|
||||||
.padding(.horizontal, 5)
|
.transition(.opacity)
|
||||||
.font(.system(size: 10))
|
}
|
||||||
.foregroundColor(.secondary)
|
}
|
||||||
.modifier(ControlBackgroundModifier())
|
.onChange(of: player.controls.presentingOverlays) { newValue in
|
||||||
.clipShape(RoundedRectangle(cornerRadius: 2))
|
if newValue {
|
||||||
|
player.backend.stopControlsUpdates()
|
||||||
|
} else {
|
||||||
|
player.backend.startControlsUpdates()
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
|
||||||
.opacity(model.presentingControls || model.presentingOverlays ? 0 : player.lastSkipped.isNil ? 0 : 1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user