This commit is contained in:
Ruoyu Fu
2019-05-06 15:05:38 +08:00
parent c28e02d1bb
commit 538cda3db1
2 changed files with 6 additions and 3 deletions

View File

@@ -29,7 +29,7 @@ open class RxGMSDataSourceDelegateProxy
register { RxGMSDataSourceDelegateProxy(dataSource: $0) }
}
var placeBehaviorSubject = BehaviorSubject<GMSPlace?>(value: nil)
public var placeBehaviorSubject = BehaviorSubject<GMSPlace?>(value: nil)
public func tableDataSource(_ tableDataSource: GMSAutocompleteTableDataSource, didAutocompleteWith place: GMSPlace) {
placeBehaviorSubject.on(.next(place))
@@ -49,7 +49,7 @@ extension Reactive where Base == GMSAutocompleteTableDataSource{
return RxGMSDataSourceDelegateProxy.proxy(for: base)
}
var sourceText:Binder<String?> {
public var sourceText:Binder<String?> {
return Binder(self.base) { (dataSource, text: String?) in
dataSource.sourceTextHasChanged(text)
}

View File

@@ -13,14 +13,15 @@ import RxSwift
class ViewController: UIViewController {
let disposeBag = DisposeBag()
@IBOutlet weak var header: UIView!
@IBOutlet weak var pickupResults: UITableView!
@IBOutlet weak var dropoffResults: UITableView!
@IBOutlet weak var pickupField: UITextField!
@IBOutlet weak var dropoffField: UITextField!
let pickupSource = GMSAutocompleteTableDataSource()
let dropoffSource = GMSAutocompleteTableDataSource()
let disposeBag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
@@ -28,12 +29,14 @@ class ViewController: UIViewController {
bindModels(textField: pickupField, table: pickupResults, source: pickupSource)
bindModels(textField: dropoffField, table: dropoffResults, source: dropoffSource)
}
func setupView() {
header.layer.masksToBounds = false
header.layer.shadowOffset = CGSize(width: 1, height: 1)
header.layer.shadowRadius = 3
header.layer.shadowOpacity = 0.3
}
func bindModels(textField: UITextField, table: UITableView, source: GMSAutocompleteTableDataSource) {
table.delegate = source
table.dataSource = source