Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sobabear/addthen
🎨 Adding view sugar for UIKit with SwiftUI style
https://github.com/sobabear/addthen
cocoapods ios swift swiftpackagemanager swiftui xcode
Last synced: 3 days ago
JSON representation
🎨 Adding view sugar for UIKit with SwiftUI style
- Host: GitHub
- URL: https://github.com/sobabear/addthen
- Owner: sobabear
- License: mit
- Created: 2021-10-01T08:14:53.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-01-23T13:51:45.000Z (12 months ago)
- Last Synced: 2024-12-30T21:48:43.159Z (4 days ago)
- Topics: cocoapods, ios, swift, swiftpackagemanager, swiftui, xcode
- Language: Swift
- Homepage:
- Size: 61.5 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AddThen
[![CI Status](https://img.shields.io/travis/stareta1202/AddThen.svg?style=flat)](https://travis-ci.org/stareta1202/AddThen)
[![Version](https://img.shields.io/cocoapods/v/AddThen.svg?style=flat)](https://cocoapods.org/pods/AddThen)
[![License](https://img.shields.io/cocoapods/l/AddThen.svg?style=flat)](https://cocoapods.org/pods/AddThen)
[![Platform](https://img.shields.io/cocoapods/p/AddThen.svg?style=flat)](https://cocoapods.org/pods/AddThen)🎨 View instance sugar for Swift & UIKit
## ExampleAdd UIView & UIViewController code with **AddThen**
```swiftlet label = UILabel()
label.backgroundColor = .red
label.text = "Hello, World"...
view.addSubview(label)
```This is equivalent to :
```swift
let label = UILabel()...
view.add(label) {
$0.backgroundColor = .red
$0.text = "Hello, World!"
}view.add(
UIStackView {
UIButton()
UIView()
UIImageView()
}
)```
Also very useful with SnapKit```swift
let label = UILabel()...
view.add(label) {
$0.backgroundColor = .red
$0.text = "Hello, World!"
$0.snp.makeConstraints {
$0.edges.equalToSuperview()
}
}```
## More SwiftUIfully
```swift
/// in certain function in UIViewController
let label = UILabel()body {
label.then({ $0.textColor = .red })
UIButton()}
body {
if true {
UIView()
} else {
EmptyView() // EmptyView will not be added
}
}```
if you want to handle certain view which should not be added, use `Emptiable` or `EmptyView`
## Requirements
- iOS 9.0+ (11.0+ recommended)
- Xcode 12.0+
- Swfit 5.0## Installation
AddThen is available through [CocoaPods](https://cocoapods.org) & SPM. To install
it, simply add the following line to your Podfile:### cocoapod
```ruby
pod 'AddThen'
```
### Swift Package Manager
```swift
import PackageDescriptionlet package = Package(
name: "MyApp",
dependencies: [
.package(url: "https://github.com/sobabear/AddThen", .upToNextMajor(from: "1.2.3")),
]
)
```
## Author- Yongjun Lee, stareta1202
- Chanwoo Cho, [GREENOVER](https://github.com/GREENOVER)## License
AddThen is available under the MIT license. See the LICENSE file for more info.