swiftformat
This commit is contained in:
parent
a8f8a93efc
commit
80477c4bbd
|
@ -35,7 +35,6 @@ struct LiveTVChannelItemWideElement: View {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private var detailText: String {
|
private var detailText: String {
|
||||||
guard let program = currentProgram else {
|
guard let program = currentProgram else {
|
||||||
return ""
|
return ""
|
||||||
|
@ -88,7 +87,6 @@ struct LiveTVChannelItemWideElement: View {
|
||||||
if loading {
|
if loading {
|
||||||
|
|
||||||
ProgressView()
|
ProgressView()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.aspectRatio(1.0, contentMode: .fit)
|
.aspectRatio(1.0, contentMode: .fit)
|
||||||
|
@ -101,13 +99,16 @@ struct LiveTVChannelItemWideElement: View {
|
||||||
.foregroundColor(Color.jellyfinPurple)
|
.foregroundColor(Color.jellyfinPurple)
|
||||||
.frame(alignment: .leading)
|
.frame(alignment: .leading)
|
||||||
.padding(.init(top: 0, leading: 0, bottom: 4, trailing: 0))
|
.padding(.init(top: 0, leading: 0, bottom: 4, trailing: 0))
|
||||||
programLabel(timeText: currentProgramText.timeDisplay, titleText: currentProgramText.title, color: Color("TextHighlightColor"))
|
programLabel(timeText: currentProgramText.timeDisplay, titleText: currentProgramText.title,
|
||||||
if nextProgramsText.count > 0,
|
color: Color("TextHighlightColor"))
|
||||||
let nextItem = nextProgramsText[0] {
|
if !nextProgramsText.isEmpty,
|
||||||
|
let nextItem = nextProgramsText[0]
|
||||||
|
{
|
||||||
programLabel(timeText: nextItem.timeDisplay, titleText: nextItem.title, color: Color.gray)
|
programLabel(timeText: nextItem.timeDisplay, titleText: nextItem.title, color: Color.gray)
|
||||||
}
|
}
|
||||||
if nextProgramsText.count > 1,
|
if nextProgramsText.count > 1,
|
||||||
let nextItem2 = nextProgramsText[1] {
|
let nextItem2 = nextProgramsText[1]
|
||||||
|
{
|
||||||
programLabel(timeText: nextItem2.timeDisplay, titleText: nextItem2.title, color: Color.gray)
|
programLabel(timeText: nextItem2.timeDisplay, titleText: nextItem2.title, color: Color.gray)
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
|
@ -118,9 +119,7 @@ struct LiveTVChannelItemWideElement: View {
|
||||||
.padding()
|
.padding()
|
||||||
.opacity(loading ? 0.5 : 1.0)
|
.opacity(loading ? 0.5 : 1.0)
|
||||||
}
|
}
|
||||||
.background(
|
.background(RoundedRectangle(cornerRadius: 10, style: .continuous).fill(Color("BackgroundSecondaryColor")))
|
||||||
RoundedRectangle(cornerRadius: 10, style: .continuous).fill(Color("BackgroundSecondaryColor"))
|
|
||||||
)
|
|
||||||
.frame(height: 128)
|
.frame(height: 128)
|
||||||
.onTapGesture {
|
.onTapGesture {
|
||||||
onSelect { loadingState in
|
onSelect { loadingState in
|
||||||
|
|
|
@ -18,7 +18,8 @@ struct LiveTVChannelsView: View {
|
||||||
var router: LiveTVCoordinator.Router
|
var router: LiveTVCoordinator.Router
|
||||||
@StateObject
|
@StateObject
|
||||||
var viewModel = LiveTVChannelsViewModel()
|
var viewModel = LiveTVChannelsViewModel()
|
||||||
@State private var isPortrait = false
|
@State
|
||||||
|
private var isPortrait = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if viewModel.isLoading == true {
|
if viewModel.isLoading == true {
|
||||||
|
@ -60,7 +61,8 @@ struct LiveTVChannelsView: View {
|
||||||
func makeCellView(indexPath: IndexPath, cell: LiveTVChannelRowCell) -> some View {
|
func makeCellView(indexPath: IndexPath, cell: LiveTVChannelRowCell) -> some View {
|
||||||
let item = cell.item
|
let item = cell.item
|
||||||
let channel = item.channel
|
let channel = item.channel
|
||||||
let currentProgramDisplayText = item.currentProgram?.programDisplayText(timeFormatter: viewModel.timeFormatter) ?? LiveTVChannelViewProgram(timeDisplay: "", title: "")
|
let currentProgramDisplayText = item.currentProgram?
|
||||||
|
.programDisplayText(timeFormatter: viewModel.timeFormatter) ?? LiveTVChannelViewProgram(timeDisplay: "", title: "")
|
||||||
let nextItems = item.programs.filter { program in
|
let nextItems = item.programs.filter { program in
|
||||||
guard let start = program.startDate else {
|
guard let start = program.startDate else {
|
||||||
return false
|
return false
|
||||||
|
@ -73,7 +75,8 @@ struct LiveTVChannelsView: View {
|
||||||
LiveTVChannelItemWideElement(channel: channel,
|
LiveTVChannelItemWideElement(channel: channel,
|
||||||
currentProgram: item.currentProgram,
|
currentProgram: item.currentProgram,
|
||||||
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
|
||||||
|
@ -87,49 +90,31 @@ struct LiveTVChannelsView: View {
|
||||||
|
|
||||||
private func createGridLayout() -> NSCollectionLayoutSection {
|
private func createGridLayout() -> NSCollectionLayoutSection {
|
||||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||||
let itemSize = NSCollectionLayoutSize(
|
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute((UIScreen.main.bounds.width / 2) - 16),
|
||||||
widthDimension: .absolute((UIScreen.main.bounds.width / 2) - 16),
|
heightDimension: .fractionalHeight(1))
|
||||||
heightDimension: .fractionalHeight(1)
|
|
||||||
)
|
|
||||||
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||||
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(
|
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: .flexible(0), top: nil,
|
||||||
leading: .flexible(0), top: nil,
|
trailing: .flexible(2), bottom: .flexible(2))
|
||||||
trailing: .flexible(2), bottom: .flexible(2)
|
|
||||||
)
|
|
||||||
let item2 = NSCollectionLayoutItem(layoutSize: itemSize)
|
let item2 = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||||
item2.edgeSpacing = NSCollectionLayoutEdgeSpacing(
|
item2.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: nil, top: nil,
|
||||||
leading: nil, top: nil,
|
trailing: .flexible(0), bottom: .flexible(2))
|
||||||
trailing: .flexible(0), bottom: .flexible(2)
|
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
|
||||||
)
|
heightDimension: .absolute(144))
|
||||||
let groupSize = NSCollectionLayoutSize(
|
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize,
|
||||||
widthDimension: .fractionalWidth(1.0),
|
subitems: [item, item2])
|
||||||
heightDimension: .absolute(144)
|
|
||||||
)
|
|
||||||
let group = NSCollectionLayoutGroup.horizontal(
|
|
||||||
layoutSize: groupSize,
|
|
||||||
subitems: [item, item2]
|
|
||||||
)
|
|
||||||
let section = NSCollectionLayoutSection(group: group)
|
let section = NSCollectionLayoutSection(group: group)
|
||||||
return section
|
return section
|
||||||
} else {
|
} else {
|
||||||
if isPortrait {
|
if isPortrait {
|
||||||
let itemSize = NSCollectionLayoutSize(
|
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(UIScreen.main.bounds.width - 32),
|
||||||
widthDimension: .absolute(UIScreen.main.bounds.width - 32),
|
heightDimension: .fractionalHeight(1))
|
||||||
heightDimension: .fractionalHeight(1)
|
|
||||||
)
|
|
||||||
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||||
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(
|
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: .flexible(0), top: nil,
|
||||||
leading: .flexible(0), top: nil,
|
trailing: .flexible(2), bottom: .flexible(2))
|
||||||
trailing: .flexible(2), bottom: .flexible(2)
|
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
|
||||||
)
|
heightDimension: .absolute(144))
|
||||||
let groupSize = NSCollectionLayoutSize(
|
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize,
|
||||||
widthDimension: .fractionalWidth(1.0),
|
subitems: [item])
|
||||||
heightDimension: .absolute(144)
|
|
||||||
)
|
|
||||||
let group = NSCollectionLayoutGroup.horizontal(
|
|
||||||
layoutSize: groupSize,
|
|
||||||
subitems: [item]
|
|
||||||
)
|
|
||||||
let section = NSCollectionLayoutSection(group: group)
|
let section = NSCollectionLayoutSection(group: group)
|
||||||
return section
|
return section
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,28 +126,18 @@ struct LiveTVChannelsView: View {
|
||||||
width = (UIScreen.main.bounds.width / 2) - safeArea.left - safeArea.right
|
width = (UIScreen.main.bounds.width / 2) - safeArea.left - safeArea.right
|
||||||
}
|
}
|
||||||
|
|
||||||
let itemSize = NSCollectionLayoutSize(
|
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(width),
|
||||||
widthDimension: .absolute(width),
|
heightDimension: .fractionalHeight(1))
|
||||||
heightDimension: .fractionalHeight(1)
|
|
||||||
)
|
|
||||||
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
let item = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||||
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(
|
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: .flexible(0), top: nil,
|
||||||
leading: .flexible(0), top: nil,
|
trailing: .flexible(2), bottom: .flexible(2))
|
||||||
trailing: .flexible(2), bottom: .flexible(2)
|
|
||||||
)
|
|
||||||
let item2 = NSCollectionLayoutItem(layoutSize: itemSize)
|
let item2 = NSCollectionLayoutItem(layoutSize: itemSize)
|
||||||
item2.edgeSpacing = NSCollectionLayoutEdgeSpacing(
|
item2.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: nil, top: nil,
|
||||||
leading: nil, top: nil,
|
trailing: .flexible(0), bottom: .flexible(2))
|
||||||
trailing: .flexible(0), bottom: .flexible(2)
|
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
|
||||||
)
|
heightDimension: .absolute(144))
|
||||||
let groupSize = NSCollectionLayoutSize(
|
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize,
|
||||||
widthDimension: .fractionalWidth(1.0),
|
subitems: [item, item2])
|
||||||
heightDimension: .absolute(144)
|
|
||||||
)
|
|
||||||
let group = NSCollectionLayoutGroup.horizontal(
|
|
||||||
layoutSize: groupSize,
|
|
||||||
subitems: [item, item2]
|
|
||||||
)
|
|
||||||
let section = NSCollectionLayoutSection(group: group)
|
let section = NSCollectionLayoutSection(group: group)
|
||||||
return section
|
return section
|
||||||
}
|
}
|
||||||
|
|
|
@ -1029,4 +1029,3 @@ extension LiveTVPlayerViewController: PlayerOverlayDelegate {
|
||||||
return videoAspectRatio > screenAspectRatio
|
return videoAspectRatio > screenAspectRatio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue