Skip to content

Commit 42d1f1f

Browse files
committed
add a simple example
1 parent 010caa8 commit 42d1f1f

File tree

2 files changed

+53
-24
lines changed

2 files changed

+53
-24
lines changed

example/hello.jsx

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,15 @@ class _Main {
1515

1616
class MyApp extends ui.Application {
1717
function constructor() {
18-
var top = new ui.TabBarController();
19-
20-
var firstTab = new FirstViewController();
21-
var secondTab = new SecondViewController();
22-
23-
top.setViewControllers([firstTab, secondTab] : ui.ViewController[]);
24-
18+
var top = new ui.ViewController();
2519
this.setRootViewController(top);
26-
}
27-
}
28-
29-
class FirstViewController extends ui.ViewController {
30-
function constructor() {
31-
this.setTabBarItem(new ui.TabBarItem("first"));
3220

3321
var view = new ui.View();
34-
view.setBackgroundColor(ui.Color.GREEN);
35-
this.setView(view);
36-
}
37-
}
38-
39-
class SecondViewController extends ui.ViewController {
40-
function constructor() {
41-
this.setTabBarItem(new ui.TabBarItem("second"));
22+
top.setView(view);
4223

43-
var view = new ui.View();
44-
view.setBackgroundColor(ui.Color.BLUE);
45-
this.setView(view);
24+
view.addSubview(new ui.Label("first"));
25+
view.addSubview(new ui.Label("second"));
26+
view.addSubview(new ui.Label("third"));
4627
}
4728
}
29+

example/tabapp.jsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import "../lib/ui/*.jsx" into ui;
2+
import "js/web.jsx";
3+
import "console.jsx";
4+
5+
class _Main {
6+
static function main(args : string[]) : void {
7+
console.time("application loading");
8+
9+
var app = new MyApp();
10+
app.attach(dom.id("world"));
11+
12+
console.timeEnd("application loading");
13+
}
14+
}
15+
16+
class MyApp extends ui.Application {
17+
function constructor() {
18+
var top = new ui.TabBarController();
19+
20+
var firstTab = new FirstViewController();
21+
var secondTab = new SecondViewController();
22+
23+
top.setViewControllers([firstTab, secondTab] : ui.ViewController[]);
24+
25+
this.setRootViewController(top);
26+
}
27+
}
28+
29+
class FirstViewController extends ui.ViewController {
30+
function constructor() {
31+
this.setTabBarItem(new ui.TabBarItem("first"));
32+
33+
var view = new ui.View();
34+
view.setBackgroundColor(ui.Color.GREEN);
35+
this.setView(view);
36+
}
37+
}
38+
39+
class SecondViewController extends ui.ViewController {
40+
function constructor() {
41+
this.setTabBarItem(new ui.TabBarItem("second"));
42+
43+
var view = new ui.View();
44+
view.setBackgroundColor(ui.Color.BLUE);
45+
this.setView(view);
46+
}
47+
}

0 commit comments

Comments
 (0)