Skip to content

Commit a960f27

Browse files
authored
Merge pull request #158 from 0xLeif/develop
v1.2
2 parents 36b9886 + af87e07 commit a960f27

File tree

12 files changed

+1753
-41
lines changed

12 files changed

+1753
-41
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,28 +104,34 @@ class ViewController: UIViewController {
104104

105105
****
106106

107-
# oneleif Project
107+
## oneleif project
108+
This means that the project is sponsored by the oneleif community, and the collaborators are team members from oneleif.
108109

109-
![](https://github.com/oneleif/olDocs/blob/master/assets/images/oneleif_logos/full_logo/oneleif_whiteback.png)
110+
<a href="http://oneleif.com" rel="oneleif website">![](https://github.com/oneleif/olDocs/blob/master/assets/images/oneleif_logos/full_logo/oneleif_whiteback.png)</a>
110111

111-
### Project Info
112112

113-
This project is a oneleif active project.
114113

115114
[![](https://img.shields.io/badge/oneleif-Twitter-blue.svg)](https://twitter.com/oneleifdev)
116115

117116
[![](https://img.shields.io/badge/oneleif-YouTube-red.svg)](https://www.youtube.com/channel/UC3HN0jID38K0Vb_WChvgQmA)
118117

118+
## What is oneleif?
119+
oneleif is a nonprofit community that supports tech minded individuals. We do this by offering a fun loving community that works on Open Sourced projects together.
120+
We love to give back through free resources and guidance.
121+
119122
## How to join oneleif
120123
Click on the link below to join the Discord server.
121124

122-
You will start with limited permissions, in a text channel that only moderators will see.
125+
[![](https://img.shields.io/badge/oneleif-Discord-7284be.svg)](https://discord.gg/tv9UdJK)
123126

124-
To get full access: read the rules, make an introduction in #introductions, and add an appropriate username.
127+
-OR-
125128

126-
When you're done with the above, shoot a message to the #start channel to let us know, and we will give you full access.
129+
[Check out our website](http://oneleif.com)
127130

128-
[![](https://img.shields.io/badge/oneleif-Discord-7284be.svg)](https://discord.gg/tv9UdJK)
129131

130132
### Questions?
131133
Feel free to email us at: [email protected]
134+
135+
-OR-
136+
137+
Ask questions in the discord
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// NSLayoutConstraint+SwiftUIKit.swift
3+
// SwiftUIKit
4+
//
5+
// Created by Zach Eriksen on 5/17/20.
6+
//
7+
8+
import UIKit
9+
10+
@available(iOS 10.0, *)
11+
public extension NSLayoutConstraint {
12+
13+
/// Check if the `constraint` is connected to the `anchor`
14+
func isConnected<T>(toAnchor anchor: NSLayoutAnchor<T>) -> Bool {
15+
firstAnchor == anchor || secondAnchor == anchor
16+
}
17+
}
18+
19+
@available(iOS 10.0, *)
20+
public extension UIView {
21+
22+
/// The leading constraints held by the view
23+
var leadingConstraints: [NSLayoutConstraint] {
24+
constraints.filter { (constraint) -> Bool in
25+
constraint.isConnected(toAnchor: leadingAnchor)
26+
}
27+
}
28+
29+
/// The trailing constraints held by the view
30+
var trailingConstraints: [NSLayoutConstraint] {
31+
constraints.filter { (constraint) -> Bool in
32+
constraint.isConnected(toAnchor: trailingAnchor)
33+
}
34+
}
35+
36+
/// The top constraints held by the view
37+
var topConstraints: [NSLayoutConstraint] {
38+
constraints.filter { (constraint) -> Bool in
39+
constraint.isConnected(toAnchor: topAnchor)
40+
}
41+
}
42+
43+
/// The bottom constraints held by the view
44+
var bottomConstraints: [NSLayoutConstraint] {
45+
constraints.filter { (constraint) -> Bool in
46+
constraint.isConnected(toAnchor: bottomAnchor)
47+
}
48+
}
49+
}

Sources/SwiftUIKit/Extensions/UIView+SwiftUIKit.swift

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,48 @@ public extension UIView {
292292
return self
293293
}
294294

295+
/// Update a padding anchor's constant value
296+
@available(iOS 10.0, *)
297+
@discardableResult
298+
func update(padding: Padding) -> Self {
299+
switch padding {
300+
case .top(let value):
301+
topConstraints.first?.constant = CGFloat(value)
302+
case .bottom(let value):
303+
bottomConstraints.first?.constant = CGFloat(-value)
304+
case .leading(let value):
305+
leadingConstraints.first?.constant = CGFloat(value)
306+
case .trailing(let value):
307+
trailingConstraints.first?.constant = CGFloat(-value)
308+
}
309+
310+
return self
311+
}
312+
313+
/// Update an array of padding anchors' constant values
314+
@available(iOS 10.0, *)
315+
@discardableResult
316+
func update(padding: [Padding]) -> Self {
317+
padding.forEach { update(padding: $0) }
318+
319+
return self
320+
}
321+
322+
/// Update all padding anchors' constant value
323+
@available(iOS 10.0, *)
324+
@discardableResult
325+
func update(padding: Float) -> Self {
326+
update(padding: [
327+
.top(padding),
328+
.bottom(padding),
329+
.leading(padding),
330+
.trailing(padding)
331+
])
332+
333+
return self
334+
}
335+
336+
295337
/// Remove the height anchor constraint
296338
@available(iOS 10.0, *)
297339
@discardableResult
@@ -432,7 +474,7 @@ public extension UIView {
432474
/// - animated: Should animate setting the left UIBarButtonItem
433475
@discardableResult
434476
func navigateSetLeft(barButton: UIBarButtonItem?, animated: Bool = true) -> Self {
435-
Navigate.shared.setLeft(barButton: barButton)
477+
Navigate.shared.setLeft(barButton: barButton, animated: animated)
436478

437479
return self
438480
}
@@ -443,7 +485,7 @@ public extension UIView {
443485
/// - animated: Should animate setting the right UIBarButtonItem
444486
@discardableResult
445487
func navigateSetRight(barButton: UIBarButtonItem?, animated: Bool = true) -> Self {
446-
Navigate.shared.setRight(barButton: barButton)
488+
Navigate.shared.setRight(barButton: barButton, animated: animated)
447489

448490
return self
449491
}
@@ -454,7 +496,7 @@ public extension UIView {
454496
/// - animated: Should animate setting the left [UIBarButtonItem]
455497
@discardableResult
456498
func navigateSetLeft(barButtons: [UIBarButtonItem]?, animated: Bool = true) -> Self {
457-
Navigate.shared.setLeft(barButtons: barButtons)
499+
Navigate.shared.setLeft(barButtons: barButtons, animated: animated)
458500

459501
return self
460502
}
@@ -465,7 +507,7 @@ public extension UIView {
465507
/// - animated: Should animate setting the right [UIBarButtonItem]
466508
@discardableResult
467509
func navigateSetRight(barButtons: [UIBarButtonItem]?, animated: Bool = true) -> Self {
468-
Navigate.shared.setRight(barButtons: barButtons)
510+
Navigate.shared.setRight(barButtons: barButtons, animated: animated)
469511

470512
return self
471513
}

0 commit comments

Comments
 (0)