Giter Club home page Giter Club logo

uicodekit's Introduction

UICodeKIT (Beta)

Version License Platform

Simple, Fast and Easy.

Introduction

UICodeKit is a UIKit ViewCode Framework alternative to help you assemble your controllers in just a few steps.

How to use

Basically you just need to follow like this example below.

You get with code below

HomeView.swift

class HomeView: BaseView {
    
    // MARK: Actions
    
    var createAccountAction: UICodeDefaultAction?
    
    // MARK: Properties
    
    lazy var titleLabel = UILabel() .. {
        $0.text = "Create an account"
        $0.font = .systemFont(ofSize: 26, weight: .heavy)
    }
    
    lazy var usernameTextField = UITextField() .. {
        $0.placeholder = "Email Address"
        $0.backgroundColor = .white
        $0.layer.cornerRadius = 6
        $0.height(40)
        $0.setLeftPaddingPoints(12)
    }
    
    lazy var passwordTextField = UITextField() .. {
        $0.placeholder = "Password"
        $0.isSecureTextEntry = true
        $0.backgroundColor = .white
        $0.height(40)
        $0.setLeftPaddingPoints(12)
    }
    
    lazy var enterButton = UIButton() .. {
        $0.setTitle("Create an Account", for: .normal)
        $0.backgroundColor = .systemBlue
        $0.setTitleColor(.white, for: .normal)
        $0.titleLabel?.font = .systemFont(ofSize: 18, weight: .medium)
        $0.layer.cornerRadius = 10
        $0.height(50)
        
        $0.addTarget(self, action: #selector(createAccountTapped), for: .touchUpInside)
    }
    
    lazy var forgotButton = UIButton() .. {
        $0.setTitle("Already have an account?", for: .normal)
        $0.setTitleColor(.systemGray, for: .normal)
        $0.titleLabel?.font = .systemFont(ofSize: 16)
        $0.layer.cornerRadius = 24
        $0.height(48)
    }
    
    // MARK: Body
    
    override func body() -> UICodeView? {
        UIStack(axis: .vertical) {
            Wrapper {
                titleLabel
            }
            .position(.centerX)
            .setHeight(50)
            
            UIStack(axis: .vertical) {
                usernameTextField
                passwordTextField
            }
            .padding(.bottom(18), .top(30))
            
            UIStack(axis: .vertical, spacing: 12) {
                enterButton
                forgotButton
            }
            
            UISeparator()
            
            UIStack(axis: .vertical) {
                UIButton(type: .system) .. {
                    $0.setTitleColor(.black, for: .normal)
                    $0.setTitle("Continue with Google", for: .normal)
                    $0.backgroundColor = .white
                    $0.height(50)
                    $0.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
                    $0.layer.cornerRadius = 10
                }
                
                UIButton(type: .system) .. {
                    $0.setTitleColor(.black, for: .normal)
                    $0.setTitle("Continue with Facebook", for: .normal)
                    $0.backgroundColor = .white
                    $0.height(50)
                    $0.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
                    $0.layer.cornerRadius = 10
                }
                
                UIButton(type: .system) .. {
                    $0.setTitleColor(.black, for: .normal)
                    $0.setTitle("Continue with Apple", for: .normal)
                    $0.backgroundColor = .white
                    $0.height(50)
                    $0.titleLabel?.font = .systemFont(ofSize: 16, weight: .medium)
                    $0.layer.cornerRadius = 10
                }
            }
            
            UISpacer()
            
            UILabel() .. {
                $0.text = "All rights reserved 2023."
                $0.textAlignment = .center
                $0.textColor = .gray.withAlphaComponent(0.5)
                $0.font = .systemFont(ofSize: 14)
            }
        }
        .padding(.top(24), .horizontal(16))
        .. {
            $0.backgroundColor = .gray.withAlphaComponent(0.1)
        }
    }
    
    // MARK: Actions
    
    @objc func createAccountTapped() {
        createAccountAction?()
    }
}


struct HomeView_Previews: PreviewProvider {
    static var previews: some View {
        HomeController().toPreview()
    }
}

extension UITextField {
    func setLeftPaddingPoints(_ amount:CGFloat){
        let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: amount, height: self.frame.size.height))
        self.leftView = paddingView
        self.leftViewMode = .always
    }
    func setRightPaddingPoints(_ amount:CGFloat) {
        let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: amount, height: self.frame.size.height))
        self.rightView = paddingView
        self.rightViewMode = .always
    }
}
    

That's it. enjoy...

Documentation

Soon...

Requirements

  • Xcode 13 or newer
  • iOS 12 or newer

Installation

UICodeKit is available through CocoaPods. To install it, simply add to your Podfile:

target 'YourApp' do
  use_frameworks!

  # Pods for YourApp

  pod 'UICodeKit'

end

Author

Victor Freitas | iOS Developer

License

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

uicodekit's People

Contributors

tqi-valves avatar vafreitas avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

tqi-valves

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.