Skip to content

Commit 8e4945e

Browse files
authored
Merge pull request #126 from 0xLeif/develop
Release 1.1
2 parents faba15f + 80d6c53 commit 8e4945e

File tree

17 files changed

+1473
-111
lines changed

17 files changed

+1473
-111
lines changed

.github/workflows/swift.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Swift
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: macOS-latest
9+
strategy:
10+
matrix:
11+
destination: ['platform=iOS Simulator,OS=13.1,name=iPhone 8']
12+
xcode: ['/Applications/Xcode_11.1.app/Contents/Developer']
13+
steps:
14+
- uses: actions/checkout@v1
15+
# Github Actions' machines do in fact have recent versions of Xcode,
16+
# but you may have to explicitly switch to them. We explicitly want
17+
# to use Xcode 11, so we use xcode-select to switch to it.
18+
- name: Switch to Xcode 11
19+
run: sudo xcode-select --switch /Applications/Xcode_11.1.app
20+
# Since we want to be running our tests from Xcode, we need to
21+
# generate an .xcodeproj file. Luckly, Swift Package Manager has
22+
# build in functionality to do so.
23+
- name: Generate xcodeproj
24+
run: swift package generate-xcodeproj
25+
# Finally, we invoke xcodebuild to run the tests on an iPhone 11
26+
# simulator.
27+
- name: Run tests
28+
run: xcodebuild test -destination 'name=iPhone 11' -scheme 'SwiftUIKit-Package'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ViewController: UIViewController {
5858
},
5959

6060
NavButton(destination: UIViewController {
61-
View(backgroundColor: .white) {
61+
UIView(backgroundColor: .white) {
6262
LoadingImage(URL(string: "https://cdn11.bigcommerce.com/s-oe2q4reh/images/stencil/2048x2048/products/832/1401/Beige_Pekingese_Puppy__21677.1568609759.jpg")!)
6363
.contentMode(.scaleAspectFit)
6464
}
@@ -100,7 +100,7 @@ class ViewController: UIViewController {
100100

101101
# oneleif Project
102102

103-
![](https://github.com/oneleif/olWebsite/blob/master/Public/images/oneleif.png?raw=true)
103+
![](https://github.com/oneleif/olDocs/blob/master/assets/images/oneleif_logos/full_logo/oneleif_whiteback.png)
104104

105105
### Project Info
106106

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
//
2+
// CALayer+SwiftUIKit.swift
3+
// SwiftUIKit
4+
//
5+
// Created by Oskar on 08/03/2020.
6+
//
7+
8+
import UIKit
9+
10+
@available(iOS 9.0, *)
11+
public extension UIView {
12+
13+
/// Change layer's background color
14+
/// - Parameter color: You can use `UIColor.colorName.cgColor` to pass UIColor value
15+
@discardableResult
16+
func layer(backgroundColor color: CGColor?) -> Self {
17+
layer.backgroundColor = color
18+
19+
return self
20+
}
21+
22+
/// Change layer's background color
23+
@discardableResult
24+
func layer(backgroundColor color: UIColor?) -> Self {
25+
layer.backgroundColor = color?.cgColor
26+
27+
return self
28+
}
29+
30+
/// Change layer's content's gravity.
31+
/// - Parameter gravity: Will be used as layer's gravity.
32+
@discardableResult
33+
func layer(contentsGravity: CALayerContentsGravity) -> Self {
34+
layer.contentsGravity = contentsGravity
35+
36+
return self
37+
}
38+
39+
/// Change layer's corner radius.
40+
/// - Parameter radius: value, defines corner radius.
41+
@discardableResult
42+
func layer(cornerRadius: Float) -> Self {
43+
layer.cornerRadius = CGFloat(cornerRadius)
44+
45+
return self
46+
}
47+
48+
/// Change layer's border color.
49+
/// - Parameter color: use `UIColor.colorName.cgColor` to pass UIColor value.
50+
@discardableResult
51+
func layer(borderColor: CGColor?) -> Self {
52+
layer.borderColor = borderColor
53+
54+
return self
55+
}
56+
57+
/// Change layer's border color.
58+
@discardableResult
59+
func layer(borderColor: UIColor?) -> Self {
60+
layer.borderColor = borderColor?.cgColor
61+
62+
return self
63+
}
64+
65+
/// Change layer's border width.
66+
/// - Parameter width: Will be used as width value.
67+
@discardableResult
68+
func layer(borderWidth: Float) -> Self {
69+
layer.borderWidth = CGFloat(borderWidth)
70+
return self
71+
}
72+
73+
/// Change layer's opacity
74+
/// - Parameter value: Will be used as opacity value.
75+
@discardableResult
76+
func layer(opacity: Float) -> Self {
77+
layer.opacity = opacity
78+
79+
return self
80+
}
81+
82+
/// Change layer's isHidden value
83+
@discardableResult
84+
func layer(isHidden: Bool) -> Self {
85+
layer.isHidden = isHidden
86+
87+
return self
88+
}
89+
90+
/// Set masks to bounds value.
91+
@discardableResult
92+
func layer(masksToBounds: Bool) -> Self {
93+
layer.masksToBounds = masksToBounds
94+
95+
return self
96+
}
97+
98+
/// Set layer's mask.
99+
/// - Parameter layer: Allows to set existing type or create new one inside closure.
100+
@discardableResult
101+
func layer(mask: @autoclosure () -> CALayer?) -> Self {
102+
self.layer.mask = mask()
103+
104+
return self
105+
}
106+
107+
/// Set `isDoubleSided` parameter.
108+
@discardableResult
109+
func layer(isDoubleSided: Bool) -> Self {
110+
layer.isDoubleSided = isDoubleSided
111+
112+
return self
113+
}
114+
115+
/// Set masked corners value.
116+
/// - Parameter corners: You can pass exisiting value or create it inside closure
117+
@available(iOS 11.0, *)
118+
@discardableResult
119+
func layer(maskedCorners: @autoclosure () -> CACornerMask) -> Self {
120+
layer.maskedCorners = maskedCorners()
121+
122+
return self
123+
}
124+
125+
/// Set layer's shadow opacity.
126+
/// - Parameter opacity:
127+
@discardableResult
128+
func layer(shadowOpacity: Float) -> Self {
129+
layer.shadowOpacity = shadowOpacity
130+
131+
return self
132+
}
133+
134+
/// Change layer's shadow color.
135+
/// - Parameter color: Pass `UIColor.colorName.cgColor` to pass UIColor value
136+
@discardableResult
137+
func layer(shadowColor: CGColor?) -> Self {
138+
layer.shadowColor = shadowColor
139+
140+
return self
141+
}
142+
143+
/// Change layer's shadow color.
144+
@discardableResult
145+
func layer(shadowColor: UIColor?) -> Self {
146+
layer.shadowColor = shadowColor?.cgColor
147+
148+
return self
149+
}
150+
151+
/// Set layer's shadow radius. Takes `Float` and converts it to `CGFloat` for programmer's convenience
152+
/// - Parameter radius:
153+
@discardableResult
154+
func layer(shadowRadius: Float) -> Self {
155+
layer.shadowRadius = CGFloat(shadowRadius)
156+
157+
return self
158+
}
159+
160+
/// Changes layer's shadowOffset to given in parameter
161+
/// - Parameter offset: offset value, can be calculated using closure inside or just add ready one.
162+
@discardableResult
163+
func layer(shadowOffset: @autoclosure () -> CGSize) -> Self {
164+
layer.shadowOffset = shadowOffset()
165+
166+
return self
167+
}
168+
169+
/// Set shadow path by passing existing object or use curly braces to create own one.
170+
/// - Parameter path:
171+
@discardableResult
172+
func layer(shadowPath: @autoclosure () -> CGPath?) -> Self {
173+
layer.shadowPath = shadowPath()
174+
175+
return self
176+
}
177+
178+
/// Set layer's `allowsEdgeAntialiasing`.
179+
@discardableResult
180+
func layer(allowsEdgeAntialiasing: Bool) -> Self {
181+
layer.allowsEdgeAntialiasing = allowsEdgeAntialiasing
182+
183+
return self
184+
}
185+
186+
/// Set layer's `allowsGroupOpacity`.
187+
@discardableResult
188+
func layer(allowsGroupOpacity: Bool) -> Self {
189+
layer.allowsGroupOpacity = allowsGroupOpacity
190+
191+
return self
192+
}
193+
194+
/// Set layer's style.
195+
/// - Parameter style: You can pass exisiting value or create new one inside closure.
196+
@discardableResult
197+
func layer(style: @autoclosure () -> [AnyHashable: Any]?) -> Self {
198+
layer.style = style()
199+
200+
return self
201+
}
202+
203+
/// Set layer's filters.
204+
/// - Parameter filters: You can pass exisiting value or create new one inside closure.
205+
@discardableResult
206+
func layer(filters: @autoclosure () -> [Any]?) -> Self {
207+
layer.filters = filters()
208+
209+
return self
210+
}
211+
212+
/// Set layer's `isOpaque` Boolean.
213+
@discardableResult
214+
func layer(isOpaque: Bool) -> Self {
215+
layer.isOpaque = isOpaque
216+
217+
return self
218+
}
219+
220+
/// Set layer's `drawsAsynchronously`
221+
@discardableResult
222+
func layer(drawsAsynchronously: Bool) -> Self {
223+
layer.drawsAsynchronously = drawsAsynchronously
224+
225+
return self
226+
}
227+
228+
/// Add animation to a layer.
229+
/// - Parameters:
230+
/// - key: Key which allows to identify given animation.
231+
/// - animation: You can pass existing value or create it inside closure.
232+
@discardableResult
233+
func layer(addAnimation animation: CAAnimation, forKey key: String?) -> Self {
234+
layer.add(animation, forKey: key)
235+
236+
return self
237+
}
238+
239+
/// Remove layer's animation specified by given key.
240+
/// - Parameter key: Key that's assigned to animation.
241+
@discardableResult
242+
func layer(removeAnimationForKey key: String) -> Self {
243+
layer.removeAnimation(forKey: key)
244+
245+
return self
246+
}
247+
248+
/// Remove all existing layer's animations.
249+
@discardableResult
250+
func removeAllAnimationsFromLayer() -> Self {
251+
layer.removeAllAnimations()
252+
253+
return self
254+
}
255+
256+
/// Modify the object's layer
257+
/// - Parameters:
258+
/// - closure: A trailing closure that receives itself.layer inside the closue
259+
@discardableResult
260+
func layer(_ closure: (CALayer) -> Void) -> Self {
261+
closure(layer)
262+
263+
return self
264+
}
265+
}

Sources/SwiftUIKit/Extensions/NSMutableAttributedString+SwiftUIKit.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public extension StringAttributes {
3333
/// - value: The value for the attribute being modifed
3434
@discardableResult
3535
mutating func add(key: AttributedStringKey, value: Any) -> StringAttributes {
36-
3736
self[key] = value
3837

3938
return self
@@ -48,7 +47,6 @@ public extension NSMutableAttributedString {
4847
/// - range: Closed Int Range. Example: 0 ... 3
4948
@discardableResult
5049
func set(attributes: StringAttributes, range: ClosedRange<Int>) -> Self {
51-
5250
self.setAttributes(attributes, range: NSRange(location: range.lowerBound, length: range.upperBound))
5351

5452
return self

Sources/SwiftUIKit/Extensions/UIAlertAction+SwiftUIKit.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public extension UIAlertAction {
1313
return UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
1414
}
1515

16-
1716
/// Quick Dismiss UIAlertAction
1817
class var dismiss: UIAlertAction {
1918
return UIAlertAction(title: "Dismiss", style: .cancel, handler: nil)

0 commit comments

Comments
 (0)