diff --git a/SwiftMonkeyPaws/MonkeyPaws.swift b/SwiftMonkeyPaws/MonkeyPaws.swift index 065d989..13dbf66 100644 --- a/SwiftMonkeyPaws/MonkeyPaws.swift +++ b/SwiftMonkeyPaws/MonkeyPaws.swift @@ -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() @@ -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 diff --git a/SwiftMonkeyPaws/Sources/Extensions/MonkeyPaws+Configuration.swift b/SwiftMonkeyPaws/Sources/Extensions/MonkeyPaws+Configuration.swift new file mode 100644 index 0000000..3b66558 --- /dev/null +++ b/SwiftMonkeyPaws/Sources/Extensions/MonkeyPaws+Configuration.swift @@ -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 + } + } +} diff --git a/SwiftMonkeyPaws/SwiftMonkeyPaws.xcodeproj/project.pbxproj b/SwiftMonkeyPaws/SwiftMonkeyPaws.xcodeproj/project.pbxproj index 5a44bf7..f878f02 100644 --- a/SwiftMonkeyPaws/SwiftMonkeyPaws.xcodeproj/project.pbxproj +++ b/SwiftMonkeyPaws/SwiftMonkeyPaws.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ 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 */; }; @@ -14,6 +15,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 183234252030AF3A00B4C6DD /* MonkeyPaws+Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MonkeyPaws+Configuration.swift"; sourceTree = ""; }; 189807AF202338A300B9F544 /* UIColor+MonkeyPaws.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIColor+MonkeyPaws.swift"; sourceTree = ""; }; 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; }; @@ -39,6 +41,7 @@ isa = PBXGroup; children = ( 189807AF202338A300B9F544 /* UIColor+MonkeyPaws.swift */, + 183234252030AF3A00B4C6DD /* MonkeyPaws+Configuration.swift */, ); path = Extensions; sourceTree = ""; @@ -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;