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

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Metzing committed Feb 11, 2018
1 parent 9d4c143 commit 1d2ea3f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 46 deletions.
48 changes: 2 additions & 46 deletions SwiftMonkeyPaws/MonkeyPaws.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,56 +34,12 @@ import UIKit

public class MonkeyPaws: NSObject, CALayerDelegate {

public struct Configuration {
// Customise the appearance of the paws
public struct Paws {

/// Define the colour of the Paws
///
/// - randomized: random colour for each paw
/// - constant: same colour for the paws
enum Colour {
case randomized
case constant(UIColor)
}
// Colour of the paws
let colour: Colour

// Brightness of a particular paw
let brightness: CGFloat

// Maximum visible paws at one time
let maxShown: Int

public static let `default`: Paws = Paws(colour: .randomized,
brightness: 0.5,
maxShown: 15)
}

public struct Radius {

/// Radius of the cross draw upon canceling a touch event
let cross: CGFloat

/// Radius of the circle draw upon ending a touch event
let circle: CGFloat

public static let `default`: Radius = Radius(cross: 7,
circle: 7)
}

let paws: Paws
let radius: Radius

public static let `default`: MonkeyPaws.Configuration = MonkeyPaws.Configuration(paws: Paws.default, radius: Radius.default)
}

public typealias BezierPathDrawer = () -> UIBezierPath

private var gestures: [(hash: Int?, gesture: Gesture)] = []
private weak var view: UIView?

let configuration: Configuration
let configuration: MonkeyPaws.Configuration
let bezierPathDrawer: BezierPathDrawer
let layer = CALayer()

Expand All @@ -109,7 +65,7 @@ public class MonkeyPaws: NSObject, CALayerDelegate {
*/
public init(view: UIView,
tapUIApplication: Bool = true,
configuration: Configuration = Configuration.default,
configuration: Configuration = Configuration(),
bezierPathDrawer: @escaping BezierPathDrawer = MonkeyPawDrawer.monkeyHandPath) {
self.configuration = configuration
self.bezierPathDrawer = bezierPathDrawer
Expand Down
62 changes: 62 additions & 0 deletions SwiftMonkeyPaws/Sources/Extensions/MonkeyPaws+Configuration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// MonkeyPaws+Configuration.swift
// SwiftMonkeyPaws
//
// Created by Daniel.Metzing on 11.02.18.
//

import UIKit

extension MonkeyPaws {

public struct Configuration {
// Customise the appearance of the paws
public struct Paws {

/// Define the colour of the Paws
///
/// - randomized: random colour for each paw
/// - constant: same colour for the paws
public enum Colour {
case randomized
case constant(UIColor)
}
// Colour of the paws
public let colour: Colour

// Brightness of a particular paw
public let brightness: CGFloat

// Maximum visible paws at one time
public let maxShown: Int

public init(colour: Colour = .randomized, brightness: CGFloat = 0.5, maxShown: Int = 15) {
self.colour = colour
self.brightness = brightness
self.maxShown = maxShown
}
}

public struct Radius {

/// Radius of the cross draw upon canceling a touch event
public let cross: CGFloat

/// Radius of the circle draw upon ending a touch event
public let circle: CGFloat

public init(cross: CGFloat = 7, circle: CGFloat = 7) {
self.cross = cross
self.circle = circle
}
}

public let paws: Paws
public let radius: Radius

public init(paws: Paws = Paws(), radius: Radius = Radius()) {
self.paws = paws
self.radius = radius
}
}
}
4 changes: 4 additions & 0 deletions SwiftMonkeyPaws/SwiftMonkeyPaws.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
objects = {

/* Begin PBXBuildFile section */
183234262030AF3A00B4C6DD /* MonkeyPaws+Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 183234252030AF3A00B4C6DD /* MonkeyPaws+Configuration.swift */; };
189807B0202338A300B9F544 /* UIColor+MonkeyPaws.swift in Sources */ = {isa = PBXBuildFile; fileRef = 189807AF202338A300B9F544 /* UIColor+MonkeyPaws.swift */; };
189807B920279AD800B9F544 /* MonkeyPawDrawer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 189807B820279AD800B9F544 /* MonkeyPawDrawer.swift */; };
C929B55C1DD0B7C9004B256F /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C929B55B1DD0B7C9004B256F /* UIKit.framework */; };
OBJ_18 /* MonkeyPaws.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_9 /* MonkeyPaws.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
183234252030AF3A00B4C6DD /* MonkeyPaws+Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MonkeyPaws+Configuration.swift"; sourceTree = "<group>"; };
189807AF202338A300B9F544 /* UIColor+MonkeyPaws.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+MonkeyPaws.swift"; sourceTree = "<group>"; };
189807B820279AD800B9F544 /* MonkeyPawDrawer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MonkeyPawDrawer.swift; sourceTree = SOURCE_ROOT; };
C929B55B1DD0B7C9004B256F /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
Expand All @@ -39,6 +41,7 @@
isa = PBXGroup;
children = (
189807AF202338A300B9F544 /* UIColor+MonkeyPaws.swift */,
183234252030AF3A00B4C6DD /* MonkeyPaws+Configuration.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -153,6 +156,7 @@
files = (
OBJ_18 /* MonkeyPaws.swift in Sources */,
189807B0202338A300B9F544 /* UIColor+MonkeyPaws.swift in Sources */,
183234262030AF3A00B4C6DD /* MonkeyPaws+Configuration.swift in Sources */,
189807B920279AD800B9F544 /* MonkeyPawDrawer.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

0 comments on commit 1d2ea3f

Please sign in to comment.