Skip to content

Commit

Permalink
Merge pull request #126 from 0xLeif/develop
Browse files Browse the repository at this point in the history
Release 1.1
  • Loading branch information
0xLeif authored Apr 27, 2020
2 parents faba15f + 80d6c53 commit 8e4945e
Show file tree
Hide file tree
Showing 17 changed files with 1,473 additions and 111 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Swift

on: [push]

jobs:
build:

runs-on: macOS-latest
strategy:
matrix:
destination: ['platform=iOS Simulator,OS=13.1,name=iPhone 8']
xcode: ['/Applications/Xcode_11.1.app/Contents/Developer']
steps:
- uses: actions/checkout@v1
# Github Actions' machines do in fact have recent versions of Xcode,
# but you may have to explicitly switch to them. We explicitly want
# to use Xcode 11, so we use xcode-select to switch to it.
- name: Switch to Xcode 11
run: sudo xcode-select --switch /Applications/Xcode_11.1.app
# Since we want to be running our tests from Xcode, we need to
# generate an .xcodeproj file. Luckly, Swift Package Manager has
# build in functionality to do so.
- name: Generate xcodeproj
run: swift package generate-xcodeproj
# Finally, we invoke xcodebuild to run the tests on an iPhone 11
# simulator.
- name: Run tests
run: xcodebuild test -destination 'name=iPhone 11' -scheme 'SwiftUIKit-Package'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ViewController: UIViewController {
},

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

# oneleif Project

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

### Project Info

Expand Down
265 changes: 265 additions & 0 deletions Sources/SwiftUIKit/Extensions/CALayer+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
//
// CALayer+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Oskar on 08/03/2020.
//

import UIKit

@available(iOS 9.0, *)
public extension UIView {

/// Change layer's background color
/// - Parameter color: You can use `UIColor.colorName.cgColor` to pass UIColor value
@discardableResult
func layer(backgroundColor color: CGColor?) -> Self {
layer.backgroundColor = color

return self
}

/// Change layer's background color
@discardableResult
func layer(backgroundColor color: UIColor?) -> Self {
layer.backgroundColor = color?.cgColor

return self
}

/// Change layer's content's gravity.
/// - Parameter gravity: Will be used as layer's gravity.
@discardableResult
func layer(contentsGravity: CALayerContentsGravity) -> Self {
layer.contentsGravity = contentsGravity

return self
}

/// Change layer's corner radius.
/// - Parameter radius: value, defines corner radius.
@discardableResult
func layer(cornerRadius: Float) -> Self {
layer.cornerRadius = CGFloat(cornerRadius)

return self
}

/// Change layer's border color.
/// - Parameter color: use `UIColor.colorName.cgColor` to pass UIColor value.
@discardableResult
func layer(borderColor: CGColor?) -> Self {
layer.borderColor = borderColor

return self
}

/// Change layer's border color.
@discardableResult
func layer(borderColor: UIColor?) -> Self {
layer.borderColor = borderColor?.cgColor

return self
}

/// Change layer's border width.
/// - Parameter width: Will be used as width value.
@discardableResult
func layer(borderWidth: Float) -> Self {
layer.borderWidth = CGFloat(borderWidth)
return self
}

/// Change layer's opacity
/// - Parameter value: Will be used as opacity value.
@discardableResult
func layer(opacity: Float) -> Self {
layer.opacity = opacity

return self
}

/// Change layer's isHidden value
@discardableResult
func layer(isHidden: Bool) -> Self {
layer.isHidden = isHidden

return self
}

/// Set masks to bounds value.
@discardableResult
func layer(masksToBounds: Bool) -> Self {
layer.masksToBounds = masksToBounds

return self
}

/// Set layer's mask.
/// - Parameter layer: Allows to set existing type or create new one inside closure.
@discardableResult
func layer(mask: @autoclosure () -> CALayer?) -> Self {
self.layer.mask = mask()

return self
}

/// Set `isDoubleSided` parameter.
@discardableResult
func layer(isDoubleSided: Bool) -> Self {
layer.isDoubleSided = isDoubleSided

return self
}

/// Set masked corners value.
/// - Parameter corners: You can pass exisiting value or create it inside closure
@available(iOS 11.0, *)
@discardableResult
func layer(maskedCorners: @autoclosure () -> CACornerMask) -> Self {
layer.maskedCorners = maskedCorners()

return self
}

/// Set layer's shadow opacity.
/// - Parameter opacity:
@discardableResult
func layer(shadowOpacity: Float) -> Self {
layer.shadowOpacity = shadowOpacity

return self
}

/// Change layer's shadow color.
/// - Parameter color: Pass `UIColor.colorName.cgColor` to pass UIColor value
@discardableResult
func layer(shadowColor: CGColor?) -> Self {
layer.shadowColor = shadowColor

return self
}

/// Change layer's shadow color.
@discardableResult
func layer(shadowColor: UIColor?) -> Self {
layer.shadowColor = shadowColor?.cgColor

return self
}

/// Set layer's shadow radius. Takes `Float` and converts it to `CGFloat` for programmer's convenience
/// - Parameter radius:
@discardableResult
func layer(shadowRadius: Float) -> Self {
layer.shadowRadius = CGFloat(shadowRadius)

return self
}

/// Changes layer's shadowOffset to given in parameter
/// - Parameter offset: offset value, can be calculated using closure inside or just add ready one.
@discardableResult
func layer(shadowOffset: @autoclosure () -> CGSize) -> Self {
layer.shadowOffset = shadowOffset()

return self
}

/// Set shadow path by passing existing object or use curly braces to create own one.
/// - Parameter path:
@discardableResult
func layer(shadowPath: @autoclosure () -> CGPath?) -> Self {
layer.shadowPath = shadowPath()

return self
}

/// Set layer's `allowsEdgeAntialiasing`.
@discardableResult
func layer(allowsEdgeAntialiasing: Bool) -> Self {
layer.allowsEdgeAntialiasing = allowsEdgeAntialiasing

return self
}

/// Set layer's `allowsGroupOpacity`.
@discardableResult
func layer(allowsGroupOpacity: Bool) -> Self {
layer.allowsGroupOpacity = allowsGroupOpacity

return self
}

/// Set layer's style.
/// - Parameter style: You can pass exisiting value or create new one inside closure.
@discardableResult
func layer(style: @autoclosure () -> [AnyHashable: Any]?) -> Self {
layer.style = style()

return self
}

/// Set layer's filters.
/// - Parameter filters: You can pass exisiting value or create new one inside closure.
@discardableResult
func layer(filters: @autoclosure () -> [Any]?) -> Self {
layer.filters = filters()

return self
}

/// Set layer's `isOpaque` Boolean.
@discardableResult
func layer(isOpaque: Bool) -> Self {
layer.isOpaque = isOpaque

return self
}

/// Set layer's `drawsAsynchronously`
@discardableResult
func layer(drawsAsynchronously: Bool) -> Self {
layer.drawsAsynchronously = drawsAsynchronously

return self
}

/// Add animation to a layer.
/// - Parameters:
/// - key: Key which allows to identify given animation.
/// - animation: You can pass existing value or create it inside closure.
@discardableResult
func layer(addAnimation animation: CAAnimation, forKey key: String?) -> Self {
layer.add(animation, forKey: key)

return self
}

/// Remove layer's animation specified by given key.
/// - Parameter key: Key that's assigned to animation.
@discardableResult
func layer(removeAnimationForKey key: String) -> Self {
layer.removeAnimation(forKey: key)

return self
}

/// Remove all existing layer's animations.
@discardableResult
func removeAllAnimationsFromLayer() -> Self {
layer.removeAllAnimations()

return self
}

/// Modify the object's layer
/// - Parameters:
/// - closure: A trailing closure that receives itself.layer inside the closue
@discardableResult
func layer(_ closure: (CALayer) -> Void) -> Self {
closure(layer)

return self
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public extension StringAttributes {
/// - value: The value for the attribute being modifed
@discardableResult
mutating func add(key: AttributedStringKey, value: Any) -> StringAttributes {

self[key] = value

return self
Expand All @@ -48,7 +47,6 @@ public extension NSMutableAttributedString {
/// - range: Closed Int Range. Example: 0 ... 3
@discardableResult
func set(attributes: StringAttributes, range: ClosedRange<Int>) -> Self {

self.setAttributes(attributes, range: NSRange(location: range.lowerBound, length: range.upperBound))

return self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public extension UIAlertAction {
return UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
}


/// Quick Dismiss UIAlertAction
class var dismiss: UIAlertAction {
return UIAlertAction(title: "Dismiss", style: .cancel, handler: nil)
Expand Down
Loading

0 comments on commit 8e4945e

Please sign in to comment.