Skip to content
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

configure default map filter mode #420

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

thorbjxrn
Copy link

@thorbjxrn thorbjxrn commented Nov 19, 2024

Why?

we would like to have polygon search as the default, so adding the possibility to configure the default map filter mode.

also see https://github.schibsted.io/finn/ios-app/pull/6200 for context

What?

added an enum to the initialiser and removed a function in setup that seemed redundant.

Show me

Before After
radius search polygon search

Copy link
Contributor

@ninarg ninarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code has to be moved to the app repo now, since Charcoal has been moved there 😄

case .radius:
selectedViewController = mapRadiusFilterViewController
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this ended up being more complicated than it needs to be because of the computed property and needing to call the same function also later in the setup function. Right now we set the default view controller 3 times.
What if we change things a bit.
We can simply do one single thing in init: set the selectedViewController to whatever is defaultMapMode.
We can remove defaultMapMode variable in the class, there's no need to change it later.

Then in setup, we can simply change the default view controller to whatever filter is selected, but if no filter is selected, do nothing. If we do nothing there, the default view controller will still be selected. So we don't need an else there. (then we can also delete the setMapViewToDefaultMode function)

Does this make sense to you? 😄
So we only need to have this logic in one place where it is needed, and that is in init.


public init(title: String, latitudeFilter: Filter, longitudeFilter: Filter, radiusFilter: Filter,
locationNameFilter: Filter, bboxFilter: Filter?, polygonFilter: Filter?, selectionStore: FilterSelectionStore) {
locationNameFilter: Filter, bboxFilter: Filter?, polygonFilter: Filter?, defaultMode: MapFilterMode = .radius, selectionStore: FilterSelectionStore) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change the param name to defaultMapMode so it's easy to see what it means on caller side?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants