浏览代码

add default color to WidgetsApp samples

/siyaoH-1.17-PlatformMessage
Xingwei Zhu 4 年前
当前提交
52e9689d
共有 10 个文件被更改,包括 154 次插入43 次删除
  1. 1
      Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs
  2. 1
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/CustomPaintSample.cs
  3. 2
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/DragDropSample.cs
  4. 99
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/HttpRequestSample.cs
  5. 2
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/LongPressSample.cs
  6. 1
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/NavigationSample.cs
  7. 1
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/PageViewSample.cs
  8. 1
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ScrollbarSample.cs
  9. 1
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ToDoAppSample.cs
  10. 88
      Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ImageFormatSample.cs

1
Samples/UIWidgetsSamples_2019_4/Assets/Script/CountTest.cs


{
return new WidgetsApp(
home: new ExampleApp(),
color: Color.white,
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(
settings: settings,

1
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/CustomPaintSample.cs


public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new Unity.UIWidgets.widgets.CustomPaint(
child: new Container(width: 300, height: 300, color: new Color(0XFFFFFFFF)),
foregroundPainter: new GridPainter(null)

2
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/DragDropSample.cs


using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new DragDropApp(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(

99
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/HttpRequestSample.cs


using UnityEngine.Networking;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class HttpRequestSample : UIWidgetsPanel
namespace UIWidgetsSample
protected override void main() {
ui_.runApp(new MaterialApp(
title: "Http Request Sample",
home: new Scaffold(
body:new AsyncRequestWidget(this.gameObject)
public class HttpRequestSample : UIWidgetsPanel
{
protected override void main()
{
ui_.runApp(new MaterialApp(
title: "Http Request Sample",
home: new Scaffold(
body: new AsyncRequestWidget(this.gameObject)
));
));
}
}
public class AsyncRequestWidget : StatefulWidget {
public readonly GameObject gameObjOfUIWidgetsPanel;
public class AsyncRequestWidget : StatefulWidget
{
public AsyncRequestWidget(GameObject gameObjOfUiWidgetsPanel, Key key = null) : base(key) {
this.gameObjOfUIWidgetsPanel = gameObjOfUiWidgetsPanel;
public readonly GameObject gameObjOfUIWidgetsPanel;
public AsyncRequestWidget(GameObject gameObjOfUiWidgetsPanel, Key key = null) : base(key)
{
this.gameObjOfUIWidgetsPanel = gameObjOfUiWidgetsPanel;
}
public override State createState()
{
return new _AsyncRequestWidgetState();
}
public override State createState() {
return new _AsyncRequestWidgetState();
[Serializable]
public class TimeData
{
public long currentFileTime;
}
[Serializable]
public class TimeData {
public long currentFileTime;
}
class _AsyncRequestWidgetState : State<AsyncRequestWidget>
{
long _fileTime;
public override Widget build(BuildContext context)
{
var isolate = Isolate.current;
class _AsyncRequestWidgetState : State<AsyncRequestWidget> {
long _fileTime;
public override Widget build(BuildContext context) {
var isolate = Isolate.current;
return new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>() {
new FlatButton(child: new Text("Click To Get Time"), onPressed: () => {
UnityWebRequest www = UnityWebRequest.Get("http://worldclockapi.com/api/json/est/now");
var asyncOperation = www.SendWebRequest();
asyncOperation.completed += operation => {
var timeData = JsonUtility.FromJson<TimeData>(www.downloadHandler.text);
using(Isolate.getScope(isolate))
return new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>()
{
new FlatButton(child: new Text("Click To Get Time"), onPressed: () =>
{
UnityWebRequest www = UnityWebRequest.Get("http://worldclockapi.com/api/json/est/now");
var asyncOperation = www.SendWebRequest();
asyncOperation.completed += operation =>
this.setState(() => { this._fileTime = timeData.currentFileTime; });
}
};
}),
new Text($"current file time: {this._fileTime}")
});
var timeData = JsonUtility.FromJson<TimeData>(www.downloadHandler.text);
using (Isolate.getScope(isolate))
{
this.setState(() => { this._fileTime = timeData.currentFileTime; });
}
};
}),
new Text($"current file time: {this._fileTime}")
});
}
}
}

2
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/LongPressSample.cs


using Unity.UIWidgets.engine2;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace UIWidgetsSample {
public class LongPressSample : UIWidgetsPanel {

public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new LongPressSampleWidget(),
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(

1
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/NavigationSample.cs


public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
initialRoute: "/",
textStyle: new TextStyle(fontSize: 24),
pageRouteBuilder: (settings, builder) =>

1
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/PageViewSample.cs


public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new Container(
width: 200,
height: 400,

1
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ScrollbarSample.cs


public override Widget build(BuildContext context)
{
return new WidgetsApp(
color: Color.white,
home: new Container(
decoration: new BoxDecoration(
border: Border.all(color: new Color(0xFFFFFF00))

1
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ToDoAppSample.cs


{
ui_.runApp(
new WidgetsApp(
color: Color.white,
home: new ToDoListApp(),
pageRouteBuilder: this.pageRouteBuilder)
);

88
Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ImageFormatSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using Image = Unity.UIWidgets.widgets.Image;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample
{
public class ImageFormatSample : UIWidgetsPanel
{
protected override void main()
{
ui_.runApp(new MyApp());
}
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new WidgetsApp(
home: new ImageFormatApp(),
color: Color.white,
pageRouteBuilder: (settings, builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (buildContext, animation, secondaryAnimation) => builder(context)
)
);
}
}
class ImageFormatApp : StatefulWidget
{
public override State createState()
{
return new ImageFormatAppState();
}
}
class ImageFormatAppState : State<ImageFormatApp>
{
private int imageId;
private static List<string> imagePath = new List<string>
{
"shrine_images/0-0.jpg",
"shrine_images/2.0x/1-0.jpg",
"shrine_images/diamond.png",
"gallery/people/square/ali.png",
"gallery/10-0.jpg",
"gallery/glasses.jpg"
};
public override Widget build(BuildContext context)
{
return new Container(
child: new Column(
children: new List<Widget>
{
new Container(
width: 100,
height: 100,
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(8))
),
child: Image.file(imagePath[imageId])
),
new Text(imagePath[imageId]),
new GestureDetector(
onTap: () => { setState(() => { imageId = (imageId + 1) % imagePath.Count; }); },
child: new Container(
color: Color.black,
padding: EdgeInsets.symmetric(20, 20),
child: new Text("Next"
)
))
}
));
}
}
}
}
正在加载...
取消
保存