swiftformat

This commit is contained in:
jhays 2022-04-28 14:29:43 -05:00
parent a8f8a93efc
commit 80477c4bbd
13 changed files with 1684 additions and 1711 deletions

View File

@ -35,7 +35,6 @@ struct LiveTVChannelItemWideElement: View {
return 0
}
private var detailText: String {
guard let program = currentProgram else {
return ""
@ -88,7 +87,6 @@ struct LiveTVChannelItemWideElement: View {
if loading {
ProgressView()
}
}
.aspectRatio(1.0, contentMode: .fit)
@ -101,13 +99,16 @@ struct LiveTVChannelItemWideElement: View {
.foregroundColor(Color.jellyfinPurple)
.frame(alignment: .leading)
.padding(.init(top: 0, leading: 0, bottom: 4, trailing: 0))
programLabel(timeText: currentProgramText.timeDisplay, titleText: currentProgramText.title, color: Color("TextHighlightColor"))
if nextProgramsText.count > 0,
let nextItem = nextProgramsText[0] {
programLabel(timeText: currentProgramText.timeDisplay, titleText: currentProgramText.title,
color: Color("TextHighlightColor"))
if !nextProgramsText.isEmpty,
let nextItem = nextProgramsText[0]
{
programLabel(timeText: nextItem.timeDisplay, titleText: nextItem.title, color: Color.gray)
}
if nextProgramsText.count > 1,
let nextItem2 = nextProgramsText[1] {
let nextItem2 = nextProgramsText[1]
{
programLabel(timeText: nextItem2.timeDisplay, titleText: nextItem2.title, color: Color.gray)
}
Spacer()
@ -118,9 +119,7 @@ struct LiveTVChannelItemWideElement: View {
.padding()
.opacity(loading ? 0.5 : 1.0)
}
.background(
RoundedRectangle(cornerRadius: 10, style: .continuous).fill(Color("BackgroundSecondaryColor"))
)
.background(RoundedRectangle(cornerRadius: 10, style: .continuous).fill(Color("BackgroundSecondaryColor")))
.frame(height: 128)
.onTapGesture {
onSelect { loadingState in
@ -128,7 +127,7 @@ struct LiveTVChannelItemWideElement: View {
}
}
}
.background{
.background {
RoundedRectangle(cornerRadius: 10, style: .continuous)
.fill(Color("BackgroundColor"))
.shadow(color: Color("ShadowColor"), radius: 4, x: 0, y: 0)

View File

@ -18,7 +18,8 @@ struct LiveTVChannelsView: View {
var router: LiveTVCoordinator.Router
@StateObject
var viewModel = LiveTVChannelsViewModel()
@State private var isPortrait = false
@State
private var isPortrait = false
var body: some View {
if viewModel.isLoading == true {
@ -60,7 +61,8 @@ struct LiveTVChannelsView: View {
func makeCellView(indexPath: IndexPath, cell: LiveTVChannelRowCell) -> some View {
let item = cell.item
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
guard let start = program.startDate else {
return false
@ -73,7 +75,8 @@ struct LiveTVChannelsView: View {
LiveTVChannelItemWideElement(channel: channel,
currentProgram: item.currentProgram,
currentProgramText: currentProgramDisplayText,
nextProgramsText: nextProgramsDisplayText(nextItems: nextItems, timeFormatter: viewModel.timeFormatter),
nextProgramsText: nextProgramsDisplayText(nextItems: nextItems,
timeFormatter: viewModel.timeFormatter),
onSelect: { loadingAction in
loadingAction(true)
self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in
@ -87,49 +90,31 @@ struct LiveTVChannelsView: View {
private func createGridLayout() -> NSCollectionLayoutSection {
if UIDevice.current.userInterfaceIdiom == .pad {
let itemSize = NSCollectionLayoutSize(
widthDimension: .absolute((UIScreen.main.bounds.width / 2) - 16),
heightDimension: .fractionalHeight(1)
)
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute((UIScreen.main.bounds.width / 2) - 16),
heightDimension: .fractionalHeight(1))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(
leading: .flexible(0), top: nil,
trailing: .flexible(2), bottom: .flexible(2)
)
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: .flexible(0), top: nil,
trailing: .flexible(2), bottom: .flexible(2))
let item2 = NSCollectionLayoutItem(layoutSize: itemSize)
item2.edgeSpacing = NSCollectionLayoutEdgeSpacing(
leading: nil, top: nil,
trailing: .flexible(0), bottom: .flexible(2)
)
let groupSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(144)
)
let group = NSCollectionLayoutGroup.horizontal(
layoutSize: groupSize,
subitems: [item, item2]
)
item2.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: nil, top: nil,
trailing: .flexible(0), bottom: .flexible(2))
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(144))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize,
subitems: [item, item2])
let section = NSCollectionLayoutSection(group: group)
return section
} else {
if isPortrait {
let itemSize = NSCollectionLayoutSize(
widthDimension: .absolute(UIScreen.main.bounds.width - 32),
heightDimension: .fractionalHeight(1)
)
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(UIScreen.main.bounds.width - 32),
heightDimension: .fractionalHeight(1))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(
leading: .flexible(0), top: nil,
trailing: .flexible(2), bottom: .flexible(2)
)
let groupSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(144)
)
let group = NSCollectionLayoutGroup.horizontal(
layoutSize: groupSize,
subitems: [item]
)
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: .flexible(0), top: nil,
trailing: .flexible(2), bottom: .flexible(2))
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(144))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize,
subitems: [item])
let section = NSCollectionLayoutSection(group: group)
return section
} else {
@ -141,28 +126,18 @@ struct LiveTVChannelsView: View {
width = (UIScreen.main.bounds.width / 2) - safeArea.left - safeArea.right
}
let itemSize = NSCollectionLayoutSize(
widthDimension: .absolute(width),
heightDimension: .fractionalHeight(1)
)
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(width),
heightDimension: .fractionalHeight(1))
let item = NSCollectionLayoutItem(layoutSize: itemSize)
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(
leading: .flexible(0), top: nil,
trailing: .flexible(2), bottom: .flexible(2)
)
item.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: .flexible(0), top: nil,
trailing: .flexible(2), bottom: .flexible(2))
let item2 = NSCollectionLayoutItem(layoutSize: itemSize)
item2.edgeSpacing = NSCollectionLayoutEdgeSpacing(
leading: nil, top: nil,
trailing: .flexible(0), bottom: .flexible(2)
)
let groupSize = NSCollectionLayoutSize(
widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(144)
)
let group = NSCollectionLayoutGroup.horizontal(
layoutSize: groupSize,
subitems: [item, item2]
)
item2.edgeSpacing = NSCollectionLayoutEdgeSpacing(leading: nil, top: nil,
trailing: .flexible(0), bottom: .flexible(2))
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
heightDimension: .absolute(144))
let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize,
subitems: [item, item2])
let section = NSCollectionLayoutSection(group: group)
return section
}

View File

@ -38,10 +38,10 @@ struct LiveTVProgramsView: View {
}
}
} label: {
#if os(iOS)
#elseif os(tvOS)
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
@ -69,10 +69,10 @@ struct LiveTVProgramsView: View {
}
}
} label: {
#if os(iOS)
#elseif os(tvOS)
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
@ -100,10 +100,10 @@ struct LiveTVProgramsView: View {
}
}
} label: {
#if os(iOS)
#elseif os(tvOS)
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
@ -131,10 +131,10 @@ struct LiveTVProgramsView: View {
}
}
} label: {
#if os(iOS)
#elseif os(tvOS)
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
@ -162,10 +162,10 @@ struct LiveTVProgramsView: View {
}
}
} label: {
#if os(iOS)
#elseif os(tvOS)
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}
@ -193,10 +193,10 @@ struct LiveTVProgramsView: View {
}
}
} label: {
#if os(iOS)
#elseif os(tvOS)
#if os(iOS)
#elseif os(tvOS)
LandscapeItemElement(item: item)
#endif
#endif
}
.buttonStyle(PlainNavigationLinkButtonStyle())
}

View File

@ -1029,4 +1029,3 @@ extension LiveTVPlayerViewController: PlayerOverlayDelegate {
return videoAspectRatio > screenAspectRatio
}
}