Skip to content

Commit

Permalink
Mostly cosmetic changes to make SwiftLint pass without warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
halmueller committed Nov 19, 2019
1 parent 436bdfe commit db5decc
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 41 deletions.
10 changes: 8 additions & 2 deletions ARKit+CoreLocation/POIViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ class POIViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification, object: nil, queue: nil) { _ in
// swiftlint:disable discarded_notification_center_observer
NotificationCenter.default.addObserver(forName: UIApplication.willResignActiveNotification,
object: nil,
queue: nil) { _ in
self.pauseAnimation()
}
NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification, object: nil, queue: nil) { _ in
NotificationCenter.default.addObserver(forName: UIApplication.didBecomeActiveNotification,
object: nil,
queue: nil) { _ in
self.restartAnimation()
}
// swiftlint:enable discarded_notification_center_observer

updateInfoLabelTimer = Timer.scheduledTimer(timeInterval: 0.1,
target: self,
Expand Down
81 changes: 54 additions & 27 deletions Node Demos/ARCLViewController.swift

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Node Demos/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import UIKit

// swiftlint:disable all
// This file is an Apple template and it's not worth our time to make it pass swiftlint for a demo.
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

Expand Down
12 changes: 9 additions & 3 deletions Node Demos/PickerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import UIKit
import ARCL

// swiftlint:disable:next type_body_length
class PickerViewController: UITableViewController, UITextFieldDelegate {

// Originally, the hard-coded factor to raise an annotation's label within the viewport was 1.1.
Expand Down Expand Up @@ -120,6 +121,7 @@ class PickerViewController: UITableViewController, UITextFieldDelegate {
destination.continuallyUpdatePositionAndScale = continuallyUpdatePositionAndScale
destination.continuallyAdjustNodePositionWhenWithinRange = continuallyAdjustNodePositionWhenWithinRange

// swiftlint:disable statement_position
if segue.identifier == "justOneNode" {
destination.demonstration = .justOneNode
}
Expand All @@ -141,6 +143,7 @@ class PickerViewController: UITableViewController, UITextFieldDelegate {
else if segue.identifier == "liveNodes" {
destination.demonstration = .dynamicNodes
}
// swiftlint:enable statement_position
}
}

Expand Down Expand Up @@ -263,16 +266,19 @@ class PickerViewController: UITableViewController, UITextFieldDelegate {
}

/// Yes, this code is very repetitive of `scalingSchemeChanged`. I could make it more DRY by adding
/// a computed property to `ScalingScheme`, but I don't want to mess with library code any more than necessary just for this demo.
/// https://medium.com/@PhiJay/why-swift-enums-with-associated-values-cannot-have-a-raw-value-21e41d5ec11 has a good discussion.
/// a computed property to `ScalingScheme`, but I don't want to mess with library code any more than
/// necessary just for this demo.
/// https://medium.com/@PhiJay/why-swift-enums-with-associated-values-cannot-have-a-raw-value-21e41d5ec11
/// has a good discussion.
fileprivate func recomputeScalingScheme() {
switch scalingScheme {
case .normal:
scalingScheme = .normal
case .tiered:
scalingScheme = .tiered(threshold: threshold1, scale: scale1)
case .doubleTiered:
scalingScheme = .doubleTiered(firstThreshold: threshold1, firstScale: scale1, secondThreshold: threshold2, secondScale: scale2)
scalingScheme = .doubleTiered(firstThreshold: threshold1, firstScale: scale1,
secondThreshold: threshold2, secondScale: scale2)
case .linear:
scalingScheme = .linear(threshold: threshold1)
case .linearBuffer:
Expand Down
2 changes: 2 additions & 0 deletions Node Demos/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import UIKit

// swiftlint:disable all
// This file is an Apple template and it's not worth our time to make it pass swiftlint for a demo.
class SceneDelegate: UIResponder, UIWindowSceneDelegate {

var window: UIWindow?
Expand Down
3 changes: 2 additions & 1 deletion Node DemosUITests/Node_DemosUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class NodeDemosUITests: XCTestCase {
// In UI tests it is usually best to stop immediately when a failure occurs.
continueAfterFailure = false

// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
// In UI tests it’s important to set the initial state - such as interface orientation - required for your tests
// before they run. The setUp method is a good place to do this.
}

override func tearDown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension SCNNode {
geom.materials.forEach { $0.readsFromDepthBuffer = false }
}
}

/// Returns a node similar to the one displayed when an `ARSCNView`'s `.debugOptions` includes `.showWorldOrigin`
class func axesNode(quiverLength: CGFloat, quiverThickness: CGFloat) -> SCNNode {
let quiverThickness = (quiverLength / 50.0) * quiverThickness
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open class LocationAnnotationNode: LocationNode {
/// To draw the label exactly on the true location, use a value of 0. To draw it below the true location,
/// use a negative value.
public var annotationHeightAdjustmentFactor = 1.1

public init(location: CLLocation?, image: UIImage) {
let plane = SCNPlane(width: image.size.width / 100, height: image.size.height / 100)
plane.firstMaterial?.diffuse.contents = image
Expand Down
4 changes: 2 additions & 2 deletions Sources/ARKit-CoreLocation/Nodes/ScalingScheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import Foundation
/// Values:
/// - normal: The default way of scaling, Hardcoded value out to 3000 meters, and then 0.75 that factor beyond 3000 m.
/// - tiered (threshold, scale): Return 1.0 at distance up to `threshold` meters, or `scale` beyond.
/// - doubleTiered (firstThreshold, firstCale, secondThreshold, secondScale): A way of scaling everything beyond 2 specific distances at two
/// specific scales.
/// - doubleTiered (firstThreshold, firstCale, secondThreshold, secondScale): A way of scaling everything
/// beyond 2 specific distances at two specific scales.
/// - linear (threshold): linearly scales an object based on its distance.
/// - linearBuffer (threshold, buffer): linearly scales an object based on its distance as long as it is
/// further than the buffer distance, otherwise it just returns 100% scale.
Expand Down
8 changes: 4 additions & 4 deletions Sources/ARKit-CoreLocation/SceneLocationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public extension SceneLocationView {
/// - polylines: A set of MKPolyline.
/// - boxBuilder: A block that will customize how a box is built.
func addPolylines(polylines: [MKPolyline], boxBuilder: BoxBuilder? = nil) {

guard let altitude = sceneLocationManager.currentLocation?.altitude else {
return assertionFailure("we don't have an elevation")
}
Expand All @@ -418,19 +418,19 @@ public extension SceneLocationView {

polylineNodes.forEach {
$0.locationNodes.forEach {

let locationNodeLocation = self.locationOfLocationNode($0)
$0.updatePositionAndScale(setup: true,
scenePosition: currentScenePosition,
locationNodeLocation: locationNodeLocation,
locationManager: sceneLocationManager,
onCompletion: {})

sceneNode?.addChildNode($0)
}
}
}

func removePolylines(polylines: [MKPolyline]) {
polylines.forEach { polyline in
if let index = polylineNodes.firstIndex(where: { $0.polyline == polyline }) {
Expand Down

0 comments on commit db5decc

Please sign in to comment.