-
Notifications
You must be signed in to change notification settings - Fork 20
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
[SSDK-399] Add Discover.Options(country, proximity, origin) #167
[SSDK-399] Add Discover.Options(country, proximity, origin) #167
Conversation
…, origin) params - SSDK-399 - Add Country.default: Self? to auto-detect the current device region and provide a value if found - Add proximity and origin CLLocationCoordinate2D fields to Discover.Option and forward these to SearchOption parameters
…399-add-country-proximity-origin-to-discover-options Conflicts: CHANGELOG.md
…399-add-country-proximity-origin-to-discover-options Conflicts: CHANGELOG.md
…e merged) - SSDK-399
…399-add-country-proximity-origin-to-discover-options Conflicts: CHANGELOG.md MapboxSearch.xcodeproj/project.pbxproj Tests/MapboxSearchUITests/MockWebServer/MockResponse.swift Tests/MapboxSearchUITests/MockWebServer/MockWebServer.swift
…399-add-country-proximity-origin-to-discover-options Conflicts: CHANGELOG.md MapboxSearch.xcodeproj/project.pbxproj
} else { | ||
let regionComponents = Locale.current.identifier.components(separatedBy: "_") | ||
if regionComponents.count >= 2 { | ||
let countryIdentifier = regionComponents[1] |
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.
Hey @aokj4ck is countryIdenitifier
only the last component in regionComponents
or it is just the second item all the time?
just smal nitpick from my side: is it possible to use regionComponents?.last
or regionComponents?.first
to leave all these checks on compiler shoulders? Instead to access item via index in array
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.
Great question, it is the second item all the time and there may be more items.
For example if you:
- Add an iOS 15 simulator (oldest simulator available in Xcode 14 and that uses this API)
- Change the Demo app > Edit Scheme > Run > Options > App Language and App Region
- Set a breakpoint on this line
- Build and run
- Go to Discover tab and tap "Search in this area"
You will find that there are scenarios where the locale has more components such as Language = Chinese (Hong Kong) and Region = Hong Kong will return the locale "en_HK_HK"
. There are various other examples and accessing the second items in the regionComponents is safest to cover all scenarios.
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.
LGTM
Sources/MapboxSearch/PublicAPI/Use Cases/Discover API/Models/Discover+Options.swift
Outdated
Show resolved
Hide resolved
- Add docs for origin and proximity
Sources/MapboxSearch/PublicAPI/Use Cases/Discover API/Discover.swift
Outdated
Show resolved
Hide resolved
….swift Co-authored-by: Nastassia Makaranka <[email protected]>
Description
Ticket: SSDK-399
Checklist
CHANGELOG