-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP - Filters work. Everything works. The UI is just... clumsy.
- Loading branch information
Showing
5 changed files
with
99 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// Swiftfin is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, you can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2025 Jellyfin & Jellyfin Contributors | ||
// | ||
|
||
import JellyfinAPI | ||
import SwiftUI | ||
|
||
// TODO: multiple filter types? | ||
// - for sort order and sort by combined | ||
struct FilterView: View { | ||
|
||
@Binding | ||
private var selection: [AnyItemFilter] | ||
|
||
@EnvironmentObject | ||
private var router: FilterCoordinator.Router | ||
|
||
@ObservedObject | ||
private var viewModel: FilterViewModel | ||
|
||
private let type: ItemFilterType | ||
|
||
var body: some View { | ||
ZStack { | ||
BlurView() | ||
.ignoresSafeArea() | ||
|
||
contentView | ||
} | ||
.navigationTitle(type.displayTitle) | ||
.topBarTrailing { | ||
Button(L10n.reset) { | ||
viewModel.send(.reset(type)) | ||
} | ||
.environment( | ||
\.isEnabled, | ||
viewModel.isFilterSelected(type: type) | ||
) | ||
} | ||
} | ||
|
||
private var contentView: some View { | ||
SplitFormWindowView() | ||
.descriptionView { | ||
Image(systemName: type.systemImage) | ||
.resizable() | ||
.aspectRatio(contentMode: .fit) | ||
.frame(maxWidth: 400) | ||
} | ||
.contentView { | ||
SelectorView( | ||
selection: $selection, | ||
sources: viewModel.allFilters[keyPath: type.collectionAnyKeyPath], | ||
type: type.selectorType | ||
) | ||
} | ||
} | ||
} | ||
|
||
extension FilterView { | ||
|
||
init( | ||
viewModel: FilterViewModel, | ||
type: ItemFilterType | ||
) { | ||
|
||
let selectionBinding: Binding<[AnyItemFilter]> = Binding { | ||
viewModel.currentFilters[keyPath: type.collectionAnyKeyPath] | ||
} set: { newValue in | ||
viewModel.send(.update(type, newValue)) | ||
} | ||
|
||
self.init( | ||
selection: selectionBinding, | ||
viewModel: viewModel, | ||
type: type | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters