浏览代码

Merge pull request #145 from Unity-Technologies/dev_1.17.5

upgrade master to uiwidgets_2.0 (preview)
/main
GitHub 4 年前
当前提交
84b67d9e
共有 1573 个文件被更改,包括 7008 次插入4943 次删除
  1. 5
      .gitignore
  2. 237
      README-ZH.md
  3. 264
      README.md
  4. 11
      Samples/UIWidgetsSamples_2019_4/Assets/Editor.meta
  5. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta
  6. 16
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/BottomAppBarSample.cs
  7. 33
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/DividerAndButton.cs
  8. 20
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs
  9. 16
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs
  10. 12
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs.meta
  11. 13
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs
  12. 14
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs.meta
  13. 15
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs
  14. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs.meta
  15. 13
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs
  16. 14
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs.meta
  17. 47
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs
  18. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs.meta
  19. 20
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs
  20. 14
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs.meta
  21. 81
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs
  22. 2
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs.meta
  23. 14
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs
  24. 14
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs.meta
  25. 37
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/GalleryMain.cs
  26. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/UIWidgetsGallery.asmdef
  27. 15
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_activity_indicator_demo.cs
  28. 506
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_alert_demo.cs
  29. 135
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_buttons_demo.cs
  30. 552
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_navigation_demo.cs
  31. 522
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_picker_demo.cs
  32. 105
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_slider_demo.cs
  33. 119
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_switch_demo.cs
  34. 330
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/cupertino/cupertino_text_field_demo.cs
  35. 11
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material.meta
  36. 404
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/backdrop_demo.cs
  37. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/backdrop_demo.cs.meta
  38. 513
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_app_bar_demo.cs
  39. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_app_bar_demo.cs.meta
  40. 114
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_navigation_demo.cs
  41. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_navigation_demo.cs.meta
  42. 690
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/buttons_demo.cs
  43. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/buttons_demo.cs.meta
  44. 530
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/cards_demo.cs
  45. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/cards_demo.cs.meta
  46. 269
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/chip_demo.cs
  47. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/chip_demo.cs.meta
  48. 185
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs
  49. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs.meta
  50. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/modal_bottom_sheet_demo.cs
  51. 9
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/persistent_bottom_sheet_demo.cs
  52. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/persistent_bottom_sheet_demo.cs.meta
  53. 19
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/search_demo.cs
  54. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/search_demo.cs.meta
  55. 2
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/tabs_fab_demo.cs
  56. 11
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine.meta
  57. 45
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine_demo.cs
  58. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine_demo.cs.meta
  59. 11
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery.meta
  60. 170
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/app.cs
  61. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/app.cs.meta
  62. 260
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/backdrop.cs
  63. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/backdrop.cs.meta
  64. 316
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demo.cs
  65. 4
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demo.cs.meta
  66. 784
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs
  67. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs.meta
  68. 304
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs
  69. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs.meta
  70. 10
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/icons.cs
  71. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/icons.cs.meta
  72. 565
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/options.cs
  73. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/options.cs.meta
  74. 152
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/scales.cs
  75. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/scales.cs.meta
  76. 64
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/themes.cs
  77. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/themes.cs.meta
  78. 80
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs
  79. 14
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs.meta
  80. 3
      Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsSample.asmdef
  81. 2
      com.unity.uiwidgets/.editorconfig
  82. 24
      com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs
  83. 22
      com.unity.uiwidgets/Runtime/animation/animation.cs
  84. 327
      com.unity.uiwidgets/Runtime/animation/animation_controller.cs
  85. 278
      com.unity.uiwidgets/Runtime/animation/animations.cs
  86. 526
      com.unity.uiwidgets/Runtime/animation/curves.cs
  87. 179
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs
  88. 40
      com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk
  89. 130
      com.unity.uiwidgets/Runtime/animation/tween.cs
  90. 71
      com.unity.uiwidgets/Runtime/async/priority_queue.cs
  91. 264
      com.unity.uiwidgets/Runtime/async/timer.cs
  92. 2
      com.unity.uiwidgets/Runtime/async/timer.cs.meta
  93. 2
      com.unity.uiwidgets/Runtime/cupertino.meta
  94. 77
      com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs
  95. 2
      com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs.meta
  96. 144
      com.unity.uiwidgets/Runtime/cupertino/app.cs
  97. 2
      com.unity.uiwidgets/Runtime/cupertino/app.cs.meta
  98. 158
      com.unity.uiwidgets/Runtime/cupertino/button.cs
  99. 2
      com.unity.uiwidgets/Runtime/cupertino/button.cs.meta
  100. 769
      com.unity.uiwidgets/Runtime/cupertino/colors.cs

5
.gitignore


npm-debug.log
build.sh.meta
build.bat.meta
# uiwidgets
Samples/Assets/Plugins/**
engine/build/**
engine/third_party/skia

237
README-ZH.md


# UIWidgets
# UIWidgets 2.0 (preview)
## 介绍

UIWidgets主要来自[Flutter](https://github.com/flutter/flutter)。但UIWidgets通过使用强大的Unity引擎为开发人员提供了许多新功能,显著地改进他们开发的应用性能和工作流程。
UIWidgets 2.0是UIWidgets的最新版本,它主要着力于UI绘制相关的整体性能优化。经测试,UIWidgets 2.0在iPhone 6等部分机型上的帧率相对1.0版本可以取得10%左右的提升。如果因为各种原因您还需要使用UIWidgets 1.0,请在Releases中下载对应的包或者使用uiwidgets_1.0分支。
与任何其他Unity项目一样,UIWidgets应用可以直接部署在各种平台上,包括PC,移动设备和网页等。
与任何其他Unity项目一样,UIWidgets应用可以直接部署在各种平台上,包括PC和移动设备等。
#### 多媒体支持
除了基本的2D UI之外,开发人员还能够将3D模型,音频,粒子系统添加到UIWidgets应用中。

#### Unity
安装 **Unity 2018.4.10f1(LTS)****Unity 2019.1.14f1** 及其更高版本。 你可以从[https://unity3d.com/get-unity/download](https://unity3d.com/get-unity/download)下载最新的Unity。
安装 **Unity 2019.1.14f1c1** 及其更高版本。 你可以从[https://unity3d.com/get-unity/download](https://unity3d.com/get-unity/download)下载最新的Unity。
访问我们的Github存储库 [https://github.com/UnityTech/UIWidgets](https://github.com/UnityTech/UIWidgets)下载最新的UIWidgets包。
访问我们的Github存储库 [https://github.com/Unity-Technologies/com.unity.uiwidgets](https://github.com/Unity-Technologies/com.unity.uiwidgets)下载最新的UIWidgets包。
将下载的包文件夹移动到Unity项目的Package文件夹中。

cd <YourProjectPath>/Packages
git clone https://github.com/UnityTech/UIWidgets.git com.unity.uiwidgets
cd <YourPackagePath>
git clone https://github.com/Unity-Technologies/com.unity.uiwidgets.git com.unity.uiwidgets
在unity的PackageManager中,选择添加添加local file。选中```/com.unity.uiwidgets```下的```package.json```。
#### 运行环境
UIWidgets目前暂时只支持MacOS(Metal),iOS(Metal),Android(Armv7,OpenGLes)以及 Windows(Direct3D11)。我们后续会针对更广泛的运行环境进行适配,敬请期待。
## 入门指南

首先,请打开或创建Unity项目并使用Unity编辑器打开它。
然后打开Project Settings,转到Player部分并**将“UIWidgets_DEBUG”添加到Scripting Define Symbols字段中。**
这样就启动了UIWidgets的调试模式。 在之后发布版本的时候清空这个字段。
#### 二、 场景构建

UIWidgets应用是用**C#脚本**来编写的。 请按照以下步骤创建应用程序并在Unity编辑器中播放。
1. 创建一个新C#脚本,命名为“UIWidgetsExample.cs”,并将以下代码粘贴到其中。
```csharp
```csharp
using Unity.UIWidgets.animation;
using uiwidgets;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using UnityEngine;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Text = Unity.UIWidgets.widgets.Text;
using ui_ = Unity.UIWidgets.widgets.ui_;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class UIWidgetsExample : UIWidgetsPanel {
protected override void OnEnable() {
namespace UIWidgetsSample
{
public class CountDemo : UIWidgetsPanel
{
protected void OnEnable()
{
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "font family name");
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
// a TextStyle object
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
// FontStyle.italic);
// add material icons, familyName must be "Material Icons"
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to material icons"), "Material Icons");
// AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
protected override Widget createWidget() {
return new WidgetsApp(
home: new ExampleApp(),
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) => builder(context)
)
);
protected override void main()
{
ui_.runApp(new MyApp());
class ExampleApp : StatefulWidget {
public ExampleApp(Key key = null) : base(key) {
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new CounterApp()
);
}
}
public override State createState() {
return new ExampleState();
}
internal class CounterApp : StatefulWidget
{
public override State createState()
{
return new CountDemoState();
}
class ExampleState : State<ExampleApp> {
int counter = 0;
internal class CountDemoState : State<CounterApp>
{
private int count = 0;
public override Widget build(BuildContext context) {
return new Column(
children: new List<Widget> {
new Text("Counter: " + this.counter),
new GestureDetector(
onTap: () => {
this.setState(() => {
this.counter++;
public override Widget build(BuildContext context)
{
return new Container(
color: Color.fromARGB(255, 255, 0, 0),
child: new Column(children: new List<Widget>()
{
new Text($"count: {count}", style: new TextStyle(color: Color.fromARGB(255, 0 ,0 ,255))),
new CupertinoButton(
onPressed: () =>
{
setState(() =>
{
count++;
padding: EdgeInsets.symmetric(20, 20),
color: Colors.blue,
child: new Text("Click Me")
color: Color.fromARGB(255,0 , 255, 0),
width: 100,
height: 40
)
),
);
}
)
);
```
```
2. 保存此脚本,并将其附加到Panel 1中作为其组件。
3. 在Unity编辑器中,点击Play按钮来启动应用。

2. 选择目标平台,点击Build。 之后Unity编辑器将自动组装所有相关资源并生成最终的应用程序包。
#### 五、如何加载图像?
1. 将你的图像文件,如image1.png,放在Resources文件夹中。
2. 你可以在同一文件夹中添加image1@2.png和image1@3.png以支持高清屏幕显示。
3. 使用Image.asset(“image1”)加载图像。 注意:因为是在Unity中,所以不需要添加.png后缀。
1. 将你的图像文件,如image1.png,放在StreamingAssets文件夹中。
2. 使用Image.file("image1.png")加载图像。
1. 假设你有一个loading1.gif文件,将其重命名为loading1.gif.bytes并复制到Resources文件夹。
2. 你可以在同一文件夹中添加loading1@2.gif.bytes和loading1@3.gif.bytes以支持高清屏幕显示。
3. 使用Image.asset(“loading1.gif”)加载gif图像。
1. 假设你有一个loading1.gif文件,复制到StreamingAssets文件夹。
2. 使用Image.file("loading1.gif")加载gif图像。
如果您希望在您的UIWidgets App中显示状态栏,您可以使用这个[解决方案](https://github.com/Over17/UnityShowAndroidStatusBar)。我们将尽快推出我们自己的解决方案,并保证届时开发者可以进行无缝切换。
如果您希望在您的UIWidgets App中显示状态栏,您可以取消```Start in fullscreen``` 与 ```record outside safe area```, 确认```UIWidgetsAndroidConfiguration```下```showStatusBar```为 ```true```
此外,为了让上述插件在Android P及以上Android系统中正常工作,请勾选上"Player Settings"中的"Render Outside Safe Area"选项。
#### 七、自动调节帧率
如果要使得构建出的应用能够自动调节帧率,请打开Project Settings,将构建目标平台对应的Quality选项卡中的V Sync Count设置为Don't Sync。
默认的逻辑是在界面静止时将帧率降低,在界面变动时再将帧率提高至60。
如果您不想开启该功能,请将`Window.onFrameRateSpeedUp`和/或`Window.onFrameRateCoolDown`设置为空函数,()=> {}即可。
在Unity 2019.3版本及以上,UIWidgets将使用OnDemandRenderAPI来实现帧率调节,它将在不影响UI响应速度的情况下大幅降低耗电和发热问题。
#### 八、WebGL Canvas分辨率调整插件
因为浏览器中Canvas的宽高和其在显示器上的像素数可能不一致,所以构建出的WebGL程序中画面可能会模糊。
插件`Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib`(目前有2018.3和2019.1)解决了这个问题。
请根据您的项目的Unity版本选择对应的插件,并禁用此插件的其他版本。方法如下:在Project面板中选中该插件,在Inspector面板中的Select platforms for plugin中,去掉WebGL后面的对勾。
如果您因为任何原因需要完全禁止此插件的功能,请按上述方法禁用此插件的所有版本。
此插件覆盖了Unity WebGL构建模块中的如下参数:
```none
JS_SystemInfo_GetWidth
JS_SystemInfo_GetHeight
JS_SystemInfo_GetCurrentCanvasWidth
JS_SystemInfo_GetCurrentCanvasHeight
$Browser
$JSEvents
```
如果您需要实现自己的WebGL插件,并且您的插件覆盖了这些参数中的至少一种,您需要采用上文中提到的方法禁用`UIWidgetsCanvasDevicePixelRatio`插件,以防止可能的冲突。
如果您仍然需要此插件所提供的功能,您可以手动将此插件对Unity WebGL构建模块的修改应用到您的插件中。
`UIWidgetsCanvasDevicePixelRatio`插件中所有的修改之处都以`////////// Modification Start ////////////`和`////////// Modification End ////////////`标识。
在被标识的代码中,所有乘/除以`devicePixelRatio`都来自于我们的修改。
若您需要详细了解此插件所修改的脚本,请参考您的Unity Editor安装目录下的`PlaybackEngines/WebGLSupport/BuildTools/lib`文件夹中的`SystemInfo.js`和`UnityNativeJS/UnityNative.js`。
#### 九、图片导入设置
默认情况下,Unity会将导入图片的宽和高放缩为最近的等于2的幂的整数。
在UIWidgets中使用图片时,记得将这一特性关闭,以免图片被意外放缩,方法如下:在Project面板中选中图片,在"Inspector"面板中将"Non Power of 2"(在"Advanced"中)设置为"None"。
#### 十、更新表情(Emoji)
UIWidgets支持渲染文本中包含的表情。
默认的表情资源为[iOS 13.2](https://emojipedia.org/apple/ios-13.2)。
我们也准备了[Google Emoji](https://emojipedia.org/google)的表情资源。
如果您希望切换到Google版本的表情,请按如下步骤操作:
#### 七、图片导入设置
请将图片放入StreamingAssets下,而后用```Image.file```读取
1. 拷贝`Runtime/Resources/backup~/EmojiGoogle.png`到`Runtime/Resources/images`目录。
2. 在**Project**面板中,找到`EmojiGoogle`资源,在**Inspector**面板中,将**Max Size**更改为4096,取消选中**Generate Mipmaps**,并选中**Alpha Is Transparency**。
3. 在您的代码中继承`UIWidgetsPanel`的类的`OnEnable()`函数中,添加如下代码
```csharp
EmojiUtils.configuration = EmojiUtils.googleEmojiConfiguration;
```
## 调试UIWidgets应用程序
如果您希望使用自己的表情图片,请按如下步骤操作:
在编辑器菜单栏选择```UIWidgets->EnableDebug```
1. 参照`EmojiGoogle.png`,创建您自己的Emoji表单,并放到工程目录下的某个`Resources`目录中,例如`Resources/myImages/MyEmoji.png`)。
2. 在`OnEnable()`函数中,添加如下代码(记得将示例的值改为真实的值)。注意Emoji的编码的顺序要和Emoji表单一致。
如果想在runtime选择是否debug,请修改文件```com.unity.uiwidgets/com.unity.uiwidgets/Runtime/foundation/debug.cs```中的```static bool debugEnableAtRuntimeInternal```
## 使用Window Scope保护外部调用
如果您在调试时遇到 `AssertionError: Window.instance is null` 或者在调用 `Window.instance` 时得到空指针, 那么您需要
使用以下方式来保护您的调用,使之可以在正确的Isolate上执行回调逻辑:
EmojiUtils.configuration = new EmojiResourceConfiguration(
spriteSheetAssetName: "myImage/MyEmoji",
emojiCodes: new List<int> {
0x1f004, 0x1f0cf, 0x1f170, ...
},
spriteSheetNumberOfRows: 36,
spriteSheetNumberOfColumns: 37,
);
using(Isolate.getScope(the isolate of your App)) {
// code dealing with UIWidgets,
// e.g. setState(() => {....})
}
#### 十一、与GameObject进行拖拽交互
<p align="center">
<img src="https://connect-prd-cdn.unity.com/20190718/p/images/e3c9cf9b-c732-4eb2-9afd-fe7de894f342_Custom_Inspector_Showcase_320px.gif" width="300"/>
</p>
我们提供了一个包装好的`UnityObjectDetector`组件以及`onRelease`回调函数,借此您可以实现简单地将物体(例如Hierarchy内的场景物体、Project窗口下的文件等)拖拽至区域内,来获得`UnityEngine.Object[] `类型的引用并进行操作。
## 调试UIWidgets应用程序
#### 定义UIWidgets_DEBUG
我们建议在Unity编辑器中定义 UIWidgets_DEBUG 脚本符号,这将打开UIWidgets中的调试断言(debug assertion),有助于更早发现潜在的Bug。
因此选择 **Player Settings** > **Other Settings** > **Configuration** > **Scripting Define Symbols** ,并添加 UIWidgets_DEBUG。
该符号仅供调试使用,请在发布版本中删除它。
#### UIWidgets Inspector
UIWidgets Inspector工具用于可视化和浏览窗口小部件树。 你可以在Unity编辑器的**Window** > **Analysis** > **UIWidget Inspector** 中的找到它。
注意
- 需要定义 UIWidgets_DEBUG 使inspector正常工作。
- Inspector目前仅适用于编辑器的播放模式,目前不支持独立版本的应用程序。
通常,在您使用外部事件,例如来自UIWidgets之外的输入事件、网络传输回调事件时需要做这样的处理。具体的您可以参考我们的 HttpRequestSample 这个样例中的写法。需要注意的是,一般情况下您在UIWidgets框架的内部调用 (如 `Widget.build, State.initState...`)中不需要额外采取上述保护措施。
## 学习

- UIWidgets官方示例。目前所有官方使用的示例项目均维护在一个独立的Github仓库( https://github.com/UIWidgets/UIWidgetsSamples )中。你可以
将它clone到你项目本地的Assets目录下使用。
- UIWidgets官方示例。目前所有官方使用的示例项目均维护在一个独立的Github仓库( https://github.com/Unity-Technologies/com.unity.uiwidgets )中。
具体的,你可以在Sample项目的**Scene**子文件夹中浏览所有示例UI场景。
此外,你还可以点击主菜单上的新增的UIWidgetsTests选项卡,并在下拉菜单中选择一个EditorWindow UI示例来运行。
- UIWidgets凉鞋系列教程。你可以在凉鞋老师整理的Github仓库( https://github.com/liangxiegame/awesome-uiwidgets )中学习UIWidgets的基本用法

264
README.md


# UIWidgets
# UIWidgets 2.0 (preview)
[中文](README-ZH.md)

the powerful Unity Engine, it offers developers many new features to improve their Apps
as well as the develop workflow significantly.
As the latest version, UIWidgets 2.0 aims to optmize the overall performance of the package. Specifically, a performance gain around 10% is observed on mobile devices like iPhone 6 after upgrading to UIWidgets 2.0. However, if you still want to use the original UIWidgets 1.0, please download the archived packages from Releases or switch your working branch to uiwidgets_1.0.
A UIWidgets App can be deployed on all kinds of platforms including PCs, mobile devices and web page directly, like
A UIWidgets App can be deployed on all kinds of platforms including PCs and mobile devices directly, like
any other Unity projects.
#### Multimedia Support

#### Unity
Install **Unity 2018.4.10f1 (LTS)** or **Unity 2019.1.14f1** and above. You can download the latest Unity on https://unity3d.com/get-unity/download.
Install **Unity 2019.1.14f1c1** and above. You can download the latest Unity on https://unity3d.com/get-unity/download.
Visit our Github repository https://github.com/UnityTech/UIWidgets
Visit our Github repository https://github.com/Unity-Technologies/com.unity.uiwidgets
to download the latest UIWidgets package.
Move the downloaded package folder into the **Package** folder of your Unity project.

```none
cd <YourProjectPath>/Packages
git clone https://github.com/UnityTech/UIWidgets.git com.unity.uiwidgets
cd <YourPackagePath>
git clone https://github.com/Unity-Technologies/com.unity.uiwidgets.git com.unity.uiwidgets
In PackageManger of unity, select add local file. select ```package.json``` under ```/com.unity.uiwidgets```
#### Runtime Environment
Currently UIWidgets only supports MacOS(Metal), iOS(Metal), Android(Armv7, OpenGLes) and Windows(Direct3D11). More devices will be supported in the future.
## Getting Start
#### i. Overview

First of all, please open or create a Unity Project and open it with Unity Editor.
And then open Project Settings, go to Player section and **add "UIWidgets_DEBUG" to the Scripting Define Symbols field.**
This enables the debug mode of UIWidgets for your development. Remove this for your release build afterwards.
#### ii. Scene Build
A UIWidgets App is usually built upon a Unity UI Canvas. Please follow the steps to create a

1. Create a new C# Script named "UIWidgetsExample.cs" and paste the following codes into it.
```csharp
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using uiwidgets;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using UnityEngine;
using FontStyle = Unity.UIWidgets.ui.FontStyle;
using Text = Unity.UIWidgets.widgets.Text;
using ui_ = Unity.UIWidgets.widgets.ui_;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {
public class UIWidgetsExample : UIWidgetsPanel {
protected override void OnEnable() {
namespace UIWidgetsSample
{
public class CountDemo : UIWidgetsPanel
{
protected void OnEnable()
{
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "font family name");
// load custom font with weight & style. The font weight & style corresponds to fontWeight, fontStyle of
// a TextStyle object
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to your font"), "Roboto", FontWeight.w500,
// FontStyle.italic);
// add material icons, familyName must be "Material Icons"
// FontManager.instance.addFont(Resources.Load<Font>(path: "path to material icons"), "Material Icons");
// AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
protected override Widget createWidget() {
return new WidgetsApp(
home: new ExampleApp(),
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(
settings: settings,
pageBuilder: (BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) => builder(context)
)
);
protected override void main()
{
ui_.runApp(new MyApp());
class ExampleApp : StatefulWidget {
public ExampleApp(Key key = null) : base(key) {
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new CupertinoApp(
home: new CounterApp()
);
}
}
public override State createState() {
return new ExampleState();
}
internal class CounterApp : StatefulWidget
{
public override State createState()
{
return new CountDemoState();
}
class ExampleState : State<ExampleApp> {
int counter = 0;
internal class CountDemoState : State<CounterApp>
{
private int count = 0;
public override Widget build(BuildContext context) {
return new Column(
children: new List<Widget> {
new Text("Counter: " + this.counter),
new GestureDetector(
onTap: () => {
this.setState(()
=> {
this.counter++;
public override Widget build(BuildContext context)
{
return new Container(
color: Color.fromARGB(255, 255, 0, 0),
child: new Column(children: new List<Widget>()
{
new Text($"count: {count}", style: new TextStyle(color: Color.fromARGB(255, 0 ,0 ,255))),
new CupertinoButton(
onPressed: () =>
{
setState(() =>
{
count++;
padding: EdgeInsets.symmetric(20, 20),
color: Colors.blue,
child: new Text("Click Me")
color: Color.fromARGB(255,0 , 255, 0),
width: 100,
height: 40
)
),
);
}
)
);
}
}
}

all relevant resources and generate the final App package.
#### How to load images?
1. Put your images files in Resources folder. e.g. image1.png.
2. You can add image1@2.png and image1@3.png in the same folder to support HD screens.
3. Use Image.asset("image1") to load the image. Note: as in Unity, ".png" is not needed.
1. Put your images files in StreamingAssets folder. e.g. image1.png.
2. Use Image.file("image1.png") to load the image.
1. Suppose you have loading1.gif. Rename it to loading1.gif.bytes and copy it to Resources folder.
2. You can add loading1@2.gif.bytes and loading1@3.gif.bytes in the same folder to support HD screens.
3. Use Image.asset("loading1.gif") to load the gif images.
1. Put your gif files in StreamingAssets folder. e.g. loading1.gif.
2. Use Image.file("loading1.gif") to load the gif images.
#### Show Status Bar on Android
Status bar is always hidden by default when an Unity project is running on an Android device.
If you
want to show the status bar in your App, you can disable```Start in fullscreen``` and ```record outside safe area```, make sure ```showStatusBar``` is ```true``` under ```UIWidgetsAndroidConfiguration```
#### Image Import Setting
Please put images under StreamingAssets folder, a and loading it using ```Image.file```.
## Debug UIWidgets Application
In Unity editor, you can switch debug/release mode by “UIWidgets->EnableDebug”.
If you want to change different mode in runtime, please modify the file “com.unity.uiwidgets/com.unity.uiwidgets/Runtime/foundation/debug.cs” by making “static bool debugEnableAtRuntimeInternal” to true or false. Note that the value is set to false by default.
#### Using Window Scope
## Using Window Scope
using(WindowProvider.of(your gameObject with UIWidgetsPanel).getScope()) {
using(Isolate.getScope(the isolate of your App)) {
// code dealing with UIWidgets,
// e.g. setState(() => {....})
}

not invoked by UIWidgets. For example, if the code is in `completed` callback of `UnityWebRequest`,
you need to enclose them with window scope.
Please see [HttpRequestSample](./Samples/UIWidgetSample/HttpRequestSample.cs) for detail.
Please see our HttpRequestSample for detail.
#### Show Status Bar on Android
Status bar is always hidden by default when an Unity project is running on an Android device. If you
want to show the status bar in your App, this
[solution](https://github.com/Over17/UnityShowAndroidStatusBar) seems to be
compatible to UIWidgets, therefore can be used as a good option before we release our
full support solution on this issue.
Besides,
please set "Render Outside Safe Area" to true in the "Player Settings" to make this plugin working properly on Android P or later.
#### Automatically Adjust Frame Rate
To build an App that is able to adjust the frame rate automatically, please open Project Settings, and in the Quality tab, set the "V Sync Count" option of the target platform to "Don't Sync".
The default logic is to reduce the frame rate when the screen is static, and change it back to 60 whenever the screen changes.
If you would like to disable this behavior, please set `Window.onFrameRateSpeedUp` and `Window.onFrameRateCoolDown` to null function, i.e., () => {}.
Note that in Unity 2019.3 and above, UIWidgets will use OnDemandRenderAPI to implement this feature, which will greatly save the battery.
#### WebGL Canvas Device Pixel Ratio Plugin
The width and height of the Canvas in browser may differ from the number of pixels the Canvas occupies on the screen.
Therefore, the image may blur in the builded WebGL program.
The Plugin `Plugins/platform/webgl/UIWidgetsCanvasDevicePixelRatio_20xx.x.jslib` (2018.3 and 2019.1 for now) solves this issue.
Please select the plugin of the Unity version corresponding to your project, and disable other versions of this plugin, as follows: select this plugin in the **Project** panel, and uncheck **WebGL** under **Select platforms for plugin** in the **Inspector** panel.
If you need to disable this plugin for any reason, please disable all the versions of this plugin as described above.
This plugin overrides the following parameters in the Unity WebGL building module:
```none
JS_SystemInfo_GetWidth
JS_SystemInfo_GetHeight
JS_SystemInfo_GetCurrentCanvasWidth
JS_SystemInfo_GetCurrentCanvasHeight
$Browser
$JSEvents
```
If you would like to implement your own WebGL plugin, and your plugin overrides at least one of the above parameters, you need to disable the `UIWidgetsCanvasDevicePixelRatio` plugin in the above mentioned way to avoid possible conflicts.
If you still need the function provided by this plugin, you can mannually apply the modification to Unity WebGL building module introduced in this plugin.
All the modifications introduced in `UIWidgetsCanvasDevicePixelRatio` are marked by `////////// Modifcation Start ////////////` and `////////// Modifcation End ////////////`.
In the marked codes, all the multiplications and divisions with `devicePixelRatio` are introduced by our modification.
To learn about the original script in detail, please refer to `SystemInfo.js` and `UnityNativeJS/UnityNative.js` in `PlaybackEngines/WebGLSupport/BuildTools/lib` in your Unity Editor installation.
#### Image Import Setting
Unity, by default, resizes the width and height of an imported image to the nearest integer that is a power of 2.
In UIWidgets, you should almost always disable this by selecting the image in the "Project" panel, then in the "Inspector" panel set the "Non Power of 2" option (in "Advanced") to "None", to prevent your image from being resized unexpectedly.
#### Update Emoji
UIWidgets supports rendering emoji in (editable) texts.
The default emoji resource version is [iOS 13.2](https://emojipedia.org/apple/ios-13.2).
We also prepared the resources of [Google Emoji](https://emojipedia.org/google).
To switch to Google version of emoji, please follow the following steps:
1. Copy `Runtime/Resources/backup~/EmojiGoogle.png` to `Runtime/Resources/images` folder.
2. In the **Project** panel, find and select `EmojiGoogle` asset, and in the **Inspector** panel, change **Max Size** to 4096, disable **Generate Mipmaps**, and enable **Alpha Is Transparency**.
3. In the `OnEnable()` function in your class overriding `UIWidgetsPanel`, add the following code
```csharp
EmojiUtils.configuration = EmojiUtils.googleEmojiConfiguration;
```
If you would like to use your own images for emoji, please follow the following steps:
1. Create the sprite sheet (take `EmojiGoogle.png` as an example), and put in a `Resources` folder in your project, (for example `Resources/myImages/MyEmoji.png`).
2. In the `OnEnable()` function, add the following code (replace example values with actual value). Note that the order of emoji codes should be consistent with the sprite sheet.
```csharp
EmojiUtils.configuration = new EmojiResourceConfiguration(
spriteSheetAssetName: "myImage/MyEmoji",
emojiCodes: new List<int> {
0x1f004, 0x1f0cf, 0x1f170, ...
},
spriteSheetNumberOfRows: 36,
spriteSheetNumberOfColumns: 37,
);
```
#### Interact with GameObject Drag&Drops
<p align="center">
<img src="https://connect-prd-cdn.unity.com/20190718/p/images/e3c9cf9b-c732-4eb2-9afd-fe7de894f342_Custom_Inspector_Showcase_320px.gif" width="300"/>
</p>
With the provided packaged stateful widget `UnityObjectDetector` and its `onRelease` callback function, you can easily drag some objects (for example GameObject from Hierarchy, files from Project Window, etc) into the area, get the UnityEngine.Object[] references and make further modification.
## Debug UIWidgets Application
#### Define UIWidgets_DEBUG
It's recommended to define the **UIWidgets_DEBUG** script symbol in editor, this will turn on
debug assertion in UIWidgets, which will help to find potential bugs earlier. To do this:
please go to **Player Settings -> Other Settings -> Configuration -> Scripting Define Symbols**,
and add **UIWidgets_DEBUG**.
The symbol is for debug purpose, please remove it from your release build.
#### UIWidgets Inspector
The UIWidgets Inspector tool is for visualizing and exploring the widget trees. You can find it
via *Window/Analysis/UIWidgets* inspector in Editor menu.
**Note**
* **UIWidgets_DEBUG** needs to be define for inspector to work properly.
* Inspector currently only works in Editor Play Mode, inspect standalone built application is not supported for now.
* UIWidgetsSamples (https://github.com/UIWidgets/UIWidgetsSamples). These samples are developed by the dev team in order to illustrates all the features of
UIWidgets. First clone this Repo to the **Assets** folder of your local UIWidgets project. Then
* UIWidgetsSamples (https://github.com/Unity-Technologies/com.unity.uiwidgets). These samples are developed by the dev team in order to illustrates all the features of
UIWidgets.
you can find all the sample scenes under the **Scene** folder.
You can also try UIWidgets-based Editor windows by clicking the new **UIWidgetsTests** tab on the main menu
and open one of the dropdown samples.

11
Samples/UIWidgetsSamples_2019_4/Assets/Editor.meta


fileFormatVersion: 2
guid: 0ae90c343ee0e4f7daf768fe6383340f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: fbf4348f25a14fb7a48fd287e0d01b88
timeCreated: 1614220178

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta


fileFormatVersion: 2
guid: 611706478d8aa410983272ad601895d3
guid: c0f377c78881e9243879a01b93524d63
folderAsset: yes
DefaultImporter:
externalObjects: {}

16
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/BottomAppBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;

using Color = Unity.UIWidgets.ui.Color;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class BottomAppBarSample : UIWidgetsSamplePanel {
public class BottomAppBarSample : UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
home: new BottomAppBarWidget());
home: new BottomAppBarWidget()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

public override Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Color.clear,
backgroundColor: Colors.grey,
bottomNavigationBar: new BottomAppBar(
child: new Row(
mainAxisSize: MainAxisSize.max,

33
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/DividerAndButton.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;

using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class DividerAndButton : UIWidgetsSamplePanel {
public class DividerAndButton : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MyApp());
}
protected override Widget createWidget() {
return new WidgetsApp(
home: new DividerAndButtonSample(),
pageRouteBuilder: this.pageRouteBuilder);
class MyApp : StatelessWidget
{
public override Widget build(BuildContext context)
{
return new MaterialApp(
home: new DividerAndButtonSample()
);
}
}
public class DividerAndButtonSample : StatefulWidget {

public class _DividerAndButtonState : State<DividerAndButtonSample> {
string title = "Hello";
string subtitle = "World";
TextEditingController controller = new TextEditingController("");
TextEditingController controller = new TextEditingController("xxxxxx");
return new Container(
return new DividerTheme(
data: new DividerThemeData(
),
child: new Container(
height: 200,
padding: EdgeInsets.all(10),
decoration: new BoxDecoration(

fontSize: 18,
height: 1.5f,
color: new Color(0xFFFF89FD)),
cursorColor: Color.fromARGB(255, 0, 0, 0)
cursorColor: Color.fromARGB(255, 0, 0, 0),
backgroundCursorColor: Colors.grey
)
),
new Divider(),

}
)
)
);
));
}
}
}

20
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs


using System.Collections.Generic;
using RSG;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using UnityEngine;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class MaterialAppBarSample : UIWidgetsSamplePanel {
public class MaterialAppBarSample : UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
home: new MaterialAppBarWidget());
home: new MaterialAppBarWidget()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

fontSize: 16.0f))
)
);
}).closed.Then((object obj) => {
}).closed.then((object obj) => {
return new Promise();
});
}

16
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class MaterialButtonSample : UIWidgetsSamplePanel {
public class MaterialButtonSample : UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
home: new MaterialButtonWidget());
home: new MaterialButtonWidget()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

}
)
)
),
new PerformanceOverlay()
)
}
);
}

12
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs.meta


fileFormatVersion: 2
fileFormatVersion: 2
timeCreated: 1573031753
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

13
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs


using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class MaterialInkWellSample : UIWidgetsSamplePanel {
public class MaterialInkWellSample : UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
home: new MaterialInkWellWidget());
home: new MaterialInkWellWidget()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialInkWellSample.cs.meta


fileFormatVersion: 2
guid: 1a03d2251d4fb4ef08021dcb11b0dc68
timeCreated: 1573031753
fileFormatVersion: 2
guid: b9e88c33e9f304d40bab9c27f1276033
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

15
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs


using System.Collections.Generic;
using RSG;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using UnityEngine;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class MaterialNavigationBarSample : UIWidgetsSamplePanel {
public class MaterialNavigationBarSample : UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
home: new MaterialNavigationBarWidget());
home: new MaterialNavigationBarWidget()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialNavigationBarSample.cs.meta


fileFormatVersion: 2
guid: 19405b76532fc44ae91d3c0996408a3e
guid: cc34344049d222b468f2487b97076448
MonoImporter:
externalObjects: {}
serializedVersion: 2

13
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class MaterialSliderSample : UIWidgetsSamplePanel {
public class MaterialSliderSample : UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
home: new MaterialSliderWidget());
home: new MaterialSliderWidget()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialSliderSample.cs.meta


fileFormatVersion: 2
guid: a403bd4bc6da446f1bb8cc0424f2fb85
timeCreated: 1573031753
fileFormatVersion: 2
guid: 0152b6f575e6ca44baea965a23ebe498
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

47
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using UnityEngine;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class MaterialTabBarSample : UIWidgetsSamplePanel {
public class MaterialTabBarSample : UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
home: new MaterialTabBarWidget());
home: new TabBarDemo()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void 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),
}
)
)
);*/
}
}

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialTabBarSample.cs.meta


fileFormatVersion: 2
guid: 0cbd2174900054317b93e50e058cd61b
guid: fecd06f805d0b0f4ead134b1ad6a9a49
MonoImporter:
externalObjects: {}
serializedVersion: 2

20
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using Unity.UIWidgets.widgets;
using UnityEngine;
using Image = Unity.UIWidgets.widgets.Image;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class MaterialThemeSample: UIWidgetsSamplePanel {
public class MaterialThemeSample: UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
);
));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

height: 250,
child: new Column(
children: new List<Widget> {
Image.asset(
"products/backpack",
fit: BoxFit.cover,
width: 200,
height: 200
),
new Text("Card Theme")
}
)

14
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialThemeSample.cs.meta


fileFormatVersion: 2
guid: f5061bd7b85f4179a65c68ac289a4a58
timeCreated: 1556597371
fileFormatVersion: 2
guid: b2a39cf0b83823749a13aebaf25cfb1b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

81
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs


using System.Collections.Generic;
using System.Linq;
using RSG;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class ReorderableListSample : UIWidgetsSamplePanel {
protected override Widget createWidget() {
return new MaterialApp(
public class ReorderableListSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
home: new MaterialReorderableListViewWidget());
home: new MaterialReorderableListViewWidget()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

}
class MaterialReorderableListViewWidgetState : State<MaterialReorderableListViewWidget> {
List<string> items = new List<string> {"First", "Second", "Third"};
List<string> _list = new List<string> {"Apple", "Ball", "Cat", "Dog", "Elephant"};
body: new Scrollbar(
child: new ReorderableListView(
header: new Text("Header of list"),
children: this.items.Select<string, Widget>((item) => {
return new Container(
key: Key.key(item),
width: 300.0f,
height: 50.0f,
decoration: new BoxDecoration(
color: Colors.blue,
border: Border.all(
color: Colors.black
)
),
child: new Center(
child: new Text(
item,
style: new TextStyle(
fontSize: 32
)
)
)
);
}).ToList(),
onReorder: (int oldIndex, int newIndex) => {
this.setState(() => {
if (newIndex > oldIndex) {
newIndex -= 1;
}
string item = this.items[oldIndex];
this.items.RemoveAt(oldIndex);
this.items.Insert(newIndex, item);
});
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(() => {});
}
)
);
}
}

2
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/ReorderableListSample.cs.meta


fileFormatVersion: 2
guid: 4743f6dbc9049447eaae87cc7519406b
guid: f510d7fbd19431046bfb4b92c39b4da4
MonoImporter:
externalObjects: {}
serializedVersion: 2

14
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using ui_ = Unity.UIWidgets.widgets.ui_;
public class TableSample : UIWidgetsSamplePanel {
public class TableSample : UIWidgetsPanel {
protected override Widget createWidget() {
return new MaterialApp(
protected override void main() {
ui_.runApp(new MaterialApp(
home: new TableWidget());
home: new TableWidget()));
protected override void OnEnable() {
FontManager.instance.addFont(Resources.Load<Font>(path: "fonts/MaterialIcons-Regular"), "Material Icons");
protected new void OnEnable() {
base.OnEnable();
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/TableSample.cs.meta


fileFormatVersion: 2
guid: 07e8ae972d9945faaef3326486f3a4bf
timeCreated: 1573031753
fileFormatVersion: 2
guid: 1cba65c03fbf50f4cac974273a7c9445
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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


using System.Collections.Generic;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using UnityEngine;
namespace UIWidgetsGallery
{
public class GalleryMain : UIWidgetsPanel
{
protected new void OnEnable()
{
base.OnEnable();
}
namespace UIWidgetsGallery {
public class GalleryMain : UIWidgetsPanel {
protected override Widget createWidget() {
return new GalleryApp();
protected override void main()
{
ui_.runApp(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();
protected override void onEnable()
{
AddFont("Material Icons", new List<string> {"MaterialIcons-Regular.ttf"}, new List<int> {0});
AddFont("CupertinoIcons", new List<string> {"CupertinoIcons.ttf"}, new List<int> {0});
AddFont("GalleryIcons", new List<string> {"gallery/GalleryIcons.ttf"}, new List<int> {0});
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/UIWidgetsGallery.asmdef


{
"name": "UIWidgetsGallery",
"references": ["Unity.UIWidgets"],
"references": [
"Unity.UIWidgets"
],
"optionalUnityReferences": [],
"excludePlatforms": []
}
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

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


using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
/*
class CupertinoProgressIndicatorDemo : StatelessWidget {
public class CupertinoProgressIndicatorDemo : StatelessWidget {
public override
Widget build(BuildContext context) {
public CupertinoProgressIndicatorDemo(){}
public override Widget build(BuildContext context) {
middle: new Text("Activity Indicator"),
trailing: new CupertinoDemoDocumentationButton(routeName)
),
middle: new Text("Activity Indicator")
),
child: new Center(
child: new CupertinoActivityIndicator()
)

*/
}

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


using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoAlertDemo : StatefulWidget {
public static string routeName = "/cupertino/alert";
public class CupertinoAlertDemo : StatefulWidget {
public static string routeName = "/cupertino/alert";
public override State createState() {
return new _CupertinoAlertDemoState();
}
public override State createState()
{
return new _CupertinoAlertDemoState();
}
public class _CupertinoAlertDemoState : State<CupertinoAlertDemo> {
string lastSelectedValue;
void showDemoDialog(BuildContext context = null, Widget child = null) {
CupertinoRouteUtils.showCupertinoDialog<string>(
context: context,
builder: (BuildContext context1) => child
).then_((string value) =>{
if (value != null) {
setState(()=> { lastSelectedValue = value; });
}
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<string>(
context: context,
builder: (BuildContext context1) => child
).then_((string value) =>{
if (value != null) {
setState(()=> { lastSelectedValue = value; });
}
});
}
public override Widget build(BuildContext context)
{
List<Widget> createWidgets(BuildContext context1)
{
List<Widget> widgets = new List<Widget>();
widgets.Add(new CupertinoScrollbar(
child: new ListView(
// Add more padding to the normal safe area.
padding: EdgeInsets.symmetric(vertical: 24.0f, horizontal: 72.0f)
+ MediaQuery.of(context1).padding,
children: new List<Widget>
{
CupertinoButton.filled(
child: new Text("Alert"),
onPressed: () => _onAlertPress(context1)
),
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: () => _onAlertWithTitlePress(context1)
),
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: () => _onAlertWithButtonsPress(context1)
),
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: () =>
{
showDemoDialog(
context: context1,
child: new CupertinoDessertDialog()
);
}
),
new Padding(padding: EdgeInsets.all(8.0f)),
CupertinoButton.filled(
child: new Text("Action Sheet"),
padding: EdgeInsets.symmetric(vertical: 16.0f, horizontal: 36.0f),
onPressed: () => _onActionSheetPress(context1)
)
}
)
));
if (lastSelectedValue != null)
widgets.Add(new Positioned(
bottom: 32.0f,
child: new Text($"You selected: {lastSelectedValue}")
));
return widgets;
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; });
}
});
}
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Alerts"),
previousPageTitle: "Cupertino"
//,trailing: CupertinoDemoDocumentationButton(CupertinoAlertDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new Builder(
builder: (BuildContext context1) => {
return new Stack(
alignment: Alignment.center,
children: createWidgets(context1)
);
}
)
)
);
}
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"); }
)
)
);
}
)
}
)
};
void _onAlertPress(BuildContext context) {
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")
),
}
)
);
}
void _onAlertWithTitlePress(BuildContext context) {
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 " +
"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")
),
}
)
);
}
if (this.lastSelectedValue != null) {
stackChildren.Add(
new Positioned(
bottom: 32.0f,
child: new Text($"You selected: {this.lastSelectedValue}")
)
);
}
void _onAlertWithButtonsPress(BuildContext context) {
showDemoDialog(
context: context,
child: new CupertinoDessertDialog(
title: new Text("Select Favorite Dessert"),
content: new Text("Please select your favorite type of dessert from the " +
"list below. Your selection will be used to customize the suggested " +
"list of eateries in your area.")
)
);
}
return new Stack(
alignment: Alignment.center,
children: stackChildren
);
}
)
)
);
}
void _onActionSheetPress(BuildContext context) {
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")
)
)
);
}
class CupertinoDessertDialog : StatelessWidget {
public CupertinoDessertDialog(
Key key = null,
Widget title = null,
Widget content = null
) : base(key: key) {
this.title = title;
this.content = content;
}
public 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"); }
),
}
);
}
public readonly Widget title;
public readonly Widget content;
public override Widget build(BuildContext context) {
return new CupertinoAlertDialog(
title: title,
content: 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");
}
)
}
);
}
}

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


using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoButtonsDemo : StatefulWidget {
public class CupertinoButtonsDemo : StatefulWidget {
public static string routeName = "/cupertino/buttons";
public override State createState() {

class _CupertinoButtonDemoState : State<CupertinoButtonsDemo> {
int _pressedCount = 0;
public class _CupertinoButtonDemoState : State<CupertinoButtonsDemo> {
int _pressedCount = 0;
public override Widget build(BuildContext context)
{
string timeStr = _pressedCount == 1 ? "" : "s";
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Buttons"),
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
),
}
)
)
previousPageTitle: "Cupertino"
//trailing: 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(_pressedCount > 0
? $"Button pressed {_pressedCount} time{timeStr}"
: " "),
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: () => { setState(() => { _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: () => { setState(() => { _pressedCount += 1; }); }
),
new Padding(padding: EdgeInsets.all(12.0f)),
CupertinoButton.filled(
child: new Text("Disabled"),
onPressed: null
}
)
);
}
)
}
)
)
)
);
}
}

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


using System.Collections.Generic;
using RSG;
//using RSG;
//using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;

using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using Brightness = Unity.UIWidgets.ui.Brightness;
namespace UIWidgetsGallery.gallery {
class CupertinoNavigationDemoUtils {

return new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new CupertinoDemoDocumentationButton(CupertinoNavigationDemo.routeName),
//new CupertinoDemoDocumentationButton(CupertinoNavigationDemo.routeName),
new Padding(padding: EdgeInsets.only(left: 8.0f)),
new ExitButton(),
}

public class CupertinoNavigationDemo : StatelessWidget {
public CupertinoNavigationDemo() {
this.colorItems = new List<Color>();
colorItems = new List<Color>();
this.colorItems.Add(CupertinoNavigationDemoUtils.coolColors[
colorItems.Add(CupertinoNavigationDemoUtils.coolColors[
this.colorNameItems = new List<string>();
colorNameItems = new List<string>();
this.colorNameItems.Add(CupertinoNavigationDemoUtils.coolColorNames[
colorNameItems.Add(CupertinoNavigationDemoUtils.coolColorNames[
Random.Range(0, CupertinoNavigationDemoUtils.coolColorNames.Count)
]);
}

public readonly List<string> colorNameItems;
public override Widget build(BuildContext context) {
onWillPop: () => { return Promise<bool>.Resolved(true); },
//onWillPop: () => { return Promise<bool>.Resolved(true); },
//onWillPop: this.onWillPop,
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new CupertinoTabScaffold(

title: new Text("Profile")
)
}
),
tabBuilder: (BuildContext _context, int index) => {
D.assert(index >= 0 && index <= 2);

builder: (BuildContext _context1) => {
return new CupertinoDemoTab1(
colorItems: this.colorItems,
colorNameItems: this.colorNameItems
colorItems: colorItems,
colorNameItems: colorNameItems
);
},
defaultTitle: "Colors"

return new CupertinoButton(
padding: EdgeInsets.zero,
child: new Tooltip(
message: "Back",
child: new Text("Exit")
),
onPressed: () => { Navigator.of(context, rootNavigator: true).pop(); }
message: "Back",
child: new Text("Exit"),
excludeFromSemantics: true
),
onPressed: () => { Navigator.of(context, rootNavigator: true).pop<object>(); }
);
}
}

public override Widget build(BuildContext context) {
return new CupertinoPageScaffold(
backgroundColor: CupertinoColors.systemGroupedBackground,
child: new CustomScrollView(
slivers: new List<Widget> {
new CupertinoSliverNavigationBar(

return new Tab1RowItem(
index: index,
lastItem: index == CupertinoNavigationDemoUtils._kChildCount - 1,
color: this.colorItems[index],
colorName: this.colorNameItems[index]
color: colorItems[index],
colorName: colorNameItems[index]
);
},
childCount: CupertinoNavigationDemoUtils._kChildCount

public readonly Color color;
public readonly string colorName;
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
onTap: () => {
onTap: () =>
{
title: this.colorName,
title: colorName,
color: this.color,
colorName: this.colorName,
index: this.index
color: color,
colorName: colorName,
index: 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
child: new Container(
color: CupertinoDynamicColor.resolve(CupertinoColors.systemBackground, context),
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: 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(colorName),
new Padding(padding: EdgeInsets.only(top: 8.0f)),
new Text(
"Buy this cool color",
style: new TextStyle(
color: CupertinoDynamicColor.resolve(
CupertinoColors.secondaryLabel, context),
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
new CupertinoButton(
padding: EdgeInsets.zero,
child: new Icon(CupertinoIcons.plus_circled
),
onPressed: () => { }
onPressed: () => { }
)
}
new CupertinoButton(
padding: EdgeInsets.zero,
child: new Icon(CupertinoIcons.share
),
onPressed: () => { }
)
}
)
);
if (this.lastItem) {
);
if (lastItem) {
return row;
}

new Container(
height: 1.0f,
color: new Color(0xFFD9D9D9)
color: CupertinoDynamicColor.resolve(CupertinoColors.separator, context)
)
}
);

public override void initState() {
base.initState();
this.relatedColors = new List<Color>();
relatedColors = new List<Color>();
this.relatedColors.Add(Color.fromARGB(
relatedColors.Add(Color.fromARGB(
(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)
(widget.color.red + Random.Range(-50, 50)).clamp(0, 255),
(widget.color.green + Random.Range(-50, 50)).clamp(0, 255),
(widget.color.blue + Random.Range(-50, 50)).clamp(0, 255)
));
}
}

trailing: new ExitButton()
),
child: new SafeArea(
top: false,
bottom: false,
child: new ListView(
children: new List<Widget> {

height: 128.0f,
width: 128.0f,
decoration: new BoxDecoration(
color: this.widget.color,
color: widget.color,
borderRadius: BorderRadius.circular(24.0f)
)
),

crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new Text(this.widget.colorName,
new Text(widget.colorName,
$"Item number {this.widget.index}",
$"Item number {widget.index}",
color: new Color(0xFF8E8E93),
color: CupertinoDynamicColor.resolve(CupertinoColors.secondaryLabel, context),
fontSize: 16.0f,
fontWeight: FontWeight.w100
)

CupertinoButton.filled(
minSize: 30.0f,
padding: EdgeInsets.zero,
borderRadius: BorderRadius.circular(16.0f),
borderRadius: BorderRadius.circular(32.0f),
child: new Icon(CupertinoIcons.ellipsis),
onPressed: () => { }
)

child: new Container(
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(8.0f),
color: this.relatedColors[index]
color: relatedColors[index]
),
child: new Center(
child: new CupertinoButton(

class CupertinoDemoTab2 : StatelessWidget {
public override Widget build(BuildContext context) {
var listViewList = new List<Widget>();
listViewList.Add(new Tab2Header());
listViewList.Add(new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevatedlayer,
child: new Tab2Header()
));
listViewList.AddRange(CupertinoNavigationDemoUtils.buildTab2Conversation());
return new CupertinoPageScaffold(

}
class Tab2Header : StatelessWidget {
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
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
child: new SafeArea(
top: false,
bottom: false,
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: CupertinoDynamicColor.resolve(CupertinoColors.systemFill, context)
),
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: CupertinoDynamicColor.resolve(CupertinoColors.secondaryLabel, context),
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,
new Container(
decoration: new BoxDecoration(
color: CupertinoDynamicColor.resolve(CupertinoColors.quaternarySystemFill, context)
),
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(
size: 20.0f
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 FileImage(
file: "gallery/people/square/trevor.png"
)
),
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 FileImage(
"gallery/people/square/sandra.png"
)
),
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 {

public readonly Tab2ConversationBubbleColor color;
public override Widget build(BuildContext context) {
Color backgroundColor = null;
Color foregroundColor = null;
switch (color) {
case Tab2ConversationBubbleColor.gray:
backgroundColor = CupertinoDynamicColor.resolve(CupertinoColors.systemFill, context);
foregroundColor = CupertinoDynamicColor.resolve(CupertinoColors.label, context);
break;
case Tab2ConversationBubbleColor.blue:
backgroundColor = CupertinoTheme.of(context).primaryColor;
foregroundColor = CupertinoColors.white;
break;
}
color: this.color == Tab2ConversationBubbleColor.blue
? CupertinoColors.activeBlue
: CupertinoColors.lightBackgroundGray
color: backgroundColor
child: new Text(this.text,
child: new Text(
text,
color: this.color == Tab2ConversationBubbleColor.blue
? CupertinoColors.white
: CupertinoColors.black,
color: foregroundColor,
letterSpacing: -0.4f,
fontSize: 15.0f,
fontWeight: FontWeight.w400

decoration: new BoxDecoration(
shape: BoxShape.circle,
gradient: new LinearGradient(
begin: Alignment.topCenter, // FractionalOfset.topCenter,
end: Alignment.bottomCenter, // FractionalOfset.bottomCenter,
begin: FractionalOffset.topCenter,
end: FractionalOffset.bottomCenter,
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)
color,
Color.fromARGB(
color.alpha,
(color.red - 60).clamp(0, 255),
(color.green - 60).clamp(0, 255),
(color.blue - 60).clamp(0, 255)
)
}
)

child: new Text(this.text,
child: new Text(
text,
style: new TextStyle(
color: CupertinoColors.white,
fontSize: 13.0f,

public readonly string text;
public override Widget build(BuildContext context) {
bool isSelf = avatar == null;
if (this.avatar != null) {
children.Add(this.avatar);
if (avatar != null) {
children.Add(avatar);
bool isSelf = this.avatar == null;
new Tab2ConversationBubble(
text: this.text,
color: isSelf
? Tab2ConversationBubbleColor.blue
: Tab2ConversationBubbleColor.gray
new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.elevatedlayer,
child: new Tab2ConversationBubble(
text: text,
color: isSelf
? Tab2ConversationBubbleColor.blue
: Tab2ConversationBubbleColor.gray
)
)
);
return new SafeArea(
child: new Row(
mainAxisAlignment: isSelf ? MainAxisAlignment.end : MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: isSelf ? CrossAxisAlignment.center : CrossAxisAlignment.end,
children: children
return new Row(
mainAxisAlignment: isSelf ? MainAxisAlignment.end : MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: isSelf ? CrossAxisAlignment.center : CrossAxisAlignment.end,
children: children
);
}
}

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)
),
}
)
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)
),
}
}
)
)
}
)
)
);

new Padding(padding: EdgeInsets.only(top: 18.0f)),
CupertinoButton.filled(
child: new Text("Sign in"),
onPressed: () => { Navigator.pop(context); }
onPressed: () => { Navigator.pop<object>(context); }
),
}
)

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


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.foundation;
using UnityEngine;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using Brightness = Unity.UIWidgets.ui.Brightness;
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", "Zaffre",
};
class CupertinoPickerDemo : StatefulWidget {
public const string routeName = "/cupertino/picker";
public class CupertinoPickerDemo : StatefulWidget {
public const string routeName = "/cupertino/picker";
public override State createState() {
return new _CupertinoPickerDemoState();
}
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
)
)
)
);
public class _CupertinoPickerDemoState : State<CupertinoPickerDemo> {
int _selectedColorIndex = 0;
TimeSpan timer = new TimeSpan();
DateTime date = DateTime.Now;
DateTime time = DateTime.Now;
DateTime dateTime = DateTime.Now;
Widget _buildColorPicker(BuildContext context) {
FixedExtentScrollController scrollController = new FixedExtentScrollController(initialItem: _selectedColorIndex);
List<Widget> widgets = new List<Widget>();
for (int i = 0; i < CupertinoPickerDemoUtils.coolColorNames.Count; i++)
{
widgets.Add(new Center(
child: new Text(CupertinoPickerDemoUtils.coolColorNames[i])
));
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
)
)
)
return new GestureDetector(
onTap: () => {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoPicker(
scrollController: scrollController,
itemExtent: CupertinoPickerDemoUtils._kPickerItemHeight,
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
onSelectedItemChanged: (int index)=> {
setState(() => _selectedColorIndex = index);
},
children: widgets
)
);
}
}
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;
},
child: new _Menu(
children: new List<Widget>{
new Text("Favorite Color"),
new Text(
CupertinoPickerDemoUtils.coolColorNames[_selectedColorIndex],
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
)
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 _buildCountdownTimerPicker(BuildContext context) {
return new GestureDetector(
onTap: () =>
{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>
{
return new _BottomPicker(
child: new CupertinoTimerPicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
initialTimerDuration: timer,
onTimerDurationChanged: (TimeSpan newTimer) =>{
setState(() => timer = newTimer);
)
)
);
}
}
},
child: new _Menu(
children: new List<Widget>{
new Text("Countdown Timer"),
new Text(
$"{timer.Hours}:" +
$"{(timer.Minutes % 60).ToString("00")}:" +
$"{(timer.Seconds % 60).ToString("00")}",
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
);
}
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 _buildDatePicker(BuildContext context)
{
return new GestureDetector(
onTap: () =>
{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>
{
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.date,
initialDateTime: date,
onDateTimeChanged: (DateTime newDateTime) =>{
setState(() => date = newDateTime);
)
)
);
}
}
},
child: new _Menu(
children: new List<Widget>{
new Text("Date"),
new Text(
date.ToString("MMMM dd, yyyy"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
);
}
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 _buildTimePicker(BuildContext context) {
return new GestureDetector(
onTap: () =>{
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.time,
initialDateTime: time,
onDateTimeChanged: (newDateTime) => {
setState(() => time = newDateTime);
)
)
);
}
}
},
child:new _Menu(
children: new List<Widget>{
new Text("Time"),
new Text(
time.ToString("h:mm tt"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
);
}
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)
)
Widget _buildDateAndTimePicker(BuildContext context) {
return new GestureDetector(
onTap: ()=> {
CupertinoRouteUtils.showCupertinoModalPopup(
context: context,
semanticsDismissible: true,
builder: (BuildContext context1) =>{
return new _BottomPicker(
child: new CupertinoDatePicker(
backgroundColor: CupertinoColors.systemBackground.resolveFrom(context1),
mode: CupertinoDatePickerMode.dateAndTime,
initialDateTime: dateTime,
onDateTimeChanged: (newDateTime) => {
setState(() => dateTime = newDateTime);
)
)
);
}
}
},
child: new _Menu(
children:new List<Widget>{
new Text("Date and Time"),
new Text(
dateTime.ToString("MMMM dd, yyyy") + " " + dateTime.ToString("HH:mm tt"),
style: new TextStyle(color: CupertinoDynamicColor.resolve(CupertinoColors.inactiveGray, context))
),
}
)
);
}
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)
}
)
)
)
)
);
}
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: CupertinoDemoDocumentationButton(CupertinoPickerDemo.routeName)
),
child: new DefaultTextStyle(
style: CupertinoTheme.of(context).textTheme.textStyle,
child: new ListView(
children: new List<Widget>{
new Padding(padding: EdgeInsets.only(top: 32.0f)),
_buildColorPicker(context),
_buildCountdownTimerPicker(context),
_buildDatePicker(context),
_buildTimePicker(context),
_buildDateAndTimePicker(context),
}
)
)
);
}
}
public class _BottomPicker : StatelessWidget {
public _BottomPicker(
Key key = null,
Widget child = null
) : base(key: key){
D.assert(child != null);
this.child = child;
}
public readonly Widget child;
public override Widget build(BuildContext context)
{
return new Container(
height: CupertinoPickerDemoUtils._kPickerSheetHeight,
padding: EdgeInsets.only(top: 6.0f),
color: CupertinoColors.label.resolveFrom(context).darkColor,
child: new DefaultTextStyle(
style: new TextStyle(
color: CupertinoColors.label.resolveFrom(context),
fontSize: 22.0f
),
child: new GestureDetector(
onTap: () =>{ },
child: new SafeArea(
top: false,
child: child
)
)
)
);
}
}
public class _Menu : StatelessWidget {
public _Menu(
Key key = null,
List<Widget> children = null
) :base(key: key) {
D.assert(children != null);
this.children = children;
}
public readonly List<Widget> children;
public override Widget build(BuildContext context) {
return new Container(
decoration: new BoxDecoration(
border: new Border(
top: new BorderSide(color: CupertinoColors.inactiveGray, width: 0),
bottom: new BorderSide(color: CupertinoColors.inactiveGray, width: 0)
)
),
height: 44,
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: children
)
)
);
}
}
}

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


using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoSliderDemo : StatefulWidget {
public class CupertinoSliderDemo : StatefulWidget {
public static string routeName = "/cupertino/slider";
public override State createState() {

class _CupertinoSliderDemoState : State<CupertinoSliderDemo> {
float _value = 25.0f;
float _discreteValue = 20.0f;
public 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}"),
}
),
}
)
)
)
)
);
}
public override Widget build(BuildContext context)
{
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Sliders"),
previousPageTitle: "Cupertino"
),
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: _value,
min: 0.0f,
max: 100.0f,
onChanged: (float value) => { setState(() => { _value = value; }); }
),
new Text($"Cupertino Continuous: {_value:F1}"),
}
),
new Column(
mainAxisSize: MainAxisSize.min,
children: new List< Widget >{
new CupertinoSlider(
value: _discreteValue,
min: 0.0f,
max: 100.0f,
divisions: 5,
onChanged: (float value) => { setState(() => { _discreteValue = value; }); }
),
new Text($"Cupertino Discrete: {_discreteValue}")
}
)
}
)
)
)
)
);
}
}

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


using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
class CupertinoSwitchDemo : StatefulWidget {
public class CupertinoSwitchDemo : StatefulWidget {
public static string routeName = "/cupertino/switch";
public override State createState() => new _CupertinoSwitchDemoState();

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"
),
}
)
}
)
)
bool _switchValue = false;
public override Widget build(BuildContext context)
{
string switchStr = _switchValue ? "On" : "Off";
return new CupertinoPageScaffold(
navigationBar: new CupertinoNavigationBar(
middle: new Text("Switch"),
previousPageTitle: "Cupertino"
// trailing: 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: _switchValue,
onChanged: (bool value)=> {
setState(()=> {
_switchValue = value;
});
}
),
new Text(
$"Enabled - {switchStr}"
)
}
),
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"
),
}
}
);
}
)
)
)
);
}
}

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


}
class _CupertinoTextFieldDemoState : State<CupertinoTextFieldDemo> {
TextEditingController _chatTextController;
TextEditingController _locationTextController;
TextEditingController _chatTextController;
TextEditingController _locationTextController;
public override void initState() {
base.initState();
this._chatTextController = new TextEditingController();
this._locationTextController = new TextEditingController(text: "Montreal, Canada");
}
public override void initState() {
base.initState();
_chatTextController = new TextEditingController();
_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 _buildChatTextField() {
return new CupertinoTextField(
controller: _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: ()=> setState(()=> _chatTextController.clear())
)
),
autofocus: true,
suffixMode: OverlayVisibilityMode.editing,
onSubmitted: (string text)=> setState(()=> _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 _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 _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 _buildLocationField() {
return new CupertinoTextField(
controller: _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 _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))
)
);
}
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()
),
}
)
public override Widget build(BuildContext context) {
return new DefaultTextStyle(
style: new TextStyle(
fontFamily: ".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 CupertinoScrollbar(
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>{
_buildNameField(),
_buildEmailField(),
_buildLocationField(),
_buildPinField(),
_buildTagsField()
}
)
);
}
),
new Padding(
padding: EdgeInsets.symmetric(vertical: 32.0f, horizontal: 16.0f),
child: _buildChatTextField()
)
}
)
)
)
);
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material.meta


fileFormatVersion: 2
guid: edc3bae86553f44c2b7e7fddbf6cb497
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 27e2b642479d4616ad980ef32f76e152
timeCreated: 1612406310

404
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/backdrop_demo.cs


using System;
using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;

using Image = Unity.UIWidgets.widgets.Image;
using Material = Unity.UIWidgets.material.Material;
namespace UIWidgetsGallery.gallery {
class BackdropDemoConstants {
public static readonly List<Category> allCategories = new List<Category> {
namespace UIWidgetsGallery.demo.material
{
public class Category
{
public Category(string title = null, List<string> assets = null)
{
this.title = title;
this.assets = assets;
}
public readonly string title;
public readonly List<string> assets;
public override string ToString()
{
return $"{this.GetType()}({this.title})";
}
public static readonly List<Category> allCategories = new List<Category>
{
assets: new List<string> {
"products/belt",
"products/earrings",
"products/backpack",
"products/hat",
"products/scarf",
"products/sunnies"
assets: new List<string>
{
"gallery/products/belt.png",
"gallery/products/earrings.png",
"gallery/products/backpack.png",
"gallery/products/hat.png",
"gallery/products/scarf.png",
"gallery/products/sunnies.png"
assets: new List<string> {
"products/backpack",
"products/cup",
"products/napkins",
"products/top"
assets: new List<string>
{
"gallery/products/backpack.png",
"gallery/products/cup.png",
"gallery/products/napkins.png",
"gallery/products/top.png"
assets: new List<string> {
"products/jacket",
"products/jumper",
"products/scarf",
"products/sweater",
"products/sweats"
assets: new List<string>
{
"gallery/products/jacket.png",
"gallery/products/jumper.png",
"gallery/products/scarf.png",
"gallery/products/sweater.png",
"gallery/products/sweats.png"
assets: new List<string> {
"products/cup",
"products/napkins",
"products/planters",
"products/table",
"products/teaset"
assets: new List<string>
{
"gallery/products/cup.png",
"gallery/products/napkins.png",
"gallery/products/planters.png",
"gallery/products/table.png",
"gallery/products/teaset.png"
assets: new List<string> {
"products/jumper",
"products/shirt",
"products/sweater",
"products/top"
assets: new List<string>
{
"gallery/products/jumper.png",
"gallery/products/shirt.png",
"gallery/products/sweater.png",
"gallery/products/top.png"
assets: new List<string> {
"products/backpack",
"products/belt",
"products/cup",
"products/dress",
"products/earrings",
"products/flatwear",
"products/hat",
"products/jacket",
"products/jumper",
"products/napkins",
"products/planters",
"products/scarf",
"products/shirt",
"products/sunnies",
"products/sweater",
"products/sweats",
"products/table",
"products/teaset",
"products/top"
assets: new List<string>
{
"gallery/products/backpack.png",
"gallery/products/belt.png",
"gallery/products/cup.png",
"gallery/products/dress.png",
"gallery/products/earrings.png",
"gallery/products/flatwear.png",
"gallery/products/hat.png",
"gallery/products/jacket.png",
"gallery/products/jumper.png",
"gallery/products/napkins.png",
"gallery/products/planters.png",
"gallery/products/scarf.png",
"gallery/products/shirt.png",
"gallery/products/sunnies.png",
"gallery/products/sweater.png",
"gallery/products/sweats.png",
"gallery/products/table.png",
"gallery/products/teaset.png",
"gallery/products/top.png"
),
)
public class Category {
public Category(string title = null, List<string> assets = null) {
this.title = title;
this.assets = assets;
}
public readonly string title;
public readonly List<string> assets;
public override string ToString() {
return $"{this.GetType()}('{this.title}')";
}
}
public class CategoryView : StatelessWidget {
public CategoryView(Key key = null, Category category = null) : base(key: key) {
public class CategoryView : StatelessWidget
{
public CategoryView(Key key = null, Category category = null) : base(key: key)
{
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
return new ListView(
key: new PageStorageKey<Category>(this.category),
padding: EdgeInsets.symmetric(
vertical: 16.0f,
horizontal: 64.0f
),
children: this.category.assets.Select<string, Widget>((string asset) => {
return new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
new Card(
child: new Container(
width: 144.0f,
alignment: Alignment.center,
child: new Column(
children: new List<Widget> {
Image.asset(
asset,
fit: BoxFit.contain
),
new Container(
padding: EdgeInsets.only(bottom: 16.0f),
alignment: Alignment.center,
child: new Text(
return new Scrollbar(
child: new ListView(
key: new PageStorageKey<Category>(this.category),
padding: EdgeInsets.symmetric(
vertical: 16.0f,
horizontal: 64.0f
),
children: this.category.assets.Select<string, Widget>((string asset) =>
{
return new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget>
{
new Card(
child: new Container(
width: 144.0f,
alignment: Alignment.center,
child: new Column(
children: new List<Widget>
{
Image.file(
style: theme.textTheme.caption
fit: BoxFit.contain
),
new Container(
padding: EdgeInsets.only(bottom: 16.0f),
alignment: AlignmentDirectional.center,
child: new Text(
asset,
style: theme.textTheme.caption
)
),
}
}
)
)
),
new SizedBox(height: 24.0f)
}
);
}).ToList()
),
new SizedBox(height: 24.0f)
}
);
}).ToList()
)
public class BackdropPanel : StatelessWidget {
internal class BackdropPanel : StatelessWidget
{
public BackdropPanel(
Key key = null,
VoidCallback onTap = null,

Widget child = null
) : base(key: key) {
) : base(key: key)
{
this.onTap = onTap;
this.onVerticalDragUpdate = onVerticalDragUpdate;
this.onVerticalDragEnd = onVerticalDragEnd;

public readonly Widget title;
public readonly Widget child;
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
ThemeData theme = Theme.of(context);
return new Material(
elevation: 2.0f,

),
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
children: new List<Widget>
{
onTap: this.onTap != null ? (GestureTapCallback) (() => { this.onTap(); }) : null,
onTap: () => { this.onTap?.Invoke(); },
padding: EdgeInsets.only(left: 16.0f),
alignment: Alignment.centerLeft,
padding: EdgeInsetsDirectional.only(start: 16.0f),
alignment: AlignmentDirectional.centerStart,
style: theme.textTheme.subhead,
style: theme.textTheme.subtitle1,
child: new Tooltip(
message: "Tap to dismiss",
child: this.title

}
}
public class BackdropTitle : AnimatedWidget {
internal class BackdropTitle : AnimatedWidget
{
Listenable listenable = null
) : base(key: key, listenable: listenable) {
Animation<float> listenable = null
) : base(key: key, listenable: listenable)
{
protected override Widget build(BuildContext context) {
Animation<float> animation = (Animation<float>) this.listenable;
protected override Widget build(BuildContext context)
{
Animation<float> animation = this.listenable as Animation<float>;
style: Theme.of(context).primaryTextTheme.title,
style: Theme.of(context).primaryTextTheme.headline6,
children: new List<Widget> {
children: new List<Widget>
{
new Opacity(
opacity: new CurvedAnimation(
parent: new ReverseAnimation(animation),

curve: new Interval(0.5f, 1.0f)
).value,
child: new Text("Asset Viewer")
),
)
}
)
);

public class BackdropDemo : StatefulWidget {
public const string routeName = "/material/backdrop";
internal class BackdropDemo : StatefulWidget
{
public static readonly string routeName = "/material/backdrop";
public override State createState() {
public override State createState()
{
class _BackdropDemoState : SingleTickerProviderStateMixin<BackdropDemo> {
GlobalKey _backdropKey = GlobalKey.key(debugLabel: "Backdrop");
AnimationController _controller;
Category _category = BackdropDemoConstants.allCategories[0];
internal class _BackdropDemoState : SingleTickerProviderStateMixin<BackdropDemo>
{
private GlobalKey _backdropKey = GlobalKey.key(debugLabel: "Backdrop");
private AnimationController _controller;
private Category _category = Category.allCategories[0];
public override void initState() {
public override void initState()
{
base.initState();
this._controller = new AnimationController(
duration: new TimeSpan(0, 0, 0, 0, 300),

}
public override void dispose() {
public override void dispose()
{
void _changeCategory(Category category) {
this.setState(() => {
private void _changeCategory(Category category)
{
this.setState(() =>
{
bool _backdropPanelVisible {
get {
private bool _backdropPanelVisible
{
get
{
void _toggleBackdropPanelVisibility() {
private void _toggleBackdropPanelVisibility()
{
float? _backdropHeight {
get {
RenderBox renderBox = (RenderBox) this._backdropKey.currentContext.findRenderObject();
private float _backdropHeight
{
get
{
RenderBox renderBox = this._backdropKey.currentContext.findRenderObject() as RenderBox;
// By design: the panel can only be opened with a swipe. To close the panel
// the user must either tap its heading or the backdrop's menu icon.
void _handleDragUpdate(DragUpdateDetails details) {
if (this._controller.isAnimating || this._controller.status == AnimationStatus.completed) {
private void _handleDragUpdate(DragUpdateDetails details)
{
if (this._controller.isAnimating || this._controller.status == AnimationStatus.completed)
}
this._controller.setValue(this._controller.value -
details.primaryDelta / (this._backdropHeight ?? details.primaryDelta) ?? 0.0f);
this._controller.setValue(this._controller.value - details.primaryDelta.Value / (this._backdropHeight));
void _handleDragEnd(DragEndDetails details) {
if (this._controller.isAnimating || this._controller.status == AnimationStatus.completed) {
private void _handleDragEnd(DragEndDetails details)
{
if (this._controller.isAnimating || this._controller.status == AnimationStatus.completed)
}
float? flingVelocity = details.velocity.pixelsPerSecond.dy / this._backdropHeight;
if (flingVelocity < 0.0f) {
this._controller.fling(velocity: Mathf.Max(2.0f, -flingVelocity ?? 0.0f));
}
else if (flingVelocity > 0.0f) {
this._controller.fling(velocity: Mathf.Min(-2.0f, -flingVelocity ?? 0.0f));
}
else {
this._controller.fling(velocity: this._controller.value < 0.5f ? -2.0f : 2.0f);
}
float flingVelocity = details.velocity.pixelsPerSecond.dy / this._backdropHeight;
if (flingVelocity < 0.0f)
this._controller.fling(velocity: Mathf.Max(2.0f, -flingVelocity));
else if (flingVelocity > 0.0f)
this._controller.fling(velocity: Mathf.Min(-2.0f, -flingVelocity));
else
this._controller.fling(velocity: this._controller.value < 0.5 ? -2.0f : 2.0f);
Widget _buildStack(BuildContext context, BoxConstraints constraints) {
const float panelTitleHeight = 48.0f;
// Stacks a BackdropPanel, which displays the selected category, on top
// of the backdrop. The categories are displayed with ListTiles. Just one
// can be selected at a time. This is a LayoutWidgetBuild function because
// we need to know how big the BackdropPanel will be to set up its
// animation.
private Widget _buildStack(BuildContext context, BoxConstraints constraints)
{
float panelTitleHeight = 48.0f;
Size panelSize = constraints.biggest;
float panelTop = panelSize.height - panelTitleHeight;

);
ThemeData theme = Theme.of(context);
List<Widget> backdropItems = BackdropDemoConstants.allCategories.Select<Category, Widget>(
(Category category) => {
bool selected = category == this._category;
return new Material(
shape: new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0f))
),
color: selected
? Colors.white.withOpacity(0.25f)
: Colors.transparent,
child: new ListTile(
title: new Text(category.title),
selected: selected,
onTap: () => { this._changeCategory(category); }
)
);
}).ToList();
List<Widget> backdropItems = Category.allCategories.Select<Category, Widget>((Category category) =>
{
bool selected = category == this._category;
return new Material(
shape: new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0f))
),
color: selected
? Colors.white.withOpacity(0.25f)
: Colors.transparent,
child: new ListTile(
title: new Text(category.title),
selected: selected,
onTap: () => { this._changeCategory(category); }
)
);
}).ToList();
children: new List<Widget> {
children: new List<Widget>
{
textColor: theme.primaryTextTheme.title.color.withOpacity(0.6f),
selectedColor: theme.primaryTextTheme.title.color,
textColor: theme.primaryTextTheme.headline6.color.withOpacity(0.6f),
selectedColor: theme.primaryTextTheme.headline6.color,
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0f),
child: new Column(

title: new Text(this._category.title),
child: new CategoryView(category: this._category)
)
),
)
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
return new Scaffold(
appBar: new AppBar(
elevation: 0.0f,

actions: new List<Widget> {
actions: new List<Widget>
{
new IconButton(
onPressed: this._toggleBackdropPanelVisibility,
icon: new AnimatedIcon(

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/backdrop_demo.cs.meta


fileFormatVersion: 2
guid: 98bee0a7e51f4f2d9c8670daf147a15f
timeCreated: 1553145970
guid: 0d229d2babb945ec933ff8ce2c53a9f4
timeCreated: 1612406341

513
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_app_bar_demo.cs


using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

using Material = Unity.UIWidgets.material.Material;
using Rect = Unity.UIWidgets.ui.Rect;
namespace UIWidgetsGallery.gallery {
public class BottomAppBarDemo : StatefulWidget {
public const string routeName = "/material/bottom_app_bar";
namespace UIWidgetsGallery.demo.material
{
internal class BottomAppBarDemo : StatefulWidget
{
public static readonly string routeName = "/material/bottom_app_bar";
public override State createState() {
public override State createState()
{
internal class _BottomAppBarDemoState : State<BottomAppBarDemo>
{
private static readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
class _BottomAppBarDemoState : State<BottomAppBarDemo> {
static readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
// FAB shape
static readonly _ChoiceValue<Widget> kNoFab = new _ChoiceValue<Widget>(
private static readonly _ChoiceValue<Widget> kNoFab = new _ChoiceValue<Widget>(
static readonly _ChoiceValue<Widget> kCircularFab = new _ChoiceValue<Widget>(
private static readonly _ChoiceValue<Widget> kCircularFab = new _ChoiceValue<Widget>(
title: "Circular",
label: "circular floating action button",
value: new FloatingActionButton(

)
);
static readonly _ChoiceValue<Widget> kDiamondFab = new _ChoiceValue<Widget>(
private static readonly _ChoiceValue<Widget> kDiamondFab = new _ChoiceValue<Widget>(
title: "Diamond",
label: "diamond shape floating action button",
value: new _DiamondFab(

);
static readonly _ChoiceValue<bool> kShowNotchTrue = new _ChoiceValue<bool>(
// Notch
private static readonly _ChoiceValue<bool> kShowNotchTrue = new _ChoiceValue<bool>(
static readonly _ChoiceValue<bool> kShowNotchFalse = new _ChoiceValue<bool>(
private static readonly _ChoiceValue<bool> kShowNotchFalse = new _ChoiceValue<bool>(
// FAB Position
static readonly _ChoiceValue<FloatingActionButtonLocation> kFabEndDocked =
private static readonly _ChoiceValue<FloatingActionButtonLocation> kFabEndDocked =
new _ChoiceValue<FloatingActionButtonLocation>(
title: "Attached - End",
label: "floating action button is docked at the end of the bottom app bar",

static readonly _ChoiceValue<FloatingActionButtonLocation> kFabCenterDocked =
private static readonly _ChoiceValue<FloatingActionButtonLocation> kFabCenterDocked =
new _ChoiceValue<FloatingActionButtonLocation>(
title: "Attached - Center",
label: "floating action button is docked at the center of the bottom app bar",

static readonly _ChoiceValue<FloatingActionButtonLocation> kFabEndFloat =
private static readonly _ChoiceValue<FloatingActionButtonLocation> kFabEndFloat =
new _ChoiceValue<FloatingActionButtonLocation>(
title: "Free - End",
label: "floating action button floats above the end of the bottom app bar",

static readonly _ChoiceValue<FloatingActionButtonLocation> kFabCenterFloat =
private static readonly _ChoiceValue<FloatingActionButtonLocation> kFabCenterFloat =
new _ChoiceValue<FloatingActionButtonLocation>(
title: "Free - Center",
label: "floating action button is floats above the center of the bottom app bar",

static void _showSnackbar() {
const string text =
"When the Scaffold's floating action button location changes, " +
"the floating action button animates to its new position." +
"The BottomAppBar adapts its shape appropriately.";
_scaffoldKey.currentState.showSnackBar(
new SnackBar(content: new Text(text))
);
}
static readonly List<_NamedColor> kBabColors = new List<_NamedColor> {
// App bar color
private static readonly List<_NamedColor> kBabColors = new List<_NamedColor>
{
new _NamedColor(null, "Clear"),
new _NamedColor(new Color(0xFFFFC100), "Orange"),
new _NamedColor(new Color(0xFF91FAFF), "Light Blue"),

};
_ChoiceValue<Widget> _fabShape = kCircularFab;
_ChoiceValue<bool> _showNotch = kShowNotchTrue;
_ChoiceValue<FloatingActionButtonLocation> _fabLocation = kFabEndDocked;
Color _babColor = kBabColors.First().color;
private Color _babColor = kBabColors.First().color;
private _ChoiceValue<FloatingActionButtonLocation> _fabLocation = kFabEndDocked;
private _ChoiceValue<Widget> _fabShape = kCircularFab;
private _ChoiceValue<bool> _showNotch = kShowNotchTrue;
private static void _showSnackbar()
{
var text =
"When the Scaffold\"s floating action button location changes, " +
"the floating action button animates to its new position. " +
"The BottomAppBar adapts its shape appropriately.";
void _onShowNotchChanged(_ChoiceValue<bool> value) {
this.setState(() => { this._showNotch = value; });
_scaffoldKey.currentState.showSnackBar(
new SnackBar(content: new Text(text))
);
void _onFabShapeChanged(_ChoiceValue<Widget> value) {
this.setState(() => { this._fabShape = value; });
private void _onShowNotchChanged(_ChoiceValue<bool> value)
{
setState(() => { _showNotch = value; });
void _onFabLocationChanged(_ChoiceValue<FloatingActionButtonLocation> value) {
this.setState(() => { this._fabLocation = value; });
private void _onFabShapeChanged(_ChoiceValue<Widget> value)
{
setState(() => { _fabShape = value; });
void _onBabColorChanged(Color value) {
this.setState(() => { this._babColor = value; });
private void _onFabLocationChanged(_ChoiceValue<FloatingActionButtonLocation> value)
{
setState(() => { _fabLocation = value; });
public override Widget build(BuildContext context) {
private void _onBabColorChanged(Color value)
{
setState(() => { _babColor = value; });
}
public override Widget build(BuildContext context)
{
key: _scaffoldKey,
appBar: new AppBar(
_scaffoldKey,
new AppBar(
actions: new List<Widget> {
actions: new List<Widget>
{
onPressed: () => {
this.setState(() => {
this._fabShape = this._fabShape == kCircularFab ? kDiamondFab : kCircularFab;
});
onPressed: () =>
{
setState(() => { _fabShape = _fabShape == kCircularFab ? kDiamondFab : kCircularFab; });
body: new ListView(
padding: EdgeInsets.only(bottom: 88.0f),
children: new List<Widget> {
new _AppBarDemoHeading("FAB Shape"),
new Scrollbar(
child: new ListView(
padding: EdgeInsets.only(bottom: 88.0f),
children: new List<Widget>
{
new _Heading("FAB Shape"),
new _RadioItem<Widget>(kCircularFab, this._fabShape, this._onFabShapeChanged),
new _RadioItem<Widget>(kDiamondFab, this._fabShape, this._onFabShapeChanged),
new _RadioItem<Widget>(kNoFab, this._fabShape, this._onFabShapeChanged),
new _RadioItem<Widget>(kCircularFab, _fabShape, _onFabShapeChanged),
new _RadioItem<Widget>(kDiamondFab, _fabShape, _onFabShapeChanged),
new _RadioItem<Widget>(kNoFab, _fabShape, _onFabShapeChanged),
new Divider(),
new _AppBarDemoHeading("Notch"),
new Divider(),
new _Heading("Notch"),
new _RadioItem<bool>(kShowNotchTrue, this._showNotch, this._onShowNotchChanged),
new _RadioItem<bool>(kShowNotchFalse, this._showNotch, this._onShowNotchChanged),
new _RadioItem<bool>(kShowNotchTrue, _showNotch, _onShowNotchChanged),
new _RadioItem<bool>(kShowNotchFalse, _showNotch, _onShowNotchChanged),
new Divider(),
new _AppBarDemoHeading("FAB Position"),
new Divider(),
new _Heading("FAB Position"),
new _RadioItem<FloatingActionButtonLocation>(kFabEndDocked, this._fabLocation,
this._onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabCenterDocked, this._fabLocation,
this._onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabEndFloat, this._fabLocation,
this._onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabCenterFloat, this._fabLocation,
this._onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabEndDocked, _fabLocation,
_onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabCenterDocked, _fabLocation,
_onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabEndFloat, _fabLocation,
_onFabLocationChanged),
new _RadioItem<FloatingActionButtonLocation>(kFabCenterFloat, _fabLocation,
_onFabLocationChanged),
new Divider(),
new _AppBarDemoHeading("App bar color"),
new Divider(),
new _Heading("App bar color"),
new _ColorsItem(kBabColors, this._babColor, this._onBabColorChanged)
}
new _ColorsItem(kBabColors, _babColor, _onBabColorChanged)
}
)
floatingActionButton:
this._fabShape.value,
floatingActionButtonLocation:
this._fabLocation.value,
_fabShape.value,
_fabLocation.value,
color: this._babColor,
fabLocation: this._fabLocation.value,
shape: this._selectNotch()
_babColor,
_fabLocation.value,
_selectNotch()
NotchedShape _selectNotch() {
if (!this._showNotch.value) {
private NotchedShape _selectNotch()
{
if (!_showNotch.value)
}
if (this._fabShape == kCircularFab) {
if (_fabShape == kCircularFab)
}
if (this._fabShape == kDiamondFab) {
if (_fabShape == kDiamondFab)
}
class _ChoiceValue<T> {
public _ChoiceValue(T value, string title, string label) {
internal class _ChoiceValue<T>
{
public readonly string label; // For the Semantics widget that contains title
public readonly string title;
public readonly T value;
public _ChoiceValue(T value, string title, string label)
{
public readonly T value;
public readonly string title;
string label; // For the Semantics widget that contains title
public override string ToString() {
return $"{this.GetType()}('{this.title}')";
public override string ToString()
{
return $"{GetType()}(\"{title}\")";
class _RadioItem<T> : StatelessWidget {
public _RadioItem(_ChoiceValue<T> value, _ChoiceValue<T> groupValue, ValueChanged<_ChoiceValue<T>> onChanged) {
internal class _RadioItem<T> : StatelessWidget
{
public readonly _ChoiceValue<T> groupValue;
public readonly ValueChanged<_ChoiceValue<T>> onChanged;
public readonly _ChoiceValue<T> value;
public _RadioItem(_ChoiceValue<T> value, _ChoiceValue<T> groupValue, ValueChanged<_ChoiceValue<T>> onChanged)
{
_ChoiceValue<T> value;
_ChoiceValue<T> groupValue;
ValueChanged<_ChoiceValue<T>> onChanged;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
public override Widget build(BuildContext context)
{
var theme = Theme.of(context);
padding: EdgeInsets.only(left: 16.0f),
alignment: Alignment.centerLeft,
padding: EdgeInsetsDirectional.only(16.0f),
alignment: AlignmentDirectional.centerStart,
children: new List<Widget> {
children: new List<Widget>
{
value: this.value,
groupValue: this.groupValue,
onChanged: this.onChanged
value: value,
groupValue: groupValue,
onChanged: onChanged
onTap: () => { this.onChanged(this.value); },
child: new Text(this.value.title,
style: theme.textTheme.subhead
onTap: () => { onChanged(value); },
child: new Text(value.title,
style: theme.textTheme.subtitle1
)
)
)

}
}
class _NamedColor {
public _NamedColor(Color color, string name) {
internal class _NamedColor
{
public readonly Color color;
public readonly string name;
public _NamedColor(Color color, string name)
{
public readonly Color color;
public readonly string name;
class _ColorsItem : StatelessWidget {
public _ColorsItem(List<_NamedColor> colors, Color selectedColor, ValueChanged<Color> onChanged) {
internal class _ColorsItem : StatelessWidget
{
public readonly List<_NamedColor> colors;
public readonly ValueChanged<Color> onChanged;
public readonly Color selectedColor;
public _ColorsItem(List<_NamedColor> colors, Color selectedColor, ValueChanged<Color> onChanged)
{
List<_NamedColor> colors;
public readonly Color selectedColor;
ValueChanged<Color> onChanged;
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
children: this.colors.Select<_NamedColor, Widget>((_NamedColor namedColor) => {
children: colors.Select<_NamedColor, Widget>(namedColor =>
{
onPressed: () => { this.onChanged(namedColor.color); },
onPressed: () => { onChanged(namedColor.color); },
width: 32.0f,
height: 32.0f
32.0f,
32.0f
side: new BorderSide(
color: namedColor.color == this.selectedColor ? Colors.black : new Color(0xFFD5D7DA),
width: 2.0f
new BorderSide(
namedColor.color == selectedColor ? Colors.black : new Color(0xFFD5D7DA),
2.0f
),
child: new Container(
)
);
}).ToList()

class _AppBarDemoHeading : StatelessWidget {
public _AppBarDemoHeading(string text) {
internal class _Heading : StatelessWidget
{
public readonly string text;
public _Heading(string text)
{
public readonly string text;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
public override Widget build(BuildContext context)
{
var theme = Theme.of(context);
padding: EdgeInsets.only(left: 56.0f),
alignment: Alignment.centerLeft,
child: new Text(this.text,
style: theme.textTheme.body1.copyWith(
padding: EdgeInsetsDirectional.only(56.0f),
alignment: AlignmentDirectional.centerStart,
child: new Text(text,
style: theme.textTheme.bodyText2.copyWith(
color: theme.primaryColor
)
)

class _DemoBottomAppBar : StatelessWidget {
internal class _DemoBottomAppBar : StatelessWidget
{
private static readonly List<FloatingActionButtonLocation> kCenterLocations =
new List<FloatingActionButtonLocation>
{
FloatingActionButtonLocation.centerDocked,
FloatingActionButtonLocation.centerFloat
};
public readonly Color color;
public readonly FloatingActionButtonLocation fabLocation;
public readonly NotchedShape shape;
) {
)
{
public readonly Color color;
public readonly FloatingActionButtonLocation fabLocation;
public readonly NotchedShape shape;
static readonly List<FloatingActionButtonLocation> kCenterLocations = new List<FloatingActionButtonLocation> {
FloatingActionButtonLocation.centerDocked,
FloatingActionButtonLocation.centerFloat
};
public override Widget build(BuildContext context) {
List<Widget> rowContents = new List<Widget> {
public override Widget build(BuildContext context)
{
var children = new List<Widget>
{
onPressed: () => {
BottomSheetUtils.showModalBottomSheet<object>(
context: context,
builder: (BuildContext _context) => new _DemoDrawer()
onPressed: () =>
{
material_.showModalBottomSheet<object>(
context,
subContext => new _DemoDrawer()
if (kCenterLocations.Contains(this.fabLocation)) {
rowContents.Add(
new Expanded(child: new SizedBox())
);
}
if (kCenterLocations.Contains(fabLocation)) children.Add(new Expanded(child: new SizedBox()));
rowContents.AddRange(new List<Widget> {
children.Add(
onPressed: () => {
onPressed: () =>
{
),
)
);
children.Add(
Theme.of(context).platform == RuntimePlatform.Android
? Icons.more_vert
: Icons.more_horiz
Theme.of(context).platform == RuntimePlatform.IPhonePlayer
? Icons.more_horiz
: Icons.more_vert
onPressed: () => {
onPressed: () =>
{
});
);
color: this.color,
child: new Row(children: rowContents),
shape: this.shape
color: color,
shape: shape,
child: new Row(children: children)
class _DemoDrawer : StatelessWidget {
public _DemoDrawer() {
}
public override Widget build(BuildContext context) {
internal class _DemoDrawer : StatelessWidget
{
public override Widget build(BuildContext context)
{
children: new List<Widget> {
children: new List<Widget>
{
new ListTile(
leading: new Icon(Icons.search),
title: new Text("Search")

}
}
class _DiamondFab : StatelessWidget {
internal class _DiamondFab : StatelessWidget
{
public readonly Widget child;
public readonly VoidCallback onPressed;
Widget child,
VoidCallback onPressed
) {
Widget child = null,
VoidCallback onPressed = null
)
{
public readonly Widget child;
public readonly VoidCallback onPressed;
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
onTap: this.onPressed == null ? (GestureTapCallback) null : () => { this.onPressed(); },
onTap: () => onPressed?.Invoke(),
data: new IconThemeData(color: Theme.of(context).accentIconTheme.color),
child: this.child
data: new IconThemeData(Theme.of(context).accentIconTheme.color),
child: child
)
)
),

}
class _DiamondNotchedRectangle : NotchedShape {
public _DiamondNotchedRectangle() {
}
public override Path getOuterPath(Rect host, Rect guest) {
if (guest == null || !host.overlaps(guest)) {
Path path = new Path();
internal class _DiamondNotchedRectangle : NotchedShape
{
public override Path getOuterPath(Rect host, Rect guest)
{
//there is a bug in flutter when guest == null, we fix it here
if (guest == null || !host.overlaps(guest))
{
var path = new Path();
path.addRect(host);
return path;
}

Rect intersection = guest.intersect(host);
float notchToCenter =
var intersection = guest.intersect(host);
// We are computing a "V" shaped notch, as in this diagram:
// -----\**** /-----
// \ /
// \ /
// \ /
//
// "-" marks the top edge of the bottom app bar.
// "\" and "/" marks the notch outline
//
// notchToCenter is the horizontal distance between the guest's center and
// the host's top edge where the notch starts (marked with "*").
// We compute notchToCenter by similar triangles:
var notchToCenter =
Path ret = new Path();
ret.moveTo(host.left, host.top);
ret.lineTo(guest.center.dx - notchToCenter, host.top);
ret.lineTo(guest.left + guest.width / 2.0f, guest.bottom);
ret.lineTo(guest.center.dx + notchToCenter, host.top);
ret.lineTo(host.right, host.top);
ret.lineTo(host.right, host.bottom);
ret.lineTo(host.left, host.bottom);
ret.close();
return ret;
var retPath = new Path();
retPath.moveTo(host.left, host.top);
retPath.lineTo(guest.center.dx - notchToCenter, host.top);
retPath.lineTo(guest.left + guest.width / 2.0f, guest.bottom);
retPath.lineTo(guest.center.dx + notchToCenter, host.top);
retPath.lineTo(host.right, host.top);
retPath.lineTo(host.right, host.bottom);
retPath.lineTo(host.left, host.bottom);
retPath.close();
return retPath;
class _DiamondBorder : ShapeBorder {
public _DiamondBorder() {
}
internal class _DiamondBorder : ShapeBorder
{
public override EdgeInsetsGeometry dimensions => EdgeInsets.only();
public override EdgeInsets dimensions {
get { return EdgeInsets.only(); }
}
public override Path getInnerPath(Rect rect) {
return this.getOuterPath(rect);
public override Path getInnerPath(Rect rect, TextDirection? textDirection = null)
{
return getOuterPath(rect, textDirection);
public override Path getOuterPath(Rect rect) {
Path path = new Path();
public override Path getOuterPath(Rect rect, TextDirection? textDirection = null)
{
var path = new Path();
path.moveTo(rect.left + rect.width / 2.0f, rect.top);
path.lineTo(rect.right, rect.top + rect.height / 2.0f);
path.lineTo(rect.left + rect.width / 2.0f, rect.bottom);

}
public override void paint(Canvas canvas, Rect rect) {
public override void paint(Canvas canvas, Rect rect, TextDirection? textDirection = null)
{
public override ShapeBorder scale(float t) {
public override ShapeBorder scale(float t)
{
return null;
}
}

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_app_bar_demo.cs.meta


fileFormatVersion: 2
guid: 7c1d20efeafe42699212e2147c0828af
timeCreated: 1553149093
guid: c1ce2a2020fa4af0b42ffceb1bba8f6a
timeCreated: 1612409991

114
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_navigation_demo.cs


using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.service;
namespace UIWidgetsGallery.gallery {
public class NavigationIconView {
public NavigationIconView(
namespace UIWidgetsGallery.demo.material
{
internal class NavigationIconView
{
internal NavigationIconView(
) {
)
{
this._icon = icon;
this._color = color;
this._title = title;

);
this.controller = new AnimationController(
duration: ThemeUtils.kThemeAnimationDuration,
vsync: vsync
);
vsync: vsync);
readonly Widget _icon;
readonly Color _color;
readonly string _title;
public readonly Widget _icon;
public readonly Color _color;
public readonly string _title;
Animation<float> _animation;
private Animation<float> _animation;
public FadeTransition transition(BottomNavigationBarType type, BuildContext context) {
internal FadeTransition transition(BottomNavigationBarType type, BuildContext context)
{
if (type == BottomNavigationBarType.shifting) {
if (type == BottomNavigationBarType.shifting)
{
else {
else
{
ThemeData themeData = Theme.of(context);
iconColor = themeData.brightness == Brightness.light
? themeData.primaryColor

}
}
public class CustomIcon : StatelessWidget {
public override Widget build(BuildContext context) {
internal class CustomIcon : StatelessWidget
{
public override Widget build(BuildContext context)
{
IconThemeData iconTheme = IconTheme.of(context);
return new Container(
margin: EdgeInsets.all(4.0f),

}
}
public class CustomInactiveIcon : StatelessWidget {
public override Widget build(BuildContext context) {
internal class CustomInactiveIcon : StatelessWidget
{
public override Widget build(BuildContext context)
{
IconThemeData iconTheme = IconTheme.of(context);
return new Container(
margin: EdgeInsets.all(4.0f),

}
}
public class BottomNavigationDemo : StatefulWidget {
public const string routeName = "/material/bottom_navigation";
internal class BottomNavigationDemo : StatefulWidget
{
public static readonly string routeName = "/material/bottom_navigation";
public override State createState() {
public override State createState()
{
class _BottomNavigationDemoState : TickerProviderStateMixin<BottomNavigationDemo> {
int _currentIndex = 0;
BottomNavigationBarType _type = BottomNavigationBarType.shifting;
List<NavigationIconView> _navigationViews;
internal class _BottomNavigationDemoState : TickerProviderStateMixin<BottomNavigationDemo>
{
private int _currentIndex = 0;
private BottomNavigationBarType _type = BottomNavigationBarType.shifting;
private List<NavigationIconView> _navigationViews;
public override void initState() {
public override void initState()
{
this._navigationViews = new List<NavigationIconView> {
this._navigationViews = new List<NavigationIconView>
{
new NavigationIconView(
icon: new Icon(Icons.access_alarm),
title: "Alarm",

this._navigationViews[this._currentIndex].controller.setValue(1.0f);
}
public override void dispose() {
foreach (NavigationIconView view in this._navigationViews) {
view.controller.dispose();
}
public override void dispose()
{
foreach (NavigationIconView view in this._navigationViews)
view.controller.dispose();
Widget _buildTransitionsStack() {
List<FadeTransition> transitions = new List<FadeTransition> { };
private Widget _buildTransitionsStack()
{
List<FadeTransition> transitions = new List<FadeTransition>();
foreach (NavigationIconView view in this._navigationViews) {
foreach (NavigationIconView view in this._navigationViews)
}
transitions.Sort((FadeTransition a, FadeTransition b) => {
// We want to have the newly animating (fading in) views on top.
transitions.Sort((FadeTransition a, FadeTransition b) =>
{
Animation<float> aAnimation = a.opacity;
Animation<float> bAnimation = b.opacity;
float aValue = aAnimation.value;

return new Stack(children: transitions.Select<FadeTransition, Widget>(w => w).ToList());
return new Stack(children: new List<Widget>(transitions));
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
items: this._navigationViews.Select((NavigationIconView navigationView) => navigationView.item)
items: this._navigationViews
.Select<NavigationIconView, BottomNavigationBarItem>((NavigationIconView navigationView) =>
navigationView.item)
onTap: (int index) => {
this.setState(() => {
onTap: (int index) =>
{
this.setState(() =>
{
this._navigationViews[this._currentIndex].controller.reverse();
this._currentIndex = index;
this._navigationViews[this._currentIndex].controller.forward();

return new Scaffold(
appBar: new AppBar(
title: new Text("Bottom navigation"),
actions: new List<Widget> {
actions: new List<Widget>
{
onSelected: (BottomNavigationBarType value) => {
onSelected: (BottomNavigationBarType value) =>
{
itemBuilder: (BuildContext _context) => new List<PopupMenuEntry<BottomNavigationBarType>> {
itemBuilder: (BuildContext subContext) => new List<PopupMenuEntry<BottomNavigationBarType>>
{
new PopupMenuItem<BottomNavigationBarType>(
value: BottomNavigationBarType.fix,
child: new Text("Fixed")

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/bottom_navigation_demo.cs.meta


fileFormatVersion: 2
guid: d279028b09c04c2b8ab3fba122868004
timeCreated: 1553221768
guid: 0141eef318dd42e6acc4f3400430dcc8
timeCreated: 1612419869

690
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/buttons_demo.cs


using System;
using Unity.UIWidgets.foundation;
using UIWidgetsGallery.gallery;
namespace UIWidgetsGallery.gallery {
class ButtonsDemo : StatefulWidget {
public const string routeName = "/material/buttons";
public ButtonsDemo(Key key = null) : base(key: key) {
}
public override State createState() {
return new _ButtonsDemoState();
}
}
class _ButtonsDemoState : State<ButtonsDemo> {
const string _raisedText =
namespace UIWidgetsGallery.demo.material
{
public static class ButtonsDemoUtils
{
public static readonly string _raisedText =
"functions on busy or wide spaces.";
"functions on busy or wide spaces.";
const string _raisedCode = "buttons_raised";
public static readonly string _raisedCode = "buttons_raised";
const string _flatText = "A flat button displays an ink splash on press " +
"but does not lift. Use flat buttons on toolbars, in dialogs and " +
"inline with padding";
public static readonly string _flatText = "A flat button displays an ink splash on press " +
"but does not lift. Use flat buttons on toolbars, in dialogs and " +
"inline with padding";
const string _flatCode = "buttons_flat";
public static readonly string _flatCode = "buttons_flat";
const string _outlineText =
public static readonly string _outlineText =
"paired with raised buttons to indicate an alternative, secondary action.";
"paired with raised buttons to indicate an alternative, secondary action.";
const string _outlineCode = "buttons_outline";
public static readonly string _outlineCode = "buttons_outline";
const string _dropdownText =
"A dropdown button displays a menu that's used to select a value from a " +
"small set of values. The button displays the current value and a down " +
"arrow.";
public static readonly string _dropdownText =
"A dropdown button displays a menu that\"s used to select a value from a " +
"small set of values. The button displays the current value and a down " +
"arrow.";
const string _dropdownCode = "buttons_dropdown";
public static readonly string _dropdownCode = "buttons_dropdown";
const string _iconText =
public static readonly string _iconText =
"to be selected or deselected, such as adding or removing an item's star.";
"to be selected or deselected, such as adding or removing an item\"s star.";
const string _iconCode = "buttons_icon";
public static readonly string _iconCode = "buttons_icon";
const string _actionText =
public static readonly string _actionText =
"distinguished by a circled icon floating above the UI and can have motion " +
"behaviors that include morphing, launching, and a transferring anchor " +
"point.";
"distinguished by a circled icon floating above the UI and can have motion " +
"behaviors that include morphing, launching, and a transferring anchor " +
"point.";
const string _actionCode = "buttons_action";
public static readonly string _actionCode = "buttons_action";
}
class ButtonsDemo : StatefulWidget {
public static readonly string routeName = "/material/buttons";
ShapeBorder _buttonShape;
public override State createState() => new _ButtonsDemoState();
}
class _ButtonsDemoState : State<ButtonsDemo> {
ShapeBorder _buttonShape;
public _ButtonsDemoState() {
}
public override Widget build(BuildContext context)
{
ButtonThemeData buttonTheme = ButtonTheme.of(context).copyWith(
shape: _buttonShape
);
public override Widget build(BuildContext context) {
ButtonThemeData buttonTheme = ButtonTheme.of(context).copyWith(
shape: this._buttonShape
);
List<ComponentDemoTabData> demos = new List<ComponentDemoTabData>{
new ComponentDemoTabData(
tabName: "RAISED",
description: ButtonsDemoUtils._raisedText,
demoWidget: ButtonTheme.fromButtonThemeData(
data: buttonTheme,
child: buildRaisedButton()
),
exampleCodeTag: ButtonsDemoUtils._raisedCode,
documentationUrl: "https://docs.flutter.io/flutter/material/RaisedButton-class.html"
),
new ComponentDemoTabData(
tabName: "FLAT",
description: ButtonsDemoUtils._flatText,
demoWidget: ButtonTheme.fromButtonThemeData(
data: buttonTheme,
child: buildFlatButton()
),
exampleCodeTag: ButtonsDemoUtils._flatCode,
documentationUrl: "https://docs.flutter.io/flutter/material/FlatButton-class.html"
),
new ComponentDemoTabData(
tabName: "OUTLINE",
description: ButtonsDemoUtils._outlineText,
demoWidget: ButtonTheme.fromButtonThemeData(
data: buttonTheme,
child: buildOutlineButton()
),
exampleCodeTag: ButtonsDemoUtils._outlineCode,
documentationUrl: "https://docs.flutter.io/flutter/material/OutlineButton-class.html"
),
new ComponentDemoTabData(
tabName: "DROPDOWN",
description: ButtonsDemoUtils._dropdownText,
demoWidget: buildDropdownButton(),
exampleCodeTag: ButtonsDemoUtils._dropdownCode,
documentationUrl: "https://docs.flutter.io/flutter/material/DropdownButton-class.html"
),
new ComponentDemoTabData(
tabName: "ICON",
description: ButtonsDemoUtils._iconText,
demoWidget: buildIconButton(),
exampleCodeTag: ButtonsDemoUtils._iconCode,
documentationUrl: "https://docs.flutter.io/flutter/material/IconButton-class.html"
),
new ComponentDemoTabData(
tabName: "ACTION",
description: ButtonsDemoUtils._actionText,
demoWidget: buildActionButton(),
exampleCodeTag: ButtonsDemoUtils._actionCode,
documentationUrl: "https://docs.flutter.io/flutter/material/FloatingActionButton-class.html"
)
};
List<ComponentDemoTabData> demos = new List<ComponentDemoTabData> {
new ComponentDemoTabData(
tabName: "RAISED",
description: _raisedText,
demoWidget: ButtonTheme.fromButtonThemeData(
data: buttonTheme,
child: this.buildRaisedButton()
),
exampleCodeTag: _raisedCode,
documentationUrl: "https://docs.flutter.io/flutter/material/RaisedButton-class.html"
),
new ComponentDemoTabData(
tabName: "FLAT",
description: _flatText,
demoWidget: ButtonTheme.fromButtonThemeData(
data: buttonTheme,
child: this.buildFlatButton()
),
exampleCodeTag: _flatCode,
documentationUrl: "https://docs.flutter.io/flutter/material/FlatButton-class.html"
),
new ComponentDemoTabData(
tabName: "OUTLINE",
description: _outlineText,
demoWidget: ButtonTheme.fromButtonThemeData(
data: buttonTheme,
child: this.buildOutlineButton()
),
exampleCodeTag: _outlineCode,
documentationUrl: "https://docs.flutter.io/flutter/material/OutlineButton-class.html"
),
new ComponentDemoTabData(
tabName: "DROPDOWN",
description: _dropdownText,
demoWidget: this.buildDropdownButton(),
exampleCodeTag: _dropdownCode,
documentationUrl: "https://docs.flutter.io/flutter/material/DropdownButton-class.html"
),
new ComponentDemoTabData(
tabName: "ICON",
description: _iconText,
demoWidget: this.buildIconButton(),
exampleCodeTag: _iconCode,
documentationUrl: "https://docs.flutter.io/flutter/material/IconButton-class.html"
),
new ComponentDemoTabData(
tabName: "ACTION",
description: _actionText,
demoWidget: this.buildActionButton(),
exampleCodeTag: _actionCode,
documentationUrl: "https://docs.flutter.io/flutter/material/FloatingActionButton-class.html"
)
};
return new TabbedComponentDemoScaffold(
title: "Buttons",
demos: demos,
actions: new List<Widget>{
new IconButton(
icon: new Icon(Icons.sentiment_very_satisfied),
onPressed: () => {
setState(() => {
_buttonShape = _buttonShape == null ? new StadiumBorder() : null;
});
}
)
}
);
}
return new TabbedComponentDemoScaffold(
title: "Buttons",
demos: demos,
actions: new List<Widget> {
new IconButton(
icon: new Icon(Icons.sentiment_very_satisfied),
onPressed: () => {
this.setState(() => {
this._buttonShape = this._buttonShape == null ? new StadiumBorder() : null;
});
}
)
Widget buildRaisedButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
new RaisedButton(
child: new Text("RAISED BUTTON"),
onPressed: () => {
// Perform some action
);
}
public Widget buildRaisedButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new RaisedButton(
child: new Text("RAISED BUTTON"),
onPressed: () => {
// Perform some action
}
),
new RaisedButton(
child: new Text("DISABLED"),
onPressed: null
)
}
),
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
RaisedButton.icon(
icon: new Icon(Icons.add, size: 18.0f),
label: new Text("RAISED BUTTON"),
onPressed: () => {
// Perform some action
}
),
RaisedButton.icon(
icon: new Icon(Icons.add, size: 18.0f),
label: new Text("DISABLED"),
onPressed: null
)
}
)
}
)
);
),
new RaisedButton(
child: new Text("DISABLED"),
onPressed: null
)
}
),
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
RaisedButton.icon(
icon: new Icon(Icons.add, size: 18.0f),
label: new Text("RAISED BUTTON"),
onPressed: () => {
// Perform some action
}
),
RaisedButton.icon(
icon: new Icon(Icons.add, size: 18.0f),
label: new Text("DISABLED"),
onPressed: null
)
}
)
)
);
}
public Widget buildFlatButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new FlatButton(
child: new Text("FLAT BUTTON"),
onPressed: () => {
// Perform some action
}
),
new FlatButton(
child: new Text("DISABLED"),
onPressed: null
)
}
),
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
FlatButton.icon(
icon: new Icon(Icons.add_circle_outline, size: 18.0f),
label: new Text("FLAT BUTTON"),
onPressed: () => {
// Perform some action
}
),
FlatButton.icon(
icon: new Icon(Icons.add_circle_outline, size: 18.0f),
label: new Text("DISABLED"),
onPressed: null
),
}
)
}
)
);
Widget buildFlatButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
new FlatButton(
child: new Text("FLAT BUTTON"),
onPressed: () => {
// Perform some action
}
),
new FlatButton(
child: new Text("DISABLED"),
onPressed: null
)
}
),
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
FlatButton.icon(
icon: new Icon(Icons.add_circle_outline, size: 18.0f),
label: new Text("FLAT BUTTON"),
onPressed: () => {
// Perform some action
}
),
FlatButton.icon(
icon: new Icon(Icons.add_circle_outline, size: 18.0f),
label: new Text("DISABLED"),
onPressed: null
)
}
)
)
);
}
Widget buildOutlineButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new OutlineButton(
child: new Text("OUTLINE BUTTON"),
onPressed: () => {
// Perform some action
}
),
new OutlineButton(
child: new Text("DISABLED"),
onPressed: null
)
}
),
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
OutlineButton.icon(
icon: new Icon(Icons.add, size: 18.0f),
label: new Text("OUTLINE BUTTON"),
onPressed: () => {
// Perform some action
}
),
OutlineButton.icon(
icon: new Icon(Icons.add, size: 18.0f),
label: new Text("DISABLED"),
onPressed: null
)
}
)
}
)
);
Widget buildOutlineButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
new OutlineButton(
child: new Text("OUTLINE BUTTON"),
onPressed: () => {
// Perform some action
}
),
new OutlineButton(
child: new Text("DISABLED"),
onPressed: null
)
}
),
new ButtonBar(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
OutlineButton.icon(
icon: new Icon(Icons.add, size: 18.0f),
label: new Text("OUTLINE BUTTON"),
onPressed: () => {
// Perform some action
}
),
OutlineButton.icon(
icon: new Icon(Icons.add, size: 18.0f),
label: new Text("DISABLED"),
onPressed: null
)
}
)
)
);
}
// https://en.wikipedia.org/wiki/Free_Four
string dropdown1Value = "Free";
string dropdown2Value;
string dropdown3Value = "Four";
// https://en.wikipedia.org/wiki/Free_Four
string dropdown1Value = "Free";
string dropdown2Value = null;
string dropdown3Value = "Four";
public Widget buildDropdownButton() {
return new Padding(
padding: EdgeInsets.all(24.0f),
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
children: new List<Widget> {
new ListTile(
title: new Text("Simple dropdown:"),
trailing: new DropdownButton<string>(
value: this.dropdown1Value,
onChanged: (string newValue) => {
this.setState(() => { this.dropdown1Value = newValue; });
},
items: new List<string> {"One", "Two", "Free", "Four"}.Select((string value) => {
return new DropdownMenuItem<string>(
value: value,
child: new Text(value)
);
}).ToList()
)
),
new SizedBox(
height: 24.0f
),
new ListTile(
title: new Text("Dropdown with a hint:"),
trailing: new DropdownButton<string>(
value: this.dropdown2Value,
hint: new Text("Choose"),
onChanged: (string newValue) => {
this.setState(() => { this.dropdown2Value = newValue; });
},
items: new List<string> {"One", "Two", "Free", "Four"}.Select((string value) => {
return new DropdownMenuItem<string>(
value: value,
child: new Text(value)
);
}).ToList()
)
),
new SizedBox(
height: 24.0f
),
new ListTile(
title: new Text("Scrollable dropdown:"),
trailing: new DropdownButton<string>(
value: this.dropdown3Value,
onChanged: (string newValue) => {
this.setState(() => { this.dropdown3Value = newValue; });
},
items: new List<string> {
"One", "Two", "Free", "Four", "Can", "I", "Have", "A", "Little",
"Bit", "More", "Five", "Six", "Seven", "Eight", "Nine", "Ten"
}.Select<string, DropdownMenuItem<string>>(value => {
return new DropdownMenuItem<string>(
value: value,
child: new Text(value)
);
}).ToList()
)
)
}
)
);
Widget buildDropdownButton() {
return new Padding(
padding: EdgeInsets.all(24.0f),
child: new Column(
mainAxisAlignment: MainAxisAlignment.start,
children: new List<Widget>{
new ListTile(
title: new Text("Simple dropdown:"),
trailing: new DropdownButton<string>(
value: dropdown1Value,
onChanged: (string newValue) => {
setState(() => {
dropdown1Value = newValue;
});
},
items: new List<string>{"One", "Two", "Free", "Four"}.Select<string, DropdownMenuItem<string>>((string value) => {
return new DropdownMenuItem<string>(
value: value,
child: new Text(value)
);
}).ToList()
)
),
new SizedBox(
height: 24.0f
),
new ListTile(
title: new Text("Dropdown with a hint:"),
trailing: new DropdownButton<string>(
value: dropdown2Value,
hint: new Text("Choose"),
onChanged: (string newValue) => {
setState(() => {
dropdown2Value = newValue;
});
},
items: new List<string>{"One", "Two", "Free", "Four"}.Select<string, DropdownMenuItem<string>>((string value) => {
return new DropdownMenuItem<string>(
value: value,
child: new Text(value)
);
}).ToList()
)
),
new SizedBox(
height: 24.0f
),
new ListTile(
title: new Text("Scrollable dropdown:"),
trailing: new DropdownButton<string>(
value: dropdown3Value,
onChanged: (string newValue) => {
setState(() => {
dropdown3Value = newValue;
});
},
items: new List<string>{
"One", "Two", "Free", "Four", "Can", "I", "Have", "A", "Little",
"Bit", "More", "Five", "Six", "Seven", "Eight", "Nine", "Ten",
}
.Select<string, DropdownMenuItem<string>>((string value) => {
return new DropdownMenuItem<string>(
value: value,
child: new Text(value)
);
})
.ToList()
)
)
)
);
}
bool iconButtonToggle = false;
bool iconButtonToggle = false;
public Widget buildIconButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
new IconButton(
icon: new Icon(
Icons.thumb_up
),
onPressed: () => { this.setState(() => this.iconButtonToggle = !this.iconButtonToggle); },
color: this.iconButtonToggle ? Theme.of(this.context).primaryColor : null
),
new IconButton(
icon: new Icon(
Icons.thumb_up
),
onPressed: null
)
}.Select<Widget, Widget>(
(Widget button) => new SizedBox(width: 64.0f, height: 64.0f, child: button)).ToList()
)
);
Widget buildIconButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget>{
new IconButton(
icon: new Icon(
Icons.thumb_up
),
onPressed: () =>{
setState(() => iconButtonToggle = !iconButtonToggle);
},
color: iconButtonToggle ? Theme.of(context).primaryColor : null
),
new IconButton(
icon: new Icon(
Icons.thumb_up
),
onPressed: null
)
.Select<Widget, Widget>((Widget button) => new SizedBox(width: 64.0f, height: 64.0f, child: button))
.ToList()
)
);
}
public Widget buildActionButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new FloatingActionButton(
child: new Icon(Icons.add),
onPressed: () => {
// Perform some action
},
tooltip: "floating action button"
)
);
}
}
Widget buildActionButton() {
return new Align(
alignment: new Alignment(0.0f, -0.2f),
child: new FloatingActionButton(
child: new Icon(Icons.add),
onPressed: () => {
// Perform some action
},
tooltip: "floating action button"
)
);
}
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/buttons_demo.cs.meta


fileFormatVersion: 2
guid: bf7a009b9ad594f1887c1178cd01160b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: d6d69568df64484b9aaee159d11dffc8
timeCreated: 1612421132

530
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/cards_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 Image = Unity.UIWidgets.widgets.Image;
using UnityEngine;
namespace UIWidgetsGallery.gallery {
class CardsDemoConstants {
public static readonly List<TravelDestination> destinations = new List<TravelDestination> {
new TravelDestination(
assetName: "india_thanjavur_market",
title: "Top 10 Cities to Visit in Tamil Nadu",
description: new List<string> {
"Number 10",
"Thanjavur",
"Thanjavur, Tamil Nadu"
}
),
new TravelDestination(
assetName: "india_chettinad_silk_maker",
title: "Artisans of Southern India",
description: new List<string> {
"Silk Spinners",
"Chettinad",
"Sivaganga, Tamil Nadu"
}
)
};
namespace UIWidgetsGallery.demo.material
{
public static class CardsDemoUtils
{
public static readonly string _kGalleryAssetsPackage = "gallery/";
}
internal enum CardDemoType
{
standard,
tappable,
selectable,
public class TravelDestination {
internal class TravelDestination
{
string assetPackage = null,
List<string> description = null
) {
string description = null,
string city = null,
string location = null,
CardDemoType type = CardDemoType.standard
)
{
D.assert(assetName != null);
D.assert(assetPackage != null);
D.assert(title != null);
D.assert(description != null);
D.assert(city != null);
D.assert(location != null);
this.assetPackage = assetPackage;
this.city = city;
this.location = location;
this.type = type;
public readonly string assetPackage;
public readonly List<string> description;
public readonly string description;
public readonly string city;
public readonly string location;
public readonly CardDemoType type;
public static readonly List<TravelDestination> destinations = new List<TravelDestination>
{
new TravelDestination(
assetName: "places/india_thanjavur_market.png",
assetPackage: CardsDemoUtils._kGalleryAssetsPackage,
title: "Top 10 Cities to Visit in Tamil Nadu",
description: "Number 10",
city: "Thanjavur",
location: "Thanjavur, Tamil Nadu"
),
new TravelDestination(
assetName: "places/india_chettinad_silk_maker.png",
assetPackage: CardsDemoUtils._kGalleryAssetsPackage,
title: "Artisans of Southern India",
description: "Silk Spinners",
city: "Chettinad",
location: "Sivaganga, Tamil Nadu",
type: CardDemoType.tappable
),
new TravelDestination(
assetName: "places/india_tanjore_thanjavur_temple.png",
assetPackage: CardsDemoUtils._kGalleryAssetsPackage,
title: "Brihadisvara Temple",
description: "Temples",
city: "Thanjavur",
location: "Thanjavur, Tamil Nadu",
type: CardDemoType.selectable
),
};
}
public bool isValid {
get { return this.assetName != null && this.title != null && this.description?.Count == 3; }
internal class TravelDestinationItem : StatelessWidget
{
public TravelDestinationItem(Key key = null, TravelDestination destination = null, ShapeBorder shape = null)
: base(key: key)
{
D.assert(destination != null);
this.destination = destination;
this.shape = shape;
}
// This height will allow for all the Card's content to fit comfortably within the card.
private const float height = 338.0f;
public readonly TravelDestination destination;
public readonly ShapeBorder shape;
public override Widget build(BuildContext context)
{
return new SafeArea(
top: false,
bottom: false,
child: new Padding(
padding: EdgeInsets.all(8.0f),
child: new Column(
children: new List<Widget>
{
new SectionTitle(title: "Normal"),
new SizedBox(
height: height,
child: new Card(
// This ensures that the Card's children are clipped correctly.
clipBehavior: Clip.antiAlias,
shape: this.shape,
child: new TravelDestinationContent(destination: this.destination)
)
)
}
)
)
);
internal class TappableTravelDestinationItem : StatelessWidget
{
public TappableTravelDestinationItem(Key key = null, TravelDestination destination = null,
ShapeBorder shape = null)
: base(key: key)
{
D.assert(destination != null);
this.destination = destination;
this.shape = shape;
}
public class TravelDestinationItem : StatelessWidget {
public TravelDestinationItem(Key key = null, TravelDestination destination = null, ShapeBorder shape = null)
: base(key: key) {
D.assert(destination != null && destination.isValid);
// This height will allow for all the Card's content to fit comfortably within the card.
private const float height = 298.0f;
public readonly TravelDestination destination;
public readonly ShapeBorder shape;
public override Widget build(BuildContext context)
{
return new SafeArea(
top: false,
bottom: false,
child: new Padding(
padding: EdgeInsets.all(8.0f),
child: new Column(
children: new List<Widget>
{
new SectionTitle(title: "Tappable"),
new SizedBox(
height: height,
child: new Card(
// This ensures that the Card's children (including the ink splash) are clipped correctly.
clipBehavior: Clip.antiAlias,
shape: this.shape,
child: new InkWell(
onTap: () => { Debug.Log("Card was tapped"); },
// Generally, material cards use onSurface with 12% opacity for the pressed state.
splashColor: Theme.of(context).colorScheme.onSurface.withOpacity(0.12f),
// Generally, material cards do not have a highlight overlay.
highlightColor: Colors.transparent,
child: new TravelDestinationContent(destination: this.destination)
)
)
)
}
)
)
);
}
}
internal class SelectableTravelDestinationItem : StatefulWidget
{
public SelectableTravelDestinationItem(Key key = null, TravelDestination destination = null,
ShapeBorder shape = null)
: base(key: key)
{
D.assert(destination != null);
public const float height = 366.0f;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white);
TextStyle descriptionStyle = theme.textTheme.subhead;
public override State createState()
{
return new _SelectableTravelDestinationItemState();
}
}
internal class _SelectableTravelDestinationItemState : State<SelectableTravelDestinationItem>
{
// This height will allow for all the Card's content to fit comfortably within the card.
private const float height = 298.0f;
private bool _isSelected = false;
public override Widget build(BuildContext context)
{
ColorScheme colorScheme = Theme.of(context).colorScheme;
child: new Container(
child: new Padding(
height: height,
child: new Card(
shape: this.shape,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new SizedBox(
height: 184.0f,
child: new Stack(
children: new List<Widget> {
Positioned.fill(
child: Image.asset(this.destination.assetName,
fit: BoxFit.cover
)
),
new Positioned(
bottom: 16.0f,
left: 16.0f,
right: 16.0f,
child: new FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: new Text(this.destination.title,
style: titleStyle
child: new Column(
children: new List<Widget>
{
new SectionTitle(title: "Selectable (long press)"),
new SizedBox(
height: height,
child: new Card(
// This ensures that the Card's children (including the ink splash) are clipped correctly.
clipBehavior: Clip.antiAlias,
shape: this.widget.shape,
child: new InkWell(
onLongPress: () =>
{
Debug.Log("Selectable card state changed");
this.setState(() => { this._isSelected = !this._isSelected; });
},
// Generally, material cards use onSurface with 12% opacity for the pressed state.
splashColor: colorScheme.onSurface.withOpacity(0.12f),
// Generally, material cards do not have a highlight overlay.
highlightColor: Colors.transparent,
child: new Stack(
children: new List<Widget>
{
new Container(
color: this._isSelected
// Generally, material cards use primary with 8% opacity for the selected state.
// See: https://material.io/design/interaction/states.html#anatomy
? colorScheme.primary.withOpacity(0.08f)
: Colors.transparent
),
new TravelDestinationContent(destination: this.widget.destination),
new Align(
alignment: Alignment.topRight,
child: new Padding(
padding: EdgeInsets.all(8.0f),
child: new Icon(
Icons.check_circle,
color: this._isSelected
? colorScheme.primary
: Colors.transparent
)
)
}
}
)
),
new Expanded(
child: new Padding(
padding: EdgeInsets.fromLTRB(16.0f, 16.0f, 16.0f, 0.0f),
child: new DefaultTextStyle(
softWrap: false,
overflow: TextOverflow.ellipsis,
style: descriptionStyle,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new Padding(
padding: EdgeInsets.only(bottom: 8.0f),
child: new Text(this.destination.description[0],
style: descriptionStyle.copyWith(color: Colors.black54)
)
),
new Text(this.destination.description[1]),
new Text(this.destination.description[2])
}
)
)
)
)
}
)
)
);
}
}
internal class SectionTitle : StatelessWidget
{
public SectionTitle(
Key key = null,
string title = null
) : base(key: key)
{
this.title = title;
}
public readonly string title;
public override Widget build(BuildContext context)
{
return new Padding(
padding: EdgeInsets.fromLTRB(4.0f, 4.0f, 4.0f, 12.0f),
child: new Align(
alignment: Alignment.centerLeft,
child: new Text(this.title, style: Theme.of(context).textTheme.subtitle1)
)
);
}
}
internal class TravelDestinationContent : StatelessWidget
{
public TravelDestinationContent(Key key = null, TravelDestination destination = null)
: base(key: key)
{
D.assert(destination != null);
this.destination = destination;
}
public readonly TravelDestination destination;
public override Widget build(BuildContext context)
{
ThemeData theme = Theme.of(context);
TextStyle titleStyle = theme.textTheme.headline5.copyWith(color: Colors.white);
TextStyle descriptionStyle = theme.textTheme.subtitle1;
var children = new List<Widget>
{
// Photo and title.
new SizedBox(
height: 184.0f,
child: new Stack(
children: new List<Widget>
{
Positioned.fill(
// In order to have the ink splash appear above the image, you
// must use Ink.image. This allows the image to be painted as part
// of the Material and display ink effects above it. Using a
// standard Image will obscure the ink splash.
child: Ink.image(
image: new FileImage(System.IO.Path.Combine(destination.assetPackage,
destination.assetName)),
fit: BoxFit.cover,
child: new Container()
)
),
new Positioned(
bottom: 16.0f,
left: 16.0f,
right: 16.0f,
child: new FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: new Text(this.destination.title,
style: titleStyle
),
ButtonTheme.bar(
child: new ButtonBar(
alignment: MainAxisAlignment.start,
children: new List<Widget> {
new FlatButton(
child: new Text("SHARE"),
textColor: Colors.amber.shade500,
onPressed: () => {
/* do nothing */
}
),
new FlatButton(
child: new Text("EXPLORE"),
textColor: Colors.amber.shade500,
onPressed: () => {
/* do nothing */
}
)
}
)
)
}
)
),
// Description and share/explore buttons.
new Padding(
padding: EdgeInsets.fromLTRB(16.0f, 16.0f, 16.0f, 0.0f),
child: new DefaultTextStyle(
softWrap: false,
overflow: TextOverflow.ellipsis,
style: descriptionStyle,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>
{
// three line description
new Padding(
padding: EdgeInsets.only(bottom: 8.0f),
child: new Text(this.destination.description,
style: descriptionStyle.copyWith(color: Colors.black54)
new Text(this.destination.city),
new Text(this.destination.location)
};
if (this.destination.type == CardDemoType.standard)
// share, explore buttons
children.Add(new ButtonBar(
alignment: MainAxisAlignment.start,
children: new List<Widget>
{
new FlatButton(
child: new Text("SHARE"),
textColor: Colors.amber.shade500,
onPressed: () => { Debug.Log("pressed"); }
),
new FlatButton(
child: new Text("EXPLORE"),
textColor: Colors.amber.shade500,
onPressed: () => { Debug.Log("pressed"); }
)
}
));
return new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: children
public class CardsDemo : StatefulWidget {
public const string routeName = "/material/cards";
internal class CardsDemo : StatefulWidget
{
public static readonly string routeName = "/material/cards";
public override State createState() {
public override State createState()
{
class _CardsDemoState : State<CardsDemo> {
ShapeBorder _shape;
internal class _CardsDemoState : State<CardsDemo>
{
private ShapeBorder _shape;
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
title: new Text("Travel stream"),
actions: new List<Widget> {
title: new Text("Cards"),
actions: new List<Widget>
{
onPressed: () => {
this.setState(() => {
onPressed: () =>
{
this.setState(() =>
{
this._shape = this._shape != null
? null
: new RoundedRectangleBorder(

)
}
),
body: new ListView(
itemExtent: TravelDestinationItem.height,
padding: EdgeInsets.only(top: 8.0f, left: 8.0f, right: 8.0f),
children: CardsDemoConstants.destinations.Select<TravelDestination, Widget>(
(TravelDestination destination) => {
return new Container(
margin: EdgeInsets.only(bottom: 8.0f),
child: new TravelDestinationItem(
destination: destination,
shape: this._shape
)
);
}).ToList()
body: new Scrollbar(
child: new ListView(
padding: EdgeInsets.only(top: 8.0f, left: 8.0f, right: 8.0f),
children: TravelDestination.destinations.Select<TravelDestination, Widget>(
(TravelDestination destination) =>
{
Widget child = null;
switch (destination.type)
{
case CardDemoType.standard:
child = new TravelDestinationItem(destination: destination, shape: this._shape);
break;
case CardDemoType.tappable:
child = new TappableTravelDestinationItem(destination: destination,
shape: this._shape);
break;
case CardDemoType.selectable:
child = new SelectableTravelDestinationItem(destination: destination,
shape: this._shape);
break;
}
return new Container(
margin: EdgeInsets.only(bottom: 8.0f),
child: child
);
}).ToList()
)
)
);
}

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/cards_demo.cs.meta


fileFormatVersion: 2
guid: f199ea32d87544c892f57b8af0fcbb03
timeCreated: 1553136548
guid: e5eef436049c4b8ba60592f26681bb56
timeCreated: 1612423408

269
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/chip_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;

namespace UIWidgetsGallery.gallery {
class ChipDemoUtils {
public static readonly List<string> _defaultMaterials = new List<string> {
namespace UIWidgetsGallery.demo.material
{
public static class ChipDemoUtils
{
public static void AddRange<T>(this HashSet<T> hashSet, List<T> list)
{
foreach (var item in list) hashSet.Add(item);
}
public static void AddRange<T>(this HashSet<T> hashSet, HashSet<T> list)
{
foreach (var item in list) hashSet.Add(item);
}
public static readonly List<string> _defaultMaterials = new List<string>
{
"poker",
"tortilla",
"fish and",

public static readonly List<string> _defaultActions = new List<string> {
public static readonly List<string> _defaultActions = new List<string>
{
"flake",
"cut",
"fragment",

"eat"
};
public static readonly Dictionary<string, string> _results = new Dictionary<string, string> {
public static readonly Dictionary<string, string> _results = new Dictionary<string, string>()
{
{"flake", "flaking"},
{"cut", "cutting"},
{"fragment", "fragmenting"},

{"solder", "soldering"},
{"cash in", "cashing in"},
{"eat", "eating"}
{"eat", "eating"},
public static readonly List<string> _defaultTools = new List<string> {
public static readonly List<string> _defaultTools = new List<string>
{
"hammer",
"chisel",
"fryer",

public static readonly Dictionary<string, string> _avatars = new Dictionary<string, string> {
{"hammer", "people/square/ali"},
{"chisel", "people/square/sandra"},
{"fryer", "people/square/trevor"},
{"fabricator", "people/square/stella"},
{"customer", "people/square/peter"}
public static readonly Dictionary<string, string> _avatars = new Dictionary<string, string>()
{
{"hammer", "gallery/people/square/ali.png"},
{"chisel", "gallery/people/square/sandra.png"},
{"fryer", "gallery/people/square/trevor.png"},
{"fabricator", "gallery/people/square/stella.png"},
{"customer", "gallery/people/square/peter.png"},
new Dictionary<string, HashSet<string>> {
{"hammer", new HashSet<string>(new List<string> {"flake", "fragment", "splinter"})},
{"chisel", new HashSet<string>(new List<string> {"flake", "nick", "splinter"})},
{"fryer", new HashSet<string>(new List<string> {"fry"})},
{"fabricator", new HashSet<string>(new List<string> {"solder"})},
{"customer", new HashSet<string>(new List<string> {"cash in", "eat"})}
new Dictionary<string, HashSet<string>>
{
{"hammer", new HashSet<string> {"flake", "fragment", "splinter"}},
{"chisel", new HashSet<string> {"flake", "nick", "splinter"}},
{"fryer", new HashSet<string> {"fry"}},
{"fabricator", new HashSet<string> {"solder"}},
{"customer", new HashSet<string> {"cash in", "eat"}},
new Dictionary<string, HashSet<string>> {
{"poker", new HashSet<string>(new List<string> {"cash in"})},
{"tortilla", new HashSet<string>(new List<string> {"fry", "eat"})},
{"fish and", new HashSet<string>(new List<string> {"fry", "eat"})},
{"micro", new HashSet<string>(new List<string> {"solder", "fragment"})},
{"wood", new HashSet<string>(new List<string> {"flake", "cut", "splinter", "nick"})}
new Dictionary<string, HashSet<string>>
{
{"poker", new HashSet<string> {"cash in"}},
{"tortilla", new HashSet<string> {"fry", "eat"}},
{"fish and", new HashSet<string> {"fry", "eat"}},
{"micro", new HashSet<string> {"solder", "fragment"}},
{"wood", new HashSet<string> {"flake", "cut", "splinter", "nick"}},
class _ChipsTile : StatelessWidget {
internal class _ChipsTile : StatelessWidget
{
) : base(key: key) {
) : base(key: key)
{
this.label = label;
this.children = children;
}

public override Widget build(BuildContext context) {
List<Widget> cardChildren = new List<Widget> {
// Wraps a list of chips into a ListTile for display as a section in the demo.
public override Widget build(BuildContext context)
{
var cardChildren = new List<Widget>
{
child: new Text(this.label, textAlign: TextAlign.left)
)
child: new Text(this.label, textAlign: TextAlign.start))
if (this.children.isNotEmpty()) {
if (this.children != null && this.children.isNotEmpty())
children: this.children.Select<Widget, Widget>((Widget chip) => {
return new Padding(
padding: EdgeInsets.all(2.0f),
child: chip
);
}).ToList()));
}
else {
TextStyle textStyle = Theme.of(context).textTheme.caption.copyWith(fontStyle: FontStyle.italic);
cardChildren.Add(
new Container(
alignment: Alignment.center,
constraints: new BoxConstraints(minWidth: 48.0f, minHeight: 48.0f),
padding: EdgeInsets.all(8.0f),
child: new Text("None", style: textStyle)
)
);
}
children: this.children.Select<Widget, Widget>((Widget chip) =>
{
return new Padding(padding: EdgeInsets.all(2.0f),
child: chip);
}).ToList()
));
else
cardChildren.Add(new Container(
alignment: Alignment.center,
constraints: new BoxConstraints(minWidth: 48.0f, minHeight: 48.0f),
padding: EdgeInsets.all(8.0f),
child: new Text("None",
style: Theme.of(context).textTheme.caption.copyWith(fontStyle: FontStyle.italic))
));
return new Card(
child: new Column(

}
}
public class ChipDemo : StatefulWidget {
public const string routeName = "/material/chip";
internal class ChipDemo : StatefulWidget
{
public static readonly string routeName = "/material/chip";
public override State createState() {
public override State createState()
{
class _ChipDemoState : State<ChipDemo> {
public _ChipDemoState() {
internal class _ChipDemoState : State<ChipDemo>
{
public _ChipDemoState()
{
HashSet<string> _materials = new HashSet<string>(new List<string> { });
string _selectedMaterial = "";
string _selectedAction = "";
HashSet<string> _tools = new HashSet<string>(new List<string> { });
HashSet<string> _selectedTools = new HashSet<string>(new List<string> { });
HashSet<string> _actions = new HashSet<string>(new List<string> { });
bool _showShapeBorder = false;
private readonly HashSet<string> _materials = new HashSet<string>();
private string _selectedMaterial = "";
private string _selectedAction = "";
private readonly HashSet<string> _tools = new HashSet<string>();
private readonly HashSet<string> _selectedTools = new HashSet<string>();
private readonly HashSet<string> _actions = new HashSet<string>();
private bool _showShapeBorder = false;
void _reset() {
// Initialize members with the default data.
private void _reset()
{
this._materials.UnionWith(ChipDemoUtils._defaultMaterials);
this._materials.AddRange(ChipDemoUtils._defaultMaterials);
this._actions.UnionWith(ChipDemoUtils._defaultActions);
this._actions.AddRange(ChipDemoUtils._defaultActions);
this._tools.UnionWith(ChipDemoUtils._defaultTools);
this._tools.AddRange(ChipDemoUtils._defaultTools);
void _removeMaterial(string name) {
private void _removeMaterial(string name)
{
if (this._selectedMaterial == name) {
this._selectedMaterial = "";
}
if (this._selectedMaterial == name) this._selectedMaterial = "";
void _removeTool(string name) {
private void _removeTool(string name)
{
string _capitalize(string name) {
private string _capitalize(string name)
{
Color _nameToColor(string name) {
// This converts a String to a unique color, based on the hash value of the
// String object. It takes the bottom 16 bits of the hash, and uses that to
// pick a hue for an HSV color, and then creates the color (with a preset
// saturation and value). This means that any unique strings will also have
// unique colors, but they'll all be readable, since they have the same
// saturation and value.
private Color _nameToColor(string name)
{
D.assert(name.Length > 1);
int hash = name.GetHashCode() & 0xffff;
float hue = (360.0f * hash / (1 << 15)) % 360.0f;

AssetImage _nameToAvatar(string name) {
private FileImage _nameToAvatar(string name)
{
return new AssetImage(
return new FileImage(
string _createResult() {
if (this._selectedAction.isEmpty()) {
return "";
}
private string _createResult()
{
if (this._selectedAction.isEmpty()) return "";
public override Widget build(BuildContext context) {
List<Widget> chips = this._materials.Select<string, Widget>((string name) => {
public override Widget build(BuildContext context)
{
List<Widget> chips = this._materials.Select<string, Widget>((string name) =>
{
key: Key.key(name),
key: new ValueKey<string>(name),
backgroundColor: this._nameToColor(name),
label: new Text(this._capitalize(name)),
onDeleted: () => { this.setState(() => { this._removeMaterial(name); }); }

List<Widget> inputChips = this._tools.Select<string, Widget>((string name) => {
List<Widget> inputChips = this._tools.Select<string, Widget>((string name) =>
{
key: ValueKey<string>.key(name),
key: new ValueKey<string>(name),
avatar: new CircleAvatar(
backgroundImage: this._nameToAvatar(name)
),

List<Widget> choiceChips = this._materials.Select<string, Widget>((string name) => {
List<Widget> choiceChips = this._materials.Select<string, Widget>((string name) =>
{
key: ValueKey<string>.key(name),
key: new ValueKey<string>(name),
onSelected: (bool value) => {
onSelected: (bool value) =>
{
List<Widget> filterChips = ChipDemoUtils._defaultTools.Select<string, Widget>((string name) => {
List<Widget> filterChips = ChipDemoUtils._defaultTools.Select<string, Widget>((string name) =>
{
key: ValueKey<string>.key(name),
key: new ValueKey<string>(name),
selected: this._tools.Contains(name) ? this._selectedTools.Contains(name) : false,
selected: this._tools.Contains(name) && this._selectedTools.Contains(name),
: (bool value) => {
this.setState(() => {
if (!value) {
: (bool value) =>
{
this.setState(() =>
{
if (!value)
}
else {
else
}
HashSet<string> allowedActions = new HashSet<string>(new List<string> { });
if (this._selectedMaterial != null && this._selectedMaterial.isNotEmpty()) {
foreach (string tool in this._selectedTools) {
allowedActions.UnionWith(ChipDemoUtils._toolActions[tool]);
}
allowedActions =
new HashSet<string>(
allowedActions.Intersect(ChipDemoUtils._materialActions[this._selectedMaterial]));
List<string> allowedActions = new List<string>();
if (this._selectedMaterial != null && this._selectedMaterial.isNotEmpty())
{
foreach (string tool in this._selectedTools) allowedActions.AddRange(ChipDemoUtils._toolActions[tool]);
allowedActions = allowedActions.Intersect(ChipDemoUtils._materialActions[this._selectedMaterial])
.ToList();
List<Widget> actionChips = allowedActions.Select<string, Widget>((string name) => {
List<Widget> actionChips = allowedActions.Select<string, Widget>((string name) =>
{
return new ActionChip(
label: new Text(this._capitalize(name)),
onPressed: () => { this.setState(() => { this._selectedAction = name; }); }

ThemeData theme = Theme.of(context);
List<Widget> tiles = new List<Widget> {
List<Widget> tiles = new List<Widget>
{
new SizedBox(height: 8.0f, width: 0.0f),
new _ChipsTile(label: "Available Materials (Chip)", children: chips),
new _ChipsTile(label: "Available Tools (InputChip)", children: inputChips),

padding: EdgeInsets.all(8.0f),
child: new Center(
child: new Text(this._createResult(),
style: theme.textTheme.title
style: theme.textTheme.headline6
)
)
)

appBar: new AppBar(
title: new Text("Chips"),
actions: new List<Widget> {
actions: new List<Widget>
{
onPressed: () => {
onPressed: () =>
{
this.setState(() => { this._showShapeBorder = !this._showShapeBorder; });
},
icon: new Icon(Icons.vignette)

borderRadius: BorderRadius.circular(10.0f)
))
: theme.chipTheme,
child: new ListView(children: tiles)
child: new Scrollbar(child: new ListView(children: tiles))
),
floatingActionButton: new FloatingActionButton(
onPressed: () => this.setState(this._reset),

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/chip_demo.cs.meta


fileFormatVersion: 2
guid: c65920c8c4b64c709b62586d0bde9579
timeCreated: 1555411023
guid: f9c596e7b509434aab8b7b7830e287ab
timeCreated: 1612425059

185
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs


using System;
using System.Collections.Generic;
using RSG;
using System.Linq;
using uiwidgets;
using UIWidgetsGallery.gallery;
using Unity.UIWidgets.async;
using Unity.UIWidgets.service;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsGallery.gallery {
class _InputDropdown : StatelessWidget {
namespace UIWidgetsGallery.demo.material
{
internal class _InputDropdown : StatelessWidget
{
Widget child = null,
VoidCallback onPressed = null,
Widget child = null
) : base(key: key) {
VoidCallback onPressed = null
) : base(key: key)
{
this.valueText = valueText;
this.valueText = valueText;
this.onPressed = onPressed;
this.child = child;
}

public readonly VoidCallback onPressed;
public readonly Widget child;
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
onTap: () => this.onPressed(),
onTap: () => this.onPressed?.Invoke(),
child: new InputDecorator(
decoration: new InputDecoration(
labelText: this.labelText

mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {
children: new List<Widget>
{
new Text(this.valueText, style: this.valueStyle),
new Icon(Icons.arrow_drop_down,
color: Theme.of(context).brightness == Brightness.light

}
}
class _DateTimePicker : StatelessWidget {
internal class _DateTimePicker : StatelessWidget
{
DateTime selectedDate,
DateTime? selectedDate = null,
ValueChanged<DateTime> selectDate = null,
ValueChanged<DateTime?> selectDate = null,
) : base(key: key) {
) : base(key: key)
{
this.selectedDate = selectedDate;
this.selectDate = selectDate;
this.selectedTime = selectedTime;
this.selectDate = selectDate;
this.selectTime = selectTime;

public readonly DateTime selectedDate;
public readonly DateTime? selectedDate;
public readonly ValueChanged<DateTime> selectDate;
public readonly ValueChanged<DateTime?> selectDate;
IPromise _selectDate(BuildContext context) {
return DatePickerUtils.showDatePicker(
private Future _selectDate(BuildContext context)
{
material_.showDatePicker(
initialDate: this.selectedDate,
firstDate: new DateTime(2015, 8, 1),
lastDate: new DateTime(2101, 1, 1)
).Then((date) => {
if (date == null) {
return;
}
initialDate: this.selectedDate.Value,
firstDate: new DateTime(2015, 8, 0),
lastDate: new DateTime(2101, 0, 0)
).then((object value) =>
{
var picked = (DateTime) value;
if (picked != null && picked != this.selectedDate) this.selectDate(picked);
});
DateTime picked = (DateTime) date;
if (picked != null && picked != this.selectedDate) {
this.selectDate(picked);
}
return null;
}
private Future _selectTime(BuildContext context)
{
TimePickerUtils.showTimePicker(
context: context,
initialTime: this.selectedTime
).then((object value) =>
{
var picked = (TimeOfDay) value;
if (picked != null && picked != this.selectedTime) this.selectTime(picked);
return null;
// Future<void> _selectTime(BuildContext context) async {
// final TimeOfDay picked = await showTimePicker(
// context: context,
// initialTime: selectedTime,
// );
// if (picked != null && picked != selectedTime)
// selectTime(picked);
// }
public override Widget build(BuildContext context) {
TextStyle valueStyle = Theme.of(context).textTheme.title;
public override Widget build(BuildContext context)
{
TextStyle valueStyle = Theme.of(context).textTheme.headline6;
children: new List<Widget> {
children: new List<Widget>
{
valueText: this.selectedDate.ToString("MM/dd/yyyy"),
valueText: this.selectedDate.Value.ToString("yyyyMMdd"),
// new Expanded(
// flex: 3,
// child: new _InputDropdown(
// valueText: this.selectedTime.format(context),
// valueStyle: valueStyle,
// onPressed: () => { this._selectTime(context); }
// )
// )
new Expanded(
flex: 3,
child: new _InputDropdown(
valueText: this.selectedTime.format(context),
valueStyle: valueStyle,
onPressed: () => { this._selectTime(context); }
)
)
public class DateAndTimePickerDemo : StatefulWidget {
public const string routeName = "/material/date-and-time-pickers";
internal class DateAndTimePickerDemo : StatefulWidget
{
public static readonly string routeName = "/material/date-and-time-pickers";
public override State createState() {
public override State createState()
{
class _DateAndTimePickerDemoState : State<DateAndTimePickerDemo> {
DateTime _fromDate = DateTime.Now;
TimeOfDay _fromTime = new TimeOfDay(hour: 7, minute: 28);
DateTime _toDate = DateTime.Now;
TimeOfDay _toTime = new TimeOfDay(hour: 7, minute: 28);
readonly List<string> _allActivities = new List<string> {"hiking", "swimming", "boating", "fishing"};
string _activity = "fishing";
public override Widget build(BuildContext context) {
var allActiviesList = new List<DropdownMenuItem<string>>();
foreach (var item in this._allActivities) {
allActiviesList.Add(
new DropdownMenuItem<string>(
value: item,
child: new Text(item)
)
);
}
internal class _DateAndTimePickerDemoState : State<DateAndTimePickerDemo>
{
private DateTime _fromDate = DateTime.Now;
private TimeOfDay _fromTime = new TimeOfDay(hour: 7, minute: 28);
private DateTime _toDate = DateTime.Now;
private TimeOfDay _toTime = new TimeOfDay(hour: 7, minute: 28);
public readonly List<string> _allActivities = new List<string> {"hiking", "swimming", "boating", "fishing"};
private string _activity = "fishing";
public override Widget build(BuildContext context)
{
return new Scaffold(
appBar: new AppBar(
title: new Text("Date and time pickers"),

bottom: false,
child: new ListView(
padding: EdgeInsets.all(16.0f),
children: new List<Widget> {
children: new List<Widget>
{
new TextField(
enabled: true,
decoration: new InputDecoration(

style: Theme.of(context).textTheme.display1
style: Theme.of(context).textTheme.headline4
style: Theme.of(context).textTheme.display1.copyWith(fontSize: 20.0f)
style: Theme.of(context).textTheme.headline4.copyWith(fontSize: 20.0f)
selectDate: (DateTime date) => { this.setState(() => { this._fromDate = date; }); },
selectDate: (DateTime? date) =>
{
this.setState(() => { this._fromDate = date.Value; });
},
selectTime: (TimeOfDay time) => { this.setState(() => { this._fromTime = time; }); }
),
new _DateTimePicker(

selectDate: (DateTime date) => { this.setState(() => { this._toDate = date; }); },
selectDate: (DateTime? date) =>
{
this.setState(() => { this._toDate = date.Value; });
},
selectTime: (TimeOfDay time) => { this.setState(() => { this._toTime = time; }); }
),
new SizedBox(height: 8.0f),

isEmpty: this._activity == null,
child: new DropdownButton<string>(
value: this._activity,
onChanged: (string newValue) => {
onChanged: (string newValue) =>
{
items: allActiviesList
items: this._allActivities.Select<string, DropdownMenuItem<string>>(
(string value) =>
{
return new DropdownMenuItem<string>(
value: value,
child: new Text(value)
);
}).ToList()
)
)
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/date_and_time_picker_demo.cs.meta


fileFormatVersion: 2
guid: d8fcf06db4da2449885ccc1f225b4808
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: acc0d8629d884dbd9670b0cb3bb3e6ec
timeCreated: 1612430045

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/modal_bottom_sheet_demo.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsGallery.gallery {
public class ModalBottomSheetDemo : StatelessWidget {

child: new RaisedButton(
child: new Text("SHOW BOTTOM SHEET"),
onPressed: () => {
BottomSheetUtils.showModalBottomSheet<object>(context: context,
material_.showModalBottomSheet<object>(context: context,
builder: (BuildContext _context) => {
return new Container(
child: new Padding(

9
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/persistent_bottom_sheet_demo.cs


using System.Collections.Generic;
using uiwidgets;
using DialogUtils = Unity.UIWidgets.material.DialogUtils;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsGallery.gallery {
public class PersistentBottomSheetDemo : StatefulWidget {

)
);
})
.closed.Then((value) => {
.closed.then((value) => {
if (this.mounted) {
this.setState(() => {
// re-enable the button

}
void _showMessage() {
DialogUtils.showDialog(
DialogUtils.showGeneralDialog<object>(
builder: (BuildContext context) => {
pageBuilder: ( context, _, __) => {
return new AlertDialog(
content: new Text("You tapped the floating action button."),
actions: new List<Widget> {

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/persistent_bottom_sheet_demo.cs.meta


fileFormatVersion: 2
guid: afb410d95c524a18b8761713f1335427
timeCreated: 1555059936
guid: c949d1ae2a444ef085b83e1a0db18cc9
timeCreated: 1612683278

19
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/search_demo.cs


using System;
using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

SearchUtils.showSearch(
context: context,
del: this._delegate
).Done((selected) => {
).then_((selected) => {
if (selected != null && (int) selected != this._lastIntegerSelected) {
this.setState(() => { this._lastIntegerSelected = (int) selected; });
}

),
floatingActionButton: FloatingActionButton.extended(
tooltip: "Back", // Tests depend on this label to exit the demo.
onPressed: () => { Navigator.of(context).pop(); },
onPressed: () => { Navigator.of(context).pop<object>(); },
label:
new Text("Close demo"),
icon:

accountName: new Text("Peter Widget"),
accountEmail: new Text("peter.widget@example.com"),
currentAccountPicture: new CircleAvatar(
backgroundImage: new AssetImage(
"people/square/peter"
backgroundImage: new FileImage(
"gallery/people/square/peter.png"
)
),
margin: EdgeInsets.zero

}
}
class _SearchDemoSearchDelegate : SearchDelegate {
class _SearchDemoSearchDelegate : SearchDelegate<int>
{
static List<int> listGenerate(int count, Func<int, int> func) {
var list = new List<int>();
for (int i = 0; i < count; i++) {

class _ResultCard : StatelessWidget {
public _ResultCard(
int integer, string title, SearchDelegate searchDelegate
int integer, string title, SearchDelegate<int> searchDelegate
) {
this.integer = integer;
this.title = title;

public readonly int integer;
public readonly string title;
public readonly SearchDelegate searchDelegate;
public readonly SearchDelegate<int> searchDelegate;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);

text: new TextSpan(
text: suggestion.Substring(0, this.query.Length),
style: theme.textTheme.subhead.copyWith(fontWeight: FontWeight.bold),
children: new List<TextSpan> {
children: new List<InlineSpan>
{
new TextSpan(
text: suggestion.Substring(this.query.Length),
style: theme.textTheme.subhead

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/search_demo.cs.meta


fileFormatVersion: 2
guid: d218ac05e5b514d148358d3cd23ff43f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 958332d4fa614f18b3d446a66cc0f93d
timeCreated: 1612682743

2
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/material/tabs_fab_demo.cs


using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsGallery.gallery {
class TabsFabDemoUtils {

11
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine.meta


fileFormatVersion: 2
guid: 2621a6f94ad8a4b5ab7199025967dc90
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: fb97b78a8c204fbb9c9dbf667cb23004
timeCreated: 1612342718

45
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine_demo.cs


using Unity.UIWidgets.animation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using System;
using UIWidgetsGallery.demo.shrine;
using Unity.UIWidgets.foundation;
namespace UIWidgetsGallery.gallery {
class ShrineDemoUtils {
public static Widget buildShrine(BuildContext context, Widget child) {
return new Theme(
data: new ThemeData(
primarySwatch: Colors.grey,
iconTheme: new IconThemeData(color: new Color(0xFF707070)),
platform: Theme.of(context).platform
),
child: new ShrineTheme(child: child)
);
}
}
namespace UIWidgetsGallery.demo
{
class ShrineDemo : StatelessWidget
{
public ShrineDemo(Key key = null) : base(key: key){}
public class ShrinePageRoute<T> : MaterialPageRoute {
public ShrinePageRoute(
WidgetBuilder builder,
RouteSettings settings
) : base(builder: builder, settings: settings) {
}
public override Widget buildPage(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) {
return ShrineDemoUtils.buildShrine(context, base.buildPage(context, animation, secondaryAnimation));
}
}
public static readonly string routeName = "/shrine";
public class ShrineDemo : StatelessWidget {
public const string routeName = "/shrine";
public override Widget build(BuildContext context) {
return ShrineDemoUtils.buildShrine(context, new ShrineHome());
public override Widget build(BuildContext context)
{
return new ShrineApp();
}
}
}

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/demo/shrine_demo.cs.meta


fileFormatVersion: 2
guid: 5902905cca7447d2aa1fe5ae7f6c5cbc
timeCreated: 1553239620
guid: b5da65292c17429ba697ebdefb05c8e4
timeCreated: 1612512022

11
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery.meta


fileFormatVersion: 2
guid: 05f67c3cc663543059f6e339e99ce4b8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 20b07a92c4c64919aa3adf9322758a65
timeCreated: 1612322595

170
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/app.cs


using System;
using System.Collections.Generic;
using System.Linq;
using RSG;
using uiwidgets;
using UIWidgetsGallery.demo.shrine.model;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.scheduler;

namespace UIWidgetsGallery.gallery {
public delegate IPromise<string> UpdateUrlFetcher();
public class GalleryApp : StatefulWidget {
public GalleryApp(
namespace UIWidgetsGallery.gallery
{
public class GalleryApp : StatefulWidget
{ public GalleryApp(
bool enablePerformanceOverlay = false,
bool enableRasterCacheImagesCheckerboard = false,
bool enableOffscreenLayersCheckerboard = false,
bool enablePerformanceOverlay = true,
bool enableRasterCacheImagesCheckerboard = true,
bool enableOffscreenLayersCheckerboard = true,
) : base(key: key) {
) : base(key: key)
{
this.updateUrlFetcher = updateUrlFetcher;
this.enablePerformanceOverlay = enablePerformanceOverlay;
this.enableRasterCacheImagesCheckerboard = enableRasterCacheImagesCheckerboard;

}
public readonly UpdateUrlFetcher updateUrlFetcher;
public override State createState() {
public override State createState()
{
class _GalleryAppState : State<GalleryApp> {
GalleryOptions _options;
Timer _timeDilationTimer;
internal class _GalleryAppState : State<GalleryApp>
{
private GalleryOptions _options;
private Timer _timeDilationTimer;
private AppStateModel model;
private Dictionary<string, WidgetBuilder> _buildRoutes()
{
Dictionary<string, WidgetBuilder> routeBulders = new Dictionary<string, WidgetBuilder>();
foreach (var demo in GalleryDemo.kAllGalleryDemos) routeBulders.Add(demo.routeName, demo.buildRoute);
Dictionary<string, WidgetBuilder> _buildRoutes() {
return DemoUtils.kAllGalleryDemos.ToDictionary(
(demo) => $"{demo.routeName}",
(demo) => demo.buildRoute);
return routeBulders;
public override void initState() {
private static readonly RuntimePlatform defaultTargetPlatform = RuntimePlatform.WindowsPlayer;
public override void initState()
{
theme: GalleryTheme.kLightGalleryTheme,
themeMode: ThemeMode.system,
timeDilation: SchedulerBinding.instance.timeDilation,
platform: Application.platform,
showPerformanceOverlay: this.widget.enablePerformanceOverlay
visualDensity: GalleryVisualDensityValue.kAllGalleryVisualDensityValues[0],
timeDilation: scheduler_.timeDilation,
platform: defaultTargetPlatform
this.model = new AppStateModel();
this.model.loadProducts();
public override void dispose() {
public override void reassemble()
{
this._options = this._options.copyWith(platform: defaultTargetPlatform);
base.reassemble();
}
public override void dispose()
{
void _handleOptionsChanged(GalleryOptions newOptions) {
this.setState(() => {
if (this._options.timeDilation != newOptions.timeDilation) {
private void _handleOptionsChanged(GalleryOptions newOptions)
{
this.setState(() =>
{
if (this._options.timeDilation != newOptions.timeDilation)
{
if (newOptions.timeDilation > 1.0f) {
this._timeDilationTimer = Window.instance.run(new TimeSpan(0, 0, 0, 0, 150),
() => { SchedulerBinding.instance.timeDilation = newOptions.timeDilation; });
} else {
SchedulerBinding.instance.timeDilation = newOptions.timeDilation;
}
if (newOptions.timeDilation > 1.0f
) // We delay the time dilation change long enough that the user can see
// that UI has started reacting and then we slam on the brakes so that
// they see that the time is in fact now dilated.
this._timeDilationTimer = Timer.create(new TimeSpan(0, 0, 0, 0, 150),
() => { scheduler_.timeDilation = newOptions.timeDilation; });
else
scheduler_.timeDilation = newOptions.timeDilation;
}
this._options = newOptions;

Widget _applyTextScaleFactor(Widget child) {
private Widget _applyTextScaleFactor(Widget child)
{
builder: context => {
builder: (BuildContext context) =>
{
return new MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaleFactor: this._options.textScaleFactor.scale

);
}
public override Widget build(BuildContext context) {
private static void defaultSendFeedback()
{
Debug.Log("hello UIWidgets !");
}
public override Widget build(BuildContext context)
{
onSendFeedback: this.widget.onSendFeedback ?? (() => {
Application.OpenURL("https://github.com/UnityTech/UIWidgets/issues");
})
),
options: this._options
onSendFeedback: this.widget.onSendFeedback ?? defaultSendFeedback
)
if (this.widget.updateUrlFetcher != null) {
if (this.widget.updateUrlFetcher != null)
}
return new MaterialApp(
theme: this._options.theme.data.copyWith(/*platform: this._options.platform*/),
title: "UIWidgets Gallery",
color: Colors.grey,
showPerformanceOverlay: this._options.showPerformanceOverlay,
//checkerboardOffscreenLayers: this._options.showOffscreenLayersCheckerboard,
//checkerboardRasterCacheImages: this._options.showRasterCacheImagesCheckerboard,
routes: this._buildRoutes(),
builder: (BuildContext _, Widget child) => this._applyTextScaleFactor(child),
home: home
return new ScopedModel<AppStateModel>(
model: this.model,
child: new MaterialApp(
theme: GalleyThemes.kLightGalleryTheme.copyWith(platform: this._options.platform,
visualDensity: this._options.visualDensity.visualDensity),
darkTheme: GalleyThemes.kDarkGalleryTheme.copyWith(platform: this._options.platform,
visualDensity: this._options.visualDensity.visualDensity),
themeMode: this._options.themeMode.Value,
title: "Flutter Gallery",
color: Colors.grey,
showPerformanceOverlay: this._options.showPerformanceOverlay,
checkerboardOffscreenLayers: this._options.showOffscreenLayersCheckerboard,
checkerboardRasterCacheImages: this._options.showRasterCacheImagesCheckerboard,
routes: this._buildRoutes(),
builder: (BuildContext subContext, Widget child) =>
{
return new Directionality(
textDirection: this._options.textDirection.Value,
child: this._applyTextScaleFactor(
// Specifically use a blank Cupertino theme here and do not transfer
// over the Material primary color etc except the brightness to
// showcase standard iOS looks.
new Builder(builder: (BuildContext context1) =>
{
return new CupertinoTheme(
data: new CupertinoThemeData(
brightness: Theme.of(context1).brightness
),
child: child
);
})
)
);
},
home: home
)
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/app.cs.meta


fileFormatVersion: 2
guid: 3fff3cf3a1dd243d088be72945a3d7e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 63b65dbf55ef42bb81d7836bd42d60c9
timeCreated: 1612341675

260
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/backdrop.cs


using Unity.UIWidgets.widgets;
using UnityEngine;
namespace UIWidgetsGallery.gallery {
class BackdropConstants {
public const float _kFrontHeadingHeight = 32.0f;
public const float _kFrontClosedHeight = 92.0f;
public const float _kBackAppBarHeight = 56.0f;
namespace UIWidgetsGallery.gallery
{
public static class GalleryBackdropUtils
{
public const float _kFrontHeadingHeight = 32.0f; // front layer beveled rectangle
public const float _kFrontClosedHeight = 92.0f; // front layer height when closed
public const float _kBackAppBarHeight = 56.0f; // back layer (options) appbar height
public static readonly Animatable<BorderRadius> _kFrontHeadingBevelRadius = new BorderRadiusTween(
begin: BorderRadius.only(

);
}
class _TappableWhileStatusIs : StatefulWidget {
internal class _TappableWhileStatusIs : StatefulWidget
{
) : base(key: key) {
) : base(key: key)
{
this.controller = controller;
this.status = status;
this.child = child;

public readonly AnimationStatus status;
public readonly Widget child;
public override State createState() {
public override State createState()
{
class _TappableWhileStatusIsState : State<_TappableWhileStatusIs> {
bool _active;
internal class _TappableWhileStatusIsState : State<_TappableWhileStatusIs>
{
private bool _active;
public override void initState() {
public override void initState()
{
public override void dispose() {
public override void dispose()
{
void _handleStatusChange(AnimationStatus status) {
private void _handleStatusChange(AnimationStatus status)
{
if (this._active != value) {
if (this._active != value)
}
public override Widget build(BuildContext context) {
return new AbsorbPointer(
public override Widget build(BuildContext context)
{
Widget child = new AbsorbPointer(
if (!this._active)
child = new FocusScope(
canRequestFocus: false,
debugLabel: "_TappableWhileStatusIs",
child: child
);
return child;
class _CrossFadeTransition : AnimatedWidget {
internal class _CrossFadeTransition : AnimatedWidget
{
public _CrossFadeTransition(
Key key = null,
Alignment alignment = null,

) : base(key: key, listenable: progress) {
this.alignment = alignment ?? Alignment.center;
) : base(key: key, listenable: progress)
{
alignment = alignment ?? Alignment.center;
this.alignment = alignment;
this.child0 = child0;
this.child1 = child1;
}

public readonly Widget child1;
protected override Widget build(BuildContext context) {
protected override Widget build(BuildContext context)
{
Animation<float> progress = this.listenable as Animation<float>;
float opacity1 = new CurvedAnimation(

return new Stack(
alignment: this.alignment,
children: new List<Widget> {
children: new List<Widget>
{
new Opacity(
opacity: opacity1,
child: this.child1

}
}
class _BackAppBar : StatelessWidget {
internal class _BackAppBar : StatelessWidget
{
) : base(key: key) {
) : base(key: key)
{
leading = leading ?? new SizedBox(width: 56.0f);
this.leading = leading ?? new SizedBox(width: 56.0f);
this.leading = leading;
this.title = title;
this.trailing = trailing;
}

public readonly Widget trailing;
public override Widget build(BuildContext context) {
List<Widget> children = new List<Widget> {
public override Widget build(BuildContext context)
{
ThemeData theme = Theme.of(context);
List<Widget> children = new List<Widget>
{
new Container(
alignment: Alignment.center,
width: 56.0f,

child: this.title
),
)
if (this.trailing != null) {
children.Add(
new Container(
alignment: Alignment.center,
width: 56.0f,
child: this.trailing
)
);
}
ThemeData theme = Theme.of(context);
if (this.trailing != null)
children.Add(new Container(
alignment: Alignment.center,
width: 56.0f,
child: this.trailing
));
style: theme.primaryTextTheme.title,
style: theme.primaryTextTheme.headline6,
height: BackdropConstants._kBackAppBarHeight,
child: new Row(children: children)
height: GalleryBackdropUtils._kBackAppBarHeight,
child: new Row(
children: children
)
)
)
);

public class Backdrop : StatefulWidget {
public class Backdrop : StatefulWidget
{
Widget frontHeading = null,
Widget frontHeading = null,
) {
)
{
this.frontHeading = frontHeading;
this.frontHeading = frontHeading;
this.backTitle = backTitle;
this.backLayer = backLayer;
}

public readonly Widget backTitle;
public readonly Widget backLayer;
public override State createState() {
public override State createState()
{
class _BackdropState : SingleTickerProviderStateMixin<Backdrop> {
GlobalKey _backdropKey = GlobalKey.key(debugLabel: "Backdrop");
AnimationController _controller;
Animation<float> _frontOpacity;
internal class _BackdropState : SingleTickerProviderStateMixin<Backdrop>
{
private GlobalKey _backdropKey = GlobalKey.key(debugLabel: "Backdrop");
private AnimationController _controller;
private Animation<float> _frontOpacity;
static Animatable<float> _frontOpacityTween = new FloatTween(begin: 0.2f, end: 1.0f)
private static readonly Animatable<float> _frontOpacityTween = new FloatTween(begin: 0.2f, end: 1.0f)
public override void initState() {
public override void initState()
{
base.initState();
this._controller = new AnimationController(
duration: new TimeSpan(0, 0, 0, 0, 300),

this._frontOpacity = this._controller.drive(_frontOpacityTween);
}
public override void dispose() {
public override void dispose()
{
float? _backdropHeight {
get {
RenderBox renderBox = (RenderBox) this._backdropKey.currentContext.findRenderObject();
private float _backdropHeight
{
get
{
// Warning: this can be safely called from the event handlers but it may
// not be called at build time.
RenderBox renderBox = this._backdropKey.currentContext.findRenderObject() as RenderBox;
renderBox.size.height - BackdropConstants._kBackAppBarHeight -
BackdropConstants._kFrontClosedHeight);
renderBox.size.height - GalleryBackdropUtils._kBackAppBarHeight -
GalleryBackdropUtils._kFrontClosedHeight);
void _handleDragUpdate(DragUpdateDetails details) {
this._controller.setValue(this._controller.value -
details.primaryDelta / (this._backdropHeight ?? details.primaryDelta) ?? 0.0f);
private void _handleDragUpdate(DragUpdateDetails details)
{
this._controller.setValue(this._controller.value - details.primaryDelta.Value / this._backdropHeight);
void _handleDragEnd(DragEndDetails details) {
if (this._controller.isAnimating || this._controller.status == AnimationStatus.completed) {
private void _handleDragEnd(DragEndDetails details)
{
if (this._controller.isAnimating || this._controller.status == AnimationStatus.completed)
}
float? flingVelocity = details.velocity.pixelsPerSecond.dy / this._backdropHeight;
if (flingVelocity < 0.0f) {
this._controller.fling(velocity: Mathf.Max(2.0f, -flingVelocity ?? 0.0f));
}
else if (flingVelocity > 0.0f) {
this._controller.fling(velocity: Mathf.Min(-2.0f, -flingVelocity ?? 0.0f));
}
else {
float flingVelocity = details.velocity.pixelsPerSecond.dy / this._backdropHeight;
if (flingVelocity < 0.0)
this._controller.fling(velocity: Mathf.Max(2.0f, -flingVelocity));
else if (flingVelocity > 0.0)
this._controller.fling(velocity: Mathf.Min(-2.0f, -flingVelocity));
else
}
void _toggleFrontLayer() {
private void _toggleFrontLayer()
{
Widget _buildStack(BuildContext context, BoxConstraints constraints) {
private Widget _buildStack(BuildContext context, BoxConstraints constraints)
{
begin: RelativeRect.fromLTRB(0.0f, constraints.biggest.height - BackdropConstants._kFrontClosedHeight,
0.0f, 0.0f),
end: RelativeRect.fromLTRB(0.0f, BackdropConstants._kBackAppBarHeight, 0.0f, 0.0f)
begin: RelativeRect.fromLTRB(0.0f,
constraints.biggest.height - GalleryBackdropUtils._kFrontClosedHeight, 0.0f, 0.0f),
end: RelativeRect.fromLTRB(0.0f, GalleryBackdropUtils._kBackAppBarHeight, 0.0f, 0.0f)
List<Widget> layers = new List<Widget> {
var children = new List<Widget>
{
children: new List<Widget> {
children: new List<Widget>
{
alignment: Alignment.centerLeft,
alignment: Alignment.center,
//alignment: AlignmentDirectional.centerStart,
child0: this.widget.frontTitle,
child1: this.widget.backTitle
),

)
),
new Expanded(
child: new Visibility(
child: this.widget.backLayer,
visible: this._controller.status != AnimationStatus.completed,
maintainState: true
child: new _TappableWhileStatusIs(
AnimationStatus.dismissed,
controller: this._controller,
child: new Visibility(
child: this.widget.backLayer,
visible: this._controller.status != AnimationStatus.completed,
maintainState: true
)
// Front layer
builder: (BuildContext _context, Widget child) => {
builder: (BuildContext subContext, Widget child) =>
{
color: Theme.of(_context).canvasColor,
color: Theme.of(subContext).canvasColor,
borderRadius: BackdropConstants._kFrontHeadingBevelRadius.evaluate(
this._controller)
borderRadius: GalleryBackdropUtils._kFrontHeadingBevelRadius.transform(
this._controller.value)
)
),
clipBehavior: Clip.antiAlias,

)
};
if (this.widget.frontHeading != null) {
layers.Add(
new PositionedTransition(
rect: frontRelativeRect,
child: new Container(
alignment: Alignment.topLeft,
child: new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: this._toggleFrontLayer,
onVerticalDragUpdate: this._handleDragUpdate,
onVerticalDragEnd: this._handleDragEnd,
child: this.widget.frontHeading
)
if (this.widget.frontHeading != null)
children.Add(new PositionedTransition(
rect: frontRelativeRect,
child: new Container(
alignment: Alignment.topLeft,
child: new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: this._toggleFrontLayer,
onVerticalDragUpdate: this._handleDragUpdate,
onVerticalDragEnd: this._handleDragEnd,
child: this.widget.frontHeading
);
}
));
children: layers
children: children
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
return new LayoutBuilder(builder: this._buildStack);
}
}

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/backdrop.cs.meta


fileFormatVersion: 2
guid: f3ee24c4986845abb1356402632d8524
timeCreated: 1552886622
guid: a1683ac7e52d43c2b016d6f38ee988ad
timeCreated: 1612334782

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


using System;
using System.Diagnostics;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.async;
using Unity.UIWidgets.service;
using UnityEngine;
namespace UIWidgetsGallery.gallery {
public class ComponentDemoTabData {
namespace UIWidgetsGallery.gallery
{
public static class BrowserUtils
{
internal static void launch(string url)
{
Process.Start(url);
}
internal static bool canLaunch(string url)
{
return true;
}
}
internal class ComponentDemoTabData : IEquatable<ComponentDemoTabData>
{
public ComponentDemoTabData(
Widget demoWidget = null,
string exampleCodeTag = null,

) {
)
{
this.demoWidget = demoWidget;
this.exampleCodeTag = exampleCodeTag;
this.description = description;

public readonly string tabName;
public readonly string documentationUrl;
public static bool operator ==(ComponentDemoTabData left, ComponentDemoTabData right) {
return left.Equals(right);
}
public bool Equals(ComponentDemoTabData other)
{
if (ReferenceEquals(null, other)) return false;
public static bool operator !=(ComponentDemoTabData left, ComponentDemoTabData right) {
return !left.Equals(right);
}
if (ReferenceEquals(this, other)) return true;
public bool Equals(ComponentDemoTabData other) {
return other.tabName == this.tabName
&& other.description == this.description
&& other.documentationUrl == this.documentationUrl;
return this.tabName.Equals(other.tabName)
&& this.description.Equals(other.description)
&& this.documentationUrl.Equals(other.documentationUrl);
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) {
return true;
}
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) {
return false;
}
if (obj.GetType() != this.GetType()) return false;
public override int GetHashCode() {
unchecked {
var hashCode = this.tabName.GetHashCode();
public override int GetHashCode()
{
unchecked
{
var hashCode = (this.tabName.GetHashCode() * 397);
public static bool operator ==(ComponentDemoTabData left, ComponentDemoTabData right)
{
return Equals(left, right);
}
public static bool operator !=(ComponentDemoTabData left, ComponentDemoTabData right)
{
return !Equals(left, right);
}
public class TabbedComponentDemoScaffold : StatelessWidget {
internal class TabbedComponentDemoScaffold : StatelessWidget
{
string title = null,
List<ComponentDemoTabData> demos = null,
List<Widget> actions = null
) {
List<ComponentDemoTabData> demos,
string title,
List<Widget> actions = null,
bool isScrollable = true,
bool showExampleCodeAction = true
)
{
this.isScrollable = isScrollable;
this.showExampleCodeAction = showExampleCodeAction;
public readonly bool isScrollable;
public readonly bool showExampleCodeAction;
void _showExampleCode(BuildContext context) {
private void _showExampleCode(BuildContext context)
{
if (tag != null) {
Navigator.push(context, new MaterialPageRoute(
builder: (BuildContext _context) => new FullScreenCodeDialog(exampleCodeTag: tag)
));
}
if (tag != null) D.assert(false, () => "TO DO >>>");
/*Navigator.push(context, MaterialPageRoute<FullScreenCodeDialog>(
builder: (BuildContext context) => FullScreenCodeDialog(exampleCodeTag: tag)
));*/
void _showApiDocumentation(BuildContext context) {
private Future _showApiDocumentation(BuildContext context)
{
if (url != null) {
Application.OpenURL(url);
}
if (url == null)
return null;
if (BrowserUtils.canLaunch(url))
BrowserUtils.launch(url);
else
material_.showDialog<object>(
context: context,
builder: (BuildContext subContext) =>
{
return new SimpleDialog(
title: new Text("Couldn't display URL:"),
children: new List<Widget>
{
new Padding(
padding: EdgeInsets.symmetric(horizontal: 16.0f),
child: new Text(url)
)
}
);
}
);
return null;
public override Widget build(BuildContext context) {
List<Widget> actions = this.actions ?? new List<Widget> { };
actions.AddRange(
new List<Widget> {
new Builder(
builder: (BuildContext _context) => {
return new IconButton(
icon: new Icon(Icons.library_books),
onPressed: () => this._showApiDocumentation(_context)
);
}
),
new Builder(
builder: (BuildContext _context) => {
return new IconButton(
icon: new Icon(Icons.code),
tooltip: "Show example code",
onPressed: () => this._showExampleCode(_context)
);
}
)
}
public override Widget build(BuildContext context)
{
var children = new List<Widget>();
if (actions != null)
{
children.AddRange(actions);
}
children.Add(new Builder(
builder: (BuildContext subContext) =>
{
return new IconButton(
icon: new Icon(Icons.library_books),
onPressed: () => this._showApiDocumentation(context)
);
}
)
if (this.showExampleCodeAction)
children.Add(new Builder(
builder: (BuildContext subContext) =>
{
return new IconButton(
icon: new Icon(Icons.code),
tooltip: "Show example code",
onPressed: () => this._showExampleCode(context)
);
}
));
actions: actions,
actions: children,
isScrollable: true,
tabs: this.demos.Select<ComponentDemoTabData, Widget>(
(ComponentDemoTabData data) => new Tab(text: data.tabName))
.ToList()
isScrollable: this.isScrollable,
tabs: this.demos.Select<ComponentDemoTabData, Widget>((ComponentDemoTabData data) =>
new Tab(text: data.tabName)).ToList()
children: this.demos.Select<ComponentDemoTabData, Widget>((ComponentDemoTabData demo) => {
children: this.demos.Select<ComponentDemoTabData, Widget>((ComponentDemoTabData demo) =>
{
children: new List<Widget> {
children: new List<Widget>
{
style: Theme.of(context).textTheme.subhead
style: Theme.of(context).textTheme.subtitle1
)
),
new Expanded(child: demo.demoWidget)

}
}
public class FullScreenCodeDialog : StatefulWidget {
public FullScreenCodeDialog(Key key = null, string exampleCodeTag = null) : base(key: key) {
this.exampleCodeTag = exampleCodeTag;
}
public readonly string exampleCodeTag;
public override State createState() {
return new FullScreenCodeDialogState();
}
}
public class FullScreenCodeDialogState : State<FullScreenCodeDialog> {
public FullScreenCodeDialogState() { }
string _exampleCode;
public override void didChangeDependencies() {
base.didChangeDependencies();
string code =
new ExampleCodeParser().getExampleCode(this.widget.exampleCodeTag, DefaultAssetBundle.of(this.context));
if (this.mounted) {
this.setState(() => { this._exampleCode = code; });
}
}
public override Widget build(BuildContext context) {
SyntaxHighlighterStyle style = Theme.of(context).brightness == Brightness.dark
? SyntaxHighlighterStyle.darkThemeStyle()
: SyntaxHighlighterStyle.lightThemeStyle();
Widget body;
if (this._exampleCode == null) {
body = new Center(
child: new CircularProgressIndicator()
);
}
else {
body = new SingleChildScrollView(
child: new Padding(
padding: EdgeInsets.all(16.0f),
child: new RichText(
text: new TextSpan(
style: new TextStyle(fontFamily: "monospace", fontSize: 10.0f),
children: new List<TextSpan> {
new DartSyntaxHighlighter(style).format(this._exampleCode)
}
)
)
)
);
}
return new Scaffold(
appBar: new AppBar(
leading: new IconButton(
icon: new Icon(
Icons.clear
),
onPressed: () => { Navigator.pop(context); }
),
title: new Text("Example code")
),
body: body
);
}
}
class MaterialDemoDocumentationButton : StatelessWidget {
public MaterialDemoDocumentationButton(string routeName, Key key = null) : base(key: key) {
this.documentationUrl = DemoUtils.kDemoDocumentationUrl[routeName];
D.assert(DemoUtils.kDemoDocumentationUrl[routeName] != null,
internal class MaterialDemoDocumentationButton : StatelessWidget
{
internal MaterialDemoDocumentationButton(string routeName, Key key = null) : base(key: key)
{
D.assert(
GalleryDemo.kDemoDocumentationUrl[routeName] != null,
this.documentationUrl = GalleryDemo.kDemoDocumentationUrl[routeName];
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
onPressed: () => Application.OpenURL(this.documentationUrl)
);
}
}
class CupertinoDemoDocumentationButton : StatelessWidget {
public CupertinoDemoDocumentationButton(
string routeName,
Key key = null
) : base(key: key) {
this.documentationUrl = DemoUtils.kDemoDocumentationUrl[routeName];
D.assert(
DemoUtils.kDemoDocumentationUrl[routeName] != null,
() => $"A documentation URL was not specified for demo route {routeName} in kAllGalleryDemos"
);
}
public readonly string documentationUrl;
public override Widget build(BuildContext context) {
return new CupertinoButton(
padding: EdgeInsets.zero,
child: new Icon(CupertinoIcons.book),
onPressed: () => Application.OpenURL(this.documentationUrl)
onPressed: () => BrowserUtils.launch(this.documentationUrl)
);
}
}

4
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demo.cs.meta


fileFormatVersion: 2
guid: 3c8404e1b03d43aba2e91d19f124de5e
timeCreated: 1552462303
guid: a66930d03e874eb0ba49812d9c1f952f
timeCreated: 1612409591

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


using System;
using UIWidgetsGallery.demo;
using UIWidgetsGallery.demo.material;
using Unity.UIWidgets.external;
namespace UIWidgetsGallery.gallery {
public class GalleryDemoCategory : IEquatable<GalleryDemoCategory> {
public GalleryDemoCategory(string name = null, IconData icon = null) {
D.assert(name != null);
D.assert(icon != null);
namespace UIWidgetsGallery.gallery
{
public class GalleryDemoCategory
{
public GalleryDemoCategory(
string name,
IconData icon)
{
public bool Equals(GalleryDemoCategory other) {
if (ReferenceEquals(null, other)) {
return false;
}
public bool Equals(GalleryDemoCategory other)
{
if (ReferenceEquals(this, other)) return true;
if (ReferenceEquals(this, other)) {
return true;
}
if (ReferenceEquals(other, null)) return false;
return string.Equals(this.name, other.name) && Equals(this.icon, other.icon);
return icon.Equals(other.icon) && name == other.name;
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) {
return false;
}
if (ReferenceEquals(obj, null)) return false;
return this.Equals((GalleryDemoCategory) obj);
}
if (obj.GetType() != GetType()) return false;
public override int GetHashCode() {
unchecked {
return ((this.name != null ? this.name.GetHashCode() : 0) * 397) ^
(this.icon != null ? this.icon.GetHashCode() : 0);
}
return Equals((GalleryDemoCategory) obj);
public static bool operator ==(GalleryDemoCategory left, GalleryDemoCategory right) {
public static bool operator ==(GalleryDemoCategory left, GalleryDemoCategory right)
{
public static bool operator !=(GalleryDemoCategory left, GalleryDemoCategory right) {
public static bool operator !=(GalleryDemoCategory left, GalleryDemoCategory right)
{
public override string ToString() {
return $"{this.GetType()}({this.name})";
public override int GetHashCode()
{
unchecked
{
return ((icon?.GetHashCode() ?? 0) * 397) ^ (name?.GetHashCode() ?? 0);
}
}
public override string ToString()
{
return $"{GetType()}{name}";
}
public static partial class DemoUtils {
internal static readonly GalleryDemoCategory _kDemos = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kDemos = new GalleryDemoCategory(
internal static readonly GalleryDemoCategory _kStyle = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kStyle = new GalleryDemoCategory(
internal static readonly GalleryDemoCategory _kMaterialComponents = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kMaterialComponents = new GalleryDemoCategory(
internal static readonly GalleryDemoCategory _kCupertinoComponents = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kCupertinoComponents = new GalleryDemoCategory(
internal static readonly GalleryDemoCategory _kMedia = new GalleryDemoCategory(
public static readonly GalleryDemoCategory _kMedia = new GalleryDemoCategory(
public class GalleryDemo {
internal class GalleryDemo
{
public GalleryDemo(
string title = null,
IconData icon = null,

string documentationUrl = null,
WidgetBuilder buildRoute = null
) {
)
{
D.assert(icon != null);
this.title = title;
this.icon = icon;
this.subtitle = subtitle;

public readonly string subtitle;
public readonly GalleryDemoCategory category;
public readonly string routeName;
public readonly string documentationUrl;
public readonly string documentationUrl;
public override string ToString() {
return $"{this.GetType()}({this.title} {this.routeName})";
public override string ToString()
{
return $"{GetType()}({title} {routeName})";
}
public static partial class DemoUtils {
static List<GalleryDemo> _buildGalleryDemos() {
List<GalleryDemo> galleryDemos = new List<GalleryDemo> {
// Demos
public static List<GalleryDemo> _buildGalleryDemos()
{
List<GalleryDemo> galleryDemos = new List<GalleryDemo>()
{
title: "Shrine",
subtitle: "Basic shopping app",
icon: GalleryIcons.shrine,
category: _kDemos,
routeName: ShrineDemo.routeName,
buildRoute: (BuildContext context) => new ShrineDemo()
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: "Contact profile",
subtitle: "Address book entry with a flexible appbar",
icon: GalleryIcons.account_box,
category: _kDemos,
routeName: ContactsDemo.routeName,
buildRoute: (BuildContext context) => new ContactsDemo()
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: "Animation",
subtitle: "Section organizer",
icon: GalleryIcons.animation,
category: _kDemos,
routeName: AnimationDemo.routeName,
buildRoute: (BuildContext context) => new AnimationDemo()
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()
// Style
new GalleryDemo(
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()
),
new GalleryDemo(
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: "Colors",
subtitle: "All of the predefined colors",
icon: GalleryIcons.colors,
category: _kStyle,
routeName: ColorsDemo.routeName,
buildRoute: (BuildContext context) => new ColorsDemo()
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: "Typography",
subtitle: "All of the predefined text styles",
icon: GalleryIcons.custom_typography,
category: _kStyle,
routeName: TypographyDemo.routeName,
buildRoute: (BuildContext context) => new TypographyDemo()
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()
// Material Components
new GalleryDemo(
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()
),
new GalleryDemo(
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()
),
new GalleryDemo(
title: "Text Fields",
icon: GalleryIcons.text_fields_alt,
category: GalleryDemoCategory._kCupertinoComponents,
routeName: CupertinoTextFieldDemo.routeName,
buildRoute: (BuildContext context) => new CupertinoTextFieldDemo()
),
new GalleryDemo(
title: "Shrine",
subtitle: "Basic shopping app",
icon: GalleryIcons.shrine,
category: GalleryDemoCategory._kDemos,
routeName: ShrineDemo.routeName,
buildRoute: (BuildContext context) => new ShrineDemo()
),
subtitle: "Select a front layer from back layer",
subtitle: $"Select a front layer from back layer",
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
title: "Banner",
subtitle: "Displaying a banner within a list",
icon: GalleryIcons.lists_leave_behind,
category: GalleryDemoCategory._kMaterialComponents,
routeName: BannerDemo.routeName,
documentationUrl: "https://api.flutter.dev/flutter/material/MaterialBanner-class.html",
buildRoute: (BuildContext context) => new BannerDemo()
),
new GalleryDemo(
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
routeName: BottomAppBarDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/BottomAppBar-class.html",
buildRoute: (BuildContext context) => new BottomAppBarDemo()

subtitle: "Bottom navigation with cross-fading views",
icon: GalleryIcons.bottom_navigation,
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
routeName: BottomNavigationDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/BottomNavigationBar-class.html",
buildRoute: (BuildContext context) => new BottomNavigationDemo()

subtitle: "A dismissable bottom sheet",
icon: GalleryIcons.bottom_sheets,
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
routeName: ModalBottomSheetDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/showModalBottomSheet.html",
buildRoute: (BuildContext context) => new ModalBottomSheetDemo()

subtitle: "A bottom sheet that sticks around",
icon: GalleryIcons.bottom_sheet_persistent,
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
routeName: PersistentBottomSheetDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/ScaffoldState/showBottomSheet.html",
buildRoute: (BuildContext context) => new PersistentBottomSheetDemo()

subtitle: "Flat, raised, dropdown, and more",
icon: GalleryIcons.generic_buttons,
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
title: "Cards",
subtitle: "Baseline cards with rounded corners",
icon: GalleryIcons.cards,
category: GalleryDemoCategory._kMaterialComponents,
routeName: CardsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/Card-class.html",
buildRoute: (BuildContext context) => new CardsDemo()
),
new GalleryDemo(
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
title: "Cards",
subtitle: "Baseline cards with rounded corners",
icon: GalleryIcons.cards,
category: _kMaterialComponents,
routeName: CardsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/Card-class.html",
buildRoute: (BuildContext context) => new CardsDemo()
),
new GalleryDemo(
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
// new GalleryDemo(
// title: "Data tables",
// subtitle: "Rows and columns",
// icon: GalleryIcons.data_table,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: DataTableDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/PaginatedDataTable-class.html",
// buildRoute: (BuildContext context) => DataTableDemo()
// ),
// new GalleryDemo(
// title: "Dialogs",
// subtitle: "Simple, alert, and fullscreen",
// icon: GalleryIcons.dialogs,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: DialogDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/showDialog.html",
// buildRoute: (BuildContext context) => DialogDemo()
// ),
// new GalleryDemo(
// title: "Elevations",
// subtitle: "Shadow values on cards",
// // TODO(larche): Change to custom icon for elevations when one exists.
// icon: GalleryIcons.cupertino_progress,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: ElevationDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/Material/elevation.html",
// buildRoute: (BuildContext context) => ElevationDemo()
// ),
// new GalleryDemo(
// title: "Expand/collapse list control",
// subtitle: "A list with one sub-list level",
// icon: GalleryIcons.expand_all,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: TwoLevelListDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/ExpansionTile-class.html",
// buildRoute: (BuildContext context) => TwoLevelListDemo()
// ),
// new GalleryDemo(
// title: "Expansion panels",
// subtitle: "List of expanding panels",
// icon: GalleryIcons.expand_all,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: ExpansionPanelsDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/ExpansionPanel-class.html",
// buildRoute: (BuildContext context) => ExpansionPanelsDemo()
// ),
// new GalleryDemo(
// title: "Grid",
// subtitle: "Row and column layout",
// icon: GalleryIcons.grid_on,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: GridListDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/widgets/GridView-class.html",
// buildRoute: (BuildContext context) => new GridListDemo()
// ),
// new GalleryDemo(
// title: "Icons",
// subtitle: "Enabled and disabled icons with opacity",
// icon: GalleryIcons.sentiment_very_satisfied,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: IconsDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/IconButton-class.html",
// buildRoute: (BuildContext context) => IconsDemo()
// ),
// new GalleryDemo(
// title: "Lists",
// subtitle: "Scrolling list layouts",
// icon: GalleryIcons.list_alt,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: ListDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/ListTile-class.html",
// buildRoute: (BuildContext context) => new ListDemo()
// ),
// new GalleryDemo(
// title: "Lists: leave-behind list items",
// subtitle: "List items with hidden actions",
// icon: GalleryIcons.lists_leave_behind,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: LeaveBehindDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/widgets/Dismissible-class.html",
// buildRoute: (BuildContext context) => new LeaveBehindDemo()
// ),
// new GalleryDemo(
// title: "Lists: reorderable",
// subtitle: "Reorderable lists",
// icon: GalleryIcons.list_alt,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: ReorderableListDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/ReorderableListView-class.html",
// buildRoute: (BuildContext context) => new ReorderableListDemo()
// ),
// new GalleryDemo(
// title: "Menus",
// subtitle: "Menu buttons and simple menus",
// icon: GalleryIcons.more_vert,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: MenuDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/PopupMenuButton-class.html",
// buildRoute: (BuildContext context) => new MenuDemo()
// ),
// new GalleryDemo(
// title: "Navigation drawer",
// subtitle: "Navigation drawer with standard header",
// icon: GalleryIcons.menu,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: DrawerDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/Drawer-class.html",
// buildRoute: (BuildContext context) => DrawerDemo()
// ),
// new GalleryDemo(
// title: "Pagination",
// subtitle: "PageView with indicator",
// icon: GalleryIcons.page_control,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: PageSelectorDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/TabBarView-class.html",
// buildRoute: (BuildContext context) => PageSelectorDemo()
// ),
title: "Pickers",
subtitle: "Date and time selection widgets",
icon: GalleryIcons.@event,
category: _kMaterialComponents,
routeName: DateAndTimePickerDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/showDatePicker.html",
buildRoute: (BuildContext context) => new DateAndTimePickerDemo()
title: "Data tables",
subtitle: "Rows and columns",
icon: GalleryIcons.data_table,
category: GalleryDemoCategory._kMaterialComponents,
routeName: DataTableDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/PaginatedDataTable-class.html",
buildRoute: (BuildContext context) => new DataTableDemo()
),
new GalleryDemo(
title: "Pull to refresh",
subtitle: "Refresh indicators",
icon: GalleryIcons.refresh,
category: GalleryDemoCategory._kMaterialComponents,
routeName: OverscrollDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/RefreshIndicator-class.html",
buildRoute: (BuildContext context) => new OverscrollDemo()
// new GalleryDemo(
// title: "Progress indicators",
// subtitle: "Linear, circular, indeterminate",
// icon: GalleryIcons.progress_activity,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: ProgressIndicatorDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/LinearProgressIndicator-class.html",
// buildRoute: (BuildContext context) => ProgressIndicatorDemo()
// ),
// new GalleryDemo(
// title: "Pull to refresh",
// subtitle: "Refresh indicators",
// icon: GalleryIcons.refresh,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: OverscrollDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/RefreshIndicator-class.html",
// buildRoute: (BuildContext context) => OverscrollDemo()
// ),
category: _kMaterialComponents,
category: GalleryDemoCategory._kMaterialComponents,
// new GalleryDemo(
// title: "Selection controls",
// subtitle: "Checkboxes, radio buttons, and switches",
// icon: GalleryIcons.check_box,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: SelectionControlsDemo.routeName,
// buildRoute: (BuildContext context) => SelectionControlsDemo()
// ),
// new GalleryDemo(
// title: "Sliders",
// subtitle: "Widgets for selecting a value by swiping",
// icon: GalleryIcons.sliders,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: SliderDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/Slider-class.html",
// buildRoute: (BuildContext context) => SliderDemo()
// ),
// new GalleryDemo(
// title: "Snackbar",
// subtitle: "Temporary messaging",
// icon: GalleryIcons.snackbar,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: SnackBarDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/ScaffoldState/showSnackBar.html",
// buildRoute: (BuildContext context) => SnackBarDemo()
// ),
// new GalleryDemo(
// title: "Tabs",
// subtitle: "Tabs with independently scrollable views",
// icon: GalleryIcons.tabs,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: TabsDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/TabBarView-class.html",
// buildRoute: (BuildContext context) => TabsDemo()
// ),
// 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) => ScrollableTabsDemo()
// ),
// new GalleryDemo(
// title: "Text fields",
// subtitle: "Single line of editable text and numbers",
// icon: GalleryIcons.text_fields_alt,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: TextFormFieldDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/TextFormField-class.html",
// buildRoute: (BuildContext context) => const TextFormFieldDemo()
// ),
// new GalleryDemo(
// title: "Tooltips",
// subtitle: "Short message displayed on long-press",
// icon: GalleryIcons.tooltip,
// category: GalleryDemoCategory._kMaterialComponents,
// routeName: TooltipDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/material/Tooltip-class.html",
// buildRoute: (BuildContext context) => TooltipDemo()
// ),
//
// Cupertino Components
// new GalleryDemo(
// title: "Activity Indicator",
// icon: GalleryIcons.cupertino_progress,
// category: _kCupertinoComponents,
// routeName: CupertinoProgressIndicatorDemo.routeName,
// documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoActivityIndicator-class.html",
// buildRoute: (BuildContext context) => CupertinoProgressIndicatorDemo()
// ),
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: "Sliders",
subtitle: "Widgets for selecting a value by swiping",
icon: GalleryIcons.sliders,
category: GalleryDemoCategory._kMaterialComponents,
routeName: SliderDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/Slider-class.html",
buildRoute: (BuildContext context) => new SliderDemo()
),
new GalleryDemo(
title: "Snackbar",
subtitle: "Temporary messaging",
icon: GalleryIcons.snackbar,
category: GalleryDemoCategory._kMaterialComponents,
routeName: SnackBarDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/ScaffoldState/showSnackBar.html",
buildRoute: (BuildContext context) => new SnackBarDemo()
),
title: "Alerts",
title: "Tabs",
subtitle: "Tabs with independently scrollable views",
icon: GalleryIcons.tabs,
category: GalleryDemoCategory._kMaterialComponents,
routeName: TabsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/TabBarView-class.html",
buildRoute: (BuildContext context) => new TabsDemo()
),
new GalleryDemo(
title: "Dialogs",
subtitle: "Simple, alert, and fullscreen",
category: _kCupertinoComponents,
routeName: CupertinoAlertDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/showCupertinoDialog.html",
buildRoute: (BuildContext context) => new CupertinoAlertDemo()
category: GalleryDemoCategory._kMaterialComponents,
routeName: DialogDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/showDialog.html",
buildRoute: (BuildContext context) => new DialogDemo()
title: "Buttons",
icon: GalleryIcons.generic_buttons,
category: _kCupertinoComponents,
routeName: CupertinoButtonsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoButton-class.html",
buildRoute: (BuildContext context) => new CupertinoButtonsDemo()
title: "Elevations",
subtitle: "Shadow values on cards",
// TODO(larche): Change to custom icon for elevations when one exists.
icon: GalleryIcons.cupertino_progress,
category: GalleryDemoCategory._kMaterialComponents,
routeName: ElevationDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/Material/elevation.html",
buildRoute: (BuildContext context) => new ElevationDemo()
title: "Navigation",
icon: GalleryIcons.bottom_navigation,
category: _kCupertinoComponents,
routeName: CupertinoNavigationDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoTabScaffold-class.html",
buildRoute: (BuildContext context) => new CupertinoNavigationDemo()
title: "Navigation drawer",
subtitle: "Navigation drawer with standard header",
icon: GalleryIcons.menu,
category: GalleryDemoCategory._kMaterialComponents,
routeName: DrawerDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/Drawer-class.html",
buildRoute: (BuildContext context) => new DrawerDemo()
title: "Pickers",
icon: GalleryIcons.@event,
category: _kCupertinoComponents,
routeName: CupertinoPickerDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoPicker-class.html",
buildRoute: (BuildContext context) => new CupertinoPickerDemo()
title: "Expansion panels",
subtitle: "List of expanding panels",
icon: GalleryIcons.expand_all,
category: GalleryDemoCategory._kMaterialComponents,
routeName: ExpansionPanelsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/ExpansionPanel-class.html",
buildRoute: (BuildContext context) => new ExpansionPanelsDemo()
// new GalleryDemo(
// title: "Pull to refresh",
// icon: GalleryIcons.cupertino_pull_to_refresh,
// category: _kCupertinoComponents,
// routeName: CupertinoRefreshControlDemo.routeName,
// documentationUrl:
// "https://docs.flutter.io/flutter/cupertino/CupertinoSliverRefreshControl-class.html",
// buildRoute: (BuildContext context) => CupertinoRefreshControlDemo()
// ),
// new GalleryDemo(
// 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) => CupertinoSegmentedControlDemo()
// ),
title: "Sliders",
icon: GalleryIcons.sliders,
category: _kCupertinoComponents,
routeName: CupertinoSliderDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSlider-class.html",
buildRoute: (BuildContext context) => new CupertinoSliderDemo()
title: "Grid",
subtitle: "Row and column layout",
icon: GalleryIcons.grid_on,
category: GalleryDemoCategory._kMaterialComponents,
routeName: GridListDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/widgets/GridView-class.html",
buildRoute: (BuildContext context) => new GridListDemo()
title: "Switches",
icon: GalleryIcons.cupertino_switch,
category: _kCupertinoComponents,
routeName: CupertinoSwitchDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/cupertino/CupertinoSwitch-class.html",
buildRoute: (BuildContext context) => new CupertinoSwitchDemo()
title: "Icons",
subtitle: "Enabled and disabled icons with opacity",
icon: GalleryIcons.sentiment_very_satisfied,
category: GalleryDemoCategory._kMaterialComponents,
routeName: IconsDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/IconButton-class.html",
buildRoute: (BuildContext context) => new IconsDemo()
title: "Text Fields",
title: "Lists",
subtitle: "Scrolling list layouts",
icon: GalleryIcons.list_alt,
category: GalleryDemoCategory._kMaterialComponents,
routeName: ListDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/ListTile-class.html",
buildRoute: (BuildContext context) => new ListDemo()
),
new GalleryDemo(
title: "Lists: leave-behind list items",
subtitle: "List items with hidden actions",
icon: GalleryIcons.lists_leave_behind,
category: GalleryDemoCategory._kMaterialComponents,
routeName: LeaveBehindDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/widgets/Dismissible-class.html",
buildRoute: (BuildContext context) => new LeaveBehindDemo()
),
new GalleryDemo(
title: "Lists: reorderable",
subtitle: "Reorderable lists",
icon: GalleryIcons.list_alt,
category: GalleryDemoCategory._kMaterialComponents,
routeName: ReorderableListDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/ReorderableListView-class.html",
buildRoute: (BuildContext context) => new ReorderableListDemo()
),
new GalleryDemo(
title: "Menus",
subtitle: "Menu buttons and simple menus",
icon: GalleryIcons.more_vert,
category: GalleryDemoCategory._kMaterialComponents,
routeName: MenuDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/PopupMenuButton-class.html",
buildRoute: (BuildContext context) => new MenuDemo()
),
new GalleryDemo(
title: "Pagination",
subtitle: "PageView with indicator",
icon: GalleryIcons.page_control,
category: GalleryDemoCategory._kMaterialComponents,
routeName: PageSelectorDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/TabBarView-class.html",
buildRoute: (BuildContext context) => new PageSelectorDemo()
),
new GalleryDemo(
title: "Progress indicators",
subtitle: "Linear, circular, indeterminate",
icon: GalleryIcons.progress_activity,
category: GalleryDemoCategory._kMaterialComponents,
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 GalleryDemo(
title: "Text fields",
subtitle: "Single line of editable text and numbers",
category: _kCupertinoComponents,
routeName: CupertinoTextFieldDemo.routeName,
buildRoute: (BuildContext context) => new CupertinoTextFieldDemo()
category: GalleryDemoCategory._kMaterialComponents,
routeName: TextFormFieldDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/TextFormField-class.html",
buildRoute: (BuildContext context) => new TextFormFieldDemo()
//
// // Media
// new GalleryDemo(
// title: "Animated images",
// subtitle: "GIF and WebP animations",
// icon: GalleryIcons.animation,
// category: GalleryDemoCategory._kMedia,
// routeName: ImagesDemo.routeName,
// buildRoute: (BuildContext context) => ImagesDemo()
// ),
// new GalleryDemo(
// title: "Video",
// subtitle: "Video playback",
// icon: GalleryIcons.drive_video,
// category: GalleryDemoCategory._kMedia,
// routeName: VideoDemo.routeName,
// buildRoute: (BuildContext context) => new VideoDemo()
// ),
new GalleryDemo(
title: "Tooltips",
subtitle: "Short message displayed on long-press",
icon: GalleryIcons.tooltip,
category: GalleryDemoCategory._kMaterialComponents,
routeName: TooltipDemo.routeName,
documentationUrl: "https://docs.flutter.io/flutter/material/Tooltip-class.html",
buildRoute: (BuildContext context) => new TooltipDemo()
)
// Keep Pesto around for its regression test value. It is not included
// in (release builds) the performance tests.
D.assert(() => {
// galleryDemos.Insert(0,
// new GalleryDemo(
// title: "Pesto",
// subtitle: "Simple recipe browser",
// icon: Icons.adjust,
// category: GalleryDemoCategory._kDemos,
// routeName: PestoDemo.routeName,
// buildRoute: (BuildContext context) => new PestoDemo()
// )
// );
return true;
});
return galleryDemos;
}

new HashSet<GalleryDemoCategory>(kAllGalleryDemos.Select(demo => demo.category));
new HashSet<GalleryDemoCategory>(kAllGalleryDemos
.Select<GalleryDemo, GalleryDemoCategory>((GalleryDemo demo) => demo.category).ToList());
private static Dictionary<GalleryDemoCategory, List<GalleryDemo>> _generateCategoryToDemos()
{
Dictionary<GalleryDemoCategory, List<GalleryDemo>> result =
new Dictionary<GalleryDemoCategory, List<GalleryDemo>>();
foreach (var category in kAllGalleryDemoCategories)
result.Add(category,
LinqUtils<GalleryDemo>.WhereList(kAllGalleryDemos,((GalleryDemo demo) => { return demo.category == category; })));
return result;
}
kAllGalleryDemoCategories.ToDictionary(
category => category,
category => kAllGalleryDemos.Where(demo => demo.category == category).ToList()
);
_generateCategoryToDemos();
public static readonly Dictionary<string, string> kDemoDocumentationUrl =
kAllGalleryDemos.Where(demo => demo.documentationUrl != null).ToDictionary(
demo => demo.routeName,
demo => demo.documentationUrl
);
private static Dictionary<string, string> _generateDemoDocumentationUrls()
{
Dictionary<string, string> result = new Dictionary<string, string>();
foreach (var demo in kAllGalleryDemos)
if (demo.documentationUrl != null)
result.Add(demo.routeName, demo.documentationUrl);
return result;
}
public static readonly Dictionary<string, string> kDemoDocumentationUrl = _generateDemoDocumentationUrls();
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/demos.cs.meta


fileFormatVersion: 2
guid: b079397083e3d41bb83262e1423dfa25
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: beaf8ef32d5a4e4b847b0626276b30ca
timeCreated: 1612337523

304
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs


using System;
using System.Collections.Generic;
using System.Linq;
using RSG;
using uiwidgets;
using Unity.UIWidgets.async;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace UIWidgetsGallery.gallery {
public static class HomeUtils {
internal static readonly Color _kUIWidgetsBlue = new Color(0xFF003D75);
internal const float _kDemoItemHeight = 64.0f;
internal static TimeSpan _kFrontLayerSwitchDuration = new TimeSpan(0, 0, 0, 0, 300);
}
class _UIWidgetsLogo : StatelessWidget {
public _UIWidgetsLogo(Key key = null, bool isDark = false) : base(key: key) {
this._isDark = isDark;
}
readonly bool _isDark;
public override Widget build(BuildContext context) {
return new Center(
child: new Container(
width: 34.0f,
height: 34.0f,
decoration: new BoxDecoration(
image: new DecorationImage(
image: new AssetImage(
this._isDark ? "unity-black" : "unity-white")
)
)
)
);
}
namespace UIWidgetsGallery.gallery
{
public static class GalleryHomeUtils
{
public static readonly string _kGalleryAssetsPackage = "uiwdigets_gallery_assets";
public static readonly Color _kFlutterBlue = new Color(0xFF003D75);
public const float _kDemoItemHeight = 64.0f;
public static readonly TimeSpan _kFrontLayerSwitchDuration = new TimeSpan(0, 0, 0, 0, 300);
class _CategoryItem : StatelessWidget {
internal class _CategoryItem : StatelessWidget
{
) : base(key: key) {
) : base(key: key)
{
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
// This repaint boundary prevents the entire _CategoriesPage from being
// repainted when the button's ink splash animates.
hoverColor: theme.primaryColor.withOpacity(0.05f),
splashColor: theme.primaryColor.withOpacity(0.12f),
highlightColor: Colors.transparent,
onPressed: this.onTap,

children: new List<Widget> {
children: new List<Widget>
{
child: new Icon(
this.category.icon,
child: new Icon(this.category.icon,
color: isDark ? Colors.white : HomeUtils._kUIWidgetsBlue
color: isDark ? Colors.white : GalleryHomeUtils._kFlutterBlue
)
),
new SizedBox(height: 10.0f),

child: new Text(
this.category.name,
child: new Text(this.category.name,
style: theme.textTheme.subhead.copyWith(
fontFamily: "GoogleSans",
color: isDark ? Colors.white : HomeUtils._kUIWidgetsBlue
style: theme.textTheme.subtitle1.copyWith(
color: isDark ? Colors.white : GalleryHomeUtils._kFlutterBlue
)
)
)

}
}
class _CategoriesPage : StatelessWidget {
internal class _CategoriesPage : StatelessWidget
{
) : base(key: key) {
) : base(key: key)
{
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
key: new PageStorageKey<string>("categories"),
key: Key.key("categories"),
builder: (_, constraints) => {
builder: (BuildContext subContext, BoxConstraints constraints) =>
{
int rowCount = (categoriesList.Count + columnCount - 1) / columnCount;
int rowCount = (this.categories.Count() + columnCount - 1) / columnCount;
var children = new List<Widget>();
for (var i = 0; i < rowCount; i++)
{
var rowIndex = i;
int columnCountForRow = rowIndex == rowCount - 1
? this.categories.Count() - columnCount * Mathf.Max(0, rowCount - 1)
: columnCount;
var subChildren = new List<Widget>();
for (var j = 0; j < columnCountForRow; j++)
{
var columnIndex = j;
int index = rowIndex * columnCount + columnIndex;
GalleryDemoCategory category = categoriesList[index];
subChildren.Add(new SizedBox(width: columnWidth,
height: rowHeight,
child: new _CategoryItem(
category: category,
onTap: () => { this.onCategoryTap(category); }
)
));
}
children.Add(new Row(
children: subChildren
));
}
children: Enumerable.Range(0, rowCount).Select(rowIndex => {
int columnCountForRow = rowIndex == rowCount - 1
? categoriesList.Count - columnCount * Mathf.Max(0, rowCount - 1)
: columnCount;
return (Widget) new Row(
children: Enumerable.Range(0, columnCountForRow).Select(columnIndex => {
int index = rowIndex * columnCount + columnIndex;
GalleryDemoCategory category = categoriesList[index];
return (Widget) new SizedBox(
width: columnWidth,
height: rowHeight,
child: new _CategoryItem(
category: category,
onTap: () => { this.onCategoryTap(category); }
)
);
}).ToList()
);
}).ToList()
children: children
}
)
);
}));
class _DemoItem : StatelessWidget {
public _DemoItem(Key key = null, GalleryDemo demo = null) : base(key: key) {
internal class _DemoItem : StatelessWidget
{
public _DemoItem(Key key = null, GalleryDemo demo = null) : base(key: key)
{
void _launchDemo(BuildContext context) {
if (this.demo.routeName != null) {
Navigator.pushNamed(context, this.demo.routeName);
}
private void _launchDemo(BuildContext context)
{
if (this.demo.routeName != null) Navigator.pushNamed(context, this.demo.routeName);
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
List<Widget> titleChildren = new List<Widget> {
new Text(
this.demo.title,
style: theme.textTheme.subhead.copyWith(
var children = new List<Widget>
{
new Text(this.demo.title,
style: theme.textTheme.subtitle1.copyWith(
),
)
if (this.demo.subtitle != null) {
titleChildren.Add(
new Text(
this.demo.subtitle,
style: theme.textTheme.body1.copyWith(
color: isDark ? Colors.white : new Color(0xFF60646B)
)
if (this.demo.subtitle != null)
children.Add(new Text(this.demo.subtitle,
style: theme.textTheme.bodyText2.copyWith(
color: isDark ? Colors.white : new Color(0xFF60646B)
);
}
));
return new RawMaterialButton(
padding: EdgeInsets.zero,

child: new Container(
constraints: new BoxConstraints(minHeight: HomeUtils._kDemoItemHeight * textScaleFactor),
constraints: new BoxConstraints(minHeight: GalleryHomeUtils._kDemoItemHeight * textScaleFactor),
children: new List<Widget> {
children: new List<Widget>
{
child: new Icon(
this.demo.icon,
child: new Icon(this.demo.icon,
color: isDark ? Colors.white : HomeUtils._kUIWidgetsBlue
color: isDark ? Colors.white : GalleryHomeUtils._kFlutterBlue
)
),
new Expanded(

children: titleChildren
children: children
new SizedBox(width: 44.0f),
new SizedBox(width: 44.0f)
}
)
)

class _DemosPage : StatelessWidget {
public _DemosPage(GalleryDemoCategory category) {
internal class _DemosPage : StatelessWidget
{
public _DemosPage(GalleryDemoCategory category)
{
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
// When overriding ListView.padding, it is necessary to manually handle
// safe areas.
key: new ValueKey<string>("GalleryDemoList"),
key: Key.key("GalleryDemoList"), // So the tests can find this ListView
key: new PageStorageKey<string>(this.category.name),
dragStartBehavior: DragStartBehavior.down,
key: Key.key(this.category.name),
children: DemoUtils.kGalleryCategoryToDemos[this.category]
.Select(demo => (Widget) new _DemoItem(demo: demo)).ToList()
children: GalleryDemo.kGalleryCategoryToDemos[this.category]
.Select<GalleryDemo, Widget>((GalleryDemo demo) => { return new _DemoItem(demo: demo); })
.ToList()
public class GalleryHome : StatefulWidget {
internal class GalleryHome : StatefulWidget
{
Widget optionsPage = null,
GalleryOptions options = null
) : base(key: key) {
Widget optionsPage = null
) : base(key: key)
{
this.options = options;
public readonly GalleryOptions options;
// In checked mode our MaterialApp will show the default "debug" banner.
// Otherwise show the "preview" banner.
public override State createState() {
public override State createState()
{
class _GalleryHomeState : SingleTickerProviderStateMixin<GalleryHome> {
readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
AnimationController _controller;
GalleryDemoCategory _category;
internal class _GalleryHomeState : SingleTickerProviderStateMixin<GalleryHome>
{
private static readonly GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
private AnimationController _controller;
private GalleryDemoCategory _category;
static Widget _topHomeLayout(Widget currentChild, List<Widget> previousChildren) {
List<Widget> children = previousChildren;
if (currentChild != null) {
children = children.ToList();
children.Add(currentChild);
}
private static Widget _topHomeLayout(Widget currentChild, List<Widget> previousChildren)
{
var children = new List<Widget>();
children.AddRange(previousChildren);
if (currentChild != null) children.Add(currentChild);
return new Stack(
children: children,

public static AnimatedSwitcherLayoutBuilder _centerHomeLayout = AnimatedSwitcher.defaultLayoutBuilder;
private static readonly AnimatedSwitcherLayoutBuilder _centerHomeLayout = AnimatedSwitcher.defaultLayoutBuilder;
public override void initState() {
public override void initState()
{
base.initState();
this._controller = new AnimationController(
duration: new TimeSpan(0, 0, 0, 0, 600),

this._controller.forward();
}
public override void dispose() {
public override void dispose()
{
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
ThemeData theme = Theme.of(context);
bool isDark = theme.brightness == Brightness.dark;
MediaQueryData media = MediaQuery.of(context);

Curve switchInCurve = new Interval(0.4f, 1.0f, curve: Curves.fastOutSlowIn);
Widget home = new Scaffold(
key: this._scaffoldKey,
backgroundColor: isDark ? HomeUtils._kUIWidgetsBlue : theme.primaryColor,
key: _scaffoldKey,
backgroundColor: isDark ? GalleryHomeUtils._kFlutterBlue : theme.primaryColor,
onWillPop: () => {
if (this._category != null) {
onWillPop: () =>
{
// Pop the category page if Android back button is pressed.
if (this._category != null)
{
return Promise<bool>.Resolved(false);
return Future.value(false).to<bool>();
return Promise<bool>.Resolved(true);
return Future.value(true).to<bool>();
duration: HomeUtils._kFrontLayerSwitchDuration,
duration: GalleryHomeUtils._kFrontLayerSwitchDuration,
? (Widget) new _UIWidgetsLogo(isDark: this.widget.options?.theme == GalleryTheme.kDarkGalleryTheme)
? (Widget) new Container()
: new IconButton(
icon: new BackButtonIcon(),
tooltip: "Back",

frontTitle: new AnimatedSwitcher(
duration: HomeUtils._kFrontLayerSwitchDuration,
duration: GalleryHomeUtils._kFrontLayerSwitchDuration,
child: this._category == null
? new Text("UIWidgets gallery")
: new Text(this._category.name)

duration: HomeUtils._kFrontLayerSwitchDuration,
duration: GalleryHomeUtils._kFrontLayerSwitchDuration,
switchOutCurve: switchOutCurve,
switchInCurve: switchInCurve,
layoutBuilder: centerHome ? _centerHomeLayout : _topHomeLayout,

categories: DemoUtils.kAllGalleryDemoCategories,
onCategoryTap: (GalleryDemoCategory category) => {
categories: GalleryDemo.kAllGalleryDemoCategories,
onCategoryTap: (GalleryDemoCategory category) =>
{
this.setState(() => this._category = category);
}
)

)
);
D.assert(() => {
D.assert(() =>
{
if (GalleryHome.showPreviewBanner) {
if (GalleryHome.showPreviewBanner)
children: new List<Widget> {
children: new List<Widget>
{
home,
new FadeTransition(
opacity: new CurvedAnimation(parent: this._controller, curve: Curves.easeInOut),

)
}
);
}
home = new AnnotatedRegion<SystemUiOverlayStyle>(
child: home,
value: SystemUiOverlayStyle.light

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/home.cs.meta


fileFormatVersion: 2
guid: b6b1570fca0b749e688be67e7bb61a5c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 5c8e2b6d71b743648d57a549e2b0c62e
timeCreated: 1612338820

10
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/icons.cs


using Unity.UIWidgets.widgets;
namespace UIWidgetsGallery.gallery {
public static class GalleryIcons {
namespace UIWidgetsGallery.gallery
{
public static class GalleryIcons
{
public static readonly IconData tooltip = new IconData(0xe900, fontFamily: "GalleryIcons");
public static readonly IconData text_fields_alt = new IconData(0xe901, fontFamily: "GalleryIcons");
public static readonly IconData tabs = new IconData(0xe902, fontFamily: "GalleryIcons");

public static readonly IconData list_alt = new IconData(0xe90d, fontFamily: "GalleryIcons");
public static readonly IconData grid_on = new IconData(0xe90e, fontFamily: "GalleryIcons");
public static readonly IconData expand_all = new IconData(0xe90f, fontFamily: "GalleryIcons");
public static readonly IconData @event = new IconData(0xe910, fontFamily: "GalleryIcons");
public static readonly IconData events = new IconData(0xe910, fontFamily: "GalleryIcons");
public static readonly IconData drive_video = new IconData(0xe911, fontFamily: "GalleryIcons");
public static readonly IconData dialogs = new IconData(0xe912, fontFamily: "GalleryIcons");
public static readonly IconData data_table = new IconData(0xe913, fontFamily: "GalleryIcons");

public static readonly IconData bottom_sheet_persistent = new IconData(0xe926, fontFamily: "GalleryIcons");
public static readonly IconData lists_leave_behind = new IconData(0xe927, fontFamily: "GalleryIcons");
}
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/icons.cs.meta


fileFormatVersion: 2
guid: 7b7592e2675d347bb9036ed6cb4fabe0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 77d0b3e255db46828d85f61b587bcb43
timeCreated: 1612324774

565
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/options.cs


using System;
using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.service;
namespace UIWidgetsGallery.gallery {
public class GalleryOptions : IEquatable<GalleryOptions> {
namespace UIWidgetsGallery.gallery
{
public static class GalleryOptionUtils
{
public const float _kItemHeight = 48.0f;
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//public static readonly EdgeInsetsDirectional _kItemPadding = EdgeInsetsDirectional.only(start: 56.0f);
public static readonly EdgeInsets _kItemPadding = EdgeInsets.only(left: 56.0f);
}
public class GalleryOptions : IEquatable<GalleryOptions>
{
GalleryTheme theme = null,
ThemeMode? themeMode = null,
GalleryVisualDensityValue visualDensity = null,
TextDirection? textDirection = null,
) {
D.assert(theme != null);
D.assert(textScaleFactor != null);
this.theme = theme;
)
{
textDirection = textDirection ?? TextDirection.ltr;
this.themeMode = themeMode;
this.visualDensity = visualDensity;
this.textDirection = textDirection;
this.platform = platform ?? Application.platform;
this.platform = platform;
public readonly GalleryTheme theme;
public readonly ThemeMode? themeMode;
public readonly GalleryVisualDensityValue visualDensity;
public readonly TextDirection? textDirection;
public readonly RuntimePlatform platform;
public readonly RuntimePlatform? platform;
public GalleryOptions copyWith(
GalleryTheme theme = null,
internal GalleryOptions copyWith(
ThemeMode? themeMode = null,
GalleryVisualDensityValue visualDensity = null,
TextDirection? textDirection = null,
) {
)
{
theme: theme ?? this.theme,
themeMode: themeMode ?? this.themeMode,
visualDensity: visualDensity ?? this.visualDensity,
textDirection: textDirection ?? this.textDirection,
timeDilation: timeDilation ?? this.timeDilation,
platform: platform ?? this.platform,
showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay,

);
}
public bool Equals(GalleryOptions other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.theme, other.theme) && Equals(this.textScaleFactor, other.textScaleFactor) &&
this.timeDilation.Equals(other.timeDilation) && this.platform == other.platform &&
this.showPerformanceOverlay == other.showPerformanceOverlay &&
this.showRasterCacheImagesCheckerboard == other.showRasterCacheImagesCheckerboard &&
this.showOffscreenLayersCheckerboard == other.showOffscreenLayersCheckerboard;
}
public bool Equals(GalleryOptions other)
{
if (ReferenceEquals(this, other)) return true;
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != this.GetType()) {
return false;
}
return this.Equals((GalleryOptions) obj);
if (ReferenceEquals(other, null)) return false;
return this.themeMode.Equals(other.themeMode)
&& this.textScaleFactor == other.textScaleFactor
&& this.visualDensity == other.visualDensity
&& this.textDirection == other.textDirection
&& this.platform == other.platform
&& this.showPerformanceOverlay == other.showPerformanceOverlay
&& this.showRasterCacheImagesCheckerboard == other.showRasterCacheImagesCheckerboard
&& this.showOffscreenLayersCheckerboard == other.showOffscreenLayersCheckerboard;
public override int GetHashCode() {
unchecked {
var hashCode = (this.theme != null ? this.theme.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (this.textScaleFactor != null ? this.textScaleFactor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ this.timeDilation.GetHashCode();
hashCode = (hashCode * 397) ^ (int) this.platform;
hashCode = (hashCode * 397) ^ this.showPerformanceOverlay.GetHashCode();
hashCode = (hashCode * 397) ^ this.showRasterCacheImagesCheckerboard.GetHashCode();
hashCode = (hashCode * 397) ^ this.showOffscreenLayersCheckerboard.GetHashCode();
return hashCode;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj)) return true;
if (ReferenceEquals(obj, null)) return false;
if (obj.GetType() != this.GetType()) return false;
return this.Equals((GalleryOptions) obj);
public static bool operator ==(GalleryOptions left, GalleryOptions right) {
public static bool operator ==(GalleryOptions left, GalleryOptions right)
{
public static bool operator !=(GalleryOptions left, GalleryOptions right) {
public static bool operator !=(GalleryOptions left, GalleryOptions right)
{
public override string ToString() {
return $"{this.GetType()}({this.theme})";
public override int GetHashCode()
{
unchecked
{
var hashcode = this.themeMode?.GetHashCode() ?? 0;
hashcode = (hashcode * 397) ^ this.textScaleFactor.GetHashCode();
hashcode = (hashcode * 397) ^ this.visualDensity.GetHashCode();
hashcode = (hashcode * 397) ^ (this.textDirection?.GetHashCode() ?? 0);
hashcode = (hashcode * 397) ^ this.timeDilation.GetHashCode();
hashcode = (hashcode * 397) ^ (this.platform?.GetHashCode() ?? 0);
hashcode = (hashcode * 397) ^ this.showPerformanceOverlay.GetHashCode();
hashcode = (hashcode * 397) ^ this.showRasterCacheImagesCheckerboard.GetHashCode();
hashcode = (hashcode * 397) ^ this.showOffscreenLayersCheckerboard.GetHashCode();
return hashcode;
}
}
public override string ToString()
{
return $"{this.GetType()}{this.themeMode}";
class _OptionsItem : StatelessWidget {
const float _kItemHeight = 48.0f;
static readonly EdgeInsets _kItemPadding = EdgeInsets.only(left: 56.0f);
public _OptionsItem(Key key = null, Widget child = null) : base(key: key) {
internal class _OptionsItem : StatelessWidget
{
public _OptionsItem(Key key = null, Widget child = null) : base(key: key)
{
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
constraints: new BoxConstraints(minHeight: _kItemHeight * textScaleFactor),
padding: _kItemPadding,
alignment: Alignment.centerLeft,
constraints: new BoxConstraints(minHeight: GalleryOptionUtils._kItemHeight * textScaleFactor),
padding: GalleryOptionUtils._kItemPadding,
alignment: AlignmentDirectional.centerStart,
child: new DefaultTextStyle(
style: DefaultTextStyle.of(context).style,
maxLines: 2,

}
}
class _BooleanItem : StatelessWidget {
public _BooleanItem(string title, bool value, ValueChanged<bool?> onChanged, Key switchKey = null) {
internal class _BooleanItem : StatelessWidget
{
public _BooleanItem(string title, bool value, ValueChanged<bool?> onChanged, Key switchKey = null)
{
this.title = title;
this.value = value;
this.onChanged = onChanged;

public readonly ValueChanged<bool?> onChanged;
public readonly Key switchKey;
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
children: new List<Widget> {
children: new List<Widget>
{
new Expanded(child: new Text(this.title)),
new Switch(
key: this.switchKey,

}
}
class _ActionItem : StatelessWidget {
public _ActionItem(string text, VoidCallback onTap) {
internal class _ActionItem : StatelessWidget
{
public _ActionItem(string text, VoidCallback onTap)
{
this.text = text;
this.onTap = onTap;
}

public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
return new _OptionsItem(
child: new _FlatButton(
onPressed: this.onTap,

}
}
class _FlatButton : StatelessWidget {
public _FlatButton(Key key = null, VoidCallback onPressed = null, Widget child = null) : base(key: key) {
internal class _FlatButton : StatelessWidget
{
public _FlatButton(Key key = null, VoidCallback onPressed = null, Widget child = null) : base(key: key)
{
this.child = child;
this.child = child;
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
style: Theme.of(context).primaryTextTheme.subhead,
style: Theme.of(context).primaryTextTheme.subtitle1,
child: this.child
)
);

class _Heading : StatelessWidget {
public _Heading(string text) {
internal class _Heading : StatelessWidget
{
public _Heading(string text)
{
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
style: theme.textTheme.body1.copyWith(
fontFamily: "GoogleSans",
color: theme.accentColor
style: theme.textTheme.headline6.copyWith(
color: theme.colorScheme.onPrimary,
fontWeight: FontWeight.w700
),
child: new Text(this.text)
)

class _ThemeItem : StatelessWidget {
public _ThemeItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged) {
internal class _ThemeModeItem : StatelessWidget
{
public _ThemeModeItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}

public override Widget build(BuildContext context) {
return new _BooleanItem(
"Dark Theme",
this.options.theme == GalleryTheme.kDarkGalleryTheme,
(bool? value) => {
this.onOptionsChanged(
this.options.copyWith(
theme: value == true ? GalleryTheme.kDarkGalleryTheme : GalleryTheme.kLightGalleryTheme
public static readonly Dictionary<ThemeMode, string> modeLabels = new Dictionary<ThemeMode, string>
{
{ThemeMode.system, "System Default"},
{ThemeMode.light, "Light"},
{ThemeMode.dark, "Dark"},
};
public override Widget build(BuildContext context)
{
return new _OptionsItem(
child: new Row(
children: new List<Widget>
{
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>
{
new Text("Theme"),
new Text(
modeLabels[this.options.themeMode.Value],
style: Theme.of(context).primaryTextTheme.bodyText2
)
}
)
),
new PopupMenuButton<ThemeMode>(
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: const EdgeInsetsDirectional.only(end: 16.0),
padding: EdgeInsets.only(right: 16.0f),
icon: new Icon(Icons.arrow_drop_down),
initialValue: this.options.themeMode.Value,
itemBuilder: (BuildContext subContext) =>
{
return modeLabels.Keys.Select<ThemeMode, PopupMenuEntry<ThemeMode>>((ThemeMode mode) =>
{
return new PopupMenuItem<ThemeMode>(
value: mode,
child: new Text(modeLabels[mode])
);
}).ToList();
},
onSelected: (ThemeMode mode) =>
{
this.onOptionsChanged(this.options.copyWith(themeMode: mode)
);
}
);
},
switchKey: Key.key("dark_theme")
}
)
class _TextScaleFactorItem : StatelessWidget {
public _TextScaleFactorItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged) {
internal class _TextScaleFactorItem : StatelessWidget
{
public _TextScaleFactorItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}

public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
children: new List<Widget> {
children: new List<Widget>
{
children: new List<Widget> {
children: new List<Widget>
{
new Text(
this.options.textScaleFactor.label,
style: Theme.of(context).primaryTextTheme.body1
),
new Text(this.options.textScaleFactor.label,
style: Theme.of(context).primaryTextTheme.bodyText2
)
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: EdgeInsetsDirectional.only(end: 16.0f),
itemBuilder: _ => {
return GalleryTextScaleValue.kAllGalleryTextScaleValues.Select(scaleValue =>
(PopupMenuEntry<GalleryTextScaleValue>) new PopupMenuItem<GalleryTextScaleValue>(
value: scaleValue,
child: new Text(scaleValue.label)
)).ToList();
itemBuilder: (BuildContext subContext) =>
{
return GalleryTextScaleValue.kAllGalleryTextScaleValues
.Select<GalleryTextScaleValue, PopupMenuEntry<GalleryTextScaleValue>>(
(GalleryTextScaleValue scaleValue) =>
{
return new PopupMenuItem<GalleryTextScaleValue>(
value: scaleValue,
child: new Text(scaleValue.label)
);
}).ToList();
onSelected: scaleValue => {
this.onOptionsChanged(
this.options.copyWith(textScaleFactor: scaleValue)
onSelected: (GalleryTextScaleValue scaleValue) =>
{
this.onOptionsChanged(this.options.copyWith(textScaleFactor: scaleValue)
)
}
)
);
}
}
internal class _VisualDensityItem : StatelessWidget
{
public _VisualDensityItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public override Widget build(BuildContext context)
{
return new _OptionsItem(
child: new Row(
children: new List<Widget>
{
new Expanded(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget>
{
new Text("Visual density"),
new Text(this.options.visualDensity.label,
style: Theme.of(context).primaryTextTheme.bodyText2
)
}
)
new PopupMenuButton<GalleryVisualDensityValue>(
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: EdgeInsetsDirectional.only(end: 16.0f),
padding: EdgeInsets.only(right: 16.0f),
icon: new Icon(Icons.arrow_drop_down),
itemBuilder: (BuildContext subContext) =>
{
return GalleryVisualDensityValue.kAllGalleryVisualDensityValues
.Select<GalleryVisualDensityValue, PopupMenuEntry<GalleryVisualDensityValue>>(
(GalleryVisualDensityValue densityValue) =>
{
return new PopupMenuItem<GalleryVisualDensityValue>(
value: densityValue,
child: new Text(densityValue.label)
);
}).ToList();
},
onSelected: (GalleryVisualDensityValue densityValue) =>
{
this.onOptionsChanged(this.options.copyWith(visualDensity: densityValue)
);
}
)
}
)
);

internal class _TextDirectionItem : StatelessWidget
{
public _TextDirectionItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}
class _TimeDilationItem : StatelessWidget {
public _TimeDilationItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged) {
public readonly GalleryOptions options;
public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public override Widget build(BuildContext context)
{
return new _BooleanItem(
"Force RTL", this.options.textDirection == TextDirection.rtl,
(bool? value) =>
{
this.onOptionsChanged(this.options.copyWith(
textDirection: value == true ? TextDirection.rtl : TextDirection.ltr
)
);
},
switchKey: Key.key("text_direction")
);
}
}
internal class _TimeDilationItem : StatelessWidget
{
public _TimeDilationItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}

public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
"Slow motion",
this.options.timeDilation != 1.0f,
(bool? value) => {
this.onOptionsChanged(
this.options.copyWith(
"Slow motion", this.options.timeDilation != 1.0f,
(bool? value) =>
{
this.onOptionsChanged(this.options.copyWith(
timeDilation: value == true ? 20.0f : 1.0f
)
);

}
}
class _PlatformItem : StatelessWidget {
public _PlatformItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged) {
internal class _PlatformItem : StatelessWidget
{
public _PlatformItem(GalleryOptions options, ValueChanged<GalleryOptions> onOptionsChanged)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
}

string _platformLabel(RuntimePlatform platform) {
private string _platformLabel(RuntimePlatform? platform)
{
public override Widget build(BuildContext context) {
private static List<RuntimePlatform> _platforms = new List<RuntimePlatform>
{RuntimePlatform.Android, RuntimePlatform.IPhonePlayer, RuntimePlatform.WindowsPlayer};
public override Widget build(BuildContext context)
{
children: new List<Widget> {
children: new List<Widget>
{
children: new List<Widget> {
children: new List<Widget>
{
new Text(
this._platformLabel(this.options.platform),
style: Theme.of(context).primaryTextTheme.body1
),
new Text(this._platformLabel(this.options.platform),
style: Theme.of(context).primaryTextTheme.bodyText2
)
//TODO: uncomment this when fixes on EdgeInsetsDirectional lands
//padding: EdgeInsetsDirectional.only(end: 16.0f),
itemBuilder: _ => {
var values = Enum.GetValues(typeof(RuntimePlatform)).Cast<RuntimePlatform>();
return values.Select(platform =>
(PopupMenuEntry<RuntimePlatform>) new PopupMenuItem<RuntimePlatform>(
value: platform,
child: new Text(this._platformLabel(platform))
)).ToList();
itemBuilder: (BuildContext subContext) =>
{
return _platforms.Select<RuntimePlatform, PopupMenuEntry<RuntimePlatform>>(
(RuntimePlatform platform) =>
{
return new PopupMenuItem<RuntimePlatform>(
value: platform,
child: new Text(this._platformLabel(platform))
);
}).ToList();
onSelected: platform => {
this.onOptionsChanged(
this.options.copyWith(platform: platform)
onSelected: (RuntimePlatform platform) =>
{
this.onOptionsChanged(this.options.copyWith(platform: platform)
),
)
}
)
);

public class GalleryOptionsPage : StatelessWidget {
internal class GalleryOptionsPage : StatelessWidget
{
) : base(key: key) {
) : base(key: key)
{
this.options = options;
this.onOptionsChanged = onOptionsChanged;
this.onSendFeedback = onSendFeedback;

public readonly ValueChanged<GalleryOptions> onOptionsChanged;
public readonly VoidCallback onSendFeedback;
List<Widget> _enabledDiagnosticItems() {
List<Widget> items = new List<Widget> {
new Divider(),
new _Heading("Diagnostics"),
};
items.Add(
new _BooleanItem(
"Highlight offscreen layers",
this.options.showOffscreenLayersCheckerboard,
(bool? value) => {
this.onOptionsChanged(this.options.copyWith(showOffscreenLayersCheckerboard: value));
}
)
);
items.Add(
new _BooleanItem(
"Highlight raster cache images",
this.options.showRasterCacheImagesCheckerboard,
(bool? value) => {
this.onOptionsChanged(this.options.copyWith(showRasterCacheImagesCheckerboard: value));
}
)
);
items.Add(
new _BooleanItem(
"Show performance overlay",
this.options.showPerformanceOverlay,
(bool? value) => { this.onOptionsChanged(this.options.copyWith(showPerformanceOverlay: value)); }
)
);
return items;
}
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
var children = new List<Widget> {
new _Heading("Display"),
new _ThemeItem(this.options, this.onOptionsChanged),
new _TextScaleFactorItem(this.options, this.onOptionsChanged),
new _TimeDilationItem(this.options, this.onOptionsChanged),
new Divider(),
new _Heading("Platform mechanics"),
new _PlatformItem(this.options, this.onOptionsChanged)
};
children.AddRange(this._enabledDiagnosticItems());
children.AddRange(new List<Widget> {
new Divider(),
new _Heading("UIWidgets Gallery"),
new _ActionItem("About UIWidgets Gallery", () => {
/* showGalleryAboutDialog(context); */
}),
new _ActionItem("Send feedback", this.onSendFeedback),
});
style: theme.primaryTextTheme.subhead,
style: theme.primaryTextTheme.subtitle1,
children: children
));
children: new List<Widget>
{
new _Heading("Display"),
new _ThemeModeItem(this.options, this.onOptionsChanged),
new _TextScaleFactorItem(this.options, this.onOptionsChanged),
new _VisualDensityItem(this.options, this.onOptionsChanged),
new _TextDirectionItem(this.options, this.onOptionsChanged),
new _TimeDilationItem(this.options, this.onOptionsChanged),
new Divider(),
new _PlatformItem(this.options, this.onOptionsChanged),
new Divider(),
new _Heading("Flutter gallery"),
new _ActionItem("About Flutter Gallery",
() => { GalleryAboutUtils.showGalleryAboutDialog(context); }),
new _ActionItem("Send feedback", this.onSendFeedback)
}
)
);
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/options.cs.meta


fileFormatVersion: 2
guid: 9eb439aba25814f79979120cd5966537
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 73fb5821ecc441269db224976d575666
timeCreated: 1612324913

152
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/scales.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.material;
namespace UIWidgetsGallery.gallery {
public class GalleryTextScaleValue : IEquatable<GalleryTextScaleValue> {
public GalleryTextScaleValue(float? scale = null, string label = null) {
namespace UIWidgetsGallery.gallery
{
public class GalleryTextScaleValue : IEquatable<GalleryTextScaleValue>
{
public GalleryTextScaleValue(float? scale, string label)
{
public bool Equals(GalleryTextScaleValue other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
public bool Equals(GalleryTextScaleValue other)
{
if (ReferenceEquals(this, other))
{
return this.scale.Equals(other.scale) && string.Equals(this.label, other.label);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
if (ReferenceEquals(other, null))
{
if (ReferenceEquals(this, obj)) {
return this.scale.Equals(other.scale) && this.label == other.label;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj))
{
if (obj.GetType() != this.GetType()) {
if (ReferenceEquals(obj, null))
{
return this.Equals((GalleryTextScaleValue) obj);
if (obj.GetType() != GetType())
{
return false;
}
return Equals((GalleryTextScaleValue)obj);
}
public static bool operator==(GalleryTextScaleValue left, GalleryTextScaleValue right)
{
return Equals(left, right);
public static bool operator !=(GalleryTextScaleValue left, GalleryTextScaleValue right)
{
return !Equals(left, right);
}
return (this.scale.GetHashCode() * 397) ^ (this.label != null ? this.label.GetHashCode() : 0);
return ((label?.GetHashCode() ?? 0) * 397) ^ (scale?.GetHashCode() ?? 0);
public static bool operator ==(GalleryTextScaleValue left, GalleryTextScaleValue right) {
public override string ToString()
{
return $"{GetType()}{label}";
}
public static readonly List<GalleryTextScaleValue> kAllGalleryTextScaleValues = new List<GalleryTextScaleValue>{
new GalleryTextScaleValue(null, "System Default"),
new GalleryTextScaleValue(0.8f, "Small"),
new GalleryTextScaleValue(1.0f, "Normal"),
new GalleryTextScaleValue(1.3f, "Large"),
new GalleryTextScaleValue(2.0f, "Huge"),
};
}
public class GalleryVisualDensityValue : IEquatable<GalleryVisualDensityValue>
{
public GalleryVisualDensityValue(VisualDensity visualDensity, string label)
{
this.visualDensity = visualDensity;
this.label = label;
}
public readonly VisualDensity visualDensity;
public readonly string label;
public bool Equals(GalleryVisualDensityValue other)
{
if (ReferenceEquals(this, other))
{
return true;
}
if (ReferenceEquals(other, null))
{
return false;
}
return this.visualDensity.Equals(other.visualDensity) && this.label == other.label;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj))
{
return true;
}
if (ReferenceEquals(obj, null))
{
return false;
}
if (obj.GetType() != GetType())
{
return false;
}
return Equals((GalleryVisualDensityValue)obj);
}
public static bool operator==(GalleryVisualDensityValue left, GalleryVisualDensityValue right)
{
public static bool operator !=(GalleryTextScaleValue left, GalleryTextScaleValue right) {
public static bool operator !=(GalleryVisualDensityValue left, GalleryVisualDensityValue right)
{
public override int GetHashCode() {
unchecked {
return ((label?.GetHashCode() ?? 0) * 397) ^ (visualDensity?.GetHashCode() ?? 0);
}
}
public override string ToString() {
return $"{this.GetType()}({this.label})";
public override string ToString()
{
return $"{GetType()}{label}";
public static readonly List<GalleryTextScaleValue> kAllGalleryTextScaleValues = new List<GalleryTextScaleValue> {
new GalleryTextScaleValue(null, "System Default"),
new GalleryTextScaleValue(0.8f, "Small"),
new GalleryTextScaleValue(1.0f, "Normal"),
new GalleryTextScaleValue(1.3f, "Large"),
new GalleryTextScaleValue(2.0f, "Huge"),
public static readonly List<GalleryVisualDensityValue> kAllGalleryVisualDensityValues = new List<GalleryVisualDensityValue>{
new GalleryVisualDensityValue(new VisualDensity(), "System Default"),
new GalleryVisualDensityValue(VisualDensity.comfortable, "Comfortable"),
new GalleryVisualDensityValue(VisualDensity.compact, "Compact"),
new GalleryVisualDensityValue(new VisualDensity(horizontal: -3, vertical: -3), "Very Compact")
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/scales.cs.meta


fileFormatVersion: 2
guid: 9bf87177b342d4feba4778ca5a9b20a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 536d205536f347459208349c7fb5220c
timeCreated: 1612324936

64
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/themes.cs


using uiwidgets;
namespace UIWidgetsGallery.gallery {
public class GalleryTheme {
GalleryTheme(string name, ThemeData data) {
this.name = name;
this.data = data;
}
namespace UIWidgetsGallery.gallery
{
public static class GalleyThemes
{
public static readonly ThemeData kLightGalleryTheme = _buildLightTheme();
public static readonly ThemeData kDarkGalleryTheme = _buildDarkTheme();
public readonly string name;
public readonly ThemeData data;
private static string _defaultGalleryFontFamily = "";
public static readonly GalleryTheme kDarkGalleryTheme = new GalleryTheme("Dark", _buildDarkTheme());
public static readonly GalleryTheme kLightGalleryTheme = new GalleryTheme("Light", _buildLightTheme());
private static TextTheme _buildTextTheme(TextTheme baseTheme)
{
if (_defaultGalleryFontFamily != "")
return baseTheme.copyWith(
headline6: baseTheme.headline6.copyWith(
fontFamily: _defaultGalleryFontFamily
)
);
static TextTheme _buildTextTheme(TextTheme baseTheme) {
return baseTheme.copyWith(
title: baseTheme.title.copyWith(
fontFamily: "GoogleSans"
)
);
return baseTheme;
static ThemeData _buildDarkTheme() {
private static ThemeData _buildDarkTheme()
{
ThemeData baseTheme = ThemeData.dark();
return baseTheme.copyWith(
ThemeData baseTheme = new ThemeData(
brightness: Brightness.dark,
accentColorBrightness: Brightness.dark,
primaryColorDark: new Color(0xFF0050a0),
primaryColorLight: secondaryColor,
toggleableActiveColor: new Color(0xFF6997DF),
accentColor: secondaryColor,
canvasColor: new Color(0xFF202124),
scaffoldBackgroundColor: new Color(0xFF202124),

colorScheme: colorScheme,
textTheme: ButtonTextTheme.primary
),
)
);
return baseTheme.copyWith(
textTheme: _buildTextTheme(baseTheme.textTheme),
primaryTextTheme: _buildTextTheme(baseTheme.primaryTextTheme),
accentTextTheme: _buildTextTheme(baseTheme.accentTextTheme)

static ThemeData _buildLightTheme() {
private static ThemeData _buildLightTheme()
{
Color primaryColor = new Color(0xFF0175c2);
Color secondaryColor = new Color(0xFF13B9FD);
ColorScheme colorScheme = ColorScheme.light().copyWith(

ThemeData baseTheme = ThemeData.light();
return baseTheme.copyWith(
ThemeData baseTheme = new ThemeData(
brightness: Brightness.light,
accentColorBrightness: Brightness.dark,
toggleableActiveColor: new Color(0xFF1E88E5),
splashColor: Colors.white24,
splashFactory: InkRipple.splashFactory,
accentColor: secondaryColor,

buttonTheme: new ButtonThemeData(
colorScheme: colorScheme,
textTheme: ButtonTextTheme.primary
),
)
);
return baseTheme.copyWith(
textTheme: _buildTextTheme(baseTheme.textTheme),
primaryTextTheme: _buildTextTheme(baseTheme.primaryTextTheme),
accentTextTheme: _buildTextTheme(baseTheme.accentTextTheme)

}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/themes.cs.meta


fileFormatVersion: 2
guid: 7510605485ec34459a4ac9b456cf583f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 3941efd4d8554df2a6f53ad10cc6ca56
timeCreated: 1612324365

80
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs


using System;
using System.Collections.Generic;
using RSG;
using System.Diagnostics;
using Unity.UIWidgets.async;
using UnityEngine;
using DialogUtils = Unity.UIWidgets.material.DialogUtils;
namespace UIWidgetsGallery.gallery {
public class Updater : StatefulWidget {
public Updater(UpdateUrlFetcher updateUrlFetcher = null, Widget child = null, Key key = null)
: base(key: key) {
namespace UIWidgetsGallery.gallery
{
public delegate Future<string> UpdateUrlFetcher();
internal class Updater : StatefulWidget
{
public Updater(UpdateUrlFetcher updateUrlFetcher, Widget child = null, Key key = null)
:
base(key: key)
{
this.updateUrlFetcher = updateUrlFetcher;
this.updateUrlFetcher = updateUrlFetcher;
public override State createState() {
public override State createState()
{
public class UpdaterState : State<Updater> {
public override void initState() {
internal class UpdaterState : State<Updater>
{
public override void initState()
{
static DateTime? _lastUpdateCheck;
private static DateTime _lastUpdateCheck;
IPromise _checkForUpdates() {
private void _checkForUpdates()
{
(DateTime.Now - _lastUpdateCheck.Value).TotalDays < 1) {
return Promise.Resolved(); // We already checked for updates recently
}
DateTime.Now - _lastUpdateCheck < new TimeSpan(1, 0, 0, 0))
return; // We already checked for updates recently
return this.widget.updateUrlFetcher().Then(updateUrl => {
if (updateUrl != null) {
return DialogUtils.showDialog(context: this.context, builder: this._buildDialog).Then(
result => {
if (result != null) {
bool wantsUpdate = (bool) result;
if (wantsUpdate) {
Application.OpenURL(updateUrl);
}
}
});
}
return Promise.Resolved();
this.widget.updateUrlFetcher.Invoke().then(updateUrl =>
{
if (updateUrl != null)
material_.showDialog<bool>(context: this.context, builder: this._buildDialog).then(wantsUpdate =>
{
if (wantsUpdate != null && (bool) wantsUpdate)
BrowserUtils.launch((string) updateUrl);
});
Widget _buildDialog(BuildContext context) {
private Widget _buildDialog(BuildContext context)
{
TextStyle dialogTextStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color);
TextStyle dialogTextStyle =
theme.textTheme.subtitle1.copyWith(color: theme.textTheme.caption.color);
actions: new List<Widget>() {
actions: new List<Widget>
{
new FlatButton(
child: new Text("NO THANKS"),
onPressed: () => { Navigator.pop(context, false); }

);
}
public override Widget build(BuildContext context) {
public override Widget build(BuildContext context)
{
}
}

14
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery/gallery/updater.cs.meta


fileFormatVersion: 2
guid: c69f6e2d93b02484fab6f2e2408c7d88
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 16139f3d73b447de87560f29d24aff3e
timeCreated: 1612323458

3
Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsSample.asmdef


{
"name": "UIWidgetsSample",
"references": [
"Unity.UIWidgets"
"Unity.UIWidgets",
"UIWidgetsGallery"
],
"optionalUnityReferences": [],
"includePlatforms": [],

2
com.unity.uiwidgets/.editorconfig


# use this.{} for all instance members
csharp_instance_members_qualify_members=all
csharp_instance_members_qualify_members=none
# all braces start at the end of a line

24
com.unity.uiwidgets/Editor/UIWidgetsPanelEditor.cs


using Unity.UIWidgets.engine;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.foundation;
using UnityEngine;
var pixelRatioProperty = this.serializedObject.FindProperty("devicePixelRatioOverride");
var antiAliasingProperty = this.serializedObject.FindProperty("hardwareAntiAliasing");
EditorGUILayout.PropertyField(pixelRatioProperty);
EditorGUILayout.PropertyField(antiAliasingProperty);
this.serializedObject.ApplyModifiedProperties();
EditorGUILayout.PropertyField(serializedObject.FindProperty("fonts"), true);
EditorGUI.BeginChangeCheck();
UIWidgetsPanel panel = (UIWidgetsPanel)target;
serializedObject.ApplyModifiedProperties();
}
[MenuItem("UIWidgets/EnableDebug")]
public static void ToggleDebugMode(){
D.enableDebug = !D.enableDebug;
}
[MenuItem("UIWidgets/EnableDebug",true)]
public static bool CurrentDebugModeState() {
Menu.SetChecked("UIWidgets/EnableDebug", D.enableDebug );
return true;
}
}
}

22
com.unity.uiwidgets/Runtime/animation/animation.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.animation {
public enum AnimationStatus {
dismissed,
forward,

public delegate void AnimationStatusListener(AnimationStatus status);
public abstract class Animation<T> : ValueListenable<T> {

public abstract T value { get; }
public bool isDismissed {
get { return this.status == AnimationStatus.dismissed; }
get { return status == AnimationStatus.dismissed; }
get { return this.status == AnimationStatus.completed; }
get { return status == AnimationStatus.completed; }
}
public Animation<U> drive<U>(Animatable<U> child) {
D.assert(this is Animation<float>);
return child.animate(this as Animation<float>);
return $"{Diagnostics.describeIdentity(this)}({this.toStringDetails()})";
return $"{foundation_.describeIdentity(this)}({toStringDetails()})";
switch (this.status) {
switch (status) {
case AnimationStatus.forward:
icon = "\u25B6"; // >
break;

D.assert(icon != null);
return icon;
}
public Animation<U> drive<U>(Animatable<U> child) {
D.assert(this is Animation<float>);
return child.animate(this as Animation<float>);
}
}
}

327
com.unity.uiwidgets/Runtime/animation/animation_controller.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.scheduler;
using Ticker = Unity.UIWidgets.scheduler.Ticker;
using TickerFuture = Unity.UIWidgets.scheduler.TickerFuture;
using TickerProvider = Unity.UIWidgets.scheduler.TickerProvider;
namespace Unity.UIWidgets.animation {
enum _AnimationDirection {

public enum AnimationBehavior {
normal,
preserve,
}
TimeSpan? reverseDuration = null,
AnimationBehavior animationBehavior = AnimationBehavior.normal,
this._direction = _AnimationDirection.forward;
_direction = _AnimationDirection.forward;
this.reverseDuration = reverseDuration;
this.animationBehavior = animationBehavior;
this._ticker = vsync.createTicker(this._tick);
this._internalSetValue(value ?? lowerBound);
_ticker = vsync.createTicker(_tick);
_internalSetValue(value ?? lowerBound);
TimeSpan? reverseDuration = null,
AnimationBehavior? animationBehavior = null,
this.lowerBound = float.NegativeInfinity;
this.upperBound = float.PositiveInfinity;
this._direction = _AnimationDirection.forward;
D.assert(animationBehavior != null);
lowerBound = float.NegativeInfinity;
upperBound = float.PositiveInfinity;
_direction = _AnimationDirection.forward;
this.reverseDuration = reverseDuration;
this.animationBehavior = animationBehavior.Value;
this._ticker = vsync.createTicker(this._tick);
this._internalSetValue(value);
_ticker = vsync.createTicker(_tick);
_internalSetValue(value);
TimeSpan? reverseDuration = null,
TickerProvider vsync = null
TickerProvider vsync = null,
AnimationBehavior animationBehavior = AnimationBehavior.preserve
return new AnimationController(value, duration, debugLabel, vsync);
return new AnimationController(value, duration, reverseDuration, debugLabel, animationBehavior, vsync);
}
public readonly float lowerBound;

public readonly AnimationBehavior animationBehavior;
public readonly string debugLabel;
public Animation<float> view {

public TimeSpan? duration;
public TimeSpan? reverseDuration;
Ticker oldTicker = this._ticker;
this._ticker = vsync.createTicker(this._tick);
this._ticker.absorbTicker(oldTicker);
Ticker oldTicker = _ticker;
_ticker = vsync.createTicker(_tick);
_ticker.absorbTicker(oldTicker);
get { return this._value; }
get { return _value; }
this.stop();
this._internalSetValue(newValue);
this.notifyListeners();
this._checkStatusChanged();
stop();
_internalSetValue(newValue);
notifyListeners();
_checkStatusChanged();
this.setValue(this.lowerBound);
setValue(lowerBound);
if (!this.isAnimating) {
if (!isAnimating) {
return this._simulation.dx((float) this.lastElapsedDuration.Value.Ticks / TimeSpan.TicksPerSecond);
return _simulation.dx((float) lastElapsedDuration.Value.Ticks / TimeSpan.TicksPerSecond);
this._value = newValue.clamp(this.lowerBound, this.upperBound);
if (this._value == this.lowerBound) {
this._status = AnimationStatus.dismissed;
_value = newValue.clamp(lowerBound, upperBound);
if (foundation_.FloatEqual(_value, lowerBound)) {
_status = AnimationStatus.dismissed;
else if (this._value == this.upperBound) {
this._status = AnimationStatus.completed;
else if (foundation_.FloatEqual(_value, upperBound)) {
_status = AnimationStatus.completed;
this._status = (this._direction == _AnimationDirection.forward)
_status = (_direction == _AnimationDirection.forward)
? AnimationStatus.forward
: AnimationStatus.reverse;
}

get { return this._lastElapsedDuration; }
get { return _lastElapsedDuration; }
get { return this._ticker != null && this._ticker.isActive; }
get { return _ticker != null && _ticker.isActive; }
get { return this._status; }
get { return _status; }
}
AnimationStatus _status;

if (this.duration == null) {
if (duration == null) {
"AnimationController.forward() called with no default Duration.\n" +
"AnimationController.forward() called with no default duration.\n" +
"The \"duration\" property should be set, either in the constructor or later, before " +
"calling the forward() function."
);

});
D.assert(
this._ticker != null,
_ticker != null,
this._direction = _AnimationDirection.forward;
_direction = _AnimationDirection.forward;
this.setValue(from.Value);
setValue(from.Value);
return this._animateToInternal(this.upperBound);
return _animateToInternal(upperBound);
if (this.duration == null) {
if (duration == null && reverseDuration == null) {
"AnimationController.reverse() called with no default Duration.\n" +
"The \"duration\" property should be set, either in the constructor or later, before " +
"AnimationController.reverse() called with no default duration or reverseDuration.\n" +
"The \"duration\" or \"reverseDuration\" property should be set, either in the constructor or later, before " +
"calling the reverse() function."
);
}

D.assert(
this._ticker != null,
_ticker != null,
this._direction = _AnimationDirection.reverse;
_direction = _AnimationDirection.reverse;
this.setValue(from.Value);
setValue(from.Value);
return this._animateToInternal(this.lowerBound);
return _animateToInternal(lowerBound);
this._ticker != null,
_ticker != null,
this._direction = _AnimationDirection.forward;
return this._animateToInternal(target, duration: duration, curve: curve);
_direction = _AnimationDirection.forward;
return _animateToInternal(target, duration: duration, curve: curve);
this._ticker != null,
_ticker != null,
this._direction = _AnimationDirection.reverse;
return this._animateToInternal(target, duration, curve);
_direction = _AnimationDirection.reverse;
return _animateToInternal(target, duration, curve);
}
TickerFuture _animateToInternal(float target, TimeSpan? duration = null, Curve curve = null) {

if (simulationDuration == null) {
D.assert(() => {
if (this.duration == null) {
if ((this.duration == null && _direction == _AnimationDirection.reverse && reverseDuration == null) ||
(this.duration == null && _direction == _AnimationDirection.forward)) {
"AnimationController.animateTo() called with no explicit Duration and no default Duration.\n" +
"AnimationController.animateTo() called with no explicit Duration and no default duration or reverseDuration.\n" +
"\"duration\" property should be set, either in the constructor or later, before " +
"\"duration\" and/or \"reverseDuration\" property should be set, either in the constructor or later, before " +
"calling the animateTo() function."
);
}

float range = this.upperBound - this.lowerBound;
float remainingFraction = range.isFinite() ? (target - this._value).abs() / range : 1.0f;
simulationDuration = TimeSpan.FromTicks((long) (this.duration.Value.Ticks * remainingFraction));
float range = upperBound - lowerBound;
float remainingFraction = range.isFinite() ? (target - _value).abs() / range : 1.0f;
TimeSpan directionDuration = (_direction == _AnimationDirection.reverse && reverseDuration != null)
? reverseDuration.Value
: this.duration.Value;
simulationDuration = TimeSpan.FromTicks((long) (directionDuration.Ticks * remainingFraction));
else if (target == this.value) {
else if (target == value) {
this.stop();
stop();
if (this._value != target) {
this._value = target.clamp(this.lowerBound, this.upperBound);
this.notifyListeners();
if (_value != target) {
_value = target.clamp(lowerBound, upperBound);
notifyListeners();
this._status = (this._direction == _AnimationDirection.forward)
_status = (_direction == _AnimationDirection.forward)
this._checkStatusChanged();
return TickerFutureImpl.complete();
_checkStatusChanged();
return TickerFuture.complete();
D.assert(!this.isAnimating);
return this._startSimulation(
new _InterpolationSimulation(this._value, target, simulationDuration.Value, curve));
D.assert(!isAnimating);
return _startSimulation(
new _InterpolationSimulation(_value, target, simulationDuration.Value, curve));
min = min ?? this.lowerBound;
max = max ?? this.upperBound;
period = period ?? this.duration;
min = min ?? lowerBound;
max = max ?? upperBound;
period = period ?? duration;
D.assert(() => {
if (period == null) {
throw new UIWidgetsError(

});
D.assert(max >= min);
D.assert(max <= this.upperBound && min >= this.lowerBound);
return this.animateWith(new _RepeatingSimulation(this._value, min.Value, max.Value, reverse, period.Value));
D.assert(max <= upperBound && min >= lowerBound);
stop();
return _startSimulation(new _RepeatingSimulation(_value, min.Value, max.Value, reverse, period.Value, _directionSetter));
}
void _directionSetter(_AnimationDirection direction) {
_direction = direction;
_status = (_direction == _AnimationDirection.forward) ? AnimationStatus.forward : AnimationStatus.reverse;
_checkStatusChanged();
this._direction = velocity < 0.0 ? _AnimationDirection.reverse : _AnimationDirection.forward;
_direction = velocity < 0.0 ? _AnimationDirection.reverse : _AnimationDirection.forward;
? this.lowerBound - _kFlingTolerance.distance
: this.upperBound + _kFlingTolerance.distance;
Simulation simulation = new SpringSimulation(_kFlingSpringDescription, this.value,
? lowerBound - _kFlingTolerance.distance
: upperBound + _kFlingTolerance.distance;
Simulation simulation = new SpringSimulation(_kFlingSpringDescription, value,
return this.animateWith(simulation);
stop();
return _startSimulation(simulation);
this._ticker != null,
_ticker != null,
this.stop();
return this._startSimulation(simulation);
stop();
_direction = _AnimationDirection.forward;
return _startSimulation(simulation);
D.assert(!this.isAnimating);
this._simulation = simulation;
this._lastElapsedDuration = TimeSpan.Zero;
this._value = simulation.x(0.0f).clamp(this.lowerBound, this.upperBound);
var result = this._ticker.start();
this._status = (this._direction == _AnimationDirection.forward)
D.assert(!isAnimating);
_simulation = simulation;
_lastElapsedDuration = TimeSpan.Zero;
_value = simulation.x(0.0f).clamp(lowerBound, upperBound);
var result = _ticker.start();
_status = (_direction == _AnimationDirection.forward)
this._checkStatusChanged();
_checkStatusChanged();
this._ticker != null,
_ticker != null,
this._simulation = null;
this._lastElapsedDuration = null;
this._ticker.stop(canceled: canceled);
_simulation = null;
_lastElapsedDuration = null;
_ticker.stop(canceled: canceled);
if (this._ticker == null) {
throw new UIWidgetsError(
"AnimationController.dispose() called more than once.\n" +
"A given " + this.GetType() + " cannot be disposed more than once.\n" +
"The following " + this.GetType() + " object was disposed multiple times:\n" +
" " + this);
if (_ticker == null) {
throw new UIWidgetsError(new List<DiagnosticsNode>() {
new ErrorSummary("AnimationController.dispose() called more than once."),
new ErrorDescription($"A given {GetType()} cannot be disposed more than once.\n"),
new DiagnosticsProperty<AnimationController>(
$"The following {GetType()} object was disposed multiple times",
this,
style: DiagnosticsTreeStyle.errorProperty)
});
this._ticker.dispose();
this._ticker = null;
_ticker.Dispose();
_ticker = null;
base.dispose();
}

AnimationStatus newStatus = this.status;
if (this._lastReportedStatus != newStatus) {
this._lastReportedStatus = newStatus;
this.notifyStatusListeners(newStatus);
AnimationStatus newStatus = status;
if (_lastReportedStatus != newStatus) {
_lastReportedStatus = newStatus;
notifyStatusListeners(newStatus);
this._lastElapsedDuration = elapsed;
_lastElapsedDuration = elapsed;
this._value = this._simulation.x(elapsedInSeconds).clamp(this.lowerBound, this.upperBound);
if (this._simulation.isDone(elapsedInSeconds)) {
this._status = (this._direction == _AnimationDirection.forward)
_value = _simulation.x(elapsedInSeconds).clamp(lowerBound, upperBound);
if (_simulation.isDone(elapsedInSeconds)) {
_status = (_direction == _AnimationDirection.forward)
this.stop(canceled: false);
stop(canceled: false);
this.notifyListeners();
this._checkStatusChanged();
notifyListeners();
_checkStatusChanged();
string paused = this.isAnimating ? "" : "; paused";
string ticker = this._ticker == null ? "; DISPOSED" : (this._ticker.muted ? "; silenced" : "");
string label = this.debugLabel == null ? "" : "; for " + this.debugLabel;
string more = $"{base.toStringDetails()} {this.value:F3}";
string paused = isAnimating ? "" : "; paused";
string ticker = _ticker == null ? "; DISPOSED" : (_ticker.muted ? "; silenced" : "");
string label = debugLabel == null ? "" : "; for " + debugLabel;
string more = $"{base.toStringDetails()} {value:F3}";
return more + paused + ticker + label;
}

class _InterpolationSimulation : Simulation {
internal _InterpolationSimulation(float begin, float end, TimeSpan duration, Curve curve) {
this._begin = begin;
this._end = end;
this._curve = curve;
_begin = begin;
_end = end;
_curve = curve;
this._durationInSeconds = (float) duration.Ticks / TimeSpan.TicksPerSecond;
_durationInSeconds = (float) duration.Ticks / TimeSpan.TicksPerSecond;
}
readonly float _durationInSeconds;

public override float x(float timeInSeconds) {
float t = (timeInSeconds / this._durationInSeconds).clamp(0.0f, 1.0f);
float t = (timeInSeconds / _durationInSeconds).clamp(0.0f, 1.0f);
return this._begin;
return _begin;
return this._end;
return _end;
return this._begin + (this._end - this._begin) * this._curve.transform(t);
return _begin + (_end - _begin) * _curve.transform(t);
float epsilon = this.tolerance.time;
return (this.x(timeInSeconds + epsilon) - this.x(timeInSeconds - epsilon)) / (2 * epsilon);
float epsilon = tolerance.time;
return (x(timeInSeconds + epsilon) - x(timeInSeconds - epsilon)) / (2 * epsilon);
return timeInSeconds > this._durationInSeconds;
return timeInSeconds > _durationInSeconds;
delegate void _DirectionSetter(_AnimationDirection direction);
internal _RepeatingSimulation(float initialValue, float min, float max, bool reverse, TimeSpan period) {
this._min = min;
this._max = max;
this._periodInSeconds = (float) period.Ticks / TimeSpan.TicksPerSecond;
this._initialT =
internal _RepeatingSimulation(float initialValue, float min, float max, bool reverse, TimeSpan period, _DirectionSetter directionSetter) {
_min = min;
_max = max;
_periodInSeconds = (float) period.Ticks / TimeSpan.TicksPerSecond;
_initialT =
this._reverse = reverse;
D.assert(this._periodInSeconds > 0.0f);
D.assert(this._initialT >= 0.0f);
_reverse = reverse;
this.directionSetter = directionSetter;
D.assert(_periodInSeconds > 0.0f);
D.assert(_initialT >= 0.0f);
}
readonly float _min;

readonly float _initialT;
readonly _DirectionSetter directionSetter;
float totalTimeInSeconds = timeInSeconds + this._initialT;
float t = (totalTimeInSeconds / this._periodInSeconds) % 1.0f;
bool _isPlayingReverse = ((int) (totalTimeInSeconds / this._periodInSeconds)) % 2 == 1;
float totalTimeInSeconds = timeInSeconds + _initialT;
float t = (totalTimeInSeconds / _periodInSeconds) % 1.0f;
bool _isPlayingReverse = ((int) (totalTimeInSeconds / _periodInSeconds)) % 2 == 1;
if (this._reverse && _isPlayingReverse) {
return MathUtils.lerpFloat(this._max, this._min, t);
if (_reverse && _isPlayingReverse) {
directionSetter(_AnimationDirection.reverse);
return MathUtils.lerpNullableFloat(_max, _min, t);
return MathUtils.lerpFloat(this._min, this._max, t);
directionSetter(_AnimationDirection.forward);
return MathUtils.lerpNullableFloat(_min, _max, t);
return (this._max - this._min) / this._periodInSeconds;
return (_max - _min) / _periodInSeconds;
}
public override bool isDone(float timeInSeconds) {

278
com.unity.uiwidgets/Runtime/animation/animations.cs


using UnityEngine;
namespace Unity.UIWidgets.animation {
class _AlwaysCompleteAnimation : Animation<float> {
internal _AlwaysCompleteAnimation() {
}

public class AlwaysStoppedAnimation<T> : Animation<T> {
public AlwaysStoppedAnimation(T value) {
this._value = value;
_value = value;
get { return this._value; }
get { return _value; }
}
readonly T _value;

}
public override string toStringDetails() {
return $"{base.toStringDetails()} {this.value}; paused";
return $"{base.toStringDetails()} {value}; paused";
}
}

public override void addListener(VoidCallback listener) {
this.parent.addListener(listener);
parent.addListener(listener);
this.parent.removeListener(listener);
parent.removeListener(listener);
this.parent.addStatusListener(listener);
parent.addStatusListener(listener);
this.parent.removeStatusListener(listener);
parent.removeStatusListener(listener);
get { return this.parent.status; }
get { return parent.status; }
}
}

this._parent = animation;
if (this._parent == null) {
this._status = AnimationStatus.dismissed;
this._value = 0.0f;
_parent = animation;
if (_parent == null) {
_status = AnimationStatus.dismissed;
_value = 0.0f;
}
}

public Animation<float> parent {
get { return this._parent; }
get { return _parent; }
if (value == this._parent) {
if (value == _parent) {
if (this._parent != null) {
this._status = this._parent.status;
this._value = this._parent.value;
if (this.isListening) {
this.didStopListening();
if (_parent != null) {
_status = _parent.status;
_value = _parent.value;
if (isListening) {
didStopListening();
this._parent = value;
if (this._parent != null) {
if (this.isListening) {
this.didStartListening();
_parent = value;
if (_parent != null) {
if (isListening) {
didStartListening();
if (this._value != this._parent.value) {
this.notifyListeners();
if (_value != _parent.value) {
notifyListeners();
if (this._status != this._parent.status) {
this.notifyStatusListeners(this._parent.status);
if (_status != _parent.status) {
notifyStatusListeners(_parent.status);
this._status = AnimationStatus.dismissed;
this._value = 0;
_status = AnimationStatus.dismissed;
_value = 0;
}
}
}

protected override void didStartListening() {
if (this._parent != null) {
this._parent.addListener(this.notifyListeners);
this._parent.addStatusListener(this.notifyStatusListeners);
if (_parent != null) {
_parent.addListener(notifyListeners);
_parent.addStatusListener(notifyStatusListeners);
if (this._parent != null) {
this._parent.removeListener(this.notifyListeners);
this._parent.removeStatusListener(this.notifyStatusListeners);
if (_parent != null) {
_parent.removeListener(notifyListeners);
_parent.removeStatusListener(notifyStatusListeners);
get { return this._parent != null ? this._parent.status : this._status; }
get { return _parent != null ? _parent.status : _status; }
get { return this._parent != null ? this._parent.value : this._value; }
get { return _parent != null ? _parent.value : _value; }
if (this.parent == null) {
return $"{this.GetType()}(null; {this.toStringDetails()} {this.value:F3}";
if (parent == null) {
return $"{GetType()}(null; {toStringDetails()} {value:F3}";
return $"{this.parent}\u27A9{this.GetType()}";
return $"{parent}\u27A9{GetType()}";
}
}

D.assert(parent != null);
this._parent = parent;
_parent = parent;
get { return this._parent; }
get { return _parent; }
this.didRegisterListener();
this.parent.addListener(listener);
didRegisterListener();
parent.addListener(listener);
this.parent.removeListener(listener);
this.didUnregisterListener();
parent.removeListener(listener);
didUnregisterListener();
this.parent.addStatusListener(this._statusChangeHandler);
parent.addStatusListener(_statusChangeHandler);
this.parent.removeStatusListener(this._statusChangeHandler);
parent.removeStatusListener(_statusChangeHandler);
this.notifyStatusListeners(this._reverseStatus(status));
notifyStatusListeners(_reverseStatus(status));
get { return this._reverseStatus(this.parent.status); }
get { return _reverseStatus(parent.status); }
get { return 1.0f - this.parent.value; }
get { return 1.0f - parent.value; }
}
AnimationStatus _reverseStatus(AnimationStatus status) {

}
public override string ToString() {
return this.parent + "\u27AA" + this.GetType();
return parent + "\u27AA" + GetType();
}
}

) {
D.assert(parent != null);
D.assert(curve != null);
this._parent = parent;
_parent = parent;
this._updateCurveDirection(parent.status);
parent.addStatusListener(this._updateCurveDirection);
_updateCurveDirection(parent.status);
parent.addStatusListener(_updateCurveDirection);
get { return this._parent; }
get { return _parent; }
}
readonly Animation<float> _parent;

switch (status) {
case AnimationStatus.dismissed:
case AnimationStatus.completed:
this._curveDirection = null;
_curveDirection = null;
this._curveDirection = this._curveDirection ?? AnimationStatus.forward;
_curveDirection = _curveDirection ?? AnimationStatus.forward;
this._curveDirection = this._curveDirection ?? AnimationStatus.reverse;
_curveDirection = _curveDirection ?? AnimationStatus.reverse;
break;
}
}

return this.reverseCurve == null ||
(this._curveDirection ?? this.parent.status) != AnimationStatus.reverse;
return reverseCurve == null ||
(_curveDirection ?? parent.status) != AnimationStatus.reverse;
Curve activeCurve = this._useForwardCurve ? this.curve : this.reverseCurve;
Curve activeCurve = _useForwardCurve ? curve : reverseCurve;
float t = this.parent.value;
float t = parent.value;
if (activeCurve == null) {
return t;
}

}
public override string ToString() {
if (this.reverseCurve == null) {
return this.parent + "\u27A9" + this.curve;
if (reverseCurve == null) {
return parent + "\u27A9" + curve;
if (this._useForwardCurve) {
return this.parent + "\u27A9" + this.curve + "\u2092\u2099/" + this.reverseCurve;
if (_useForwardCurve) {
return parent + "\u27A9" + curve + "\u2092\u2099/" + reverseCurve;
return this.parent + "\u27A9" + this.curve + "/" + this.reverseCurve + "\u2092\u2099";
return parent + "\u27A9" + curve + "/" + reverseCurve + "\u2092\u2099";
}
}

Animation<float> nextTrain = null,
VoidCallback onSwitchedTrain = null) {
D.assert(currentTrain != null);
this._currentTrain = currentTrain;
this._nextTrain = nextTrain;
_currentTrain = currentTrain;
_nextTrain = nextTrain;
if (this._nextTrain != null) {
if (this._currentTrain.value > this._nextTrain.value) {
this._mode = _TrainHoppingMode.maximize;
if (_nextTrain != null) {
if (_currentTrain.value > _nextTrain.value) {
_mode = _TrainHoppingMode.maximize;
this._mode = _TrainHoppingMode.minimize;
if (this._currentTrain.value == this._nextTrain.value) {
this._currentTrain = this._nextTrain;
this._nextTrain = null;
_mode = _TrainHoppingMode.minimize;
if (_currentTrain.value == _nextTrain.value) {
_currentTrain = _nextTrain;
_nextTrain = null;
this._currentTrain.addStatusListener(this._statusChangeHandler);
this._currentTrain.addListener(this._valueChangeHandler);
if (this._nextTrain != null) {
this._nextTrain.addListener(this._valueChangeHandler);
_currentTrain.addStatusListener(_statusChangeHandler);
_currentTrain.addListener(_valueChangeHandler);
if (_nextTrain != null) {
_nextTrain.addListener(_valueChangeHandler);
get { return this._currentTrain; }
get { return _currentTrain; }
}
Animation<float> _currentTrain;

AnimationStatus? _lastStatus;
void _statusChangeHandler(AnimationStatus status) {
D.assert(this._currentTrain != null);
D.assert(_currentTrain != null);
if (status != this._lastStatus) {
this.notifyListeners();
this._lastStatus = status;
if (status != _lastStatus) {
notifyListeners();
_lastStatus = status;
D.assert(this._lastStatus != null);
D.assert(_lastStatus != null);
get { return this._currentTrain.status; }
get { return _currentTrain.status; }
D.assert(this._currentTrain != null);
D.assert(_currentTrain != null);
if (this._nextTrain != null) {
switch (this._mode) {
if (_nextTrain != null) {
switch (_mode) {
hop = this._nextTrain.value <= this._currentTrain.value;
hop = _nextTrain.value <= _currentTrain.value;
hop = this._nextTrain.value >= this._currentTrain.value;
hop = _nextTrain.value >= _currentTrain.value;
this._currentTrain.removeStatusListener(this._statusChangeHandler);
this._currentTrain.removeListener(this._valueChangeHandler);
this._currentTrain = this._nextTrain;
this._nextTrain = null;
this._currentTrain.addStatusListener(this._statusChangeHandler);
this._statusChangeHandler(this._currentTrain.status);
_currentTrain.removeStatusListener(_statusChangeHandler);
_currentTrain.removeListener(_valueChangeHandler);
_currentTrain = _nextTrain;
_nextTrain = null;
_currentTrain.addStatusListener(_statusChangeHandler);
_statusChangeHandler(_currentTrain.status);
float newValue = this.value;
if (newValue != this._lastValue) {
this.notifyListeners();
this._lastValue = newValue;
float newValue = value;
if (newValue != _lastValue) {
notifyListeners();
_lastValue = newValue;
D.assert(this._lastValue != null);
D.assert(_lastValue != null);
if (hop && this.onSwitchedTrain != null) {
this.onSwitchedTrain();
if (hop && onSwitchedTrain != null) {
onSwitchedTrain();
get { return this._currentTrain.value; }
get { return _currentTrain.value; }
D.assert(this._currentTrain != null);
D.assert(_currentTrain != null);
this._currentTrain.removeStatusListener(this._statusChangeHandler);
this._currentTrain.removeListener(this._valueChangeHandler);
this._currentTrain = null;
_currentTrain.removeStatusListener(_statusChangeHandler);
_currentTrain.removeListener(_valueChangeHandler);
_currentTrain = null;
if (this._nextTrain != null) {
this._nextTrain.removeListener(this._valueChangeHandler);
this._nextTrain = null;
if (_nextTrain != null) {
_nextTrain.removeListener(_valueChangeHandler);
_nextTrain = null;
if (this._nextTrain != null) {
return $"{this.currentTrain}\u27A9{this.GetType()}(next: {this._nextTrain})";
if (_nextTrain != null) {
return $"{currentTrain}\u27A9{GetType()}(next: {_nextTrain})";
return $"{this.currentTrain}\u27A9{this.GetType()}(no next)";
return $"{currentTrain}\u27A9{GetType()}(no next)";
}
}

public readonly Animation<T> next;
protected override void didStartListening() {
this.first.addListener(this._maybeNotifyListeners);
this.first.addStatusListener(this._maybeNotifyStatusListeners);
this.next.addListener(this._maybeNotifyListeners);
this.next.addStatusListener(this._maybeNotifyStatusListeners);
first.addListener(_maybeNotifyListeners);
first.addStatusListener(_maybeNotifyStatusListeners);
next.addListener(_maybeNotifyListeners);
next.addStatusListener(_maybeNotifyStatusListeners);
this.first.removeListener(this._maybeNotifyListeners);
this.first.removeStatusListener(this._maybeNotifyStatusListeners);
this.next.removeListener(this._maybeNotifyListeners);
this.next.removeStatusListener(this._maybeNotifyStatusListeners);
first.removeListener(_maybeNotifyListeners);
first.removeStatusListener(_maybeNotifyStatusListeners);
next.removeListener(_maybeNotifyListeners);
next.removeStatusListener(_maybeNotifyStatusListeners);
if (this.next.status == AnimationStatus.forward || this.next.status == AnimationStatus.reverse) {
return this.next.status;
if (next.status == AnimationStatus.forward || next.status == AnimationStatus.reverse) {
return next.status;
return this.first.status;
return first.status;
return $"{this.GetType()}({this.first}, {this.next})";
return $"{GetType()}({first}, {next})";
if (this.status != this._lastStatus) {
this._lastStatus = this.status;
this.notifyStatusListeners(this.status);
if (status != _lastStatus) {
_lastStatus = status;
notifyStatusListeners(status);
}
}

if (!Equals(this.value, this._lastValue)) {
this._lastValue = this.value;
this.notifyListeners();
if (!Equals(value, _lastValue)) {
_lastValue = value;
notifyListeners();
}
}
}

}
public override float value {
get { return (this.first.value + this.next.value) / 2.0f; }
get { return (first.value + next.value) / 2.0f; }
}
}

}
public override float value {
get { return Mathf.Max(this.first.value, this.next.value); }
get { return Mathf.Max(first.value, next.value); }
}
}

}
public override float value {
get { return Mathf.Min(this.first.value, this.next.value); }
get { return Mathf.Min(first.value, next.value); }
}
}

526
com.unity.uiwidgets/Runtime/animation/curves.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Random = System.Random;
public abstract class Curve {
public float transform(float t) {
D.assert(t >= 0.0f && t <= 1.0f);
public abstract class ParametricCurve<T> {
public virtual T transform(float t) {
D.assert(t >= 0.0f && t <= 1.0f, () => $"parametric value {t} is outside of [0, 1] range.");
return transformInternal(t);
}
protected virtual T transformInternal(float t) {
throw new NotImplementedException();
}
public override string ToString() {
return $"{GetType()}";
}
}
public abstract class Curve : ParametricCurve<float> {
public override float transform(float t) {
return this.transformInternal(t);
}
protected virtual float transformInternal(float t) {
throw new NotImplementedException();
return base.transform(t);
}
public override string ToString() {
return this.GetType().ToString();
}
}

public readonly int count;
protected override float transformInternal(float t) {
t *= this.count;
t *= count;
return $"{this.GetType()}({this.count})";
return $"{GetType()}({count})";
}
}

protected override float transformInternal(float t) {
D.assert(t >= 0.0 && t <= 1.0);
D.assert(this.begin >= 0.0);
D.assert(this.begin <= 1.0);
D.assert(this.end >= 0.0);
D.assert(this.end <= 1.0);
D.assert(this.end >= this.begin);
t = ((t - this.begin) / (this.end - this.begin)).clamp(0.0f, 1.0f);
D.assert(begin >= 0.0);
D.assert(begin <= 1.0);
D.assert(end >= 0.0);
D.assert(end <= 1.0);
D.assert(end >= begin);
t = ((t - begin) / (end - begin)).clamp(0.0f, 1.0f);
return this.curve.transform(t);
return curve.transform(t);
if (!(this.curve is _Linear)) {
return $"{this.GetType()}({this.begin}\u22EF{this.end}\u27A9{this.curve}";
if (!(curve is _Linear)) {
return $"{GetType()}({begin}\u22EF{end}\u27A9{curve}";
return $"{this.GetType()}({this.begin}\u22EF{this.end})";
return $"{GetType()}({begin}\u22EF{end})";
}
}

public readonly float threshold;
protected override float transformInternal(float t) {
D.assert(this.threshold >= 0.0);
D.assert(this.threshold <= 1.0);
return t < this.threshold ? 0.0f : 1.0f;
D.assert(threshold >= 0.0);
D.assert(threshold <= 1.0);
return t < threshold ? 0.0f : 1.0f;
}
}

float end = 1.0f;
while (true) {
float midpoint = (start + end) / 2;
float estimate = this._evaluateCubic(this.a, this.c, midpoint);
float estimate = _evaluateCubic(a, c, midpoint);
return this._evaluateCubic(this.b, this.d, midpoint);
return _evaluateCubic(b, d, midpoint);
}
if (estimate < t) {

}
public override string ToString() {
return $"{this.GetType()}({this.a:F2}, {this.b:F2}, {this.c:F2}, {this.d:F2})";
return $"{GetType()}({a:F2}, {b:F2}, {c:F2}, {d:F2})";
}
}
public abstract class Curve2D : ParametricCurve<Offset> {
internal IEnumerable<Curve2DSample> generateSamples(
float start = 0.0f,
float end = 1.0f,
float tolerance = 1e-10f) {
D.assert(end > start);
Random rand = new Random(samplingSeed);
bool isFlat(Offset p, Offset q, Offset r) {
Offset pr = p - r;
Offset qr = q - r;
float z = pr.dx * qr.dy - qr.dx * pr.dy;
return z * z < tolerance;
}
Curve2DSample first = new Curve2DSample(start, transform(start));
Curve2DSample last = new Curve2DSample(end, transform(end));
List<Curve2DSample> samples = new List<Curve2DSample>(){first};
void sample(Curve2DSample p, Curve2DSample q, bool forceSubdivide = false) {
float t = p.t + (0.45f + 0.1f * (float)rand.NextDouble() * (q.t - p.t));
Curve2DSample r = new Curve2DSample(t, transform(t));
if (!forceSubdivide && isFlat(p.value, q.value, r.value)) {
samples.Add(q);
}
else {
sample(p, r);
sample(r, q);
}
}
sample(first, last,
forceSubdivide: (first.value.dx - last.value.dx).abs() < tolerance &&
(first.value.dy - last.value.dy).abs() < tolerance);
return samples;
}
protected virtual int samplingSeed {
get { return 0; }
}
public float findInverse(float x) {
float start = 0.0f;
float end = 1.0f;
float mid = 0f;
float offsetToOrigin(float pos) {
return x - transform(pos).dx;
}
const float errorLimit = 1e-6f;
int count = 100;
float startValue = offsetToOrigin(start);
while ((end - start / 2.0f) > errorLimit && count > 0) {
mid = (end + start) / 2.0f;
float value = offsetToOrigin(mid);
if (value.sign() == startValue.sign()) {
start = mid;
}
else {
end = mid;
}
count--;
}
return mid;
}
}
internal class Curve2DSample {
public Curve2DSample(float t, Offset value) {
this.t = t;
this.value = value;
}
public readonly float t;
public readonly Offset value;
public override string ToString() {
return $"[{value.dx:F2}, {value.dy:F2}, {t:F2}]";
}
}
class CatmullRomSpline : Curve2D {
CatmullRomSpline(
List<Offset> controlPoints,
float? tension = 0.0f,
Offset startHandle = null,
Offset endHandle = null
) {
D.assert(controlPoints != null);
D.assert(tension != null);
D.assert(tension <= 1.0f, () => $"tension {tension} must not be greater than 1.0.");
D.assert(tension >= 0.0f, () => $"tension {tension} must not be negative.");
D.assert(controlPoints.Count > 3, () => "There must be at least four control points to create a CatmullRomSpline.");
_controlPoints = controlPoints;
_startHandle = startHandle;
_endHandle = endHandle;
_tension = tension;
_cubicSegments = new List<List<Offset>>();
}
internal CatmullRomSpline(
List<Offset> controlPoints,
float? tension = 0.0f,
Offset startHandle = null,
Offset endHandle = null,
List<List<Offset>> cubicSegments = null
) {
D.assert(cubicSegments != null);
_controlPoints = controlPoints;
_startHandle = startHandle;
_endHandle = endHandle;
_tension = tension;
_cubicSegments = new List<List<Offset>>();
}
public static CatmullRomSpline precompute(
List<Offset> controlPoints,
float? tension = 0.0f,
Offset startHandle = null,
Offset endHandle = null
) {
D.assert(controlPoints != null);
D.assert(tension != null);
D.assert(tension <= 1.0f, () => $"tension {tension} must not be greater than 1.0.");
D.assert(tension >= 0.0f, () => $"tension {tension} must not be negative.");
D.assert(controlPoints.Count > 3, () => "There must be at least four control points to create a CatmullRomSpline.");
return new CatmullRomSpline(
controlPoints: null,
tension: null,
startHandle: null,
endHandle: null,
cubicSegments: _computeSegments(controlPoints, tension, startHandle: startHandle, endHandle: endHandle)
);
}
static List<List<Offset>> _computeSegments(
List<Offset> controlPoints,
float? tension,
Offset startHandle,
Offset endHandle) {
startHandle = startHandle ?? controlPoints[0] * 2.0f - controlPoints[1];
endHandle = endHandle ?? controlPoints.last() * 2.0f - controlPoints[controlPoints.Count - 2];
List<Offset> allPoints = new List<Offset>();
allPoints.Add(startHandle);
allPoints.AddRange(controlPoints);
allPoints.Add(endHandle);
const float alpha = 0.5f;
float reverseTension = 1.0f - tension.Value;
List<List<Offset>> result = new List<List<Offset>>();
for (int i = 0; i < allPoints.Count - 3; ++i) {
List<Offset> curve = new List<Offset>{allPoints[i], allPoints[i + 1], allPoints[i + 2], allPoints[i + 3]};
Offset diffCurve10 = curve[1] - curve[0];
Offset diffCurve21 = curve[2] - curve[1];
Offset diffCurve32 = curve[3] - curve[2];
float t01 = Mathf.Pow(diffCurve10.distance, alpha);
float t12 = Mathf.Pow(diffCurve21.distance, alpha);
float t23 = Mathf.Pow(diffCurve32.distance, alpha);
Offset m1 = (diffCurve21 + (diffCurve10 / t01 - (curve[2] - curve[0]) / (t01 + t12)) * t12) * reverseTension;
Offset m2 = (diffCurve21 + (diffCurve32 / t23 - (curve[3] - curve[1]) / (t12 + t23)) * t12) * reverseTension;
Offset sumM12 = m1 + m2;
List<Offset> segment = new List<Offset> {
diffCurve21 * -2.0f + sumM12,
diffCurve21 * 3.0f - m1 - sumM12,
m1,
curve[1]
};
result.Add(segment);
}
return result;
}
readonly List<List<Offset>> _cubicSegments;
readonly List<Offset> _controlPoints;
readonly Offset _startHandle;
readonly Offset _endHandle;
readonly float? _tension;
void _initializeIfNeeded() {
if (_cubicSegments.isNotEmpty()) {
return;
}
_cubicSegments.AddRange(_computeSegments(_controlPoints, _tension, startHandle: _startHandle, endHandle: _endHandle));
}
protected override int samplingSeed {
get {
_initializeIfNeeded();
Offset seedPoint = _cubicSegments[0][1];
return ((seedPoint.dx + seedPoint.dy) * 10000).round();
}
}
protected override Offset transformInternal(float t) {
_initializeIfNeeded();
float length = _cubicSegments.Count;
float position;
float localT;
int index;
if (t < 1.0f) {
position = t * length;
localT = position - position.floor();
index = position.floor();
} else {
position = length;
localT = 1.0f;
index = _cubicSegments.Count - 1;
}
List<Offset> cubicControlPoints = _cubicSegments[index];
float localT2 = localT * localT;
return cubicControlPoints[0] * localT2 * localT
+ cubicControlPoints[1] * localT2
+ cubicControlPoints[2] * localT
+ cubicControlPoints[3];
}
}
public class CatmullRomCurve : Curve {
public CatmullRomCurve(
List<Offset> controlPoints,
float? tension = 0.0f) {
D.assert(tension != null);
this.controlPoints = controlPoints;
this.tension = tension;
D.assert(() => {
_debugAssertReasons.Clear();
return validateControlPoints(controlPoints,
tension: tension,
reasons: _debugAssertReasons);
}, () => $"control points {controlPoints} could not be validated:\n {string.Join("\n ", _debugAssertReasons)}");
_precomputedSamples = new List<Curve2DSample>();
}
internal CatmullRomCurve(
List<Offset> controlPoints,
float? tension = 0.0f,
List<Curve2DSample> precomputedSamples = null) {
D.assert(precomputedSamples != null);
D.assert(tension != null);
this.controlPoints = controlPoints;
this.tension = tension;
D.assert(() => {
_debugAssertReasons.Clear();
return validateControlPoints(controlPoints,
tension: tension,
reasons: _debugAssertReasons);
}, () => $"control points {controlPoints} could not be validated:\n {string.Join("\n ", _debugAssertReasons)}");
_precomputedSamples = precomputedSamples;
}
public static CatmullRomCurve precompute(
List<Offset> controlPoints, float? tension = 0.0f) {
return new CatmullRomCurve(
controlPoints,
tension,
_computeSamples(controlPoints, tension));
}
static List<Curve2DSample> _computeSamples(List<Offset> controlPoints, float? tension) {
List<Offset> _controlPoints = new List<Offset>();
_controlPoints.Add(Offset.zero);
_controlPoints.AddRange(controlPoints);
_controlPoints.Add(new Offset(1.0f, 1.0f));
return CatmullRomSpline.precompute(_controlPoints, tension: tension).generateSamples(
start: 0.0f, end: 1.0f, tolerance: 1e-12f).ToList();
}
static readonly List<string> _debugAssertReasons = new List<string>();
readonly List<Curve2DSample> _precomputedSamples;
public readonly List<Offset> controlPoints;
public readonly float? tension;
static bool validateControlPoints(
List<Offset> controlPoints,
float? tension = 0.0f,
List<string> reasons = null) {
D.assert(tension != null);
if (controlPoints == null) {
D.assert(() => {
reasons?.Add("Supplied control points cannot be null");
return true;
});
return false;
}
if (controlPoints.Count < 2) {
D.assert(() => {
reasons?.Add("There must be at least two points supplied to create a valid curve.");
return true;
});
return false;
}
List<Offset> _controlPoints = new List<Offset>();
_controlPoints.AddRange(controlPoints);
_controlPoints.Insert(0, Offset.zero);
_controlPoints.Add(new Offset(1.0f, 1.0f));
Offset startHandle = _controlPoints[0] * 2.0f - _controlPoints[1];
Offset endHandle = _controlPoints.last() * 2.0f - _controlPoints[_controlPoints.Count - 2];
_controlPoints.Insert(0, startHandle);
_controlPoints.Add(endHandle);
float lastX = -float.PositiveInfinity;
for (int i = 0; i < _controlPoints.Count; ++i) {
if (i > 1 &&
i < _controlPoints.Count - 2 &&
(_controlPoints[i].dx <= 0.0f || _controlPoints[i].dx >= 1.0f)) {
D.assert(() => {
reasons?.Add("Control points must have X values between 0.0 and 1.0, exclusive. " +
$"Point {i} has an x value ({_controlPoints[i].dx}) which is outside the range.");
return true;
});
return false;
}
if (_controlPoints[i].dx <= lastX) {
D.assert(() => {
reasons?.Add("Each X coordinate must be greater than the preceding X coordinate " +
$"(i.e. must be monotonically increasing in X). Point {i} has an x value of " +
$"{_controlPoints[i].dx}, which is not greater than {lastX}");
return true;
});
return false;
}
lastX = _controlPoints[i].dx;
}
bool success = true;
lastX = -float.PositiveInfinity;
const float tolerance = 1e-3f;
CatmullRomSpline testSpline = new CatmullRomSpline(_controlPoints, tension: tension);
float start = testSpline.findInverse(0.0f);
float end = testSpline.findInverse(1.0f);
IEnumerable<Curve2DSample> samplePoints = testSpline.generateSamples(start: start, end: end);
if (samplePoints.First().value.dy.abs() > tolerance ||
(1.0f - samplePoints.Last().value.dy).abs() > tolerance) {
bool bail = true;
success = false;
D.assert(() => {
reasons?.Add($"The curve has more than one Y value at X = {samplePoints.First().value.dx}. " +
"Try moving some control points further away from this value of X, or increasing " +
"the tension.");
bail = reasons == null;
return true;
});
if (bail) {
return false;
}
}
foreach (Curve2DSample sample in samplePoints) {
Offset point = sample.value;
float t = sample.t;
float x = point.dx;
if (t >= start && t <= end && (x < -1e-3f || x > 1.0f + 1e-3f)) {
bool bail = true;
success = false;
D.assert(() => {
reasons?.Add($"The resulting curve has an X value ({x}) which is outside " +
"the range [0.0, 1.0], inclusive.");
bail = reasons == null;
return true;
});
if (bail) {
return false;
}
}
if (x < lastX) {
bool bail = true;
success = false;
D.assert(() => {
reasons?.Add($"The curve has more than one Y value at x = {x}. Try moving " +
"some control points further apart in X, or increasing the tension.");
bail = reasons == null;
return true;
});
if (bail) {
return false;
}
}
lastX = x;
}
return success;
}
protected override float transformInternal(float t) {
if (_precomputedSamples.isEmpty()) {
// Compute the samples now if we were constructed lazily.
_precomputedSamples.AddRange(_computeSamples(controlPoints, tension));
}
int start = 0;
int end = _precomputedSamples.Count - 1;
int mid;
Offset value;
Offset startValue = _precomputedSamples[start].value;
Offset endValue = _precomputedSamples[end].value;
while (end - start > 1) {
mid = (end + start) / 2;
value = _precomputedSamples[mid].value;
if (t >= value.dx) {
start = mid;
startValue = value;
} else {
end = mid;
endValue = value;
}
}
float t2 = (t - startValue.dx) / (endValue.dx - startValue.dx);
return MathUtils.lerpNullableFloat(startValue.dy, endValue.dy, t2);
}
}

public readonly Curve curve;
protected override float transformInternal(float t) {
return 1.0f - this.curve.transform(1.0f - t);
return 1.0f - curve.transform(1.0f - t);
return $"{this.GetType()}({this.curve})";
return $"{GetType()}({curve})";
}
}

public readonly float period;
protected override float transformInternal(float t) {
float s = this.period / 4.0f;
float s = period / 4.0f;
return -Mathf.Pow(2.0f, 10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period);
return -Mathf.Pow(2.0f, 10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / period);
return $"{this.GetType()}({this.period})";
return $"{GetType()}({period})";
}
}

public readonly float period;
protected override float transformInternal(float t) {
float s = this.period / 4.0f;
return Mathf.Pow(2.0f, -10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period) + 1.0f;
float s = period / 4.0f;
return Mathf.Pow(2.0f, -10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / period) + 1.0f;
return $"{this.GetType()}({this.period})";
return $"{GetType()}({period})";
}
}

public readonly float period;
protected override float transformInternal(float t) {
float s = this.period / 4.0f;
float s = period / 4.0f;
return -0.5f * Mathf.Pow(2.0f, 10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period);
return -0.5f * Mathf.Pow(2.0f, 10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / period);
return Mathf.Pow(2.0f, -10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / this.period) * 0.5f +
return Mathf.Pow(2.0f, -10.0f * t) * Mathf.Sin((t - s) * (Mathf.PI * 2.0f) / period) * 0.5f +
return $"{this.GetType()}({this.period})";
return $"{GetType()}({period})";
}
}

179
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.gen.cs


int _listenerCounter = 0;
protected void didRegisterListener() {
D.assert(this._listenerCounter >= 0);
if (this._listenerCounter == 0) {
this.didStartListening();
D.assert(_listenerCounter >= 0);
if (_listenerCounter == 0) {
didStartListening();
this._listenerCounter += 1;
_listenerCounter += 1;
D.assert(this._listenerCounter >= 1);
this._listenerCounter -= 1;
if (this._listenerCounter == 0) {
this.didStopListening();
D.assert(_listenerCounter >= 1);
_listenerCounter -= 1;
if (_listenerCounter == 0) {
didStopListening();
}
}

public bool isListening {
get { return this._listenerCounter > 0; }
get { return _listenerCounter > 0; }
}
}

readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {
this.didRegisterListener();
this._listeners.Add(listener);
didRegisterListener();
_listeners.Add(listener);
bool removed = this._listeners.Remove(listener);
bool removed = _listeners.Remove(listener);
this.didUnregisterListener();
didUnregisterListener();
var localListeners = new List<VoidCallback>(this._listeners);
var localListeners = new List<VoidCallback>(_listeners);
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
if (this._listeners.Contains(listener)) {
if (_listeners.Contains(listener)) {
listener();
}
} catch (Exception exception) {

context: "while notifying listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + GetType()),
informationCollector: collector
));
}
}

readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {
this.didRegisterListener();
this._listeners.Add(listener);
didRegisterListener();
_listeners.Add(listener);
bool removed = this._listeners.Remove(listener);
bool removed = _listeners.Remove(listener);
this.didUnregisterListener();
didUnregisterListener();
var localListeners = new List<VoidCallback>(this._listeners);
var localListeners = new List<VoidCallback>(_listeners);
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T>>(
"The " + GetType() + " notifying listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
if (this._listeners.Contains(listener)) {
if (_listeners.Contains(listener)) {
listener();
}
} catch (Exception exception) {

context: "while notifying listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + GetType()),
informationCollector: collector
));
}
}

readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {
this.didRegisterListener();
this._statusListeners.Add(listener);
didRegisterListener();
_statusListeners.Add(listener);
bool removed = this._statusListeners.Remove(listener);
bool removed = _statusListeners.Remove(listener);
this.didUnregisterListener();
didUnregisterListener();
var localListeners = new List<AnimationStatusListener>(this._statusListeners);
var localListeners = new List<AnimationStatusListener>(_statusListeners);
if (this._statusListeners.Contains(listener)) {
if (_statusListeners.Contains(listener)) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying status listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
context: "while notifying status listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: collector
));
}
}

readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {
this.didRegisterListener();
this._statusListeners.Add(listener);
didRegisterListener();
_statusListeners.Add(listener);
bool removed = this._statusListeners.Remove(listener);
bool removed = _statusListeners.Remove(listener);
this.didUnregisterListener();
didUnregisterListener();
var localListeners = new List<AnimationStatusListener>(this._statusListeners);
var localListeners = new List<AnimationStatusListener>(_statusListeners);
if (this._statusListeners.Contains(listener)) {
if (_statusListeners.Contains(listener)) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T>>(
"The " + GetType() + " notifying status listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
context: "while notifying status listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: collector
));
}
}

readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {
this.didRegisterListener();
this._statusListeners.Add(listener);
didRegisterListener();
_statusListeners.Add(listener);
bool removed = this._statusListeners.Remove(listener);
bool removed = _statusListeners.Remove(listener);
this.didUnregisterListener();
didUnregisterListener();
var localListeners = new List<AnimationStatusListener>(this._statusListeners);
var localListeners = new List<AnimationStatusListener>(_statusListeners);
if (this._statusListeners.Contains(listener)) {
if (_statusListeners.Contains(listener)) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T>>(
"The " + GetType() + " notifying status listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
context: "while notifying status listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + GetType()),
informationCollector: collector
));
}
}

40
com.unity.uiwidgets/Runtime/animation/listener_helpers.mixin.njk


public void notifyListeners() {
var localListeners = new List<VoidCallback>(this._listeners);
foreach (VoidCallback listener in localListeners) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
try {
if (this._listeners.Contains(listener)) {
listener();

exception: exception,
library: "animation library",
context: "while notifying listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying listeners for " + this.GetType()),
informationCollector: collector
));
}
}

listener(status);
}
} catch (Exception exception) {
InformationCollector collector = null;
D.assert(() => {
IEnumerable<DiagnosticsNode> infoCollector() {
yield return new DiagnosticsProperty<AnimationLocalStatusListenersMixin{{with | safe}}>(
"The " + this.GetType() + " notifying status listeners was",
this,
style: DiagnosticsTreeStyle.errorProperty
);
}
collector = infoCollector;
return true;
});
context: "while notifying status listeners for " + this.GetType(),
informationCollector: information => {
information.AppendLine("The " + this.GetType() + " notifying status listeners was:");
information.Append(" " + this);
}
context: new ErrorDescription("while notifying status listeners for " + this.GetType()),
informationCollector: collector
));
}
}

130
com.unity.uiwidgets/Runtime/animation/tween.cs


namespace Unity.UIWidgets.animation {
public abstract class Animatable<T> {
public abstract T evaluate(Animation<float> animation);
public Animatable() {
}
public abstract T transform(float t);
public T evaluate(Animation<float> animation) {
return transform(animation.value);
}
public Animation<T> animate(Animation<float> parent) {
return new _AnimatedEvaluation<T>(parent, this);

class _AnimatedEvaluation<T> : AnimationWithParentMixin<float, T> {
internal _AnimatedEvaluation(Animation<float> parent, Animatable<T> evaluatable) {
this._parent = parent;
this._evaluatable = evaluatable;
_parent = parent;
_evaluatable = evaluatable;
get { return this._parent; }
get { return _parent; }
}
readonly Animation<float> _parent;

public override T value {
get { return this._evaluatable.evaluate(this.parent); }
get {
return _evaluatable.evaluate(parent);
}
return $"{this.parent}\u27A9{this._evaluatable}\u27A9{this.value}";
return $"{parent}\u27A9{_evaluatable}\u27A9{value}";
return base.toStringDetails() + " " + this._evaluatable;
return base.toStringDetails() + " " + _evaluatable;
}
}

this._parent = parent;
this._evaluatable = evaluatable;
_parent = parent;
_evaluatable = evaluatable;
public override T evaluate(Animation<float> animation) {
float value = this._parent.evaluate(animation);
return this._evaluatable.evaluate(new AlwaysStoppedAnimation<float>(value));
public override T transform(float t) {
return _evaluatable.transform(_parent.transform(t));
/*public override T evaluate(Animation<float> animation) {
float value = _parent.evaluate(animation);
return _evaluatable.evaluate(new AlwaysStoppedAnimation<float>(value));
}*/
return $"{this._parent}\u27A9{this._evaluatable}";
return $"{_parent}\u27A9{_evaluatable}";
/**
* We make Tween<T> a abstract class by design here (while it is not a abstract class in flutter
* The reason to do so is, in C# we cannot use arithmetic between generic types, therefore the
* lerp method cannot be implemented in Tween<T>
*
* To solve this problem, we make each Tween<T1>, Tween<T2> an explicit subclass T1Tween and T2Tween and
* implement the lerp method specifically
*
* See the implementations in "_OnOffAnimationColor" for some specific workarounds on this issue
*
*/
protected Tween(T begin, T end) {
public Tween(T begin, T end) {
this.begin = begin;
this.end = end;
}

public abstract T lerp(float t);
public override T evaluate(Animation<float> animation) {
float t = animation.value;
if (t == 0.0) {
return this.begin;
}
if (t == 1.0) {
return this.end;
}
return this.lerp(t);
public override T transform(float t) {
if (t == 0.0)
return begin;
if (t == 1.0)
return end;
return lerp(t);
return $"{this.GetType()}({this.begin} \u2192 {this.end})";
return $"{GetType()}({begin} \u2192 {end})";
}
public bool Equals(Tween<T> other) {

return true;
}
return EqualityComparer<T>.Default.Equals(this.begin, other.begin) &&
EqualityComparer<T>.Default.Equals(this.end, other.end);
return EqualityComparer<T>.Default.Equals(begin, other.begin) &&
EqualityComparer<T>.Default.Equals(end, other.end);
}
public override bool Equals(object obj) {

return true;
}
if (obj.GetType() != this.GetType()) {
if (obj.GetType() != GetType()) {
return this.Equals((Tween<T>) obj);
return Equals((Tween<T>) obj);
return (EqualityComparer<T>.Default.GetHashCode(this.begin) * 397) ^
EqualityComparer<T>.Default.GetHashCode(this.end);
return (EqualityComparer<T>.Default.GetHashCode(begin) * 397) ^
EqualityComparer<T>.Default.GetHashCode(end);
}
}

public readonly Tween<T> parent;
public override T lerp(float t) {
return this.parent.lerp(1.0f - t);
return parent.lerp(1.0f - t);
}
}

public override Color lerp(float t) {
return Color.lerp(this.begin, this.end, t);
return Color.lerp(begin, end, t);
}
}

public override Size lerp(float t) {
return Size.lerp(this.begin, this.end, t);
return Size.lerp(begin, end, t);
}
}

public override Rect lerp(float t) {
return Rect.lerp(this.begin, this.end, t);
return Rect.lerp(begin, end, t);
}
}

public override int lerp(float t) {
return (this.begin + (this.end - this.begin) * t).round();
return (begin + (end - begin) * t).round();
}
}

public override float? lerp(float t) {
D.assert(this.begin != null);
D.assert(this.end != null);
return this.begin + (this.end - this.begin) * t;
D.assert(begin != null);
D.assert(end != null);
return begin + (end - begin) * t;
}
}

public override float lerp(float t) {
return this.begin + (this.end - this.begin) * t;
return begin + (end - begin) * t;
}
}

public override int lerp(float t) {
return (this.begin + (this.end - this.begin) * t).floor();
return (begin + (end - begin) * t).floor();
}
}

public override Offset lerp(float t) {
return (this.begin + (this.end - this.begin) * t);
return (begin + (end - begin) * t);
}
}

public override T lerp(float t) {
return this.begin;
return begin;
return $"{this.GetType()}(value: {this.begin})";
return $"{GetType()}(value: {begin})";
}
}

}
public readonly Curve curve;
public override float transform(float t) {
if (t == 0.0 || t == 1.0) {
D.assert(curve.transform(t).round() == t);
return t;
}
return curve.transform(t);
}
public override float evaluate(Animation<float> animation) {
/*public override float evaluate(Animation<float> animation) {
D.assert(this.curve.transform(t).round() == t);
D.assert(curve.transform(t).round() == t);
return this.curve.transform(t);
}
return curve.transform(t);
}*/
return $"{this.GetType()}(curve: {this.curve})";
return $"{GetType()}(curve: {curve})";
}
}
}

71
com.unity.uiwidgets/Runtime/async/priority_queue.cs


using System;
using System.Collections.Generic;

public PriorityQueue() {
this._data = new List<T>();
_data = new List<T>();
this._data.Add(item);
int ci = this._data.Count - 1; // child index; start at end
_data.Add(item);
int ci = _data.Count - 1; // child index; start at end
if (this._data[ci].CompareTo(this._data[pi]) >= 0) {
if (_data[ci].CompareTo(_data[pi]) >= 0) {
T tmp = this._data[ci];
this._data[ci] = this._data[pi];
this._data[pi] = tmp;
T tmp = _data[ci];
_data[ci] = _data[pi];
_data[pi] = tmp;
ci = pi;
}
}

int li = this._data.Count - 1; // last index (before removal)
T frontItem = this._data[0]; // fetch the front
this._data[0] = this._data[li];
this._data.RemoveAt(li);
int li = _data.Count - 1; // last index (before removal)
T frontItem = _data[0]; // fetch the front
_data[0] = _data[li];
_data.RemoveAt(li);
--li; // last index (after removal)
int pi = 0; // parent index. start at front of pq

}
int rc = ci + 1; // right child
if (rc <= li && this._data[rc].CompareTo(this._data[ci]) < 0) {
if (rc <= li && _data[rc].CompareTo(_data[ci]) < 0) {
if (this._data[pi].CompareTo(this._data[ci]) <= 0) {
if (_data[pi].CompareTo(_data[ci]) <= 0) {
T tmp = this._data[pi];
this._data[pi] = this._data[ci];
this._data[ci] = tmp; // swap parent and child
T tmp = _data[pi];
_data[pi] = _data[ci];
_data[ci] = tmp; // swap parent and child
pi = ci;
}

public T peek() {
T frontItem = this._data[0];
T frontItem = _data[0];
get { return this._data.Count; }
get { return _data.Count; }
}
public bool isEmpty {
get { return count == 0; }
}
public bool isNotEmpty {
get { return count != 0; }
}
public T first {
get {
return peek();
}
}
public T removeFirst() {
return dequeue();
for (int i = 0; i < this._data.Count; ++i) {
s += this._data[i] + " ";
for (int i = 0; i < _data.Count; ++i) {
s += _data[i] + " ";
s += "count = " + this._data.Count;
s += "count = " + _data.Count;
if (this._data.Count == 0) {
if (_data.Count == 0) {
int li = this._data.Count - 1; // last index
for (int pi = 0; pi < this._data.Count; ++pi) {
int li = _data.Count - 1; // last index
for (int pi = 0; pi < _data.Count; ++pi) {
if (lci <= li && this._data[pi].CompareTo(this._data[lci]) > 0) {
if (lci <= li && _data[pi].CompareTo(_data[lci]) > 0) {
if (rci <= li && this._data[pi].CompareTo(this._data[rci]) > 0) {
if (rci <= li && _data[pi].CompareTo(_data[rci]) > 0) {
return false; // check the right child too.
}
}

264
com.unity.uiwidgets/Runtime/async/timer.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using System.Runtime.InteropServices;
using AOT;
using Unity.UIWidgets.ui;
#if UNITY_EDITOR
using UnityEditor;
#endif
public abstract void cancel();
public void Dispose() {
this.cancel();
}
public static float timeSinceStartup {
get {
#if UNITY_EDITOR
return (float) EditorApplication.timeSinceStartup;
#else
return Time.realtimeSinceStartup;
#endif
public static Timer create(TimeSpan duration, ZoneCallback callback) {
if (Zone.current == Zone.root) {
return Zone.current.createTimer(duration, callback);
}
public static TimeSpan timespanSinceStartup {
get { return TimeSpan.FromSeconds(timeSinceStartup); }
return Zone.current
.createTimer(duration, Zone.current.bindCallbackGuarded(callback));
static readonly object _syncObj = new object();
static LinkedList<Action> _callbacks = new LinkedList<Action>();
public static void runInMainFromFinalizer(Action callback) {
lock (_syncObj) {
_callbacks.AddLast(callback);
}
public static Timer create(TimeSpan duration, Action callback) {
return create(duration, () => {
callback.Invoke();
return null;
});
internal static void update() {
LinkedList<Action> callbacks;
lock (_syncObj) {
if (_callbacks.isEmpty()) {
return;
}
callbacks = _callbacks;
_callbacks = new LinkedList<Action>();
public static Timer periodic(TimeSpan duration, ZoneUnaryCallback callback) {
if (Zone.current == Zone.root) {
return Zone.current.createPeriodicTimer(duration, callback);
foreach (var callback in callbacks) {
try {
callback();
}
catch (Exception ex) {
D.logError("Error to execute runInMain callback: ", ex);
}
}
var boundCallback = Zone.current.bindUnaryCallbackGuarded(callback);
return Zone.current.createPeriodicTimer(duration, boundCallback);
}
public class TimerProvider {
readonly PriorityQueue<TimerImpl> _queue;
public TimerProvider() {
this._queue = new PriorityQueue<TimerImpl>();
public static void run(ZoneCallback callback) {
create(TimeSpan.Zero, callback);
public Timer runInMain(Action callback) {
var timer = new TimerImpl(callback);
public abstract void cancel();
lock (this._queue) {
this._queue.enqueue(timer);
}
return timer;
public void Dispose() {
cancel();
public Timer run(TimeSpan duration, Action callback) {
var timer = new TimerImpl(duration, callback);
public abstract long tick { get; }
lock (this._queue) {
this._queue.enqueue(timer);
}
public abstract bool isActive { get; }
return timer;
internal static Timer _createTimer(TimeSpan duration, ZoneCallback callback) {
return _Timer._createTimer(_ => callback(), (int) duration.TotalMilliseconds, false);
public Timer periodic(TimeSpan duration, Action callback) {
var timer = new TimerImpl(duration, callback, periodic: true);
internal static Timer _createPeriodicTimer(
TimeSpan duration, ZoneUnaryCallback callback) {
return _Timer._createTimer(callback, (int) duration.TotalMilliseconds, true);
}
}
lock (this._queue) {
this._queue.enqueue(timer);
}
class _Timer : Timer {
long _tick = 0;
ZoneUnaryCallback _callback;
long _wakeupTime;
readonly int _milliSeconds;
readonly bool _repeating;
return timer;
_Timer(ZoneUnaryCallback callback, long wakeupTime, int milliSeconds, bool repeating) {
_callback = callback;
_wakeupTime = wakeupTime;
_milliSeconds = milliSeconds;
_repeating = repeating;
static readonly List<TimerImpl> _timers = new List<TimerImpl>();
static readonly List<TimerImpl> _appendList = new List<TimerImpl>();
public void update(Action flushMicroTasks = null) {
var now = Timer.timeSinceStartup;
_timers.Clear();
_appendList.Clear();
lock (this._queue) {
while (this._queue.count > 0 && this._queue.peek().deadline <= now) {
var timer = this._queue.dequeue();
_timers.Add(timer);
}
public static TimeSpan timespanSinceStartup {
get { return TimeSpan.FromMilliseconds(UIMonoState_timerMillisecondClock()); }
}
internal static _Timer _createTimer(ZoneUnaryCallback callback, int milliSeconds, bool repeating) {
if (milliSeconds < 0) {
milliSeconds = 0;
if (_timers.Count != 0) {
foreach (var timer in _timers) {
if (flushMicroTasks != null) {
flushMicroTasks();
}
long now = UIMonoState_timerMillisecondClock();
long wakeupTime = (milliSeconds == 0) ? now : (now + 1 + milliSeconds);
timer.invoke();
if (timer.periodic && !timer.done) {
_appendList.Add(timer);
}
}
}
_Timer timer = new _Timer(callback, wakeupTime, milliSeconds, repeating);
timer._enqueue();
if (_appendList.Count != 0) {
lock (this._queue) {
foreach (var timer in _appendList) {
this._queue.enqueue(timer);
}
}
}
return timer;
class TimerImpl : Timer, IComparable<TimerImpl> {
float _deadline;
readonly Action _callback;
bool _done;
public readonly bool periodic;
readonly TimeSpan _interval;
public override void cancel() {
_callback = null;
}
public TimerImpl(TimeSpan duration, Action callback, bool periodic = false) {
this._deadline = timeSinceStartup + (float) duration.TotalSeconds;
this._callback = callback;
this._done = false;
public override bool isActive => _callback != null;
this.periodic = periodic;
if (periodic) {
this._interval = duration;
}
}
public override long tick => _tick;
public TimerImpl(Action callback) {
this._deadline = 0;
this._callback = callback;
this._done = false;
void _advanceWakeupTime() {
if (_milliSeconds > 0) {
_wakeupTime += _milliSeconds;
public float deadline {
get { return this._deadline; }
else {
_wakeupTime = UIMonoState_timerMillisecondClock();
}
public override void cancel() {
this._done = true;
}
const long MILLI_TO_NANO = 1000000L;
void _enqueue() {
Isolate.ensureExists();
GCHandle callbackHandle = GCHandle.Alloc(this);
UIMonoState_postTaskForTime(_postTaskForTime, (IntPtr) callbackHandle, _wakeupTime * MILLI_TO_NANO);
}
public bool done {
get { return this._done; }
}
[MonoPInvokeCallback(typeof(UIMonoState_postTaskForTimeCallback))]
static void _postTaskForTime(IntPtr callbackHandle) {
GCHandle timerHandle = (GCHandle) callbackHandle;
var timer = (_Timer) timerHandle.Target;
timerHandle.Free();
public void invoke() {
if (this._done) {
return;
}
try {
if (timer._callback != null) {
var callback = timer._callback;
if (!timer._repeating) {
timer._callback = null;
}
else if (timer._milliSeconds > 0) {
var ms = timer._milliSeconds;
long overdue = UIMonoState_timerMillisecondClock() - timer._wakeupTime;
if (overdue > ms) {
long missedTicks = overdue / ms;
timer._wakeupTime += missedTicks * ms;
timer._tick += missedTicks;
}
}
var now = timeSinceStartup;
if (!this.periodic) {
this._done = true;
}
timer._tick += 1;
try {
this._callback();
}
catch (Exception ex) {
D.logError("Error to execute timer callback: ", ex);
}
callback(timer);
if (this.periodic) {
this._deadline = now + (float) this._interval.TotalSeconds;
if (timer._repeating && (timer._callback != null)) {
timer._advanceWakeupTime();
timer._enqueue();
}
public int CompareTo(TimerImpl other) {
return this.deadline.CompareTo(other.deadline);
catch (Exception ex) {
Debug.LogException(ex);
[DllImport(NativeBindings.dllName)]
static extern long UIMonoState_timerMillisecondClock();
delegate void UIMonoState_postTaskForTimeCallback(IntPtr callbackHandle);
[DllImport(NativeBindings.dllName)]
static extern void UIMonoState_postTaskForTime(UIMonoState_postTaskForTimeCallback callback,
IntPtr callbackHandle, long targetTimeNanos);
}
}

2
com.unity.uiwidgets/Runtime/async/timer.cs.meta


fileFormatVersion: 2
guid: 22e7b4cca5d354a4e9aa008cafcfdfe8
guid: 79d38f7d7b0725b4887dbc2f3ec30cee
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
com.unity.uiwidgets/Runtime/cupertino.meta


fileFormatVersion: 2
guid: 30914a0a38eca48bfa7c425f084a3684
guid: 5c3d34af75804254da0566129e0d4ac0
folderAsset: yes
DefaultImporter:
externalObjects: {}

77
com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

namespace Unity.UIWidgets.cupertino {
static class CupertinoActivityIndicatorUtils {
public const float _kDefaultIndicatorRadius = 10.0f;
public static readonly Color _kActiveTickColor = CupertinoDynamicColor.withBrightness(
color: new Color(0xFF3C3C44),
darkColor: new Color(0xFFEBEBF5)
);
// list
public static int[] _alphaValues = {
147, 131, 114, 97, 81, 64, 47, 47, 47, 47, 47, 47
};
public static readonly Color _kActiveTickColor = new Color(0xFF9D9D9D);
}
public class CupertinoActivityIndicator : StatefulWidget {

float radius = CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius
) : base(key: key) {
D.assert(animating != null);
D.assert(radius != null);
D.assert(radius > 0);
this.animating = animating;
this.radius = radius;

public override void initState() {
base.initState();
this._controller = new AnimationController(
_controller = new AnimationController(
if (this.widget.animating) {
this._controller.repeat();
if (widget.animating) {
_controller.repeat();
}
}

if (this.widget.animating != _oldWidget.animating) {
if (this.widget.animating) {
this._controller.repeat();
if (widget.animating != _oldWidget.animating) {
if (widget.animating) {
_controller.repeat();
this._controller.stop();
_controller.stop();
}
}
}

this._controller.dispose();
_controller.dispose();
height: this.widget.radius * 2,
width: this.widget.radius * 2,
height: widget.radius * 2,
width: widget.radius * 2,
position: this._controller,
radius: this.widget.radius
position: _controller,
activeColor: CupertinoDynamicColor.resolve(CupertinoActivityIndicatorUtils._kActiveTickColor, context),
radius: widget.radius
)
)
);

class _CupertinoActivityIndicatorPainter : AbstractCustomPainter {
class _CupertinoActivityIndicatorPainter : AbstractCustomPainter
{
Animation<float> position,
float radius
Animation<float> position = null,
Color activeColor = null,
float radius = 0f
this.tickFundamentalRRect = RRect.fromLTRBXY(
tickFundamentalRRect = RRect.fromLTRBXY(
radiusX: 1.0f,
radiusY: 1.0f
radiusX: 1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius,
radiusY: 1.0f * radius / CupertinoActivityIndicatorUtils._kDefaultIndicatorRadius
this.activeColor = activeColor;
readonly Animation<float> position;
readonly RRect tickFundamentalRRect;
public readonly Animation<float> position;
public readonly RRect tickFundamentalRRect;
public readonly Color activeColor;
public override void paint(Canvas canvas, Size size) {
Paint paint = new Paint();

int activeTick = (CupertinoActivityIndicatorUtils._kTickCount * this.position.value).floor();
int activeTick = (CupertinoActivityIndicatorUtils._kTickCount * position.value).floor();
float t = (((i + activeTick) % CupertinoActivityIndicatorUtils._kTickCount) /
CupertinoActivityIndicatorUtils._kHalfTickCount).clamp(0, 1);
paint.color = Color.lerp(a: CupertinoActivityIndicatorUtils._kActiveTickColor,
b: CupertinoActivityIndicatorUtils._kTickColor, t: t);
canvas.drawRRect(rect: this.tickFundamentalRRect, paint: paint);
int t = ((i + activeTick) % CupertinoActivityIndicatorUtils._kTickCount);
paint.color = activeColor.withAlpha(CupertinoActivityIndicatorUtils._alphaValues[t]);
canvas.drawRRect(tickFundamentalRRect,paint);
canvas.rotate(-CupertinoActivityIndicatorUtils._kTwoPI / CupertinoActivityIndicatorUtils._kTickCount);
}

public override bool shouldRepaint(CustomPainter oldPainter) {
return (oldPainter as _CupertinoActivityIndicatorPainter).position != this.position;
return ((oldPainter as _CupertinoActivityIndicatorPainter).position != position) ||
((oldPainter as _CupertinoActivityIndicatorPainter).activeColor != activeColor);
}
}
}

2
com.unity.uiwidgets/Runtime/cupertino/activity_indicator.cs.meta


fileFormatVersion: 2
guid: a08f265049c0646969c9b5adafa6916f
guid: ed3ef7a3308cfad4e968eb19fe99ba4b
MonoImporter:
externalObjects: {}
serializedVersion: 2

144
com.unity.uiwidgets/Runtime/cupertino/app.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
//using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

Dictionary<string, WidgetBuilder> routes = null,
string initialRoute = null,
RouteFactory onGenerateRoute = null,
InitialRouteListFactory onGenerateInitialRoutes = null,
RouteFactory onUnknownRoute = null,
List<NavigatorObserver> navigatorObservers = null,
TransitionBuilder builder = null,

LocaleListResolutionCallback localeListResolutionCallback = null,
LocaleResolutionCallback localeResolutionCallback = null,
List<Locale> supportedLocales = null,
bool showPerformanceOverlay = false
bool showPerformanceOverlay = false,
bool checkerboardRasterCacheImages = false,
bool checkerboardOffscreenLayers = false,
bool showSemanticsDebugger = false,
bool debugShowCheckedModeBanner = true,
Dictionary<LogicalKeySet, Intent> shortcuts = null,
Dictionary<LocalKey, ActionFactory> actions = null
supportedLocales = supportedLocales ?? new List<Locale> {new Locale("en", "US")};
this.navigatorKey = navigatorKey;
this.home = home;

this.onGenerateRoute = onGenerateRoute;
this.onGenerateInitialRoutes = onGenerateInitialRoutes;
this.onUnknownRoute = onUnknownRoute;
this.navigatorObservers = navigatorObservers ?? new List<NavigatorObserver>();
this.builder = builder;

this.localeResolutionCallback = localeResolutionCallback;
this.supportedLocales = supportedLocales;
this.showPerformanceOverlay = showPerformanceOverlay;
this.showSemanticsDebugger = showSemanticsDebugger;
this.debugShowCheckedModeBanner = debugShowCheckedModeBanner;
this.shortcuts = shortcuts;
this.actions = actions;
}
public readonly GlobalKey<NavigatorState> navigatorKey;

public readonly string initialRoute;
public readonly RouteFactory onGenerateRoute;
public readonly InitialRouteListFactory onGenerateInitialRoutes;
public readonly RouteFactory onUnknownRoute;
public readonly List<NavigatorObserver> navigatorObservers;
public readonly TransitionBuilder builder;

public readonly LocaleResolutionCallback localeResolutionCallback;
public readonly List<Locale> supportedLocales;
public readonly bool showPerformanceOverlay;
public readonly bool checkerboardRasterCacheImages;
public readonly bool checkerboardOffscreenLayers;
public readonly bool showSemanticsDebugger;
public readonly bool debugShowCheckedModeBanner;
public readonly Dictionary<LogicalKeySet, Intent> shortcuts;
public readonly Dictionary<LocalKey, ActionFactory> actions;
public override State createState() {
return new _CupertinoAppState();

public override void initState() {
base.initState();
this._heroController = CupertinoApp.createCupertinoHeroController();
this._updateNavigator();
_heroController = CupertinoApp.createCupertinoHeroController();
_updateNavigator();
if (this.widget.navigatorKey != ((CupertinoApp) oldWidget).navigatorKey) {
this._heroController = CupertinoApp.createCupertinoHeroController();
if (widget.navigatorKey != ((CupertinoApp) oldWidget).navigatorKey) {
_heroController = CupertinoApp.createCupertinoHeroController();
this._updateNavigator();
_updateNavigator();
if (this.widget.home != null || this.widget.routes.isNotEmpty() || this.widget.onGenerateRoute != null ||
this.widget.onUnknownRoute != null) {
this._navigatorObservers = new List<NavigatorObserver>();
foreach (var item in this.widget.navigatorObservers) {
this._navigatorObservers.Add(item);
if (widget.home != null ||
widget.routes.isNotEmpty() ||
widget.onGenerateRoute != null ||
widget.onUnknownRoute != null) {
_navigatorObservers = new List<NavigatorObserver>();
foreach (var item in widget.navigatorObservers) {
_navigatorObservers.Add(item);
this._navigatorObservers = new List<NavigatorObserver>();
_navigatorObservers = new List<NavigatorObserver>();
}
}

if (this.widget.localizationsDelegates != null) {
_delegates.AddRange(this.widget.localizationsDelegates);
if (widget.localizationsDelegates != null) {
_delegates.AddRange(widget.localizationsDelegates);
_delegates.Add(DefaultMaterialLocalizations.del);
CupertinoThemeData effectiveThemeData = this.widget.theme ?? new CupertinoThemeData();
CupertinoThemeData effectiveThemeData = widget.theme ?? new CupertinoThemeData();
child: new CupertinoTheme(
data: effectiveThemeData,
child: new WidgetsApp(
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new CupertinoPageRoute(settings: settings, builder: builder),
home: this.widget.home,
routes: this.widget.routes,
initialRoute: this.widget.initialRoute,
onGenerateRoute: this.widget.onGenerateRoute,
onUnknownRoute: this.widget.onUnknownRoute,
builder: this.widget.builder,
title: this.widget.title,
onGenerateTitle: this.widget.onGenerateTitle,
textStyle: effectiveThemeData.textTheme.textStyle,
color: this.widget.color ?? CupertinoColors.activeBlue,
locale: this.widget.locale,
localizationsDelegates: this._localizationsDelegates,
localeResolutionCallback: this.widget.localeResolutionCallback,
localeListResolutionCallback: this.widget.localeListResolutionCallback,
supportedLocales: this.widget.supportedLocales,
showPerformanceOverlay: this.widget.showPerformanceOverlay,
inspectorSelectButtonBuilder: (BuildContext _context, VoidCallback onPressed) => {
return CupertinoButton.filled(
child: new Icon(
CupertinoIcons.search,
size: 28.0f,
color: CupertinoColors.white
),
padding: EdgeInsets.zero,
onPressed: onPressed
);
}
child: new CupertinoUserInterfaceLevel(
data: CupertinoUserInterfaceLevelData.baselayer,
child: new CupertinoTheme(
data: effectiveThemeData,
child: new Builder(
builder: (BuildContext context1)=> {
return new WidgetsApp(
key: new GlobalObjectKey<State<StatefulWidget>>(value: this),
navigatorKey: widget.navigatorKey,
navigatorObservers: _navigatorObservers,
pageRouteBuilder:(RouteSettings settings, WidgetBuilder builder) =>
new CupertinoPageRoute(settings: settings, builder: builder),
home: widget.home,
routes: widget.routes,
initialRoute: widget.initialRoute,
onGenerateRoute: widget.onGenerateRoute,
onGenerateInitialRoutes: widget.onGenerateInitialRoutes,
onUnknownRoute: widget.onUnknownRoute,
builder: widget.builder,
title: widget.title,
onGenerateTitle: widget.onGenerateTitle,
textStyle: CupertinoTheme.of(context1).textTheme.textStyle,
color: CupertinoDynamicColor.resolve(widget.color ?? effectiveThemeData.primaryColor, context1),
locale: widget.locale,
localizationsDelegates: _localizationsDelegates,
localeResolutionCallback: widget.localeResolutionCallback,
localeListResolutionCallback: widget.localeListResolutionCallback,
supportedLocales: widget.supportedLocales,
showPerformanceOverlay: widget.showPerformanceOverlay,
checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages,
checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers,
showSemanticsDebugger: widget.showSemanticsDebugger,
debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner,
inspectorSelectButtonBuilder: (BuildContext context3, VoidCallback onPressed) => {
return CupertinoButton.filled(
child: new Icon(
CupertinoIcons.search,
size: 28.0f,
color: CupertinoColors.white
),
padding: EdgeInsets.zero,
onPressed: onPressed
);
},
shortcuts: widget.shortcuts,
actions: widget.actions
);
}
)
}
}
}
}

2
com.unity.uiwidgets/Runtime/cupertino/app.cs.meta


fileFormatVersion: 2
guid: ae05cbcca3d324a2da3b3aadbb2f124d
guid: eaa69370ca020aa4ca9cfeff075ab39c
MonoImporter:
externalObjects: {}
serializedVersion: 2

158
com.unity.uiwidgets/Runtime/cupertino/button.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using TickerFuture = Unity.UIWidgets.scheduler.TickerFuture;
public static readonly Color _kDisabledBackground = new Color(0xFFA9A9A9);
public static readonly Color _kDisabledForeground = new Color(0xFFD1D1D1);
public static readonly EdgeInsets _kBackgroundButtonPadding = EdgeInsets.symmetric(vertical: 14.0f, horizontal: 64.0f);
public static readonly EdgeInsets _kBackgroundButtonPadding = EdgeInsets.symmetric(
vertical: 14.0f,
horizontal: 64.0f);
public static readonly float kMinInteractiveDimensionCupertino = 44.0f;
Widget child,
VoidCallback onPressed,
EdgeInsets padding = null,
Widget child = null,
EdgeInsetsGeometry padding = null,
float pressedOpacity = 0.1f,
float pressedOpacity = 0.4f,
bool filled = false
VoidCallback onPressed = null
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
this._filled = filled;
D.assert((pressedOpacity >= 0.0 && pressedOpacity <= 1.0));
_filled = false;
this.disabledColor = disabledColor;
this.disabledColor = disabledColor ?? CupertinoColors.quaternarySystemFill;
this.minSize = minSize;
this.pressedOpacity = pressedOpacity;
this.borderRadius = borderRadius ?? BorderRadius.all(Radius.circular(8.0f));

Widget child,
VoidCallback onPressed,
EdgeInsets padding = null,
Widget child = null,
EdgeInsetsGeometry padding = null,
float pressedOpacity = 0.1f,
BorderRadius borderRadius = null
float pressedOpacity = 0.4f,
BorderRadius borderRadius = null,
VoidCallback onPressed = null
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
return new CupertinoButton(
disabledColor = disabledColor ?? CupertinoColors.quaternarySystemFill;
D.assert(pressedOpacity >= 0.0 && pressedOpacity <= 1.0);
var btn = new CupertinoButton(
onPressed: onPressed,
filled: true
onPressed: onPressed
btn._filled = true;
return btn;
public readonly EdgeInsets padding;
public readonly EdgeInsetsGeometry padding;
public readonly Color color;

public readonly float minSize;
public readonly float? pressedOpacity;
public readonly float pressedOpacity;
public readonly bool _filled;
public bool _filled;
get { return this.onPressed != null; }
get { return onPressed != null; }
}
public override State createState() {

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("enabled", value: this.enabled, ifFalse: "disabled"));
properties.add(new FlagProperty("enabled", value: enabled, ifFalse: "disabled"));
}
}

public readonly FloatTween _opacityTween = new FloatTween(begin: 1.0f, end: 0.0f);
public readonly Tween<float> _opacityTween = new FloatTween(begin: 1.0f, end: 0.0f);//Tween<Float>
this._animationController = new AnimationController(
_animationController = new AnimationController(
this._opacityAnimation = this._animationController
_opacityAnimation = _animationController
.drive(this._opacityTween);
this._setTween();
.drive(_opacityTween);
_setTween();
this._setTween();
_setTween();
if (this.widget != null) {
this._opacityTween.end = this.widget.pressedOpacity ?? 1.0f;
if (widget != null) {
_opacityTween.end = 1.0f;
if (!widget.pressedOpacity.Equals(0f)) {
_opacityTween.end = widget.pressedOpacity;
}
this._animationController.dispose();
this._animationController = null;
_animationController.dispose();
_animationController = null;
base.dispose();
}

if (!this._buttonHeldDown) {
this._buttonHeldDown = true;
this._animate();
if (!_buttonHeldDown) {
_buttonHeldDown = true;
_animate();
if (this._buttonHeldDown) {
this._buttonHeldDown = false;
this._animate();
if (_buttonHeldDown) {
_buttonHeldDown = false;
_animate();
if (this._buttonHeldDown) {
this._buttonHeldDown = false;
this._animate();
if (_buttonHeldDown) {
_buttonHeldDown = false;
_animate();
if (this._animationController.isAnimating) {
if (_animationController.isAnimating) {
bool wasHeldDown = this._buttonHeldDown;
bool wasHeldDown = _buttonHeldDown;
TickerFuture ticker = this._buttonHeldDown
? this._animationController.animateTo(1.0f, duration: kFadeOutDuration)
: this._animationController.animateTo(0.0f, duration: kFadeInDuration);
TickerFuture ticker = _buttonHeldDown
? _animationController.animateTo(1.0f, duration: kFadeOutDuration)
: _animationController.animateTo(0.0f, duration: kFadeInDuration);
ticker.Then(() => {
if (this.mounted && wasHeldDown != this._buttonHeldDown) {
this._animate();
ticker.then(_ => {
if (mounted && wasHeldDown != _buttonHeldDown) {
_animate();
bool enabled = this.widget.enabled;
Color primaryColor = CupertinoTheme.of(context).primaryColor;
Color backgroundColor = this.widget.color ?? (this.widget._filled ? primaryColor : null);
bool enabled = widget.enabled;
CupertinoThemeData themeData = CupertinoTheme.of(context);
Color primaryColor = themeData.primaryColor;
Color backgroundColor = (widget.color == null)
? (widget._filled ? primaryColor : null)
: CupertinoDynamicColor.resolve(widget.color, context);
? CupertinoTheme.of(context).primaryContrastingColor
? themeData.primaryContrastingColor
: CupertinoButtonUtils._kDisabledForeground;
: CupertinoDynamicColor.resolve(CupertinoColors.placeholderText, context);
CupertinoTheme.of(context).textTheme.textStyle.copyWith(color: foregroundColor);
themeData.textTheme.textStyle.copyWith(color: foregroundColor);
onTapDown: enabled ? this._handleTapDown : (GestureTapDownCallback) null,
onTapUp: enabled ? this._handleTapUp : (GestureTapUpCallback) null,
onTapCancel: enabled ? this._handleTapCancel : (GestureTapCancelCallback) null,
onTap: this.widget.onPressed == null
onTapDown: enabled ? _handleTapDown : (GestureTapDownCallback) null,
onTapUp: enabled ? _handleTapUp : (GestureTapUpCallback) null,
onTapCancel: enabled ? _handleTapCancel : (GestureTapCancelCallback) null,
onTap: widget.onPressed == null
if (this.widget.onPressed != null) {
this.widget.onPressed();
if (widget.onPressed != null) {
widget.onPressed();
constraints: new BoxConstraints(
minWidth: this.widget.minSize,
minHeight: this.widget.minSize
constraints: widget.minSize == null
? new BoxConstraints() :
new BoxConstraints(
minWidth: widget.minSize,
minHeight: widget.minSize
opacity: this._opacityAnimation,
opacity: _opacityAnimation,
borderRadius: this.widget.borderRadius,
borderRadius: widget.borderRadius,
? this.widget.disabledColor ?? CupertinoButtonUtils._kDisabledBackground
? CupertinoDynamicColor.resolve(widget.disabledColor, context)
padding: this.widget.padding ?? (backgroundColor != null
padding: widget.padding ?? (backgroundColor != null
? CupertinoButtonUtils._kBackgroundButtonPadding
: CupertinoButtonUtils._kButtonPadding),
child: new Center(

style: textStyle,
child: new IconTheme(
data: new IconThemeData(color: foregroundColor),
child: this.widget.child
child: widget.child
)
)
)

2
com.unity.uiwidgets/Runtime/cupertino/button.cs.meta


fileFormatVersion: 2
guid: 7c17a9b64e1654955af4ee61cc15780b
guid: 629437eb94ae5aa4bbe7bcf510b6a7cc
MonoImporter:
externalObjects: {}
serializedVersion: 2

769
com.unity.uiwidgets/Runtime/cupertino/colors.cs


using System;
using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
using Unity.UIWidgets.painting;
public static readonly Color activeBlue = new Color(0xFF007AFF);
public static readonly CupertinoDynamicColor activeBlue = systemBlue;
public static readonly CupertinoDynamicColor activeGreen = systemGreen;
public static readonly CupertinoDynamicColor activeOrange = systemOrange;
public static Color white = new Color(0xFFFFFFFF);
public static Color black = new Color(0xFF000000);
public static Color lightBackgroundGray = new Color(0xFFE5E5EA);
public static Color extraLightBackgroundGray = new Color(0xFFEFEFF4);
public static Color darkBackgroundGray = new Color(0xFF171717);
public static readonly CupertinoDynamicColor inactiveGray = CupertinoDynamicColor.withBrightness(
debugLabel: "inactiveGray",
color: new Color(0xFF999999),
darkColor: new Color(0xFF757575)
);
public static readonly CupertinoDynamicColor destructiveRed = systemRed;
public static readonly CupertinoDynamicColor systemBlue = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemBlue",
color: Color.fromARGB(255, 0, 122, 255),
darkColor: Color.fromARGB(255, 10, 132, 255),
highContrastColor: Color.fromARGB(255, 0, 64, 221),
darkHighContrastColor: Color.fromARGB(255, 64, 156, 255)
);
public static readonly CupertinoDynamicColor systemGreen = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemGreen",
color: Color.fromARGB(255, 52, 199, 89),
darkColor: Color.fromARGB(255, 48, 209, 88),
highContrastColor: Color.fromARGB(255, 36, 138, 61),
darkHighContrastColor: Color.fromARGB(255, 48, 219, 91)
);
public static readonly CupertinoDynamicColor systemIndigo = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemIndigo",
color: Color.fromARGB(255, 88, 86, 214),
darkColor: Color.fromARGB(255, 94, 92, 230),
highContrastColor: Color.fromARGB(255, 54, 52, 163),
darkHighContrastColor: Color.fromARGB(255, 125, 122, 255)
);
public static readonly CupertinoDynamicColor systemOrange = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemOrange",
color: Color.fromARGB(255, 255, 149, 0),
darkColor: Color.fromARGB(255, 255, 159, 10),
highContrastColor: Color.fromARGB(255, 201, 52, 0),
darkHighContrastColor: Color.fromARGB(255, 255, 179, 64)
);
public static readonly CupertinoDynamicColor systemPink = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemPink",
color: Color.fromARGB(255, 255, 45, 85),
darkColor: Color.fromARGB(255, 255, 55, 95),
highContrastColor: Color.fromARGB(255, 211, 15, 69),
darkHighContrastColor: Color.fromARGB(255, 255, 100, 130)
);
public static readonly CupertinoDynamicColor systemPurple = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemPurple",
color: Color.fromARGB(255, 175, 82, 222),
darkColor: Color.fromARGB(255, 191, 90, 242),
highContrastColor: Color.fromARGB(255, 137, 68, 171),
darkHighContrastColor: Color.fromARGB(255, 218, 143, 255)
);
public static readonly CupertinoDynamicColor systemRed = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemRed",
color: Color.fromARGB(255, 255, 59, 48),
darkColor: Color.fromARGB(255, 255, 69, 58),
highContrastColor: Color.fromARGB(255, 215, 0, 21),
darkHighContrastColor: Color.fromARGB(255, 255, 105, 97)
);
public static readonly CupertinoDynamicColor systemTeal = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemTeal",
color: Color.fromARGB(255, 90, 200, 250),
darkColor: Color.fromARGB(255, 100, 210, 255),
highContrastColor: Color.fromARGB(255, 0, 113, 164),
darkHighContrastColor: Color.fromARGB(255, 112, 215, 255)
);
public static readonly CupertinoDynamicColor systemYellow = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemYellow",
color: Color.fromARGB(255, 255, 204, 0),
darkColor: Color.fromARGB(255, 255, 214, 10),
highContrastColor: Color.fromARGB(255, 160, 90, 0),
darkHighContrastColor: Color.fromARGB(255, 255, 212, 38)
);
public static readonly CupertinoDynamicColor systemGrey = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemGrey",
color: Color.fromARGB(255, 142, 142, 147),
darkColor: Color.fromARGB(255, 142, 142, 147),
highContrastColor: Color.fromARGB(255, 108, 108, 112),
darkHighContrastColor: Color.fromARGB(255, 174, 174, 178)
);
public static readonly CupertinoDynamicColor systemGrey2 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemGrey2",
color: Color.fromARGB(255, 174, 174, 178),
darkColor: Color.fromARGB(255, 99, 99, 102),
highContrastColor: Color.fromARGB(255, 142, 142, 147),
darkHighContrastColor: Color.fromARGB(255, 124, 124, 128)
);
public static readonly CupertinoDynamicColor systemGrey3 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemGrey3",
color: Color.fromARGB(255, 199, 199, 204),
darkColor: Color.fromARGB(255, 72, 72, 74),
highContrastColor: Color.fromARGB(255, 174, 174, 178),
darkHighContrastColor: Color.fromARGB(255, 84, 84, 86)
);
public static readonly CupertinoDynamicColor systemGrey4 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemGrey4",
color: Color.fromARGB(255, 209, 209, 214),
darkColor: Color.fromARGB(255, 58, 58, 60),
highContrastColor: Color.fromARGB(255, 188, 188, 192),
darkHighContrastColor: Color.fromARGB(255, 68, 68, 70)
);
public static readonly CupertinoDynamicColor systemGrey5 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemGrey5",
color: Color.fromARGB(255, 229, 229, 234),
darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 216, 216, 220),
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56)
);
public static readonly CupertinoDynamicColor systemGrey6 = CupertinoDynamicColor.withBrightnessAndContrast(
debugLabel: "systemGrey6",
color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38)
);
public static readonly CupertinoDynamicColor label = new CupertinoDynamicColor(
debugLabel: "label",
effectiveColor:Color.fromARGB(255, 0, 0, 0),
color: Color.fromARGB(255, 0, 0, 0),
darkColor: Color.fromARGB(255, 255, 255, 255),
highContrastColor: Color.fromARGB(255, 0, 0, 0),
darkHighContrastColor: Color.fromARGB(255, 255, 255, 255),
elevatedColor: Color.fromARGB(255, 0, 0, 0),
darkElevatedColor: Color.fromARGB(255, 255, 255, 255),
highContrastElevatedColor: Color.fromARGB(255, 0, 0, 0),
darkHighContrastElevatedColor: Color.fromARGB(255, 255, 255, 255)
);
public static readonly CupertinoDynamicColor secondaryLabel = new CupertinoDynamicColor(
debugLabel: "secondaryLabel",
effectiveColor:Color.fromARGB(153, 60, 60, 67),
color: Color.fromARGB(153, 60, 60, 67),
darkColor: Color.fromARGB(153, 235, 235, 245),
highContrastColor: Color.fromARGB(173, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(173, 235, 235, 245),
elevatedColor: Color.fromARGB(153, 60, 60, 67),
darkElevatedColor: Color.fromARGB(153, 235, 235, 245),
highContrastElevatedColor: Color.fromARGB(173, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(173, 235, 235, 245)
);
/// The color for text labels containing tertiary content, equivalent to
/// [UIColor.tertiaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173153-tertiarylabel).
public static readonly CupertinoDynamicColor tertiaryLabel = new CupertinoDynamicColor(
debugLabel: "tertiaryLabel",
effectiveColor: Color.fromARGB(76, 60, 60, 67),
color: Color.fromARGB(76, 60, 60, 67),
darkColor: Color.fromARGB(76, 235, 235, 245),
highContrastColor: Color.fromARGB(96, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(96, 235, 235, 245),
elevatedColor: Color.fromARGB(76, 60, 60, 67),
darkElevatedColor: Color.fromARGB(76, 235, 235, 245),
highContrastElevatedColor: Color.fromARGB(96, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(96, 235, 235, 245)
);
public static readonly CupertinoDynamicColor quaternaryLabel = new CupertinoDynamicColor(
debugLabel: "quaternaryLabel",
effectiveColor:Color.fromARGB(45, 60, 60, 67),
color: Color.fromARGB(45, 60, 60, 67),
darkColor: Color.fromARGB(40, 235, 235, 245),
highContrastColor: Color.fromARGB(66, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(61, 235, 235, 245),
elevatedColor: Color.fromARGB(45, 60, 60, 67),
darkElevatedColor: Color.fromARGB(40, 235, 235, 245),
highContrastElevatedColor: Color.fromARGB(66, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(61, 235, 235, 245)
);
public static readonly CupertinoDynamicColor systemFill = new CupertinoDynamicColor(
debugLabel: "systemFill",
effectiveColor:Color.fromARGB(51, 120, 120, 128),
color: Color.fromARGB(51, 120, 120, 128),
darkColor: Color.fromARGB(91, 120, 120, 128),
highContrastColor: Color.fromARGB(71, 120, 120, 128),
darkHighContrastColor: Color.fromARGB(112, 120, 120, 128),
elevatedColor: Color.fromARGB(51, 120, 120, 128),
darkElevatedColor: Color.fromARGB(91, 120, 120, 128),
highContrastElevatedColor: Color.fromARGB(71, 120, 120, 128),
darkHighContrastElevatedColor: Color.fromARGB(112, 120, 120, 128)
);
public static readonly CupertinoDynamicColor secondarySystemFill = new CupertinoDynamicColor(
debugLabel: "secondarySystemFill",
effectiveColor: Color.fromARGB(40, 120, 120, 128),
color: Color.fromARGB(40, 120, 120, 128),
darkColor: Color.fromARGB(81, 120, 120, 128),
highContrastColor: Color.fromARGB(61, 120, 120, 128),
darkHighContrastColor: Color.fromARGB(102, 120, 120, 128),
elevatedColor: Color.fromARGB(40, 120, 120, 128),
darkElevatedColor: Color.fromARGB(81, 120, 120, 128),
highContrastElevatedColor: Color.fromARGB(61, 120, 120, 128),
darkHighContrastElevatedColor: Color.fromARGB(102, 120, 120, 128)
);
public static readonly CupertinoDynamicColor tertiarySystemFill = new CupertinoDynamicColor(
debugLabel: "tertiarySystemFill",
effectiveColor:Color.fromARGB(30, 118, 118, 128),
color: Color.fromARGB(30, 118, 118, 128),
darkColor: Color.fromARGB(61, 118, 118, 128),
highContrastColor: Color.fromARGB(51, 118, 118, 128),
darkHighContrastColor: Color.fromARGB(81, 118, 118, 128),
elevatedColor: Color.fromARGB(30, 118, 118, 128),
darkElevatedColor: Color.fromARGB(61, 118, 118, 128),
highContrastElevatedColor: Color.fromARGB(51, 118, 118, 128),
darkHighContrastElevatedColor: Color.fromARGB(81, 118, 118, 128)
);
public static readonly CupertinoDynamicColor quaternarySystemFill = new CupertinoDynamicColor(
debugLabel: "quaternarySystemFill",
effectiveColor:Color.fromARGB(20, 116, 116, 128),
color: Color.fromARGB(20, 116, 116, 128),
darkColor: Color.fromARGB(45, 118, 118, 128),
highContrastColor: Color.fromARGB(40, 116, 116, 128),
darkHighContrastColor: Color.fromARGB(66, 118, 118, 128),
elevatedColor: Color.fromARGB(20, 116, 116, 128),
darkElevatedColor: Color.fromARGB(45, 118, 118, 128),
highContrastElevatedColor: Color.fromARGB(40, 116, 116, 128),
darkHighContrastElevatedColor: Color.fromARGB(66, 118, 118, 128)
);
/// The color for placeholder text in controls or text views, equivalent to
/// [UIColor.placeholderText](https://developer.apple.com/documentation/uikit/uicolor/3173134-placeholdertext).
public static readonly CupertinoDynamicColor placeholderText = new CupertinoDynamicColor(
debugLabel: "placeholderText",
effectiveColor:Color.fromARGB(76, 60, 60, 67),
color: Color.fromARGB(76, 60, 60, 67),
darkColor: Color.fromARGB(76, 235, 235, 245),
highContrastColor: Color.fromARGB(96, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(96, 235, 235, 245),
elevatedColor: Color.fromARGB(76, 60, 60, 67),
darkElevatedColor: Color.fromARGB(76, 235, 235, 245),
highContrastElevatedColor: Color.fromARGB(96, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(96, 235, 235, 245)
);
public static readonly CupertinoDynamicColor systemBackground = new CupertinoDynamicColor(
debugLabel: "systemBackground",
effectiveColor:Color.fromARGB(255, 255, 255, 255),
color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 0, 0, 0),
highContrastColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastColor: Color.fromARGB(255, 0, 0, 0),
elevatedColor: Color.fromARGB(255, 255, 255, 255),
darkElevatedColor: Color.fromARGB(255, 28, 28, 30),
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38)
);
public static readonly CupertinoDynamicColor secondarySystemBackground = new CupertinoDynamicColor(
debugLabel: "secondarySystemBackground",
effectiveColor:Color.fromARGB(255, 242, 242, 247),
color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38),
elevatedColor: Color.fromARGB(255, 242, 242, 247),
darkElevatedColor: Color.fromARGB(255, 44, 44, 46),
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastElevatedColor: Color.fromARGB(255, 54, 54, 56)
);
public static readonly CupertinoDynamicColor tertiarySystemBackground = new CupertinoDynamicColor(
debugLabel: "tertiarySystemBackground",
effectiveColor:Color.fromARGB(255, 255, 255, 255),
color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56),
elevatedColor: Color.fromARGB(255, 255, 255, 255),
darkElevatedColor: Color.fromARGB(255, 58, 58, 60),
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastElevatedColor: Color.fromARGB(255, 68, 68, 70)
);
public static readonly CupertinoDynamicColor systemGroupedBackground = new CupertinoDynamicColor(
debugLabel: "systemGroupedBackground",
effectiveColor:Color.fromARGB(255, 242, 242, 247),
color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 0, 0, 0),
highContrastColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastColor: Color.fromARGB(255, 0, 0, 0),
elevatedColor: Color.fromARGB(255, 242, 242, 247),
darkElevatedColor: Color.fromARGB(255, 28, 28, 30),
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastElevatedColor: Color.fromARGB(255, 36, 36, 38)
);
public static readonly CupertinoDynamicColor secondarySystemGroupedBackground = new CupertinoDynamicColor(
debugLabel: "secondarySystemGroupedBackground",
effectiveColor:Color.fromARGB(255, 255, 255, 255),
color: Color.fromARGB(255, 255, 255, 255),
darkColor: Color.fromARGB(255, 28, 28, 30),
highContrastColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastColor: Color.fromARGB(255, 36, 36, 38),
elevatedColor: Color.fromARGB(255, 255, 255, 255),
darkElevatedColor: Color.fromARGB(255, 44, 44, 46),
highContrastElevatedColor: Color.fromARGB(255, 255, 255, 255),
darkHighContrastElevatedColor: Color.fromARGB(255, 54, 54, 56)
);
public static readonly CupertinoDynamicColor tertiarySystemGroupedBackground = new CupertinoDynamicColor(
debugLabel: "tertiarySystemGroupedBackground",
effectiveColor:Color.fromARGB(255, 242, 242, 247),
color: Color.fromARGB(255, 242, 242, 247),
darkColor: Color.fromARGB(255, 44, 44, 46),
highContrastColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastColor: Color.fromARGB(255, 54, 54, 56),
elevatedColor: Color.fromARGB(255, 242, 242, 247),
darkElevatedColor: Color.fromARGB(255, 58, 58, 60),
highContrastElevatedColor: Color.fromARGB(255, 235, 235, 240),
darkHighContrastElevatedColor: Color.fromARGB(255, 68, 68, 70)
);
public static readonly CupertinoDynamicColor separator = new CupertinoDynamicColor(
debugLabel: "separator",
effectiveColor:Color.fromARGB(73, 60, 60, 67),
color: Color.fromARGB(73, 60, 60, 67),
darkColor: Color.fromARGB(153, 84, 84, 88),
highContrastColor: Color.fromARGB(94, 60, 60, 67),
darkHighContrastColor: Color.fromARGB(173, 84, 84, 88),
elevatedColor: Color.fromARGB(73, 60, 60, 67),
darkElevatedColor: Color.fromARGB(153, 84, 84, 88),
highContrastElevatedColor: Color.fromARGB(94, 60, 60, 67),
darkHighContrastElevatedColor: Color.fromARGB(173, 84, 84, 88)
);
/// The color for borders or divider lines that hide any underlying content,
/// equivalent to [UIColor.opaqueSeparator](https://developer.apple.com/documentation/uikit/uicolor/3173133-opaqueseparator).
public static readonly CupertinoDynamicColor opaqueSeparator = new CupertinoDynamicColor(
debugLabel: "opaqueSeparator",
effectiveColor:Color.fromARGB(255, 198, 198, 200),
color: Color.fromARGB(255, 198, 198, 200),
darkColor: Color.fromARGB(255, 56, 56, 58),
highContrastColor: Color.fromARGB(255, 198, 198, 200),
darkHighContrastColor: Color.fromARGB(255, 56, 56, 58),
elevatedColor: Color.fromARGB(255, 198, 198, 200),
darkElevatedColor: Color.fromARGB(255, 56, 56, 58),
highContrastElevatedColor: Color.fromARGB(255, 198, 198, 200),
darkHighContrastElevatedColor: Color.fromARGB(255, 56, 56, 58)
);
public static readonly CupertinoDynamicColor link =
new CupertinoDynamicColor(
debugLabel: "link",
effectiveColor:Color.fromARGB(255, 0, 122, 255),
color: Color.fromARGB(255, 0, 122, 255),
darkColor: Color.fromARGB(255, 9, 132, 255),
highContrastColor: Color.fromARGB(255, 0, 122, 255),
darkHighContrastColor: Color.fromARGB(255, 9, 132, 255),
elevatedColor: Color.fromARGB(255, 0, 122, 255),
darkElevatedColor: Color.fromARGB(255, 9, 132, 255),
highContrastElevatedColor: Color.fromARGB(255, 0, 122, 255),
darkHighContrastElevatedColor: Color.fromARGB(255, 9, 132, 255)
);
}
public static readonly Color activeGreen = new Color(0xFF4CD964);
public class CupertinoDynamicColor : DiagnosticableMixinColor {
public CupertinoDynamicColor(
string debugLabel = null,
Color effectiveColor = null,
Color color = null,
Color darkColor = null,
Color highContrastColor = null,
Color darkHighContrastColor = null,
Color elevatedColor = null,
Color darkElevatedColor = null,
Color highContrastElevatedColor = null,
Color darkHighContrastElevatedColor = null,
Element debugResolveContext = null
): base(0)
{
D.assert(color != null,()=>"color8 == null");
D.assert(darkColor != null,()=>"color7 == null");
D.assert(highContrastColor != null,()=>"color6 == null");
D.assert(darkHighContrastColor != null,()=>"color5 == null");
D.assert(elevatedColor != null,()=>"color4 == null");
D.assert(darkElevatedColor != null,()=>"color3 == null");
D.assert(highContrastElevatedColor != null,()=>"color2 == null");
D.assert(darkHighContrastElevatedColor != null,()=>"color1 == null");
public static readonly Color activeOrange = new Color(0xFFFF9500);
_effectiveColor = effectiveColor ?? color;
this.color = color;
this.darkColor = darkColor;
this.highContrastColor = highContrastColor;
this.darkHighContrastColor = darkHighContrastColor;
this.elevatedColor = elevatedColor;
this.darkElevatedColor = darkElevatedColor;
this.highContrastElevatedColor = highContrastElevatedColor;
this.darkHighContrastElevatedColor = darkHighContrastElevatedColor;
_debugResolveContext = debugResolveContext;
_debugLabel = debugLabel;
}
public static readonly Color white = new Color(0xFFFFFFFF);
public static readonly Color black = new Color(0xFF000000);
public static CupertinoDynamicColor withBrightnessAndContrast(
string debugLabel ,
Color color ,
Color darkColor ,
Color highContrastColor ,
Color darkHighContrastColor
) {
return new CupertinoDynamicColor(
debugLabel: debugLabel,
color: color,
darkColor: darkColor,
highContrastColor: highContrastColor,
darkHighContrastColor: darkHighContrastColor,
elevatedColor: color,
darkElevatedColor: darkColor,
highContrastElevatedColor: highContrastColor,
darkHighContrastElevatedColor: darkHighContrastColor,
debugResolveContext: null
);
}
public static readonly Color lightBackgroundGray = new Color(0xFFE5E5EA);
public static CupertinoDynamicColor withBrightness(
string debugLabel = null,
Color color = null,
Color darkColor = null
) {
return new CupertinoDynamicColor(
debugLabel: debugLabel,
color: color,
darkColor: darkColor,
highContrastColor: color,
darkHighContrastColor: darkColor,
elevatedColor: color,
darkElevatedColor: darkColor,
highContrastElevatedColor: color,
darkHighContrastElevatedColor: darkColor,
debugResolveContext: null
);
}
public static readonly Color extraLightBackgroundGray = new Color(0xFFEFEFF4);
public readonly Color _effectiveColor;
public new uint value {
get {
return _effectiveColor.value;
}
}
public static readonly Color darkBackgroundGray = new Color(0xFF171717);
public static readonly Color inactiveGray = new Color(0xFF8E8E93);
public readonly string _debugLabel;
public readonly Element _debugResolveContext;
public readonly Color color;
public static readonly Color destructiveRed = new Color(0xFFFF3B30);
public readonly Color darkColor;
public readonly Color highContrastColor;
public readonly Color darkHighContrastColor;
public readonly Color elevatedColor;
public readonly Color darkElevatedColor;
public readonly Color highContrastElevatedColor;
public readonly Color darkHighContrastElevatedColor;
public static Color resolve(Color resolvable, BuildContext context, bool nullOk = true) {
if (resolvable == null)
return null;
D.assert(context != null);
//var resolveColor = (resolvable is CupertinoDynamicColor) ? ((CupertinoDynamicColor)resolvable).resolveFrom(context, nullOk: nullOk) : resolvable;
Color resolveColor = null;
if (resolvable is CupertinoDynamicColor) {
int i = 0;
resolveColor = ((CupertinoDynamicColor) resolvable).resolveFrom(context, nullOk: nullOk)._effectiveColor;
}
else {
int j = 0;
resolveColor = resolvable;
}
return resolveColor;
}
public bool _isPlatformBrightnessDependent {
get {
return color != darkColor
|| elevatedColor != darkElevatedColor
|| highContrastColor != darkHighContrastColor
|| highContrastElevatedColor != darkHighContrastElevatedColor;
}
}
public bool _isHighContrastDependent {
get {
return color != highContrastColor
|| darkColor != darkHighContrastColor
|| elevatedColor != highContrastElevatedColor
|| darkElevatedColor != darkHighContrastElevatedColor;
}
}
public bool _isInterfaceElevationDependent {
get {
return color != elevatedColor
|| darkColor != darkElevatedColor
|| highContrastColor != highContrastElevatedColor
|| darkHighContrastColor != darkHighContrastElevatedColor;
}
}
public CupertinoDynamicColor resolveFrom(BuildContext context, bool nullOk = true) {
Brightness brightness = _isPlatformBrightnessDependent
? CupertinoTheme.brightnessOf(context, nullOk: nullOk) ?? Brightness.light
: Brightness.light;
bool isHighContrastEnabled = _isHighContrastDependent
&& (MediaQuery.of(context, nullOk: nullOk)?.highContrast ?? false);
CupertinoUserInterfaceLevelData level = _isInterfaceElevationDependent
? CupertinoUserInterfaceLevel.of(context, nullOk: nullOk) ?? CupertinoUserInterfaceLevelData.baselayer
: CupertinoUserInterfaceLevelData.baselayer;
Color resolved = null;
switch (brightness) {
case Brightness.light:
switch (level) {
case CupertinoUserInterfaceLevelData.baselayer:
resolved = isHighContrastEnabled ? highContrastColor : color;
break;
case CupertinoUserInterfaceLevelData.elevatedlayer:
resolved = isHighContrastEnabled ? highContrastElevatedColor : elevatedColor;
break;
}
break;
case Brightness.dark:
switch (level) {
case CupertinoUserInterfaceLevelData.baselayer:
resolved = isHighContrastEnabled ? darkHighContrastColor : darkColor;
break;
case CupertinoUserInterfaceLevelData.elevatedlayer:
resolved = isHighContrastEnabled ? darkHighContrastElevatedColor : darkElevatedColor;
break;
}
break;
}
Element _debugContext = null;
D.assert(() => {
_debugContext = context as Element;
return true;
}
);
return new CupertinoDynamicColor(
debugLabel: _debugLabel,
effectiveColor: resolved,
color: color,
darkColor: darkColor,
highContrastColor: highContrastColor,
darkHighContrastColor: darkHighContrastColor,
elevatedColor: color,
darkElevatedColor: darkColor,
highContrastElevatedColor: highContrastColor,
darkHighContrastElevatedColor: darkHighContrastColor,
debugResolveContext: null
);
}
public bool Equals(CupertinoDynamicColor other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(value, other.value)
&& Equals(color, other.color)
&& Equals(darkColor, other.darkColor)
&& Equals(highContrastColor, other.highContrastColor)
&& Equals(darkHighContrastColor, other.darkHighContrastColor)
&& Equals(elevatedColor, other.elevatedColor)
&& Equals(darkElevatedColor, other.darkElevatedColor)
&& Equals(highContrastElevatedColor, other.highContrastElevatedColor)
&& Equals(darkHighContrastElevatedColor, other.darkHighContrastElevatedColor);
}
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;
}
if (ReferenceEquals(this, obj)) {
return true;
}
if (obj.GetType() != GetType()) {
return false;
}
return Equals((CupertinoDynamicColor) obj);
}
public override int GetHashCode() {
unchecked {
var hashCode = (value != null ? value.GetHashCode() : 0);
hashCode = (hashCode * 397) ^(color != null ? color.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (darkColor != null ? darkColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (highContrastColor != null ? highContrastColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (elevatedColor != null ? elevatedColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (darkElevatedColor != null ? darkElevatedColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (darkHighContrastColor != null ? darkHighContrastColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (darkHighContrastElevatedColor != null
? darkHighContrastElevatedColor.GetHashCode()
: 0);
hashCode = (hashCode * 397) ^
(highContrastElevatedColor != null ? highContrastElevatedColor.GetHashCode() : 0);
return hashCode;
}
}
public static bool operator ==(CupertinoDynamicColor left, CupertinoDynamicColor right) {
return Equals(left, right);
}
public static bool operator !=(CupertinoDynamicColor left, CupertinoDynamicColor right) {
return !Equals(left, right);
}
public override string ToString() {
return toString();
}
public override string toString(DiagnosticLevel minLevel = DiagnosticLevel.debug) {
string toStringColor(string name, Color color) {
string marker = color == _effectiveColor ? "*" : "";
return marker+ name+" = " + color + marker;
}
List<string> xs = new List<string>();
xs.Add(toStringColor("color",color));
if (_isPlatformBrightnessDependent)
xs.Add(toStringColor("darkColor", darkColor));
if (_isHighContrastDependent)
xs.Add( toStringColor("highContrastColor", highContrastColor));
if (_isPlatformBrightnessDependent && _isHighContrastDependent)
xs.Add(toStringColor("darkHighContrastColor", darkHighContrastColor));
if (_isInterfaceElevationDependent)
xs.Add( toStringColor("elevatedColor", elevatedColor));
if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent)
xs.Add(toStringColor("darkElevatedColor", darkElevatedColor));
if (_isHighContrastDependent && _isInterfaceElevationDependent)
xs.Add(toStringColor("highContrastElevatedColor", highContrastElevatedColor));
if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent)
xs.Add(toStringColor("darkHighContrastElevatedColor", darkHighContrastElevatedColor));
string xsStr = "";
foreach (var xss in xs) {
xsStr += xss;
}
var debugContext = _debugResolveContext?.widget;
if (_debugResolveContext?.widget == null) {
return $"[{_debugLabel ?? GetType().ToString()}({xsStr}, resolved by: UNRESOLVED)]";
}
else {
return $"[{_debugLabel ?? GetType().ToString()}({xsStr}, resolved by: {_debugResolveContext?.widget })]";
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
if (_debugLabel != null)
properties.add(new MessageProperty("debugLabel", _debugLabel));
properties.add(createCupertinoColorProperty("color", color));
if (_isPlatformBrightnessDependent)
properties.add(createCupertinoColorProperty("darkColor", darkColor));
if (_isHighContrastDependent)
properties.add(createCupertinoColorProperty("highContrastColor", highContrastColor));
if (_isPlatformBrightnessDependent && _isHighContrastDependent)
properties.add(createCupertinoColorProperty("darkHighContrastColor", darkHighContrastColor));
if (_isInterfaceElevationDependent)
properties.add(createCupertinoColorProperty("elevatedColor", elevatedColor));
if (_isPlatformBrightnessDependent && _isInterfaceElevationDependent)
properties.add(createCupertinoColorProperty("darkElevatedColor", darkElevatedColor));
if (_isHighContrastDependent && _isInterfaceElevationDependent)
properties.add(createCupertinoColorProperty("highContrastElevatedColor", highContrastElevatedColor));
if (_isPlatformBrightnessDependent && _isHighContrastDependent && _isInterfaceElevationDependent)
properties.add(createCupertinoColorProperty("darkHighContrastElevatedColor",
darkHighContrastElevatedColor));
if (_debugResolveContext != null)
properties.add(new DiagnosticsProperty<Element>("last resolved", _debugResolveContext));
}
public static DiagnosticsProperty<Color> createCupertinoColorProperty(
string name ,
Color value ,
bool showName = true,
object defaultValue = null,
DiagnosticsTreeStyle style = DiagnosticsTreeStyle.singleLine,
DiagnosticLevel level = DiagnosticLevel.info
) {
if (value is CupertinoDynamicColor) {
return new DiagnosticsProperty<Color>(
name: name,
value: value,
description: ((CupertinoDynamicColor)value)._debugLabel,
showName: showName,
defaultValue: defaultValue,
style: style,
level: level
);
}
else {
return new ColorProperty(
name,
value,
showName: showName,
defaultValue: defaultValue,
style: style,
level: level
);
}
}
}
}

部分文件因为文件数量过多而无法显示

正在加载...
取消
保存