浏览代码

Test code

/siyaoH-1.17-PlatformMessage
Shiyun Wen 4 年前
当前提交
543783e6
共有 14 个文件被更改,包括 2061 次插入1 次删除
  1. 192
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs
  2. 26
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
  3. 11
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs.meta
  4. 24
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_activity_indicator_demo.cs
  5. 272
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_alert_demo.cs
  6. 86
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_buttons_demo.cs
  7. 831
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_navigation_demo.cs
  8. 285
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_picker_demo.cs
  9. 70
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_slider_demo.cs
  10. 73
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_switch_demo.cs
  11. 192
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_text_field_demo.cs

192
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsExample.cs


using ui_ = Unity.UIWidgets.widgets.ui_;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.rendering;
//using UIWidgetsGallery.gallery;
using Unity.UIWidgets.service;
namespace UIWidgetsSample
{

),
backgroundColor: Colors.brown
);*/
List<BottomNavigationBarItem> items = new List<BottomNavigationBarItem>();
items.Add( new BottomNavigationBarItem(
icon: new Icon(CupertinoIcons.bell),

Navigator.of(contex1).push(
new CupertinoPageRoute(builder: (contex3) =>
{
return new DetailScreen1(index==0? "views" : "articles" );
return
new DetailScreen1(index==0? "views" : "articles" );
})
);
}

);
}
}
class CupertinoTextFieldDemo : StatefulWidget {
public const string routeName = "/cupertino/text_fields";
public override State createState() {
return new _CupertinoTextFieldDemoState();
}
}
class _CupertinoTextFieldDemoState : State<CupertinoTextFieldDemo> {
TextEditingController _chatTextController;
TextEditingController _locationTextController;
public override void initState() {
base.initState();
this._chatTextController = new TextEditingController();
this._locationTextController = new TextEditingController(text: "Montreal, Canada");
}
Widget _buildChatTextField() {
return new CupertinoTextField(
controller: this._chatTextController,
textCapitalization: TextCapitalization.sentences,
placeholder: "Text Message",
decoration: new BoxDecoration(
border: Border.all(
width: 0.0f,
color: CupertinoColors.inactiveGray
),
borderRadius: BorderRadius.circular(15.0f)
),
maxLines: null,
keyboardType: TextInputType.multiline,
prefix: new Padding(padding: EdgeInsets.symmetric(horizontal: 4.0f)),
suffix:
new Padding(
padding: EdgeInsets.symmetric(horizontal: 4.0f),
child: new CupertinoButton(
color: CupertinoColors.activeGreen,
minSize: 0.0f,
child: new Icon(
CupertinoIcons.up_arrow,
size: 21.0f,
color: CupertinoColors.white
),
padding: EdgeInsets.all(2.0f),
borderRadius:
BorderRadius.circular(15.0f),
onPressed: () => this.setState(() => this._chatTextController.clear())
)
),
autofocus: true,
suffixMode: OverlayVisibilityMode.editing,
onSubmitted: (string text) => this.setState(() => this._chatTextController.clear())
);
}
Widget _buildNameField() {
return new CupertinoTextField(
prefix: new Icon(
CupertinoIcons.person_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
clearButtonMode: OverlayVisibilityMode.editing,
textCapitalization: TextCapitalization.words,
autocorrect: false,
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
),
placeholder: "Name"
);
}
Widget _buildEmailField() {
return new CupertinoTextField(
prefix: new Icon(
CupertinoIcons.mail_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
clearButtonMode: OverlayVisibilityMode.editing,
keyboardType: TextInputType.emailAddress,
autocorrect: false,
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
),
placeholder: "Email"
);
}
Widget _buildLocationField() {
return new CupertinoTextField(
controller: this._locationTextController,
prefix: new Icon(
CupertinoIcons.location_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
clearButtonMode: OverlayVisibilityMode.editing,
textCapitalization: TextCapitalization.words,
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
),
placeholder: "Location"
);
}
Widget _buildPinField() {
return new CupertinoTextField(
prefix: new Icon(
CupertinoIcons.padlock_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
clearButtonMode: OverlayVisibilityMode.editing,
keyboardType: TextInputType.number,
autocorrect: false,
obscureText: true,
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
),
placeholder: "Create a PIN"
);
}
Widget _buildTagsField() {
return new CupertinoTextField(
controller: new TextEditingController(text: "colleague, reading club"),
prefix: new Icon(
CupertinoIcons.tags_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
enabled: false,
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
)
);
}
public override Widget build(BuildContext context) {
return new DefaultTextStyle(
style: new TextStyle(
fontFamily: ".SF Pro Text", // ".SF UI Text",
inherit: false,
fontSize: 17.0f,
color: CupertinoColors.black
),
child: new CupertinoPageScaffold(
child: new SafeArea(
child: new ListView(
children: new List<Widget>
{
/*new Padding(
padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f),
child: new Column(
children: new List<Widget> {
this._buildNameField(),
this._buildEmailField(),
this._buildLocationField(),
this._buildPinField(),
this._buildTagsField(),
}
)
),*/
new Padding(
padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f)//,
//child: this._buildChatTextField()
),
}
)
)
)
);
}
}
}
}

26
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs


using UIWidgetsGallery.gallery;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
namespace UIWidgetsGallery {
/*public class GalleryMain : UIWidgetsPanel {
protected override Widget createWidget() {
return new GalleryApp();
}
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>("fonts/MaterialIcons-Regular"), "Material Icons");
FontManager.instance.addFont(Resources.Load<Font>("fonts/GalleryIcons"), "GalleryIcons");
FontManager.instance.addFont(Resources.Load<Font>("fonts/CupertinoIcons"), "CupertinoIcons");
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/SF-Pro-Text-Regular"), ".SF Pro Text", FontWeight.w400);
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/SF-Pro-Text-Semibold"), ".SF Pro Text", FontWeight.w600);
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/SF-Pro-Text-Bold"), ".SF Pro Text", FontWeight.w700);
base.OnEnable();
}
}*/
}

11
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs.meta


fileFormatVersion: 2
guid: 9c5c86936ca864ae684720ddcd50d759
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

24
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_activity_indicator_demo.cs


using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
/*
class CupertinoProgressIndicatorDemo : StatelessWidget {
public static string routeName = "/cupertino/progress_indicator";
public override
Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
previousPageTitle: "Cupertino",
middle: new Text("Activity Indicator"),
trailing: new CupertinoDemoDocumentationButton(routeName)
),
child: new Center(
child: new CupertinoActivityIndicator()
)
);
}
}
*/
}

272
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_alert_demo.cs


using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoAlertDemo : StatefulWidget {
public static string routeName = "/cupertino/alert";
public override State createState() {
return new _CupertinoAlertDemoState();
}
}
class _CupertinoAlertDemoState : State<CupertinoAlertDemo> {
string lastSelectedValue;
void showDemoDialog(
BuildContext context = null,
Widget child = null
) {
CupertinoRouteUtils.showCupertinoDialog(
context: context,
builder: (BuildContext _context) => child
).then((object value) => {
if (value != null) {
this.setState(() => { this.lastSelectedValue = value as string; });
}
});
}
void showDemoActionSheet(
BuildContext context = null,
Widget child = null
) {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (BuildContext _context) => child
).then((object value) => {
if (value != null) {
this.setState(() => { this.lastSelectedValue = value as string; });
}
});
}
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Alerts"),
previousPageTitle: "Cupertino"
//, trailing: new CupertinoDemoDocumentationButton(CupertinoAlertDemo.routeName)
),
child:
new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new Builder(
builder: (BuildContext _context) => {
List<Widget> stackChildren = new List<Widget> {
new ListView(
padding: EdgeInsets.symmetric(vertical: 24.0f, horizontal: 72.0f)
+ MediaQuery.of(_context).padding,
children: new List<Widget> {
CupertinoButton.filled(
child: new Text("Alert"),
onPressed: () => {
this.showDemoDialog(
context: _context,
child:
new CupertinoAlertDialog(
title: new Text("Discard draft?"),
actions: new List<Widget> {
new CupertinoDialogAction(
child: new Text("Discard"),
isDestructiveAction: true,
onPressed: () => { Navigator.pop(_context, "Discard"); }
),
new CupertinoDialogAction(
child: new Text("Cancel"),
isDefaultAction: true,
onPressed: () => { Navigator.pop(_context, "Cancel"); }
),
}
)
);
}
),
new Padding(padding: EdgeInsets.all(8.0f)),
CupertinoButton.filled(
child: new Text("Alert with Title"),
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
onPressed: () => {
this.showDemoDialog(
context: _context,
child: new CupertinoAlertDialog(
title: new Text(
"Allow \"Maps\" to access your location while you are using the app?")
,
content: new Text(
"Your current location will be displayed on the map and used \n" +
"for directions, nearby search results, and estimated travel times.")
,
actions: new List<Widget> {
new CupertinoDialogAction(
child: new Text("Don\"t Allow"),
onPressed: () => {
Navigator.pop(_context, "Disallow");
}
),
new CupertinoDialogAction(
child: new Text("Allow"),
onPressed: () => { Navigator.pop(_context, "Allow"); }
),
}
)
);
}
),
new Padding(padding: EdgeInsets.all(8.0f)),
CupertinoButton.filled(
child: new Text("Alert with Buttons"),
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
onPressed: () => {
this.showDemoDialog(
context: _context,
child: new CupertinoDessertDialog(
title: new Text("Select Favorite Dessert"),
content: new Text(
"Please select your favorite type of dessert from the \n" +
"list below. Your selection will be used to customize the suggested \n" +
"list of eateries in your area.")
)
);
}
),
new Padding(padding: EdgeInsets.all(8.0f)),
CupertinoButton.filled(
child: new Text("Alert Buttons Only"),
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
onPressed: () => {
this.showDemoDialog(
context: _context,
child: new CupertinoDessertDialog()
);
}
),
// TODO: FIX BUG
new Padding(padding: EdgeInsets.all(8.0f)),
CupertinoButton.filled(
child: new Text("Action Sheet"),
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
onPressed: () => {
this.showDemoActionSheet(
context: _context,
child: new CupertinoActionSheet(
title: new Text("Favorite Dessert"),
message: new Text(
"Please select the best dessert from the options below."),
actions: new List<Widget> {
new CupertinoActionSheetAction(
child: new Text("Profiteroles"),
onPressed: () => {
Navigator.pop(_context, "Profiteroles");
}
),
new CupertinoActionSheetAction(
child: new Text("Cannolis"),
onPressed: () => {
Navigator.pop(_context, "Cannolis");
}
),
new CupertinoActionSheetAction(
child: new Text("Trifle"),
onPressed: () => { Navigator.pop(_context, "Trifle"); }
)
},
cancelButton: new CupertinoActionSheetAction(
child: new Text("Cancel"),
isDefaultAction: true,
onPressed: () => { Navigator.pop(_context, "Cancel"); }
)
)
);
}
)
}
)
};
if (this.lastSelectedValue != null) {
stackChildren.Add(
new Positioned(
bottom: 32.0f,
child: new Text($"You selected: {this.lastSelectedValue}")
)
);
}
return new Stack(
alignment: Alignment.center,
children: stackChildren
);
}
)
)
);
}
}
class CupertinoDessertDialog : StatelessWidget {
public CupertinoDessertDialog(
Key key = null,
Widget title = null,
Widget content = null
) : base(key: key) {
this.title = title;
this.content = content;
}
public readonly Widget title;
public readonly Widget content;
public override Widget build(BuildContext context) {
return new CupertinoAlertDialog(
title: this.title,
content: this.content,
actions: new List<Widget> {
new CupertinoDialogAction(
child: new Text("Cheesecake"),
onPressed: () => { Navigator.pop(context, "Cheesecake"); }
),
new CupertinoDialogAction(
child: new Text("Tiramisu"),
onPressed: () => { Navigator.pop(context, "Tiramisu"); }
),
new CupertinoDialogAction(
child: new Text("Apple Pie"),
onPressed:
() => { Navigator.pop(context, "Apple Pie"); }
),
new CupertinoDialogAction(
child: new Text("Devil\"s food cake"),
onPressed:
() => { Navigator.pop(context, "Devil\"s food cake"); }
),
new CupertinoDialogAction(
child: new Text("Banana Split"),
onPressed:
() => { Navigator.pop(context, "Banana Split"); }
),
new CupertinoDialogAction(
child: new Text("Oatmeal Cookie"),
onPressed:
() => { Navigator.pop(context, "Oatmeal Cookies"); }
),
new CupertinoDialogAction(
child: new Text("Chocolate Brownie"),
onPressed:
() => { Navigator.pop(context, "Chocolate Brownies"); }
),
new CupertinoDialogAction(
child: new Text("Cancel"),
isDestructiveAction:
true,
onPressed:
() => { Navigator.pop(context, "Cancel"); }
),
}
);
}
}
}

86
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_buttons_demo.cs


using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoButtonsDemo : StatefulWidget {
public static string routeName = "/cupertino/buttons";
public override State createState() {
return new _CupertinoButtonDemoState();
}
}
class _CupertinoButtonDemoState : State<CupertinoButtonsDemo> {
int _pressedCount = 0;
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Buttons"),
previousPageTitle: "Cupertino"
//, trailing: new CupertinoDemoDocumentationButton(CupertinoButtonsDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new SafeArea(
child: new Column(
children: new List<Widget> {
new Padding(
padding: EdgeInsets.all(16.0f),
child: new Text(
"iOS themed buttons are flat. They can have borders or backgrounds but only when necessary."
)
),
new Expanded(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: new List<Widget> {
new Text(this._pressedCount > 0
? $"Button pressed {this._pressedCount} time" +
(this._pressedCount == 1 ? "" : "s")
: " "),
new Padding(padding: EdgeInsets.all(12.0f)),
new Align(
alignment: new Alignment(0.0f, -0.2f),
child:
new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new CupertinoButton(
child: new Text("Cupertino Button"),
onPressed:
() => { this.setState(() => { this._pressedCount += 1; }); }
),
new CupertinoButton(
child: new Text("Disabled"),
onPressed: null
)
}
)
),
new Padding(padding: EdgeInsets.all(12.0f)),
CupertinoButton.filled(
child: new Text("With Background"),
onPressed:
() => { this.setState(() => { this._pressedCount += 1; }); }
),
new Padding(padding: EdgeInsets.all(12.0f)),
CupertinoButton.filled(
child: new Text("Disabled"),
onPressed: null
),
}
)
)
}
)
)
)
);
}
}
}

831
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_navigation_demo.cs


using System.Collections.Generic;
//using RSG;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
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 Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using Brightness = Unity.UIWidgets.ui.Brightness;
namespace UIWidgetsGallery.gallery {
class CupertinoNavigationDemoUtils {
public const int _kChildCount = 50;
public static List<Color> coolColors = new List<Color> {
Color.fromARGB(255, 255, 59, 48),
Color.fromARGB(255, 255, 149, 0),
Color.fromARGB(255, 255, 204, 0),
Color.fromARGB(255, 76, 217, 100),
Color.fromARGB(255, 90, 200, 250),
Color.fromARGB(255, 0, 122, 255),
Color.fromARGB(255, 88, 86, 214),
Color.fromARGB(255, 255, 45, 85),
};
public static List<string> coolColorNames = new List<string> {
"Sarcoline", "Coquelicot", "Smaragdine", "Mikado", "Glaucous", "Wenge",
"Fulvous", "Xanadu", "Falu", "Eburnean", "Amaranth", "Australien",
"Banan", "Falu", "Gingerline", "Incarnadine", "Labrador", "Nattier",
"Pervenche", "Sinoper", "Verditer", "Watchet", "Zafre",
};
public static Widget trailingButtons {
get {
return new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
//new CupertinoDemoDocumentationButton(CupertinoNavigationDemo.routeName),
new Padding(padding: EdgeInsets.only(left: 8.0f)),
new ExitButton(),
}
);
}
}
public static List<Widget> buildTab2Conversation() {
return new List<Widget> {
new Tab2ConversationRow(
text: "My Xanadu doesn't look right"
),
new Tab2ConversationRow(
avatar: new Tab2ConversationAvatar(
text: "KL",
color: new Color(0xFFFD5015)
),
text: "We'll rush you a new one.\nIt's gonna be incredible"
),
new Tab2ConversationRow(
text: "Awesome thanks!"
),
new Tab2ConversationRow(
avatar: new Tab2ConversationAvatar(
text: "SJ",
color: new Color(0xFF34CAD6)
),
text: "We'll send you our\nnewest Labrador too!"
),
new Tab2ConversationRow(
text: "Yay"
),
new Tab2ConversationRow(
avatar: new Tab2ConversationAvatar(
text: "KL",
color: new Color(0xFFFD5015)
),
text: "Actually there's one more thing..."
),
new Tab2ConversationRow(
text: "What's that ? "
),
};
}
}
public class CupertinoNavigationDemo : StatelessWidget {
public CupertinoNavigationDemo() {
this.colorItems = new List<Color>();
for (int i = 0; i < CupertinoNavigationDemoUtils._kChildCount; i++) {
this.colorItems.Add(CupertinoNavigationDemoUtils.coolColors[
Random.Range(0, CupertinoNavigationDemoUtils.coolColors.Count)
]);
}
this.colorNameItems = new List<string>();
for (int i = 0; i < CupertinoNavigationDemoUtils._kChildCount; i++) {
this.colorNameItems.Add(CupertinoNavigationDemoUtils.coolColorNames[
Random.Range(0, CupertinoNavigationDemoUtils.coolColorNames.Count)
]);
}
}
public static string routeName = "/cupertino/navigation";
public readonly List<Color> colorItems;
public readonly List<string> colorNameItems;
public override Widget build(BuildContext context) {
return new WillPopScope(
//onWillPop: () => { return Promise<bool>.Resolved(true); },
//onWillPop: this.onWillPop,
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new CupertinoTabScaffold(
tabBar: new CupertinoTabBar(
items: new List<BottomNavigationBarItem> {
new BottomNavigationBarItem(
icon: new Icon(CupertinoIcons.home),
title: new Text("Home")
),
new BottomNavigationBarItem(
icon: new Icon(CupertinoIcons.conversation_bubble),
title: new Text("Support")
),
new BottomNavigationBarItem(
icon: new Icon(CupertinoIcons.profile_circled),
title: new Text("Profile")
)
}
),
tabBuilder: (BuildContext _context, int index) => {
D.assert(index >= 0 && index <= 2);
switch (index) {
case 0:
return new CupertinoTabView(
builder: (BuildContext _context1) => {
return new CupertinoDemoTab1(
colorItems: this.colorItems,
colorNameItems: this.colorNameItems
);
},
defaultTitle: "Colors"
);
case 1:
return new CupertinoTabView(
builder: (BuildContext _context2) => new CupertinoDemoTab2(),
defaultTitle: "Support Chat"
);
case 2:
return new CupertinoTabView(
builder: (BuildContext _context3) => new CupertinoDemoTab3(),
defaultTitle: "Account"
);
}
return null;
}
)
)
);
}
}
class ExitButton : StatelessWidget {
public ExitButton() { }
public override Widget build(BuildContext context) {
return new CupertinoButton(
padding: EdgeInsets.zero,
child: new Text("Exit"),
onPressed: () => { Navigator.of(context, rootNavigator: true).pop(); }
);
}
}
class CupertinoDemoTab1 : StatelessWidget {
public CupertinoDemoTab1(
List<Color> colorItems = null,
List<string> colorNameItems = null
) {
this.colorItems = colorItems ?? new List<Color>();
this.colorNameItems = colorNameItems ?? new List<string>();
}
public readonly List<Color> colorItems;
public readonly List<string> colorNameItems;
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
child: new CustomScrollView(
slivers: new List<Widget> {
new CupertinoSliverNavigationBar(
trailing: CupertinoNavigationDemoUtils.trailingButtons
),
new SliverPadding(
padding: MediaQuery.of(context).removePadding(
removeTop: true,
removeLeft: true,
removeRight: true
).padding,
sliver: new SliverList(
del: new SliverChildBuilderDelegate(
(BuildContext _context, int index) => {
return new Tab1RowItem(
index: index,
lastItem: index == CupertinoNavigationDemoUtils._kChildCount - 1,
color: this.colorItems[index],
colorName: this.colorNameItems[index]
);
},
childCount: CupertinoNavigationDemoUtils._kChildCount
)
)
)
}
)
);
}
}
class Tab1RowItem : StatelessWidget {
public Tab1RowItem(
int index,
bool lastItem,
Color color,
string colorName
) {
this.index = index;
this.lastItem = lastItem;
this.color = color;
this.colorName = colorName;
}
public readonly int index;
public readonly bool lastItem;
public readonly Color color;
public readonly string colorName;
public override Widget build(BuildContext context) {
Widget row = new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => {
Navigator.of(context).push(new CupertinoPageRoute(
title: this.colorName,
builder: (BuildContext _context) => new Tab1ItemPage(
color: this.color,
colorName: this.colorName,
index: this.index
)
));
},
child: new SafeArea(
top: false,
bottom: false,
child: new Padding(
padding: EdgeInsets.only(left: 16.0f, top: 8.0f, bottom: 8.0f, right: 8.0f),
child: new Row(
children: new List<Widget> {
new Container(
height: 60.0f,
width: 60.0f,
decoration: new BoxDecoration(
color: this.color,
borderRadius: BorderRadius.circular(8.0f)
)
),
new Expanded(
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 12.0f),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new Text(this.colorName),
new Padding(padding: EdgeInsets.only(top: 8.0f)),
new Text(
"Buy this cool color",
style: new TextStyle(
color: new Color(0xFF8E8E93),
fontSize: 13.0f,
fontWeight: FontWeight.w300
)
)
}
)
)
),
new CupertinoButton(
padding: EdgeInsets.zero,
child: new Icon(CupertinoIcons.plus_circled
),
onPressed: () => { }
),
new CupertinoButton(
padding: EdgeInsets.zero,
child: new Icon(CupertinoIcons.share
),
onPressed: () => { }
)
}
)
)
)
);
if (this.lastItem) {
return row;
}
return new Column(
children: new List<Widget> {
row,
new Container(
height: 1.0f,
color: new Color(0xFFD9D9D9)
)
}
);
}
}
class Tab1ItemPage : StatefulWidget {
public Tab1ItemPage(
Color color,
string colorName,
int index
) {
this.color = color;
this.colorName = colorName;
this.index = index;
}
public readonly Color color;
public readonly string colorName;
public readonly int index;
public override State createState() {
return new Tab1ItemPageState();
}
}
class Tab1ItemPageState : State<Tab1ItemPage> {
public override void initState() {
base.initState();
this.relatedColors = new List<Color>();
for (int i = 0; i < 10; i++) {
this.relatedColors.Add(Color.fromARGB(
255,
(this.widget.color.red + Random.Range(-50, 50)).clamp(0, 255),
(this.widget.color.green + Random.Range(-50, 50)).clamp(0, 255),
(this.widget.color.blue + Random.Range(-50, 50)).clamp(0, 255)
));
}
}
List<Color> relatedColors;
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
trailing: new ExitButton()
),
child: new SafeArea(
bottom: false,
child: new ListView(
children: new List<Widget> {
new Padding(padding: EdgeInsets.only(top: 16.0f)),
new Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0f),
child: new Row(
mainAxisSize: MainAxisSize.max,
children: new List<Widget> {
new Container(
height: 128.0f,
width: 128.0f,
decoration: new BoxDecoration(
color: this.widget.color,
borderRadius: BorderRadius.circular(24.0f)
)
),
new Padding(padding: EdgeInsets.only(left: 18.0f)),
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new Text(this.widget.colorName,
style: new TextStyle(fontSize: 24.0f,
fontWeight: FontWeight.bold)
),
new Padding(padding: EdgeInsets.only(top: 6.0f)),
new Text(
$"Item number {this.widget.index}",
style: new TextStyle(
color: new Color(0xFF8E8E93),
fontSize: 16.0f,
fontWeight: FontWeight.w100
)
),
new Padding(padding: EdgeInsets.only(top: 20.0f)),
new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: new List<Widget> {
CupertinoButton.filled(
minSize: 30.0f,
padding: EdgeInsets.symmetric(horizontal: 24.0f),
borderRadius: BorderRadius.circular(16.0f),
child: new Text(
"GET",
style: new TextStyle(
fontSize: 14.0f,
fontWeight: FontWeight.w700,
letterSpacing: -0.28f
)
),
onPressed: () => { }
),
CupertinoButton.filled(
minSize: 30.0f,
padding: EdgeInsets.zero,
borderRadius: BorderRadius.circular(16.0f),
child: new Icon(CupertinoIcons.ellipsis),
onPressed: () => { }
)
}
)
}
)
)
}
)
),
new Padding(
padding: EdgeInsets.only(left: 16.0f, top: 28.0f, bottom: 8.0f),
child: new Text(
"USERS ALSO LIKED",
style: new TextStyle(
color: new Color(0xFF646464),
letterSpacing: -0.60f,
fontSize: 15.0f,
fontWeight: FontWeight.w500
)
)
),
new SizedBox(
height: 200.0f,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 10,
itemExtent: 160.0f,
itemBuilder: (BuildContext _context, int index) => {
return new Padding(
padding: EdgeInsets.only(left: 16.0f),
child: new Container(
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(8.0f),
color: this.relatedColors[index]
),
child: new Center(
child: new CupertinoButton(
child: new Icon(
CupertinoIcons.plus_circled,
color: CupertinoColors.white,
size: 36.0f
),
onPressed: () => { }
)
)
)
);
}
)
)
}
)
)
);
}
}
class CupertinoDemoTab2 : StatelessWidget {
public override Widget build(BuildContext context) {
var listViewList = new List<Widget>();
listViewList.Add(new Tab2Header());
listViewList.AddRange(CupertinoNavigationDemoUtils.buildTab2Conversation());
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
trailing: CupertinoNavigationDemoUtils.trailingButtons
),
child:
new SafeArea(
child: new ListView(
children: listViewList
)
)
);
}
}
class Tab2Header : StatelessWidget {
public override Widget build(BuildContext context) {
return new Padding(
padding: EdgeInsets.all(16.0f),
child: new ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(16.0f)),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new Container(
decoration: new BoxDecoration(
color: new Color(0xFFE5E5E5)
),
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 18.0f, vertical: 12.0f),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: new List<Widget> {
new Text(
"SUPPORT TICKET",
style: new TextStyle(
color: new Color(0xFF646464),
letterSpacing: -0.9f,
fontSize: 14.0f,
fontWeight: FontWeight.w500
)
),
new Text(
"Show More",
style: new TextStyle(
color: new Color(0xFF646464),
letterSpacing: -0.6f,
fontSize: 12.0f,
fontWeight: FontWeight.w500
)
)
}
)
)
),
new Container(
decoration: new BoxDecoration(
color: new Color(0xFFF3F3F3)
),
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 18.0f, vertical: 12.0f),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new Text(
"Product or product packaging damaged during transit",
style: new TextStyle(
fontSize: 16.0f,
fontWeight: FontWeight.w700,
letterSpacing: -0.46f
)
),
new Padding(padding: EdgeInsets.only(top: 16.0f)),
new Text(
"REVIEWERS",
style: new TextStyle(
color: new Color(0xFF646464),
fontSize: 12.0f,
letterSpacing: -0.6f,
fontWeight: FontWeight.w500
)
),
new Padding(padding: EdgeInsets.only(top: 8.0f)),
new Row(
children: new List<Widget> {
new Container(
width: 44.0f,
height: 44.0f,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage(
"people/square/trevor"
)
),
shape: BoxShape.circle
)
),
new Padding(padding: EdgeInsets.only(left: 8.0f)),
new Container(
width: 44.0f,
height: 44.0f,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage(
"people/square/sandra"
)
),
shape: BoxShape.circle
)
),
new Padding(padding: EdgeInsets.only(left: 2.0f)),
new Icon(
CupertinoIcons.check_mark_circled,
color: new Color(0xFF646464),
size: 20.0f
)
}
)
}
)
)
)
}
)
)
);
}
}
enum Tab2ConversationBubbleColor {
blue,
gray,
}
class Tab2ConversationBubble : StatelessWidget {
public Tab2ConversationBubble(
string text,
Tab2ConversationBubbleColor color
) {
this.text = text;
this.color = color;
}
public readonly string text;
public readonly Tab2ConversationBubbleColor color;
public override Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(18.0f)),
color: this.color == Tab2ConversationBubbleColor.blue
? CupertinoColors.activeBlue
: CupertinoColors.lightBackgroundGray
),
margin: EdgeInsets.symmetric(horizontal: 8.0f, vertical: 8.0f),
padding: EdgeInsets.symmetric(horizontal: 14.0f, vertical: 10.0f),
child: new Text(this.text,
style: new TextStyle(
color: this.color == Tab2ConversationBubbleColor.blue
? CupertinoColors.white
: CupertinoColors.black,
letterSpacing: -0.4f,
fontSize: 15.0f,
fontWeight: FontWeight.w400
)
)
);
}
}
class Tab2ConversationAvatar : StatelessWidget {
public Tab2ConversationAvatar(
string text,
Color color
) {
this.text = text;
this.color = color;
}
public readonly string text;
public readonly Color color;
public override Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(
shape: BoxShape.circle,
gradient: new LinearGradient(
begin: Alignment.topCenter, // FractionalOfset.topCenter,
end: Alignment.bottomCenter, // FractionalOfset.bottomCenter,
colors: new List<Color> {
this.color,
Color.fromARGB(this.color.alpha,
(this.color.red - 60).clamp(0, 255),
(this.color.green - 60).clamp(0, 255),
(this.color.blue - 60).clamp(0, 255)
)
}
)
),
margin: EdgeInsets.only(left: 8.0f, bottom: 8.0f),
padding: EdgeInsets.all(12.0f),
child: new Text(this.text,
style: new TextStyle(
color: CupertinoColors.white,
fontSize: 13.0f,
fontWeight: FontWeight.w500
)
)
);
}
}
class Tab2ConversationRow : StatelessWidget {
public Tab2ConversationRow(
string text,
Tab2ConversationAvatar avatar = null
) {
this.avatar = avatar;
this.text = text;
}
public readonly Tab2ConversationAvatar avatar;
public readonly string text;
public override Widget build(BuildContext context) {
List<Widget> children = new List<Widget>();
if (this.avatar != null) {
children.Add(this.avatar);
}
bool isSelf = this.avatar == null;
children.Add(
new Tab2ConversationBubble(
text: this.text,
color: isSelf
? Tab2ConversationBubbleColor.blue
: Tab2ConversationBubbleColor.gray
)
);
return new Row(
mainAxisAlignment: isSelf ? MainAxisAlignment.end : MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: isSelf ? CrossAxisAlignment.center : CrossAxisAlignment.end,
children: children
);
}
}
class CupertinoDemoTab3 : StatelessWidget {
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
trailing: CupertinoNavigationDemoUtils.trailingButtons
),
child: new SafeArea(
child: new DecoratedBox(
decoration: new BoxDecoration(
color: CupertinoTheme.of(context).brightness == Brightness.light
? CupertinoColors.extraLightBackgroundGray
: CupertinoColors.darkBackgroundGray
),
child: new ListView(
children: new List<Widget> {
new Padding(padding: EdgeInsets.only(top: 32.0f)),
new GestureDetector(
onTap: () => {
Navigator.of(context, rootNavigator: true).push(
new CupertinoPageRoute(
fullscreenDialog: true,
builder: (BuildContext _context) => new Tab3Dialog()
)
);
},
child: new Container(
decoration: new BoxDecoration(
color: CupertinoTheme.of(context).scaffoldBackgroundColor,
border: new Border(
top: new BorderSide(color: new Color(0xFFBCBBC1), width: 0.0f),
bottom: new BorderSide(color: new Color(0xFFBCBBC1), width: 0.0f)
)
),
height: 44.0f,
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0f, vertical: 8.0f),
child: new SafeArea(
top: false,
bottom: false,
child: new Row(
children: new List<Widget> {
new Text(
"Sign in",
style: new TextStyle(color: CupertinoTheme.of(context)
.primaryColor)
),
}
)
)
)
)
)
}
)
)
)
);
}
}
class Tab3Dialog : StatelessWidget {
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
leading: new CupertinoButton(
child: new Text("Cancel"),
padding: EdgeInsets.zero,
onPressed: () => { Navigator.of(context).pop(false); }
)
),
child: new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new Icon(
CupertinoIcons.profile_circled,
size: 160.0f,
color: new Color(0xFF646464)
),
new Padding(padding: EdgeInsets.only(top: 18.0f)),
CupertinoButton.filled(
child: new Text("Sign in"),
onPressed: () => { Navigator.pop(context); }
),
}
)
)
);
}
}
}

285
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_picker_demo.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using Brightness = Unity.UIWidgets.ui.Brightness;
namespace UIWidgetsGallery.gallery {
class CupertinoPickerDemoUtils {
public const float _kPickerSheetHeight = 216.0f;
public const float _kPickerItemHeight = 32.0f;
}
class CupertinoPickerDemo : StatefulWidget {
public const string routeName = "/cupertino/picker";
public override State createState() {
return new _CupertinoPickerDemoState();
}
}
class _CupertinoPickerDemoState : State<CupertinoPickerDemo> {
int _selectedColorIndex = 0;
TimeSpan timer = new TimeSpan();
// Value that is shown in the date picker in date mode.
DateTime date = DateTime.Now;
// Value that is shown in the date picker in time mode.
DateTime time = DateTime.Now;
// Value that is shown in the date picker in dateAndTime mode.
DateTime dateTime = DateTime.Now;
Widget _buildMenu(List<Widget> children) {
return new Container(
decoration: new BoxDecoration(
color: CupertinoTheme.of(this.context).scaffoldBackgroundColor,
border: new Border(
top: new BorderSide(color: new Color(0xFFBCBBC1), width: 0.0f),
bottom: new BorderSide(color: new Color(0xFFBCBBC1), width: 0.0f)
)
),
height: 44.0f,
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0f),
child: new SafeArea(
top: false,
bottom: false,
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: children
)
)
)
);
}
Widget _buildBottomPicker(Widget picker) {
return new Container(
height: CupertinoPickerDemoUtils._kPickerSheetHeight,
padding: EdgeInsets.only(top: 6.0f),
color: CupertinoColors.white,
child: new DefaultTextStyle(
style: new TextStyle(
color: CupertinoColors.black,
fontSize: 22.0f
),
child: new GestureDetector(
// Blocks taps from propagating to the modal sheet and popping.
onTap: () => { },
child: new SafeArea(
top: false,
child: picker
)
)
)
);
}
Widget _buildColorPicker(BuildContext context) {
FixedExtentScrollController scrollController =
new FixedExtentScrollController(initialItem: this._selectedColorIndex);
List<Widget> generateList() {
var list = new List<Widget>();
foreach (var item in CupertinoNavigationDemoUtils.coolColorNames) {
list.Add(new Center(child:
new Text(item)
));
}
return list;
}
return new GestureDetector(
onTap: () => {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (BuildContext _context) => {
return this._buildBottomPicker(
new CupertinoPicker(
scrollController: scrollController,
itemExtent: CupertinoPickerDemoUtils._kPickerItemHeight,
backgroundColor: CupertinoColors.white,
onSelectedItemChanged: (int index) => {
this.setState(() => this._selectedColorIndex = index);
},
children: generateList()
)
);
}
);
},
child: this._buildMenu(new List<Widget> {
new Text("Favorite Color"),
new Text(
CupertinoNavigationDemoUtils.coolColorNames[this._selectedColorIndex],
style: new TextStyle(
color: CupertinoColors.inactiveGray
)
)
}
)
);
}
Widget _buildCountdownTimerPicker(BuildContext context) {
return new GestureDetector(
onTap: () => {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (BuildContext _context) => {
return this._buildBottomPicker(
new CupertinoTimerPicker(
initialTimerDuration: this.timer,
onTimerDurationChanged: (TimeSpan newTimer) => {
this.setState(() => this.timer = newTimer);
}
)
);
}
);
},
child: this._buildMenu(new List<Widget> {
new Text("Countdown Timer"),
new Text(
$"{this.timer.Hours}:" +
$"{(this.timer.Minutes % 60).ToString("00")}:" +
$"{(this.timer.Seconds % 60).ToString("00")}",
style: new TextStyle(color: CupertinoColors.inactiveGray)
)
}
)
);
}
Widget _buildDatePicker(BuildContext context) {
return new GestureDetector(
onTap: () => {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (BuildContext _context) => {
return this._buildBottomPicker(
new CupertinoDatePicker(
mode: CupertinoDatePickerMode.date,
initialDateTime: this.date,
onDateTimeChanged: (DateTime newDateTime) => {
this.setState(() => this.date = newDateTime);
}
)
);
}
);
},
child: this._buildMenu(new List<Widget> {
new Text("Date"),
new Text(
this.date.ToString("MMMM dd, yyyy"),
style: new TextStyle(color: CupertinoColors.inactiveGray)
)
}
)
);
}
Widget _buildTimePicker(BuildContext context) {
return new GestureDetector(
onTap: () => {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (BuildContext _context) => {
return this._buildBottomPicker(
new CupertinoDatePicker(
mode: CupertinoDatePickerMode.time,
initialDateTime: this.time,
onDateTimeChanged: (DateTime newDateTime) => {
this.setState(() => this.time = newDateTime);
}
)
);
}
);
},
child: this._buildMenu(new List<Widget> {
new Text("Time"),
new Text(
this.time.ToString("h:mm tt"),
style: new TextStyle(color: CupertinoColors.inactiveGray)
)
}
)
);
}
Widget _buildDateAndTimePicker(BuildContext context) {
return new GestureDetector(
onTap: () => {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
builder: (BuildContext _context) => {
return this._buildBottomPicker(
new CupertinoDatePicker(
mode: CupertinoDatePickerMode.dateAndTime,
initialDateTime: this.dateTime,
onDateTimeChanged: (DateTime newDateTime) => {
this.setState(() => this.dateTime = newDateTime);
}
)
);
}
);
},
child: this._buildMenu(new List<Widget> {
new Text("Date and Time"),
new Text(
this.dateTime.ToString("MMMM dd, yyyy h:mm tt"),
style: new TextStyle(color: CupertinoColors.inactiveGray)
)
}
)
);
}
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Picker"),
// We"re specifying a back label here because the previous page is a
// Material page. CupertinoPageRoutes could auto-populate these back
// labels.
previousPageTitle: "Cupertino"
//, trailing: new CupertinoDemoDocumentationButton(CupertinoPickerDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new DecoratedBox(
decoration: new BoxDecoration(
color: CupertinoTheme.of(context).brightness == Brightness.light
? CupertinoColors.extraLightBackgroundGray
: CupertinoColors.darkBackgroundGray
),
child: new SafeArea(
child: new ListView(
children: new List<Widget> {
new Padding(padding: EdgeInsets.only(top: 32.0f)),
this._buildColorPicker(context),
this._buildCountdownTimerPicker(context),
this._buildDatePicker(context),
this._buildTimePicker(context),
this._buildDateAndTimePicker(context)
}
)
)
)
)
);
}
}
}

70
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_slider_demo.cs


using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoSliderDemo : StatefulWidget {
public static string routeName = "/cupertino/slider";
public override State createState() {
return new _CupertinoSliderDemoState();
}
}
class _CupertinoSliderDemoState : State<CupertinoSliderDemo> {
float _value = 25.0f;
float _discreteValue = 20.0f;
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Sliders"),
previousPageTitle: "Cupertino"
//, trailing: new CupertinoDemoDocumentationButton(CupertinoSliderDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new SafeArea(
child: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: new List<Widget> {
new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new CupertinoSlider(
value: this._value,
min: 0.0f,
max: 100.0f,
onChanged: (float value) => {
this.setState(() => { this._value = value; });
}
),
new Text($"Cupertino Continuous: {this._value.ToString("F1")}"),
}
),
new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new CupertinoSlider(
value: this._discreteValue,
min: 0.0f,
max: 100.0f,
divisions: 5,
onChanged: (float value) => {
this.setState(() => { this._discreteValue = value; });
}
),
new Text($"Cupertino Discrete: {this._discreteValue}"),
}
),
}
)
)
)
)
);
}
}
}

73
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_switch_demo.cs


using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoSwitchDemo : StatefulWidget {
public static string routeName = "/cupertino/switch";
public override State createState() => new _CupertinoSwitchDemoState();
}
class _CupertinoSwitchDemoState : State<CupertinoSwitchDemo> {
bool _switchValue = false;
public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Switch"),
previousPageTitle: "Cupertino"
//, trailing: new CupertinoDemoDocumentationButton(CupertinoSwitchDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new SafeArea(
child: new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: new List<Widget> {
new Column(
children: new List<Widget> {
new CupertinoSwitch(
value: this._switchValue,
onChanged: (bool value) => {
this.setState(() => { this._switchValue = value; });
}
),
new Text(
"Enabled - " + (this._switchValue ? "On" : "Off")
),
}
),
new Column(
children: new List<Widget> {
new CupertinoSwitch(
value: true,
onChanged: null
),
new Text(
"Disabled - On"
),
}
),
new Column(
children: new List<Widget> {
new CupertinoSwitch(
value: false,
onChanged: null
),
new Text(
"Disabled - Off"
),
}
)
}
)
)
)
)
);
}
}
}

192
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_text_field_demo.cs


using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.service;
using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoTextFieldDemo : StatefulWidget {
public const string routeName = "/cupertino/text_fields";
public override State createState() {
return new _CupertinoTextFieldDemoState();
}
}
class _CupertinoTextFieldDemoState : State<CupertinoTextFieldDemo> {
TextEditingController _chatTextController;
TextEditingController _locationTextController;
public override void initState() {
base.initState();
this._chatTextController = new TextEditingController();
this._locationTextController = new TextEditingController(text: "Montreal, Canada");
}
Widget _buildChatTextField() {
return new CupertinoTextField(
controller: this._chatTextController,
textCapitalization: TextCapitalization.sentences,
placeholder: "Text Message",
decoration: new BoxDecoration(
border: Border.all(
width: 0.0f,
color: CupertinoColors.inactiveGray
),
borderRadius: BorderRadius.circular(15.0f)
),
maxLines: null,
keyboardType: TextInputType.multiline,
prefix: new Padding(padding: EdgeInsets.symmetric(horizontal: 4.0f)),
suffix:
new Padding(
padding: EdgeInsets.symmetric(horizontal: 4.0f),
child: new CupertinoButton(
color: CupertinoColors.activeGreen,
minSize: 0.0f,
child: new Icon(
CupertinoIcons.up_arrow,
size: 21.0f,
color: CupertinoColors.white
),
padding: EdgeInsets.all(2.0f),
borderRadius:
BorderRadius.circular(15.0f),
onPressed: () => this.setState(() => this._chatTextController.clear())
)
),
autofocus: true,
suffixMode: OverlayVisibilityMode.editing,
onSubmitted: (string text) => this.setState(() => this._chatTextController.clear())
);
}
Widget _buildNameField() {
return new CupertinoTextField(
prefix: new Icon(
CupertinoIcons.person_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
clearButtonMode: OverlayVisibilityMode.editing,
textCapitalization: TextCapitalization.words,
autocorrect: false,
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
),
placeholder: "Name"
);
}
Widget _buildEmailField() {
return new CupertinoTextField(
prefix: new Icon(
CupertinoIcons.mail_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
clearButtonMode: OverlayVisibilityMode.editing,
keyboardType: TextInputType.emailAddress,
autocorrect: false,
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
),
placeholder: "Email"
);
}
Widget _buildLocationField() {
return new CupertinoTextField(
controller: this._locationTextController,
prefix: new Icon(
CupertinoIcons.location_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
clearButtonMode: OverlayVisibilityMode.editing,
textCapitalization: TextCapitalization.words,
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
),
placeholder: "Location"
);
}
Widget _buildPinField() {
return new CupertinoTextField(
prefix: new Icon(
CupertinoIcons.padlock_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
clearButtonMode: OverlayVisibilityMode.editing,
keyboardType: TextInputType.number,
autocorrect: false,
obscureText: true,
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
),
placeholder: "Create a PIN"
);
}
Widget _buildTagsField() {
return new CupertinoTextField(
controller: new TextEditingController(text: "colleague, reading club"),
prefix: new Icon(
CupertinoIcons.tags_solid,
color: CupertinoColors.lightBackgroundGray,
size: 28.0f
),
enabled: false,
padding: EdgeInsets.symmetric(horizontal: 6.0f, vertical: 12.0f),
decoration: new BoxDecoration(
border: new Border(bottom: new BorderSide(width: 0.0f, color: CupertinoColors.inactiveGray))
)
);
}
public override Widget build(BuildContext context) {
return new DefaultTextStyle(
style: new TextStyle(
fontFamily: ".SF Pro Text", // ".SF UI Text",
inherit: false,
fontSize: 17.0f,
color: CupertinoColors.black
),
child: new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
previousPageTitle: "Cupertino",
middle: new Text("Text Fields")
),
child: new SafeArea(
child: new ListView(
children: new List<Widget> {
new Padding(
padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f),
child: new Column(
children: new List<Widget> {
this._buildNameField(),
this._buildEmailField(),
this._buildLocationField(),
this._buildPinField(),
this._buildTagsField(),
}
)
),
new Padding(
padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f),
child: this._buildChatTextField()
),
}
)
)
)
);
}
}
}
正在加载...
取消
保存