Skip to content

Latest commit

 

History

History
91 lines (57 loc) · 1.75 KB

frameworkDoc.md

File metadata and controls

91 lines (57 loc) · 1.75 KB

Fairy framework

Color

//new a white color
var c = Color(hex: "#ffffff")

View

View(width: 200, height: 50, backgroundColor: red, radius: 2)
//all those property you can call set function, like this👇,except width and height
View(width: 200, height: 50).setBackgroundColor(color: blue)
//you can call setSize adjust width and height
View().setSize(width: 100, height: 100)

Stack: View

stack is extended from View, you can call any View's function.

They are implement with UIStackView.

VStack()
HStack()

Label: View

Label(width: 200, height: 50, text: "Fairy", textAlignment: TextAlignmentCenter, textColor: red, bold:1, textSize: 18)

ImageView: View

ImageView(width: 400, height: 200, src: "fairy")

Spacer: View

Spacer(width:1, height:40)

Fairy <=> Native

Fairy object => Native object

Basic types will be automatically converted, other Fairy objects need to implement the toNativeObj method, the system will automatically call this method to obtain for conversion

Native object => Fairy object

Basic types will be automatically converted, other objects will become FARNativeWrapperInstance

Fairy call native

  1. add Fairy-Native interface in FARNativeApi.m

    - (void)testFunc:(NSDictionary *)params {
    }
  2. call in Fairy

    __Native.testFunc(param: p)

Native call Fairy

Note: You must get the Fairy object in Native before calling Fairy

- (void)setClickListener:(NSDictionary *)params {
    FARObjectWrapper *wrapper = params[@"clickListener"];
    wrapper callWithParams:@{@"sender": sender}];
 }

you can see internalScript.far and find more usage