Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Updated Code Layout
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenTiigi committed Jan 18, 2019
1 parent 5a068c4 commit 264ad4e
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions Sources/Controller/STLocationRequestController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public class STLocationRequestController: UIViewController {
label.numberOfLines = 0
label.lineBreakMode = .byWordWrapping
label.textColor = self.configuration.title.color
label.shadowColor = UIColor(red: 108/255, green: 108/255, blue: 108/255, alpha: 1)
label.shadowOffset = CGSize(width: 0, height: 1)
label.shadowColor = .init(red: 108 / 255, green: 108 / 255, blue: 108 / 255, alpha: 1)
label.shadowOffset = .init(width: 0, height: 1)
return label
}()

Expand Down Expand Up @@ -163,8 +163,10 @@ public class STLocationRequestController: UIViewController {

/// Deinit
deinit {
// Perform CleanUp
self.cleanUp()
// Stop place changer
self.placeChanger.stop()
// Stop Rotation
self.flyoverMapView.stop()
}

// MARK: View-Lifecycle
Expand All @@ -190,17 +192,6 @@ public class STLocationRequestController: UIViewController {
self.placeChanger.start()
}

/// ViewDidDisappear
override public func viewDidDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
// Perform CleanUp
self.cleanUp()
}

var frame: CGRect {
return self.view.frame
}

/// ViewDidLayoutSubviews
public override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
Expand Down Expand Up @@ -253,7 +244,7 @@ public class STLocationRequestController: UIViewController {

}

// MARK: - Public API Present/Dismiss functions
// MARK: - Present/Dismiss

public extension STLocationRequestController {

Expand Down Expand Up @@ -286,18 +277,10 @@ public extension STLocationRequestController {

}

// MARK: - Private API
// MARK: - Check Orientation

private extension STLocationRequestController {

/// Clean up the STLocationRequestController
func cleanUp() {
// Stop place changer
self.placeChanger.stop()
// Stop Rotation
self.flyoverMapView.stop()
}

/// Check device orientation
func checkOrientation() {
#if os(iOS)
Expand All @@ -317,9 +300,16 @@ private extension STLocationRequestController {
self.pulseEffect.setPulseRadius(isLandscape ? 0 : self.configuration.pulseEffect.radius)
#endif
}

}

// MARK: - Button Touch Handler

private extension STLocationRequestController {

/// Allow button was touched request authorization by AuthorizeType
@objc func allowButtonTouched() {
@objc
func allowButtonTouched() {
// Switch on authorite type
switch self.configuration.authorizeType {
#if os(iOS)
Expand All @@ -334,7 +324,8 @@ private extension STLocationRequestController {
}

/// Not now button was touched dismiss Viewcontroller
@objc func notNowButtonTouched() {
@objc
func notNowButtonTouched() {
// Update the Controller
self.onEvent?(.notNowButtonTapped)
// Dismiss Controller
Expand All @@ -348,7 +339,8 @@ private extension STLocationRequestController {
extension STLocationRequestController: CLLocationManagerDelegate {

/// LocationManager didChangeAuthorizationStatus
public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
public func locationManager(_ manager: CLLocationManager,
didChangeAuthorization status: CLAuthorizationStatus) {
// Check if Event is available
guard let event = status.toEvent() else {
// Return out of function no event to emit
Expand Down

0 comments on commit 264ad4e

Please sign in to comment.