mirror of
https://github.com/jellyfin/Swiftfin.git
synced 2024-11-27 08:10:23 +00:00
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)
|
||||
var liveTVAlphaEnabled
|
||||
|
||||
let supportedCollectionTypes = ["movies", "tvshows", "boxsets", "livetv", "other"]
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
LazyVStack {
|
||||
if !viewModel.isLoading {
|
||||
|
||||
if let collectionLibraryItem = viewModel.libraries.first(where: { $0.collectionType == "boxsets" }) {
|
||||
Button {
|
||||
self.libraryListRouter.route(to: \.library,
|
||||
(viewModel: LibraryViewModel(parentID: collectionLibraryItem.id),
|
||||
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
|
||||
ForEach(viewModel.libraries.filter { [self] library in
|
||||
let collectionType = library.collectionType ?? "other"
|
||||
return self.supportedCollectionTypes.contains(collectionType)
|
||||
}, id: \.id) { library in
|
||||
if library.collectionType == "livetv" {
|
||||
if liveTVAlphaEnabled {
|
||||
Button {
|
||||
|
@ -16,6 +16,8 @@ struct LibraryListView: View {
|
||||
@StateObject
|
||||
var viewModel = LibraryListViewModel()
|
||||
|
||||
let supportedCollectionTypes = ["movies", "tvshows", "boxsets", "other"]
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
LazyVStack {
|
||||
@ -42,37 +44,10 @@ struct LibraryListView: View {
|
||||
.padding(.bottom, 5)
|
||||
|
||||
if !viewModel.isLoading {
|
||||
|
||||
if let collectionsLibraryItem = viewModel.libraries.first(where: { $0.collectionType == "boxsets" }) {
|
||||
Button {
|
||||
libraryListRouter.route(to: \.library,
|
||||
(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
|
||||
ForEach(viewModel.libraries.filter { [self] library in
|
||||
let collectionType = library.collectionType ?? "other"
|
||||
return self.supportedCollectionTypes.contains(collectionType)
|
||||
}, id: \.id) { library in
|
||||
Button {
|
||||
libraryListRouter.route(to: \.library,
|
||||
(viewModel: LibraryViewModel(parentID: library.id),
|
||||
|
Loading…
Reference in New Issue
Block a user