Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 23, 2022. It is now read-only.

maximkrouk/SweetUI

Repository files navigation

SweetUI 🍯

SwiftUI-like declarative UIKit based framework.

SwiftUI is great but still lacks some useful features of UIKit and doesn't support older versions of iOS. This framework will allow you to use UIKit in a declarative way, pretty similar to the SwiftUI, but with support of iOS 10+ and well-known behavior of the system.

Usage

// JUMPING BUTTON EXAMPLE
import SweetUI
class ViewController: UIViewController {
 
 private(set) var button: UIButton?
 override func viewDidLoad() {
 super.viewDidLoad()
 // Setup view
 view.ui.add {
 	// Add title
 UILabel(text: "Jumping button", alignment: .center, color: .red).ui
 .font(.systemFont(ofSize: 32, weight: .semibold))
 .center(.init(x: view.center.x, y: view.center.y - 60))
 .size(.init(width: CGRect.screen.width, height: 32))
 
 	// Add button
 UIButton(title: "Tap me!") { [weak self] in
 print("The button was tapped.")
 let position0 = self?.button?.center ?? .zero
 let position1 = CGPoint(x: position0.x, y: position0.y - 32)
 self?.button?.ui
 .animate(.sequence,								// Perform one by one
 .move(center: position1, // Jump up
 duration: 0.1),
 .move(center: position0, // Fall down
 duration: 0.1))
 }.ui
 .link(to: &button) // Store UIButton in self.button
 .title(color: .blue)
 .center(view.center)
 .size(.init(width: 100, height: 32))
 }
 }
 
}

(Working on new features and documentation)

Initialization

SwiftUI provides custom convenience initializers for your views.

ViewProxy

SweetUI provides some proxies for interaction with your view's properties. You can access these DSLs via SomeView.ui property, which returns a ViewProxy or it's successor's instance.

LayoutProxy

SweetUI provides some proxies for interaction with your view's properties. You can access these DSLs via SomeView.layout or SomeViewProxy.layout property, which returns a LayoutProxy or it's successor's instance.

Requirements

  • ⌨️ XCode12+
  • πŸ“± iOS 10.0+

Installation

SUILayout is available through SwiftPM

.package(url: "https://github.com/maximkrouk/SweetUI.git", from: "1.0.0-beta.3.7")
.product(name: "SweetUI", package: "SweetUI")

License

SweetUI is available under the MIT license. See the LICENSE file for more info.

To-do

  • Conditional building βœ…
  • Add DSL's for every UIView subclass.
  • Add convenience methods for user interaction, such as tapAction(_ execute: () -> Void) βœ…
  • Complete Xcode documentation.
  • Provide more examples.
  • Add API for shadows. βœ…
  • Add more animation templates. βœ…
  • Add layout engine. βœ…
  • Make some API improvements.
  • Provide DSLs for UIViewControllers.
  • Mix sequential and parallel animations.

Feel free to contribute or communicate. SweetUI is open to your ideas. 🌝

About

Declarative SwiftUI-like framework, based on UIKit. (pre-alpha actually yet πŸ˜”)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /