Skip to content

Commit

Permalink
swift format
Browse files Browse the repository at this point in the history
  • Loading branch information
jhays committed Aug 18, 2023
1 parent 0b04d42 commit bd02d1b
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ final class MainCoordinator: NavigationCoordinatable {
func makeVideoPlayer(manager: VideoPlayerManager) -> VideoPlayerCoordinator {
VideoPlayerCoordinator(manager: manager)
}

func makeLiveVideoPlayer(manager: LiveVideoPlayerManager) -> LiveVideoPlayerCoordinator {
LiveVideoPlayerCoordinator(manager: manager)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Defaults
import SwiftUI

extension LiveVideoPlayer.Overlay {

struct LiveBottomBarView: View {

@Environment(\.currentOverlayType)
@Binding
private var currentOverlayType
Expand All @@ -22,7 +22,7 @@ extension LiveVideoPlayer.Overlay {
@Environment(\.isScrubbing)
@Binding
private var isScrubbing: Bool

@EnvironmentObject
private var currentProgressHandler: LiveVideoPlayerManager.CurrentProgressHandler
@EnvironmentObject
Expand All @@ -31,10 +31,10 @@ extension LiveVideoPlayer.Overlay {
private var videoPlayerManager: LiveVideoPlayerManager
@EnvironmentObject
private var viewModel: VideoPlayerViewModel

@FocusState
private var isBarFocused: Bool

@ViewBuilder
private var playbackStateView: some View {
// if videoPlayerManager.state == .playing {
Expand All @@ -45,13 +45,14 @@ extension LiveVideoPlayer.Overlay {
// ProgressView()
// }
// videoPLayerManager access is giving an error here:
// Fatal error: No ObservableObject of type LiveVideoPlayerManager found. A View.environmentObject(_:) for LiveVideoPlayerManager may be missing as an ancestor of this view.
// Fatal error: No ObservableObject of type LiveVideoPlayerManager found. A View.environmentObject(_:) for
// LiveVideoPlayerManager may be missing as an ancestor of this view.
EmptyView()
}

var body: some View {
VStack(alignment: .VideoPlayerTitleAlignmentGuide, spacing: 10) {

if let subtitle = viewModel.item.subtitle {
Text(subtitle)
.font(.subheadline)
Expand All @@ -60,25 +61,25 @@ extension LiveVideoPlayer.Overlay {
dimensions[.leading]
}
}

HStack {

Text(viewModel.item.displayTitle)
.font(.largeTitle)
.fontWeight(.bold)
.alignmentGuide(.VideoPlayerTitleAlignmentGuide) { dimensions in
dimensions[.leading]
}

Spacer()

VideoPlayer.Overlay.BarActionButtons()
}

tvOSSliderView(value: $currentProgressHandler.scrubbedProgress)
.onEditingChanged { isEditing in
isScrubbing = isEditing

if isEditing {
overlayTimer.pause()
} else {
Expand All @@ -88,18 +89,18 @@ extension LiveVideoPlayer.Overlay {
.focused($isBarFocused)
.frame(height: 60)
// .visible(isScrubbing || isPresentingOverlay)

HStack(spacing: 15) {

Text(currentProgressHandler.scrubbedSeconds.timeLabel)
.monospacedDigit()
.foregroundColor(.white)

playbackStateView
.frame(maxWidth: 40, maxHeight: 40)

Spacer()

Text((viewModel.item.runTimeSeconds - currentProgressHandler.scrubbedSeconds).timeLabel.prepending("-"))
.monospacedDigit()
.foregroundColor(.white)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Defaults
import SwiftUI

extension LiveVideoPlayer {

struct LiveMainOverlay: View {

@Environment(\.currentOverlayType)
@Binding
private var currentOverlayType
Expand All @@ -22,17 +22,17 @@ extension LiveVideoPlayer {
@Environment(\.isScrubbing)
@Binding
private var isScrubbing: Bool

@EnvironmentObject
private var currentProgressHandler: LiveVideoPlayerManager.CurrentProgressHandler
@EnvironmentObject
private var overlayTimer: TimerProxy

var body: some View {
VStack {

Spacer()

Overlay.LiveBottomBarView()
.padding2()
.padding2()
Expand Down
32 changes: 16 additions & 16 deletions Swiftfin tvOS/Views/VideoPlayer/LiveOverlays/LiveOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ import SwiftUI
import VLCUI

extension LiveVideoPlayer {

struct Overlay: View {

@Environment(\.isPresentingOverlay)
@Binding
private var isPresentingOverlay

@EnvironmentObject
private var proxy: VLCVideoPlayer.Proxy
@EnvironmentObject
private var router: LiveVideoPlayerCoordinator.Router

@State
private var confirmCloseWorkItem: DispatchWorkItem?
@State
private var currentOverlayType: VideoPlayer.OverlayType = .main

@StateObject
private var overlayTimer: TimerProxy = .init()

var body: some View {
ZStack {

LiveMainOverlay()
.visible(currentOverlayType == .main)

ConfirmCloseOverlay()
.visible(currentOverlayType == .confirmClose)

VideoPlayer.SmallMenuOverlay()
.visible(currentOverlayType == .smallMenu)

VideoPlayer.ChapterOverlay()
.visible(currentOverlayType == .chapters)
}
Expand All @@ -58,7 +58,7 @@ extension LiveVideoPlayer {
}
.onChange(of: overlayTimer.isActive) { isActive in
guard !isActive else { return }

withAnimation(.linear(duration: 0.3)) {
isPresentingOverlay = false
}
Expand All @@ -69,10 +69,10 @@ extension LiveVideoPlayer {
overlayTimer.start(5)
}
.onMenuPressed {

overlayTimer.start(5)
confirmCloseWorkItem?.cancel()

if isPresentingOverlay && currentOverlayType == .confirmClose {
proxy.stop()
router.dismissCoordinator()
Expand All @@ -83,16 +83,16 @@ extension LiveVideoPlayer {
currentOverlayType = .confirmClose
isPresentingOverlay = true
}

let task = DispatchWorkItem {
withAnimation {
isPresentingOverlay = false
overlayTimer.stop()
}
}

confirmCloseWorkItem = task

DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: task)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Swiftfin tvOS/Views/VideoPlayer/LiveVideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct LiveVideoPlayer: View {
private var currentProgressHandler: VideoPlayerManager.CurrentProgressHandler
@ObservedObject
private var videoPlayerManager: VideoPlayerManager

@State
private var isPresentingOverlay: Bool = false
@State
Expand Down
18 changes: 9 additions & 9 deletions Swiftfin/Views/VideoPlayer/LiveOverlays/LiveMainOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import Defaults
import SwiftUI

extension LiveVideoPlayer {

struct LiveMainOverlay: View {

@Default(.VideoPlayer.Overlay.playbackButtonType)
private var playbackButtonType

@Environment(\.currentOverlayType)
@Binding
private var currentOverlayType
Expand All @@ -27,13 +27,13 @@ extension LiveVideoPlayer {
private var isScrubbing: Bool
@Environment(\.safeAreaInsets)
private var safeAreaInsets

@EnvironmentObject
private var splitContentViewProxy: SplitContentViewProxy

@StateObject
private var overlayTimer: TimerProxy = .init()

var body: some View {
ZStack {
VStack {
Expand Down Expand Up @@ -61,7 +61,7 @@ extension LiveVideoPlayer {

Spacer()
.allowsHitTesting(false)

Overlay.LiveBottomBarView()
.if(UIDevice.hasNotch) { view in
view.padding(safeAreaInsets.mutating(\.trailing, with: 0))
Expand Down Expand Up @@ -91,7 +91,7 @@ extension LiveVideoPlayer {
}
.visible(isScrubbing || isPresentingOverlay)
}

if playbackButtonType == .large {
VideoPlayer.Overlay.LargePlaybackButtons()
.visible(!isScrubbing && isPresentingOverlay)
Expand All @@ -117,7 +117,7 @@ extension LiveVideoPlayer {
}
.onChange(of: overlayTimer.isActive) { newValue in
guard !newValue, !isScrubbing else { return }

withAnimation(.linear(duration: 0.3)) {
isPresentingOverlay = false
}
Expand Down
10 changes: 5 additions & 5 deletions Swiftfin/Views/VideoPlayer/LiveOverlays/LiveOverlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
import SwiftUI

extension LiveVideoPlayer {

struct Overlay: View {

@Environment(\.isPresentingOverlay)
@Binding
private var isPresentingOverlay

@State
private var currentOverlayType: VideoPlayer.OverlayType = .main

var body: some View {
ZStack {

LiveMainOverlay()
.visible(currentOverlayType == .main)
}
Expand Down

0 comments on commit bd02d1b

Please sign in to comment.