Skip to content

chunkyguy/WLKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WLKit

Simple utilities for getting things done.

SLE

Simple Layout Engine

A simplistic layout engine. Think what if CGRectDivide() went all the way.

Usage:

let layout = Layout(parentFrame: frame, direction: .column)
try layout.add(item: .flexible)
try layout.add(item: .height(200))

let topFrame = try layout.frame(at: 0)
let bottomFrame = try layout.frame(at: 1)

addSubview(SLECreateView(topFrame, .red))
addSubview(SLECreateView(bottomFrame, .blue))

Read More

VFL

Visual Formatting Language

Simple wrapper around Apple's ascii based constraints. But also stateful.

Usage:

VFL(self)
  .add(subview: MyView(), name: "view")
  .appendConstraints(formats: ["H:|[view(320)]|", "V:|[view(480)]|"])

But unlike other wrappers, VFL is meant to be used as a supplement and not a replacement. So you can also add constraints created using system API. Here's an example that creates a view of size 320x480 and aligns it to the center of parent

let view = VFLColorView()

VFL(self)
  .add(subview: view, name: "view")
  .appendConstraints(formats: [
    "H:[view(320)]", "V:[view(480)]",]
  )
  .appendConstraints([
    NSLayoutConstraint(
      item: view, attribute: .centerX,
      relatedBy: .equal,
      toItem: self, attribute: .centerX,
      multiplier: 1, constant: 0
    ),
    NSLayoutConstraint(
      item: view, attribute: .centerY,
      relatedBy: .equal,
      toItem: self, attribute: .centerY,
      multiplier: 1, constant: 0
    )
  ])

Read More

  1. Introducing VFL
  2. Autolayout and aligning subviews

FLIC

Feedback Loop is Cool

Best way to build GUI apps!

Usage

enum AsyncViewModel {
  case loading
  case success(UIView)
  case error(AppError)
}

class AsyncView: View<AsyncViewModel>, ContentViewBindable {
  var contentView: UIView { self }
  
  override func setUp() {
    super.setUp()
    backgroundColor = .white
  }
  
  override func viewModelDidUpdate() {
    super.viewModelDidUpdate()
    switch viewModel {
    case .loading:
      self.view = LoadingView(true)
    case .success(let view):
      self.view = view
    case .error(let error):
      self.view = ErrorView(error)      
    }
  }
}

Read More

About

Simple utilities for getting things done.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages