GMSAutocompleteViewController.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // GMSAutocompleteViewController.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 GMSAutocompleteViewController;
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * Protocol used by |GMSAutocompleteViewController|, to communicate the user's interaction
  20. * with the controller to the application.
  21. */
  22. @protocol GMSAutocompleteViewControllerDelegate <NSObject>
  23. @required
  24. /**
  25. * Called when a place has been selected from the available autocomplete predictions.
  26. *
  27. * Implementations of this method should dismiss the view controller as the view controller will not
  28. * dismiss itself.
  29. *
  30. * @param viewController The |GMSAutocompleteViewController| that generated the event.
  31. * @param place The |GMSPlace| that was returned.
  32. */
  33. - (void)viewController:(GMSAutocompleteViewController *)viewController
  34. didAutocompleteWithPlace:(GMSPlace *)place;
  35. /**
  36. * Called when a non-retryable error occurred when retrieving autocomplete predictions or place
  37. * details. A non-retryable error is defined as one that is unlikely to be fixed by immediately
  38. * retrying the operation.
  39. *
  40. * Only the following values of |GMSPlacesErrorCode| are retryable:
  41. * <ul>
  42. * <li>kGMSPlacesNetworkError
  43. * <li>kGMSPlacesServerError
  44. * <li>kGMSPlacesInternalError
  45. * </ul>
  46. * All other error codes are non-retryable.
  47. *
  48. * @param viewController The |GMSAutocompleteViewController| that generated the event.
  49. * @param error The |NSError| that was returned.
  50. */
  51. - (void)viewController:(GMSAutocompleteViewController *)viewController
  52. didFailAutocompleteWithError:(NSError *)error;
  53. /**
  54. * Called when the user taps the Cancel button in a |GMSAutocompleteViewController|.
  55. *
  56. * Implementations of this method should dismiss the view controller as the view controller will not
  57. * dismiss itself.
  58. *
  59. * @param viewController The |GMSAutocompleteViewController| that generated the event.
  60. */
  61. - (void)wasCancelled:(GMSAutocompleteViewController *)viewController;
  62. @optional
  63. /**
  64. * Called when the user selects an autocomplete prediction from the list but before requesting
  65. * place details.
  66. *
  67. * Returning NO from this method will suppress the place details fetch and didAutocompleteWithPlace
  68. * will not be called.
  69. *
  70. * @param viewController The |GMSAutocompleteViewController| that generated the event.
  71. * @param prediction The |GMSAutocompletePrediction| that was selected.
  72. */
  73. - (BOOL)viewController:(GMSAutocompleteViewController *)viewController
  74. didSelectPrediction:(GMSAutocompletePrediction *)prediction;
  75. /**
  76. * Called once every time new autocomplete predictions are received.
  77. *
  78. * @param viewController The |GMSAutocompleteViewController| that generated the event.
  79. */
  80. - (void)didUpdateAutocompletePredictions:(GMSAutocompleteViewController *)viewController;
  81. /**
  82. * Called once immediately after a request for autocomplete predictions is made.
  83. *
  84. * @param viewController The |GMSAutocompleteViewController| that generated the event.
  85. */
  86. - (void)didRequestAutocompletePredictions:(GMSAutocompleteViewController *)viewController;
  87. @end
  88. /**
  89. * GMSAutocompleteViewController provides an interface that displays a table of autocomplete
  90. * predictions that updates as the user enters text. Place selections made by the user are
  91. * returned to the app via the |GMSAutocompleteViewControllerResultsDelegate| protocol.
  92. *
  93. * To use GMSAutocompleteViewController, set its delegate to an object in your app that
  94. * conforms to the |GMSAutocompleteViewControllerDelegate| protocol and present the controller
  95. * (eg using presentViewController). The |GMSAutocompleteViewControllerDelegate| delegate methods
  96. * can be used to determine when the user has selected a place or has cancelled selection.
  97. */
  98. @interface GMSAutocompleteViewController : UIViewController
  99. /** Delegate to be notified when a place is selected or picking is cancelled. */
  100. @property(nonatomic, weak, nullable) IBOutlet id<GMSAutocompleteViewControllerDelegate> delegate;
  101. /** Filter to apply to autocomplete suggestions (can be nil). */
  102. @property(nonatomic, strong, nullable) GMSAutocompleteFilter *autocompleteFilter;
  103. /** The background color of table cells. */
  104. @property(nonatomic, strong) IBInspectable UIColor *tableCellBackgroundColor;
  105. /** The color of the separator line between table cells. */
  106. @property(nonatomic, strong) IBInspectable UIColor *tableCellSeparatorColor;
  107. /** The color of result name text in autocomplete results */
  108. @property(nonatomic, strong) IBInspectable UIColor *primaryTextColor;
  109. /** The color used to highlight matching text in autocomplete results */
  110. @property(nonatomic, strong) IBInspectable UIColor *primaryTextHighlightColor;
  111. /** The color of the second row of text in autocomplete results. */
  112. @property(nonatomic, strong) IBInspectable UIColor *secondaryTextColor;
  113. /** The tint color applied to controls in the Autocomplete view. */
  114. @property(nonatomic, strong, nullable) IBInspectable UIColor *tintColor;
  115. /**
  116. * Specify individual place details to fetch for object |GMSPlace|.
  117. * Defaults to returning all details if not overridden.
  118. */
  119. @property(nonatomic, assign) GMSPlaceField placeFields;
  120. @end
  121. NS_ASSUME_NONNULL_END