-
Notifications
You must be signed in to change notification settings - Fork 1.2k
MBL-2220: Implement parent filter modal for search phase 2 #2399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+136
−208
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -11,18 +11,12 @@ protocol FilterCategory: Identifiable, Equatable { | |
protocol FilterCategoryViewModelInputs { | ||
associatedtype T: FilterCategory | ||
func selectCategory(_ category: T, subcategory: T?) | ||
func seeResults() | ||
func close() | ||
func resetSelection() | ||
} | ||
|
||
protocol FilterCategoryViewModelOutputs { | ||
associatedtype T: FilterCategory | ||
var selectedCategory: AnyPublisher<CategoryAndSubcategory<T>?, Never> { get } | ||
var seeResultsTapped: AnyPublisher<Void, Never> { get } | ||
var closeTapped: AnyPublisher<Void, Never> { get } | ||
var categories: [T] { get } | ||
var canReset: Bool { get } | ||
var isLoading: Bool { get } | ||
func isCategorySelected(_ category: T) -> Bool | ||
func isSubcategorySelected(_ category: T?) -> Bool | ||
|
@@ -63,7 +57,21 @@ class FilterCategoryViewModel<T: FilterCategory>: FilterCategoryViewModelType { | |
.assign(to: &self.$currentSubcategory) | ||
|
||
if let category = selectedCategory { | ||
self.selectInitialCategory(selectedCategory: category) | ||
} | ||
} | ||
|
||
private func selectInitialCategory(selectedCategory: T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you initialized this page with a subcategory, it wasn't reflected in the UI. This fixes it. |
||
if let category = self.categories.first(where: { $0 == selectedCategory }) { | ||
self.selectCategory(category, subcategory: nil) | ||
return | ||
} | ||
|
||
for category in self.categories { | ||
if let subcategory = category.availableSubcategories?.first(where: { $0 == selectedCategory }) { | ||
self.selectCategory(category, subcategory: subcategory) | ||
return | ||
} | ||
} | ||
} | ||
|
||
|
@@ -77,31 +85,13 @@ class FilterCategoryViewModel<T: FilterCategory>: FilterCategoryViewModelType { | |
self.selectedCategorySubject.send(nil) | ||
} | ||
|
||
func seeResults() { | ||
self.seeResultsTappedSubject.send() | ||
} | ||
|
||
func close() { | ||
self.closeTappedSubject.send() | ||
} | ||
|
||
// MARK: - Outputs | ||
|
||
var selectedCategory: AnyPublisher<CategoryAndSubcategory<T>?, Never> { | ||
self.selectedCategorySubject.eraseToAnyPublisher() | ||
} | ||
|
||
var seeResultsTapped: AnyPublisher<Void, Never> { | ||
self.seeResultsTappedSubject.eraseToAnyPublisher() | ||
} | ||
|
||
var closeTapped: AnyPublisher<Void, Never> { | ||
self.closeTappedSubject.eraseToAnyPublisher() | ||
} | ||
|
||
private let selectedCategorySubject = PassthroughSubject<CategoryAndSubcategory<T>?, Never>() | ||
private let seeResultsTappedSubject = PassthroughSubject<Void, Never>() | ||
private let closeTappedSubject = PassthroughSubject<Void, Never>() | ||
|
||
func isCategorySelected(_ category: T) -> Bool { | ||
self.currentCategory?.id == category.id | ||
|
This file contains hidden or 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
Binary file modified
BIN
-5.85 KB
(93%)
..._Snapshots__/FilterCategoryViewTest/testFilterCategoryView_CategoriesList.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-5.5 KB
(82%)
.../__Snapshots__/FilterCategoryViewTest/testFilterCategoryView_LoadingState.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buttons are moving out of
FilterCategoryView
and intoFilterRootView
, which is why I have all these deletes.