From f2e9bcaefe09aa54a3e9ccb9a530384f96a4761c Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Sun, 29 May 2022 22:13:39 +0200 Subject: [PATCH] Add close video button to browser controls --- Shared/Views/BrowserPlayerControls.swift | 69 ++++++++++-------------- 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/Shared/Views/BrowserPlayerControls.swift b/Shared/Views/BrowserPlayerControls.swift index 4f85afaa..95f3372c 100644 --- a/Shared/Views/BrowserPlayerControls.swift +++ b/Shared/Views/BrowserPlayerControls.swift @@ -65,15 +65,6 @@ struct BrowserPlayerControls: View { .lineLimit(1) } } - .contextMenu { - Button { - model.closeCurrentItem() - } label: { - Label("Close Video", systemImage: "xmark.circle") - .labelStyle(.automatic) - } - .disabled(model.currentItem.isNil) - } Spacer() } @@ -82,43 +73,41 @@ struct BrowserPlayerControls: View { } .padding(.vertical, 20) - ZStack(alignment: .bottom) { - HStack { - Group { - if playerControls.isPlaying { - Button(action: { - model.pause() - }) { - Label("Pause", systemImage: "pause.fill") - } - } else { - Button(action: { - model.play() - }) { - Label("Play", systemImage: "play.fill") - } + HStack { + Group { + if !model.currentItem.isNil { + Button { + model.closeCurrentItem() + model.closePiP() + } label: { + Label("Close Video", systemImage: "xmark") } } - .disabled(playerControls.isLoadingVideo || model.currentItem.isNil) - .font(.system(size: 30)) - .frame(minWidth: 30) - Button(action: { model.advanceToNextItem() }) { - Label("Next", systemImage: "forward.fill") - .padding(.vertical) - .contentShape(Rectangle()) + if playerControls.isPlaying { + Button(action: { + model.pause() + }) { + 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) - .progressViewStyle(.linear) - #if os(iOS) - .frame(maxWidth: 60) - #else - .offset(y: 6) - .frame(maxWidth: 70) - #endif + Button(action: { model.advanceToNextItem() }) { + Label("Next", systemImage: "forward.fill") + .padding(.vertical) + .contentShape(Rectangle()) + } + .disabled(model.queue.isEmpty) } } .buttonStyle(.plain)