GMSAutocompleteResultsViewController.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // GMSAutocompleteResultsViewController.h
  3. // Google Places SDK for iOS
  4. //
  5. // Copyright 2016 Google LLC
  6. //
  7. // Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
  8. // Service: https://developers.google.com/maps/terms
  9. //
  10. #import <UIKit/UIKit.h>
  11. #import "GMSAutocompleteFilter.h"
  12. #import "GMSAutocompletePrediction.h"
  13. #import "GMSPlace.h"
  14. #import "GMSPlaceFieldMask.h"
  15. #import "GMSPlacesDeprecationUtils.h"
  16. @class GMSAutocompleteResultsViewController;
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * Protocol used by |GMSAutocompleteResultsViewController|, to communicate the user's interaction
  20. * with the controller to the application.
  21. */
  22. @protocol GMSAutocompleteResultsViewControllerDelegate <NSObject>
  23. @required
  24. /**
  25. * Called when a place has been selected from the available autocomplete predictions.
  26. * @param resultsController The |GMSAutocompleteResultsViewController| that generated the event.
  27. * @param place The |GMSPlace| that was returned.
  28. */
  29. - (void)resultsController:(GMSAutocompleteResultsViewController *)resultsController
  30. didAutocompleteWithPlace:(GMSPlace *)place;
  31. /**
  32. * Called when a non-retryable error occurred when retrieving autocomplete predictions or place
  33. * details. A non-retryable error is defined as one that is unlikely to be fixed by immediately
  34. * retrying the operation.
  35. * <p>
  36. * Only the following values of |GMSPlacesErrorCode| are retryable:
  37. * <ul>
  38. * <li>kGMSPlacesNetworkError
  39. * <li>kGMSPlacesServerError
  40. * <li>kGMSPlacesInternalError
  41. * </ul>
  42. * All other error codes are non-retryable.
  43. * @param resultsController The |GMSAutocompleteResultsViewController| that generated the event.
  44. * @param error The |NSError| that was returned.
  45. */
  46. - (void)resultsController:(GMSAutocompleteResultsViewController *)resultsController
  47. didFailAutocompleteWithError:(NSError *)error;
  48. @optional
  49. /**
  50. * Called when the user selects an autocomplete prediction from the list but before requesting
  51. * place details. Returning NO from this method will suppress the place details fetch and
  52. * didAutocompleteWithPlace will not be called.
  53. * @param resultsController The |GMSAutocompleteResultsViewController| that generated the event.
  54. * @param prediction The |GMSAutocompletePrediction| that was selected.
  55. */
  56. - (BOOL)resultsController:(GMSAutocompleteResultsViewController *)resultsController
  57. didSelectPrediction:(GMSAutocompletePrediction *)prediction;
  58. /**
  59. * Called once every time new autocomplete predictions are received.
  60. * @param resultsController The |GMSAutocompleteResultsViewController| that generated the event.
  61. */
  62. - (void)didUpdateAutocompletePredictionsForResultsController:
  63. (GMSAutocompleteResultsViewController *)resultsController;
  64. /**
  65. * Called once immediately after a request for autocomplete predictions is made.
  66. * @param resultsController The |GMSAutocompleteResultsViewController| that generated the event.
  67. */
  68. - (void)didRequestAutocompletePredictionsForResultsController:
  69. (GMSAutocompleteResultsViewController *)resultsController;
  70. @end
  71. /**
  72. * GMSAutocompleteResultsViewController provides an interface that displays place autocomplete
  73. * predictions in a table view. The table view will be automatically updated as input text
  74. * changes.
  75. *
  76. * This class is intended to be used as the search results controller of a UISearchController. Pass
  77. * an instance of |GMSAutocompleteResultsViewController| to UISearchController's
  78. * initWithSearchResultsController method, then set the controller as the UISearchController's
  79. * searchResultsUpdater property.
  80. *
  81. * Use the |GMSAutocompleteResultsViewControllerDelegate| delegate protocol to be notified when a
  82. * place is selected from the list.
  83. */
  84. @interface GMSAutocompleteResultsViewController : UIViewController <UISearchResultsUpdating>
  85. /** Delegate to be notified when a place is selected. */
  86. @property(nonatomic, weak, nullable) id<GMSAutocompleteResultsViewControllerDelegate> delegate;
  87. /** Filter to apply to autocomplete suggestions (can be nil). */
  88. @property(nonatomic, strong, nullable) GMSAutocompleteFilter *autocompleteFilter;
  89. /** The background color of table cells. */
  90. @property(nonatomic, strong) IBInspectable UIColor *tableCellBackgroundColor;
  91. /** The color of the separator line between table cells. */
  92. @property(nonatomic, strong) IBInspectable UIColor *tableCellSeparatorColor;
  93. /** The color of result name text in autocomplete results */
  94. @property(nonatomic, strong) IBInspectable UIColor *primaryTextColor;
  95. /** The color used to highlight matching text in autocomplete results */
  96. @property(nonatomic, strong) IBInspectable UIColor *primaryTextHighlightColor;
  97. /** The color of the second row of text in autocomplete results. */
  98. @property(nonatomic, strong) IBInspectable UIColor *secondaryTextColor;
  99. /** The tint color applied to controls in the Autocomplete view. */
  100. @property(nonatomic, strong, nullable) IBInspectable UIColor *tintColor;
  101. /**
  102. * Specify individual place details to fetch for object |GMSPlace|.
  103. * Defaults to returning all details if not overridden.
  104. */
  105. @property(nonatomic, assign) GMSPlaceField placeFields;
  106. @end
  107. NS_ASSUME_NONNULL_END