浏览代码

polish test case

/main
xingwei.zhu 6 年前
当前提交
d09c8037
共有 4 个文件被更改,包括 192 次插入112 次删除
  1. 2
      Runtime/material/card.cs
  2. 4
      Runtime/rendering/proxy_box.cs
  3. 206
      Samples/UIWidgetSample/ExpansionPanelCanvas.cs
  4. 92
      Samples/UIWidgetSample/MaterialCanvas.cs

2
Runtime/material/card.cs


using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
class Card : StatelessWidget {
public class Card : StatelessWidget {
public Card(
Key key = null,
Color color = null,

4
Runtime/rendering/proxy_box.cs


return base.hitTest(result, position: position);
}
//todo:xingwei.zhu: implementation shadow + compositeLayer
//todo:xingwei.zhu: implementation shadow + compositeLayer (issue: no color when composite)
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();

return base.hitTest(result, position: position);
}
//todo:xingwei.zhu: implementation shadow + compositeLayer
//todo:xingwei.zhu: implementation shadow + compositeLayer (issue: no color when composite)
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();

206
Samples/UIWidgetSample/ExpansionPanelCanvas.cs


using System.Collections.Generic;
using Unity.UIWidgets.widgets;
using System.Collections.Generic;
using Unity.UIWidgets.widgets;
int testCaseId = 1;
readonly List<Widget> testCases = new List<Widget> {
new SingleChildScrollWidget(),
new ExpansionPanelWidget()
};
return new ExpansionPanelWidget();
return this.testCases[this.testCaseId];
}
class ExpansionPanelWidget : StatefulWidget {
public ExpansionPanelWidget(Key key = null) : base(key) {
}
class SingleChildScrollWidget : StatefulWidget {
public SingleChildScrollWidget(Key key = null) : base(key) {
}
public override State createState() {
return new ExpansionPanelWidgetState();
}
public override State createState() {
return new SingleChildScrollWidgetState();
}
}
class SingleChildScrollWidgetState : State<SingleChildScrollWidget> {
public override Widget build(BuildContext context) {
return new Material(
child: new SingleChildScrollView(
child: new Container(
width: 40.0,
height: 40.0,
constraints: BoxConstraints.tight(new Size(40, 600)),
color: AsScreenCanvas.CLColors.red,
child: new Center(child: new Text("Beijing"))
)
)
);
}
}
class ExpansionPanelWidget : StatefulWidget {
public ExpansionPanelWidget(Key key = null) : base(key) {
}
public override State createState() {
return new ExpansionPanelWidgetState();
class ExpansionPanelWidgetState : State<ExpansionPanelWidget> {
List<bool> isExpand = new List<bool>{false, false};
public override Widget build(BuildContext context) {
/*return new Material(
child: new SingleChildScrollView(
child: new Container(
width: 40.0,
height: 40.0,
constraints: BoxConstraints.tight(new Size(40, 300)),
color: AsScreenCanvas.CLColors.red,
child: new Center(child: new Text("XXXXXXXX"))
)
)
);*/
return new Material(
child: new SingleChildScrollView(
child: new ExpansionPanelList(
expansionCallback: (int _index, bool _isExpanded) => {
Debug.Log("???????????" + _index + " <> " + _isExpanded);
this.isExpand[_index] = !_isExpanded;
this.setState(() => {});
}
class ExpansionPanelWidgetState : State<ExpansionPanelWidget> {
readonly List<bool> isExpand = new List<bool> {false, false};
public override Widget build(BuildContext context) {
return new Material(
child: new SingleChildScrollView(
child: new ExpansionPanelList(
expansionCallback: (int _index, bool _isExpanded) => {
Debug.Log("<tile " + _index + "> from [" + (_isExpanded ? "Open" : "Close") + "]" +
" to [" + (_isExpanded ? "Close" : "Open") + "]");
this.isExpand[_index] = !_isExpanded;
this.setState(() => { });
},
children: new List<ExpansionPanel> {
new ExpansionPanel(
headerBuilder: (BuildContext subContext, bool isExpanded) => {
return new Container(
color: Colors.black45,
child: new Center(
child: new Text("Beijing")
)
);
children: new List<ExpansionPanel> {
new ExpansionPanel(
headerBuilder: (BuildContext subContext, bool isExpanded) => {
return new Container(
width: 10.0,
height: 10.0,
constraints: BoxConstraints.tight(new Size(10, 10)),
color: AsScreenCanvas.CLColors.blue
);
},
body: new Container(
width: 40.0,
height: 10.0,
constraints: BoxConstraints.tight(new Size(40, 10)),
color: AsScreenCanvas.CLColors.red
),
isExpanded : this.isExpand[0]
),
new ExpansionPanel(
headerBuilder: (BuildContext subContext, bool isExpanded) => {
return new Container(
width: 10.0,
height: 10.0,
constraints: BoxConstraints.tight(new Size(10, 10)),
color: AsScreenCanvas.CLColors.blue
);
},
body: new Container(
width: 40.0,
height: 10.0,
constraints: BoxConstraints.tight(new Size(40, 10)),
color: AsScreenCanvas.CLColors.red
),
isExpanded: this.isExpand[1]
body: new Container(
child: new Column(
children: new List<Widget> {
new Card(
child: new Container(
color: Colors.black38,
height: 36,
width: 300,
child: new Center(
child: new Text("Beijing")
)
)
)
}
)
),
isExpanded: this.isExpand[0]
),
new ExpansionPanel(
headerBuilder: (BuildContext subContext, bool isExpanded) => {
return new Container(
color: Colors.black45,
child: new Center(
child: new Text("Hebei")
)
);
},
body: new Container(
child: new Column(
children: new List<Widget> {
new Card(
child: new Container(
color: Colors.black38,
height: 36,
width: 300,
child: new Center(
child: new Text("Tianjin")
)
)
),
new Card(
child: new Container(
color: Colors.black38,
height: 36,
width: 300,
child: new Center(
child: new Text("Shijiazhuang")
)
)
),
new Card(
child: new Container(
color: Colors.black38,
height: 36,
width: 300,
child: new Center(
child: new Text("Zhumadian")
)
)
)
}
}
)
),
isExpanded: this.isExpand[1]
),
}
);
}
)
);
}
}
}

92
Samples/UIWidgetSample/MaterialCanvas.cs


using System.Collections.Generic;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;

public class MaterialCanvas : WidgetCanvas {
int testCaseId = 0;
List<Widget> testCases = new List<Widget> {
new MaterialButtonWidget(),
new MaterialInkWellWidget()
};
return new MaterialWidget();
return this.testCases[this.testCaseId];
}
class MaterialWidget : StatefulWidget {
public MaterialWidget(Key key = null) : base(key) {
}
class MaterialInkWellWidget : StatefulWidget {
public MaterialInkWellWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialWidgetState();
}
public override State createState() {
return new MaterialInkWidgetState();
}
// test-case: material button
class MaterialWidgetState : State<MaterialWidget> {
public override Widget build(BuildContext context) {
return new Material(
child: new Center(
child: new MaterialButton(
color: Colors.blue,
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
onPressed: () => { Debug.Log("pressed here"); }
class MaterialInkWidgetState : State<MaterialInkWellWidget> {
public override Widget build(BuildContext context) {
return new Material(
child: new Center(
child: new Container(
width: 30,
height: 30,
child: new InkWell(
borderRadius: BorderRadius.circular(2.0),
highlightColor: new Color(0xAAFF0000),
splashColor: new Color(0xAA0000FF),
onTap: () => { Debug.Log("on tap"); }
);
}
)
);
}
// // test-case: ink well
// class MaterialWidgetState : State<MaterialWidget> {
// public override Widget build(BuildContext context) {
// return new Material(
// child: new Center(
// child: new Container(
// width: 30,
// height: 30,
// child : new InkWell(
// borderRadius: BorderRadius.circular(2.0),
// highlightColor: new Color(0xAAFF0000),
// splashColor: new Color(0xAA0000FF),
// //radius : 20,
// onTap: () => { }
// ))
// )
// );
// }
// }
class MaterialButtonWidget : StatefulWidget {
public MaterialButtonWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialButtonWidgetState();
}
}
class MaterialButtonWidgetState : State<MaterialButtonWidget> {
public override Widget build(BuildContext context) {
return new Material(
child: new Center(
child: new MaterialButton(
color: Colors.blue,
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
onPressed: () => { Debug.Log("pressed here"); }
)
)
);
}
}
}
正在加载...
取消
保存