[iOS & tvOS] FilterViewModel - Cleanup #1412
Open
+283
−87
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Resolves: #1246
This PR updates the
FilterViewModel
to beStateful
. Additionally, all of the filter logic is moved from theFilterView
to theViewModel
. Finally, while I was working on theFilterView
, I found that #1246 was still present. I've updated theSelectorView
and tested this from both theFontPickerView
andFilterView
and this is now working as expected.I feel very good about the
FilterViewModel
change toStateful
. As I understand it, the data functionality should be tied to theViewModel
instead of the view. Please let me know if that is not the case or if there is any reason this view was intentional left as non-Stateful
.The
SelectorView
is functional in both locations it's called from but not pretty. To make this functional for both theString
andAnyItemFilter
I had to have the selection as both aState
and aBinding
. I'm open to feedback if there is a cleaner way to do this but I was trying to accomplish this without having to change the callers too dramatically.If we decide the
SelectorView
changes are a wash, I'm perfectly fine with this PR focusing on theFilterViewModel
changes instead! Let me know!Final item, the
SearchViewModel
didn't have a filter for Letters. I've added that as a drop in copy/paste from theLibraryItemViewModel
Before:
The reset appropriately resets the filter but the UI does not update. This is because the selection in a binding box is not updating correctly. My solution was to have a
State
item for editing that updated theBinding
item on change.Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-01-27.at.18.51.07.mp4
After:
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-01-27.at.18.44.13.mp4