LiveTV iOS route to playback
This commit is contained in:
parent
081857262c
commit
5531c912ea
|
@ -16,15 +16,15 @@ final class LiveTVCoordinator: NavigationCoordinatable {
|
|||
|
||||
@Root
|
||||
var start = makeStart
|
||||
// @Route(.push)
|
||||
// var search = makeSearch
|
||||
@Route(.fullScreen)
|
||||
var videoPlayer = makeVideoPlayer
|
||||
|
||||
@ViewBuilder
|
||||
func makeStart() -> some View {
|
||||
LiveTVChannelsView()
|
||||
}
|
||||
|
||||
// func makeSearch(viewModel: LibrarySearchViewModel) -> SearchCoordinator {
|
||||
// SearchCoordinator(viewModel: viewModel)
|
||||
// }
|
||||
func makeVideoPlayer(viewModel: VideoPlayerViewModel) -> NavigationViewCoordinator<LiveTVVideoPlayerCoordinator> {
|
||||
NavigationViewCoordinator(LiveTVVideoPlayerCoordinator(viewModel: viewModel))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,11 +63,11 @@ struct LiveTVChannelItemWideElement: View {
|
|||
var body: some View {
|
||||
ZStack {
|
||||
HStack {
|
||||
ZStack(alignment: .bottomLeading) {
|
||||
ZStack(alignment: .center) {
|
||||
ImageView(channel.getPrimaryImage(maxWidth: 128))
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.padding(.init(top: 0, leading: 0, bottom: 8, trailing: 0))
|
||||
VStack {
|
||||
VStack(alignment: .center) {
|
||||
Spacer()
|
||||
.frame(maxHeight: .infinity)
|
||||
GeometryReader { gp in
|
||||
|
@ -81,8 +81,13 @@ struct LiveTVChannelItemWideElement: View {
|
|||
.frame(width: CGFloat(progressPercent * gp.size.width), height: 6)
|
||||
}
|
||||
}
|
||||
.frame(height: 6, alignment: .bottomLeading)
|
||||
.padding(.init(top: 0, leading: 0, bottom: 0, trailing: 8))
|
||||
.frame(height: 6, alignment: .center)
|
||||
.padding(.init(top: 0, leading: 4, bottom: 0, trailing: 4))
|
||||
}
|
||||
if loading {
|
||||
|
||||
ProgressView()
|
||||
|
||||
}
|
||||
}
|
||||
.aspectRatio(1.0, contentMode: .fit)
|
||||
|
@ -139,14 +144,15 @@ struct LiveTVChannelItemWideElement: View {
|
|||
.frame(alignment: .leading)
|
||||
.padding()
|
||||
.opacity(loading ? 0.5 : 1.0)
|
||||
|
||||
if loading {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 16, style: .continuous).fill(Color("BackgroundColor"))
|
||||
)
|
||||
.frame(height: 128)
|
||||
.onTapGesture {
|
||||
onSelect { loadingState in
|
||||
loading = loadingState
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ typealias LiveTVChannelViewProgram = (timeDisplay: String, title: String)
|
|||
|
||||
struct LiveTVChannelsView: View {
|
||||
@EnvironmentObject
|
||||
var router: LiveTVChannelsCoordinator.Router
|
||||
var router: LiveTVCoordinator.Router
|
||||
@StateObject
|
||||
var viewModel = LiveTVChannelsViewModel()
|
||||
@State private var isPortrait = false
|
||||
|
@ -75,12 +75,12 @@ struct LiveTVChannelsView: View {
|
|||
currentProgramText: currentProgramDisplayText,
|
||||
nextProgramsText: nextProgramsDisplayText(nextItems: nextItems, timeFormatter: viewModel.timeFormatter),
|
||||
onSelect: { loadingAction in
|
||||
loadingAction(true)
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in
|
||||
// self.router.route(to: \.videoPlayer, playerViewModel)
|
||||
// DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||
// loadingAction(false)
|
||||
// }
|
||||
loadingAction(true)
|
||||
self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in
|
||||
self.router.route(to: \.videoPlayer, playerViewModel)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||
loadingAction(false)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -165,8 +165,7 @@ struct LiveTVChannelsView: View {
|
|||
let scenes = UIApplication.shared.connectedScenes
|
||||
let windowScene = scenes.first as? UIWindowScene
|
||||
guard let scene = windowScene else { return }
|
||||
self.isPortrait = scene.interfaceOrientation.isPortrait
|
||||
print("orientationDidChange: isPortrait? \(self.isPortrait)")
|
||||
self.isPortrait = scene.interfaceOrientation.isPortrait
|
||||
}
|
||||
|
||||
private func nextProgramsDisplayText(nextItems: [BaseItemDto], timeFormatter: DateFormatter) -> [LiveTVChannelViewProgram] {
|
||||
|
|
Loading…
Reference in New Issue