Simplify library display logics in LibraryListView
And restore the filter that only shows supported library types.
This commit is contained in:
parent
87331444be
commit
f84d796536
|
@ -21,39 +21,17 @@ struct LibraryListView: View {
|
||||||
@Default(.Experimental.liveTVAlphaEnabled)
|
@Default(.Experimental.liveTVAlphaEnabled)
|
||||||
var liveTVAlphaEnabled
|
var liveTVAlphaEnabled
|
||||||
|
|
||||||
|
let supportedCollectionTypes = ["movies", "tvshows", "boxsets", "livetv", "other"]
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
LazyVStack {
|
LazyVStack {
|
||||||
if !viewModel.isLoading {
|
if !viewModel.isLoading {
|
||||||
|
|
||||||
if let collectionLibraryItem = viewModel.libraries.first(where: { $0.collectionType == "boxsets" }) {
|
ForEach(viewModel.libraries.filter { [self] library in
|
||||||
Button {
|
let collectionType = library.collectionType ?? "other"
|
||||||
self.libraryListRouter.route(to: \.library,
|
return self.supportedCollectionTypes.contains(collectionType)
|
||||||
(viewModel: LibraryViewModel(parentID: collectionLibraryItem.id),
|
}, id: \.id) { library in
|
||||||
title: collectionLibraryItem.name ?? ""))
|
|
||||||
}
|
|
||||||
label: {
|
|
||||||
ZStack {
|
|
||||||
HStack {
|
|
||||||
Spacer()
|
|
||||||
VStack {
|
|
||||||
Text(collectionLibraryItem.name ?? "")
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.font(.title2)
|
|
||||||
.fontWeight(.semibold)
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
}.padding(32)
|
|
||||||
}
|
|
||||||
.frame(minWidth: 100, maxWidth: .infinity)
|
|
||||||
.frame(height: 100)
|
|
||||||
}
|
|
||||||
.cornerRadius(10)
|
|
||||||
.shadow(radius: 5)
|
|
||||||
.padding(.bottom, 5)
|
|
||||||
}
|
|
||||||
|
|
||||||
ForEach(viewModel.libraries.filter { $0.collectionType != "boxsets" }, id: \.id) { library in
|
|
||||||
if library.collectionType == "livetv" {
|
if library.collectionType == "livetv" {
|
||||||
if liveTVAlphaEnabled {
|
if liveTVAlphaEnabled {
|
||||||
Button {
|
Button {
|
||||||
|
|
|
@ -16,6 +16,8 @@ struct LibraryListView: View {
|
||||||
@StateObject
|
@StateObject
|
||||||
var viewModel = LibraryListViewModel()
|
var viewModel = LibraryListViewModel()
|
||||||
|
|
||||||
|
let supportedCollectionTypes = ["movies", "tvshows", "boxsets", "other"]
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
LazyVStack {
|
LazyVStack {
|
||||||
|
@ -42,37 +44,10 @@ struct LibraryListView: View {
|
||||||
.padding(.bottom, 5)
|
.padding(.bottom, 5)
|
||||||
|
|
||||||
if !viewModel.isLoading {
|
if !viewModel.isLoading {
|
||||||
|
ForEach(viewModel.libraries.filter { [self] library in
|
||||||
if let collectionsLibraryItem = viewModel.libraries.first(where: { $0.collectionType == "boxsets" }) {
|
let collectionType = library.collectionType ?? "other"
|
||||||
Button {
|
return self.supportedCollectionTypes.contains(collectionType)
|
||||||
libraryListRouter.route(to: \.library,
|
}, id: \.id) { library in
|
||||||
(viewModel: LibraryViewModel(parentID: collectionsLibraryItem.id),
|
|
||||||
title: collectionsLibraryItem.name ?? ""))
|
|
||||||
} label: {
|
|
||||||
ZStack {
|
|
||||||
ImageView(src: collectionsLibraryItem.getPrimaryImage(maxWidth: 500),
|
|
||||||
bh: collectionsLibraryItem.getPrimaryImageBlurHash())
|
|
||||||
.opacity(0.4)
|
|
||||||
HStack {
|
|
||||||
Spacer()
|
|
||||||
VStack {
|
|
||||||
Text(collectionsLibraryItem.name ?? "")
|
|
||||||
.foregroundColor(.white)
|
|
||||||
.font(.title2)
|
|
||||||
.fontWeight(.semibold)
|
|
||||||
}
|
|
||||||
Spacer()
|
|
||||||
}.padding(32)
|
|
||||||
}.background(Color.black)
|
|
||||||
.frame(minWidth: 100, maxWidth: .infinity)
|
|
||||||
.frame(height: 100)
|
|
||||||
}
|
|
||||||
.cornerRadius(10)
|
|
||||||
.shadow(radius: 5)
|
|
||||||
.padding(.bottom, 5)
|
|
||||||
}
|
|
||||||
|
|
||||||
ForEach(viewModel.libraries, id: \.id) { library in
|
|
||||||
Button {
|
Button {
|
||||||
libraryListRouter.route(to: \.library,
|
libraryListRouter.route(to: \.library,
|
||||||
(viewModel: LibraryViewModel(parentID: library.id),
|
(viewModel: LibraryViewModel(parentID: library.id),
|
||||||
|
|
Loading…
Reference in New Issue