Skip to content

Commit d5370d0

Browse files
committed
Added SPDiffableSlider
1 parent 5381bfb commit d5370d0

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

SPDiffable.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
F4398D72255A67580047093F /* SPDiffableSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4398D71255A67580047093F /* SPDiffableSlider.swift */; };
11+
F4398D73255A67580047093F /* SPDiffableSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4398D71255A67580047093F /* SPDiffableSlider.swift */; };
1012
F47A41F324EB22A70054DBB2 /* RootController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47A41E524EB22A70054DBB2 /* RootController.swift */; };
1113
F47A41F524EB22A70054DBB2 /* DiffableTableController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47A41E624EB22A70054DBB2 /* DiffableTableController.swift */; };
1214
F47A41F724EB22A70054DBB2 /* SideBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F47A41E724EB22A70054DBB2 /* SideBarController.swift */; };
@@ -81,6 +83,7 @@
8183
/* End PBXCopyFilesBuildPhase section */
8284

8385
/* Begin PBXFileReference section */
86+
F4398D71255A67580047093F /* SPDiffableSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SPDiffableSlider.swift; sourceTree = "<group>"; };
8487
F47A41CE24EB222C0054DBB2 /* Example iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
8588
F47A41DE24EB222D0054DBB2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8689
F47A41E524EB22A70054DBB2 /* RootController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RootController.swift; sourceTree = "<group>"; };
@@ -243,6 +246,7 @@
243246
OBJ_32 /* SPDiffableSubtitleTableViewCell.swift */,
244247
OBJ_31 /* SPDiffableStepper.swift */,
245248
OBJ_33 /* SPDiffableSwitch.swift */,
249+
F4398D71255A67580047093F /* SPDiffableSlider.swift */,
246250
);
247251
path = Cells;
248252
sourceTree = "<group>";
@@ -418,6 +422,7 @@
418422
F47A420D24EB23220054DBB2 /* SPDiffableTableViewCell.swift in Sources */,
419423
F47A420424EB23220054DBB2 /* SPDiffableTableDataSource.swift in Sources */,
420424
F47A420F24EB23220054DBB2 /* SPDiffableSideBarController.swift in Sources */,
425+
F4398D72255A67580047093F /* SPDiffableSlider.swift in Sources */,
421426
F47A41F324EB22A70054DBB2 /* RootController.swift in Sources */,
422427
F47A421324EB23220054DBB2 /* SPDiffableSideBarItem.swift in Sources */,
423428
);
@@ -442,6 +447,7 @@
442447
OBJ_62 /* SPDiffableSnapshot.swift in Sources */,
443448
OBJ_63 /* SPDiffableTextHeaderFooter.swift in Sources */,
444449
OBJ_64 /* SPDiffableTableRow.swift in Sources */,
450+
F4398D73255A67580047093F /* SPDiffableSlider.swift in Sources */,
445451
OBJ_65 /* SPDiffableTableRowButton.swift in Sources */,
446452
OBJ_66 /* SPDiffableTableRowStepper.swift in Sources */,
447453
OBJ_67 /* SPDiffableTableRowSubtitle.swift in Sources */,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// The MIT License (MIT)
2+
// Copyright © 2020 Ivan Vorobei ([email protected])
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
import UIKit
23+
24+
open class SPDiffableSlider: UISlider {
25+
26+
var action: (_ value: Double) -> Void
27+
28+
public init(action: @escaping (Double) -> Void) {
29+
self.action = action
30+
super.init(frame: .zero)
31+
addTarget(self, action: #selector(self.valueChanged), for: .valueChanged)
32+
}
33+
34+
required public init?(coder: NSCoder) {
35+
self.action = { _ in }
36+
super.init(coder: coder)
37+
}
38+
39+
@objc func valueChanged() {
40+
action(Double(value))
41+
}
42+
}

0 commit comments

Comments
 (0)