Skip to content

Commit

Permalink
Feat: Implement distance search view #89
Browse files Browse the repository at this point in the history
- Add Distance search view, implement animation
  • Loading branch information
jinios committed Jul 22, 2019
1 parent 2b33286 commit aa89683
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions MartHoliday/MartHoliday/View/TickMarkSlider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TickMarkSlider: UISlider {
self.unit = (maximumValue - self.minimumValue) / tick
self.maximumValue = maximumValue
self.value = initialValue
self.minimumTrackTintColor = UIColor.appColor(color: .mint)
}

private override init(frame: CGRect) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ class LocationSearchViewController: IndicatorViewController, NMFMapViewDelegate,

@IBOutlet weak var naverMapView: NMFNaverMapView!
@IBOutlet weak var searchAgainButton: UIButton!

@IBOutlet weak var distanceSearchView: UIView!
@IBOutlet weak var sliderView : UIView!
@IBOutlet weak var sliderViewTopConstraint: NSLayoutConstraint!

@IBOutlet weak var distanceLabel: UILabel!

var userLocation: NMGLatLng? {
didSet {
guard let userLocation = self.userLocation else { return }
Expand Down Expand Up @@ -116,6 +120,8 @@ class LocationSearchViewController: IndicatorViewController, NMFMapViewDelegate,

var settingDistance: Int? {
didSet {
self.distanceLabel.text = "\(self.settingDistance ?? 2) km"

let distanceSettingButton = UIButton(type: .custom)

let buttonTitle = NSAttributedString(string: "\(self.settingDistance ?? 2)km",
Expand All @@ -139,8 +145,25 @@ class LocationSearchViewController: IndicatorViewController, NMFMapViewDelegate,
}
}

var isDistanceSearchViewShown = false

@objc func changeSearchDistance() {
self.showAndHideDistanceView(isShown: self.isDistanceSearchViewShown)
}

@IBAction func hideDistanceView(_ sender: UIButton) {
self.showAndHideDistanceView(isShown: false)
}

private func showAndHideDistanceView(isShown: Bool) {
self.sliderViewTopConstraint.constant = isShown ? 0 : -150

UIView.animate(withDuration: 0.5, delay: 0, options: .curveEaseIn, animations: {
self.distanceSearchView.alpha = isShown ? 1 : 0
self.view.layoutIfNeeded()
}) { _ in
self.isDistanceSearchViewShown = !self.isDistanceSearchViewShown
}
}

}
Expand Down

0 comments on commit aa89683

Please sign in to comment.