• Stars
    star
    810
  • Rank 56,306 (Top 2 %)
  • Language
    Swift
  • License
    Other
  • Created almost 10 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Flexbox in Swift, using Facebook's css-layout.

SwiftBox

A Swift wrapper around Facebook's implementation of CSS's flexbox.

Example

let parent = Node(size: CGSize(width: 300, height: 300),
                  childAlignment: .Center,
                  direction: .Row,
                  children: [
    Node(flex: 75,
         margin: Edges(left: 10, right: 10),
         size: CGSize(width: 0, height: 100)), 
    Node(flex: 15,
         margin: Edges(right: 10),
         size: CGSize(width: 0, height: 50)),
    Node(flex: 10,
         margin: Edges(right: 10),
         size: CGSize(width: 0, height: 180)),
])

let layout = parent.layout()
println(layout)

//{origin={0.0, 0.0}, size={300.0, 300.0}}
//	{origin={10.0, 100.0}, size={195.0, 100.0}}
//	{origin={215.0, 125.0}, size={39.0, 50.0}}
//	{origin={264.0, 60.0}, size={26.0, 180.0}}

Alternatively, you could apply the layout to a view hierarchy (after ensuring Auto Layout is off):

layout.apply(someView)

See SwiftBoxDemo for a demo.

More Repositories

1

Few.swift

Views as functions of their state.
Swift
1,079
star
2

clojurem

Clojure to Objective-C compiler
Clojure
284
star
3

JAListView

An NSTableView replacement that doesn't suck.
Objective-C
249
star
4

MacShairport

A native Mac Shairport implementation
Objective-C
176
star
5

RACSignupDemo

A ReactiveCocoa signup view
Objective-C
68
star
6

JAViewController

A subclass of NSViewController that's actually useful
Objective-C
62
star
7

Freezer

Database as a value.
Objective-C
54
star
8

ReederDemo

Demo of how Reeder's push/pop animation works
Objective-C
39
star
9

ts2re

Convert TypeScript type declarations to Reason
OCaml
34
star
10

Marketplace

Craigslist, without the ugly.
Objective-C
25
star
11

MoreAnimation

MoreAnimation is a super lazy, super dumbed-down re-implementation of Core Animation.
Objective-C
23
star
12

JAAnimatingContainer

Easier animations
Objective-C
17
star
13

TwUIPushPopTest

A navigation controller test using TwUI
Objective-C
17
star
14

PagesDemo

How to re-create the Pages window zoom animation
Objective-C
12
star
15

Octodo

Your todo list, with Octocats.
Objective-C
11
star
16

MAUIKit

MAUKit was a start at making a modern, gloriously layer-based Mac UI framework.
Objective-C
9
star
17

FloatingViewDemo

Objective-C
8
star
18

CourierDemo

Demo of Courier's envelope animation
Objective-C
7
star
19

this-is-a-cool-project

And it does cool things!
6
star
20

JAWeakReferenceHaterProxy

NSWindowController hating on your weak references? No worries friend.
Objective-C
6
star
21

bucklescript-react-test

OCaml
5
star
22

Temperature

A Cocoa integration test suite
Objective-C
5
star
23

simple-server

It's simple!
JavaScript
3
star
24

WTFXcode

An attempt at making an Xcode plugin
Objective-C
3
star
25

potential-potato

2
star
26

simple-rails-server

Ruby
2
star
27

almost-empty

2
star
28

auto-pretty

JavaScript
2
star
29

empty

2
star
30

simple-docker-compose

1
star
31

no-more-hotdogs

Dockerfile
1
star
32

mean-dad

Dockerfile
1
star
33

haze

JavaScript
1
star
34

joshaber.github.io

CSS
1
star
35

garbage

1
star
36

empty_repo

...so lonely
1
star
37

jupyter-test

Jupyter Notebook
1
star
38

all-maroon

JavaScript
1
star
39

tunnels-test

TypeScript
1
star
40

atom-types

Type declarations. For Atom.
1
star