Skip to content

Commit

Permalink
Merge pull request #162 from 0xLeif/develop
Browse files Browse the repository at this point in the history
Version 1.3
  • Loading branch information
0xLeif authored Jul 9, 2020
2 parents a960f27 + 8c2cb11 commit b0f6b26
Show file tree
Hide file tree
Showing 18 changed files with 629 additions and 254 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@ class ViewController: UIViewController {
Navigate.shared.configure(controller: navigationController)
.set(title: "Hello SwiftUIKit")
.setRight(barButton: BarButton {
Button({
Button("Button 0") {
print("Tapped the barbutton")
}) {
Label("Button 0")
}
})


view.embed {
SafeAreaView {
Table(defaultCellHeight: 60) {
List(defaultCellHeight: 60) {
[
Button("Say Hello") {
print("Hello World!")
Expand Down Expand Up @@ -57,10 +55,12 @@ class ViewController: UIViewController {
]
},

NavButton(destination: UIViewController {
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)
NavButton(destination: {
UIViewController {
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)
}
}
}, style: .push) {
Label("Go see a puppy")
Expand Down
18 changes: 18 additions & 0 deletions Sources/SwiftUIKit/Extensions/UIButton+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// UIButton+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 7/7/20.
//

import UIKit

public extension UIButton {
@discardableResult
func set(titleColor: UIColor?,
forState state: UIControl.State = .normal) -> Self {
setTitleColor(titleColor, for: state)

return self
}
}
37 changes: 37 additions & 0 deletions Sources/SwiftUIKit/Extensions/UIControl+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// UIControl+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 7/7/20.
//

import UIKit

public extension UIControl {
/// Set `isEnabled` for the view
@discardableResult
func enabled(if value: Bool = true) -> Self {
isEnabled = value

return self
}

/// Set `isEnabled` to `true` for the view
@discardableResult
func enable() -> Self {
enabled(if: true)
}

/// Set `isEnabled` to `false` for the view
@discardableResult
func disable() -> Self {
enabled(if: false)
}

@discardableResult
func tint(color: UIColor?) -> Self {
tintColor = color

return self
}
}
18 changes: 18 additions & 0 deletions Sources/SwiftUIKit/Extensions/UIImage+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// UIImage+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 7/7/20.
//

import UIKit

public extension UIImage {
var template: UIImage {
guard renderingMode != .alwaysTemplate else {
return self
}

return withRenderingMode(.alwaysTemplate)
}
}
24 changes: 24 additions & 0 deletions Sources/SwiftUIKit/Extensions/UIImageView+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// UIImageView+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 7/7/20.
//

import UIKit

public extension UIImageView {
@discardableResult
func templateImage() -> Self {
image = image?.template

return self
}

@discardableResult
func tint(color: UIColor?) -> Self {
tintColor = color

return self
}
}
26 changes: 26 additions & 0 deletions Sources/SwiftUIKit/Extensions/UISlider+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// UISlider+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 7/7/20.
//

import UIKit

public extension UISlider {
@discardableResult
func set(thumbImage: UIImage?,
forState state: UIControl.State = .normal) -> Self {
setThumbImage(thumbImage, for: state)

return self
}

@discardableResult
func tint(thumbColor: UIColor?) -> Self {
thumbTintColor = thumbColor

return self
}
}

29 changes: 29 additions & 0 deletions Sources/SwiftUIKit/Extensions/UISwitch+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// UISwitch+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 7/7/20.
//

import UIKit

public extension UISwitch {
@discardableResult
func turn(on: Bool) -> Self {
DispatchQueue.main.async {
self.isOn = on
}

return self
}

@discardableResult
func turnOn() -> Self {
turn(on: true)
}

@discardableResult
func turnOff() -> Self {
turn(on: false)
}
}
17 changes: 17 additions & 0 deletions Sources/SwiftUIKit/Extensions/UITextField+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// UITextField+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 7/7/20.
//

import UIKit

public extension UITextField {
@discardableResult
func text(color: UIColor?) -> Self {
textColor = color

return self
}
}
31 changes: 31 additions & 0 deletions Sources/SwiftUIKit/Extensions/UITextView+SwiftUIKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// UITextView+SwiftUIKit.swift
// SwiftUIKit
//
// Created by Zach Eriksen on 7/7/20.
//

import UIKit

public extension UITextView {
@discardableResult
func text(color: UIColor?) -> Self {
textColor = color

return self
}

@discardableResult
func tint(color: UIColor?) -> Self {
tintColor = color

return self
}

@discardableResult
func set(delegate: UITextViewDelegate?) -> Self {
self.delegate = delegate

return self
}
}
Loading

0 comments on commit b0f6b26

Please sign in to comment.