diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000..927eb79 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,2 @@ +exclude_patterns: +- "Example/" \ No newline at end of file diff --git a/Example/HGCircularSlider.xcodeproj/project.pbxproj b/Example/HGCircularSlider.xcodeproj/project.pbxproj index 94dffce..c293442 100644 --- a/Example/HGCircularSlider.xcodeproj/project.pbxproj +++ b/Example/HGCircularSlider.xcodeproj/project.pbxproj @@ -19,6 +19,8 @@ 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; + BB409EA9235C82CE006DC844 /* CircularSliderHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB409EA7235C82CA006DC844 /* CircularSliderHelperTests.swift */; }; + BB409EAB235C8ACE006DC844 /* CircularSliderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB409EAA235C8ACE006DC844 /* CircularSliderTests.swift */; }; BDF84380A076F46A79D0C634 /* Pods_HGCircularSlider_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41A4019E034E0265198683A8 /* Pods_HGCircularSlider_Example.framework */; }; /* End PBXBuildFile section */ @@ -55,6 +57,8 @@ 6C7918EC49141F7F4652E8F1 /* Pods_HGCircularSlider_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_HGCircularSlider_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 99A3B0410141275989079EB6 /* Pods-HGCircularSlider_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HGCircularSlider_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-HGCircularSlider_Tests/Pods-HGCircularSlider_Tests.release.xcconfig"; sourceTree = ""; }; 9BA305BCC009CE17283FE799 /* Pods-HGCircularSlider_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HGCircularSlider_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-HGCircularSlider_Example/Pods-HGCircularSlider_Example.release.xcconfig"; sourceTree = ""; }; + BB409EA7235C82CA006DC844 /* CircularSliderHelperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CircularSliderHelperTests.swift; sourceTree = ""; }; + BB409EAA235C8ACE006DC844 /* CircularSliderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularSliderTests.swift; sourceTree = ""; }; E7D1A678D25EC3365B800DB3 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; EEE4816CB037512E066C24A8 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; /* End PBXFileReference section */ @@ -141,6 +145,8 @@ 607FACE81AFB9204008FA782 /* Tests */ = { isa = PBXGroup; children = ( + BB409EA7235C82CA006DC844 /* CircularSliderHelperTests.swift */, + BB409EAA235C8ACE006DC844 /* CircularSliderTests.swift */, 607FACEB1AFB9204008FA782 /* Tests.swift */, 607FACE91AFB9204008FA782 /* Supporting Files */, ); @@ -356,6 +362,8 @@ buildActionMask = 2147483647; files = ( 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, + BB409EAB235C8ACE006DC844 /* CircularSliderTests.swift in Sources */, + BB409EA9235C82CE006DC844 /* CircularSliderHelperTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/HGCircularSlider.xcodeproj/xcshareddata/xcschemes/HGCircularSlider-Example.xcscheme b/Example/HGCircularSlider.xcodeproj/xcshareddata/xcschemes/HGCircularSlider-Example.xcscheme index 63d13de..a31b7a0 100755 --- a/Example/HGCircularSlider.xcodeproj/xcshareddata/xcschemes/HGCircularSlider-Example.xcscheme +++ b/Example/HGCircularSlider.xcodeproj/xcshareddata/xcschemes/HGCircularSlider-Example.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -53,17 +62,6 @@ - - - - - - - - CFBundlePackageType FMWK CFBundleShortVersionString - 2.1.0 + 2.2.0 CFBundleSignature ???? CFBundleVersion diff --git a/Example/Tests/CircularSliderHelperTests.swift b/Example/Tests/CircularSliderHelperTests.swift index e13fc1d..f37896d 100644 --- a/Example/Tests/CircularSliderHelperTests.swift +++ b/Example/Tests/CircularSliderHelperTests.swift @@ -47,4 +47,26 @@ class CircularSliderHelperTests: XCTestCase { let angle = CircularSliderHelper.scaleValue(value, fromInterval: valuesInterval, toInterval: cirlceInterval).toDegrees XCTAssertEqual(angle, 180) } + + func testValueFromRangeToAnotherRangeMinValueEqualToZero() { + let oldRange = Interval(min: 0, max: 100) + let newRange = Interval(min: 10, max: 20) + + let value: CGFloat = 10 + + let newValue = CircularSliderHelper.scaleValue(value, fromInterval: oldRange, toInterval: newRange) + + XCTAssertEqual(newValue, 11) + } + + func testValueFromRangeToAnotherRangeMinValueGratherThanZero() { + let oldRange = Interval(min: 5, max: 30) + let newRange = Interval(min: 0, max: 100) + + let value: CGFloat = 10 + + let newValue = CircularSliderHelper.scaleValue(value, fromInterval: oldRange, toInterval: newRange) + + XCTAssertEqual(newValue, 20) + } } diff --git a/Example/Tests/CircularSliderTests.swift b/Example/Tests/CircularSliderTests.swift new file mode 100644 index 0000000..a1d572e --- /dev/null +++ b/Example/Tests/CircularSliderTests.swift @@ -0,0 +1,98 @@ +// +// CircularSliderTests.swift +// HGCircularSlider_Tests +// +// Created by Hamza on 20/10/2019. +// Copyright © 2019 CocoaPods. All rights reserved. +// + +import XCTest +@testable import HGCircularSlider + +class CircularSliderTests: XCTestCase { + + func testEndPointPositionWithZeroAsInitialValueAnd90DegreesAsTouchPosition() { + // Given + let circularSlider = CircularSlider(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) + let startPosition = CGPoint(x: 25, y: 0) + circularSlider.minimumValue = 0 + circularSlider.maximumValue = 100 + circularSlider.endPointValue = 0 + + let touchPosition = CGPoint(x: 50, y: 25) + + // When + let newValue = circularSlider.newValue(from: circularSlider.endPointValue, touch: touchPosition, start: startPosition) + + // Then + XCTAssertEqual(newValue, 25, accuracy: 0.001) + } + + func testEndPointPositionWithValueGratherThanZeroAsInitialValueAnd90DegreesAsTouchPosition() { + // Given + let circularSlider = CircularSlider(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) + let startPosition = CGPoint(x: 25, y: 0) + circularSlider.minimumValue = 5 + circularSlider.maximumValue = 25 + circularSlider.endPointValue = 5 + + let touchPosition = CGPoint(x: 50, y: 25) + + // When + let newValue = circularSlider.newValue(from: circularSlider.endPointValue, touch: touchPosition, start: startPosition) + + // Then + XCTAssertEqual(newValue, 10, accuracy: 0.001) + } + + func testndPointPositionWithValueGratherThanZeroAsInitialValueAnd180DegreesAsTouchPosition() { + // Given + let circularSlider = CircularSlider(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) + let startPosition = CGPoint(x: 25, y: 0) + circularSlider.minimumValue = 5 + circularSlider.maximumValue = 25 + circularSlider.endPointValue = 10 + + let touchPosition = CGPoint(x: 25, y: 50) + + // When + let newValue = circularSlider.newValue(from: circularSlider.endPointValue, touch: touchPosition, start: startPosition) + + // Then + XCTAssertEqual(newValue, 15, accuracy: 0.001) + } + + func testndPointPositionWithValueGratherThanZeroAsInitialValueAnd270DegreesAsTouchPosition() { + // Given + let circularSlider = CircularSlider(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) + let startPosition = CGPoint(x: 25, y: 0) + circularSlider.minimumValue = 5 + circularSlider.maximumValue = 25 + circularSlider.endPointValue = 10 + + let touchPosition = CGPoint(x: 0, y: 25) + + // When + let newValue = circularSlider.newValue(from: circularSlider.endPointValue, touch: touchPosition, start: startPosition) + + // Then + XCTAssertEqual(newValue, 20, accuracy: 0.001) + } + + func testndPointPositionWithValueGratherThanZeroAsInitialValueAnd360DegreesAsTouchPosition() { + // Given + let circularSlider = CircularSlider(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) + let startPosition = CGPoint(x: 25, y: 0) + circularSlider.minimumValue = 5 + circularSlider.maximumValue = 25 + circularSlider.endPointValue = 10 + + let touchPosition = CGPoint(x: 24.999, y: 0) + + // When + let newValue = circularSlider.newValue(from: circularSlider.endPointValue, touch: touchPosition, start: startPosition) + + // Then + XCTAssertEqual(newValue, 25, accuracy: 0.001) + } +} diff --git a/HGCircularSlider.xcodeproj/project.pbxproj b/HGCircularSlider.xcodeproj/project.pbxproj index 957f2dc..ed7a639 100755 --- a/HGCircularSlider.xcodeproj/project.pbxproj +++ b/HGCircularSlider.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + BB692D2E235C9EB300CB74DA /* HGCircularSliderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB692D2D235C9EB300CB74DA /* HGCircularSliderTests.swift */; }; + BB692D30235C9EB300CB74DA /* HGCircularSlider.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CCDBFDDB1E43366F005D6F08 /* HGCircularSlider.framework */; }; + BB692D37235C9F1100CB74DA /* CircularSliderHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB692D36235C9F1100CB74DA /* CircularSliderHelperTests.swift */; }; + BB692D39235C9F1C00CB74DA /* CircularSliderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB692D38235C9F1C00CB74DA /* CircularSliderTests.swift */; }; CCCC96461E9F7FD000999D34 /* MidPointCircularSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCCC96451E9F7FD000999D34 /* MidPointCircularSlider.swift */; }; CCDBFDE01E43366F005D6F08 /* HGCircularSlider.h in Headers */ = {isa = PBXBuildFile; fileRef = CCDBFDDE1E43366F005D6F08 /* HGCircularSlider.h */; settings = {ATTRIBUTES = (Public, ); }; }; CCDBFDFD1E4336C9005D6F08 /* .gitkeep in Resources */ = {isa = PBXBuildFile; fileRef = CCDBFDF61E4336C9005D6F08 /* .gitkeep */; }; @@ -16,7 +20,22 @@ CCDBFE021E4336C9005D6F08 /* RangeCircularSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = CCDBFDFC1E4336C9005D6F08 /* RangeCircularSlider.swift */; }; /* End PBXBuildFile section */ +/* Begin PBXContainerItemProxy section */ + BB692D31235C9EB300CB74DA /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = CCDBFDD21E43366F005D6F08 /* Project object */; + proxyType = 1; + remoteGlobalIDString = CCDBFDDA1E43366F005D6F08; + remoteInfo = HGCircularSlider; + }; +/* End PBXContainerItemProxy section */ + /* Begin PBXFileReference section */ + BB692D2B235C9EB300CB74DA /* HGCircularSliderTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HGCircularSliderTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + BB692D2D235C9EB300CB74DA /* HGCircularSliderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HGCircularSliderTests.swift; sourceTree = ""; }; + BB692D2F235C9EB300CB74DA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + BB692D36235C9F1100CB74DA /* CircularSliderHelperTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CircularSliderHelperTests.swift; path = Example/Tests/CircularSliderHelperTests.swift; sourceTree = SOURCE_ROOT; }; + BB692D38235C9F1C00CB74DA /* CircularSliderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CircularSliderTests.swift; path = Example/Tests/CircularSliderTests.swift; sourceTree = SOURCE_ROOT; }; CCCC96451E9F7FD000999D34 /* MidPointCircularSlider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MidPointCircularSlider.swift; sourceTree = ""; }; CCDBFDDB1E43366F005D6F08 /* HGCircularSlider.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = HGCircularSlider.framework; sourceTree = BUILT_PRODUCTS_DIR; }; CCDBFDDE1E43366F005D6F08 /* HGCircularSlider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HGCircularSlider.h; sourceTree = ""; }; @@ -29,6 +48,14 @@ /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ + BB692D28235C9EB300CB74DA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + BB692D30235C9EB300CB74DA /* HGCircularSlider.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; CCDBFDD71E43366F005D6F08 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -39,10 +66,22 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + BB692D2C235C9EB300CB74DA /* HGCircularSliderTests */ = { + isa = PBXGroup; + children = ( + BB692D36235C9F1100CB74DA /* CircularSliderHelperTests.swift */, + BB692D38235C9F1C00CB74DA /* CircularSliderTests.swift */, + BB692D2D235C9EB300CB74DA /* HGCircularSliderTests.swift */, + BB692D2F235C9EB300CB74DA /* Info.plist */, + ); + path = HGCircularSliderTests; + sourceTree = ""; + }; CCDBFDD11E43366F005D6F08 = { isa = PBXGroup; children = ( CCDBFDDD1E43366F005D6F08 /* HGCircularSlider */, + BB692D2C235C9EB300CB74DA /* HGCircularSliderTests */, CCDBFDDC1E43366F005D6F08 /* Products */, ); sourceTree = ""; @@ -51,6 +90,7 @@ isa = PBXGroup; children = ( CCDBFDDB1E43366F005D6F08 /* HGCircularSlider.framework */, + BB692D2B235C9EB300CB74DA /* HGCircularSliderTests.xctest */, ); name = Products; sourceTree = ""; @@ -100,6 +140,24 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXNativeTarget section */ + BB692D2A235C9EB300CB74DA /* HGCircularSliderTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = BB692D35235C9EB300CB74DA /* Build configuration list for PBXNativeTarget "HGCircularSliderTests" */; + buildPhases = ( + BB692D27235C9EB300CB74DA /* Sources */, + BB692D28235C9EB300CB74DA /* Frameworks */, + BB692D29235C9EB300CB74DA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + BB692D32235C9EB300CB74DA /* PBXTargetDependency */, + ); + name = HGCircularSliderTests; + productName = HGCircularSliderTests; + productReference = BB692D2B235C9EB300CB74DA /* HGCircularSliderTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; CCDBFDDA1E43366F005D6F08 /* HGCircularSlider */ = { isa = PBXNativeTarget; buildConfigurationList = CCDBFDE31E43366F005D6F08 /* Build configuration list for PBXNativeTarget "HGCircularSlider" */; @@ -124,9 +182,14 @@ CCDBFDD21E43366F005D6F08 /* Project object */ = { isa = PBXProject; attributes = { + LastSwiftUpdateCheck = 1110; LastUpgradeCheck = 1020; ORGANIZATIONNAME = intive; TargetAttributes = { + BB692D2A235C9EB300CB74DA = { + CreatedOnToolsVersion = 11.1; + ProvisioningStyle = Automatic; + }; CCDBFDDA1E43366F005D6F08 = { CreatedOnToolsVersion = 8.2.1; DevelopmentTeam = R6JBLAQ685; @@ -148,11 +211,19 @@ projectRoot = ""; targets = ( CCDBFDDA1E43366F005D6F08 /* HGCircularSlider */, + BB692D2A235C9EB300CB74DA /* HGCircularSliderTests */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ + BB692D29235C9EB300CB74DA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; CCDBFDD91E43366F005D6F08 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -164,6 +235,16 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ + BB692D27235C9EB300CB74DA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BB692D2E235C9EB300CB74DA /* HGCircularSliderTests.swift in Sources */, + BB692D39235C9F1C00CB74DA /* CircularSliderTests.swift in Sources */, + BB692D37235C9F1100CB74DA /* CircularSliderHelperTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; CCDBFDD61E43366F005D6F08 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -178,7 +259,56 @@ }; /* End PBXSourcesBuildPhase section */ +/* Begin PBXTargetDependency section */ + BB692D32235C9EB300CB74DA /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = CCDBFDDA1E43366F005D6F08 /* HGCircularSlider */; + targetProxy = BB692D31235C9EB300CB74DA /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + /* Begin XCBuildConfiguration section */ + BB692D33235C9EB300CB74DA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = HGCircularSliderTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.github.HGCircularSliderTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + BB692D34235C9EB300CB74DA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_STYLE = Automatic; + GCC_C_LANGUAGE_STANDARD = gnu11; + INFOPLIST_FILE = HGCircularSliderTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 13.1; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.github.HGCircularSliderTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; CCDBFDE11E43366F005D6F08 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -339,6 +469,15 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ + BB692D35235C9EB300CB74DA /* Build configuration list for PBXNativeTarget "HGCircularSliderTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + BB692D33235C9EB300CB74DA /* Debug */, + BB692D34235C9EB300CB74DA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; CCDBFDD51E43366F005D6F08 /* Build configuration list for PBXProject "HGCircularSlider" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/HGCircularSlider.xcodeproj/xcshareddata/xcschemes/HGCircularSlider.xcscheme b/HGCircularSlider.xcodeproj/xcshareddata/xcschemes/HGCircularSlider.xcscheme index 0883724..7c28849 100755 --- a/HGCircularSlider.xcodeproj/xcshareddata/xcschemes/HGCircularSlider.xcscheme +++ b/HGCircularSlider.xcodeproj/xcshareddata/xcschemes/HGCircularSlider.xcscheme @@ -28,9 +28,17 @@ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> + + + + - - - - maximumValue { endPointValue = maximumValue } - else if endPointValue < minimumValue { + if endPointValue < minimumValue { endPointValue = minimumValue } @@ -329,7 +329,7 @@ open class CircularSlider: UIControl { let interval = Interval(min: minimumValue, max: maximumValue, rounds: numberOfRounds) let deltaValue = CircularSliderHelper.delta(in: interval, for: angle, oldValue: oldValue) - var newValue = oldValue + deltaValue + var newValue = oldValue + deltaValue - minimumValue let range = maximumValue - minimumValue if !stopThumbAtMinMax { @@ -343,7 +343,4 @@ open class CircularSlider: UIControl { return newValue } - - - } diff --git a/HGCircularSliderTests/HGCircularSliderTests.swift b/HGCircularSliderTests/HGCircularSliderTests.swift new file mode 100644 index 0000000..afcf48c --- /dev/null +++ b/HGCircularSliderTests/HGCircularSliderTests.swift @@ -0,0 +1,33 @@ +// +// HGCircularSliderTests.swift +// HGCircularSliderTests +// +// Created by Hamza on 20/10/2019. +// Copyright © 2019 intive. All rights reserved. +// + +import XCTest + +class HGCircularSliderTests: XCTestCase { + + override func setUp() { + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testExample() { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. + } + + func testPerformanceExample() { + // This is an example of a performance test case. + measure { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/HGCircularSliderTests/Info.plist b/HGCircularSliderTests/Info.plist new file mode 100644 index 0000000..64d65ca --- /dev/null +++ b/HGCircularSliderTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + +