/LemonadeUI

Custom UI repo

Primary LanguageSwiftMIT LicenseMIT

HeaderImage.jpg

LemonadeUI custom UI library for iOS and OSX.

https://img.shields.io/cocoapods/v/LemonadeUI.svg?style=flat

https://img.shields.io/cocoapods/l/LemonadeUI.svg?style=flat

https://img.shields.io/cocoapods/p/LemonadeUI.svg?style=flat

Requirements


  • iOS 12.0+ / Mac OS X 10+
  • Xcode 10.0+
  • Swift 5.0+

Communication


Installation


CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate LemonadeUI into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
	pod 'LemonadeUI'
end

Then, run the following command:

$ pod install

Usage


  • Contraints
someView.top(otherView, equalTo: .top, constant: 10, safeArea: true)
someView.left(otherView, equalTo: .left , constant: 10)
// ....
someView.leftAndRight(view , constant: 24)
// ....
someView.centerX(otherView, equalTo: .centerX)
someView.center(to: otherView, width: .screenWidth(24), height: .screenHeight())
someView.center(to: otherView)
// ....
someView.height(constant: 20)
someView.width(otherView, equalTo: .height, multiplier: 0.8, safeArea: true)
someView.width(constant: .screenWidth(48))
// .... 
someView.fill2SuperView()
someView.fill2SuperView(.init(right: 10, left: 10, top: 10, bottom: 10))
  • Some basic configuration types and functions usages
public struct LemonadeBorder {
    var borderColor : CGColor
    var borderWidth : CGFloat 
...
}
someView.border(...//LemonadeBorder)
public struct LemonadeRadius {
    var radius : CGFloat
    var maskedCorners : CACornerMask?
...
}
someView.radius(...//LemonadeRadius)
public struct LemonadeGradient {
    var colors : [CGColor]
    var from : CGPoint
    var to   : CGPoint
    var locations : [NSNumber]?
...
}
someView.gradient(...//LemonadeRadius)
public struct LemonadeColor {
    var backgroundColor : UIColor?
    var gradient        : LemonadeGradient?
...
}
someView.color(...//LemonadeColor)
public struct LemonadeEmptyUI {
    var image : UIImage?
    var text  : String
    var descriptionText : String?
...
}
 someView.emptyUI(...//LemonadeEmptyUI)
  • Some basic custom component usages
import LemonadeUI

private lazy var lotus : LemonadeLotus = {
        let config = LemonadeLotusConfig(petal: .systemBlue, numberOfItems: 8, pattern: [
            .init(duration: 3, position: .sleep),
            .init(duration: 4, position: .awake),
            .init(duration: 1, position: .sleep),
            .init(duration: 5, position: .awake),
        ])
        let lotus = LemonadeLotus(frame: .zero, config)
        lotus.lotusDelegate = self
        return lotus
    }()
....

extension ExampleVC: LemonadeLotusDelegate {
    func actionChanged(_ lotus: LemonadeLotus, action: LemonadeLotusAnimationPatternItem) {
        print("Action changed -> \(action.position)")
    }
    
    func animationStart(_ lotus: LemonadeLotus) {
        print("Animate Start")
    }
    
    func animationEnd(_ lotus: LemonadeLotus) {
        print("Animate Stop")
    }
}
import LemonadeUI

private lazy var exampleButton: LemonadeButton = {
        let button: LemonadeButton = .init(frame: .zero, color: .init(backgroundColor: .systemBlue), radius:.init(radius: 8))
        button.text(.init(text: "Start Pattern", color: .white, font: .systemFont(ofSize: 20), alignment: .center))
        return button
    }()

....

private func handlers(){
        exampleButton.addAction { [weak self] in
            // actions
        }
}
import LemonadeUI

private lazy var flower: LemonadeFlower = {
        let config: LemonadeFlowerConfig = .init(items: [
            .init(sliceColor: .init(backgroundColor: .systemBlue.withAlphaComponent(0.7)), sliceBorder: .init(borderColor: .black, width: 2.0)),
            .init(sliceColor: .init(backgroundColor: .systemPink.withAlphaComponent(0.7)), sliceBorder: .init(borderColor: .black, width: 1.0)),
            .init(sliceColor: .init(backgroundColor: .black.withAlphaComponent(0.7)), sliceBorder: .init(borderColor: .white, width: 2.0), customView: .init(frame: .zero, color: .init(backgroundColor: .orange), radius: .init(radius: 20), border: .init(borderColor: .white, width: 2.0)))
        ], spacing: 3)
        let flower: LemonadeFlower = .init(frame: .zero, config)
        flower.backgroundColor = .clear
        flower.flowerdelegate = self
        return flower
    }()

....

extension ExampleVC: LemonadeFlowerDelegate {
    func sliceTapped(_ flower: LemonadeFlower, index: Int) {
        print("Index Tapped -> \(index)")
    }
}

Playground


You can try LemonadeUI on Example Project. Just download and run Example Project.

Resources


Credits


License

LemonadeUI is released under the MIT license. See LICENSE for details.