Refactor
This commit is contained in:
parent
16e3cd6ea5
commit
d10cb35451
|
@ -263,8 +263,8 @@
|
||||||
E18845F626DD631E00B0C5B7 /* BaseItemDto+Stackable.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18845F426DD631E00B0C5B7 /* BaseItemDto+Stackable.swift */; };
|
E18845F626DD631E00B0C5B7 /* BaseItemDto+Stackable.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18845F426DD631E00B0C5B7 /* BaseItemDto+Stackable.swift */; };
|
||||||
E18845F826DEA9C900B0C5B7 /* ItemViewBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18845F726DEA9C900B0C5B7 /* ItemViewBody.swift */; };
|
E18845F826DEA9C900B0C5B7 /* ItemViewBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18845F726DEA9C900B0C5B7 /* ItemViewBody.swift */; };
|
||||||
E188460026DECB9E00B0C5B7 /* ItemLandscapeTopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18845FF26DECB9E00B0C5B7 /* ItemLandscapeTopBarView.swift */; };
|
E188460026DECB9E00B0C5B7 /* ItemLandscapeTopBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E18845FF26DECB9E00B0C5B7 /* ItemLandscapeTopBarView.swift */; };
|
||||||
E188460426DEF04800B0C5B7 /* CardVStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E188460326DEF04800B0C5B7 /* CardVStackView.swift */; };
|
E188460426DEF04800B0C5B7 /* EpisodeCardVStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E188460326DEF04800B0C5B7 /* EpisodeCardVStackView.swift */; };
|
||||||
E188460526DEF04800B0C5B7 /* CardVStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E188460326DEF04800B0C5B7 /* CardVStackView.swift */; };
|
E188460526DEF04800B0C5B7 /* EpisodeCardVStackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E188460326DEF04800B0C5B7 /* EpisodeCardVStackView.swift */; };
|
||||||
E1AD104A26D94822003E4A08 /* DetailItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1AD104926D94822003E4A08 /* DetailItem.swift */; };
|
E1AD104A26D94822003E4A08 /* DetailItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1AD104926D94822003E4A08 /* DetailItem.swift */; };
|
||||||
E1AD104B26D94822003E4A08 /* DetailItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1AD104926D94822003E4A08 /* DetailItem.swift */; };
|
E1AD104B26D94822003E4A08 /* DetailItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1AD104926D94822003E4A08 /* DetailItem.swift */; };
|
||||||
E1AD104D26D96CE3003E4A08 /* BaseItemDtoExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1AD104C26D96CE3003E4A08 /* BaseItemDtoExtensions.swift */; };
|
E1AD104D26D96CE3003E4A08 /* BaseItemDtoExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1AD104C26D96CE3003E4A08 /* BaseItemDtoExtensions.swift */; };
|
||||||
|
@ -497,7 +497,7 @@
|
||||||
E18845F426DD631E00B0C5B7 /* BaseItemDto+Stackable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseItemDto+Stackable.swift"; sourceTree = "<group>"; };
|
E18845F426DD631E00B0C5B7 /* BaseItemDto+Stackable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BaseItemDto+Stackable.swift"; sourceTree = "<group>"; };
|
||||||
E18845F726DEA9C900B0C5B7 /* ItemViewBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemViewBody.swift; sourceTree = "<group>"; };
|
E18845F726DEA9C900B0C5B7 /* ItemViewBody.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemViewBody.swift; sourceTree = "<group>"; };
|
||||||
E18845FF26DECB9E00B0C5B7 /* ItemLandscapeTopBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemLandscapeTopBarView.swift; sourceTree = "<group>"; };
|
E18845FF26DECB9E00B0C5B7 /* ItemLandscapeTopBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemLandscapeTopBarView.swift; sourceTree = "<group>"; };
|
||||||
E188460326DEF04800B0C5B7 /* CardVStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardVStackView.swift; sourceTree = "<group>"; };
|
E188460326DEF04800B0C5B7 /* EpisodeCardVStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EpisodeCardVStackView.swift; sourceTree = "<group>"; };
|
||||||
E1AD104926D94822003E4A08 /* DetailItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailItem.swift; sourceTree = "<group>"; };
|
E1AD104926D94822003E4A08 /* DetailItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailItem.swift; sourceTree = "<group>"; };
|
||||||
E1AD104C26D96CE3003E4A08 /* BaseItemDtoExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemDtoExtensions.swift; sourceTree = "<group>"; };
|
E1AD104C26D96CE3003E4A08 /* BaseItemDtoExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BaseItemDtoExtensions.swift; sourceTree = "<group>"; };
|
||||||
E1AD105526D981CE003E4A08 /* PortraitHStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortraitHStackView.swift; sourceTree = "<group>"; };
|
E1AD105526D981CE003E4A08 /* PortraitHStackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortraitHStackView.swift; sourceTree = "<group>"; };
|
||||||
|
@ -962,7 +962,7 @@
|
||||||
E1AD105B26D9ABDD003E4A08 /* PillHStackView.swift */,
|
E1AD105B26D9ABDD003E4A08 /* PillHStackView.swift */,
|
||||||
E1AD105526D981CE003E4A08 /* PortraitHStackView.swift */,
|
E1AD105526D981CE003E4A08 /* PortraitHStackView.swift */,
|
||||||
53F866432687A45F00DCD1D7 /* PortraitItemView.swift */,
|
53F866432687A45F00DCD1D7 /* PortraitItemView.swift */,
|
||||||
E188460326DEF04800B0C5B7 /* CardVStackView.swift */,
|
E188460326DEF04800B0C5B7 /* EpisodeCardVStackView.swift */,
|
||||||
);
|
);
|
||||||
path = Components;
|
path = Components;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -1533,7 +1533,7 @@
|
||||||
53ABFDE4267974EF00886593 /* LibraryListViewModel.swift in Sources */,
|
53ABFDE4267974EF00886593 /* LibraryListViewModel.swift in Sources */,
|
||||||
5364F456266CA0DC0026ECBA /* BaseItemPersonExtensions.swift in Sources */,
|
5364F456266CA0DC0026ECBA /* BaseItemPersonExtensions.swift in Sources */,
|
||||||
E1AD105D26D9ABDD003E4A08 /* PillHStackView.swift in Sources */,
|
E1AD105D26D9ABDD003E4A08 /* PillHStackView.swift in Sources */,
|
||||||
E188460526DEF04800B0C5B7 /* CardVStackView.swift in Sources */,
|
E188460526DEF04800B0C5B7 /* EpisodeCardVStackView.swift in Sources */,
|
||||||
5364F456266CA0DC0026ECBA /* BaseItemPersonExtensions.swift in Sources */,
|
5364F456266CA0DC0026ECBA /* BaseItemPersonExtensions.swift in Sources */,
|
||||||
6220D0BE26D60D6600B8E046 /* ItemViewModel.swift in Sources */,
|
6220D0BE26D60D6600B8E046 /* ItemViewModel.swift in Sources */,
|
||||||
531690FA267AD6EC005D8AB9 /* PlainNavigationLinkButton.swift in Sources */,
|
531690FA267AD6EC005D8AB9 /* PlainNavigationLinkButton.swift in Sources */,
|
||||||
|
@ -1575,7 +1575,7 @@
|
||||||
E1FCD08826C35A0D007C8DCF /* NetworkError.swift in Sources */,
|
E1FCD08826C35A0D007C8DCF /* NetworkError.swift in Sources */,
|
||||||
E18845F826DEA9C900B0C5B7 /* ItemViewBody.swift in Sources */,
|
E18845F826DEA9C900B0C5B7 /* ItemViewBody.swift in Sources */,
|
||||||
E173DA5426D050F500CC4EB7 /* ServerDetailViewModel.swift in Sources */,
|
E173DA5426D050F500CC4EB7 /* ServerDetailViewModel.swift in Sources */,
|
||||||
E188460426DEF04800B0C5B7 /* CardVStackView.swift in Sources */,
|
E188460426DEF04800B0C5B7 /* EpisodeCardVStackView.swift in Sources */,
|
||||||
53F8377D265FF67C00F456B3 /* VideoPlayerSettingsView.swift in Sources */,
|
53F8377D265FF67C00F456B3 /* VideoPlayerSettingsView.swift in Sources */,
|
||||||
53192D5D265AA78A008A4215 /* DeviceProfileBuilder.swift in Sources */,
|
53192D5D265AA78A008A4215 /* DeviceProfileBuilder.swift in Sources */,
|
||||||
62133890265F83A900A81A2A /* LibraryListView.swift in Sources */,
|
62133890265F83A900A81A2A /* LibraryListView.swift in Sources */,
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import JellyfinAPI
|
import JellyfinAPI
|
||||||
|
|
||||||
struct CardVStackView: View {
|
struct EpisodeCardVStackView: View {
|
||||||
|
|
||||||
let items: [BaseItemDto]
|
let items: [BaseItemDto]
|
||||||
|
let selectedAction: (BaseItemDto) -> Void
|
||||||
|
|
||||||
private func buildCardOverlayView(item: BaseItemDto) -> some View {
|
private func buildCardOverlayView(item: BaseItemDto) -> some View {
|
||||||
HStack {
|
HStack {
|
||||||
|
@ -45,8 +46,9 @@ struct CardVStackView: View {
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
ForEach(items, id: \.id) { item in
|
ForEach(items, id: \.id) { item in
|
||||||
NavigationLink(destination: ItemNavigationView(item: item)) {
|
Button {
|
||||||
|
selectedAction(item)
|
||||||
|
} label: {
|
||||||
HStack {
|
HStack {
|
||||||
|
|
||||||
// MARK: Image
|
// MARK: Image
|
|
@ -13,11 +13,12 @@ protocol PillStackable {
|
||||||
var title: String { get }
|
var title: String { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PillHStackView<NavigationView: View, ItemType: PillStackable>: View {
|
struct PillHStackView<ItemType: PillStackable>: View {
|
||||||
|
|
||||||
let title: String
|
let title: String
|
||||||
let items: [ItemType]
|
let items: [ItemType]
|
||||||
let navigationView: (ItemType) -> NavigationView
|
// let navigationView: (ItemType) -> NavigationView
|
||||||
|
let selectedAction: (ItemType) -> Void
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
|
@ -30,14 +31,14 @@ struct PillHStackView<NavigationView: View, ItemType: PillStackable>: View {
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
HStack {
|
HStack {
|
||||||
ForEach(items, id: \.title) { item in
|
ForEach(items, id: \.title) { item in
|
||||||
NavigationLink(destination: LazyView {
|
Button {
|
||||||
navigationView(item)
|
selectedAction(item)
|
||||||
}) {
|
} label: {
|
||||||
ZStack {
|
ZStack {
|
||||||
Color(UIColor.systemFill)
|
Color(UIColor.systemFill)
|
||||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
|
|
||||||
Text(item.title)
|
Text(item.title)
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
|
|
|
@ -17,20 +17,20 @@ public protocol PortraitImageStackable {
|
||||||
var failureInitials: String { get }
|
var failureInitials: String { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PortraitImageHStackView<TopBarView: View, NavigationView: View, ItemType: PortraitImageStackable>: View {
|
struct PortraitImageHStackView<TopBarView: View, ItemType: PortraitImageStackable>: View {
|
||||||
|
|
||||||
let items: [ItemType]
|
let items: [ItemType]
|
||||||
let maxWidth: Int
|
let maxWidth: Int
|
||||||
let horizontalAlignment: HorizontalAlignment
|
let horizontalAlignment: HorizontalAlignment
|
||||||
let topBarView: () -> TopBarView
|
let topBarView: () -> TopBarView
|
||||||
let navigationView: (ItemType) -> NavigationView
|
let selectedAction: (ItemType) -> Void
|
||||||
|
|
||||||
init(items: [ItemType], maxWidth: Int, horizontalAlignment: HorizontalAlignment = .leading, topBarView: @escaping () -> TopBarView, navigationView: @escaping (ItemType) -> NavigationView) {
|
init(items: [ItemType], maxWidth: Int, horizontalAlignment: HorizontalAlignment = .leading, topBarView: @escaping () -> TopBarView, selectedAction: @escaping (ItemType) -> Void) {
|
||||||
self.items = items
|
self.items = items
|
||||||
self.maxWidth = maxWidth
|
self.maxWidth = maxWidth
|
||||||
self.horizontalAlignment = horizontalAlignment
|
self.horizontalAlignment = horizontalAlignment
|
||||||
self.topBarView = topBarView
|
self.topBarView = topBarView
|
||||||
self.navigationView = navigationView
|
self.selectedAction = selectedAction
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -45,38 +45,36 @@ struct PortraitImageHStackView<TopBarView: View, NavigationView: View, ItemType:
|
||||||
Spacer().frame(width: 16)
|
Spacer().frame(width: 16)
|
||||||
|
|
||||||
ForEach(items, id: \.title) { item in
|
ForEach(items, id: \.title) { item in
|
||||||
NavigationLink(
|
Button {
|
||||||
destination: LazyView {
|
selectedAction(item)
|
||||||
navigationView(item)
|
} label: {
|
||||||
},
|
VStack {
|
||||||
label: {
|
ImageView(src: item.imageURLContsructor(maxWidth: maxWidth),
|
||||||
VStack {
|
bh: item.blurHash,
|
||||||
ImageView(src: item.imageURLContsructor(maxWidth: maxWidth),
|
failureInitials: item.failureInitials)
|
||||||
bh: item.blurHash,
|
.frame(width: 100, height: CGFloat(maxWidth))
|
||||||
failureInitials: item.failureInitials)
|
.cornerRadius(10)
|
||||||
.frame(width: 100, height: CGFloat(maxWidth))
|
.shadow(radius: 4, y: 2)
|
||||||
.cornerRadius(10)
|
|
||||||
.shadow(radius: 4, y: 2)
|
Text(item.title)
|
||||||
|
.font(.footnote)
|
||||||
Text(item.title)
|
.fontWeight(.regular)
|
||||||
.font(.footnote)
|
.frame(width: 100)
|
||||||
.fontWeight(.regular)
|
.foregroundColor(.primary)
|
||||||
|
.multilineTextAlignment(.center)
|
||||||
|
.lineLimit(2)
|
||||||
|
|
||||||
|
if let description = item.description {
|
||||||
|
Text(description)
|
||||||
|
.font(.caption)
|
||||||
|
.fontWeight(.medium)
|
||||||
.frame(width: 100)
|
.frame(width: 100)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.secondary)
|
||||||
.multilineTextAlignment(.center)
|
.multilineTextAlignment(.center)
|
||||||
.lineLimit(2)
|
.lineLimit(2)
|
||||||
|
|
||||||
if let description = item.description {
|
|
||||||
Text(description)
|
|
||||||
.font(.caption)
|
|
||||||
.fontWeight(.medium)
|
|
||||||
.frame(width: 100)
|
|
||||||
.foregroundColor(.secondary)
|
|
||||||
.multilineTextAlignment(.center)
|
|
||||||
.lineLimit(2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Spacer().frame(width: UIDevice.current.userInterfaceIdiom == .pad ? 16 : 55)
|
Spacer().frame(width: UIDevice.current.userInterfaceIdiom == .pad ? 16 : 55)
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,22 +33,26 @@ struct ItemViewBody: View {
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.padding(.top, 3)
|
.padding(.top, 3)
|
||||||
.padding(.leading, 16)
|
.padding(.leading, 16)
|
||||||
}, navigationView: { season in
|
}, selectedAction: { season in
|
||||||
ItemNavigationView(item: season)
|
// Router work here to present a:
|
||||||
|
// ItemNavigationView(item: Season)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Genres
|
// MARK: Genres
|
||||||
PillHStackView(title: "Genres",
|
PillHStackView(title: "Genres",
|
||||||
items: viewModel.item.genreItems ?? []) { genre in
|
items: viewModel.item.genreItems ?? [],
|
||||||
LibraryView(viewModel: .init(genre: genre), title: genre.title)
|
selectedAction: { genre in
|
||||||
}
|
// Router work here to present a:
|
||||||
|
// LibraryView(viewModel: .init(genre: genre), title: genre.title)
|
||||||
|
})
|
||||||
|
|
||||||
// MARK: Studios
|
// MARK: Studios
|
||||||
if let studios = viewModel.item.studios {
|
if let studios = viewModel.item.studios {
|
||||||
PillHStackView(title: "Studios",
|
PillHStackView(title: "Studios",
|
||||||
items: studios) { studio in
|
items: studios) { studio in
|
||||||
LibraryView(viewModel: .init(studio: studio), title: studio.name ?? "")
|
// Router work here to present a:
|
||||||
|
// LibraryView(viewModel: .init(studio: studio), title: studio.name ?? "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +67,9 @@ struct ItemViewBody: View {
|
||||||
.padding(.top, 3)
|
.padding(.top, 3)
|
||||||
.padding(.leading, 16)
|
.padding(.leading, 16)
|
||||||
},
|
},
|
||||||
navigationView: { person in
|
selectedAction: { person in
|
||||||
LibraryView(viewModel: .init(person: person), title: person.title)
|
// Router work here to present a:
|
||||||
|
// LibraryView(viewModel: .init(person: person), title: person.title)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,8 +84,9 @@ struct ItemViewBody: View {
|
||||||
.padding(.top, 3)
|
.padding(.top, 3)
|
||||||
.padding(.leading, 16)
|
.padding(.leading, 16)
|
||||||
},
|
},
|
||||||
navigationView: { item in
|
selectedAction: { item in
|
||||||
ItemNavigationView(item: item)
|
// Router work here to present a:
|
||||||
|
// ItemNavigationView(item: item)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,10 @@ struct ItemLandscapeMainView: View {
|
||||||
// MARK: ItemViewBody
|
// MARK: ItemViewBody
|
||||||
|
|
||||||
if let episodeViewModel = viewModel as? SeasonItemViewModel {
|
if let episodeViewModel = viewModel as? SeasonItemViewModel {
|
||||||
CardVStackView(items: episodeViewModel.episodes)
|
EpisodeCardVStackView(items: episodeViewModel.episodes) { episode in
|
||||||
|
// Router work here to present a:
|
||||||
|
// ItemNavigationView(item: episode)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ItemViewBody()
|
ItemViewBody()
|
||||||
.environmentObject(viewModel)
|
.environmentObject(viewModel)
|
||||||
|
|
|
@ -49,8 +49,11 @@ struct ItemPortraitMainView: View {
|
||||||
|
|
||||||
if let episodeViewModel = viewModel as? SeasonItemViewModel {
|
if let episodeViewModel = viewModel as? SeasonItemViewModel {
|
||||||
Spacer()
|
Spacer()
|
||||||
CardVStackView(items: episodeViewModel.episodes)
|
EpisodeCardVStackView(items: episodeViewModel.episodes) { episode in
|
||||||
.padding(.top, 5)
|
// Router work to present a:
|
||||||
|
// ItemNavigationView(item: episode)
|
||||||
|
}
|
||||||
|
.padding(.top, 5)
|
||||||
} else {
|
} else {
|
||||||
ItemViewBody()
|
ItemViewBody()
|
||||||
.environmentObject(viewModel)
|
.environmentObject(viewModel)
|
||||||
|
|
Loading…
Reference in New Issue