diff --git a/Slider.xcodeproj/project.xcworkspace/xcuserdata/ramizkichibekov.xcuserdatad/UserInterfaceState.xcuserstate b/Slider.xcodeproj/project.xcworkspace/xcuserdata/ramizkichibekov.xcuserdatad/UserInterfaceState.xcuserstate index 368b816..277922b 100644 Binary files a/Slider.xcodeproj/project.xcworkspace/xcuserdata/ramizkichibekov.xcuserdatad/UserInterfaceState.xcuserstate and b/Slider.xcodeproj/project.xcworkspace/xcuserdata/ramizkichibekov.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Slider.xcodeproj/xcshareddata/xcschemes/Slider_Example.xcscheme b/Slider.xcodeproj/xcshareddata/xcschemes/Slider_Example.xcscheme new file mode 100644 index 0000000..c9e548f --- /dev/null +++ b/Slider.xcodeproj/xcshareddata/xcschemes/Slider_Example.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Slider/.gitignore b/Slider/.gitignore new file mode 100644 index 0000000..3b29812 --- /dev/null +++ b/Slider/.gitignore @@ -0,0 +1,9 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +xcuserdata/ +DerivedData/ +.swiftpm/config/registries.json +.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata +.netrc diff --git a/Slider/Package.swift b/Slider/Package.swift new file mode 100644 index 0000000..e0940de --- /dev/null +++ b/Slider/Package.swift @@ -0,0 +1,23 @@ +// swift-tools-version: 5.7 + +import PackageDescription + +let package = Package( + name: "Slider", + platforms: [.iOS(.v13)], + products: [ + .library( + name: "Slider", + targets: ["Slider"]), + ], + dependencies: [], + targets: [ + .target( + name: "Slider", + dependencies: []), + .testTarget( + name: "SliderTests", + dependencies: ["Slider"]), + ], + swiftLanguageVersions: [.v5] +) diff --git a/Slider/Protocols/Protocols.swift b/Slider/Protocols/Protocols.swift index 2a94ab3..41c7574 100644 --- a/Slider/Protocols/Protocols.swift +++ b/Slider/Protocols/Protocols.swift @@ -23,7 +23,8 @@ // import UIKit -@objc public protocol SliderDelegate: AnyObject { +@objc +public protocol SliderDelegate: AnyObject { func slider(_ slider: Slider, displayTextForValue value: CGFloat) -> String func didBeginTracking(_ slider: Slider) func didContinueTracking(_ slider: Slider) diff --git a/Slider/README.md b/Slider/README.md new file mode 100644 index 0000000..26f7c78 --- /dev/null +++ b/Slider/README.md @@ -0,0 +1,3 @@ +# Slider + +A description of this package. diff --git a/Slider/Slider.swift b/Slider/Slider.swift index 1666ee4..cf6f4bb 100644 --- a/Slider/Slider.swift +++ b/Slider/Slider.swift @@ -235,7 +235,7 @@ open class Slider: UIControl { final public var usableTrackingLength: CGFloat = .zero private let trackMaskLayer = CAShapeLayer() - // MARK: - Life cycle + // MARK: - Initial methods required public override init(frame: CGRect) { super.init(frame: frame) @@ -253,6 +253,8 @@ open class Slider: UIControl { commonInit() } + // MARK: - Life cycle + public override func layoutSubviews() { super.layoutSubviews() @@ -271,8 +273,7 @@ open class Slider: UIControl { redrawLayers() } - // MARK: - Custom methods - // MARK: Private methods + // MARK: - Private methods private func initialControl() { backgroundColor = .clear @@ -347,7 +348,7 @@ open class Slider: UIControl { translatesAutoresizingMaskIntoConstraints = false } - // MARK: - Update methods + // MARK: Update methods private func reinitComponentValues() { trackLayer.minimumValue = minimum diff --git a/Slider/SliderTrackLayer.swift b/Slider/SliderTrackLayer.swift index b239999..524577c 100644 --- a/Slider/SliderTrackLayer.swift +++ b/Slider/SliderTrackLayer.swift @@ -26,6 +26,8 @@ import UIKit public final class SliderTrackLayer: CALayer { + // MARK: - Properties + public var value: CGFloat = .zero public var minimumValue: CGFloat = .zero public var maximumValue: CGFloat = 1 @@ -33,6 +35,8 @@ public final class SliderTrackLayer: CALayer { public var trackMaxColor: UIColor! public var trackMinColor: UIColor! + // MARK: - Life cycle + override public func draw(in ctx: CGContext) { ctx.setFillColor(trackMaxColor.cgColor) ctx.addPath(UIBezierPath(roundedRect: bounds, cornerRadius: cornerRadius).cgPath) diff --git a/Slider/Tests/SliderTests/SliderTests.swift b/Slider/Tests/SliderTests/SliderTests.swift new file mode 100644 index 0000000..94d88e1 --- /dev/null +++ b/Slider/Tests/SliderTests/SliderTests.swift @@ -0,0 +1,8 @@ +import XCTest +@testable import Slider + +final class SliderTests: XCTestCase { + func testExample() throws { + XCTAssertEqual(0, 0) + } +}