Code Monkey home page Code Monkey logo

sweetui's Introduction

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. ๐ŸŒ

sweetui's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mohsinalimat

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.