-
Notifications
You must be signed in to change notification settings - Fork 1
/
Deprecated.swift
183 lines (141 loc) · 6.37 KB
/
Deprecated.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//
// Deprecated.swift
// Lipstick
//
// Created by Filip Dolnik on 18.10.16.
// Copyright © 2016 Brightify. All rights reserved.
//
import UIKit
@available(*, deprecated, renamed: "UIEdgeInsets.init(_:)")
public func insets(_ all: CGFloat) -> UIEdgeInsets {
return UIEdgeInsets(all)
}
@available(*, deprecated, renamed: "UIEdgeInsets.init(horizontal:vertical:)")
public func insets(horizontal: CGFloat = 0, vertical: CGFloat = 0) -> UIEdgeInsets {
return UIEdgeInsets(horizontal: horizontal, vertical: vertical)
}
@available(*, deprecated, renamed: "UIEdgeInsets.init(top:left:bottom:right:)")
public func insets(left: CGFloat = 0, top: CGFloat = 0, right: CGFloat = 0, bottom: CGFloat = 0) -> UIEdgeInsets {
return UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
}
@available(*, deprecated, renamed: "CGSize.init(_:)")
public func size(_ both: CGFloat) -> CGSize {
return CGSize(both)
}
@available(*, deprecated, renamed: "CGSize.init(width:height:)")
public func size(width: CGFloat = 0, height: CGFloat = 0) -> CGSize {
return CGSize(width: width, height: height)
}
@available(*, deprecated, renamed: "CGPoint.init(_:)")
public func point(_ both: CGFloat) -> CGPoint {
return CGPoint(both)
}
@available(*, deprecated, renamed: "CGPoint.init(x:y:)")
public func point(x: CGFloat = 0, y: CGFloat = 0) -> CGPoint {
return CGPoint(x: x, y: y)
}
@available(*, deprecated, renamed: "CGRect.init(x:y:width:height:)")
public func rect(x: CGFloat = 0, y: CGFloat = 0, width: CGFloat = 0, height: CGFloat = 0) -> CGRect {
return CGRect(x: x, y: y, width: width, height: height)
}
@available(*, deprecated, renamed: "UIFont.init(_:_:)")
public func font(_ name: String, _ size: CGFloat) -> UIFont {
return UIFont(name, size)
}
@available(*, deprecated, renamed: "UIFont.init(descriptor:size:)")
public func font(_ descriptor: UIFontDescriptor, _ size: CGFloat) -> UIFont {
return UIFont(descriptor: descriptor, size: size)
}
@available(*, deprecated, renamed: "UIImage.init(named:)")
public func image(_ name: String) -> UIImage? {
return UIImage(named: name)
}
@available(*, deprecated, message: "Replace with: UIColor(rgb: UInt)")
public func rgb(_ red: CGFloat, _ green: CGFloat, _ blue: CGFloat) -> UIColor {
return rgba(red, green, blue, 1)
}
@available(*, deprecated, message: "Replace with: UIColor(rgba: UInt)")
public func rgba(_ red: CGFloat, _ green: CGFloat, _ blue: CGFloat, _ alpha: CGFloat) -> UIColor {
return UIColor(red: red / 255, green: green / 255, blue: blue / 255, alpha: alpha)
}
@available(*, deprecated, renamed: "UIColor.init(hue:saturation:brightness:alpha:)")
public func hsl(_ hue: CGFloat, _ saturation: CGFloat, _ brightness: CGFloat) -> UIColor {
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: 1)
}
@available(*, deprecated, renamed: "UIColor.init(hue:saturation:brightness:alpha:)")
public func hsla(_ hue: CGFloat, _ saturation: CGFloat, _ brightness: CGFloat, _ alpha: CGFloat) -> UIColor {
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: alpha)
}
@available(*, deprecated, renamed: "UIOffset.init(horizontal:vertical:)")
public func offset(_ horizontal: CGFloat, vertical: CGFloat) -> UIOffset {
return UIOffset(horizontal: horizontal, vertical: vertical)
}
@available(*, deprecated, message: "Replace with: color.darker(by: percent)")
public func darken(_ color: UIColor, _ percent: CGFloat) -> UIColor {
return color.darker(by: percent)
}
@available(*, deprecated, message: "Replace with: color.lighter(by: percent)")
public func lighten(_ color: UIColor, _ percent: CGFloat) -> UIColor {
return color.lighter(by: percent)
}
@available(*, deprecated, message: "Replace with: color.saturated(by: percent)")
public func saturate(_ color: UIColor, _ percent: CGFloat) -> UIColor {
return color.saturated(by: percent)
}
@available(*, deprecated, message: "Replace with: color.desaturated(by: percent)")
public func desaturate(_ color: UIColor, _ percent: CGFloat) -> UIColor {
return color.desaturated(by: percent)
}
@available(*, deprecated, message: "Replace with: color.fadedIn(by: percent)")
public func fadein(_ color: UIColor, _ percent: CGFloat) -> UIColor {
return color.fadedIn(by: percent)
}
@available(*, deprecated, message: "Replace with: color.fadedOut(by: percent)")
public func fadeout(_ color: UIColor, _ percent: CGFloat) -> UIColor {
return color.fadedOut(by: percent)
}
@available(*, deprecated, message: "Replace with: UIColor(hex: hexString)")
public func color(_ hexString: String) -> UIColor {
return UIColor(hex: hexString)
}
extension UIButton {
@available(*, deprecated, message: "Replace with: UIButton().styled(using: styles)")
public convenience init(styles: (@escaping (UIButton) -> Void)...) {
self.init()
apply(styles: styles)
}
@available(*, deprecated, message: "Replace with: UIButton(title: title).styled(using: styles)")
public convenience init(title: String, styles: (@escaping (UIButton) -> Void)...) {
self.init()
self.setTitle(title, for: UIControlState())
apply(styles: styles)
}
}
extension UICollectionView {
@available(*, deprecated, message: "Replace with: UICollectionView(collectionViewLayout: layout).styled(using: styles)")
public convenience init(collectionViewLayout layout: UICollectionViewLayout, styles: ((UICollectionView) -> Void)...) {
self.init(collectionViewLayout: layout)
styles.forEach(apply)
}
}
extension UILabel {
@available(*, deprecated, message: "Replace with: UILabel(text: text).styled(using: styles)")
public convenience init(text: String, styles: (@escaping (UILabel) -> Void)...) {
self.init(text: text)
apply(styles: styles)
}
}
extension UITableView {
@available(*, deprecated, message: "Replace with: UITableView(style: style).styled(using: styles)")
public convenience init(style: UITableViewStyle, styles: ((UITableView) -> Void)...) {
self.init(style: style)
styles.forEach(apply)
}
}
extension UIWindow {
@available(*, deprecated, message: "Replace with: UIWindow(frame: frame).styled(using: styles)")
public convenience init(frame: CGRect, styles: (@escaping (UIWindow) -> Void)...) {
self.init(frame: frame)
apply(styles: styles)
}
}