浏览代码

add samples and bug fix

/siyaoH-1.17-PlatformMessage
xingwei.zhu 4 年前
当前提交
c1269e1c
共有 7 个文件被更改,包括 753 次插入310 次删除
  1. 379
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/reorderable_list_demo.cs
  2. 8
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demo.cs
  3. 244
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs
  4. 1
      com.unity.uiwidgets/Runtime/material/radio.cs
  5. 1
      com.unity.uiwidgets/Runtime/material/switch.cs
  6. 222
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/scrollable_tabs_demo.cs
  7. 208
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/selection_controls_demo.cs

379
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/reorderable_list_demo.cs


namespace UIWidgetsGallery.demo.material
{
enum _ReorderableListType {
internal enum _ReorderableListType
{
/// A list tile that contains a [CircleAvatar].
horizontalAvatar,

/// A list tile that contains three lines of text and a checkbox.
threeLine,
}
class ReorderableListDemo : StatefulWidget {
public ReorderableListDemo(Key key = null) : base(key: key)
internal class ReorderableListDemo : StatefulWidget
{
public ReorderableListDemo(Key key = null) : base(key: key)
public static readonly string routeName = "/material/reorderable-list";
public static readonly string routeName = "/material/reorderable-list";
public override State createState() => new _ReorderableListDemoState();
}
class _ListItem {
public override State createState()
{
return new _ReorderableListDemoState();
}
}
internal class _ListItem
{
public _ListItem(string value, bool? checkState)
{
this.value = value;

public readonly string value;
internal bool? checkState;
internal bool? checkState;
class _ReorderableListDemoState : State<ReorderableListDemo> {
static readonly GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>.key();
PersistentBottomSheetController<object> _bottomSheet;
_ReorderableListType _itemType = _ReorderableListType.threeLine;
bool _reverse = false;
bool _reverseSort = false;
static readonly List<_ListItem> _items = new List<string>{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
}.Select<string, _ListItem>((string item) => new _ListItem(item, false)).ToList();
internal class _ReorderableListDemoState : State<ReorderableListDemo>
{
private static readonly GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>.key();
void changeItemType(_ReorderableListType type) {
setState(() => {
_itemType = type;
});
// Rebuild the bottom sheet to reflect the selected list view.
_bottomSheet?.setState(() => {
// Trigger a rebuild.
});
// Close the bottom sheet to give the user a clear view of the list.
_bottomSheet?.close();
}
private PersistentBottomSheetController<object> _bottomSheet;
private _ReorderableListType _itemType = _ReorderableListType.threeLine;
private bool _reverse = false;
private bool _reverseSort = false;
void changeReverse(bool? newValue) {
setState(() => {
_reverse = newValue.Value;
});
// Rebuild the bottom sheet to reflect the selected list view.
_bottomSheet?.setState(() => {
// Trigger a rebuild.
});
// Close the bottom sheet to give the user a clear view of the list.
_bottomSheet?.close();
}
private static readonly List<_ListItem> _items = new List<string>
{
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
}.Select<string, _ListItem>((string item) => new _ListItem(item, false)).ToList();
void _showConfigurationSheet() {
setState(() => {
_bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) => {
return new DecoratedBox(
decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: Colors.black26))
),
child: new ListView(
shrinkWrap: true,
primary: false,
children: new List<Widget>{
new CheckboxListTile(
dense: true,
title: new Text("Reverse"),
value: _reverse,
onChanged: changeReverse
),
new RadioListTile<_ReorderableListType>(
dense: true,
title: new Text("Horizontal Avatars"),
value: _ReorderableListType.horizontalAvatar,
groupValue: _itemType,
onChanged: changeItemType
),
new RadioListTile<_ReorderableListType>(
dense: true,
title: new Text("Vertical Avatars"),
value: _ReorderableListType.verticalAvatar,
groupValue: _itemType,
onChanged: changeItemType
),
new RadioListTile<_ReorderableListType>(
dense: true,
title: new Text("Three-line"),
value: _ReorderableListType.threeLine,
groupValue: _itemType,
onChanged: changeItemType
)
}
)
);
});
private void changeItemType(_ReorderableListType type)
{
setState(() => { _itemType = type; });
// Rebuild the bottom sheet to reflect the selected list view.
_bottomSheet?.setState(() =>
{
// Trigger a rebuild.
});
// Close the bottom sheet to give the user a clear view of the list.
_bottomSheet?.close();
}
// Garbage collect the bottom sheet when it closes.
_bottomSheet.closed.whenComplete(() => {
if (mounted) {
setState(() => {
_bottomSheet = null;
});
private void changeReverse(bool? newValue)
{
setState(() => { _reverse = newValue.Value; });
// Rebuild the bottom sheet to reflect the selected list view.
_bottomSheet?.setState(() =>
{
// Trigger a rebuild.
});
// Close the bottom sheet to give the user a clear view of the list.
_bottomSheet?.close();
});
});
}
private void _showConfigurationSheet()
{
setState(() =>
{
_bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) =>
{
return new DecoratedBox(
decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: Colors.black26))
),
child: new ListView(
shrinkWrap: true,
primary: false,
children: new List<Widget>
{
new CheckboxListTile(
dense: true,
title: new Text("Reverse"),
value: _reverse,
onChanged: changeReverse
),
new RadioListTile<_ReorderableListType>(
dense: true,
title: new Text("Horizontal Avatars"),
value: _ReorderableListType.horizontalAvatar,
groupValue: _itemType,
onChanged: changeItemType
),
new RadioListTile<_ReorderableListType>(
dense: true,
title: new Text("Vertical Avatars"),
value: _ReorderableListType.verticalAvatar,
groupValue: _itemType,
onChanged: changeItemType
),
new RadioListTile<_ReorderableListType>(
dense: true,
title: new Text("Three-line"),
value: _ReorderableListType.threeLine,
groupValue: _itemType,
onChanged: changeItemType
)
}
)
);
});
Widget buildListTile(_ListItem item) {
Widget secondary = new Text(
"Even more additional list item information appears on line three."
);
Widget listTile = null;
switch (_itemType) {
case _ReorderableListType.threeLine:
listTile = new CheckboxListTile(
key: Key.key(item.value),
isThreeLine: true,
value: item.checkState ?? false,
onChanged: (bool? newValue) => {
setState(() => {
item.checkState = newValue.Value;
// Garbage collect the bottom sheet when it closes.
_bottomSheet.closed.whenComplete(() =>
{
if (mounted)
setState(() => { _bottomSheet = null; });
});
},
title: new Text($"This item represents {item.value}."),
subtitle: secondary,
secondary: new Icon(Icons.drag_handle)
);
break;
case _ReorderableListType.horizontalAvatar:
case _ReorderableListType.verticalAvatar:
listTile = new Container(
key: Key.key(item.value),
height: 100.0f,
width: 100.0f,
child: new CircleAvatar(child: new Text(item.value),
backgroundColor: Colors.green
)
);
break;
}
}
private Widget buildListTile(_ListItem item)
{
Widget secondary = new Text(
"Even more additional list item information appears on line three."
);
Widget listTile = null;
switch (_itemType)
{
case _ReorderableListType.threeLine:
listTile = new CheckboxListTile(
key: Key.key(item.value),
isThreeLine: true,
value: item.checkState ?? false,
onChanged: (bool? newValue) => { setState(() => { item.checkState = newValue.Value; }); },
title: new Text($"This item represents {item.value}."),
subtitle: secondary,
secondary: new Icon(Icons.drag_handle)
);
break;
case _ReorderableListType.horizontalAvatar:
case _ReorderableListType.verticalAvatar:
listTile = new Container(
key: Key.key(item.value),
height: 100.0f,
width: 100.0f,
child: new CircleAvatar(child: new Text(item.value),
backgroundColor: Colors.green
)
);
break;
}
return listTile;
}
return listTile;
}
void _onReorder(int oldIndex, int newIndex) {
setState(() => {
if (newIndex > oldIndex) {
newIndex -= 1;
}
_ListItem item = _items[oldIndex];
_items.RemoveAt(oldIndex);
_items.Insert(newIndex, item);
});
}
private void _onReorder(int oldIndex, int newIndex)
{
setState(() =>
{
if (newIndex > oldIndex) newIndex -= 1;
_ListItem item = _items[oldIndex];
_items.RemoveAt(oldIndex);
_items.Insert(newIndex, item);
});
}
public override Widget build(BuildContext context) {
return new Scaffold(
key: scaffoldKey,
appBar: new AppBar(
title: new Text("Reorderable list"),
actions: new List<Widget>{
new MaterialDemoDocumentationButton(ReorderableListDemo.routeName),
new IconButton(
icon: new Icon(Icons.sort_by_alpha),
tooltip: "Sort",
onPressed: () => {
setState(() => {
_reverseSort = !_reverseSort;
_items.Sort((_ListItem a, _ListItem b) => _reverseSort ? b.value.CompareTo(a.value) : a.value.CompareTo(b.value));
});
}
),
new IconButton(
icon: new Icon(
Theme.of(context).platform == RuntimePlatform.IPhonePlayer
? Icons.more_horiz
: Icons.more_vert
),
tooltip: "Show menu",
onPressed: _bottomSheet == null ? _showConfigurationSheet : (VoidCallback)null
)
public override Widget build(BuildContext context)
{
return new Scaffold(
key: scaffoldKey,
appBar: new AppBar(
title: new Text("Reorderable list"),
actions: new List<Widget>
{
new MaterialDemoDocumentationButton(ReorderableListDemo.routeName),
new IconButton(
icon: new Icon(Icons.sort_by_alpha),
tooltip: "Sort",
onPressed: () =>
{
setState(() =>
{
_reverseSort = !_reverseSort;
_items.Sort((_ListItem a, _ListItem b) =>
_reverseSort ? b.value.CompareTo(a.value) : a.value.CompareTo(b.value));
});
}
),
new IconButton(
icon: new Icon(
Theme.of(context).platform == RuntimePlatform.IPhonePlayer
? Icons.more_horiz
: Icons.more_vert
),
tooltip: "Show menu",
onPressed: _bottomSheet == null ? _showConfigurationSheet : (VoidCallback) null
)
}
),
body: new Scrollbar(
child: new ReorderableListView(
header: _itemType != _ReorderableListType.threeLine
? new Padding(
padding: EdgeInsets.all(8.0f),
child: new Text("Header of the list", style: Theme.of(context).textTheme.headline5))
: null,
onReorder: _onReorder,
reverse: _reverse,
scrollDirection: _itemType == _ReorderableListType.horizontalAvatar
? Axis.horizontal
: Axis.vertical,
padding: EdgeInsets.symmetric(vertical: 8.0f),
children: _items.Select<_ListItem, Widget>(buildListTile).ToList()
)
)
);
),
body: new Scrollbar(
child: new ReorderableListView(
header: _itemType != _ReorderableListType.threeLine
? new Padding(
padding: EdgeInsets.all(8.0f),
child: new Text("Header of the list", style: Theme.of(context).textTheme.headline5))
: null,
onReorder: _onReorder,
reverse: _reverse,
scrollDirection: _itemType == _ReorderableListType.horizontalAvatar ? Axis.horizontal : Axis.vertical,
padding: EdgeInsets.symmetric(vertical: 8.0f),
children: _items.Select<_ListItem, Widget>(buildListTile).ToList()
)
)
);
}
}
}
}

8
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demo.cs


public TabbedComponentDemoScaffold(
List<ComponentDemoTabData> demos,
string title,
List<Widget> actions,
List<Widget> actions = null,
bool isScrollable = true,
bool showExampleCodeAction = true
)

public override Widget build(BuildContext context)
{
var children = new List<Widget>(this.actions);
var children = new List<Widget>();
if (actions != null)
{
children.AddRange(actions);
}
children.Add(new Builder(
builder: (BuildContext subContext) =>
{

244
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs


using System;
using System.Collections.Generic;
using System.Linq;
using UIWidgetsGallery.demo;

using Unity.UIWidgets.widgets;
using UnityEngine;
namespace UIWidgetsGallery.gallery
{

string name,
string name,
if (ReferenceEquals(this, other))
{
return true;
}
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(other, null))
{
return false;
}
if (ReferenceEquals(other, null)) return false;
return this.icon.Equals(other.icon) && this.name == other.name;
return icon.Equals(other.icon) && name == other.name;
if (ReferenceEquals(this, obj))
{
return true;
}
if (ReferenceEquals(this, obj)) return true;
if (ReferenceEquals(obj, null)) return false;
if (obj.GetType() != GetType()) return false;
if (ReferenceEquals(obj, null))
{
return false;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((GalleryDemoCategory)obj);
return Equals((GalleryDemoCategory) obj);
public static bool operator==(GalleryDemoCategory left, GalleryDemoCategory right)
public static bool operator ==(GalleryDemoCategory left, GalleryDemoCategory right)
{
return Equals(left, right);
}

return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
public override int GetHashCode()
{
unchecked
{
return ((icon?.GetHashCode() ?? 0) * 397) ^ (name?.GetHashCode() ?? 0);
}
}

return $"{GetType()}{name}";
}
public static readonly GalleryDemoCategory _kStyle = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kStyle = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kMaterialComponents = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kMaterialComponents = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kCupertinoComponents = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kCupertinoComponents = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kMedia = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kMedia = new GalleryDemoCategory(
class GalleryDemo {
internal class GalleryDemo
{
public GalleryDemo(
string title = null,
IconData icon = null,

}
public readonly string title;
public readonly IconData icon;
public readonly string subtitle;
public readonly GalleryDemoCategory category;
public readonly string routeName;
public readonly WidgetBuilder buildRoute;
public readonly string documentationUrl;
public override string ToString() {
public readonly IconData icon;
public readonly string subtitle;
public readonly GalleryDemoCategory category;
public readonly string routeName;
public readonly WidgetBuilder buildRoute;
public readonly string documentationUrl;
public override string ToString()
{
return $"{GetType()}({title} {routeName})";
}

{
new GalleryDemo(
title: "Activity Indicator",
icon: GalleryIcons.cupertino_progress,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoProgressIndicatorDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoActivityIndicator-class.html",
buildRoute: (BuildContext context) => new CupertinoProgressIndicatorDemo()
title: "Activity Indicator",
icon: GalleryIcons.cupertino_progress,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoProgressIndicatorDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoActivityIndicator-class.html",
buildRoute: (BuildContext context) => new CupertinoProgressIndicatorDemo()
title: "Alerts",
icon: GalleryIcons.dialogs,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoAlertDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/showCupertinoDialog.html",
buildRoute: (BuildContext context) => new CupertinoAlertDemo()
title: "Alerts",
icon: GalleryIcons.dialogs,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoAlertDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/showCupertinoDialog.html",
buildRoute: (BuildContext context) => new CupertinoAlertDemo()
title: "Buttons",
icon: GalleryIcons.generic_buttons,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoButtonsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoButton-class.html",
buildRoute: (BuildContext context) => new CupertinoButtonsDemo()
title: "Buttons",
icon: GalleryIcons.generic_buttons,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoButtonsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoButton-class.html",
buildRoute: (BuildContext context) => new CupertinoButtonsDemo()
title: "Navigation",
icon: GalleryIcons.bottom_navigation,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoNavigationDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoTabScaffold-class.html",
buildRoute: (BuildContext context) => new CupertinoNavigationDemo()
title: "Navigation",
icon: GalleryIcons.bottom_navigation,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoNavigationDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoTabScaffold-class.html",
buildRoute: (BuildContext context) => new CupertinoNavigationDemo()
title: "Pickers",
icon: GalleryIcons.cards,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoPickerDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoPicker-class.html",
buildRoute: (BuildContext context) => new CupertinoPickerDemo()
title: "Pickers",
icon: GalleryIcons.cards,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoPickerDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoPicker-class.html",
buildRoute: (BuildContext context) => new CupertinoPickerDemo()
title: "Pull to refresh",
icon: GalleryIcons.cupertino_pull_to_refresh,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoRefreshControlDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSliverRefreshControl-class.html",
buildRoute: (BuildContext context) => new CupertinoRefreshControlDemo()
title: "Pull to refresh",
icon: GalleryIcons.cupertino_pull_to_refresh,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoRefreshControlDemo.routeName,
documentationUrl:
"https://docs.flutter.io/flutter/cupertino/CupertinoSliverRefreshControl-class.html",
buildRoute: (BuildContext context) => new CupertinoRefreshControlDemo()
title: "Segmented Control",
icon: GalleryIcons.tabs,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSegmentedControlDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSegmentedControl-class.html",
buildRoute: (BuildContext context) => new CupertinoSegmentedControlDemo()
title: "Segmented Control",
icon: GalleryIcons.tabs,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSegmentedControlDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSegmentedControl-class.html",
buildRoute: (BuildContext context) => new CupertinoSegmentedControlDemo()
title: "Sliders",
icon: GalleryIcons.sliders,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSliderDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSlider-class.html",
buildRoute: (BuildContext context) => new CupertinoSliderDemo()
title: "Sliders",
icon: GalleryIcons.sliders,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSliderDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSlider-class.html",
buildRoute: (BuildContext context) => new CupertinoSliderDemo()
title: "Switches",
icon: GalleryIcons.cupertino_switch,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSwitchDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSwitch-class.html",
buildRoute: (BuildContext context) => new CupertinoSwitchDemo()
title: "Switches",
icon: GalleryIcons.cupertino_switch,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoSwitchDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSwitch-class.html",
buildRoute: (BuildContext context) => new CupertinoSwitchDemo()
title: "Text Fields",
icon: GalleryIcons.text_fields_alt,
category:GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoTextFieldDemo.routeName,
buildRoute: (BuildContext context) => new CupertinoTextFieldDemo()
title: "Text Fields",
icon: GalleryIcons.text_fields_alt,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoTextFieldDemo.routeName,
buildRoute: (BuildContext context) => new CupertinoTextFieldDemo()
),
new GalleryDemo(
title: "Shrine",

buildRoute: (BuildContext context) => new SearchDemo()
),
new GalleryDemo(
title: "Selection controls",
subtitle: "Checkboxes, radio buttons, and switches",
icon: GalleryIcons.check_box,
category: GalleryDemoCategory._kMaterialComponents,
routeName: SelectionControlsDemo.routeName,
buildRoute: (BuildContext context) => new SelectionControlsDemo()
),
new GalleryDemo(
title: "Dialogs",
subtitle: "Simple, alert, and fullscreen",
icon: GalleryIcons.dialogs,

routeName: ProgressIndicatorDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/LinearProgressIndicator-class.html",
buildRoute: (BuildContext context) => new ProgressIndicatorDemo()
),
new GalleryDemo(
title: "Tabs: Scrolling",
subtitle: "Tab bar that scrolls",
category: GalleryDemoCategory._kMaterialComponents,
icon: GalleryIcons.tabs,
routeName: ScrollableTabsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/TabBar-class.html",
buildRoute: (BuildContext context) => new ScrollableTabsDemo()
new HashSet<GalleryDemoCategory>(kAllGalleryDemos.Select<GalleryDemo, GalleryDemoCategory>((GalleryDemo demo) => demo.category).ToList());
new HashSet<GalleryDemoCategory>(kAllGalleryDemos
.Select<GalleryDemo, GalleryDemoCategory>((GalleryDemo demo) => demo.category).ToList());
static Dictionary<GalleryDemoCategory, List<GalleryDemo>> _generateCategoryToDemos()
private static Dictionary<GalleryDemoCategory, List<GalleryDemo>> _generateCategoryToDemos()
{
result.Add(category, kAllGalleryDemos.Where((GalleryDemo demo) =>
{
return demo.category == category;
}).ToList());
}
result.Add(category,
kAllGalleryDemos.Where((GalleryDemo demo) => { return demo.category == category; }).ToList());
return result;
}

static Dictionary<string, string> _generateDemoDocumentationUrls()
private static Dictionary<string, string> _generateDemoDocumentationUrls()
{
{
}
}
return result;
}

}

1
com.unity.uiwidgets/Runtime/material/radio.cs


) : base(key: key) {
D.assert(value != null);
D.assert(groupValue != null);
D.assert(onChanged != null);
this.value = value;
this.groupValue = groupValue;
this.onChanged = onChanged;

1
com.unity.uiwidgets/Runtime/material/switch.cs


) : base(key: key) {
D.assert(value != null);
this.value = value.Value;
D.assert(onChanged != null);
D.assert(activeThumbImage != null || onActiveThumbImageError == null);
D.assert(inactiveThumbImage != null || onInactiveThumbImageError == null);
this.onChanged = onChanged;

222
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/scrollable_tabs_demo.cs


using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.demo.material
{
internal enum TabsDemoStyle
{
iconsAndText,
iconsOnly,
textOnly
}
internal class _Page
{
public _Page(IconData icon = null, string text = null)
{
this.icon = icon;
this.text = text;
}
public readonly IconData icon;
public readonly string text;
public static readonly List<_Page> _allPages = new List<_Page>
{
new _Page(icon: Icons.grade, text: "TRIUMPH"),
new _Page(icon: Icons.playlist_add, text: "NOTE"),
new _Page(icon: Icons.check_circle, text: "SUCCESS"),
new _Page(icon: Icons.question_answer, text: "OVERSTATE"),
new _Page(icon: Icons.sentiment_very_satisfied, text: "SATISFACTION"),
new _Page(icon: Icons.camera, text: "APERTURE"),
new _Page(icon: Icons.assignment_late, text: "WE MUST"),
new _Page(icon: Icons.assignment_turned_in, text: "WE CAN"),
new _Page(icon: Icons.group, text: "ALL"),
new _Page(icon: Icons.block, text: "EXCEPT"),
new _Page(icon: Icons.sentiment_very_dissatisfied, text: "CRYING"),
new _Page(icon: Icons.error, text: "MISTAKE"),
new _Page(icon: Icons.loop, text: "TRYING"),
new _Page(icon: Icons.cake, text: "CAKE")
};
}
internal class ScrollableTabsDemo : StatefulWidget
{
public static readonly string routeName = "/material/scrollable-tabs";
public override State createState()
{
return new ScrollableTabsDemoState();
}
}
internal class ScrollableTabsDemoState : SingleTickerProviderStateMixin<ScrollableTabsDemo>
{
private TabController _controller;
private TabsDemoStyle _demoStyle = TabsDemoStyle.iconsAndText;
private bool _customIndicator = false;
public override void initState()
{
base.initState();
_controller = new TabController(vsync: this, length: _Page._allPages.Count);
}
public override void dispose()
{
_controller.dispose();
base.dispose();
}
private void changeDemoStyle(TabsDemoStyle style)
{
setState(() => { _demoStyle = style; });
}
private Decoration getIndicator()
{
if (!_customIndicator)
return new UnderlineTabIndicator();
switch (_demoStyle)
{
case TabsDemoStyle.iconsAndText:
return new ShapeDecoration(
shape: new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0f)),
side: new BorderSide(
color: Colors.white24,
width: 2.0f
)
) + new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0f)),
side: new BorderSide(
color: Colors.transparent,
width: 4.0f
)
)
);
case TabsDemoStyle.iconsOnly:
return new ShapeDecoration(
shape: new CircleBorder(
side: new BorderSide(
color: Colors.white24,
width: 4.0f
)
) + new CircleBorder(
side: new BorderSide(
color: Colors.transparent,
width: 4.0f
)
)
);
case TabsDemoStyle.textOnly:
return new ShapeDecoration(
shape: new StadiumBorder(
side: new BorderSide(
color: Colors.white24,
width: 2.0f
)
) + new StadiumBorder(
side: new BorderSide(
color: Colors.transparent,
width: 4.0f
)
)
);
}
return null;
}
public override Widget build(BuildContext context)
{
Color iconColor = Theme.of(context).accentColor;
return new Scaffold(
appBar: new AppBar(
title: new Text("Scrollable tabs"),
actions: new List<Widget>
{
new MaterialDemoDocumentationButton(ScrollableTabsDemo.routeName),
new IconButton(
icon: new Icon(Icons.sentiment_very_satisfied),
onPressed: () => { setState(() => { _customIndicator = !_customIndicator; }); }
),
new PopupMenuButton<TabsDemoStyle>(
onSelected: changeDemoStyle,
itemBuilder: (BuildContext subContext) => new List<PopupMenuEntry<TabsDemoStyle>>
{
new PopupMenuItem<TabsDemoStyle>(
value: TabsDemoStyle.iconsAndText,
child: new Text("Icons and text")
),
new PopupMenuItem<TabsDemoStyle>(
value: TabsDemoStyle.iconsOnly,
child: new Text("Icons only")
),
new PopupMenuItem<TabsDemoStyle>(
value: TabsDemoStyle.textOnly,
child: new Text("Text only")
)
}
)
},
bottom: new TabBar(
controller: _controller,
isScrollable: true,
indicator: getIndicator(),
tabs: _Page._allPages.Select<_Page, Widget>((_Page page) =>
{
D.assert(_demoStyle != null);
switch (_demoStyle)
{
case TabsDemoStyle.iconsAndText:
return new Tab(text: page.text, icon: new Icon(page.icon));
case TabsDemoStyle.iconsOnly:
return new Tab(icon: new Icon(page.icon));
case TabsDemoStyle.textOnly:
return new Tab(text: page.text);
}
return null;
}).ToList()
)
),
body: new TabBarView(
controller: _controller,
children: _Page._allPages.Select<_Page, Widget>((_Page page) =>
{
return new SafeArea(
top: false,
bottom: false,
child: new Container(
key: new ObjectKey(page.icon),
padding: EdgeInsets.all(12.0f),
child: new Card(
child: new Center(
child: new Icon(
page.icon,
color: iconColor,
size: 128.0f
)
)
)
)
);
}).ToList()
)
);
}
}
}

208
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/selection_controls_demo.cs


using System.Collections.Generic;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.demo.material
{
internal static class SelectionControlDemoUtils
{
public static readonly string _checkboxText =
"Checkboxes allow the user to select multiple options from a set. " +
"A normal checkbox\"s value is true or false and a tristate checkbox\"s " +
"value can also be null.";
public static readonly string _checkboxCode = "selectioncontrols_checkbox";
public static readonly string _radioText =
"Radio buttons allow the user to select one option from a set. Use radio " +
"buttons for exclusive selection if you think that the user needs to see " +
"all available options side-by-side.";
public static readonly string _radioCode = "selectioncontrols_radio";
public static readonly string _switchText =
"On/off switches toggle the state of a single settings option. The option " +
"that the switch controls, as well as the state it’s in, should be made " +
"clear from the corresponding inline label.";
public static readonly string _switchCode = "selectioncontrols_switch";
}
internal class SelectionControlsDemo : StatefulWidget
{
public static readonly string routeName = "/material/selection-controls";
public override State createState()
{
return new _SelectionControlsDemoState();
}
}
internal class _SelectionControlsDemoState : State<SelectionControlsDemo>
{
public override Widget build(BuildContext context)
{
List<ComponentDemoTabData> demos = new List<ComponentDemoTabData>
{
new ComponentDemoTabData(
tabName: "CHECKBOX",
description: SelectionControlDemoUtils._checkboxText,
demoWidget: buildCheckbox(),
exampleCodeTag: SelectionControlDemoUtils._checkboxCode,
documentationUrl: "https://docs.flutter.io/flutter/material/Checkbox-class.html"
),
new ComponentDemoTabData(
tabName: "RADIO",
description: SelectionControlDemoUtils._radioText,
demoWidget: buildRadio(),
exampleCodeTag: SelectionControlDemoUtils._radioCode,
documentationUrl: "https://docs.flutter.io/flutter/material/Radio-class.html"
),
new ComponentDemoTabData(
tabName: "SWITCH",
description: SelectionControlDemoUtils._switchText,
demoWidget: buildSwitch(),
exampleCodeTag: SelectionControlDemoUtils._switchCode,
documentationUrl: "https://docs.flutter.io/flutter/material/Switch-class.html"
)
};
return new TabbedComponentDemoScaffold(
title: "Selection controls",
demos: demos
);
}
private bool checkboxValueA = true;
private bool checkboxValueB = false;
private bool checkboxValueC;
private int radioValue = 0;
private bool switchValue = false;
private void handleRadioValueChanged(int value)
{
setState(() => { radioValue = value; });
}
private Widget buildCheckbox()
{
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>
{
new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>
{
new Checkbox(
value: checkboxValueA,
onChanged: (bool? value) => { setState(() => { checkboxValueA = value.Value; }); }
),
new Checkbox(
value: checkboxValueB,
onChanged: (bool? value) => { setState(() => { checkboxValueB = value.Value; }); }
),
new Checkbox(
value: checkboxValueC,
tristate: true,
onChanged: (bool? value) => { setState(() => { checkboxValueC = value.Value; }); }
)
}
),
new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>
{
// Disabled checkboxes
new Checkbox(value: true, onChanged: null),
new Checkbox(value: false, onChanged: null),
new Checkbox(value: null, tristate: true, onChanged: null),
}
)
}
)
);
}
private Widget buildRadio()
{
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>
{
new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>
{
new Radio<int>(
value: 0,
groupValue: radioValue,
onChanged: handleRadioValueChanged
),
new Radio<int>(
value: 1,
groupValue: radioValue,
onChanged: handleRadioValueChanged
),
new Radio<int>(
value: 2,
groupValue: radioValue,
onChanged: handleRadioValueChanged
)
}
),
// Disabled radio buttons
new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>
{
new Radio<int>(
value: 0,
groupValue: 0,
onChanged: null
),
new Radio<int>(
value: 1,
groupValue: 0,
onChanged: null
),
new Radio<int>(
value: 2,
groupValue: 0,
onChanged: null
)
}
)
}
)
);
}
private Widget buildSwitch()
{
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>
{
Switch.adaptive(
value: switchValue,
onChanged: (bool? value) => { setState(() => { switchValue = value.Value; }); }
),
// Disabled switches
Switch.adaptive(value: true, onChanged: null),
Switch.adaptive(value: false, onChanged: null)
}
)
);
}
}
}
正在加载...
取消
保存