36
TCTheme system view build system with json configuration on iOS Saturday, May 4, 13

TCTheme iOS view building system

Embed Size (px)

DESCRIPTION

TCTheme is a view building system for iOS

Citation preview

Page 1: TCTheme iOS view building system

TCTheme systemview build system with json configuration on iOS

Saturday, May 4, 13

Page 2: TCTheme iOS view building system

The point of TCTheme

• realize theme changing on iPhone, iPad

• supply a more coder friendly way to write views on iOS

• remove UIView initializing code from controllers, to make the controller more clean

Saturday, May 4, 13

Page 3: TCTheme iOS view building system

DEMO

Saturday, May 4, 13

Page 4: TCTheme iOS view building system

How to?

Saturday, May 4, 13

Page 5: TCTheme iOS view building system

How to?

Step 1: load them from the json configuration file

Saturday, May 4, 13

Page 6: TCTheme iOS view building system

How to?

Step 2: build the view in the configuration

Saturday, May 4, 13

Page 7: TCTheme iOS view building system

How to change theme?

The only thing you need to do is load the new

theme configuration file, then all will be changed.

Saturday, May 4, 13

Page 8: TCTheme iOS view building system

without interface builder,we need to write code

like these ...

we don’t like interface builder,because it’s not coder friendly

Saturday, May 4, 13

Page 9: TCTheme iOS view building system

without interface builder,we need to write code

like these ...

Pay attention! There are much more lines of codes outside!!

we don’t like interface builder,because it’s not coder friendly

Saturday, May 4, 13

Page 10: TCTheme iOS view building system

use the top level key in the json to build view

Saturday, May 4, 13

Page 11: TCTheme iOS view building system

we can set some attributes here

Saturday, May 4, 13

Page 12: TCTheme iOS view building system

Supported attributes

• class

• type

• frame

• text

• font

• image

• background

• background-image

• color

• border

• radius

• shadow

• autoresizing

• subviews

• extends

• ...

Saturday, May 4, 13

Page 13: TCTheme iOS view building system

class, frame, type, text

class name of the view

position and size of the view

button type

the text shown in the button

Saturday, May 4, 13

Page 14: TCTheme iOS view building system

class, frame, type, text

if the text is included by {}, then it will be replaced by the translation

Saturday, May 4, 13

Page 15: TCTheme iOS view building system

class, frame, type, text

expression is supported here

Saturday, May 4, 13

Page 16: TCTheme iOS view building system

font

this means the system default font with size 18

bold system default font with size 18

italic system default font with size 18

Arial Rounded MT Bold, size 18

Saturday, May 4, 13

Page 17: TCTheme iOS view building system

image, background-image

image under app root

relative path based on the path of the configuration file

stretchable params

Saturday, May 4, 13

Page 18: TCTheme iOS view building system

background, color

hex rgb color, 4 bit each

rgba

rgb, 8 bit each

rgba

Saturday, May 4, 13

Page 19: TCTheme iOS view building system

background, color

Saturday, May 4, 13

Page 20: TCTheme iOS view building system

background

background color also support image

Saturday, May 4, 13

Page 21: TCTheme iOS view building system

border, radius

border color

border width

corner radius

Saturday, May 4, 13

Page 22: TCTheme iOS view building system

shadow, autoresizing

shadow is also supported

auto resizing

Saturday, May 4, 13

Page 23: TCTheme iOS view building system

subviews

every subview has a key, then you get the subview by styledViewForKey in code

Saturday, May 4, 13

Page 24: TCTheme iOS view building system

subviews with array

dictionary is out of order, we can use array here if subview order concerns

Saturday, May 4, 13

Page 25: TCTheme iOS view building system

content-subviews

these will be rendered as UIImageView forbackgroundView and selectedBackgroundView

Saturday, May 4, 13

Page 26: TCTheme iOS view building system

content-subviews

content-subviews for UITableViewCellthese views will be added to the cell’s contentView

Saturday, May 4, 13

Page 27: TCTheme iOS view building system

content-subviews

Yes, as you can see, they are syntax highlighted !

Saturday, May 4, 13

Page 28: TCTheme iOS view building system

serve for lazy coder 1

TextMate bundle

for json editing

https://github.com/starfalling/tctheme-textmate

Saturday, May 4, 13

Page 29: TCTheme iOS view building system

AutoComplete with the TextMate bundle

after tab pressed

Saturday, May 4, 13

Page 30: TCTheme iOS view building system

Serve for lazy coder 2

• we can include another theme configuration file

Saturday, May 4, 13

Page 31: TCTheme iOS view building system

Serve for lazy coder 3

will be merged together

• we can define class level configurationsSaturday, May 4, 13

Page 32: TCTheme iOS view building system

Serve for lazy coder 4

• we can extends another top level key

Saturday, May 4, 13

Page 33: TCTheme iOS view building system

Serve for lazy coder 5

• load configuration files in the project path, and run your app in simulator

• TCTheme will watch the configuration file changing, and reload when changed

• change the configuration, and you will see the result without restart app

Saturday, May 4, 13

Page 34: TCTheme iOS view building system

QA

• So what’s your opinion about this system?

Saturday, May 4, 13

Page 36: TCTheme iOS view building system

Thank you !

Saturday, May 4, 13