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

Add distance formatter field to MapboxSearchUI.Configuration #171

Merged
merged 6 commits into from
Feb 13, 2024

Conversation

aokj4ck
Copy link
Contributor

@aokj4ck aokj4ck commented Feb 7, 2024

Description

Fixes #168

  • Add an optional MKDistanceFormatter parameter to Configuration that will be used in the suggestion results to format the distance.
  • If no value is provided then the default system behavior of auto-detecting the device locale for the formatter style will be used.
  • Update the Examples/SearchExample.xcworkspace project with sample code

Checklist

  • Update CHANGELOG

Screenshots

With nil value With a custom formatter in locale en_US
Simulator Screen Shot - iPhone 13 - 2024-02-07 at 16 46 34 Simulator Screen Shot - iPhone 13 - 2024-02-07 at 16 46 54

Listing for "With a nil value" screenshot in SimpleUISearchViewController

var configuration = Configuration()

Listing for "With a custom formatter in locale en_US" screenshot in SimpleUISearchViewController

let formatter = MKDistanceFormatter()
formatter.units = .metric
formatter.unitStyle = .full
var configuration = Configuration(
    distanceFormatter: formatter
)

…istanceFormatter-field-to-configuration

Conflicts:
	CHANGELOG.md
…istanceFormatter-field-to-configuration

Conflicts:
	CHANGELOG.md
@aokj4ck aokj4ck merged commit 70ca06e into main Feb 13, 2024
5 checks passed
@aokj4ck aokj4ck deleted the add-distanceFormatter-field-to-configuration branch February 13, 2024 18:21
aokj4ck added a commit that referenced this pull request Apr 5, 2024
### Description
Fixes #168

- Add an optional [MKDistanceFormatter](https://developer.apple.com/documentation/mapkit/mkdistanceformatter) parameter to Configuration that will be used in the suggestion results to format the distance.
- If no value is provided then the default system behavior of auto-detecting the device locale for the formatter style will be used.
- Update the Examples/SearchExample.xcworkspace project with sample code

### Checklist
- [x] Update `CHANGELOG`

### Screenshots

| With nil value | With a custom formatter in locale en_US |
| -- | -- |
| ![Simulator Screen Shot - iPhone 13 - 2024-02-07 at 16 46 34](https://github.com/mapbox/mapbox-search-ios/assets/384288/f65b3f70-7fc2-4214-b369-61b5f570193e) | ![Simulator Screen Shot - iPhone 13 - 2024-02-07 at 16 46 54](https://github.com/mapbox/mapbox-search-ios/assets/384288/a8054483-d1fa-4814-860f-6354cad660a7) |

Listing for "With a nil value" screenshot in SimpleUISearchViewController
```swift
var configuration = Configuration()
```

Listing for "With a custom formatter in locale en_US" screenshot in SimpleUISearchViewController
```swift
let formatter = MKDistanceFormatter()
formatter.units = .metric
formatter.unitStyle = .full
var configuration = Configuration(
    distanceFormatter: formatter
)
```
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.

No way of changing distance units in search UI
2 participants