-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathTestLinearLayout1.dart
73 lines (66 loc) · 2.09 KB
/
TestLinearLayout1.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//Test Code: TestLinearLayout1
import 'package:rikulo_ui/view.dart';
void test1(View parent, int left, int top) {
//case 1: fixed size
View hlayout = new View();
hlayout.left = left;
hlayout.top = top;
hlayout.style.backgroundColor = "#ddb";
hlayout.layout.type = "linear";
//hlayout.layout.orient = "horizontal"; //default
hlayout.profile.width = hlayout.profile.height = "content";
parent.addChild(hlayout);
View view = new View();
view.style.backgroundColor = "blue";
view.profile.width = "30"; //test profile.width
view.height = 50; //test height
hlayout.addChild(view);
view = new View();
view.style.backgroundColor = "orange";
view.width = 50;
view.profile.height = "40";
hlayout.addChild(view);
view = new View();
view.style.backgroundColor = "yellow";
view.width = 70;
view.height = 30;
view.profile.align = "end";
hlayout.addChild(view);
}
void test2(View parent, int left, int top) {
//case 2: flex
View hlayout = new View();
hlayout.left = left;
hlayout.top = top;
hlayout.style.border = "1px solid #884";
hlayout.layout.type = "linear";
hlayout.layout.align = "center";
hlayout.layout.orient = "horizontal";
hlayout.layout.spacing = "5 5";
hlayout.profile.width = "70%";
//we can't use flex (which implies parent.clientWidth)
//of course, we can use hlayout to partition but it is not tested here
hlayout.profile.height = "40"; //..profile.height = "40" is also OK
parent.addChild(hlayout);
View view = new View();
view.style.backgroundColor = "blue";
view.profile.width = "flex"; //test profile.width
view.profile.height = "flex";
hlayout.addChild(view);
view = new View();
view.style.backgroundColor = "orange";
view.profile.width = "flex 2";
view.profile.height = "50%";
hlayout.addChild(view);
view = new View();
view.style.backgroundColor = "yellow";
view.profile.width = "flex 3";
view.profile.height = "100%";
hlayout.addChild(view);
}
void main() {
final View mainView = new View()..addToDocument();
mainView.style.backgroundColor = "#cca";
test1(mainView, 10, 10);
test2(mainView, 10, 100);
}