xingwei.zhu
6 年前
当前提交
d09c8037
共有 4 个文件被更改,包括 192 次插入 和 112 次删除
-
2Runtime/material/card.cs
-
4Runtime/rendering/proxy_box.cs
-
206Samples/UIWidgetSample/ExpansionPanelCanvas.cs
-
92Samples/UIWidgetSample/MaterialCanvas.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] |
|||
), |
|||
} |
|||
); |
|||
} |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue