LiveTV iOS route to playback

This commit is contained in:
jhays 2022-04-24 19:44:56 -05:00
parent 081857262c
commit 5531c912ea
3 changed files with 27 additions and 22 deletions

View File

@ -16,15 +16,15 @@ final class LiveTVCoordinator: NavigationCoordinatable {
@Root @Root
var start = makeStart var start = makeStart
// @Route(.push) @Route(.fullScreen)
// var search = makeSearch var videoPlayer = makeVideoPlayer
@ViewBuilder @ViewBuilder
func makeStart() -> some View { func makeStart() -> some View {
LiveTVChannelsView() LiveTVChannelsView()
} }
// func makeSearch(viewModel: LibrarySearchViewModel) -> SearchCoordinator { func makeVideoPlayer(viewModel: VideoPlayerViewModel) -> NavigationViewCoordinator<LiveTVVideoPlayerCoordinator> {
// SearchCoordinator(viewModel: viewModel) NavigationViewCoordinator(LiveTVVideoPlayerCoordinator(viewModel: viewModel))
// } }
} }

View File

@ -63,11 +63,11 @@ struct LiveTVChannelItemWideElement: View {
var body: some View { var body: some View {
ZStack { ZStack {
HStack { HStack {
ZStack(alignment: .bottomLeading) { ZStack(alignment: .center) {
ImageView(channel.getPrimaryImage(maxWidth: 128)) ImageView(channel.getPrimaryImage(maxWidth: 128))
.aspectRatio(contentMode: .fit) .aspectRatio(contentMode: .fit)
.padding(.init(top: 0, leading: 0, bottom: 8, trailing: 0)) .padding(.init(top: 0, leading: 0, bottom: 8, trailing: 0))
VStack { VStack(alignment: .center) {
Spacer() Spacer()
.frame(maxHeight: .infinity) .frame(maxHeight: .infinity)
GeometryReader { gp in GeometryReader { gp in
@ -81,8 +81,13 @@ struct LiveTVChannelItemWideElement: View {
.frame(width: CGFloat(progressPercent * gp.size.width), height: 6) .frame(width: CGFloat(progressPercent * gp.size.width), height: 6)
} }
} }
.frame(height: 6, alignment: .bottomLeading) .frame(height: 6, alignment: .center)
.padding(.init(top: 0, leading: 0, bottom: 0, trailing: 8)) .padding(.init(top: 0, leading: 4, bottom: 0, trailing: 4))
}
if loading {
ProgressView()
} }
} }
.aspectRatio(1.0, contentMode: .fit) .aspectRatio(1.0, contentMode: .fit)
@ -139,14 +144,15 @@ struct LiveTVChannelItemWideElement: View {
.frame(alignment: .leading) .frame(alignment: .leading)
.padding() .padding()
.opacity(loading ? 0.5 : 1.0) .opacity(loading ? 0.5 : 1.0)
if loading {
ProgressView()
}
} }
.background( .background(
RoundedRectangle(cornerRadius: 16, style: .continuous).fill(Color("BackgroundColor")) RoundedRectangle(cornerRadius: 16, style: .continuous).fill(Color("BackgroundColor"))
) )
.frame(height: 128) .frame(height: 128)
.onTapGesture {
onSelect { loadingState in
loading = loadingState
}
}
} }
} }

View File

@ -15,7 +15,7 @@ typealias LiveTVChannelViewProgram = (timeDisplay: String, title: String)
struct LiveTVChannelsView: View { struct LiveTVChannelsView: View {
@EnvironmentObject @EnvironmentObject
var router: LiveTVChannelsCoordinator.Router var router: LiveTVCoordinator.Router
@StateObject @StateObject
var viewModel = LiveTVChannelsViewModel() var viewModel = LiveTVChannelsViewModel()
@State private var isPortrait = false @State private var isPortrait = false
@ -75,12 +75,12 @@ struct LiveTVChannelsView: View {
currentProgramText: currentProgramDisplayText, currentProgramText: currentProgramDisplayText,
nextProgramsText: nextProgramsDisplayText(nextItems: nextItems, timeFormatter: viewModel.timeFormatter), nextProgramsText: nextProgramsDisplayText(nextItems: nextItems, timeFormatter: viewModel.timeFormatter),
onSelect: { loadingAction in onSelect: { loadingAction in
loadingAction(true) loadingAction(true)
self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in
// self.router.route(to: \.videoPlayer, playerViewModel) self.router.route(to: \.videoPlayer, playerViewModel)
// DispatchQueue.main.asyncAfter(deadline: .now() + 2) { DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
// loadingAction(false) loadingAction(false)
// } }
} }
}) })
} }
@ -165,8 +165,7 @@ struct LiveTVChannelsView: View {
let scenes = UIApplication.shared.connectedScenes let scenes = UIApplication.shared.connectedScenes
let windowScene = scenes.first as? UIWindowScene let windowScene = scenes.first as? UIWindowScene
guard let scene = windowScene else { return } guard let scene = windowScene else { return }
self.isPortrait = scene.interfaceOrientation.isPortrait self.isPortrait = scene.interfaceOrientation.isPortrait
print("orientationDidChange: isPortrait? \(self.isPortrait)")
} }
private func nextProgramsDisplayText(nextItems: [BaseItemDto], timeFormatter: DateFormatter) -> [LiveTVChannelViewProgram] { private func nextProgramsDisplayText(nextItems: [BaseItemDto], timeFormatter: DateFormatter) -> [LiveTVChannelViewProgram] {