Allegory is a library built to resemble SwiftUI as much as possible built on top of UIKit for use on iOS versions starting from iOS 10.
See Progress
Allegory is designed to be almost identical to SwiftUI, except that the body of your views returns SomeView
instead of some View
.
struct Counter: View {
@State var count: Int
let limit: Int
var body: SomeView {
if count < limit {
VStack {
Button("Increment") { count = 1 }
Text("\(count)")
}
// Not yet implemented
// .onAppear { print("Counter.VStack onAppear") }
// .onDisappear { print("Counter.VStack onDisappear") }
} else {
VStack { Text("Limit exceeded") }
}
}
}
@main
struct CounterApp: App {
var body: SomeScene {
WindowGroup("Counter Demo") {
Counter(count: 5, limit: 15)
}
}
}
With CocoaPods
Add the following line to your Podfile:
pod 'Allegory', '~> 0.0.2'
In Xcode 12.3 go to File -> Swift Packages -> Add Package Dependency
and enter there URL of this repo
https://github.com/mgray88/Allegory
Allegory is a highly dynamic work in progress. Much of it is not ready for use.
- Twitter: @MikeMgray88
Many, many thanks to these other open source projects and resources that have inspired and provided insight on the inner workings of SwiftUI
- Mockingbird and MockingbirdUIKit
- RxSwiftWidgets
- UIKitPlus
- Tokamak
- SwiftUI Layout Explained @ objc.io
- SwiftUI State Explained @ objc.io
SwiftUI is a trademark owned by Apple Inc. Software maintained as a part of the Allegory project is not affiliated with Apple Inc.
Allegory is available under the MIT license. See LICENSE for more info.