Skip to content

Commit 2388dbc

Browse files
committed
inc. version
1 parent 6f3154d commit 2388dbc

6 files changed

Lines changed: 54 additions & 8 deletions

File tree

docs/customization.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,13 @@ Some widgets have parameters without names (e.g. Text, Icon), you can add a name
361361
}
362362
}
363363
```
364+
365+
366+
## 5. Form controls that have controllers
367+
*****
368+
If you use :formControl on a TextField-like, you should add it to "controlsWithTextEditingControllers" option, otherwise will use `onChanged` event and `value` property instead.
369+
```json
370+
{
371+
"controlsWithTextEditingControllers": ["CupertinoTextField"]
372+
}
373+
```

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "XML Layout for Flutter",
44
"description": "XML Layout for Flutter. Brings Angular's style to Flutter!",
55
"publisher": "WaseemDev",
6-
"version": "0.0.31",
6+
"version": "0.0.32",
77
"icon": "images/logo.png",
88
"repository": {
99
"type": "github",

src/generators/widget-generator.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export class WidgetCodeGenerator {
2424
let props: string[] = [];
2525
const tabs = makeTabs(tabsLevel);
2626

27-
const properties = widget.properties.sort(sortProperties).filter(a => !a.skipGeneratingCode);
27+
const constProp = widget.properties.find(a => a.name === 'const');
28+
const properties = widget.properties.sort(sortProperties).filter(a => !a.skipGeneratingCode && a.name !== 'const');
2829

2930
for (const prop of properties) {
3031
let propCode = this.generatePropertyCode(widget, prop, tabsLevel + (widget.isPropertyElement ? 0: 1));
@@ -39,9 +40,11 @@ export class WidgetCodeGenerator {
3940
code = widget.comments.map(a => a.trim()).filter(a => !!a).join('\n' + tabs) + '\n';
4041
}
4142

43+
const constCode = constProp && (constProp.value === '' || constProp.value === 'true') ? 'const ' : '';
4244
const propsCode = props.filter(a => a.trim()).join(',\n');
45+
4346
if (!widget.isPropertyElement && widget.type) {
44-
code += `${widget.type}(\n${propsCode}${propsCode.trim() ? ',' : ''}\n${tabs})`;
47+
code += `${constCode}${widget.type}(\n${propsCode}${propsCode.trim() ? ',' : ''}\n${tabs})`;
4548
}
4649
else {
4750
code += propsCode;

src/property-handlers/item-builder.test.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,39 @@ suite("ItemBuilder Tests", function () {
7979
assertEqual(generated, expected);
8080
});
8181

82+
test("with stream 2", function() {
83+
const xml = `
84+
<ListView :use="builder" itemCount="(component.items | stream).length" :itemBuilder="ItemModel item of component.items | stream">
85+
<Text text="item.title" />
86+
</ListView>
87+
`;
88+
89+
const expected = `
90+
StreamBuilder(
91+
initialData: null,
92+
stream: component.items,
93+
builder: (BuildContext context, componentItemsSnapshot) {
94+
final componentItemsValue = componentItemsSnapshot.data;
95+
if (componentItemsValue == null) {
96+
return Container(width: 0, height: 0);
97+
}
98+
return ListView.builder(
99+
itemCount: (componentItemsValue).length,
100+
itemBuilder: (BuildContext context, int index) {
101+
final ItemModel item = componentItemsValue == null || componentItemsValue.length <= index || componentItemsValue.length == 0 ? null : componentItemsValue[index];
102+
return Text(
103+
item.title,
104+
);
105+
},
106+
);
107+
},
108+
)
109+
`;
110+
111+
const generated = generateWidget(xml);
112+
assertEqual(generated, expected);
113+
});
114+
82115
test("with wrapper property (margin)", function() {
83116
const xml = `
84117
<ListView :use="builder" :margin="5" :itemBuilder="item of component.items">

src/property-handlers/wrapper-animation.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ suite("Wrapper Animation Property Tests", function () {
5454
cycles: 5,
5555
duration: Duration(milliseconds: 1000),
5656
tweenMap: {
57-
"color": ColorTween(begin: Colors.transparent, end: Colors.white),
57+
"height": Tween<int>(begin: 100, end: 300),
5858
"width": Tween<int>(begin: 100, end: 200),
59-
"height": Tween<int>(begin: 100, end: 300)
59+
"color": ColorTween(begin: Colors.transparent, end: Colors.white)
6060
},
6161
builderMap: (Map<String, Animation> animations, Widget child) {
6262
return Container(
@@ -88,9 +88,9 @@ suite("Wrapper Animation Property Tests", function () {
8888
duration: Duration(seconds: 1),
8989
key: ctrl._myAnimationKey,
9090
tweenMap: {
91-
"color": ColorTween(begin: Colors.blue, end: Colors.red),
91+
"height": Tween<double>(begin: 100, end: 300),
9292
"width": Tween<double>(begin: 100, end: 200),
93-
"height": Tween<double>(begin: 100, end: 300)
93+
"color": ColorTween(begin: Colors.blue, end: Colors.red)
9494
},
9595
builderMap: (Map<String, Animation> animations, Widget child) {
9696
return Container(

0 commit comments

Comments
 (0)