clean up iOS LiveTVProgramsView

This commit is contained in:
jhays 2022-05-26 08:21:15 -05:00
parent 4564921701
commit 0d6b9acb79
1 changed files with 90 additions and 162 deletions

View File

@ -21,188 +21,116 @@ struct LiveTVProgramsView: View {
if !viewModel.recommendedItems.isEmpty, if !viewModel.recommendedItems.isEmpty,
let items = viewModel.recommendedItems let items = viewModel.recommendedItems
{ {
Text("On Now") PortraitImageHStackView(items: items,
.font(.headline) horizontalAlignment: .leading) {
.fontWeight(.semibold) Text("On Now")
.padding(.leading, 90) .font(.headline)
ScrollView(.horizontal, showsIndicators: false) { .fontWeight(.semibold)
LazyHStack { .padding(.leading, 90)
Spacer().frame(width: 45) } selectedAction: { item in
ForEach(items, id: \.id) { item in if let chanId = item.channelId,
Button { let chan = viewModel.findChannel(id: chanId)
if let chanId = item.channelId, {
let chan = viewModel.findChannel(id: chanId) self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
{ self.programsRouter.route(to: \.videoPlayer, playerViewModel)
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in }
self.programsRouter.route(to: \.videoPlayer, playerViewModel) }
} }
}
} label: {
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
Spacer().frame(width: 45)
}
}.frame(height: 350)
} }
if !viewModel.seriesItems.isEmpty, if !viewModel.seriesItems.isEmpty,
let items = viewModel.seriesItems let items = viewModel.seriesItems
{ {
Text("Shows") PortraitImageHStackView(items: items,
.font(.headline) horizontalAlignment: .leading) {
.fontWeight(.semibold) Text("Shows")
.padding(.leading, 90) .font(.headline)
ScrollView(.horizontal, showsIndicators: false) { .fontWeight(.semibold)
LazyHStack { .padding(.leading, 90)
Spacer().frame(width: 45) } selectedAction: { item in
ForEach(items, id: \.id) { item in if let chanId = item.channelId,
Button { let chan = viewModel.findChannel(id: chanId)
if let chanId = item.channelId, {
let chan = viewModel.findChannel(id: chanId) self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
{ self.programsRouter.route(to: \.videoPlayer, playerViewModel)
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in }
self.programsRouter.route(to: \.videoPlayer, playerViewModel) }
} }
}
} label: {
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
Spacer().frame(width: 45)
}
}.frame(height: 350)
} }
if !viewModel.movieItems.isEmpty, if !viewModel.movieItems.isEmpty,
let items = viewModel.movieItems let items = viewModel.movieItems
{ {
Text("Movies") PortraitImageHStackView(items: items,
.font(.headline) horizontalAlignment: .leading) {
.fontWeight(.semibold) Text("Movies")
.padding(.leading, 90) .font(.headline)
ScrollView(.horizontal, showsIndicators: false) { .fontWeight(.semibold)
LazyHStack { .padding(.leading, 90)
Spacer().frame(width: 45) } selectedAction: { item in
ForEach(items, id: \.id) { item in if let chanId = item.channelId,
Button { let chan = viewModel.findChannel(id: chanId)
if let chanId = item.channelId, {
let chan = viewModel.findChannel(id: chanId) self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
{ self.programsRouter.route(to: \.videoPlayer, playerViewModel)
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in }
self.programsRouter.route(to: \.videoPlayer, playerViewModel) }
} }
}
} label: {
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
Spacer().frame(width: 45)
}
}.frame(height: 350)
} }
if !viewModel.sportsItems.isEmpty, if !viewModel.sportsItems.isEmpty,
let items = viewModel.sportsItems let items = viewModel.sportsItems
{ {
Text("Sports") PortraitImageHStackView(items: items,
.font(.headline) horizontalAlignment: .leading) {
.fontWeight(.semibold) Text("Sports")
.padding(.leading, 90) .font(.headline)
ScrollView(.horizontal, showsIndicators: false) { .fontWeight(.semibold)
LazyHStack { .padding(.leading, 90)
Spacer().frame(width: 45) } selectedAction: { item in
ForEach(items, id: \.id) { item in if let chanId = item.channelId,
Button { let chan = viewModel.findChannel(id: chanId)
if let chanId = item.channelId, {
let chan = viewModel.findChannel(id: chanId) self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
{ self.programsRouter.route(to: \.videoPlayer, playerViewModel)
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in }
self.programsRouter.route(to: \.videoPlayer, playerViewModel) }
} }
}
} label: {
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
Spacer().frame(width: 45)
}
}.frame(height: 350)
} }
if !viewModel.kidsItems.isEmpty, if !viewModel.kidsItems.isEmpty,
let items = viewModel.kidsItems let items = viewModel.kidsItems
{ {
Text("Kids") PortraitImageHStackView(items: items,
.font(.headline) horizontalAlignment: .leading) {
.fontWeight(.semibold) Text("Kids")
.padding(.leading, 90) .font(.headline)
ScrollView(.horizontal, showsIndicators: false) { .fontWeight(.semibold)
LazyHStack { .padding(.leading, 90)
Spacer().frame(width: 45) } selectedAction: { item in
ForEach(items, id: \.id) { item in if let chanId = item.channelId,
Button { let chan = viewModel.findChannel(id: chanId)
if let chanId = item.channelId, {
let chan = viewModel.findChannel(id: chanId) self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
{ self.programsRouter.route(to: \.videoPlayer, playerViewModel)
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in }
self.programsRouter.route(to: \.videoPlayer, playerViewModel) }
} }
}
} label: {
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
Spacer().frame(width: 45)
}
}.frame(height: 350)
} }
if !viewModel.newsItems.isEmpty, if !viewModel.newsItems.isEmpty,
let items = viewModel.newsItems let items = viewModel.newsItems
{ {
Text("News") PortraitImageHStackView(items: items,
.font(.headline) horizontalAlignment: .leading) {
.fontWeight(.semibold) Text("News")
.padding(.leading, 90) .font(.headline)
ScrollView(.horizontal, showsIndicators: false) { .fontWeight(.semibold)
LazyHStack { .padding(.leading, 90)
Spacer().frame(width: 45) } selectedAction: { item in
ForEach(items, id: \.id) { item in if let chanId = item.channelId,
Button { let chan = viewModel.findChannel(id: chanId)
if let chanId = item.channelId, {
let chan = viewModel.findChannel(id: chanId) self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in
{ self.programsRouter.route(to: \.videoPlayer, playerViewModel)
self.viewModel.fetchVideoPlayerViewModel(item: chan) { playerViewModel in }
self.programsRouter.route(to: \.videoPlayer, playerViewModel) }
} }
}
} label: {
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
Spacer().frame(width: 45)
}
}.frame(height: 350)
} }
} }
} }