siyao
4 年前
当前提交
4882bcd1
共有 58 个文件被更改,包括 2223 次插入 和 157 次删除
-
8Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_navigation_demo.cs
-
3com.unity.uiwidgets/Runtime/gestures/multidrag.cs
-
30com.unity.uiwidgets/Runtime/material/expansion_panel.cs
-
2com.unity.uiwidgets/Runtime/material/flat_button.cs
-
2com.unity.uiwidgets/Runtime/material/raised_button.cs
-
139com.unity.uiwidgets/Runtime/material/slider_theme.cs
-
10com.unity.uiwidgets/Runtime/painting/alignment.cs
-
1com.unity.uiwidgets/Runtime/painting/image_resolution.cs
-
5com.unity.uiwidgets/Runtime/rendering/list_wheel_viewport.cs
-
2com.unity.uiwidgets/Runtime/rendering/sliver_padding.cs
-
4com.unity.uiwidgets/Runtime/rendering/sliver_persistent_header.cs
-
6com.unity.uiwidgets/Runtime/rendering/viewport.cs
-
2com.unity.uiwidgets/Runtime/services/text_input.cs
-
7com.unity.uiwidgets/Runtime/widgets/DiagnosticableTree.mixin.gen.cs
-
4com.unity.uiwidgets/Runtime/widgets/DiagnosticableTree.mixin.njk
-
3com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.gen.cs
-
5com.unity.uiwidgets/Runtime/widgets/DirectionalFocusTraversalPolicy.mixin.njk
-
1com.unity.uiwidgets/Runtime/widgets/animated_size.cs
-
2com.unity.uiwidgets/Runtime/widgets/drag_target.cs
-
4com.unity.uiwidgets/Runtime/widgets/framework.cs
-
15com.unity.uiwidgets/Runtime/widgets/navigator.cs
-
6com.unity.uiwidgets/Runtime/widgets/page_view.cs
-
43com.unity.uiwidgets/Runtime/widgets/sliver_persistent_header.cs
-
8Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta
-
56Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs.meta
-
86Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs.meta
-
61Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs.meta
-
131Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs.meta
-
82Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs.meta
-
79Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs.meta
-
53Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs.meta
-
3Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample.meta
-
232com.unity.uiwidgets/Runtime/widgets/sliver_persistent_header.mixin.gen.cs
-
240com.unity.uiwidgets/Runtime/widgets/sliver_persistent_header.mixin.njk
-
168Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/DragDropSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/DragDropSample.cs.meta
-
52Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/LongPressSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/LongPressSample.cs.meta
-
228Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/NavigationSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/NavigationSample.cs.meta
-
45Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/PageViewSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/PageViewSample.cs.meta
-
59Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ScrollbarSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ScrollbarSample.cs.meta
-
87Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/CustomPaintSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/CustomPaintSample.cs.meta
-
172Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ExpansionPanelSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/ExpansionPanelSample.cs.meta
-
69Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/HttpRequestSample.cs
-
11Samples/UIWidgetsSamples_2019_4/Assets/WidgetsSample/HttpRequestSample.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: c0f377c78881e9243879a01b93524d63 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using Material = Unity.UIWidgets.material.Material; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
|
|||
public class MaterialInkWellSample : UIWidgetsPanel { |
|||
|
|||
protected override void main() { |
|||
ui_.runApp(new MaterialApp( |
|||
showPerformanceOverlay: false, |
|||
home: new MaterialInkWellWidget())); |
|||
} |
|||
|
|||
protected new void OnEnable() { |
|||
base.OnEnable(); |
|||
} |
|||
} |
|||
|
|||
public class MaterialInkWellWidget : StatefulWidget { |
|||
public MaterialInkWellWidget(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new MaterialInkWidgetState(); |
|||
} |
|||
} |
|||
|
|||
public class MaterialInkWidgetState : State<MaterialInkWellWidget> { |
|||
public override Widget build(BuildContext context) { |
|||
return new Material( |
|||
//color: Colors.blue,
|
|||
child: new Center( |
|||
child: new Container( |
|||
width: 200, |
|||
height: 200, |
|||
child: new InkWell( |
|||
borderRadius: BorderRadius.circular(2.0f), |
|||
highlightColor: new Color(0xAAFF0000), |
|||
splashColor: new Color(0xAA0000FF), |
|||
onTap: () => { Debug.Log("on tap"); } |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b9e88c33e9f304d40bab9c27f1276033 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
|
|||
public class MaterialNavigationBarSample : UIWidgetsPanel { |
|||
|
|||
protected override void main() { |
|||
ui_.runApp(new MaterialApp( |
|||
showPerformanceOverlay: false, |
|||
home: new MaterialNavigationBarWidget())); |
|||
} |
|||
|
|||
protected new void OnEnable() { |
|||
base.OnEnable(); |
|||
} |
|||
} |
|||
|
|||
class MaterialNavigationBarWidget : StatefulWidget { |
|||
public MaterialNavigationBarWidget(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new MaterialNavigationBarWidgetState(); |
|||
} |
|||
} |
|||
|
|||
class MaterialNavigationBarWidgetState : SingleTickerProviderStateMixin<MaterialNavigationBarWidget> { |
|||
int _currentIndex = 0; |
|||
|
|||
public MaterialNavigationBarWidgetState() { |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Scaffold( |
|||
bottomNavigationBar: new Container( |
|||
height: 100, |
|||
color: Colors.blue, |
|||
child: new Center( |
|||
child: new BottomNavigationBar( |
|||
type: BottomNavigationBarType.shifting, |
|||
// type: BottomNavigationBarType.fix,
|
|||
items: new List<BottomNavigationBarItem> { |
|||
new BottomNavigationBarItem( |
|||
icon: new Icon(icon: Unity.UIWidgets.material.Icons.work, size: 30), |
|||
title: new Text("Work"), |
|||
activeIcon: new Icon(icon: Unity.UIWidgets.material.Icons.work, size: 50), |
|||
backgroundColor: Colors.blue |
|||
), |
|||
new BottomNavigationBarItem( |
|||
icon: new Icon(icon: Unity.UIWidgets.material.Icons.home, size: 30), |
|||
title: new Text("Home"), |
|||
activeIcon: new Icon(icon: Unity.UIWidgets.material.Icons.home, size: 50), |
|||
backgroundColor: Colors.blue |
|||
), |
|||
new BottomNavigationBarItem( |
|||
icon: new Icon(icon: Unity.UIWidgets.material.Icons.shop, size: 30), |
|||
title: new Text("Shop"), |
|||
activeIcon: new Icon(icon: Unity.UIWidgets.material.Icons.shop, size: 50), |
|||
backgroundColor: Colors.blue |
|||
), |
|||
new BottomNavigationBarItem( |
|||
icon: new Icon(icon: Unity.UIWidgets.material.Icons.school, size: 30), |
|||
title: new Text("School"), |
|||
activeIcon: new Icon(icon: Unity.UIWidgets.material.Icons.school, size: 50), |
|||
backgroundColor: Colors.blue |
|||
), |
|||
}, |
|||
currentIndex: this._currentIndex, |
|||
onTap: (value) => { this.setState(() => { this._currentIndex = value; }); } |
|||
) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: cc34344049d222b468f2487b97076448 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
|
|||
public class MaterialSliderSample : UIWidgetsPanel { |
|||
|
|||
protected override void main() { |
|||
ui_.runApp(new MaterialApp( |
|||
showPerformanceOverlay: false, |
|||
home: new MaterialSliderWidget())); |
|||
} |
|||
|
|||
protected new void OnEnable() { |
|||
base.OnEnable(); |
|||
} |
|||
} |
|||
|
|||
public class MaterialSliderWidget : StatefulWidget { |
|||
public override State createState() { |
|||
return new MaterialSliderState(); |
|||
} |
|||
} |
|||
|
|||
public class MaterialSliderState : State<MaterialSliderWidget> { |
|||
|
|||
float _value = 0.8f; |
|||
|
|||
void onChanged(float value) { |
|||
this.setState(() => { this._value = value; }); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Scaffold( |
|||
appBar: new AppBar( |
|||
title: new Text("Slider and Indicators")), |
|||
body: new Column( |
|||
children: new List<Widget> { |
|||
new Padding( |
|||
padding: EdgeInsets.only(top: 100.0f), |
|||
child: new Container( |
|||
child: new Slider( |
|||
divisions: 10, |
|||
min: 0.4f, |
|||
label: "Here", |
|||
value: this._value, |
|||
onChanged: this.onChanged)) |
|||
) |
|||
} |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0152b6f575e6ca44baea965a23ebe498 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
|
|||
public class MaterialTabBarSample : UIWidgetsPanel { |
|||
|
|||
protected override void main() { |
|||
ui_.runApp(new MaterialApp( |
|||
showPerformanceOverlay: false, |
|||
home: new TabBarDemo())); |
|||
} |
|||
|
|||
protected new void OnEnable() { |
|||
base.OnEnable(); |
|||
} |
|||
} |
|||
|
|||
public class TabBarDemo : StatelessWidget |
|||
{ |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
|
|||
return new MaterialTabBarWidget(); |
|||
/* |
|||
return new DefaultTabController( |
|||
length: 3, |
|||
child: new Scaffold( |
|||
appBar: new AppBar( |
|||
bottom: new TabBar( |
|||
tabs: new List<Widget> { |
|||
new Tab(icon: new Icon(Icons.directions_car)), |
|||
new Tab(icon: new Icon(Icons.directions_transit)), |
|||
new Tab(icon: new Icon(Icons.directions_bike)), |
|||
} |
|||
), |
|||
title: new Text("Tabs Demo") |
|||
), |
|||
body: new TabBarView( |
|||
children: new List<Widget> { |
|||
new Icon(Icons.directions_car), |
|||
new Icon(Icons.directions_transit), |
|||
new Icon(Icons.directions_bike), |
|||
} |
|||
) |
|||
) |
|||
);*/ |
|||
} |
|||
} |
|||
|
|||
public class MaterialTabBarWidget : StatefulWidget { |
|||
public MaterialTabBarWidget(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new MaterialTabBarWidgetState(); |
|||
} |
|||
} |
|||
|
|||
public class MaterialTabBarWidgetState : SingleTickerProviderStateMixin<MaterialTabBarWidget> { |
|||
TabController _tabController; |
|||
|
|||
public override void initState() { |
|||
base.initState(); |
|||
this._tabController = new TabController(vsync: this, length: Choice.choices.Count); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this._tabController.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _nextPage(int delta) { |
|||
int newIndex = this._tabController.index + delta; |
|||
if (newIndex < 0 || newIndex >= this._tabController.length) { |
|||
return; |
|||
} |
|||
|
|||
this._tabController.animateTo(newIndex); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<Widget> tapChildren = new List<Widget>(); |
|||
foreach (Choice choice in Choice.choices) { |
|||
tapChildren.Add( |
|||
new Padding( |
|||
padding: EdgeInsets.all(16.0f), |
|||
child: new ChoiceCard(choice: choice))); |
|||
} |
|||
|
|||
return new Scaffold( |
|||
appBar: new AppBar( |
|||
title: new Center( |
|||
child: new Text("AppBar Bottom Widget") |
|||
), |
|||
leading: new IconButton( |
|||
tooltip: "Previous choice", |
|||
icon: new Icon(Unity.UIWidgets.material.Icons.arrow_back), |
|||
onPressed: () => { this._nextPage(-1); } |
|||
), |
|||
actions: new List<Widget> { |
|||
new IconButton( |
|||
icon: new Icon(Unity.UIWidgets.material.Icons.arrow_forward), |
|||
tooltip: "Next choice", |
|||
onPressed: () => { this._nextPage(1); }) |
|||
}, |
|||
bottom: new PreferredSize( |
|||
preferredSize: Size.fromHeight(48.0f), |
|||
child: new Theme( |
|||
data: Theme.of(context).copyWith(accentColor: Colors.white), |
|||
child: new Container( |
|||
height: 48.0f, |
|||
alignment: Alignment.center, |
|||
child: new TabPageSelector( |
|||
controller: this._tabController)))) |
|||
), |
|||
body: new TabBarView( |
|||
controller: this._tabController, |
|||
children: tapChildren |
|||
)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fecd06f805d0b0f4ead134b1ad6a9a49 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.engine; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Image = Unity.UIWidgets.widgets.Image; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class MaterialThemeSample: UIWidgetsPanel { |
|||
|
|||
protected override void main() { |
|||
ui_.runApp(new MaterialApp( |
|||
home: new MaterialThemeSampleWidget(), |
|||
darkTheme: new ThemeData(primaryColor: Colors.black26) |
|||
)); |
|||
} |
|||
|
|||
protected new void OnEnable() { |
|||
base.OnEnable(); |
|||
} |
|||
} |
|||
|
|||
public class MaterialThemeSampleWidget: StatefulWidget { |
|||
public override State createState() { |
|||
return new _MaterialThemeSampleWidgetState(); |
|||
} |
|||
} |
|||
|
|||
class _MaterialThemeSampleWidgetState : State<MaterialThemeSampleWidget> { |
|||
public override Widget build(BuildContext context) { |
|||
return new Theme( |
|||
data: new ThemeData( |
|||
appBarTheme: new AppBarTheme( |
|||
color: Colors.purple |
|||
), |
|||
bottomAppBarTheme: new BottomAppBarTheme( |
|||
color: Colors.blue |
|||
), |
|||
cardTheme: new CardTheme( |
|||
color: Colors.red, |
|||
elevation: 2.0f |
|||
) |
|||
), |
|||
child: new Scaffold( |
|||
appBar: new AppBar(title: new Text("Test App Bar Theme")), |
|||
body: new Center( |
|||
child: new Card( |
|||
shape: new RoundedRectangleBorder( |
|||
borderRadius: BorderRadius.all(5.0f) |
|||
), |
|||
child: new Container( |
|||
height: 250, |
|||
child: new Column( |
|||
children: new List<Widget> { |
|||
new Text("Card Theme") |
|||
} |
|||
) |
|||
) |
|||
) |
|||
), |
|||
bottomNavigationBar: new BottomAppBar( |
|||
child: new Row( |
|||
mainAxisSize: MainAxisSize.max, |
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|||
children: new List<Widget> { |
|||
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.menu), onPressed: () => { }), |
|||
new IconButton(icon: new Icon(Unity.UIWidgets.material.Icons.account_balance), onPressed: () => { }) |
|||
}) |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b2a39cf0b83823749a13aebaf25cfb1b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using Material = Unity.UIWidgets.material.Material; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class ReorderableListSample : UIWidgetsPanel { |
|||
protected override void main() { |
|||
ui_.runApp(new MaterialApp( |
|||
showPerformanceOverlay: false, |
|||
home: new MaterialReorderableListViewWidget())); |
|||
} |
|||
|
|||
protected new void OnEnable() { |
|||
base.OnEnable(); |
|||
} |
|||
} |
|||
|
|||
class MaterialReorderableListViewWidget : StatefulWidget { |
|||
public MaterialReorderableListViewWidget(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new MaterialReorderableListViewWidgetState(); |
|||
} |
|||
} |
|||
|
|||
class MaterialReorderableListViewWidgetState : State<MaterialReorderableListViewWidget> { |
|||
List<string> _list = new List<string> {"Apple", "Ball", "Cat", "Dog", "Elephant"}; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Scaffold( |
|||
body: new ReorderableListView( |
|||
children: this._list.Select<string, Widget>((item) => |
|||
{ |
|||
return new ListTile( |
|||
Key.key(item), |
|||
title: new Text(item), |
|||
trailing: new Icon(Icons.menu)); |
|||
}).ToList(), |
|||
onReorder: (int start, int current) => |
|||
{ |
|||
if (start < current) { |
|||
int end = current - 1; |
|||
string startItem = _list[start]; |
|||
int i = 0; |
|||
int local = start; |
|||
do { |
|||
_list[local] = _list[++local]; |
|||
i++; |
|||
} while (i < end - start); |
|||
_list[end] = startItem; |
|||
} |
|||
// dragging from bottom to top
|
|||
else if (start > current) { |
|||
string startItem = _list[start]; |
|||
for (int i = start; i > current; i--) { |
|||
_list[i] = _list[i - 1]; |
|||
} |
|||
_list[current] = startItem; |
|||
} |
|||
setState(() => {}); |
|||
} |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f510d7fbd19431046bfb4b92c39b4da4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
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 class TableSample : UIWidgetsPanel { |
|||
|
|||
protected override void main() { |
|||
ui_.runApp(new MaterialApp( |
|||
showPerformanceOverlay: false, |
|||
home: new TableWidget())); |
|||
} |
|||
|
|||
protected new void OnEnable() { |
|||
base.OnEnable(); |
|||
} |
|||
} |
|||
|
|||
public class TableWidget : StatelessWidget { |
|||
public TableWidget(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Scaffold( |
|||
body: new Table( |
|||
children: new List<TableRow> { |
|||
new TableRow( |
|||
decoration: new BoxDecoration(color: Colors.blue), |
|||
children: new List<Widget> { |
|||
new Text("item 1"), |
|||
new Text("item 2") |
|||
} |
|||
), |
|||
new TableRow(children: new List<Widget> { |
|||
new Text("item 3"), |
|||
new Text("item 4") |
|||
} |
|||
) |
|||
}, |
|||
defaultVerticalAlignment: TableCellVerticalAlignment.middle)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1cba65c03fbf50f4cac974273a7c9445 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 00ea9ee5829c47a687a61fb521f91107 |
|||
timeCreated: 1612237197 |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.rendering; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
|
|||
public abstract class _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverFloatingPersistentHeader : RenderSliverFloatingPersistentHeader, _RenderSliverPersistentHeaderForWidgetsMixin { |
|||
|
|||
public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverFloatingPersistentHeader( |
|||
RenderBox child = null, |
|||
FloatingHeaderSnapConfiguration snapConfiguration = null, |
|||
OverScrollHeaderStretchConfiguration stretchConfiguration = null |
|||
) : base( |
|||
child: child, |
|||
stretchConfiguration: stretchConfiguration) { |
|||
_snapConfiguration = snapConfiguration; |
|||
} |
|||
|
|||
public _SliverPersistentHeaderElement _element { |
|||
get { |
|||
return sliver_persistent_header_utils._element; |
|||
} |
|||
set { |
|||
if (value == sliver_persistent_header_utils._element) { |
|||
return; |
|||
} |
|||
|
|||
sliver_persistent_header_utils._element = value; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override float? minExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
public override float? maxExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
protected override void updateChild(float shrinkOffset, bool overlapsContent) { |
|||
D.assert(_element != null); |
|||
_element._build(shrinkOffset, overlapsContent); |
|||
} |
|||
|
|||
void _RenderSliverPersistentHeaderForWidgetsMixin.triggerRebuild() { |
|||
triggerRebuild(); |
|||
} |
|||
|
|||
void triggerRebuild() { |
|||
markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
public abstract class _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverFloatingPinnedPersistentHeader : RenderSliverFloatingPinnedPersistentHeader, _RenderSliverPersistentHeaderForWidgetsMixin { |
|||
|
|||
public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverFloatingPinnedPersistentHeader( |
|||
RenderBox child = null, |
|||
FloatingHeaderSnapConfiguration snapConfiguration = null, |
|||
OverScrollHeaderStretchConfiguration stretchConfiguration = null |
|||
) : base(child: child, |
|||
snapConfiguration: snapConfiguration, |
|||
stretchConfiguration: stretchConfiguration) { |
|||
} |
|||
|
|||
public _SliverPersistentHeaderElement _element { |
|||
get { |
|||
return sliver_persistent_header_utils._element; |
|||
} |
|||
set { |
|||
if (value == sliver_persistent_header_utils._element) { |
|||
return; |
|||
} |
|||
|
|||
sliver_persistent_header_utils._element = value; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override float? minExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
public override float? maxExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
protected override void updateChild(float shrinkOffset, bool overlapsContent) { |
|||
D.assert(_element != null); |
|||
_element._build(shrinkOffset, overlapsContent); |
|||
} |
|||
|
|||
void _RenderSliverPersistentHeaderForWidgetsMixin.triggerRebuild() { |
|||
triggerRebuild(); |
|||
} |
|||
|
|||
void triggerRebuild() { |
|||
markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
public abstract class _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverPinnedPersistentHeader : RenderSliverPinnedPersistentHeader, _RenderSliverPersistentHeaderForWidgetsMixin { |
|||
|
|||
public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverPinnedPersistentHeader( |
|||
RenderBox child = null, |
|||
OverScrollHeaderStretchConfiguration stretchConfiguration = null |
|||
) : base(child: child, |
|||
stretchConfiguration: stretchConfiguration) { |
|||
} |
|||
|
|||
public _SliverPersistentHeaderElement _element { |
|||
get { |
|||
return sliver_persistent_header_utils._element; |
|||
} |
|||
set { |
|||
if (value == sliver_persistent_header_utils._element) { |
|||
return; |
|||
} |
|||
|
|||
sliver_persistent_header_utils._element = value; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override float? minExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
public override float? maxExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
protected override void updateChild(float shrinkOffset, bool overlapsContent) { |
|||
D.assert(_element != null); |
|||
_element._build(shrinkOffset, overlapsContent); |
|||
} |
|||
|
|||
void _RenderSliverPersistentHeaderForWidgetsMixin.triggerRebuild() { |
|||
triggerRebuild(); |
|||
} |
|||
|
|||
void triggerRebuild() { |
|||
markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
public abstract class _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverScrollingPersistentHeader : RenderSliverScrollingPersistentHeader, _RenderSliverPersistentHeaderForWidgetsMixin { |
|||
|
|||
public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverScrollingPersistentHeader( |
|||
RenderBox child = null, |
|||
OverScrollHeaderStretchConfiguration stretchConfiguration = null |
|||
) : base(child: child, |
|||
stretchConfiguration: stretchConfiguration) { |
|||
} |
|||
|
|||
public _SliverPersistentHeaderElement _element { |
|||
get { |
|||
return sliver_persistent_header_utils._element; |
|||
} |
|||
set { |
|||
if (value == sliver_persistent_header_utils._element) { |
|||
return; |
|||
} |
|||
|
|||
sliver_persistent_header_utils._element = value; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override float? minExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
public override float? maxExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
protected override void updateChild(float shrinkOffset, bool overlapsContent) { |
|||
D.assert(_element != null); |
|||
_element._build(shrinkOffset, overlapsContent); |
|||
} |
|||
|
|||
void _RenderSliverPersistentHeaderForWidgetsMixin.triggerRebuild() { |
|||
triggerRebuild(); |
|||
} |
|||
|
|||
void triggerRebuild() { |
|||
markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.rendering; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
{% macro _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader(with) %} |
|||
public abstract class _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader{{with}} : {{with}}, _RenderSliverPersistentHeaderForWidgetsMixin { |
|||
|
|||
public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverFloatingPersistentHeader( |
|||
RenderBox child = null, |
|||
FloatingHeaderSnapConfiguration snapConfiguration = null, |
|||
OverScrollHeaderStretchConfiguration stretchConfiguration = null |
|||
) : base( |
|||
child: child, |
|||
stretchConfiguration: stretchConfiguration) { |
|||
_snapConfiguration = snapConfiguration; |
|||
} |
|||
|
|||
public _SliverPersistentHeaderElement _element { |
|||
get { |
|||
return sliver_persistent_header_utils._element; |
|||
} |
|||
set { |
|||
if (value == sliver_persistent_header_utils._element) { |
|||
return; |
|||
} |
|||
|
|||
sliver_persistent_header_utils._element = value; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override float? minExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
public override float? maxExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
protected override void updateChild(float shrinkOffset, bool overlapsContent) { |
|||
D.assert(_element != null); |
|||
_element._build(shrinkOffset, overlapsContent); |
|||
} |
|||
|
|||
void _RenderSliverPersistentHeaderForWidgetsMixin.triggerRebuild() { |
|||
triggerRebuild(); |
|||
} |
|||
|
|||
void triggerRebuild() { |
|||
markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
{% endmacro %} |
|||
|
|||
{{ _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader('RenderSliverFloatingPersistentHeader') }} |
|||
|
|||
{% macro _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader(with) %} |
|||
public abstract class _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader{{with}} : {{with}}, _RenderSliverPersistentHeaderForWidgetsMixin { |
|||
|
|||
public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverFloatingPinnedPersistentHeader( |
|||
RenderBox child = null, |
|||
FloatingHeaderSnapConfiguration snapConfiguration = null, |
|||
OverScrollHeaderStretchConfiguration stretchConfiguration = null |
|||
) : base(child: child, |
|||
snapConfiguration: snapConfiguration, |
|||
stretchConfiguration: stretchConfiguration) { |
|||
} |
|||
|
|||
public _SliverPersistentHeaderElement _element { |
|||
get { |
|||
return sliver_persistent_header_utils._element; |
|||
} |
|||
set { |
|||
if (value == sliver_persistent_header_utils._element) { |
|||
return; |
|||
} |
|||
|
|||
sliver_persistent_header_utils._element = value; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override float? minExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
public override float? maxExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
protected override void updateChild(float shrinkOffset, bool overlapsContent) { |
|||
D.assert(_element != null); |
|||
_element._build(shrinkOffset, overlapsContent); |
|||
} |
|||
|
|||
void _RenderSliverPersistentHeaderForWidgetsMixin.triggerRebuild() { |
|||
triggerRebuild(); |
|||
} |
|||
|
|||
void triggerRebuild() { |
|||
markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
{% endmacro %} |
|||
|
|||
|
|||
|
|||
{{ _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader('RenderSliverFloatingPinnedPersistentHeader') }} |
|||
|
|||
{% macro _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader(with) %} |
|||
public abstract class _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader{{with}} : {{with}}, _RenderSliverPersistentHeaderForWidgetsMixin { |
|||
|
|||
public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverPinnedPersistentHeader( |
|||
RenderBox child = null, |
|||
OverScrollHeaderStretchConfiguration stretchConfiguration = null |
|||
) : base(child: child, |
|||
stretchConfiguration: stretchConfiguration) { |
|||
} |
|||
|
|||
public _SliverPersistentHeaderElement _element { |
|||
get { |
|||
return sliver_persistent_header_utils._element; |
|||
} |
|||
set { |
|||
if (value == sliver_persistent_header_utils._element) { |
|||
return; |
|||
} |
|||
|
|||
sliver_persistent_header_utils._element = value; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override float? minExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
public override float? maxExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
protected override void updateChild(float shrinkOffset, bool overlapsContent) { |
|||
D.assert(_element != null); |
|||
_element._build(shrinkOffset, overlapsContent); |
|||
} |
|||
|
|||
void _RenderSliverPersistentHeaderForWidgetsMixin.triggerRebuild() { |
|||
triggerRebuild(); |
|||
} |
|||
|
|||
void triggerRebuild() { |
|||
markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
{% endmacro %} |
|||
|
|||
{{ _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader('RenderSliverPinnedPersistentHeader') }} |
|||
|
|||
{% macro _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader(with) %} |
|||
public abstract class _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader{{with}} : {{with}}, _RenderSliverPersistentHeaderForWidgetsMixin { |
|||
|
|||
public _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeaderRenderSliverScrollingPersistentHeader( |
|||
RenderBox child = null, |
|||
OverScrollHeaderStretchConfiguration stretchConfiguration = null |
|||
) : base(child: child, |
|||
stretchConfiguration: stretchConfiguration) { |
|||
} |
|||
|
|||
public _SliverPersistentHeaderElement _element { |
|||
get { |
|||
return sliver_persistent_header_utils._element; |
|||
} |
|||
set { |
|||
if (value == sliver_persistent_header_utils._element) { |
|||
return; |
|||
} |
|||
|
|||
sliver_persistent_header_utils._element = value; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override float? minExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
public override float? maxExtent { |
|||
get { |
|||
return _element.widget.layoutDelegate.minExtent; |
|||
} |
|||
} |
|||
|
|||
protected override void updateChild(float shrinkOffset, bool overlapsContent) { |
|||
D.assert(_element != null); |
|||
_element._build(shrinkOffset, overlapsContent); |
|||
} |
|||
|
|||
void _RenderSliverPersistentHeaderForWidgetsMixin.triggerRebuild() { |
|||
triggerRebuild(); |
|||
} |
|||
|
|||
void triggerRebuild() { |
|||
markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
base.performLayout(); |
|||
} |
|||
} |
|||
{% endmacro %} |
|||
|
|||
{{ _RenderSliverPersistentHeaderForWidgetsMixinOnRenderSliverPersistentHeader('RenderSliverScrollingPersistentHeader') }} |
|||
|
|||
} |
|
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class DragDropSample : UIWidgetsPanel { |
|||
protected override void main() { |
|||
ui_.runApp(new MyApp()); |
|||
} |
|||
|
|||
class MyApp : StatelessWidget |
|||
{ |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new WidgetsApp( |
|||
home: new DragDropApp(), |
|||
pageRouteBuilder: (settings, builder) => |
|||
new PageRouteBuilder( |
|||
settings: settings, |
|||
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class DragDropApp : StatefulWidget { |
|||
public DragDropApp(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new DragDropState(); |
|||
} |
|||
} |
|||
|
|||
class DragTargetWidget : StatefulWidget { |
|||
public DragTargetWidget(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new DragTargetWidgetState(); |
|||
} |
|||
} |
|||
|
|||
class DragTargetWidgetState : State<DragTargetWidget> { |
|||
int value; |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new Positioned( |
|||
left: 40.0f, |
|||
bottom: 40.0f, |
|||
child: new DragTarget<int>( |
|||
onWillAccept: (o) => true, |
|||
onAccept: obj => { |
|||
Debug.Log("ON ACCEPTED ..." + obj); |
|||
this.setState(() => { this.value += obj; }); |
|||
}, |
|||
builder: (inner_context2, accepted, rejected) => { |
|||
return new Container( |
|||
width: 40.0f, |
|||
height: 40.0f, |
|||
constraints: BoxConstraints.tight(new Size(40, 40)), |
|||
color: Colors.red, |
|||
child: new Center(child: new Text("" + this.value)) |
|||
); |
|||
} |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class DragDropState : State<DragDropApp> { |
|||
public override Widget build(BuildContext context) { |
|||
var entries = new List<OverlayEntry>(); |
|||
|
|||
var entry_bg = new OverlayEntry( |
|||
inner_context => new Container( |
|||
color: Colors.white |
|||
)); |
|||
|
|||
var entry = new OverlayEntry( |
|||
inner_context => new Positioned( |
|||
left: 0.0f, |
|||
bottom: 0.0f, |
|||
child: new GestureDetector( |
|||
onTap: () => { }, |
|||
child: new Draggable<int>( |
|||
data: 5, |
|||
child: new Container( |
|||
color: Colors.blue, |
|||
width: 30.0f, |
|||
height: 30.0f, |
|||
constraints: BoxConstraints.tight(new Size(30, 30)), |
|||
child: new Center(child: new Text("5")) |
|||
), |
|||
feedback: new Container( |
|||
color: Colors.green, |
|||
width: 30.0f, |
|||
height: 30.0f), |
|||
//maxSimultaneousDrags: 1,
|
|||
childWhenDragging: new Container( |
|||
color: Colors.black, |
|||
width: 30.0f, |
|||
height: 30.0f, |
|||
constraints: BoxConstraints.tight(new Size(30, 30)) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
var entry3 = new OverlayEntry( |
|||
inner_context => new Positioned( |
|||
left: 0.0f, |
|||
bottom: 40.0f, |
|||
child: new GestureDetector( |
|||
onTap: () => { }, |
|||
child: |
|||
new Draggable<int>( |
|||
data: 8, |
|||
child: new Container( |
|||
color: Colors.grey, |
|||
width: 30.0f, |
|||
height: 30.0f, |
|||
constraints: BoxConstraints.tight(new Size(30, 30)), |
|||
child: new Center(child: new Text("8"))) |
|||
, |
|||
feedback: new Container( |
|||
color: Colors.green, |
|||
width: 30.0f, |
|||
height: 30.0f), |
|||
maxSimultaneousDrags: 1, |
|||
childWhenDragging: new Container( |
|||
color: Colors.black, |
|||
width: 30.0f, |
|||
height: 30.0f, |
|||
constraints: BoxConstraints.tight(new Size(30, 30)) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
var entry2 = new OverlayEntry( |
|||
inner_context => new DragTargetWidget() |
|||
); |
|||
|
|||
entries.Add(entry_bg); |
|||
entries.Add(entry); |
|||
entries.Add(entry2); |
|||
entries.Add(entry3); |
|||
|
|||
return new Container( |
|||
color: Colors.white, |
|||
child: new Overlay( |
|||
initialEntries: entries |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f6b796615f43b734d8c9507513773ff3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using uiwidgets; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class LongPressSample : UIWidgetsPanel { |
|||
protected override void main() { |
|||
ui_.runApp(new MyApp()); |
|||
} |
|||
} |
|||
|
|||
class MyApp : StatelessWidget |
|||
{ |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new WidgetsApp( |
|||
home: new LongPressSampleWidget(), |
|||
pageRouteBuilder: (settings, builder) => |
|||
new PageRouteBuilder( |
|||
settings: settings, |
|||
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
public class LongPressSampleWidget : StatefulWidget { |
|||
public override State createState() { |
|||
return new _LongPressSampleWidgetState(); |
|||
} |
|||
} |
|||
|
|||
class _LongPressSampleWidgetState : State<LongPressSampleWidget> { |
|||
public override Widget build(BuildContext context) { |
|||
return new GestureDetector( |
|||
onLongPressStart: (value) => { Debug.Log($"Long Press Drag Start: {value}"); }, |
|||
onLongPressMoveUpdate: (value) => { Debug.Log($"Long Press Drag Update: {value}"); }, |
|||
onLongPressEnd: (value) => { Debug.Log($"Long Press Drag Up: {value}"); }, |
|||
onLongPressUp: () => { Debug.Log($"Long Press Up"); }, |
|||
onLongPress: () => { Debug.Log($"Long Press"); }, |
|||
child: new Center( |
|||
child: new Container( |
|||
width: 200, |
|||
height: 200, |
|||
color: Colors.blue |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b77689aad2545fb4bb66d5d41126fab2 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using DialogUtils = Unity.UIWidgets.widgets.DialogUtils; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class NavigationSample : UIWidgetsPanel { |
|||
|
|||
protected override void main() |
|||
{ |
|||
ui_.runApp(new MyApp()); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
class MyApp : StatelessWidget |
|||
{ |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new WidgetsApp( |
|||
initialRoute: "/", |
|||
textStyle: new TextStyle(fontSize: 24), |
|||
pageRouteBuilder: (settings, builder) => |
|||
new PageRouteBuilder( |
|||
settings: settings, |
|||
pageBuilder: (BuildContext subContext, Animation<float> animation, |
|||
Animation<float> secondaryAnimation) => builder(subContext), |
|||
transitionsBuilder: (BuildContext subContext, Animation<float> |
|||
animation, Animation<float> secondaryAnimation, Widget child) => |
|||
new _FadeUpwardsPageTransition( |
|||
routeAnimation: animation, |
|||
child: child |
|||
) |
|||
), |
|||
routes: new Dictionary<string, WidgetBuilder> { |
|||
{"/", (subContext) => new HomeScreen()}, |
|||
{"/detail", (subContext) => new DetailScreen()} |
|||
} |
|||
); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public class CustomButton : StatelessWidget { |
|||
public CustomButton( |
|||
Key key = null, |
|||
GestureTapCallback onPressed = null, |
|||
EdgeInsets padding = null, |
|||
Color backgroundColor = null, |
|||
Widget child = null |
|||
) : base(key: key) { |
|||
this.onPressed = onPressed; |
|||
this.padding = padding ?? EdgeInsets.all(8.0f); |
|||
this.backgroundColor = backgroundColor ?? Colors.white; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly GestureTapCallback onPressed; |
|||
public readonly EdgeInsets padding; |
|||
public readonly Widget child; |
|||
public readonly Color backgroundColor; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new GestureDetector( |
|||
onTap: this.onPressed, |
|||
child: new Container( |
|||
padding: this.padding, |
|||
color: this.backgroundColor, |
|||
child: this.child |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
|
|||
class HomeScreen : StatelessWidget { |
|||
public override Widget build(BuildContext context) { |
|||
return new NavigationPage( |
|||
body: new Container( |
|||
color: new Color(0xFF888888), |
|||
child: new Center( |
|||
child: new CustomButton(onPressed: () => { Navigator.pushNamed(context, "/detail"); }, |
|||
child: new Text("Go to Detail")) |
|||
)), |
|||
title: "Home" |
|||
); |
|||
} |
|||
} |
|||
|
|||
class DetailScreen : StatelessWidget { |
|||
public override Widget build(BuildContext context) { |
|||
return new NavigationPage( |
|||
body: new Container( |
|||
color: new Color(0xFF1389FD), |
|||
child: new Center( |
|||
child: new Column( |
|||
children: new List<Widget>() { |
|||
new CustomButton(onPressed: () => { Navigator.pop<object>(context); }, child: new Text("Back")), |
|||
new CustomButton( |
|||
onPressed: () => { |
|||
_Dialog.showDialog(context, builder: (BuildContext c) => new Dialog()); |
|||
}, child: new Text("Show Dialog")) |
|||
} |
|||
) |
|||
)), |
|||
title: "Detail"); |
|||
} |
|||
} |
|||
|
|||
class Dialog : StatelessWidget { |
|||
public override Widget build(BuildContext context) { |
|||
return new Center(child: new Container( |
|||
color: new Color(0xFFFF0000), |
|||
width: 100, |
|||
height: 80, |
|||
child: new Center( |
|||
child: new Text("Hello Dialog") |
|||
))); |
|||
} |
|||
} |
|||
|
|||
class _FadeUpwardsPageTransition : StatelessWidget { |
|||
internal _FadeUpwardsPageTransition( |
|||
Key key = null, |
|||
Animation<float> routeAnimation = null, // The route's linear 0.0 - 1.0 animation.
|
|||
Widget child = null |
|||
) : base(key: key) { |
|||
this._positionAnimation = _bottomUpTween.chain(_fastOutSlowInTween).animate(routeAnimation); |
|||
this._opacityAnimation = _easeInTween.animate(routeAnimation); |
|||
this.child = child; |
|||
} |
|||
|
|||
static Tween<Offset> _bottomUpTween = new OffsetTween( |
|||
begin: new Offset(0.0f, 0.25f), |
|||
end: Offset.zero |
|||
); |
|||
|
|||
static Animatable<float> _fastOutSlowInTween = new CurveTween(curve: Curves.fastOutSlowIn); |
|||
static Animatable<float> _easeInTween = new CurveTween(curve: Curves.easeIn); |
|||
|
|||
readonly Animation<Offset> _positionAnimation; |
|||
readonly Animation<float> _opacityAnimation; |
|||
public readonly Widget child; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new SlideTransition( |
|||
position: this._positionAnimation, |
|||
child: new FadeTransition( |
|||
opacity: this._opacityAnimation, |
|||
child: this.child |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class NavigationPage : StatelessWidget { |
|||
public readonly Widget body; |
|||
public readonly string title; |
|||
|
|||
public NavigationPage(Widget body = null, string title = null) { |
|||
this.title = title; |
|||
this.body = body; |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
Widget back = null; |
|||
if (Navigator.of(context).canPop()) { |
|||
back = new CustomButton(onPressed: () => { Navigator.pop<object>(context); }, |
|||
child: new Text("Go Back")); |
|||
back = new Column(mainAxisAlignment: MainAxisAlignment.center, children: new List<Widget>() {back}); |
|||
} |
|||
|
|||
|
|||
return new Container( |
|||
child: new Column( |
|||
children: new List<Widget>() { |
|||
new ConstrainedBox(constraints: new BoxConstraints(maxHeight: 80), |
|||
child: new DecoratedBox( |
|||
decoration: new BoxDecoration(color: new Color(0XFFE1ECF4)), |
|||
child: new NavigationToolbar(leading: back, |
|||
middle: new Text(this.title, textAlign: TextAlign.center)))), |
|||
new Flexible(child: this.body) |
|||
} |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
static class _Dialog { |
|||
public static void showDialog(BuildContext context, |
|||
bool barrierDismissible = true, WidgetBuilder builder = null) { |
|||
DialogUtils.showGeneralDialog<object>( |
|||
context: context, |
|||
pageBuilder: (BuildContext buildContext, Animation<float> animation, |
|||
Animation<float> secondaryAnimation) => { |
|||
return builder(buildContext); |
|||
}, |
|||
barrierDismissible: barrierDismissible, |
|||
barrierColor: new Color(0x8A000000), |
|||
transitionDuration: TimeSpan.FromMilliseconds(150), |
|||
transitionBuilder: _buildMaterialDialogTransitions |
|||
); |
|||
} |
|||
|
|||
static Widget _buildMaterialDialogTransitions(BuildContext context, |
|||
Animation<float> animation, Animation<float> secondaryAnimation, Widget child) { |
|||
return new FadeTransition( |
|||
opacity: new CurvedAnimation( |
|||
parent: animation, |
|||
curve: Curves.easeOut |
|||
), |
|||
child: child |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 351f52ea9be972a48ad92328d8a99951 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class PageViewSample : UIWidgetsPanel { |
|||
|
|||
protected override void main() |
|||
{ |
|||
ui_.runApp(new MyApp()); |
|||
} |
|||
|
|||
class MyApp : StatelessWidget |
|||
{ |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new WidgetsApp( |
|||
home: new Container( |
|||
width: 200, |
|||
height: 400, |
|||
child: new PageView( |
|||
children: new List<Widget>() { |
|||
new Container( |
|||
color: new Color(0xFFE91E63) |
|||
), |
|||
new Container( |
|||
color: new Color(0xFF00BCD4) |
|||
), |
|||
new Container( |
|||
color: new Color(0xFF673AB7) |
|||
) |
|||
} |
|||
)), |
|||
pageRouteBuilder: (settings, builder) => |
|||
new PageRouteBuilder( |
|||
settings: settings, |
|||
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dfec4b1201ff9494e83d2f2cc6e22f82 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class ScrollbarSample : UIWidgetsPanel { |
|||
protected override void main() |
|||
{ |
|||
ui_.runApp(new MyApp()); |
|||
} |
|||
|
|||
class MyApp : StatelessWidget |
|||
{ |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new WidgetsApp( |
|||
home: new Container( |
|||
decoration: new BoxDecoration( |
|||
border: Border.all(color: new Color(0xFFFFFF00)) |
|||
), |
|||
child: new Scrollbar( |
|||
child: new ListView( |
|||
children: new List<Widget> { |
|||
new Container(height: 40.0f, child: new Text("0")), |
|||
new Container(height: 40.0f, child: new Text("1")), |
|||
new Container(height: 40.0f, child: new Text("2")), |
|||
new Container(height: 40.0f, child: new Text("3")), |
|||
new Container(height: 40.0f, child: new Text("4")), |
|||
new Container(height: 40.0f, child: new Text("5")), |
|||
new Container(height: 40.0f, child: new Text("6")), |
|||
new Container(height: 40.0f, child: new Text("7")), |
|||
new Container(height: 40.0f, child: new Text("8")), |
|||
new Container(height: 40.0f, child: new Text("9")), |
|||
new Container(height: 40.0f, child: new Text("10")), |
|||
new Container(height: 40.0f, child: new Text("11")), |
|||
new Container(height: 40.0f, child: new Text("12")), |
|||
new Container(height: 40.0f, child: new Text("13")), |
|||
new Container(height: 40.0f, child: new Text("14")), |
|||
new Container(height: 40.0f, child: new Text("15")), |
|||
new Container(height: 40.0f, child: new Text("16")), |
|||
new Container(height: 40.0f, child: new Text("17")), |
|||
} |
|||
) |
|||
) |
|||
), |
|||
pageRouteBuilder: (settings, builder) => |
|||
new PageRouteBuilder( |
|||
settings: settings, |
|||
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0666abb393df1e44bb00b1cff94ad6ca |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class CustomPaintSample : UIWidgetsPanel { |
|||
protected override void main() |
|||
{ |
|||
ui_.runApp(new MyApp()); |
|||
} |
|||
|
|||
class MyApp : StatelessWidget |
|||
{ |
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new WidgetsApp( |
|||
home: new Unity.UIWidgets.widgets.CustomPaint( |
|||
child: new Container(width: 300, height: 300, color: new Color(0XFFFFFFFF)), |
|||
foregroundPainter: new GridPainter(null) |
|||
), |
|||
pageRouteBuilder: (settings, builder) => |
|||
new PageRouteBuilder( |
|||
settings: settings, |
|||
pageBuilder: (Buildcontext, animation, secondaryAnimation) => builder(context) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
public class GridPainter : AbstractCustomPainter { |
|||
public GridPainter(Listenable repaint) : base(repaint) { |
|||
} |
|||
|
|||
public override void paint(Canvas canvas, Size size) { |
|||
int numGrid = 4; |
|||
var paint = new Paint(); |
|||
paint.color = new Color(0xFFFF0000); |
|||
paint.strokeWidth = 2; |
|||
paint.style = PaintingStyle.stroke; |
|||
for (int i = 1; i < numGrid; i++) { |
|||
float offsetY = size.height * i / numGrid; |
|||
canvas.drawLine(new Offset(0, offsetY), new Offset(size.width, offsetY), |
|||
paint); |
|||
} |
|||
|
|||
for (int i = 1; i < numGrid; i++) { |
|||
float offsetx = size.width * i / numGrid; |
|||
canvas.drawLine(new Offset(offsetx, 0), new Offset(offsetx, size.height), |
|||
paint); |
|||
} |
|||
|
|||
|
|||
// draw a arrow line
|
|||
canvas.save(); |
|||
canvas.rotate(0.4f); |
|||
canvas.scale(2, 2); |
|||
canvas.translate(50, 50); |
|||
canvas.drawLine(new Offset(0, 0), new Offset(100, 0), |
|||
new Paint() { |
|||
color = new Color(0xFFFF0000), |
|||
strokeWidth = 2, |
|||
style = PaintingStyle.stroke |
|||
}); |
|||
var path = new Path(); |
|||
var arrowPaint = new Paint() { |
|||
color = new Color(0xFFFF0000), |
|||
style = PaintingStyle.fill |
|||
}; |
|||
path.moveTo(100, 0); |
|||
path.lineTo(100, 5); |
|||
path.lineTo(120, 0); |
|||
path.lineTo(100, -5); |
|||
path.close(); |
|||
canvas.drawPath(path, arrowPaint); |
|||
canvas.restore(); |
|||
} |
|||
|
|||
public override bool shouldRepaint(CustomPainter oldDelegate) { |
|||
return false; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 64240ba829347de43abdb2daa8488bc6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using uiwidgets; |
|||
using Unity.UIWidgets.engine; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Material = Unity.UIWidgets.material.Material; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class ExpansionPanelSample : UIWidgetsPanel { |
|||
|
|||
protected override void main() { |
|||
ui_.runApp(new MyApp()); |
|||
} |
|||
|
|||
class MyApp : StatelessWidget |
|||
{ |
|||
int testCaseId = 1; |
|||
|
|||
readonly List<Widget> testCases = new List<Widget> { |
|||
new SingleChildScrollWidget(), |
|||
new ExpansionPanelWidget() |
|||
}; |
|||
|
|||
public override Widget build(BuildContext context) |
|||
{ |
|||
return new MaterialApp( |
|||
home: this.testCases[this.testCaseId] |
|||
); |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
class SingleChildScrollWidget : StatefulWidget { |
|||
public SingleChildScrollWidget(Key key = null) : base(key) { |
|||
} |
|||
|
|||
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.0f, |
|||
height: 40.0f, |
|||
constraints: BoxConstraints.tight(new Size(40, 600)), |
|||
color:Colors.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> { |
|||
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") |
|||
) |
|||
); |
|||
}, |
|||
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] |
|||
), |
|||
} |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 49545bd84f0a8614e866467b68490383 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.engine; |
|||
using Unity.UIWidgets.engine2; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using UnityEngine.Networking; |
|||
using ui_ = Unity.UIWidgets.widgets.ui_; |
|||
|
|||
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 AsyncRequestWidget(GameObject gameObjOfUiWidgetsPanel, Key key = null) : base(key) { |
|||
this.gameObjOfUIWidgetsPanel = gameObjOfUiWidgetsPanel; |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new _AsyncRequestWidgetState(); |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class TimeData { |
|||
public long currentFileTime; |
|||
} |
|||
|
|||
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)) |
|||
{ |
|||
this.setState(() => { this._fileTime = timeData.currentFileTime; }); |
|||
} |
|||
|
|||
}; |
|||
}), |
|||
new Text($"current file time: {this._fileTime}") |
|||
}); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b8fdebced4875694db8d21968f82b2c9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue