Skip to content

Commit

Permalink
Feat: Add UISegmentedControl to set distance #71
Browse files Browse the repository at this point in the history
  • Loading branch information
jinios committed Feb 3, 2019
1 parent 2cd5d4a commit 595c71d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 9 deletions.
41 changes: 39 additions & 2 deletions MartHoliday/MartHoliday/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,48 @@ Cgo
<!--Location Search View Controller-->
<scene sceneID="U0x-QV-y44">
<objects>
<viewController id="0c7-x9-EAa" customClass="LocationSearchViewController" customModule="MartHoliday" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="locationVC" id="0c7-x9-EAa" customClass="LocationSearchViewController" customModule="MartHoliday" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="iGd-SD-Jr7">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="PQR-co-5qa">
<rect key="frame" x="0.0" y="20" width="375" height="45"/>
<subviews>
<segmentedControl opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="MVv-RV-Hy0">
<rect key="frame" x="30" y="8.5" width="315" height="29"/>
<color key="backgroundColor" name="mh-mint"/>
<segments>
<segment title="3km"/>
<segment title="5km"/>
<segment title="7km"/>
</segments>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</segmentedControl>
</subviews>
<color key="backgroundColor" name="mh-mint"/>
<color key="tintColor" name="mh-lightgray"/>
<constraints>
<constraint firstItem="MVv-RV-Hy0" firstAttribute="leading" secondItem="PQR-co-5qa" secondAttribute="leading" constant="30" id="0yO-eO-9xV"/>
<constraint firstAttribute="trailing" secondItem="MVv-RV-Hy0" secondAttribute="trailing" constant="30" id="Ugs-h6-Wjv"/>
<constraint firstItem="MVv-RV-Hy0" firstAttribute="centerY" secondItem="PQR-co-5qa" secondAttribute="centerY" id="iEu-D9-h2Y"/>
<constraint firstAttribute="height" constant="45" id="pB2-6J-c00"/>
<constraint firstItem="MVv-RV-Hy0" firstAttribute="centerX" secondItem="PQR-co-5qa" secondAttribute="centerX" id="qZ2-QA-ero"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="PQR-co-5qa" firstAttribute="leading" secondItem="eFQ-Aq-t96" secondAttribute="leading" id="GwZ-RL-gA2"/>
<constraint firstItem="PQR-co-5qa" firstAttribute="top" secondItem="eFQ-Aq-t96" secondAttribute="top" id="NVn-fy-rkB"/>
<constraint firstItem="PQR-co-5qa" firstAttribute="trailing" secondItem="eFQ-Aq-t96" secondAttribute="trailing" id="WRa-Si-LgA"/>
</constraints>
<viewLayoutGuide key="safeArea" id="eFQ-Aq-t96"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="z1Q-hG-VW4" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1639" y="147"/>
<point key="canvasLocation" x="1637.5999999999999" y="146.17691154422789"/>
</scene>
<!--Main View Controller-->
<scene sceneID="27w-gz-Gyf">
Expand Down Expand Up @@ -572,5 +603,11 @@ Cgo
<namedColor name="mh-lightgray">
<color red="0.93725490196078431" green="0.94509803921568625" blue="0.95294117647058818" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
</namedColor>
<namedColor name="mh-lightgray">
<color red="0.93725490196078431" green="0.94509803921568625" blue="0.95294117647058818" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
</namedColor>
<namedColor name="mh-mint">
<color red="0.54117647058823526" green="0.7686274509803922" blue="0.81568627450980391" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
</namedColor>
</resources>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ class LocationSearchViewController: UIViewController, NMapViewDelegate, NMapPOId

override func viewDidLoad() {
super.viewDidLoad()
locationTrackingStateButton = setLocationTrackingButton()
self.setNavigationBar()

// 위치서비스 허용했는지 검사 추가 / 안했으면 setting으로 넘김
guard let locationManager = NMapLocationManager.getSharedInstance() else { return }
self.locationManager = locationManager

mapView = NMapView(frame: self.view.frame)
mapView = NMapView(frame: CGRect(x: 0, y: 45, width: self.view.frame.width, height: self.view.frame.height-45))

if let mapView = mapView {

Expand All @@ -45,15 +46,20 @@ class LocationSearchViewController: UIViewController, NMapViewDelegate, NMapPOId
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]

currentState = .tracking
locationTrackingStateButton = setLocationTrackingButton()
enableLocationUpdate()

view.addSubview(mapView)
if let button = locationTrackingStateButton {
mapView.addSubview(button)
}
}

if let button = locationTrackingStateButton {
self.view.addSubview(button)
}
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.setNavigationBar()
}

override func viewDidAppear(_ animated: Bool) {
Expand All @@ -67,12 +73,26 @@ class LocationSearchViewController: UIViewController, NMapViewDelegate, NMapPOId
disableLocationUpdate()
}

private func setNavigationBar() {
navigationController?.navigationBar.barTintColor = UIColor.appColor(color: .mint)
navigationController?.navigationBar.isTranslucent = false
// To remove 1px line of under the navigationBar
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
self.navigationItem.title = "내 주변 마트 검색"
}

private func setLocationTrackingButton() -> UIButton {
let button = UIButton(type: .custom)

button.frame = CGRect(x: 15, y: 80, width: 36, height: 36)
button.setImage(UIImage(named: "v4_btn_navi_location_normal"), for: .normal)

switch currentState {
case .disabled:
locationTrackingStateButton?.setImage(UIImage(named: "v4_btn_navi_location_normal"), for: .normal)
case .tracking:
locationTrackingStateButton?.setImage(UIImage(named: "v4_btn_navi_location_selected"), for: .normal)
}

button.addTarget(self, action: #selector(locationTrackingButtonTapped(_:)), for: .touchUpInside)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ extension MainViewController: MFMailComposeViewControllerDelegate {
self.navigationController?.pushViewController(nextVC, animated: true)
case .location:
handleDismiss()
let nextVC = LocationSearchViewController()
guard let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "locationVC") as? LocationSearchViewController else { return }
self.navigationController?.pushViewController(nextVC, animated: true)
case .sendMail:
handleDismiss()
Expand Down

0 comments on commit 595c71d

Please sign in to comment.