Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit d103ff0

Browse files
committed
Updated objc extensions with prefixes
1 parent 539fa1a commit d103ff0

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

TimePicker/Classes/Extensions/NSLayoutConstraints.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,35 @@ import Foundation
1010

1111
extension NSLayoutConstraint {
1212

13-
static func horizontallyCentered(view: UIView, in superview: UIView) -> [NSLayoutConstraint] {
14-
return constraints(
13+
static func tp_horizontallyCentered(view: UIView, in superview: UIView) -> [NSLayoutConstraint] {
14+
return self.constraints(
1515
withVisualFormat: "V:[superview]-(<=1)-[view]",
1616
options: .alignAllCenterX,
1717
metrics: nil,
1818
views: ["superview": superview, "view": view]
1919
)
2020
}
2121

22-
static func verticallyCentered(view: UIView, in superview: UIView) -> [NSLayoutConstraint] {
23-
return constraints(
22+
static func tp_verticallyCentered(view: UIView, in superview: UIView) -> [NSLayoutConstraint] {
23+
return self.constraints(
2424
withVisualFormat: "H:[superview]-(<=1)-[view]",
2525
options: .alignAllCenterY,
2626
metrics: nil,
2727
views: ["superview": superview, "view": view]
2828
)
2929
}
3030

31-
static func alignHorizontally(view: UIView, trailingTo trailingView: UIView, distance: CGFloat = 0) -> [NSLayoutConstraint] {
32-
return constraints(
31+
static func tp_alignHorizontally(view: UIView, trailingTo trailingView: UIView, distance: CGFloat = 0) -> [NSLayoutConstraint] {
32+
return self.constraints(
3333
withVisualFormat: "H:[view]-distance-[trailingView]",
3434
options: NSLayoutFormatOptions(),
3535
metrics: ["distance": distance],
3636
views: ["view": view, "trailingView": trailingView]
3737
)
3838
}
3939

40-
static func alignHorizontally(view: UIView, leadingBy leadingView: UIView, distance: CGFloat = 0) -> [NSLayoutConstraint] {
41-
return constraints(
40+
static func tp_alignHorizontally(view: UIView, leadingBy leadingView: UIView, distance: CGFloat = 0) -> [NSLayoutConstraint] {
41+
return self.constraints(
4242
withVisualFormat: "H:[leadingView]-distance-[view]",
4343
options: NSLayoutFormatOptions(),
4444
metrics: ["distance": distance],

TimePicker/Classes/Extensions/UIGestureRecognizer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ extension UIGestureRecognizer {
1414
case upper, lower
1515
}
1616

17-
func locationType(in view: UIView) -> LocationType {
18-
return location(in: view).y < view.bounds.height / 2 ? .upper : .lower
17+
func tp_locationType(in view: UIView) -> LocationType {
18+
return self.location(in: view).y < view.bounds.height / 2 ? .upper : .lower
1919
}
2020

21-
func hasUpperLocationType(in view: UIView) -> Bool {
22-
return locationType(in: view) == .upper
21+
func tp_hasUpperLocationType(in view: UIView) -> Bool {
22+
return self.tp_locationType(in: view) == .upper
2323
}
2424

2525
}

TimePicker/Classes/TimePicker.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ extension TimePicker {
109109
switch gesture.state {
110110
case .began:
111111
calculator.beginUpdates()
112-
gesture.hasUpperLocationType(in: self) ? calculator.increment() : calculator.decrement()
112+
gesture.tp_hasUpperLocationType(in: self) ? calculator.increment() : calculator.decrement()
113113

114114
case .changed:
115115
()
@@ -120,7 +120,7 @@ extension TimePicker {
120120
}
121121

122122
@objc fileprivate func handleTapGesture(_ gesture: UITapGestureRecognizer) {
123-
gesture.hasUpperLocationType(in: self) ? calculator.increment() : calculator.decrement()
123+
gesture.tp_hasUpperLocationType(in: self) ? calculator.increment() : calculator.decrement()
124124
}
125125

126126
}
@@ -177,29 +177,29 @@ extension TimePicker {
177177
addSubview(
178178
colonLabel,
179179
constraints: (
180-
NSLayoutConstraint.horizontallyCentered(view: colonLabel, in: self) +
181-
NSLayoutConstraint.verticallyCentered(view: colonLabel, in: self)
180+
NSLayoutConstraint.tp_horizontallyCentered(view: colonLabel, in: self) +
181+
NSLayoutConstraint.tp_verticallyCentered(view: colonLabel, in: self)
182182
)
183183
)
184184
addSubview(
185185
hourLabel,
186186
constraints: (
187-
NSLayoutConstraint.alignHorizontally(view: hourLabel, trailingTo: colonLabel) +
188-
NSLayoutConstraint.verticallyCentered(view: hourLabel, in: self)
187+
NSLayoutConstraint.tp_alignHorizontally(view: hourLabel, trailingTo: colonLabel) +
188+
NSLayoutConstraint.tp_verticallyCentered(view: hourLabel, in: self)
189189
)
190190
)
191191
addSubview(
192192
timeLabel,
193193
constraints: (
194-
NSLayoutConstraint.alignHorizontally(view: timeLabel, leadingBy: colonLabel) +
195-
NSLayoutConstraint.verticallyCentered(view: timeLabel, in: self)
194+
NSLayoutConstraint.tp_alignHorizontally(view: timeLabel, leadingBy: colonLabel) +
195+
NSLayoutConstraint.tp_verticallyCentered(view: timeLabel, in: self)
196196
)
197197
)
198198
addSubview(
199199
periodLabel,
200200
constraints: (
201-
NSLayoutConstraint.alignHorizontally(view: periodLabel, leadingBy: timeLabel, distance: 8) +
202-
NSLayoutConstraint.verticallyCentered(view: periodLabel, in: self)
201+
NSLayoutConstraint.tp_alignHorizontally(view: periodLabel, leadingBy: timeLabel, distance: 8) +
202+
NSLayoutConstraint.tp_verticallyCentered(view: periodLabel, in: self)
203203
)
204204
)
205205
}

0 commit comments

Comments
 (0)