-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathTestDomUtil.dart
41 lines (34 loc) · 1.3 KB
/
TestDomUtil.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
//Test Code: TestDomUtil
import 'package:rikulo_ui/view.dart';
import "package:rikulo_ui/html.dart";
void _createText(View parent, String text, [String cssText="", Iterable<String> classes]) {
final View hlayout = new View();
hlayout.layout.text = "type: linear";
hlayout.profile.width = "flex";
parent.addChild(hlayout);
final TextView textView = new TextView(text);
textView.style.cssText = cssText;
if (classes != null)
for (String c in classes)
textView.classes.add(c);
textView.profile.width = "150";
hlayout.addChild(textView);
final TextView info = new TextView();
info.profile.width = "flex";
hlayout.addChild(info);
}
void main() {
final View mainView = new View()..addToDocument();
mainView.layout.text = "type: linear; orient: vertical";
_createText(mainView, "Test Case 1");
_createText(mainView, "Test Case 2", "font-size: 20px; font-weight: bold;");
_createText(mainView, "Test Case 3", "font-style: italic; font-size: 9px;", ["v-button"]);
final Button button = new Button("Measure");
button.on.click.listen((event) {
for (TextView textView in mainView.queryAll("TextView:first-child")) {
final TextView info = textView.nextSibling;
info.text = "${DomUtil.measureText(textView.node, textView.text)}";
}
});
mainView.addChild(button);
}