Skip to content

Commit

Permalink
Add a ConstatValues struct for all default values used in the project
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaantonioni committed Jul 30, 2017
1 parent 5122209 commit 4255167
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
4 changes: 4 additions & 0 deletions M13Checkbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
172E9F881F2E125900610B82 /* ConstantValues.swift in Sources */ = {isa = PBXBuildFile; fileRef = 172E9F871F2E125900610B82 /* ConstantValues.swift */; };
43242B551DA7BC1100C6AF91 /* M13CheckboxAddRemovePathGenerator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43242B541DA7BC1100C6AF91 /* M13CheckboxAddRemovePathGenerator.swift */; };
43242B561DA7C2CC00C6AF91 /* M13CheckboxFillController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA3591421CAC1F12000FBA3B /* M13CheckboxFillController.swift */; };
43242B571DA7C3CA00C6AF91 /* M13CheckboxBounceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA26E1E41CAC66F000ACB4F4 /* M13CheckboxBounceController.swift */; };
Expand Down Expand Up @@ -71,6 +72,7 @@

/* Begin PBXFileReference section */
142C71FD96ACA2685D246CF8 /* Pods_M13Checkbox.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_M13Checkbox.framework; sourceTree = BUILT_PRODUCTS_DIR; };
172E9F871F2E125900610B82 /* ConstantValues.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstantValues.swift; sourceTree = "<group>"; };
43242B541DA7BC1100C6AF91 /* M13CheckboxAddRemovePathGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = M13CheckboxAddRemovePathGenerator.swift; path = Sources/Paths/M13CheckboxAddRemovePathGenerator.swift; sourceTree = SOURCE_ROOT; };
434D1FF51DABB52300F5A8C8 /* M13CheckboxDisclosurePathGenerator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = M13CheckboxDisclosurePathGenerator.swift; path = Sources/Paths/M13CheckboxDisclosurePathGenerator.swift; sourceTree = SOURCE_ROOT; };
43A4CE6E1E64F86D23A4560F /* Pods-M13Checkbox.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-M13Checkbox.release.xcconfig"; path = "Pods/Target Support Files/Pods-M13Checkbox/Pods-M13Checkbox.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -228,6 +230,7 @@
EA26E1EC1CAEDD0800ACB4F4 /* Path Generators */,
EAA0983C1CA8BE7F001AAF6E /* Controllers */,
EA6720301C7DFC3D008054BA /* M13Checkbox+IB.swift */,
172E9F871F2E125900610B82 /* ConstantValues.swift */,
);
name = Source;
path = M13Checkbox;
Expand Down Expand Up @@ -457,6 +460,7 @@
43242B5A1DA7C6F400C6AF91 /* M13CheckboxSpiralController.swift in Sources */,
43BDF4E21DA672EA005476B2 /* M13CheckboxCheckPathGenerator.swift in Sources */,
43242B581DA7C4B600C6AF91 /* M13CheckboxExpandController.swift in Sources */,
172E9F881F2E125900610B82 /* ConstantValues.swift in Sources */,
43BDF4E31DA67304005476B2 /* M13CheckboxPathGenerator.swift in Sources */,
43242B5B1DA7C7C300C6AF91 /* M13CheckboxFadeController.swift in Sources */,
EA96F9081CBEB5190066C6B7 /* M13CheckboxController.swift in Sources */,
Expand Down
24 changes: 24 additions & 0 deletions M13Checkbox/ConstantValues.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// ConstantValues.swift
// M13Checkbox
//
// Created by Andrea Antonioni on 30/07/17.
// Copyright © 2017 Brandon McQuilkin. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import Foundation

// A set of default values used to initialize the object
struct ConstantValues {

static let defaultAnimation: M13Checkbox.Animation = .stroke
static let defaultMarkType: M13Checkbox.MarkType = .checkmark
static let defaultBoxType: M13Checkbox.BoxType = .circle
static let defaultCheckState: M13Checkbox.CheckState = .unchecked

}
8 changes: 4 additions & 4 deletions Sources/M13Checkbox+IB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public extension M13Checkbox {
if let type = Animation(rawValue: newValue) {
stateChangeAnimation = type
} else {
stateChangeAnimation = .stroke
stateChangeAnimation = ConstantValues.defaultAnimation
}
}
}
Expand All @@ -38,7 +38,7 @@ public extension M13Checkbox {
if let type = MarkType(rawValue: newValue) {
markType = type
} else {
markType = .checkmark
markType = ConstantValues.defaultMarkType
}
}
}
Expand All @@ -52,7 +52,7 @@ public extension M13Checkbox {
if let type = BoxType(rawValue: newValue) {
boxType = type
} else {
boxType = .circle
boxType = ConstantValues.defaultBoxType
}
}
}
Expand All @@ -66,7 +66,7 @@ public extension M13Checkbox {
if let temp = CheckState(rawValue: newValue) {
checkState = temp
} else {
checkState = .unchecked
checkState = ConstantValues.defaultCheckState
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/M13Checkbox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ open class M13Checkbox: UIControl {
layer.addSublayer(aLayer)
}
controller.tintColor = tintColor
controller.resetLayersForState(.unchecked)
controller.resetLayersForState(ConstantValues.defaultCheckState)

let longPressGesture = M13CheckboxGestureRecognizer(target: self, action: #selector(M13Checkbox.handleLongPress(_:)))
addGestureRecognizer(longPressGesture)
Expand Down Expand Up @@ -345,7 +345,7 @@ open class M13Checkbox: UIControl {
}

/// The type of animation to preform when changing from the unchecked state to any other state.
open var stateChangeAnimation: Animation = .stroke {
open var stateChangeAnimation: Animation = ConstantValues.defaultAnimation {
didSet {

// Remove the sublayers
Expand Down

0 comments on commit 4255167

Please sign in to comment.