fix a bug about ios

This commit is contained in:
2026-08-31 13:37:38 +08:00
parent 637101bcdb
commit 7e4c0f5f90
4 changed files with 113 additions and 34 deletions

View File

@@ -5,33 +5,53 @@ struct FullscreenPlayerView: View {
@ObservedObject var controller: PlayerController
let onExit: () -> Void
@State private var subtitleVisible = true
var body: some View {
ZStack {
Color.black.ignoresSafeArea()
PlayerSurfaceView(controller: controller)
PlayerSurfaceView(controller: controller) { isSwipeUp in
guard subtitleVisible != isSwipeUp else {
return
}
withAnimation(.easeInOut(duration: 0.22)) {
subtitleVisible = isSwipeUp
}
}
.ignoresSafeArea()
HStack(spacing: 8) {
overlayPill(timeText)
Spacer()
overlayPill(Theme.formatSpeed(controller.snapshot.speed))
}
.padding(12)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.allowsHitTesting(false)
VStack {
Spacer()
VStack(alignment: .leading, spacing: 6) {
Text(controller.currentItem?.title ?? "未选择课程")
.font(.system(size: 17, weight: .bold))
.foregroundColor(.white)
.lineLimit(1)
Text(sentenceMetaText)
.font(.system(size: 13))
.foregroundColor(Theme.textOverlay)
Text(sentenceTextText)
.font(.system(size: 15))
.foregroundColor(.white)
.lineLimit(2)
progressRow
Text(statusText)
.font(.system(size: 13))
.foregroundColor(Theme.textOverlay)
if subtitleVisible {
VStack(alignment: .leading, spacing: 6) {
Text(controller.currentItem?.title ?? "未选择课程")
.font(.system(size: 17, weight: .bold))
.foregroundColor(.white)
.lineLimit(1)
Text(sentenceMetaText)
.font(.system(size: 13))
.foregroundColor(Theme.textOverlay)
Text(sentenceTextText)
.font(.system(size: 15))
.foregroundColor(.white)
.lineLimit(2)
progressRow
Text(statusText)
.font(.system(size: 13))
.foregroundColor(Theme.textOverlay)
}
.padding(18)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Theme.overlayFaint)
.transition(.move(edge: .bottom).combined(with: .opacity))
}
.padding(18)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Theme.overlayFaint)
}
VStack {
Spacer()
@@ -55,6 +75,11 @@ struct FullscreenPlayerView: View {
@State private var progressDragging = false
@State private var dragPositionMs: Int64 = 0
private var timeText: String {
let snapshot = controller.snapshot
return "\(Theme.formatTime(snapshot.positionMs)) / \(Theme.formatTime(snapshot.durationMs))"
}
private var progressRow: some View {
let duration = controller.snapshot.durationMs
return HStack(spacing: 8) {
@@ -133,4 +158,14 @@ struct FullscreenPlayerView: View {
}
return controller.playbackStatusText(controller.snapshot)
}
private func overlayPill(_ text: String) -> some View {
Text(text)
.font(.system(size: 13, weight: .bold))
.foregroundColor(.white)
.padding(.horizontal, 10)
.padding(.vertical, 6)
.background(Theme.overlay)
.clipShape(RoundedRectangle(cornerRadius: 8))
}
}