fix LibraryFilterView's layout
This commit is contained in:
parent
a46ed45925
commit
34dbc2ac00
|
@ -6,8 +6,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import JellyfinAPI
|
import JellyfinAPI
|
||||||
import SwiftUI
|
|
||||||
import Stinsen
|
import Stinsen
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
struct LibraryFilterView: View {
|
struct LibraryFilterView: View {
|
||||||
@EnvironmentObject var filterRouter: FilterCoordinator.Router
|
@EnvironmentObject var filterRouter: FilterCoordinator.Router
|
||||||
|
@ -20,75 +20,74 @@ struct LibraryFilterView: View {
|
||||||
init(filters: Binding<LibraryFilters>, enabledFilterType: [FilterType], parentId: String) {
|
init(filters: Binding<LibraryFilters>, enabledFilterType: [FilterType], parentId: String) {
|
||||||
_filters = filters
|
_filters = filters
|
||||||
self.parentId = parentId
|
self.parentId = parentId
|
||||||
_viewModel = StateObject(wrappedValue: .init(filters: filters.wrappedValue, enabledFilterType: enabledFilterType, parentId: parentId))
|
_viewModel =
|
||||||
|
StateObject(wrappedValue: .init(filters: filters.wrappedValue, enabledFilterType: enabledFilterType, parentId: parentId))
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
VStack {
|
||||||
VStack {
|
if viewModel.isLoading {
|
||||||
if viewModel.isLoading {
|
ProgressView()
|
||||||
ProgressView()
|
} else {
|
||||||
} else {
|
Form {
|
||||||
Form {
|
if viewModel.enabledFilterType.contains(.genre) {
|
||||||
if viewModel.enabledFilterType.contains(.genre) {
|
MultiSelector(label: NSLocalizedString("Genres", comment: ""),
|
||||||
MultiSelector(label: NSLocalizedString("Genres", comment: ""),
|
options: viewModel.possibleGenres,
|
||||||
options: viewModel.possibleGenres,
|
optionToString: { $0.name ?? "" },
|
||||||
optionToString: { $0.name ?? "" },
|
selected: $viewModel.modifiedFilters.withGenres)
|
||||||
selected: $viewModel.modifiedFilters.withGenres)
|
}
|
||||||
}
|
if viewModel.enabledFilterType.contains(.filter) {
|
||||||
if viewModel.enabledFilterType.contains(.filter) {
|
MultiSelector(label: NSLocalizedString("Filters", comment: ""),
|
||||||
MultiSelector(label: NSLocalizedString("Filters", comment: ""),
|
options: viewModel.possibleItemFilters,
|
||||||
options: viewModel.possibleItemFilters,
|
optionToString: { $0.localized },
|
||||||
optionToString: { $0.localized },
|
selected: $viewModel.modifiedFilters.filters)
|
||||||
selected: $viewModel.modifiedFilters.filters)
|
}
|
||||||
}
|
if viewModel.enabledFilterType.contains(.tag) {
|
||||||
if viewModel.enabledFilterType.contains(.tag) {
|
MultiSelector(label: NSLocalizedString("Tags", comment: ""),
|
||||||
MultiSelector(label: NSLocalizedString("Tags", comment: ""),
|
options: viewModel.possibleTags,
|
||||||
options: viewModel.possibleTags,
|
optionToString: { $0 },
|
||||||
optionToString: { $0 },
|
selected: $viewModel.modifiedFilters.tags)
|
||||||
selected: $viewModel.modifiedFilters.tags)
|
}
|
||||||
}
|
if viewModel.enabledFilterType.contains(.sortBy) {
|
||||||
if viewModel.enabledFilterType.contains(.sortBy) {
|
Picker(selection: $viewModel.selectedSortBy, label: Text("Sort by")) {
|
||||||
Picker(selection: $viewModel.selectedSortBy, label: Text("Sort by")) {
|
ForEach(viewModel.possibleSortBys, id: \.self) { so in
|
||||||
ForEach(viewModel.possibleSortBys, id: \.self) { so in
|
Text(so.localized).tag(so)
|
||||||
Text(so.localized).tag(so)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if viewModel.enabledFilterType.contains(.sortOrder) {
|
|
||||||
Picker(selection: $viewModel.selectedSortOrder, label: Text("Display order")) {
|
|
||||||
ForEach(viewModel.possibleSortOrders, id: \.self) { so in
|
|
||||||
Text(so.rawValue).tag(so)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Button {
|
if viewModel.enabledFilterType.contains(.sortOrder) {
|
||||||
viewModel.resetFilters()
|
Picker(selection: $viewModel.selectedSortOrder, label: Text("Display order")) {
|
||||||
self.filters = viewModel.modifiedFilters
|
ForEach(viewModel.possibleSortOrders, id: \.self) { so in
|
||||||
filterRouter.dismissCoordinator()
|
Text(so.rawValue).tag(so)
|
||||||
} label: {
|
}
|
||||||
Text("Reset")
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Button {
|
||||||
|
viewModel.resetFilters()
|
||||||
|
self.filters = viewModel.modifiedFilters
|
||||||
|
filterRouter.dismissCoordinator()
|
||||||
|
} label: {
|
||||||
|
Text("Reset")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.navigationBarTitle(NSLocalizedString("Filter Results", comment: ""), displayMode: .inline)
|
}
|
||||||
.toolbar {
|
.navigationBarTitle(NSLocalizedString("Filter Results", comment: ""), displayMode: .inline)
|
||||||
ToolbarItemGroup(placement: .navigationBarLeading) {
|
.toolbar {
|
||||||
Button {
|
ToolbarItemGroup(placement: .navigationBarLeading) {
|
||||||
filterRouter.dismissCoordinator()
|
Button {
|
||||||
} label: {
|
filterRouter.dismissCoordinator()
|
||||||
Image(systemName: "xmark")
|
} label: {
|
||||||
}
|
Image(systemName: "xmark")
|
||||||
}
|
}
|
||||||
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
}
|
||||||
Button {
|
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
||||||
viewModel.updateModifiedFilter()
|
Button {
|
||||||
self.filters = viewModel.modifiedFilters
|
viewModel.updateModifiedFilter()
|
||||||
filterRouter.dismissCoordinator()
|
self.filters = viewModel.modifiedFilters
|
||||||
} label: {
|
filterRouter.dismissCoordinator()
|
||||||
Text("Apply")
|
} label: {
|
||||||
}
|
Text("Apply")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue