Skip to content

Commit

Permalink
Merge pull request #12 from mapbox/release/v1.0.0-beta.18
Browse files Browse the repository at this point in the history
Release/v1.0.0 beta.18
  • Loading branch information
Victor Privalov authored Dec 7, 2021
2 parents bb8ceb6 + cbad0b1 commit f9733e1
Show file tree
Hide file tree
Showing 19 changed files with 212 additions and 226 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ Guide: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [1.0.0-beta.18] - 2021-12-06

### Internal

- `scripts/release_binary_manifest` reworked as `scripts/release_notes`

### Breaking changes

- `Category` renamed into `SearchCategory`
- Delegate method `SearchControllerDelegate.categorySearchResultsReceived(results:)` added extra parameter `categorySearchResultsReceived(category:results:)`

## [1.0.0-beta.17] - 2021-11-29

### Internal
Expand Down
8 changes: 4 additions & 4 deletions MapboxSearch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
FEEDD36C2508E02700DC0A98 /* FavoritesTableViewSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEDD33A2508E02700DC0A98 /* FavoritesTableViewSource.swift */; };
FEEDD36D2508E02700DC0A98 /* SearchTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEDD33B2508E02700DC0A98 /* SearchTextField.swift */; };
FEEDD36E2508E02700DC0A98 /* DragIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEDD33C2508E02700DC0A98 /* DragIndicator.swift */; };
FEEDD36F2508E02700DC0A98 /* Category.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEDD33D2508E02700DC0A98 /* Category.swift */; };
FEEDD36F2508E02700DC0A98 /* SearchCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEDD33D2508E02700DC0A98 /* SearchCategory.swift */; };
FEEDD3702508E02700DC0A98 /* Images.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEDD33E2508E02700DC0A98 /* Images.swift */; };
FEEDD3722508E02700DC0A98 /* CategoriesTableViewSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEDD3402508E02700DC0A98 /* CategoriesTableViewSource.swift */; };
FEEDD3732508E02700DC0A98 /* CategoriesFavoritesSegmentControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = FEEDD3412508E02700DC0A98 /* CategoriesFavoritesSegmentControl.swift */; };
Expand Down Expand Up @@ -666,7 +666,7 @@
FEEDD33A2508E02700DC0A98 /* FavoritesTableViewSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FavoritesTableViewSource.swift; sourceTree = "<group>"; };
FEEDD33B2508E02700DC0A98 /* SearchTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchTextField.swift; sourceTree = "<group>"; };
FEEDD33C2508E02700DC0A98 /* DragIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DragIndicator.swift; sourceTree = "<group>"; };
FEEDD33D2508E02700DC0A98 /* Category.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Category.swift; sourceTree = "<group>"; };
FEEDD33D2508E02700DC0A98 /* SearchCategory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchCategory.swift; sourceTree = "<group>"; };
FEEDD33E2508E02700DC0A98 /* Images.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Images.swift; sourceTree = "<group>"; };
FEEDD33F2508E02700DC0A98 /* ActivityProgressView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ActivityProgressView.xib; sourceTree = "<group>"; };
FEEDD3402508E02700DC0A98 /* CategoriesTableViewSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CategoriesTableViewSource.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1149,7 +1149,7 @@
FEEDD34B2508E02700DC0A98 /* CategoriesProvider.swift */,
FEEDD32E2508E02700DC0A98 /* CategoriesTableViewCell.swift */,
FEEDD3402508E02700DC0A98 /* CategoriesTableViewSource.swift */,
FEEDD33D2508E02700DC0A98 /* Category.swift */,
FEEDD33D2508E02700DC0A98 /* SearchCategory.swift */,
FE49CF6A2510EF7C0059C189 /* CategoryDataProvider.swift */,
F98E086025386D7F00FDAD1F /* CategorySuggestionsController.swift */,
F96535A72538AD380066D699 /* CategorySuggestionsController.xib */,
Expand Down Expand Up @@ -2126,7 +2126,7 @@
F914EE5F2743E38E00D4F173 /* SearchSuggestionCell.swift in Sources */,
FEEDD37E2508E02700DC0A98 /* SearchErrorView.swift in Sources */,
FEEDD37A2508E02700DC0A98 /* PlaceholderView.swift in Sources */,
FEEDD36F2508E02700DC0A98 /* Category.swift in Sources */,
FEEDD36F2508E02700DC0A98 /* SearchCategory.swift in Sources */,
FEEDD3602508E02700DC0A98 /* CategoriesTableViewCell.swift in Sources */,
FEEDD3702508E02700DC0A98 /* Images.swift in Sources */,
FE49CF6E2510EFD00059C189 /* DefaultCategoryDataProvider.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion SearchUI Documentation.docc/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let searchController = MapboxSearchController(accessToken: "YOUR_TOKEN")

To control data flow, implement ``SearchControllerDelegate`` and assign ``MapboxSearchController/delegate``. That protocol has next required methods:
1. ``SearchControllerDelegate/searchResultSelected(_:)`` method to return representable `SearchResult` object that match input query.
2. ``SearchControllerDelegate/categorySearchResultsReceived(results:)`` returns a collection of `SearchResult` object matches with requested category name.
2. ``SearchControllerDelegate/categorySearchResultsReceived(category:results:)`` returns a collection of `SearchResult` object matches with requested category name.
3. ``SearchControllerDelegate/userFavoriteSelected(_:)`` returns `FavoriteRecord` representing user-provided record.

#### Presentation
Expand Down
2 changes: 1 addition & 1 deletion Sources/Demo/MapRootController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MapRootController: UIViewController {
}

extension MapRootController: SearchControllerDelegate {
func categorySearchResultsReceived(results: [SearchResult]) {
func categorySearchResultsReceived(category: SearchCategory, results: [SearchResult]) {
let annotations = results.map { searchResult -> MKPointAnnotation in
let annotation = MKPointAnnotation()
annotation.coordinate = searchResult.coordinate
Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxSearch/PublicAPI/SearchRequestOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public struct SearchRequestOptions: Codable {

let proximityCodable: CLLocationCoordinate2DCodable?

init(query: String, proximity: CLLocationCoordinate2D?) {
public init(query: String, proximity: CLLocationCoordinate2D?) {
self.query = query
self.proximityCodable = proximity.map(CLLocationCoordinate2DCodable.init)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxSearchUI/CategoriesProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
/// CategoriesProvider contains a list of all available categories.
public class CategoriesProvider {
/// List of all available categories.
public let categories: [Category]
public let categories: [SearchCategory]

/// Shared instance of ``CategoriesProvider``
public static let shared = CategoriesProvider()
Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxSearchUI/CategoriesTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CategoriesTableViewCell: UITableViewCell {
fatalError("init(coder:) has not been implemented")
}

func configure(category: Category, configuration: Configuration) {
func configure(category: SearchCategory, configuration: Configuration) {
backgroundColor = configuration.style.primaryBackgroundColor
textLabel?.textColor = configuration.style.primaryTextColor

Expand Down
4 changes: 2 additions & 2 deletions Sources/MapboxSearchUI/CategoriesTableViewSource.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import UIKit

protocol CategoriesTableViewSourceDelegate: AnyObject {
func userSelectedCategory(_ category: Category)
func userSelectedCategory(_ category: SearchCategory)
}

class CategoriesTableViewSource: NSObject, UITableViewDataSource, UITableViewDelegate {
var categories: [Category] {
var categories: [SearchCategory] {
didSet {
tableView?.reloadData()
}
Expand Down
146 changes: 0 additions & 146 deletions Sources/MapboxSearchUI/Category.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Sources/MapboxSearchUI/CategoryDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ public protocol CategoryDataProvider {
/// Provide custom list of category buttons in the row under search textfield.
/// Only first 4 categories would be used.
/// Default values would be added if necessary.
var categorySlots: [Category] { get }
var categorySlots: [SearchCategory] { get }

/// Provide custom vertical list of categories
var categoryList: [Category] { get }
var categoryList: [SearchCategory] { get }
}
6 changes: 3 additions & 3 deletions Sources/MapboxSearchUI/ConstantCategoryDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ public class ConstantCategoryDataProvider: CategoryDataProvider {
/// Only first 4 categories would be used.
///
/// Default values would be added if necessary.
public var categorySlots: [Category]
public var categorySlots: [SearchCategory]

/// Provide custom vertical list of categories
public var categoryList: [Category]
public var categoryList: [SearchCategory]

/// Make a constant categories provider
/// - Parameters:
/// - slots: Categories you would like to see in horizontal list. Passing `nil` would follow to default list.
/// Passing less-than-required number of categories would follow in appending default categories
/// - list: Custom category collection for vertical list. Passing `nil` would follow to default list.
/// There is no required minimal number of categories.
public init(slots: [Category]?, list: [Category]? = nil) {
public init(slots: [SearchCategory]?, list: [SearchCategory]? = nil) {
let defaults = DefaultCategoryDataProvider()

self.categoryList = list ?? defaults.categoryList
Expand Down
4 changes: 2 additions & 2 deletions Sources/MapboxSearchUI/DefaultCategoryDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ public class DefaultCategoryDataProvider: CategoryDataProvider {
public static let minCategoriesCount = 4

/// Horizontal categories.
public var categorySlots: [Category] {
public var categorySlots: [SearchCategory] {
[.gas, .parking, .food, .cafe]
}

/// Vertical list of categories.
public var categoryList: [Category] = CategoriesProvider.shared.categories
public var categoryList: [SearchCategory] = CategoriesProvider.shared.categories

/// Make your default categories provider.
public init() { }
Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxSearchUI/HotCategoryButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HotCategoryButton: UIControl {
categoryButton.adjustsImageSizeForAccessibilityContentSizeCategory = true
}

var category: Category = .empty {
var category: SearchCategory = .empty {
didSet {
updateUI()
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/MapboxSearchUI/MapboxSearchController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public protocol SearchControllerDelegate: AnyObject {
func searchResultSelected(_ searchResult: SearchResult)

/// Collection of results received as a response for a category search request.
func categorySearchResultsReceived(results: [SearchResult])
func categorySearchResultsReceived(category: SearchCategory, results: [SearchResult])

/// Customer selected record from the Favorites UI tab
func userFavoriteSelected(_ userFavorite: FavoriteRecord)
Expand Down Expand Up @@ -567,13 +567,13 @@ extension MapboxSearchController: SearchCategoriesRootViewDelegate {
updateSearchState(.createFavorite)
}

func userSelectedCategory(_ category: Category) {
func userSelectedCategory(_ category: SearchCategory) {
let categoryName = categorySearchEngine.supportSBS ? category.canonicalId : category.legacyName

categorySearchEngine.search(categoryName: categoryName, options: categorySearchOptions) { results in
switch results {
case .success(let items):
self.delegate?.categorySearchResultsReceived(results: items)
self.delegate?.categorySearchResultsReceived(category: category, results: items)
case .failure(let searchError):
print("Failed search; error=\(searchError)")
self.presentSearchError(searchError)
Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxSearchUI/SearchCategoriesRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class SearchCategoriesRootView: UIView {
}

extension SearchCategoriesRootView: CategoriesTableViewSourceDelegate {
func userSelectedCategory(_ category: Category) {
func userSelectedCategory(_ category: SearchCategory) {
delegate?.userSelectedCategory(category)
}
}
Expand Down
Loading

0 comments on commit f9733e1

Please sign in to comment.