1
0
mirror of https://github.com/yattee/yattee.git synced 2025-01-10 11:30:32 +05:30

Add close video button to browser controls

This commit is contained in:
Arkadiusz Fal 2022-05-29 22:13:39 +02:00
parent e3e68cd158
commit a0a6020ee6

View File

@ -65,15 +65,6 @@ struct BrowserPlayerControls<Content: View, Toolbar: View>: View {
.lineLimit(1) .lineLimit(1)
} }
} }
.contextMenu {
Button {
model.closeCurrentItem()
} label: {
Label("Close Video", systemImage: "xmark.circle")
.labelStyle(.automatic)
}
.disabled(model.currentItem.isNil)
}
Spacer() Spacer()
} }
@ -82,43 +73,41 @@ struct BrowserPlayerControls<Content: View, Toolbar: View>: View {
} }
.padding(.vertical, 20) .padding(.vertical, 20)
ZStack(alignment: .bottom) { HStack {
HStack { Group {
Group { if !model.currentItem.isNil {
if playerControls.isPlaying { Button {
Button(action: { model.closeCurrentItem()
model.pause() model.closePiP()
}) { } label: {
Label("Pause", systemImage: "pause.fill") Label("Close Video", systemImage: "xmark")
}
} else {
Button(action: {
model.play()
}) {
Label("Play", systemImage: "play.fill")
}
} }
} }
.disabled(playerControls.isLoadingVideo || model.currentItem.isNil)
.font(.system(size: 30))
.frame(minWidth: 30)
Button(action: { model.advanceToNextItem() }) { if playerControls.isPlaying {
Label("Next", systemImage: "forward.fill") Button(action: {
.padding(.vertical) model.pause()
.contentShape(Rectangle()) }) {
Label("Pause", systemImage: "pause.fill")
}
} else {
Button(action: {
model.play()
}) {
Label("Play", systemImage: "play.fill")
}
} }
.disabled(model.queue.isEmpty)
} }
.disabled(playerControls.isLoadingVideo || model.currentItem.isNil)
.font(.system(size: 30))
.frame(minWidth: 30)
ProgressView(value: progressViewValue, total: progressViewTotal) Button(action: { model.advanceToNextItem() }) {
.progressViewStyle(.linear) Label("Next", systemImage: "forward.fill")
#if os(iOS) .padding(.vertical)
.frame(maxWidth: 60) .contentShape(Rectangle())
#else }
.offset(y: 6) .disabled(model.queue.isEmpty)
.frame(maxWidth: 70)
#endif
} }
} }
.buttonStyle(.plain) .buttonStyle(.plain)