浏览代码

scaffold test sample

/main
xingwei.zhu 6 年前
当前提交
ee26e999
共有 3 个文件被更改,包括 112 次插入5 次删除
  1. 2
      Runtime/material/app_bar.cs
  2. 4
      Runtime/material/scaffold.cs
  3. 111
      Samples/UIWidgetSample/MaterialSample.cs

2
Runtime/material/app_bar.cs


}
}
class AppBar : StatefulWidget, IPreferredSizeWidget {
public class AppBar : StatefulWidget, IPreferredSizeWidget {
public AppBar(
Key key = null,
Widget leading = null,

4
Runtime/material/scaffold.cs


public class Scaffold : StatefulWidget {
public Scaffold(
Key key = null,
PreferredSizeWidget appBar = null,
AppBar appBar = null,
Widget body = null,
Widget floatingActionButton = null,
FloatingActionButtonLocation floatingActionButtonLocation = null,

this.primary = primary;
}
public readonly PreferredSizeWidget appBar;
public readonly AppBar appBar;
public readonly Widget body;

111
Samples/UIWidgetSample/MaterialSample.cs


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

public class MaterialSample : UIWidgetsSamplePanel {
int testCaseId = 0;
int testCaseId = 2;
new MaterialInkWellWidget()
new MaterialInkWellWidget(),
new MaterialAppBarWidget()
}
}
class MaterialAppBarWidget : StatefulWidget {
public MaterialAppBarWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialAppBarWidgetState();
}
}
class MaterialAppBarWidgetState : State<MaterialAppBarWidget> {
Choice _selectedChoice = Choice.choices[0];
void _select(Choice choice) {
this.setState(() => { this._selectedChoice = choice; });
}
public override Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text("Basic AppBar"),
actions: new List<Widget> {
new IconButton(
icon: new Icon(Choice.choices[0].icon),
onPressed: () => {
this._select((Choice.choices[0]));
}
),
new IconButton(
icon: new Icon(Choice.choices[1].icon),
onPressed: () => {
this._select((Choice.choices[1]));
}
),
/*new PopupMenuButton<Choice>(
onSelected: this._select,
itemBuilder: (BuildContext subContext) => {
List<PopupMenuEntry<Choice>> popupItems = new List<PopupMenuEntry<Choice>>();
for (int i = 2; i < Choice.choices.Count; i++) {
popupItems.Add(new PopupMenuItem<Choice>(
value: Choice.choices[i],
child: new Text(Choice.choices[i].title)));
}
return popupItems;
}
)*/
}
),
body: new Padding(
padding: EdgeInsets.all(16.0f),
child: new ChoiceCard(choice: this._selectedChoice)
)
)
);
}
}
class Choice {
public Choice(string title, IconData icon) {
this.title = title;
this.icon = icon;
}
public readonly string title;
public readonly IconData icon;
public static List<Choice> choices = new List<Choice> {
new Choice("Car", Unity.UIWidgets.material.Icons.directions_car),
new Choice("Bicycle", Unity.UIWidgets.material.Icons.directions_bike),
new Choice("Boat", Unity.UIWidgets.material.Icons.directions_boat),
new Choice("Bus", Unity.UIWidgets.material.Icons.directions_bus),
new Choice("Train", Unity.UIWidgets.material.Icons.directions_railway),
new Choice("Walk", Unity.UIWidgets.material.Icons.directions_walk)
};
}
class ChoiceCard : StatelessWidget {
public ChoiceCard(Key key = null, Choice choice = null) : base(key: key) {
this.choice = choice;
}
public readonly Choice choice;
public override Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.display1;
return new Card(
color: Colors.white,
child: new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: new List<Widget>{
new Icon(this.choice.icon, size: 128.0f, color: textStyle.color),
new Text(this.choice.title, style: textStyle)
}
)
)
);
}
}

正在加载...
取消
保存