Support folder-type libraries on tvOS

And fixed a bug in LibraryListView where proper parent ID was not passed
to LibraryViewModel.
This commit is contained in:
Min-Yih Hsu 2022-01-26 22:59:20 +08:00
parent 3f52223be5
commit 87331444be
3 changed files with 12 additions and 13 deletions

View File

@ -62,7 +62,7 @@ struct ItemView: View {
} else { } else {
SeriesItemView(viewModel: SeriesItemViewModel(item: item)) SeriesItemView(viewModel: SeriesItemViewModel(item: item))
} }
case .boxset: case .boxset, .folder:
CinematicCollectionItemView(viewModel: CollectionItemViewModel(item: item)) CinematicCollectionItemView(viewModel: CollectionItemViewModel(item: item))
default: default:
Text(L10n.notImplementedYetWithType(item.type ?? "")) Text(L10n.notImplementedYetWithType(item.type ?? ""))

View File

@ -81,7 +81,8 @@ struct LibraryListView: View {
} }
} else { } else {
Button { Button {
self.libraryListRouter.route(to: \.library, (viewModel: LibraryViewModel(), title: library.name ?? "")) self.libraryListRouter.route(to: \.library,
(viewModel: LibraryViewModel(parentID: library.id), title: library.name ?? ""))
} }
label: { label: {
ZStack { ZStack {

View File

@ -56,17 +56,15 @@ struct LibraryView: View {
} cell: { _, cell in } cell: { _, cell in
GeometryReader { _ in GeometryReader { _ in
if let item = cell.item { if let item = cell.item {
if item.type != "Folder" { Button {
Button { libraryRouter.route(to: \.modalItem, item)
libraryRouter.route(to: \.modalItem, item) } label: {
} label: { PortraitItemElement(item: item)
PortraitItemElement(item: item) }
} .buttonStyle(PlainNavigationLinkButtonStyle())
.buttonStyle(PlainNavigationLinkButtonStyle()) .onAppear {
.onAppear { if item == viewModel.items.last && viewModel.hasNextPage {
if item == viewModel.items.last && viewModel.hasNextPage { viewModel.requestNextPageAsync()
viewModel.requestNextPageAsync()
}
} }
} }
} else if cell.loadingCell { } else if cell.loadingCell {