浏览代码

Merge remote-tracking branch 'upstream/master' into widgets_panel

/main
fzhangtj 6 年前
当前提交
ece17ad8
共有 144 个文件被更改,包括 5941 次插入520 次删除
  1. 12
      .gitignore
  2. 7
      .npmignore
  3. 6
      CHANGELOG.md
  4. 28
      CONTRIBUTING.md
  5. 27
      LICENSE.md
  6. 25
      README.md
  7. 46
      Runtime/animation/listener_helpers.mixin.gen.cs
  8. 27
      Runtime/editor/editor_window.cs
  9. 5
      Runtime/engine/UIWidgetsPanel.cs
  10. 31
      Runtime/foundation/node.mixin.gen.cs
  11. 8
      Runtime/foundation/node.mixin.njk
  12. 30
      Runtime/material/arc.cs
  13. 44
      Runtime/material/button_theme.cs
  14. 3
      Runtime/material/color_scheme.cs
  15. 10
      Runtime/material/constants.cs
  16. 53
      Runtime/material/debug.cs
  17. 8
      Runtime/material/drawer.cs
  18. 7
      Runtime/material/drawer_header.cs
  19. 2
      Runtime/material/expand_icon.cs
  20. 6
      Runtime/material/expansion_panel.cs
  21. 5
      Runtime/material/expansion_tile.cs
  22. 8
      Runtime/material/icon_button.cs
  23. 998
      Runtime/material/icons.cs
  24. 2
      Runtime/material/ink_decoration.cs
  25. 5
      Runtime/material/ink_highlight.cs
  26. 43
      Runtime/material/ink_ripple.cs
  27. 52
      Runtime/material/ink_splash.cs
  28. 2
      Runtime/material/ink_well.cs
  29. 2
      Runtime/material/list_tile.cs
  30. 14
      Runtime/material/material.cs
  31. 10
      Runtime/material/scrollbar.cs
  32. 3
      Runtime/material/text_theme.cs
  33. 6
      Runtime/material/theme.cs
  34. 224
      Runtime/material/theme_data.cs
  35. 7
      Runtime/material/tooltip.cs
  36. 1
      Runtime/painting/image_resolution.cs
  37. 7
      Runtime/promise/Promise_NonGeneric.cs
  38. 3
      Runtime/rendering/binding.cs
  39. 8
      Runtime/rendering/box.cs
  40. 18
      Runtime/rendering/box.mixin.gen.cs
  41. 68
      Runtime/rendering/layer.cs
  42. 88
      Runtime/rendering/object.mixin.gen.cs
  43. 157
      Runtime/rendering/proxy_box.cs
  44. 20
      Runtime/rendering/proxy_box.mixin.gen.cs
  45. 27
      Runtime/scheduler/binding.cs
  46. 36
      Runtime/ui/compositing.cs
  47. 4
      Runtime/ui/geometry.cs
  48. 39
      Runtime/ui/painting/canvas.cs
  49. 6
      Runtime/ui/painting/canvas_impl.cs
  50. 170
      Runtime/ui/painting/path.cs
  51. 16
      Runtime/ui/window.cs
  52. 23
      Runtime/widgets/app.cs
  53. 117
      Runtime/widgets/automatic_keep_alive.cs
  54. 179
      Runtime/widgets/basic.cs
  55. 30
      Runtime/widgets/debug.cs
  56. 10
      Runtime/widgets/framework.cs
  57. 71
      Runtime/widgets/implicit_animations.cs
  58. 3
      Runtime/widgets/layout_builder.cs
  59. 256
      Runtime/widgets/navigator.cs
  60. 6
      Runtime/widgets/pages.cs
  61. 13
      Runtime/widgets/routes.cs
  62. 60
      Runtime/widgets/safe_area.cs
  63. 4
      Runtime/widgets/scroll_notification.mixin.gen.cs
  64. 2
      Runtime/widgets/ticker_provider.cs
  65. 2
      Runtime/widgets/transitions.cs
  66. 9
      Samples/UIWidgetSample/AsScreenSample.cs
  67. 30
      Samples/UIWidgetSample/MaterialSample.cs
  68. 3
      Samples/UIWidgetSample/NavigationSample.cs
  69. 29
      Tests/Editor/CanvasAndLayers.cs
  70. 15
      Tests/Editor/Widgets.cs
  71. 32
      Third Party Notices.md
  72. 8
      package.json
  73. 95
      Runtime/flow/performance_overlay_layer.cs
  74. 11
      Runtime/flow/performance_overlay_layer.cs.meta
  75. 51
      Runtime/flow/texture_layer.cs
  76. 11
      Runtime/flow/texture_layer.cs.meta
  77. 135
      Runtime/material/app.cs
  78. 11
      Runtime/material/app.cs.meta
  79. 274
      Runtime/material/dialog.cs
  80. 11
      Runtime/material/dialog.cs.meta
  81. 69
      Runtime/material/dialog_theme.cs
  82. 11
      Runtime/material/dialog_theme.cs.meta
  83. 390
      Runtime/material/material_localizations.cs
  84. 11
      Runtime/material/material_localizations.cs.meta
  85. 62
      Runtime/material/page.cs
  86. 11
      Runtime/material/page.cs.meta
  87. 151
      Runtime/material/page_transitions_theme.cs
  88. 11
      Runtime/material/page_transitions_theme.cs.meta
  89. 608
      Runtime/material/popup_menu.cs
  90. 11
      Runtime/material/popup_menu.cs.meta
  91. 527
      Runtime/material/switch.cs
  92. 11
      Runtime/material/switch.cs.meta
  93. 153
      Runtime/material/timer.cs
  94. 11
      Runtime/material/timer.cs.meta
  95. 317
      Runtime/material/toggleable.cs
  96. 11
      Runtime/material/toggleable.cs.meta
  97. 81
      Runtime/rendering/performance_overlay.cs
  98. 11
      Runtime/rendering/performance_overlay.cs.meta
  99. 58
      Runtime/rendering/texture.cs
  100. 11
      Runtime/rendering/texture.cs.meta

12
.gitignore


node_modules/
npm-debug.log
yarn-error.log
artifacts/**
build/**
.build_script/**
node_modules/**
.DS_Store
.npmrc
!Documentation~
!.Documentation
npm-debug.log
build.sh.meta
build.bat.meta

7
.npmignore


build.sh.meta
build.bat
build.bat.meta
automation/**
utr_output/**
.Editor/**
.yamato/**
*.zip*
scripts~/**

6
CHANGELOG.md


The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [0.1.0] - 2017-MM-DD
## [1.0.0-preview] - 2019-03-01
### This is the first release of *Unity Package \<Your package name\>*.
### This is the first release of *Unity Package UIWidgets*.
*Short description of this release*
*just the first release*

28
CONTRIBUTING.md


# Contributing
## If you are interested in contributing, here are some ground rules:
* ... Define guidelines & rules for what contributors need to know to successfully make Pull requests against your repo ...
### Code Style (using JetBrains Rider)
1. **Import the Customized Code Cleanup Settings**: Open Preferences -> Manage Layers,
Choose 'Solution "\<YourProjectName\>" personal' and Click "Add Layer" ("+") -> "Open Settings File...".
and Open the file "UIWidgetCleanupPlugin.DotSettings" under \<YourProjectPath\>/Packages/com.unity.uiwidgets/"
2. **Cleanup Code style using the Customized Code Cleanup Settings**: Open Code -> Code Cleanup,
Pick a Cleanup scope as you want and Choose "UIWidgets" as the "Code cleanup profile", then click "OK"
3. **Refine Code Style Rules**: Edit the ".editorconfig" file under \<YourProjectPath\>/Packages/com.unity.uiwidgets/". Visit
https://www.jetbrains.com/help/rider/EditorConfig_Index.html for the detailed.
### Generate Code.
Code files ending with ".gen.cs" are auto generated. Follow these steps to generate them:
1. **Go to scripts Folder and Run npm install**:
```
cd <YourProjectPath>/Packages/com.unity.uiwidgets/scripts~
npm install
```
2. **Run the codegen Command**:
```
node uiwidgets-cli.js codegen . generate mixin code
```
## All contributions are subject to the [Unity Contribution Agreement(UCA)](https://unity3d.com/legal/licenses/Unity_Contribution_Agreement)
By making a pull request, you are confirming agreement to the terms and conditions of the UCA, including that your Contributions are your original creation and that you have complete right and authority to make your Contributions.

27
LICENSE.md


Copyright 2019 The UIWidget Authors. All rights reserved.
Copyright 2014 The Chromium Authors. All rights reserved.
UIWidgets copyright © 2019 Unity Technologies ApS
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Unless expressly provided otherwise, the Software under this license is made available strictly on an “AS IS” BASIS WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. Please review the license for details on these and other terms and conditions.

25
README.md


| Any IDE recommendation for UIWidgets? | **Rider, VSCode(Open .sln)** |
## How to Contribute
If you want to join us, please contact us via Github and we will respond as soon as possible.
#### Code Style
1. **Import the Customized Code Cleanup Settings**: Open Preferences -> Manage Layers,
Choose 'Solution "\<YourProjectName\>" personal' and Click "Add Layer" ("+") -> "Open Settings File...".
and Open the file "UIWidgetCleanupPlugin.DotSettings" under \<YourProjectPath\>/Packages/com.unity.uiwidgets/"
2. **Cleanup Code style using the Customized Code Cleanup Settings**: Open Code -> Code Cleanup,
Pick a Cleanup scope as you want and Choose "UIWidgets" as the "Code cleanup profile", then click "OK"
3. **Refine Code Style Rules**: Edit the ".editorconfig" file under \<YourProjectPath\>/Packages/com.unity.uiwidgets/". Visit
https://www.jetbrains.com/help/rider/EditorConfig_Index.html for the detailed.
#### Generate njk Code
1. **Go to scripts Folder and Run npm install**:
```
cd <YourProjectPath>/Packages/com.unity.uiwidgets/scripts
npm install
```
2. **Run the codegen Command**:
```
node uiwidgets-cli.js codegen . generate mixin code
```
Check [CONTRIBUTING.md](CONTRIBUTING.md)

46
Runtime/animation/listener_helpers.mixin.gen.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.animation {
public abstract class AnimationLazyListenerMixinAnimation<T> : Animation<T> {
int _listenerCounter = 0;

}
public abstract class AnimationEagerListenerMixinAnimation<T> : Animation<T> {
protected void didRegisterListener() {
}

}
public abstract class
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
public abstract class AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {

if (this._listeners.Contains(listener)) {
listener();
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

}
public abstract class
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationEagerListenerMixinAnimation<T> {
public abstract class AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationEagerListenerMixinAnimation<T> {
readonly ObserverList<VoidCallback> _listeners = new ObserverList<VoidCallback>();
public override void addListener(VoidCallback listener) {

if (this._listeners.Contains(listener)) {
listener();
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

}
public abstract class
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> :
AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> {
public abstract class AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLocalListenersMixinAnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (this._statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

}
public abstract class
AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T
> {
public abstract class AnimationLocalStatusListenersMixinAnimationLazyListenerMixinAnimation<T> : AnimationLazyListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (this._statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

}
public abstract class
AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> :
AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> {
public abstract class AnimationLocalStatusListenersMixinAnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> : AnimationLocalListenersMixinAnimationEagerListenerMixinAnimation<T> {
readonly ObserverList<AnimationStatusListener> _statusListeners = new ObserverList<AnimationStatusListener>();
public override void addStatusListener(AnimationStatusListener listener) {

if (this._statusListeners.Contains(listener)) {
listener(status);
}
}
catch (Exception exception) {
} catch (Exception exception) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: exception,
library: "animation library",

}
}
}
}

27
Runtime/editor/editor_window.cs


using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

}
}
WidgetsBinding _binding;
internal WidgetsBinding _binding;
float _lastWindowWidth;
float _lastWindowHeight;

}
public override IDisposable getScope() {
instance = this;
WindowAdapter oldInstance = (WindowAdapter) Window._instance;
Window._instance = this;
}
WidgetsBinding.instance = this._binding;
return new WindowDisposable(this);
}
SchedulerBinding._instance = this._binding;
return new WindowDisposable(this, oldInstance);
readonly WindowAdapter _oldWindow;
public WindowDisposable(WindowAdapter window) {
public WindowDisposable(WindowAdapter window, WindowAdapter oldWindow) {
this._oldWindow = oldWindow;
D.assert(instance == this._window);
instance = null;
D.assert(Window._instance == this._window);
Window._instance = this._oldWindow;
D.assert(WidgetsBinding.instance == this._window._binding);
WidgetsBinding.instance = null;
D.assert(SchedulerBinding._instance == this._window._binding);
SchedulerBinding._instance = this._oldWindow?._binding;
}
}

5
Runtime/engine/UIWidgetsPanel.cs


using System.Collections.Generic;
using System.Collections.Generic;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

using Rect = UnityEngine.Rect;
using Texture = UnityEngine.Texture;
namespace Unity.UIWidgets.engine {
public class UIWidgetWindowAdapter : WindowAdapter {

}
void Update() {
PerformanceUtils.instance.updateDeltaTime(Time.unscaledDeltaTime);
this._displayMetrics.Update();
UIWidgetsMessageManager.ensureUIWidgetsMessageManagerIfNeeded();
if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != this.gameObject) {

31
Runtime/foundation/node.mixin.gen.cs


using Unity.UIWidgets.async;
namespace Unity.UIWidgets.foundation {
public class AbstractNode {
public class AbstractNode {
public int depth {
get { return this._depth; }
}

while (node.parent != null) {
node = node.parent;
}
D.assert(node != child); // indicates we are about to create a cycle
return true;
});

}
public class AbstractNodeMixinDiagnosticableTree : DiagnosticableTree {
public class AbstractNodeMixinDiagnosticableTree : DiagnosticableTree {
public int depth {
get { return this._depth; }
}

while (node.parent != null) {
node = node.parent;
}
D.assert(node != child); // indicates we are about to create a cycle
return true;
});

}
public abstract class CanonicalMixinDiagnosticableTree : DiagnosticableTree {
public abstract class CanonicalMixinDiagnosticableTree : DiagnosticableTree {
_DependencyList _dependencyList;
_DependencyList _getDependencyList() {

return this._dependencyList;
}
CanonicalMixinDiagnosticableTree _canonical;
CanonicalMixinDiagnosticableTree _getCanonical() {

}
}
}
public bool alwaysUpdate { get; set; } // if canonicalEquals should not be used.
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {

return false;
}
return ReferenceEquals(this._getCanonical(), ((CanonicalMixinDiagnosticableTree) obj)._getCanonical());
if (this.alwaysUpdate) {
return ReferenceEquals(this, obj);
} else {
return ReferenceEquals(this._getCanonical(), ((CanonicalMixinDiagnosticableTree) obj)._getCanonical());
}
}

8
Runtime/foundation/node.mixin.njk


static readonly Dictionary<_DependencyList, WeakReference> _canonicalObjects =
new Dictionary<_DependencyList, WeakReference>();
public bool alwaysUpdate { get; set; } // if canonicalEquals should not be used.
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {
return false;

return false;
}
return ReferenceEquals(this._getCanonical(), ((CanonicalMixin{{with}}) obj)._getCanonical());
if (this.alwaysUpdate) {
return ReferenceEquals(this, obj);
} else {
return ReferenceEquals(this._getCanonical(), ((CanonicalMixin{{with}}) obj)._getCanonical());
}
}
public override int GetHashCode() {

30
Runtime/material/arc.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;

namespace Unity.UIWidgets.material {
static class ArcUtils {
public const float _kOnAxisDelta = 2.0f;
public static readonly List<_Diagonal> _allDiagonals = new List<_Diagonal> {
new _Diagonal(_CornerId.topLeft, _CornerId.bottomRight),
new _Diagonal(_CornerId.bottomRight, _CornerId.topLeft),
new _Diagonal(_CornerId.topRight, _CornerId.bottomLeft),
new _Diagonal(_CornerId.bottomLeft, _CornerId.topRight)
};
public delegate float _KeyFunc<T>(T input);
public static T _maxBy<T>(List<T> input, _KeyFunc<T> keyFunc) {
T maxValue = default(T);
float? maxKey = null;
foreach (T value in input) {
float key = keyFunc(value);
if (maxKey == null || key > maxKey) {
maxValue = value;
maxKey = key;
}
}
return maxValue;
}
}
public class MaterialPointArcTween : Tween<Offset> {
public MaterialPointArcTween(
Offset begin = null,

44
Runtime/material/button_theme.cs


this.data = data;
}
public static ButtonTheme fromButtonThemeData(
Key key = null,
ButtonThemeData data = null,
Widget child = null) {
return new ButtonTheme(key, data, child);
}
public static ButtonTheme bar(
Key key = null,
ButtonTextTheme textTheme = ButtonTextTheme.accent,
float minWidth = 64.0f,
float height = 36.0f,
EdgeInsets padding = null,
ShapeBorder shape = null,
bool alignedDropdown = false,
Color buttonColor = null,
Color disabledColor = null,
Color highlightColor = null,
Color splashColor = null,
ColorScheme colorScheme = null,
Widget child = null,
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded
) {
D.assert(minWidth >= 0.0);
D.assert(height >= 0.0);
return new ButtonTheme(key, new ButtonThemeData(
textTheme: textTheme,
minWidth: minWidth,
height: height,
padding: padding ?? EdgeInsets.symmetric(horizontal: 8.0f),
shape: shape,
alignedDropdown: alignedDropdown,
layoutBehavior: layoutBehavior,
buttonColor: buttonColor,
disabledColor: disabledColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorScheme: colorScheme
), child);
}
public readonly ButtonThemeData data;
public static ButtonThemeData of(BuildContext context) {

}
public class ButtonThemeData : Diagnosticable {
public class ButtonThemeData : Diagnosticable, IEquatable<ButtonThemeData> {
public ButtonThemeData(
ButtonTextTheme textTheme = ButtonTextTheme.normal,
float minWidth = 88.0f,

3
Runtime/material/color_scheme.cs


using System;
public class ColorScheme : Diagnosticable {
public class ColorScheme : Diagnosticable, IEquatable<ColorScheme> {
public ColorScheme(
Color primary,
Color primaryVariant,

10
Runtime/material/constants.cs


namespace Unity.UIWidgets.material {
public static class Constants {
public static readonly float kToolbarHeight = 56.0f;
public const float kToolbarHeight = 56.0f;
public static readonly float kBottomNavigationBarHeight = 56.0f;
public const float kBottomNavigationBarHeight = 56.0f;
public static readonly float kTextTabBarHeight = 48.0f;
public const float kTextTabBarHeight = 48.0f;
public static readonly float kRadialReactionRadius = 20.0f;
public const float kRadialReactionRadius = 20.0f;
public static readonly int kRadialReactionAlpha = 0x1F;
public const int kRadialReactionAlpha = 0x1F;
public static readonly TimeSpan kTabScrollDuration = new TimeSpan(0, 0, 0, 0, 300);

53
Runtime/material/debug.cs


using System.Collections.Generic;
using System.Text;
public static class MaterialDebug {
public static class MaterialD {
public static bool debugCheckHasMaterial(BuildContext context) {
D.assert(() => {
if (!(context.widget is Material) && context.ancestorWidgetOfExactType(typeof(Material)) == null) {

message += "In material design, most widgets are conceptually \"printed\" on " +
"a sheet of material. In Flutter\'s material library, that " +
"a sheet of material. In UIWidgets\'s material library, that " +
"material is represented by the Material widget. It is the " +
"Material widget that renders ink splashes, for instance. " +
"Because of this, many material library widgets require that " +

if (ancestors.isNotEmpty()) {
message += "The ancestors of this widget were:";
foreach (Widget ancestor in ancestors) {
message += "\n $ancestor";
message += "\n " + ancestor;
}
else {
} else {
message += "This widget is the root of the tree, so it has no " +
"ancestors, let alone a \"Material\" ancestor.";
}

return true;
});
return true;
}
public static bool debugCheckHasMaterialLocalizations(BuildContext context) {
D.assert(() => {
if (Localizations.of<MaterialLocalizations>(context, typeof(MaterialLocalizations)) == null) {
StringBuilder message = new StringBuilder();
message.AppendLine("No MaterialLocalizations found.");
message.AppendLine(
context.widget.GetType() + " widgets require MaterialLocalizations " +
"to be provided by a Localizations widget ancestor.");
message.AppendLine(
"Localizations are used to generate many different messages, labels," +
"and abbreviations which are used by the material library. ");
message.AppendLine(
"To introduce a MaterialLocalizations, either use a " +
" MaterialApp at the root of your application to include them " +
"automatically, or add a Localization widget with a " +
"MaterialLocalizations delegate.");
message.AppendLine(
"The specific widget that could not find a MaterialLocalizations ancestor was:"
);
message.AppendLine(" " + context.widget);
List<Widget> ancestors = new List<Widget>();
context.visitAncestorElements((Element element) => {
ancestors.Add(element.widget);
return true;
});
if (ancestors.isNotEmpty()) {
message.Append("The ancestors of this widget were:");
foreach (Widget ancestor in ancestors) {
message.Append("\n " + ancestor);
}
} else {
message.AppendLine(
"This widget is the root of the tree, so it has no " +
"ancestors, let alone a \"Localizations\" ancestor."
);
}
throw new UIWidgetsError(message.ToString());
}
return true;
});
return true;

8
Runtime/material/drawer.cs


using UnityEngine;
namespace Unity.UIWidgets.material {
static class DrawerUtils {
public const float _kWidth = 304.0f;
public const float _kEdgeDragWidth = 20.0f;
public const float _kMinFlingVelocity = 365.0f;
public static readonly TimeSpan _kBaseSettleDuration = new TimeSpan(0, 0, 0, 0, 246);
}
public enum DrawerAlignment {
start,
end

7
Runtime/material/drawer_header.cs


using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
static class DrawerHeaderUtils {
public const float _kDrawerHeaderHeight = 160.0f + 1.0f;
}
public class DrawerHeader : StatelessWidget {
public DrawerHeader(
Key key = null,

public override Widget build(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
D.assert(MaterialD.debugCheckHasMaterial(context));
ThemeData theme = Theme.of(context);
float statusBarHeight = MediaQuery.of(context).padding.top;
return new Container(

2
Runtime/material/expand_icon.cs


public override Widget build(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
D.assert(MaterialD.debugCheckHasMaterial(context));
ThemeData theme = Theme.of(context);
return new IconButton(
padding: this.widget.padding,

6
Runtime/material/expansion_panel.cs


using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
static class ExpansionPanelUtils {
public const float _kPanelHeaderCollapsedHeight = 48.0f;
public const float _kPanelHeaderExpandedHeight = 64.0f;
}
class _SaltedKey<S, V> : LocalKey {
public _SaltedKey(
S salt,

5
Runtime/material/expansion_tile.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;

using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
static class ExpansionTileUtils {
public static readonly TimeSpan _kExpand = new TimeSpan(0, 0, 0, 0, 200);
}
public class ExpansionTile : StatefulWidget {
public ExpansionTile(
Key key = null,

8
Runtime/material/icon_button.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
static class IconButtonUtils {
public const float _kMinButtonSize = 48.0f;
}
public class IconButton : StatelessWidget {
public IconButton(
Key key = null,

public readonly string tooltip;
public override Widget build(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
D.assert(MaterialD.debugCheckHasMaterial(context));
Color currentColor;
if (this.onPressed != null) {
currentColor = this.color;

998
Runtime/material/icons.cs
文件差异内容过多而无法显示
查看文件

2
Runtime/material/ink_decoration.cs


}
public override Widget build(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
D.assert(MaterialD.debugCheckHasMaterial(context));
Widget result = new LayoutBuilder(
builder: this._build
);

5
Runtime/material/ink_highlight.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;

namespace Unity.UIWidgets.material {
static class InkHighlightUtils {
public static readonly TimeSpan _kHighlightFadeDuration = new TimeSpan(0, 0, 0, 0, 200);
}
public class InkHighlight : InteractiveInkFeature {
public InkHighlight(
MaterialInkController controller = null,

43
Runtime/material/ink_ripple.cs


using System;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
static class InkRippleUtils {
public static readonly TimeSpan _kUnconfirmedRippleDuration = new TimeSpan(0, 0, 1);
public static readonly TimeSpan _kFadeInDuration = new TimeSpan(0, 0, 0, 0, 75);
public static readonly TimeSpan _kRadiusDuration = new TimeSpan(0, 0, 0, 0, 225);
public static readonly TimeSpan _kFadeOutDuration = new TimeSpan(0, 0, 0, 0, 375);
public static readonly TimeSpan _kCancelDuration = new TimeSpan(0, 0, 0, 0, 75);
public const float _kFadeOutIntervalStart = 225.0f / 375.0f;
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell,
RectCallback rectCallback) {
if (rectCallback != null) {
D.assert(containedInkWell);
return rectCallback;
}
if (containedInkWell) {
return () => Offset.zero & referenceBox.size;
}
return null;
}
public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
Offset position) {
Size size = rectCallback != null ? rectCallback().size : referenceBox.size;
float d1 = size.bottomRight(Offset.zero).distance;
float d2 = (size.topRight(Offset.zero) - size.bottomLeft(Offset.zero)).distance;
return (Mathf.Max(d1, d2) / 2.0f);
}
}
public class _InkRippleFactory : InteractiveInkFeatureFactory {
public _InkRippleFactory() {
}

}
}
//todo:xingwei.zhu: remove this condition when drawCircle bug fixed (when radius.value == 0)
if (this._radius.value != 0) {
canvas.drawCircle(center, this._radius.value, paint);
}
canvas.drawCircle(center, this._radius.value, paint);
canvas.restore();
}
}

52
Runtime/material/ink_splash.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
static class InkSplashUtils {
public static readonly TimeSpan _kUnconfirmedSplashDuration = new TimeSpan(0, 0, 0, 1, 0);
public static readonly TimeSpan _kSplashFadeDuration = new TimeSpan(0, 0, 0, 0, 200);
public const float _kSplashInitialSize = 0.0f;
public const float _kSplashConfirmedVelocity = 1.0f;
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell,
RectCallback rectCallback) {
if (rectCallback != null) {
D.assert(containedInkWell);
return rectCallback;
}
if (containedInkWell) {
return () => Offset.zero & referenceBox.size;
}
return null;
}
public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback,
Offset position) {
if (containedInkWell) {
Size size = rectCallback != null ? rectCallback().size : referenceBox.size;
return _getSplashRadiusForPositionInSize(size, position);
}
return Material.defaultSplashRadius;
}
static float _getSplashRadiusForPositionInSize(Size bounds, Offset position) {
float d1 = (position - bounds.topLeft(Offset.zero)).distance;
float d2 = (position - bounds.topRight(Offset.zero)).distance;
float d3 = (position - bounds.bottomLeft(Offset.zero)).distance;
float d4 = (position - bounds.bottomRight(Offset.zero)).distance;
return Mathf.Max(Mathf.Max(d1, d2), Mathf.Max(d3, d4)).ceil();
}
}
public class _InkSplashFactory : InteractiveInkFeatureFactory {
public _InkSplashFactory() {
}

}
}
//todo:xingwei.zhu: remove this condition when drawCircle bug fixed (when radius.value == 0)
if (this._radius.value != 0) {
canvas.drawCircle(center, this._radius.value, paint);
}
canvas.drawCircle(center, this._radius.value, paint);
canvas.restore();
}
}

2
Runtime/material/ink_well.cs


public virtual bool debugCheckContext(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
D.assert(MaterialD.debugCheckHasMaterial(context));
return true;
}

2
Runtime/material/list_tile.cs


}
public override Widget build(BuildContext context) {
D.assert(MaterialDebug.debugCheckHasMaterial(context));
D.assert(MaterialD.debugCheckHasMaterial(context));
ThemeData theme = Theme.of(context);
ListTileTheme tileTheme = ListTileTheme.of(context);

14
Runtime/material/material.cs


using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
static class MaterialConstantsUtils {
public static readonly Dictionary<MaterialType, BorderRadius> kMaterialEdges =
new Dictionary<MaterialType, BorderRadius> {
{MaterialType.canvas, null},
{MaterialType.card, BorderRadius.circular(2.0f)},
{MaterialType.circle, null},
{MaterialType.button, BorderRadius.circular(2.0f)},
{MaterialType.transparency, null}
};
}
public delegate Rect RectCallback();
public enum MaterialType {

ColorTween _shadowColor;
ShapeBorderTween _border;
protected override void forEachTween(ITweenVisitor visitor) {
protected override void forEachTween(TweenVisitor visitor) {
this._elevation = (FloatTween) visitor.visit(this, this._elevation, this.widget.elevation,
(float value) => new FloatTween(begin: value, end: value));
this._shadowColor = (ColorTween) visitor.visit(this, this._shadowColor, this.widget.shadowColor,

10
Runtime/material/scrollbar.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;

namespace Unity.UIWidgets.material {
static class ScrollbarUtils {
public static readonly TimeSpan _kScrollbarFadeDuration = TimeSpan.FromMilliseconds(300);
public static readonly TimeSpan _kScrollbarTimeToFade = TimeSpan.FromMilliseconds(600);
public const float _kScrollbarThickness = 6.0f;
}
public class Scrollbar : StatefulWidget {
public Scrollbar(
Key key = null,

3
Runtime/material/text_theme.cs


using System;
public class TextTheme : Diagnosticable {
public class TextTheme : Diagnosticable, IEquatable<TextTheme> {
public TextTheme(
TextStyle display4 = null,
TextStyle display3 = null,

6
Runtime/material/theme.cs


using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
static class ThemeUtils {
public static readonly TimeSpan kThemeAnimationDuration = new TimeSpan(0, 0, 0, 0, 200);
}
public class Theme : StatelessWidget {
public Theme(
Key key = null,

class _AnimatedThemeState : AnimatedWidgetBaseState<AnimatedTheme> {
ThemeDataTween _data;
protected override void forEachTween(ITweenVisitor visitor) {
protected override void forEachTween(TweenVisitor visitor) {
this._data = (ThemeDataTween) visitor.visit(this, this._data, this.widget.data,
(ThemeData value) => new ThemeDataTween(begin: value));
}

224
Runtime/material/theme_data.cs


using System;
using Unity.UIWidgets.ui;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
static class ThemeDataUtils {
public static readonly Color _kLightThemeHighlightColor = new Color(0x66BCBCBC);
public static readonly Color _kLightThemeSplashColor = new Color(0x66C8C8C8);
public static readonly Color _kDarkThemeHighlightColor = new Color(0x40CCCCCC);
public static readonly Color _kDarkThemeSplashColor = new Color(0x40CCCCCC);
}
public enum MaterialTapTargetSize {
padded,

public class ThemeData : Diagnosticable {
public class ThemeData : Diagnosticable, IEquatable<ThemeData> {
public ThemeData(
Brightness? brightness = null,
MaterialColor primarySwatch = null,

IconThemeData iconTheme = null,
IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
RuntimePlatform? platform = null,
PageTransitionsTheme pageTransitionsTheme = null,
DialogTheme dialogTheme = null,
Typography typography = null
) {
brightness = brightness ?? Brightness.light;

hintColor = hintColor ?? (isDark ? new Color(0x80FFFFFF) : new Color(0x8A000000));
errorColor = errorColor ?? Colors.red[700];
pageTransitionsTheme = pageTransitionsTheme ?? new PageTransitionsTheme();
primaryIconTheme = primaryIconTheme ??
(primaryIsDark
? new IconThemeData(color: Colors.white)

: new IconThemeData(color: Colors.black));
iconTheme = iconTheme ??
(isDark ? new IconThemeData(color: Colors.white) : new IconThemeData(color: Colors.black87));
platform = platform ?? Application.platform;
typography = typography ?? new Typography();
TextTheme defaultTextTheme = isDark ? typography.white : typography.black;
textTheme = defaultTextTheme.merge(textTheme);

(isDark
? ThemeDataUtils._kDarkThemeSplashColor
: ThemeDataUtils._kLightThemeSplashColor);
dialogTheme = dialogTheme ?? new DialogTheme();
D.assert(brightness != null);
D.assert(primaryColor != null);

D.assert(primaryIconTheme != null);
D.assert(accentIconTheme != null);
D.assert(materialTapTargetSize != null);
D.assert(pageTransitionsTheme != null);
D.assert(dialogTheme != null);
this.brightness = brightness ?? Brightness.light;
this.primaryColor = primaryColor;

this.iconTheme = iconTheme;
this.primaryIconTheme = primaryIconTheme;
this.accentIconTheme = accentIconTheme;
this.platform = platform.Value;
this.pageTransitionsTheme = pageTransitionsTheme;
this.dialogTheme = dialogTheme;
Brightness? brightness,
Color primaryColor,
Brightness? primaryColorBrightness,
Color primaryColorLight,
Color primaryColorDark,
Color canvasColor,
Color accentColor,
Brightness? accentColorBrightness,
Color scaffoldBackgroundColor,
Color bottomAppBarColor,
Color cardColor,
Color dividerColor,
Color highlightColor,
Color splashColor,
InteractiveInkFeatureFactory splashFactory,
Color selectedRowColor,
Color unselectedWidgetColor,
Color disabledColor,
ButtonThemeData buttonTheme,
Color buttonColor,
Color secondaryHeaderColor,
Color textSelectionColor,
Color cursorColor,
Color textSelectionHandleColor,
Color backgroundColor,
Color dialogBackgroundColor,
Color indicatorColor,
Color hintColor,
Color errorColor,
Color toggleableActiveColor,
TextTheme textTheme,
TextTheme primaryTextTheme,
TextTheme accentTextTheme,
IconThemeData iconTheme,
IconThemeData primaryIconTheme,
IconThemeData accentIconTheme,
MaterialTapTargetSize? materialTapTargetSize,
ColorScheme colorScheme,
Typography typography
Brightness? brightness = null,
Color primaryColor = null,
Brightness? primaryColorBrightness = null,
Color primaryColorLight = null,
Color primaryColorDark = null,
Color canvasColor = null,
Color accentColor = null,
Brightness? accentColorBrightness = null,
Color scaffoldBackgroundColor = null,
Color bottomAppBarColor = null,
Color cardColor = null,
Color dividerColor = null,
Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null,
Color selectedRowColor = null,
Color unselectedWidgetColor = null,
Color disabledColor = null,
ButtonThemeData buttonTheme = null,
Color buttonColor = null,
Color secondaryHeaderColor = null,
Color textSelectionColor = null,
Color cursorColor = null,
Color textSelectionHandleColor = null,
Color backgroundColor = null,
Color dialogBackgroundColor = null,
Color indicatorColor = null,
Color hintColor = null,
Color errorColor = null,
Color toggleableActiveColor = null,
TextTheme textTheme = null,
TextTheme primaryTextTheme = null,
TextTheme accentTextTheme = null,
IconThemeData iconTheme = null,
IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
PageTransitionsTheme pageTransitionsTheme = null,
ColorScheme colorScheme = null,
DialogTheme dialogTheme = null,
Typography typography = null
) {
D.assert(brightness != null);
D.assert(primaryColor != null);

D.assert(iconTheme != null);
D.assert(primaryIconTheme != null);
D.assert(accentIconTheme != null);
D.assert(platform != null);
D.assert(pageTransitionsTheme != null);
D.assert(dialogTheme != null);
return new ThemeData(
brightness: brightness,

iconTheme: iconTheme,
primaryIconTheme: primaryIconTheme,
accentIconTheme: accentIconTheme,
platform: platform,
pageTransitionsTheme: pageTransitionsTheme,
dialogTheme: dialogTheme,
typography: typography);
}

public readonly IconThemeData accentIconTheme;
public readonly RuntimePlatform platform;
public readonly PageTransitionsTheme pageTransitionsTheme;
public readonly DialogTheme dialogTheme;
Brightness? brightness,
Color primaryColor,
Brightness? primaryColorBrightness,
Color primaryColorLight,
Color primaryColorDark,
Color accentColor,
Brightness? accentColorBrightness,
Color canvasColor,
Color scaffoldBackgroundColor,
Color bottomAppBarColor,
Color cardColor,
Color dividerColor,
Color highlightColor,
Color splashColor,
InteractiveInkFeatureFactory splashFactory,
Color selectedRowColor,
Color unselectedWidgetColor,
Color disabledColor,
ButtonThemeData buttonTheme,
Color buttonColor,
Color secondaryHeaderColor,
Color textSelectionColor,
Color cursorColor,
Color textSelectionHandleColor,
Color backgroundColor,
Color dialogBackgroundColor,
Color indicatorColor,
Color hintColor,
Color errorColor,
Color toggleableActiveColor,
TextTheme textTheme,
TextTheme primaryTextTheme,
TextTheme accentTextTheme,
IconThemeData iconTheme,
IconThemeData primaryIconTheme,
IconThemeData accentIconTheme,
MaterialTapTargetSize? materialTapTargetSize,
ColorScheme colorScheme,
Typography typography
Brightness? brightness = null,
Color primaryColor = null,
Brightness? primaryColorBrightness = null,
Color primaryColorLight = null,
Color primaryColorDark = null,
Color accentColor = null,
Brightness? accentColorBrightness = null,
Color canvasColor = null,
Color scaffoldBackgroundColor = null,
Color bottomAppBarColor = null,
Color cardColor = null,
Color dividerColor = null,
Color highlightColor = null,
Color splashColor = null,
InteractiveInkFeatureFactory splashFactory = null,
Color selectedRowColor = null,
Color unselectedWidgetColor = null,
Color disabledColor = null,
ButtonThemeData buttonTheme = null,
Color buttonColor = null,
Color secondaryHeaderColor = null,
Color textSelectionColor = null,
Color cursorColor = null,
Color textSelectionHandleColor = null,
Color backgroundColor = null,
Color dialogBackgroundColor = null,
Color indicatorColor = null,
Color hintColor = null,
Color errorColor = null,
Color toggleableActiveColor = null,
TextTheme textTheme = null,
TextTheme primaryTextTheme = null,
TextTheme accentTextTheme = null,
IconThemeData iconTheme = null,
IconThemeData primaryIconTheme = null,
IconThemeData accentIconTheme = null,
RuntimePlatform? platform = null,
MaterialTapTargetSize? materialTapTargetSize = null,
PageTransitionsTheme pageTransitionsTheme = null,
ColorScheme colorScheme = null,
DialogTheme dialogTheme = null,
Typography typography = null
) {
return raw(
brightness: brightness ?? this.brightness,

iconTheme: iconTheme ?? this.iconTheme,
primaryIconTheme: primaryIconTheme ?? this.primaryIconTheme,
accentIconTheme: accentIconTheme ?? this.accentIconTheme,
platform: platform ?? this.platform,
pageTransitionsTheme: pageTransitionsTheme ?? this.pageTransitionsTheme,
dialogTheme: dialogTheme ?? this.dialogTheme,
public static Brightness estimateBrightnessForColor(Color color) {
float relativeLuminance = color.computeLuminance();

iconTheme: IconThemeData.lerp(a.iconTheme, b.iconTheme, t),
primaryIconTheme: IconThemeData.lerp(a.primaryIconTheme, b.primaryIconTheme, t),
accentIconTheme: IconThemeData.lerp(a.accentIconTheme, b.accentIconTheme, t),
platform: t < 0.5 ? a.platform : b.platform,
pageTransitionsTheme: t < 0.5 ? a.pageTransitionsTheme : b.pageTransitionsTheme,
dialogTheme: DialogTheme.lerp(a.dialogTheme, b.dialogTheme, t),
typography: Typography.lerp(a.typography, b.typography, t)
);
}

other.iconTheme == this.iconTheme &&
other.primaryIconTheme == this.primaryIconTheme &&
other.accentIconTheme == this.accentIconTheme &&
other.platform == this.platform &&
other.pageTransitionsTheme == this.pageTransitionsTheme &&
other.dialogTheme == this.dialogTheme &&
other.typography == this.typography;
}

hashCode = (hashCode * 397) ^ this.iconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.primaryIconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.accentIconTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.platform.GetHashCode();
hashCode = (hashCode * 397) ^ this.pageTransitionsTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.dialogTheme.GetHashCode();
hashCode = (hashCode * 397) ^ this.typography.GetHashCode();
return hashCode;
}

base.debugFillProperties(properties);
ThemeData defaultData = fallback();
properties.add(new EnumProperty<RuntimePlatform>("platform", this.platform,
defaultValue: Application.platform));
properties.add(new EnumProperty<Brightness>("brightness", this.brightness,
defaultValue: defaultData.brightness));
properties.add(new DiagnosticsProperty<Color>("primaryColor", this.primaryColor,

properties.add(new DiagnosticsProperty<IconThemeData>("accentIconTheme", this.accentIconTheme));
properties.add(
new DiagnosticsProperty<MaterialTapTargetSize>("materialTapTargetSize", this.materialTapTargetSize));
properties.add(
new DiagnosticsProperty<PageTransitionsTheme>("pageTransitionsTheme", this.pageTransitionsTheme));
properties.add(new DiagnosticsProperty<DialogTheme>("dialogTheme", this.dialogTheme,
defaultValue: defaultData.dialogTheme));
properties.add(new DiagnosticsProperty<Typography>("typography", this.typography,
defaultValue: defaultData.typography));
}

7
Runtime/material/tooltip.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async;
using Unity.UIWidgets.foundation;

using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
static class TooltipUtils {
public static readonly TimeSpan _kFadeDuration = new TimeSpan(0, 0, 0, 0, 200);
public static readonly TimeSpan _kShowDuration = new TimeSpan(0, 0, 0, 0, 1500);
}
public class Tooltip : StatefulWidget {
public Tooltip(
Key key = null,

1
Runtime/painting/image_resolution.cs


public readonly string assetName;
public readonly AssetBundle bundle;
protected override
IPromise<AssetBundleImageKey> obtainKey(ImageConfiguration configuration) {
AssetImageConfiguration assetConfig = new AssetImageConfiguration(configuration, this.assetName);

7
Runtime/promise/Promise_NonGeneric.cs


promise.Reject(ex);
return promise;
}
public static IPromise Delayed(TimeSpan duration) {
var promise = new Promise();
Window.instance.run(duration, () => { promise.Resolve(); });
return promise;
}
public IPromise Finally(Action onComplete) {
var promise = new Promise(isSync: true);

3
Runtime/rendering/binding.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.rendering {

}
protected virtual void drawFrame() {
PerformanceUtils.instance.startProfile();
PerformanceUtils.instance.endProfile();
}
public override void hitTest(HitTestResult result, Offset position) {

8
Runtime/rendering/box.cs


// ideographic baseline
float? baselineI = this.getDistanceToBaseline(TextBaseline.ideographic, onlyReal: true);
if (baselineI != null) {
paint.color = new Color(0xFFFFD000);
paint.color = new Color(0xFFFFD000);
path = new Path();
path.moveTo(offset.dx, offset.dy + baselineI.Value);
path.lineTo(offset.dx + this.size.width, offset.dy + baselineI.Value);

// alphabetic baseline
float? baselineA = this.getDistanceToBaseline(TextBaseline.alphabetic, onlyReal: true);
if (baselineA != null) {
paint.color = new Color (0xFF00FF00);
paint.color = new Color(0xFF00FF00);
path = new Path();
path.moveTo(offset.dx, offset.dy + baselineA.Value);
path.lineTo(offset.dx + this.size.width, offset.dy + baselineA.Value);

base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Size>("size", this._size, missingIfNull: true));
}
}
public abstract class ContainerBoxParentData<ChildType> : ContainerParentDataMixinBoxParentData<ChildType>
where ChildType : RenderBox {
}
public abstract class

18
Runtime/rendering/box.mixin.gen.cs


using System;
using UnityEngine;
using UnityEngine;
public float? defaultComputeDistanceToFirstActualBaseline(TextBaseline baseline) {
var child = this.firstChild;
while (child != null) {

candidate += childParentData.offset.dy;
if (result != null) {
result = Mathf.Min(result.Value, candidate.Value);
}
else {
} else {
result = candidate;
}
}

}
}
public bool defaultHitTestChildren(HitTestResult result, Offset position) {
public bool defaultHitTestChildren(HitTestResult result, Offset position) {
while (child != null) {
while (child != null)
{
return false;
}

return result;
}
}
}

68
Runtime/rendering/layer.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public abstract class Layer : AbstractNodeMixinDiagnosticableTree {

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Rect>("paint bounds", this.canvasBounds));
}
}
public class TextureLayer : Layer {
public TextureLayer(
Rect rect,
Texture texture,
bool freeze = false
) {
D.assert(rect != null);
D.assert(texture != null);
this.rect = rect;
this.texture = texture;
this.freeze = freeze;
}
public readonly Rect rect;
public readonly Texture texture;
public readonly bool freeze;
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
Rect shiftedRect = this.rect.shift(layerOffset);
builder.addTexture(
this.texture,
offset: shiftedRect.topLeft,
width: shiftedRect.width,
height: shiftedRect.height,
freeze: this.freeze
);
return null;
}
}

properties.add(new DiagnosticsProperty<LayerLink>("link", this.link));
properties.add(new TransformProperty("transform", this.getLastTransform(),
defaultValue: Diagnostics.kNullDefaultValue));
}
}
public class PerformanceOverlayLayer : Layer {
public PerformanceOverlayLayer(
Rect overlayRect = null,
int? optionsMask = null
) {
D.assert(overlayRect != null);
D.assert(optionsMask != null);
this._overlayRect = overlayRect;
this.optionsMask = optionsMask ?? 0;
}
public Rect overlayRect {
get { return this._overlayRect; }
set {
if (value != this._overlayRect) {
this._overlayRect = value;
this.markNeedsAddToScene();
}
}
}
Rect _overlayRect;
public readonly int optionsMask;
internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
builder.addPerformanceOverlay(this.optionsMask, this.overlayRect.shift(layerOffset));
return null;
}
}
}

88
Runtime/rendering/object.mixin.gen.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using UnityEngine;
public abstract class RenderObjectWithChildMixinRenderObject<ChildType> : RenderObject,
RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public abstract class RenderObjectWithChildMixinRenderObject<ChildType> : RenderObject, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {

public override List<DiagnosticsNode> debugDescribeChildren() {
return this.child != null
? new List<DiagnosticsNode> {this.child.toDiagnosticsNode(name: "child")}
? new List<DiagnosticsNode>{this.child.toDiagnosticsNode(name: "child")}
public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox,
RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public abstract class RenderObjectWithChildMixinRenderBox<ChildType> : RenderBox, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {

public override List<DiagnosticsNode> debugDescribeChildren() {
return this.child != null
? new List<DiagnosticsNode> {this.child.toDiagnosticsNode(name: "child")}
? new List<DiagnosticsNode>{this.child.toDiagnosticsNode(name: "child")}
public abstract class RenderObjectWithChildMixinRenderSliver<ChildType> : RenderSliver,
RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public abstract class RenderObjectWithChildMixinRenderSliver<ChildType> : RenderSliver, RenderObjectWithChildMixin<ChildType>, RenderObjectWithChildMixin where ChildType : RenderObject {
public bool debugValidateChild(RenderObject child) {
D.assert(() => {
if (!(child is ChildType)) {

public override List<DiagnosticsNode> debugDescribeChildren() {
return this.child != null
? new List<DiagnosticsNode> {this.child.toDiagnosticsNode(name: "child")}
? new List<DiagnosticsNode>{this.child.toDiagnosticsNode(name: "child")}
public abstract class ContainerParentDataMixinParentData<ChildType> : ParentData,
ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public abstract class ContainerParentDataMixinParentData<ChildType> : ParentData, ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public ChildType previousSibling { get; set; }
public ChildType nextSibling { get; set; }

}
public abstract class ContainerParentDataMixinBoxParentData<ChildType> : BoxParentData,
ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public abstract class ContainerParentDataMixinBoxParentData<ChildType> : BoxParentData, ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public ChildType previousSibling { get; set; }
public ChildType nextSibling { get; set; }

}
public abstract class ContainerParentDataMixinSliverPhysicalParentData<ChildType> : SliverPhysicalParentData,
ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public abstract class ContainerParentDataMixinSliverPhysicalParentData<ChildType> : SliverPhysicalParentData, ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public ChildType previousSibling { get; set; }
public ChildType nextSibling { get; set; }

}
public abstract class ContainerParentDataMixinSliverLogicalParentData<ChildType> : SliverLogicalParentData,
ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public abstract class ContainerParentDataMixinSliverLogicalParentData<ChildType> : SliverLogicalParentData, ContainerParentDataMixin<ChildType> where ChildType : RenderObject {
public ChildType previousSibling { get; set; }
public ChildType nextSibling { get; set; }

}
public abstract class ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType> : RenderBox,
ContainerRenderObjectMixin
public abstract class ContainerRenderObjectMixinRenderBox<ChildType, ParentDataType> : RenderBox, ContainerRenderObjectMixin
bool _debugUltimatePreviousSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.previousSibling != null) {

this._firstChild = child;
this._lastChild = this._lastChild ?? child;
}
else {
} else {
D.assert(this._firstChild != null);
D.assert(this._lastChild != null);
D.assert(this._debugUltimatePreviousSiblingOf(after, equals: this._firstChild));

childParentData.previousSibling = after;
afterParentData.nextSibling = child;
this._lastChild = child;
}
else {
} else {
childParentData.nextSibling = afterParentData.nextSibling;
childParentData.previousSibling = after;
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;

if (childParentData.previousSibling == null) {
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
}
else {
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;
childPreviousSiblingParentData.nextSibling = childParentData.nextSibling;
}

this._lastChild = childParentData.previousSibling;
}
else {
} else {
var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childNextSiblingParentData.previousSibling = childParentData.previousSibling;
}

}
public abstract class ContainerRenderObjectMixinRenderSliver<ChildType, ParentDataType> : RenderSliver,
ContainerRenderObjectMixin
public abstract class ContainerRenderObjectMixinRenderSliver<ChildType, ParentDataType> : RenderSliver, ContainerRenderObjectMixin
bool _debugUltimatePreviousSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.previousSibling != null) {

this._firstChild = child;
this._lastChild = this._lastChild ?? child;
}
else {
} else {
D.assert(this._firstChild != null);
D.assert(this._lastChild != null);
D.assert(this._debugUltimatePreviousSiblingOf(after, equals: this._firstChild));

childParentData.previousSibling = after;
afterParentData.nextSibling = child;
this._lastChild = child;
}
else {
} else {
childParentData.nextSibling = afterParentData.nextSibling;
childParentData.previousSibling = after;
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;

if (childParentData.previousSibling == null) {
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
}
else {
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;
childPreviousSiblingParentData.nextSibling = childParentData.nextSibling;
}

this._lastChild = childParentData.previousSibling;
}
else {
} else {
var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childNextSiblingParentData.previousSibling = childParentData.previousSibling;
}

}
public abstract class
ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<ChildType,
ParentDataType> : RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack,
ContainerRenderObjectMixin
public abstract class ContainerRenderObjectMixinRenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack<ChildType, ParentDataType> : RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack, ContainerRenderObjectMixin
bool _debugUltimatePreviousSiblingOf(ChildType child, ChildType equals = null) {
ParentDataType childParentData = (ParentDataType) child.parentData;
while (childParentData.previousSibling != null) {

this._firstChild = child;
this._lastChild = this._lastChild ?? child;
}
else {
} else {
D.assert(this._firstChild != null);
D.assert(this._lastChild != null);
D.assert(this._debugUltimatePreviousSiblingOf(after, equals: this._firstChild));

childParentData.previousSibling = after;
afterParentData.nextSibling = child;
this._lastChild = child;
}
else {
} else {
childParentData.nextSibling = afterParentData.nextSibling;
childParentData.previousSibling = after;
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;

if (childParentData.previousSibling == null) {
D.assert(this._firstChild == child);
this._firstChild = childParentData.nextSibling;
}
else {
} else {
var childPreviousSiblingParentData = (ParentDataType) childParentData.previousSibling.parentData;
childPreviousSiblingParentData.nextSibling = childParentData.nextSibling;
}

this._lastChild = childParentData.previousSibling;
}
else {
} else {
var childNextSiblingParentData = (ParentDataType) childParentData.nextSibling.parentData;
childNextSiblingParentData.previousSibling = childParentData.previousSibling;
}

return this.childAfter((ChildType) child);
}
}
}

157
Runtime/rendering/proxy_box.cs


}
}
public class RenderIntrinsicWidth : RenderProxyBox {
public RenderIntrinsicWidth(
float? stepWidth = null,
float? stepHeight = null,
RenderBox child = null
) : base(child) {
this._stepWidth = stepWidth;
this._stepHeight = stepHeight;
}
float? _stepWidth;
public float? stepWidth {
get { return this._stepWidth; }
set {
if (value == this._stepWidth) {
return;
}
this._stepWidth = value;
this.markNeedsLayout();
}
}
float? _stepHeight;
public float? stepHeight {
get { return this._stepHeight; }
set {
if (value == this._stepHeight) {
return;
}
this._stepHeight = value;
this.markNeedsLayout();
}
}
static float _applyStep(float input, float? step) {
D.assert(input.isFinite());
if (step == null) {
return input;
}
return (input / step.Value).ceil() * step.Value;
}
protected override float computeMinIntrinsicWidth(float height) {
return this.computeMaxIntrinsicWidth(height);
}
protected override float computeMaxIntrinsicWidth(float height) {
if (this.child == null) {
return 0.0f;
}
float width = this.child.getMaxIntrinsicWidth(height);
return _applyStep(width, this._stepWidth);
}
protected override float computeMinIntrinsicHeight(float width) {
if (this.child == null) {
return 0.0f;
}
if (!width.isFinite()) {
width = this.computeMaxIntrinsicWidth(float.PositiveInfinity);
}
D.assert(width.isFinite());
float height = this.child.getMinIntrinsicHeight(width);
return _applyStep(height, this._stepHeight);
}
protected override float computeMaxIntrinsicHeight(float width) {
if (this.child == null) {
return 0.0f;
}
if (!width.isFinite()) {
width = this.computeMaxIntrinsicWidth(float.PositiveInfinity);
}
D.assert(width.isFinite());
float height = this.child.getMaxIntrinsicHeight(width);
return _applyStep(height, this._stepHeight);
}
protected override void performLayout() {
if (this.child != null) {
BoxConstraints childConstraints = this.constraints;
if (!childConstraints.hasTightWidth) {
float width = this.child.getMaxIntrinsicWidth(childConstraints.maxHeight);
D.assert(width.isFinite());
childConstraints = childConstraints.tighten(width: _applyStep(width, this._stepWidth));
}
if (this._stepHeight != null) {
float height = this.child.getMaxIntrinsicHeight(childConstraints.maxWidth);
D.assert(height.isFinite());
childConstraints = childConstraints.tighten(height: _applyStep(height, this._stepHeight));
}
this.child.layout(childConstraints, parentUsesSize: true);
this.size = this.child.size;
} else {
this.performResize();
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("stepWidth", this.stepWidth));
properties.add(new FloatProperty("stepHeight", this.stepHeight));
}
}
public class RenderIntrinsicHeight : RenderProxyBox {
public RenderIntrinsicHeight(
RenderBox child = null
) : base(child) {
}
protected override float computeMinIntrinsicWidth(float height) {
if (this.child == null) {
return 0.0f;
}
if (!height.isFinite()) {
height = this.child.getMaxIntrinsicHeight(float.PositiveInfinity);
}
D.assert(height.isFinite());
return this.child.getMinIntrinsicWidth(height);
}
protected override float computeMaxIntrinsicWidth(float height) {
if (this.child == null) {
return 0.0f;
}
if (!height.isFinite()) {
height = this.child.getMaxIntrinsicHeight(float.PositiveInfinity);
}
D.assert(height.isFinite());
return this.child.getMaxIntrinsicWidth(height);
}
protected override float computeMinIntrinsicHeight(float width) {
return this.computeMaxIntrinsicHeight(width);
}
protected override void performLayout() {
if (this.child != null) {
BoxConstraints childConstraints = this.constraints;
if (!childConstraints.hasTightHeight) {
float height = this.child.getMaxIntrinsicHeight(childConstraints.maxWidth);
D.assert(height.isFinite());
childConstraints = childConstraints.tighten(height: height);
}
this.child.layout(childConstraints, parentUsesSize: true);
this.size = this.child.size;
} else {
this.performResize();
}
}
}
public class RenderOpacity : RenderProxyBox {
public RenderOpacity(float opacity = 1.0f, RenderBox child = null) : base(child) {
D.assert(opacity >= 0.0 && opacity <= 1.0);

public abstract T getClip(Size size);
public Rect getApproximateClipRect(Size size) {
public virtual Rect getApproximateClipRect(Size size) {
return Offset.zero & size;
}

20
Runtime/rendering/proxy_box.mixin.gen.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.gestures;
using UnityEngine;
public abstract class
RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<T> : RenderObjectWithChildMixinRenderBox<T>
where T : RenderBox {
public abstract class RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<T> : RenderObjectWithChildMixinRenderBox<T> where T : RenderBox {
public override void setupParentData(RenderObject child) {
if (!(child.parentData is ParentData)) {
child.parentData = new ParentData();

if (this.child != null) {
this.child.layout(this.constraints, parentUsesSize: true);
this.size = this.child.size;
}
else {
} else {
this.performResize();
}
}

}
public abstract class RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack :
public abstract class RenderProxyBoxMixinRenderObjectWithChildMixinRenderBoxRenderStack:
}
}

27
Runtime/scheduler/binding.cs


return true;
});
this.debugStack = debugCurrentCallbackStack;
}
else {
} else {
this.debugStack = new StackTrace(2, true);
}

public class SchedulerBinding {
public static SchedulerBinding instance {
get {
D.assert(_instance != null, "Binding.instance is null");
D.assert(_instance != null,
"Binding.instance is null. " +
"This usually happens when there is a callback from outside of UIWidgets. " +
"Try to use \"using (WindowProvider.of(BuildContext).getScope()) { ... }\" to wrap your code.");
return _instance;
}

_instance = null;
}
else {
} else {
D.assert(_instance == null, "Binding.instance is already assigned.");
_instance = value;
}

static SchedulerBinding _instance;
internal static SchedulerBinding _instance;
public SchedulerBinding() {
Window.instance.onBeginFrame += this._handleBeginFrame;

if (rawTimeStamp != null) {
_debugDescribeTimeStamp(
this._currentFrameTimeStamp.Value, frameTimeStampDescription);
}
else {
} else {
frameTimeStampDescription.Append("(warm-up frame)");
}

}
this._removedIds.Clear();
}
finally {
} finally {
this._schedulerPhase = SchedulerPhase.midFrameMicrotasks;
}
}

foreach (FrameCallback callback in localPostFrameCallbacks) {
this._invokeFrameCallback(callback, this._currentFrameTimeStamp.Value);
}
}
finally {
} finally {
this._schedulerPhase = SchedulerPhase.idle;
D.assert(() => {
if (D.debugPrintEndFrameBanner) {

try {
callback(timeStamp);
}
catch (Exception ex) {
} catch (Exception ex) {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
exception: ex,
library: "scheduler library",

});
}
}
}
}

36
Runtime/ui/compositing.cs


using System;
using System;
using UnityEngine;
namespace Unity.UIWidgets.ui {
public class SceneBuilder {

layer.picture = picture;
layer.isComplex = isComplexHint;
layer.willChange = willChangeHint;
this._currentLayer.add(layer);
}
public void addTexture(
Texture texture,
Offset offset,
float width,
float height,
bool freeze) {
if (this._currentLayer == null) {
return;
}
var layer = new TextureLayer();
layer.offset = offset;
layer.size = new Size(width, height);
layer.texture = texture;
layer.freeze = freeze;
this._currentLayer.add(layer);
}
public void addPerformanceOverlay(int enabledOptions, Rect bounds) {
if (this._currentLayer == null) {
return;
}
var layer = new PerformanceOverlayLayer(enabledOptions);
layer.paintBounds = Rect.fromLTRB(
bounds.left,
bounds.top,
bounds.right,
bounds.bottom
);
this._currentLayer.add(layer);
}
}

4
Runtime/ui/geometry.cs


return value;
}
public static int abs(this int value) {
return Mathf.Abs(value);
}
public static float abs(this float value) {
return Mathf.Abs(value);
}

39
Runtime/ui/painting/canvas.cs


using System;
using UnityEngine;
using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.ui {
public interface Canvas {

void drawTextBlob(TextBlob textBlob, Offset offset, Paint paint);
void drawParagraph(Paragraph paragraph, Offset offset);
void flush();
void reset();

public void drawArc(Rect rect, float startAngle, float sweepAngle, bool useCenter, Paint paint) {
var path = new Path();
//path.(c.dx, c.dy, radius);
if (useCenter) {
var center = rect.center;
path.moveTo(center.dx, center.dy);
}
bool forceMoveTo = !useCenter;
while (sweepAngle <= -Mathf.PI * 2) {
path.addArc(rect, startAngle, -Mathf.PI, forceMoveTo);
startAngle -= Mathf.PI;
path.addArc(rect, startAngle, -Mathf.PI, false);
startAngle -= Mathf.PI;
forceMoveTo = false;
sweepAngle += Mathf.PI * 2;
}
while (sweepAngle >= Mathf.PI * 2) {
path.addArc(rect, startAngle, Mathf.PI, forceMoveTo);
startAngle += Mathf.PI;
path.addArc(rect, startAngle, Mathf.PI, false);
startAngle += Mathf.PI;
forceMoveTo = false;
sweepAngle -= Mathf.PI * 2;
}
path.addArc(rect, startAngle, sweepAngle, forceMoveTo);
if (useCenter) {
path.close();
}
this._recorder.addDrawCmd(new DrawPath {
path = path,

offset = offset,
paint = new Paint(paint),
});
}
public void drawParagraph(Paragraph paragraph, Offset offset) {
D.assert(paragraph != null);
D.assert(PaintingUtils._offsetIsValid(offset));
paragraph.paint(this, offset);
}
public virtual void flush() {

6
Runtime/ui/painting/canvas_impl.cs


}
bool _applyClip(Rect queryBounds) {
if (queryBounds == null || queryBounds.isEmpty) {
return false;
}
var layer = this._currentLayer;
var layerBounds = layer.layerBounds;
ReducedClip reducedClip = new ReducedClip(layer.clipStack, layerBounds, queryBounds);

continue;
}
D.assert(mesh.vertices.Count > 0);
cmd.meshObj.SetVertices(mesh.vertices);
cmd.meshObj.SetTriangles(mesh.triangles, 0, false);
cmd.meshObj.SetUVs(0, mesh.uv);

170
Runtime/ui/painting/path.cs


this.addEllipse(center.dx, center.dy, oval.width / 2, oval.height / 2);
}
public void arcTo(float x1, float y1, float x2, float y2, float radius) {
var x0 = this._commandx;
var y0 = this._commandy;
// Calculate tangential circle to lines (x0,y0)-(x1,y1) and (x1,y1)-(x2,y2).
float dx0 = x0 - x1;
float dy0 = y0 - y1;
float dx1 = x2 - x1;
float dy1 = y2 - y1;
PathUtils.normalize(ref dx0, ref dy0);
PathUtils.normalize(ref dx1, ref dy1);
float a = Mathf.Acos(dx0 * dx1 + dy0 * dy1);
float d = radius / Mathf.Tan(a / 2.0f);
if (d > 10000.0f) {
this.lineTo(x1, y1);
return;
}
float cx, cy, a0, a1;
PathWinding dir;
float cross = dx1 * dy0 - dx0 * dy1;
if (cross > 0.0f) {
cx = x1 + dx0 * d + dy0 * radius;
cy = y1 + dy0 * d + -dx0 * radius;
a0 = Mathf.Atan2(dx0, -dy0);
a1 = Mathf.Atan2(-dx1, dy1);
dir = PathWinding.clockwise;
} else {
cx = x1 + dx0 * d + -dy0 * radius;
cy = y1 + dy0 * d + dx0 * radius;
a0 = Mathf.Atan2(-dx0, dy0);
a1 = Mathf.Atan2(dx1, -dy1);
dir = PathWinding.counterClockwise;
}
this.addArc(cx, cy, radius, a0, a1, dir);
}
public void addArc(Rect rect, float startAngle, float sweepAngle, bool forceMoveTo = true) {
var mat = Matrix3.makeScale(rect.width / 2, rect.height / 2);
var center = rect.center;
mat.postTranslate(center.dx, center.dy);
var vals = this._getArcCommands(0, 0, 1, startAngle, startAngle + sweepAngle,
sweepAngle >= 0 ? PathWinding.clockwise : PathWinding.counterClockwise, forceMoveTo);
this._transformCommands(vals, mat);
this._appendCommands(vals.ToArray());
}
void _transformCommands(List<float> commands, Matrix3 mat) {
if (mat == null) {
return;
}
var i = 0;
while (i < commands.Count) {
var cmd = (PathCommand) commands[i];
switch (cmd) {
case PathCommand.moveTo:
case PathCommand.lineTo:
var res = mat.mapXY(commands[i + 1], commands[i + 2]);
commands[i + 1] = res.dx;
commands[i + 2] = res.dy;
i += 3;
break;
case PathCommand.bezierTo:
var res1 = mat.mapXY(commands[i + 1], commands[i + 2]);
commands[i + 1] = res1.dx;
commands[i + 2] = res1.dy;
var res2 = mat.mapXY(commands[i + 3], commands[i + 4]);
commands[i + 3] = res2.dx;
commands[i + 4] = res2.dy;
var res3 = mat.mapXY(commands[i + 5], commands[i + 6]);
commands[i + 5] = res3.dx;
commands[i + 6] = res3.dy;
i += 7;
break;
case PathCommand.close:
i++;
break;
case PathCommand.winding:
i += 2;
break;
default:
D.assert(false, "unknown cmd: " + cmd);
break;
}
}
}
List<float> _getArcCommands(float cx, float cy, float r, float a0, float a1, PathWinding dir, bool forceMoveTo) {
// Clamp angles
float da = a1 - a0;
if (dir == PathWinding.clockwise) {
if (Mathf.Abs(da) >= Mathf.PI * 2) {
da = Mathf.PI * 2;
} else {
while (da < 0.0f) {
da += Mathf.PI * 2;
}
if (da <= 1e-5) {
return new List<float>();
}
}
} else {
if (Mathf.Abs(da) >= Mathf.PI * 2) {
da = -Mathf.PI * 2;
} else {
while (da > 0.0f) {
da -= Mathf.PI * 2;
}
if (da >= -1e-5) {
return new List<float>();
}
}
}
// Split arc into max 90 degree segments.
int ndivs = Mathf.Max(1, Mathf.Min((int) (Mathf.Abs(da) / (Mathf.PI * 0.5f) + 0.5f), 5));
float hda = (da / ndivs) / 2.0f;
float kappa = Mathf.Abs(4.0f / 3.0f * (1.0f - Mathf.Cos(hda)) / Mathf.Sin(hda));
if (dir == PathWinding.counterClockwise) {
kappa = -kappa;
}
PathCommand move = (forceMoveTo || this._commands.Count == 0) ? PathCommand.moveTo : PathCommand.lineTo;
float px = 0, py = 0, ptanx = 0, ptany = 0;
List<float> vals = new List<float>();
for (int i = 0; i <= ndivs; i++) {
float a = a0 + da * (i / (float) ndivs);
float dx = Mathf.Cos(a);
float dy = Mathf.Sin(a);
float x = cx + dx * r;
float y = cy + dy * r;
float tanx = -dy * r * kappa;
float tany = dx * r * kappa;
if (i == 0) {
vals.Add((float) move);
vals.Add(x);
vals.Add(y);
} else {
vals.Add((float) PathCommand.bezierTo);
vals.Add(px + ptanx);
vals.Add(py + ptany);
vals.Add(x - tanx);
vals.Add(y - tany);
vals.Add(x);
vals.Add(y);
}
px = x;
py = y;
ptanx = tanx;
ptany = tany;
}
return vals;
}
public void addArc(float cx, float cy, float r, float a0, float a1, PathWinding dir, bool forceMoveTo = true) {
var vals = this._getArcCommands(cx, cy, r, a0, a1, dir, forceMoveTo);
this._appendCommands(vals.ToArray());
}
public void addPolygon(IList<Offset> points, bool close) {
D.assert(points != null);
if (points.Count == 0) {

}
var points = TessellationGenerator.tessellateBezier(x1, y1, x2, y2, x3, y3, x4, y4, this._tessTol);
D.assert(points.Count > 0);
points[points.Count - 1].flags = flags;
foreach (var point in points) {
this._addPoint(point);

16
Runtime/ui/window.cs


public abstract class Window {
public static Window instance {
get {
D.assert(_instance != null, "Window.instance is null");
D.assert(_instance != null,
"Window.instance is null. " +
"This usually happens when there is a callback from outside of UIWidgets. " +
"Try to use \"using (WindowProvider.of(BuildContext).getScope()) { ... }\" to wrap your code.");
return _instance;
}

_instance = null;
}
else {
} else {
D.assert(_instance == null, "Window.instance is already assigned.");
_instance = value;
}

get { return _instance != null; }
}
static Window _instance;
internal static Window _instance;
public float devicePixelRatio {
get { return this._devicePixelRatio; }

public abstract void scheduleFrame(bool regenerateLayerTree = true);
public void textureFrameAvailable() {
this.scheduleFrame(false);
}
public abstract void render(Scene scene);
public abstract void scheduleMicrotask(Action callback);

public abstract IDisposable getScope();
}
}
}

23
Runtime/widgets/app.cs


public readonly Dictionary<string, WidgetBuilder> routes;
public readonly TextStyle textStyle;
public readonly Window window;
public readonly bool showPerformanceoverlay;
public WidgetsApp(
Key key = null,

Dictionary<string, WidgetBuilder> routes = null,
TransitionBuilder builder = null,
TextStyle textStyle = null,
Widget home = null
Widget home = null,
bool showPerformanceOverlay = false
) : base(key) {
routes = routes ?? new Dictionary<string, WidgetBuilder>();
this.window = Window.instance;

this.initialRoute = initialRoute;
this.builder = builder;
this.textStyle = textStyle;
this.showPerformanceoverlay = showPerformanceOverlay;
D.assert(
home == null ||

var name = settings.name;
var pageContentBuilder = name == Navigator.defaultRouteName && this.widget.home != null
? context => this.widget.home
: this.widget.routes[name];
: this.widget.routes.getOrDefault(name);
if (pageContentBuilder != null) {
D.assert(this.widget.pageRouteBuilder != null,

style: this.widget.textStyle,
child: result
);
}
PerformanceOverlay performanceOverlay = null;
if (this.widget.showPerformanceoverlay) {
performanceOverlay = PerformanceOverlay.allEnabled();
}
if (performanceOverlay != null) {
result = new Stack(
children: new List<Widget> {
result,
new Positioned(top: 0.0f,
left: 0.0f,
right: 0.0f,
child: performanceOverlay)
});
}
D.assert(() => {

117
Runtime/widgets/automatic_keep_alive.cs


}
}
// There is a copy of the implementation of this mixin
// in AutomaticKeepAliveClientWithTickerProviderStateMixin, remember to keep the copy up to date
KeepAliveHandle _keepAliveHandle;
void _ensureKeepAlive() {
D.assert(this._keepAliveHandle == null);
this._keepAliveHandle = new KeepAliveHandle();
new KeepAliveNotification(this._keepAliveHandle).dispatch(this.context);
}
void _releaseKeepAlive() {
this._keepAliveHandle.release();
this._keepAliveHandle = null;
}
protected abstract bool wantKeepAlive { get; }
protected void updateKeepAlive() {
if (this.wantKeepAlive) {
if (this._keepAliveHandle == null) {
this._ensureKeepAlive();
}
}
else {
if (this._keepAliveHandle != null) {
this._releaseKeepAlive();
}
}
}
public override void initState() {
base.initState();
if (this.wantKeepAlive) {
this._ensureKeepAlive();
}
}
public override void deactivate() {
if (this._keepAliveHandle != null) {
this._releaseKeepAlive();
}
base.deactivate();
}
public override Widget build(BuildContext context) {
if (this.wantKeepAlive && this._keepAliveHandle == null) {
this._ensureKeepAlive();
}
return null;
}
}
public abstract class AutomaticKeepAliveClientWithTickerProviderStateMixin<T> : State<T>, TickerProvider
where T : StatefulWidget {
HashSet<Ticker> _tickers;
public Ticker createTicker(TickerCallback onTick) {
this._tickers = this._tickers ?? new HashSet<Ticker>();
var result = new _AutomaticWidgetTicker<T>(onTick, this, debugLabel: "created by " + this);
this._tickers.Add(result);
return result;
}
internal void _removeTicker(_AutomaticWidgetTicker<T> ticker) {
D.assert(this._tickers != null);
D.assert(this._tickers.Contains(ticker));
this._tickers.Remove(ticker);
}
public override void dispose() {
D.assert(() => {
if (this._tickers != null) {
foreach (Ticker ticker in this._tickers) {
if (ticker.isActive) {
throw new UIWidgetsError(
this + " was disposed with an active Ticker.\n" +
this.GetType() +
" created a Ticker via its TickerProviderStateMixin, but at the time " +
"dispose() was called on the mixin, that Ticker was still active. All Tickers must " +
"be disposed before calling super.dispose(). Tickers used by AnimationControllers " +
"should be disposed by calling dispose() on the AnimationController itself. " +
"Otherwise, the ticker will leak.\n" +
"The offending ticker was: " + ticker.toString(debugIncludeStack: true)
);
}
}
}
return true;
});
base.dispose();
}
public override void didChangeDependencies() {
bool muted = !TickerMode.of(this.context);
if (this._tickers != null) {
foreach (Ticker ticker in this._tickers) {
ticker.muted = muted;
}
}
base.didChangeDependencies();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<HashSet<Ticker>>(
"tickers",
this._tickers,
description: this._tickers != null ? "tracking " + this._tickers.Count + " tickers" : null,
defaultValue: Diagnostics.kNullDefaultValue
));
}
KeepAliveHandle _keepAliveHandle;
void _ensureKeepAlive() {

179
Runtime/widgets/basic.cs


}
}
public class IntrinsicWidth : SingleChildRenderObjectWidget {
public IntrinsicWidth(Key key = null, float? stepWidth = null, float? stepHeight = null, Widget child = null)
: base(key: key, child: child) {
this.stepWidth = stepWidth;
this.stepHeight = stepHeight;
}
public readonly float? stepWidth;
public readonly float? stepHeight;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderIntrinsicWidth(stepWidth: this.stepWidth, stepHeight: this.stepHeight);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObjectRaw) {
var renderObject = (RenderIntrinsicWidth) renderObjectRaw;
renderObject.stepWidth = this.stepWidth;
renderObject.stepHeight = this.stepHeight;
}
}
public class IntrinsicHeight : SingleChildRenderObjectWidget {
public IntrinsicHeight(Key key = null, Widget child = null)
: base(key: key, child: child) {
}
public override RenderObject createRenderObject(BuildContext context) {
return new RenderIntrinsicHeight();
}
}
public class Baseline : SingleChildRenderObjectWidget {
public Baseline(
Key key = null,
float? baseline = null,
TextBaseline? baselineType = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(baseline != null);
D.assert(baselineType != null);
this.baseline = baseline.Value;
this.baselineType = baselineType.Value;
}
public readonly float baseline;
public readonly TextBaseline baselineType;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderBaseline(baseline: this.baseline, baselineType: this.baselineType);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObjectRaw) {
RenderBaseline renderObject = (RenderBaseline) renderObjectRaw;
renderObject.baseline = this.baseline;
renderObject.baselineType = this.baselineType;
}
}
public class ListBody : MultiChildRenderObjectWidget {
public ListBody(

}
}
public class Wrap : MultiChildRenderObjectWidget {
public Wrap(
Key key = null,
Axis direction = Axis.horizontal,
WrapAlignment alignment = WrapAlignment.start,
float spacing = 0.0f,
WrapAlignment runAlignment = WrapAlignment.start,
float runSpacing = 0.0f,
WrapCrossAlignment crossAxisAlignment = WrapCrossAlignment.start,
TextDirection? textDirection = null,
VerticalDirection verticalDirection = VerticalDirection.down,
List<Widget> children = null
) : base(key: key, children: children) {
this.direction = direction;
this.alignment = alignment;
this.spacing = spacing;
this.runAlignment = runAlignment;
this.runSpacing = runSpacing;
this.crossAxisAlignment = crossAxisAlignment;
this.textDirection = textDirection;
this.verticalDirection = verticalDirection;
}
public readonly Axis direction;
public readonly WrapAlignment alignment;
public readonly float spacing;
public readonly WrapAlignment runAlignment;
public readonly float runSpacing;
public readonly WrapCrossAlignment crossAxisAlignment;
public readonly TextDirection? textDirection;
public readonly VerticalDirection verticalDirection;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderWrap(
children: null,
direction: this.direction,
alignment: this.alignment,
spacing: this.spacing,
runAlignment: this.runAlignment,
runSpacing: this.runSpacing,
crossAxisAlignment: this.crossAxisAlignment,
textDirection: this.textDirection ?? Directionality.of(context),
verticalDirection: this.verticalDirection
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
D.assert(renderObject is RenderWrap);
RenderWrap renderWrap = renderObject as RenderWrap;
renderWrap.direction = this.direction;
renderWrap.alignment = this.alignment;
renderWrap.spacing = this.spacing;
renderWrap.runAlignment = this.runAlignment;
renderWrap.runSpacing = this.runSpacing;
renderWrap.crossAxisAlignment = this.crossAxisAlignment;
renderWrap.textDirection = this.textDirection ?? Directionality.of(context);
renderWrap.verticalDirection = this.verticalDirection;
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<Axis>("direction", this.direction));
properties.add(new EnumProperty<WrapAlignment>("alignment", this.alignment));
properties.add(new FloatProperty("spacing", this.spacing));
properties.add(new EnumProperty<WrapAlignment>("runAlignment", this.runAlignment));
properties.add(new FloatProperty("runSpacing", this.runSpacing));
properties.add(new FloatProperty("crossAxisAlignment", this.runSpacing));
properties.add(new EnumProperty<TextDirection?>("textDirection", this.textDirection, defaultValue: null));
properties.add(new EnumProperty<VerticalDirection>("verticalDirection", this.verticalDirection,
defaultValue: VerticalDirection.down));
}
}
public class PhysicalModel : SingleChildRenderObjectWidget {
public PhysicalModel(

bool absorbing = true,
Widget child = null
) : base(key: key, child: child) {
this.absorbing = absorbing;
public override RenderObject createRenderObject(BuildContext context) {
return new RenderAbsorbPointer(

properties.add(new DiagnosticsProperty<object>("metaData", this.metaData));
}
}
public class KeyedSubtree : StatelessWidget {
public KeyedSubtree(
Key key,
Widget child = null
) : base(key: key) {
D.assert(child != null);
this.child = child;
}
public static KeyedSubtree wrap(Widget child, int childIndex) {
Key key = child.key != null ? (Key) new ValueKey<Key>(child.key) : new ValueKey<int>(childIndex);
return new KeyedSubtree(key: key, child: child);
}
public readonly Widget child;
public static List<Widget> ensureUniqueKeysForList(IEnumerable<Widget> items, int baseIndex = 0) {
if (items == null) {
return null;
}
List<Widget> itemsWithUniqueKeys = new List<Widget>();
int itemIndex = baseIndex;
foreach (Widget item in items) {
itemsWithUniqueKeys.Add(KeyedSubtree.wrap(item, itemIndex));
itemIndex += 1;
}
D.assert(!WidgetsD.debugItemsHaveDuplicateKeys(itemsWithUniqueKeys));
return itemsWithUniqueKeys;
}
public override Widget build(BuildContext context) {
return this.child;
}
}
public class Builder : StatelessWidget {
public Builder(

30
Runtime/widgets/debug.cs


return false;
}
public static bool debugItemsHaveDuplicateKeys(IEnumerable<Widget> items) {
D.assert(() => {
Key nonUniqueKey = _firstNonUniqueKey(items);
if (nonUniqueKey != null) {
throw new UIWidgetsError($"Duplicate key found: {nonUniqueKey}.");
}
return true;
});
return false;
}
public static void debugWidgetBuilderValue(Widget widget, Widget built) {
D.assert(() => {

return true;
});
}
public static bool debugCheckHasMediaQuery(BuildContext context) {
D.assert(() => {
if (!(context.widget is MediaQuery) && context.ancestorWidgetOfExactType(typeof(MediaQuery)) == null) {
Element element = (Element) context;
throw new UIWidgetsError(
"No MediaQuery widget found.\n" +
context.widget.GetType() + " widgets require a MediaQuery widget ancestor.\n" +
"The specific widget that could not find a MediaQuery ancestor was:\n" +
" " + context.widget + "\n" +
"The ownership chain for the affected widget is:\n" +
" " + element.debugGetCreatorChain(10) + "\n" +
"Typically, the MediaQuery widget is introduced by the MaterialApp or " +
"WidgetsApp widget at the top of your application widget tree."
);
}
return true;
});
return true;
}
public static bool debugCheckHasDirectionality(BuildContext context) {

10
Runtime/widgets/framework.cs


return true;
});
if (Window.hasInstance) {
this._setState(fn);
} else {
using (WindowProvider.of(this.context).getScope()) {
this._setState(fn);
}
}
}
void _setState(VoidCallback fn = null) {
if (fn != null) {
fn();
}

71
Runtime/widgets/implicit_animations.cs


}
}
public abstract class ImplicitlyAnimatedWidget : StatefulWidget {
public ImplicitlyAnimatedWidget(
Key key = null,

public delegate Tween<T> TweenConstructor<T>(T targetValue);
public interface ITweenVisitor {
public interface TweenVisitor {
public class TweenVisitorUpdateTween : ITweenVisitor {
public class TweenVisitorUpdateTween : TweenVisitor {
public Tween<T> visit<T, T2>(ImplicitlyAnimatedWidgetState<T2> state, Tween<T> tween, T targetValue,
TweenConstructor<T> constructor)
where T2 : ImplicitlyAnimatedWidget {

}
public class TweenVisitorCheckStartAnimation : ITweenVisitor {
public class TweenVisitorCheckStartAnimation : TweenVisitor {
public bool shouldStartAnimation;
public TweenVisitorCheckStartAnimation() {

return visitor.shouldStartAnimation;
}
protected abstract void forEachTween(ITweenVisitor visitor);
protected abstract void forEachTween(TweenVisitor visitor);
protected virtual void didUpdateTweens() {
}

}
}
public class _AnimatedContainerState : AnimatedWidgetBaseState<AnimatedContainer> {
class _AnimatedContainerState : AnimatedWidgetBaseState<AnimatedContainer> {
AlignmentTween _alignment;
EdgeInsetsTween _padding;
DecorationTween _decoration;

Matrix3Tween _transform;
protected override void forEachTween(ITweenVisitor visitor) {
protected override void forEachTween(TweenVisitor visitor) {
this._alignment = (AlignmentTween) visitor.visit(this, this._alignment, this.widget.alignment,
(Alignment value) => new AlignmentTween(begin: value));
this._padding = (EdgeInsetsTween) visitor.visit(this, this._padding, this.widget.padding,

}
}
public class AnimatedPadding : ImplicitlyAnimatedWidget {
public AnimatedPadding(
Key key = null,
EdgeInsets padding = null,
Widget child = null,
Curve curve = null,
TimeSpan? duration = null
) : base(key: key, curve: curve, duration: duration) {
D.assert(padding != null);
D.assert(padding.isNonNegative);
this.padding = padding;
this.child = child;
}
public readonly EdgeInsets padding;
public readonly Widget child;
public override State createState() {
return new _AnimatedPaddingState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding));
}
}
class _AnimatedPaddingState : AnimatedWidgetBaseState<AnimatedPadding> {
EdgeInsetsTween _padding;
protected override void forEachTween(TweenVisitor visitor) {
this._padding = (EdgeInsetsTween) visitor.visit(this, this._padding, this.widget.padding,
(EdgeInsets value) => new EdgeInsetsTween(begin: value));
}
public override Widget build(BuildContext context) {
return new Padding(
padding: this._padding.evaluate(this.animation),
child: this.widget.child
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder description) {
base.debugFillProperties(description);
description.add(new DiagnosticsProperty<EdgeInsetsTween>("padding", this._padding,
defaultValue: Diagnostics.kNullDefaultValue));
}
}
public class AnimatedDefaultTextStyle : ImplicitlyAnimatedWidget {
public AnimatedDefaultTextStyle(
Key key = null,

}
public class _AnimatedDefaultTextStyleState : AnimatedWidgetBaseState<AnimatedDefaultTextStyle> {
class _AnimatedDefaultTextStyleState : AnimatedWidgetBaseState<AnimatedDefaultTextStyle> {
protected override void forEachTween(ITweenVisitor visitor) {
protected override void forEachTween(TweenVisitor visitor) {
this._style = (TextStyleTween) visitor.visit(this, this._style, this.widget.style,
(TextStyle value) => new TextStyleTween(begin: value));
}

}
}
public class _AnimatedPhysicalModelState : AnimatedWidgetBaseState<AnimatedPhysicalModel> {
class _AnimatedPhysicalModelState : AnimatedWidgetBaseState<AnimatedPhysicalModel> {
protected override void forEachTween(ITweenVisitor visitor) {
protected override void forEachTween(TweenVisitor visitor) {
this._borderRadius = (BorderRadiusTween) visitor.visit(this, this._borderRadius, this.widget.borderRadius,
(BorderRadius value) => new BorderRadiusTween(begin: value));
this._elevation = (FloatTween) visitor.visit(this, this._elevation, this.widget.elevation,

3
Runtime/widgets/layout_builder.cs


namespace Unity.UIWidgets.widgets {
public delegate Widget LayoutWidgetBuilder(BuildContext context, BoxConstraints constraints);
class LayoutBuilder : RenderObjectWidget {
public class LayoutBuilder : RenderObjectWidget {
public LayoutBuilder(
Key key = null,
LayoutWidgetBuilder builder = null) : base(key: key) {

256
Runtime/widgets/navigator.cs


}
public abstract class Route {
public readonly RouteSettings settings;
internal NavigatorState _navigator;
internal NavigatorState _navigator;
public readonly RouteSettings settings;
public virtual bool willHandlePopInternally {
get { return false; }
}
public object currentResult {
get { return default; }
}
public Promise<object> popped { get; } = new Promise<object>();
public bool isCurrent {
get { return this._navigator != null && this._navigator._history.last() == this; }
}
public bool isFirst {
get { return this._navigator != null && this._navigator._history.first() == this; }
}
public bool isActive {
get { return this._navigator != null && this._navigator._history.Contains(this); }
}
protected internal virtual void install(OverlayEntry insertionPoint) {
}

: RoutePopDisposition.pop);
}
public virtual bool willHandlePopInternally {
get { return false; }
}
public object currentResult {
get { return null; }
}
public IPromise<object> popped {
get { return this._popCompleter; }
}
internal readonly Promise<object> _popCompleter = new Promise<object>();
protected internal virtual bool didPop(object result) {
this.didComplete(result);
return true;

this.popped.Resolve(result);
this._popCompleter.Resolve(result);
}
protected internal virtual void didPopNext(Route nextRoute) {

protected internal virtual void dispose() {
this._navigator = null;
}
}
public class RouteSettings {
public readonly bool isInitialRoute;
public bool isCurrent {
get { return this._navigator != null && this._navigator._history.last() == this; }
}
public readonly string name;
public bool isFirst {
get { return this._navigator != null && this._navigator._history.first() == this; }
}
public bool isActive {
get { return this._navigator != null && this._navigator._history.Contains(this); }
}
}
public class RouteSettings {
public RouteSettings(string name = null, bool isInitialRoute = false) {
this.name = name;
this.isInitialRoute = isInitialRoute;

);
}
public readonly bool isInitialRoute;
public readonly string name;
public override string ToString() {
return $"\"{this.name}\"";

}
public class Navigator : StatefulWidget {
/// The default name for the [initialRoute].
///
/// See also:
///
/// * [dart:ui.Window.defaultRouteName], which reflects the route that the
/// application was started with.
public static string defaultRouteName = "/";
public Navigator(
Key key = null,
string initialRoute = null,
RouteFactory onGenerateRoute = null,
RouteFactory onUnknownRoute = null,
List<NavigatorObserver> observers = null) : base(key) {
D.assert(onGenerateRoute != null);
this.initialRoute = initialRoute;
this.onGenerateRoute = onGenerateRoute;
this.onUnknownRoute = onUnknownRoute;
this.observers = observers ?? new List<NavigatorObserver>();
}
public readonly List<NavigatorObserver> observers;
public Navigator(Key key = null, string initialRoute = null,
RouteFactory onGenerateRoute = null, RouteFactory onUnknownRoute = null,
List<NavigatorObserver> observers = null) : base(key) {
D.assert(onGenerateRoute != null);
this.initialRoute = initialRoute;
this.onUnknownRoute = onUnknownRoute;
this.onGenerateRoute = onGenerateRoute;
this.observers = observers ?? new List<NavigatorObserver>();
}
public readonly List<NavigatorObserver> observers;
public static IPromise<object> pushName(BuildContext context, string routeName) {
return of(context).pushNamed(routeName);
public static readonly string defaultRouteName = "/";
public static IPromise<object> pushNamed(BuildContext context, string routeName) {
return Navigator.of(context).pushNamed(routeName);
return of(context).pushReplacementNamed(routeName, result);
return Navigator.of(context).pushReplacementNamed(routeName, result: result);
return of(context).popAndPushNamed(routeName, result);
return Navigator.of(context).popAndPushNamed(routeName, result: result);
return of(context).pushNamedAndRemoveUntil(newRouteName, predicate);
return Navigator.of(context).pushNamedAndRemoveUntil(newRouteName, predicate);
return of(context).push(route);
return Navigator.of(context).push(route);
return of(context).pushReplacement(newRoute, result);
return Navigator.of(context).pushReplacement(newRoute, result);
return of(context).pushAndRemoveUntil(newRoute, predicate);
return Navigator.of(context).pushAndRemoveUntil(newRoute, predicate);
public static void replace(BuildContext context, Route oldRoute, Route newRoute) {
of(context).replace(oldRoute, newRoute);
public static void replace(BuildContext context, Route oldRoute = null, Route newRoute = null) {
D.assert(oldRoute != null);
D.assert(newRoute != null);
Navigator.of(context).replace(oldRoute: oldRoute, newRoute: newRoute);
of(context).replaceRouteBelow(anchorRoute, newRoute);
D.assert(anchorRoute != null);
D.assert(newRoute != null);
Navigator.of(context).replaceRouteBelow(anchorRoute: anchorRoute, newRoute: newRoute);
public static bool canPop(BuildContext context) {
NavigatorState navigator = Navigator.of(context, nullOk: true);
return navigator != null && navigator.canPop();
}
return of(context).maybePop(result);
return Navigator.of(context).maybePop(result);
return of(context).pop(result);
return Navigator.of(context).pop(result);
of(context).popUntil(predicate);
Navigator.of(context).popUntil(predicate);
of(context).removeRoute(route);
Navigator.of(context).removeRoute(route);
of(context).removeRouteBelow(anchorRoute);
Navigator.of(context).removeRouteBelow(anchorRoute);
}
public static NavigatorState of(

}
public class NavigatorState : TickerProviderStateMixin<Navigator> {
readonly GlobalKey<OverlayState> _overlayKey = GlobalKey<OverlayState>.key();
readonly GlobalKey<OverlayState> _overlayKey = new LabeledGlobalKey<OverlayState>();
readonly HashSet<int> _activePointers = new HashSet<int>();
bool _debugLocked;
int _userGesturesInProgress;
public OverlayState overlay {
get { return this._overlayKey.currentState; }
}
OverlayEntry _currentOverlayEntry {
get {
var route = this._history.FindLast(r => r.overlayEntries.isNotEmpty());
return route?.overlayEntries.last();
}
}
public bool userGestureInProgress {
get { return this._userGesturesInProgress > 0; }
}
public override void initState() {
base.initState();
foreach (var observer in this.widget.observers) {

if (plannedInitialRoutes.Contains(null)) {
D.assert(() => {
UIWidgetsError.reportError(new UIWidgetsErrorDetails(
new Exception(
exception: new Exception(
"Could not navigate to initial route.\n" +
$"The requested route name was: \"{initialRouteName}\n" +
"The following routes were therefore attempted:\n" +

return true;
});
this.push(this._routeNamed(Navigator.defaultRouteName));
}
else {
} else {
}
else {
} else {
Route route = null;
if (initialRouteName != Navigator.defaultRouteName) {
route = this._routeNamed(initialRouteName, true);

}
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
if (((Navigator) oldWidget).observers != this.widget.observers) {

return true;
});
}
public OverlayState overlay {
get { return this._overlayKey.currentState; }
}
OverlayEntry _currentOverlayEntry {
get {
var route = this._history.FindLast(r => r.overlayEntries.isNotEmpty());
return route?.overlayEntries.last();
}
}
bool _debugLocked;
var settings = new RouteSettings(name, this._history.isEmpty());
var route = this.widget.onGenerateRoute(settings);
var settings = new RouteSettings(
name: name,
isInitialRoute: this._history.isEmpty()
);
var route = (Route) this.widget.onGenerateRoute(settings);
if (route == null && !allowNull) {
D.assert(() => {
if (this.widget.onUnknownRoute == null) {

return true;
});
route = this.widget.onUnknownRoute(settings);
route = (Route) this.widget.onUnknownRoute(settings);
D.assert(() => {
if (route == null) {
throw new UIWidgetsError(

return route;
}
public Promise<object> pushNamed(string routeName) {
public IPromise<object> pushNamed(string routeName) {
public Promise<object> pushReplacementNamed(string routeName, object result = null) {
public IPromise<object> pushReplacementNamed(string routeName, object result = null) {
public Promise<object> popAndPushNamed(string routeName, object result = null) {
public IPromise<object> popAndPushNamed(string routeName, object result = null) {
public Promise<object> pushNamedAndRemoveUntil(string newRouteName, RoutePredicate predicate) {
public IPromise<object> pushNamedAndRemoveUntil(string newRouteName, RoutePredicate predicate) {
public Promise<object> push(Route route) {
public IPromise<object> push(Route route) {
D.assert(!this._debugLocked);
D.assert(() => {
this._debugLocked = true;

}
void _afterNavigation() {
this._cancelActivePointers();
public Promise<object> pushReplacement(Route newRoute, object result = null) {
public IPromise<object> pushReplacement(Route newRoute, object result = null) {
D.assert(!this._debugLocked);
D.assert(() => {
this._debugLocked = true;

newRoute.install(this._currentOverlayEntry);
this._history[index] = newRoute;
newRoute.didPush().whenCompleteOrCancel(() => {
// The old route's exit is not animated. We're assuming that the
// new route completely obscures the old one.
if (this.mounted) {
oldRoute.didComplete(result ?? oldRoute.currentResult);
oldRoute.dispose();

}
foreach (var observer in this.widget.observers) {
observer.didReplace(newRoute, oldRoute);
observer.didReplace(newRoute: newRoute, oldRoute: oldRoute);
}
D.assert(() => {

return newRoute.popped;
}
public Promise<object> pushAndRemoveUntil(Route newRoute, RoutePredicate predicate) {
public IPromise<object> pushAndRemoveUntil(Route newRoute, RoutePredicate predicate) {
D.assert(!this._debugLocked);
D.assert(() => {
this._debugLocked = true;

D.assert(!this._debugLocked);
D.assert(oldRoute != null);
D.assert(newRoute != null);
if (oldRoute == newRoute
) // ignore: unrelated_type_equality_checks, https://github.com/dart-lang/sdk/issues/32522
{
if (oldRoute == newRoute) {
return;
}

newRoute.install(oldRoute.overlayEntries.last());
this._history[index] = newRoute;
newRoute.didReplace(oldRoute);
if (index + 1 < this._history.Capacity) {
if (index + 1 < this._history.Count) {
newRoute.didChangeNext(this._history[index + 1]);
this._history[index + 1].didChangePrevious(newRoute);
}

}
foreach (var observer in this.widget.observers) {
observer.didReplace(newRoute, oldRoute);
observer.didReplace(newRoute: newRoute, oldRoute: oldRoute);
}
oldRoute.dispose();

this.pop(result);
}
return Promise<bool>.Resolved(true);
return true;
return Promise<bool>.Resolved(false);
return false;
});
}

D.assert(debugPredictedWouldPop);
if (this._history.Count > 1) {
this._history.removeLast();
// If route._navigator is null, the route called finalizeRoute from
// didPop, which means the route has already been disposed and doesn't
// need to be added to _poppedRoutes for later disposal.
if (route._navigator != null) {
this._poppedRoutes.Add(route);
}

this._poppedRoutes.Remove(route);
route.dispose();
}
int _userGesturesInProgress = 0;
public bool userGestureInProgress {
get { return this._userGesturesInProgress > 0; }
}
public void didStartUserGesture() {
this._userGesturesInProgress += 1;

? this._history[this._history.Count - 2]
: null;
// Don't operate the _history list since the gesture may be cancelled.
// In case of a back swipe, the gesture controller will call .pop() itself.
foreach (var observer in this.widget.observers) {
observer.didStartUserGesture(route, previousRoute);
}

}
}
readonly HashSet<int> _activePointers = new HashSet<int>();
void _handlePointerDown(PointerDownEvent evt) {
this._activePointers.Add(evt.pointer);

}
});
}
foreach (var activePointer in this._activePointers) {
WidgetsBinding.instance.cancelPointer(activePointer);
}
this._activePointers.ToList().ForEach(WidgetsBinding.instance.cancelPointer);
public override Widget build(BuildContext context) {
D.assert(!this._debugLocked);

this.focusScopeNode,
autofocus: true,
child: new Overlay(
this._overlayKey,
this._initialOverlayEntries
key: this._overlayKey,
initialEntries: this._initialOverlayEntries
)
) {
alwaysUpdate = true,
}
)
);
}

6
Runtime/widgets/pages.cs


}
public override bool opaque {
get { return false; }
get { return true; }
}
public override bool barrierDismissible {

bool opaque = true,
bool barrierDismissible = false,
Color barrierColor = null,
string barrierLabel = null,
bool maintainState = true
) : base(settings) {
D.assert(pageBuilder != null);

this.transitionDuration = transitionDuration ?? TimeSpan.FromMilliseconds(300);
this.barrierColor = barrierColor;
this.maintainState = maintainState;
this.barrierLabel = barrierLabel;
this.barrierDismissible = barrierDismissible;
}

public override bool barrierDismissible { get; }
public override Color barrierColor { get; }
public override string barrierLabel { get; }
public override bool maintainState { get; }

13
Runtime/widgets/routes.cs


public virtual bool barrierDismissible { get; }
public virtual string barrierLabel { get; }
public virtual bool maintainState { get; }

class _DialogRoute : PopupRoute {
internal _DialogRoute(RoutePageBuilder pageBuilder = null, bool barrierDismissible = true,
string barrierLabel = null,
Color barrierColor = null,
TimeSpan? transitionDuration = null,
RouteTransitionsBuilder transitionBuilder = null,

this.barrierLabel = barrierLabel;
this.barrierColor = barrierColor ?? new Color(0x80000000);
this.transitionDuration = transitionDuration ?? TimeSpan.FromMilliseconds(200);
this._transitionBuilder = transitionBuilder;

public override bool barrierDismissible { get; }
public override string barrierLabel { get; }
public override Color barrierColor { get; }

}
public static class DialogUtils {
public static Promise<object> showGeneralDialog(
public static IPromise<object> showGeneralDialog(
string barrierLabel = null,
D.assert(!barrierDismissible || barrierLabel != null);
barrierLabel: barrierLabel,
barrierColor: barrierColor,
transitionDuration: transitionDuration,
transitionBuilder: transitionBuilder

60
Runtime/widgets/safe_area.cs


using UnityEngine;
using UnityEngine;
namespace Unity.UIWidgets.widgets {
public class SafeArea : StatelessWidget {

child: this.child));
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("left", value: this.left, ifTrue: "avoid left padding"));
properties.add(new FlagProperty("top", value: this.top, ifTrue: "avoid top padding"));
properties.add(new FlagProperty("right", value: this.right, ifTrue: "avoid right padding"));
properties.add(new FlagProperty("bottom", value: this.bottom, ifTrue: "avoid bottom padding"));
}
}
class SliverSafeArea : StatelessWidget {
public SliverSafeArea(
Key key = null,
bool left = true,
bool top = true,
bool right = true,
bool bottom = true,
EdgeInsets minimum = null,
Widget sliver = null) : base(key: key) {
D.assert(sliver != null);
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
this.minimum = minimum ?? EdgeInsets.zero;
this.sliver = sliver;
}
public readonly bool left;
public readonly bool top;
public readonly bool right;
public readonly bool bottom;
public readonly EdgeInsets minimum;
public readonly Widget sliver;
public override Widget build(BuildContext context) {
EdgeInsets padding = MediaQuery.of(context).padding;
return new SliverPadding(
padding: EdgeInsets.only(
left: Mathf.Max(this.left ? padding.left : 0.0f, this.minimum.left),
top: Mathf.Max(this.top ? padding.top : 0.0f, this.minimum.top),
right: Mathf.Max(this.right ? padding.right : 0.0f, this.minimum.right),
bottom: Mathf.Max(this.bottom ? padding.bottom : 0.0f, this.minimum.bottom)
),
sliver: MediaQuery.removePadding(
context: context,
removeLeft: this.left,
removeTop: this.top,
removeRight: this.right,
removeBottom: this.bottom,
child: this.sliver));
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);

4
Runtime/widgets/scroll_notification.mixin.gen.cs


using Unity.UIWidgets.rendering;
namespace Unity.UIWidgets.widgets {
public abstract class ViewportNotificationMixinNotification : Notification {
public int depth {
get { return this._depth; }

}
public abstract class ViewportNotificationMixinLayoutChangedNotification : LayoutChangedNotification {
public int depth {
get { return this._depth; }

this._depth, this._depth == 0 ? "local" : "remote"));
}
}
}

2
Runtime/widgets/ticker_provider.cs


}
}
// There is a copy of the implementation of this mixin at widgets/automatic_keep_alive.cs,
// in AutomaticKeepAliveClientWithTickerProviderStateMixin, remember to keep the copy up to date
public abstract class TickerProviderStateMixin<T> : State<T>, TickerProvider where T : StatefulWidget {
HashSet<Ticker> _tickers;

2
Runtime/widgets/transitions.cs


Animation<float> sizeFactor = null,
float axisAlignment = 0.0f,
Widget child = null) : base(key: key, listenable: sizeFactor) {
D.assert(axis != null);
D.assert(axisAlignment != null);
this.axis = axis;
this.axisAlignment = axisAlignment;
this.child = child;

9
Samples/UIWidgetSample/AsScreenSample.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Image = Unity.UIWidgets.widgets.Image;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

height: 450,
color: CLColors.white,
child: Image.network(
"https://d2ujflorbtfzji.cloudfront.net/banner/5c57178c-4be6-4903-953b-85125bfb7154.jpg",
fit: BoxFit.cover
"https://assetstorev1-prd-cdn.unity3d.com/banner/9716cc07-748c-43cc-8809-10113119c97a.jpg",
fit: BoxFit.cover,
filterMode: FilterMode.Bilinear
)
);
}

45.0f,
36.0f,
true,
"https://d2ujflorbtfzji.cloudfront.net/key-image/46dc65c1-f605-4ccb-97e0-3d60b28cfdfe.jpg"
"https://assetstorev1-prd-cdn.unity3d.com/key-image/76a549ae-de17-4536-bd96-4231ed20dece.jpg"
);
return new Container(
margin: EdgeInsets.only(left: 98),

30
Samples/UIWidgetSample/MaterialSample.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;

};
protected override Widget createWidget() {
return new WidgetsApp(
home: this.testCases[this.testCaseId],
pageRouteBuilder: this.pageRouteBuilder);
return new MaterialApp(
home: this.testCases[this.testCaseId]);
}
}

class MaterialButtonWidgetState : State<MaterialButtonWidget> {
public override Widget build(BuildContext context) {
return new Material(
child: new Center(
child: new MaterialButton(
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
onPressed: () => { Debug.Log("pressed here"); }
)
)
return new Stack(
children: new List<Widget> {
new Material(
child: new Center(
child: new FlatButton(
shape: new RoundedRectangleBorder(borderRadius: BorderRadius.all(20.0f)),
color: new Color(0xFF00FF00),
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
child: new Text("Click Me"),
onPressed: () => { Debug.Log("pressed here"); }
)
)
),
new PerformanceOverlay()
}
);
}
}

3
Samples/UIWidgetSample/NavigationSample.cs


body: new Container(
color: new Color(0xFF888888),
child: new Center(
child: new CustomButton(onPressed: () => { Navigator.pushName(context, "/detail"); },
child: new CustomButton(onPressed: () => { Navigator.pushNamed(context, "/detail"); },
child: new Text("Go to Detail"))
)),
title: "Home"

return builder(buildContext);
},
barrierDismissible: barrierDismissible,
barrierLabel: "",
barrierColor: new Color(0x8A000000),
transitionDuration: TimeSpan.FromMilliseconds(150),
transitionBuilder: _buildMaterialDialogTransitions

29
Tests/Editor/CanvasAndLayers.cs


using System;
using System.Collections.Generic;
using System.Linq;
using RSG;
using Unity.UIWidgets.editor;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;

this.clipRRect,
this.saveLayer,
this.drawLine,
this.drawParagraph,
};
this._optionStrings = this._options.Select(x => x.Method.Name).ToArray();
this._selected = 0;

Window.instance = this._windowAdapter;
if (Event.current.type == EventType.MouseDown) {
Promise.Delayed(new TimeSpan(0, 0, 5)).Then(() => { Debug.Log("Promise.Delayed: 5s"); });
}
this._options[this._selected]();
Window.instance = null;

}, null, TileMode.clamp)
};
// canvas.drawRect(
// Unity.UIWidgets.ui.Rect.fromLTRB(10, 10, 110, 110),
// paint);
canvas.rotate(Mathf.PI * 15 / 180);
var path = new Path();
path.moveTo(10, 150);
path.lineTo(10, 160);

}
canvas.drawPath(path, paint);
canvas.rotate(Mathf.PI * 15 / 180);
canvas.translate(100, 100);

new Offset(90, 10),
paint);
canvas.drawArc(Unity.UIWidgets.ui.Rect.fromLTWH(200, 200, 100, 100), Mathf.PI / 4,
-Mathf.PI / 2 + Mathf.PI * 4 - 1, true, paint);
paint.maskFilter = MaskFilter.blur(BlurStyle.normal, 1);
paint.strokeWidth = 4;

editorCanvas.flush();
}
void drawParagraph() {
var pb = new ParagraphBuilder(new ParagraphStyle{});
pb.addText("Hello drawParagraph");
var paragraph = pb.build();
paragraph.layout(new ParagraphConstraints(width:300));
var canvas = new CommandBufferCanvas(this._renderTexture, Window.instance.devicePixelRatio,
this._meshPool);
canvas.drawParagraph(paragraph, new Offset(10f, 100f));
canvas.flush();
}
void drawImageRect() {
if (this._stream == null || this._stream.completer == null || this._stream.completer.currentImage == null) {
return;

15
Tests/Editor/Widgets.cs


if (this._selected != selected) {
this._selected = selected;
this._attachRootWidget(null);
this._attachRootWidget(new Container());
}
if (GUILayout.Button("loadLocal")) {

}
void _attachRootWidget(Widget widget) {
this.windowAdapter.attachRootWidget(() => new WidgetsApp(home: widget,
this.windowAdapter.attachRootWidget(() => new WidgetsApp(
home: widget,
navigatorKey: GlobalKey<NavigatorState>.key(),
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(
settings: settings,

height: 450,
color: CLColors.white,
child: Image.network(
"https://d2ujflorbtfzji.cloudfront.net/banner/5c57178c-4be6-4903-953b-85125bfb7154.jpg",
fit: BoxFit.cover
"https://assetstorev1-prd-cdn.unity3d.com/banner/9716cc07-748c-43cc-8809-10113119c97a.jpg",
fit: BoxFit.cover,
filterMode: FilterMode.Bilinear
)
);
}

45.0f,
36.0f,
true,
"https://d2ujflorbtfzji.cloudfront.net/key-image/46dc65c1-f605-4ccb-97e0-3d60b28cfdfe.jpg"
"https://assetstorev1-prd-cdn.unity3d.com/key-image/76a549ae-de17-4536-bd96-4231ed20dece.jpg"
);
return new Container(
margin: EdgeInsets.only(left: 98),

child: new Container(
color: CLColors.background3,
child: new Transform(
transform: Matrix3.makeRotate(45, px, py),
transform: Matrix3.makeRotate(Mathf.PI/180 * 5, px, py),
child:
new Column(
children: new List<Widget> {

32
Third Party Notices.md


This package contains third-party software components governed by the license(s) indicated below:
---------
Component Name: [provide component name]
License Type: [Provide license type, i.e. "MIT", "Apache 2.0"]
Component Name: [flutter](https://flutter.dev/)
[Provide License Details]
License Type: flutter
---------
Component Name: [provide component name]
Copyright 2014 The Chromium Authors. All rights reserved.
License Type: [Provide license type, i.e. "MIT", "Apache 2.0"]
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
[Provide License Details]
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

8
package.json


{
"name": "com.unity.uiwidgets",
"displayName":"UI Widgets",
"version": "0.1.0-preview",
"unity": "2018.3",
"description": "Replace this string with your own description of the package. This description appears in the Package Manager window when the user selects this package from the list. \n\nFor best results, use this text to summarize: \n\u25AA What the package does \n\u25AA How it can benefit the user \n\nNote: Special formatting characters are supported, including line breaks ('\\n') and bullets ('\\u25AA').",
"displayName":"UIWidgets",
"version": "1.0.0-preview",
"unity": "2018.1",
"description": "UIWidgets allows you to build beautiful cross-platform apps through Unity",
"dependencies": {
}
}

95
Runtime/flow/performance_overlay_layer.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using UnityEngine;
using Canvas = Unity.UIWidgets.ui.Canvas;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.flow {
public class PerformanceOverlayLayer : Layer {
public PerformanceOverlayLayer(int options) {
this._options = options;
}
readonly int _options;
public override void paint(PaintContext context) {
D.assert(this.needsPainting);
const int padding = 8;
const int fpsHeight = 20;
Canvas canvas = context.canvas;
canvas.save();
float x = this.paintBounds.left + padding;
float y = this.paintBounds.top + padding;
float width = this.paintBounds.width - padding * 2;
float height = this.paintBounds.height;
this._drawFPS(canvas, x, y);
if ((this._options & (int) PerformanceOverlayOption.drawFrameCost) == 1) {
this._drawFrameCost(canvas, x, y + fpsHeight, width, height - padding - fpsHeight);
}
canvas.restore();
}
void _drawFPS(Canvas canvas, float x, float y) {
var pb = new ParagraphBuilder(new ParagraphStyle { });
pb.addText("FPS = " + PerformanceUtils.instance.getFPS());
var paragraph = pb.build();
paragraph.layout(new ParagraphConstraints(width: 300));
canvas.drawParagraph(paragraph, new Offset(x, y));
}
void _drawFrameCost(Canvas canvas, float x, float y, float width, float height) {
Rect visualizationRect = Rect.fromLTWH(x, y, width, height);
Paint paint = new Paint {color = Colors.blue};
Paint paint2 = new Paint {color = Colors.red};
Paint paint3 = new Paint {color = Colors.green};
Paint paint4 = new Paint {color = Colors.white70};
float[] costFrames = PerformanceUtils.instance.getFrames();
int curFrame = PerformanceUtils.instance.getCurFrame();
float barWidth = Mathf.Max(1, width / costFrames.Length);
float perHeight = height / 32.0f;
canvas.drawRect(visualizationRect, paint4);
canvas.drawRect(Rect.fromLTWH(x, y + perHeight * 16.0f, width, 1), paint3);
float cur_x = x;
Path barPath = new Path();
for (var i = 0; i < costFrames.Length; i++) {
if (costFrames[i] != 0) {
float curHeight = Mathf.Min(perHeight * costFrames[i], height);
Rect barRect = Rect.fromLTWH(cur_x, y + height - curHeight, barWidth, curHeight);
barPath.addRect(barRect);
}
cur_x += barWidth;
}
canvas.drawPath(barPath, paint);
if (curFrame >= 0 && curFrame < costFrames.Length && costFrames[curFrame] != 0) {
float curHeight = Mathf.Min(perHeight * costFrames[curFrame], height);
Rect barRect = Rect.fromLTWH(x + barWidth * curFrame, y + height - curHeight, barWidth, curHeight);
canvas.drawRect(barRect, paint2);
var pb = new ParagraphBuilder(new ParagraphStyle { });
pb.addText("Frame Cost: " + costFrames[curFrame] + "ms");
var paragraph = pb.build();
paragraph.layout(new ParagraphConstraints(width: 300));
canvas.drawParagraph(paragraph, new Offset(x, y + height - 12));
}
}
}
}

11
Runtime/flow/performance_overlay_layer.cs.meta


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

51
Runtime/flow/texture_layer.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.flow {
public class TextureLayer : Layer {
Offset _offset = Offset.zero;
public Offset offset {
set { this._offset = value ?? Offset.zero; }
}
Size _size;
public Size size {
set { this._size = value; }
}
Texture _texture;
public Texture texture {
set { this._texture = value; }
}
bool _freeze = false;
public bool freeze {
set { this._freeze = value; }
}
public override void preroll(PrerollContext context, Matrix3 matrix) {
this.paintBounds = Rect.fromLTWH(
this._offset.dx, this._offset.dy, this._size.width, this._size.height);
}
public override void paint(PaintContext context) {
D.assert(this.needsPainting);
if (this._texture == null) {
return;
}
var image = new Image(this._texture, noDispose: true);
var canvas = context.canvas;
canvas.drawImageRect(image, this.paintBounds, new Paint());
}
}
}

11
Runtime/flow/texture_layer.cs.meta


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

135
Runtime/material/app.cs


using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
static class AppUtils {
public static readonly TextStyle _errorTextStyle = new TextStyle(
color: new Color(0xD0FF0000),
fontFamily: "monospace",
fontSize: 48.0f,
fontWeight: FontWeight.w700,
decoration: TextDecoration.underline,
decorationColor: new Color(0xFFFFFF00),
decorationStyle: TextDecorationStyle.doubleLine
);
}
public class MaterialApp : StatefulWidget {
public MaterialApp(
Key key = null,
GlobalKey<NavigatorState> navigatorKey = null,
Widget home = null,
Dictionary<string, WidgetBuilder> routes = null,
string initialRoute = null,
RouteFactory onGenerateRoute = null,
RouteFactory onUnknownRoute = null,
List<NavigatorObserver> navigatorObservers = null,
TransitionBuilder builder = null,
string title = "",
Color color = null,
ThemeData theme = null,
bool showPerformanceOverlay = false
) : base(key: key) {
this.navigatorKey = navigatorKey;
this.home = home;
this.routes = routes ?? new Dictionary<string, WidgetBuilder>();
this.initialRoute = initialRoute;
this.onGenerateRoute = onGenerateRoute;
this.onUnknownRoute = onUnknownRoute;
this.navigatorObservers = navigatorObservers ?? new List<NavigatorObserver>();
this.builder = builder;
this.title = title;
this.color = color;
this.theme = theme;
this.showPerformanceOverlay = showPerformanceOverlay;
}
public readonly GlobalKey<NavigatorState> navigatorKey;
public readonly Widget home;
public readonly Dictionary<string, WidgetBuilder> routes;
public readonly string initialRoute;
public readonly RouteFactory onGenerateRoute;
public readonly RouteFactory onUnknownRoute;
public readonly List<NavigatorObserver> navigatorObservers;
public readonly TransitionBuilder builder;
public readonly string title;
public readonly ThemeData theme;
public readonly Color color;
public readonly bool showPerformanceOverlay;
public override State createState() {
return new _MaterialAppState();
}
}
class _MaterialAppState : State<MaterialApp> {
public override void initState() {
base.initState();
this._updateNavigator();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
this._updateNavigator();
}
List<NavigatorObserver> _navigatorObservers;
void _updateNavigator() {
if (this.widget.home != null ||
this.widget.routes.isNotEmpty() ||
this.widget.onGenerateRoute != null ||
this.widget.onUnknownRoute != null) {
this._navigatorObservers = new List<NavigatorObserver>(this.widget.navigatorObservers);
}
else {
this._navigatorObservers = null;
}
}
RectTween _createRectTween(Rect begin, Rect end) {
return new MaterialRectArcTween(begin: begin, end: end);
}
public override Widget build(BuildContext context) {
ThemeData theme = this.widget.theme ?? ThemeData.fallback();
Widget result = new AnimatedTheme(
data: theme,
isMaterialAppTheme: true,
child: new WidgetsApp(
key: new GlobalObjectKey<State>(this),
navigatorKey: this.widget.navigatorKey,
navigatorObservers: this._navigatorObservers,
pageRouteBuilder: (RouteSettings settings, WidgetBuilder builder) =>
new MaterialPageRoute(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,
textStyle: AppUtils._errorTextStyle
)
);
return result;
}
}
}

11
Runtime/material/app.cs.meta


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

274
Runtime/material/dialog.cs


using System;
using System.Collections.Generic;
using RSG;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class Dialog : StatelessWidget {
public Dialog(
Key key = null,
Widget child = null,
TimeSpan? insetAnimationDuration = null,
Curve insetAnimationCurve = null,
ShapeBorder shape = null
) : base(key: key) {
this.child = child;
this.insetAnimationDuration = insetAnimationDuration ?? new TimeSpan(0, 0, 0, 0, 100);
this.insetAnimationCurve = Curves.decelerate;
this.shape = shape;
}
public readonly Widget child;
public readonly TimeSpan insetAnimationDuration;
public readonly Curve insetAnimationCurve;
public readonly ShapeBorder shape;
Color _getColor(BuildContext context) {
return Theme.of(context).dialogBackgroundColor;
}
public static readonly RoundedRectangleBorder _defaultDialogShape =
new RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(2.0f)));
public override Widget build(BuildContext context) {
DialogTheme dialogTheme = DialogTheme.of(context);
return new AnimatedPadding(
padding: MediaQuery.of(context).viewInsets + EdgeInsets.symmetric(horizontal: 40.0f, vertical: 24.0f),
duration: this.insetAnimationDuration,
curve: this.insetAnimationCurve,
child: MediaQuery.removeViewInsets(
removeLeft: true,
removeTop: true,
removeRight: true,
removeBottom: true,
context: context,
child: new Center(
child: new ConstrainedBox(
constraints: new BoxConstraints(minWidth: 280.0f),
child: new Material(
elevation: 24.0f,
color: this._getColor(context),
type: MaterialType.card,
child: this.child,
shape: this.shape ?? dialogTheme.shape ?? _defaultDialogShape
)
)
)
)
);
}
}
public class AlertDialog : StatelessWidget {
public AlertDialog(
Key key = null,
Widget title = null,
EdgeInsets titlePadding = null,
Widget content = null,
EdgeInsets contentPadding = null,
List<Widget> actions = null,
ShapeBorder shape = null
) : base(key: key) {
this.title = title;
this.titlePadding = titlePadding;
this.content = content;
this.contentPadding = contentPadding ?? EdgeInsets.fromLTRB(24.0f, 20.0f, 24.0f, 24.0f);
this.actions = actions;
this.shape = shape;
}
public readonly Widget title;
public readonly EdgeInsets titlePadding;
public readonly Widget content;
public readonly EdgeInsets contentPadding;
public readonly List<Widget> actions;
public readonly ShapeBorder shape;
public override Widget build(BuildContext context) {
// D.assert(debugCheckHasMaterialLocalizations(context));
List<Widget> children = new List<Widget>();
if (this.title != null) {
children.Add(new Padding(
padding: this.titlePadding ??
EdgeInsets.fromLTRB(24.0f, 24.0f, 24.0f, this.content == null ? 20.0f : 0.0f),
child: new DefaultTextStyle(
style: Theme.of(context).textTheme.title,
child: this.title
)
));
}
if (this.content != null) {
children.Add(new Flexible(
child: new Padding(
padding: this.contentPadding,
child: new DefaultTextStyle(
style: Theme.of(context).textTheme.subhead,
child: this.content
)
)
));
}
if (this.actions != null) {
children.Add(ButtonTheme.bar(
child: new ButtonBar(
children: this.actions
)
));
}
Widget dialogChild = new IntrinsicWidth(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children
)
);
return new Dialog(child: dialogChild, shape: this.shape);
}
}
public class SimpleDialogOption : StatelessWidget {
public SimpleDialogOption(
Key key = null,
VoidCallback onPressed = null,
Widget child = null
) : base(key: key) {
this.onPressed = onPressed;
this.child = child;
}
public readonly VoidCallback onPressed;
public readonly Widget child;
public override Widget build(BuildContext context) {
return new InkWell(
onTap: () => this.onPressed(),
child: new Padding(
padding: EdgeInsets.symmetric(vertical: 8.0f, horizontal: 24.0f),
child: this.child
)
);
}
}
public class SimpleDialog : StatelessWidget {
public SimpleDialog(
Key key = null,
Widget title = null,
EdgeInsets titlePadding = null,
List<Widget> children = null,
EdgeInsets contentPadding = null,
ShapeBorder shape = null
) : base(key: key) {
this.title = title;
this.titlePadding = titlePadding ?? EdgeInsets.fromLTRB(24.0f, 24.0f, 24.0f, 0.0f);
this.children = children;
this.contentPadding = contentPadding ?? EdgeInsets.fromLTRB(0.0f, 12.0f, 0.0f, 16.0f);
this.shape = shape;
}
public readonly Widget title;
public readonly EdgeInsets titlePadding;
public readonly List<Widget> children;
public readonly EdgeInsets contentPadding;
public readonly ShapeBorder shape;
public override Widget build(BuildContext context) {
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
List<Widget> body = new List<Widget>();
if (this.title != null) {
body.Add(new Padding(
padding: this.titlePadding,
child: new DefaultTextStyle(
style: Theme.of(context).textTheme.title,
child: this.title
)
));
}
if (this.children != null) {
body.Add(new Flexible(
child: new SingleChildScrollView(
padding: this.contentPadding,
child: new ListBody(children: this.children)
)
));
}
Widget dialogChild = new IntrinsicWidth(
stepWidth: 56.0f,
child: new ConstrainedBox(
constraints: new BoxConstraints(minWidth: 280.0f),
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: body
)
)
);
return new Dialog(child: dialogChild, shape: this.shape);
}
}
public static class DialogUtils {
static Widget _buildMaterialDialogTransitions(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation, Widget child) {
return new FadeTransition(
opacity: new CurvedAnimation(
parent: animation,
curve: Curves.easeOut
),
child: child
);
}
public static IPromise<object> showDialog(
BuildContext context = null,
bool barrierDismissible = true,
WidgetBuilder builder = null
) {
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
return widgets.DialogUtils.showGeneralDialog(
context: context,
pageBuilder: (buildContext, animation, secondaryAnimation) => {
ThemeData theme = Theme.of(context, shadowThemeOnly: true);
Widget pageChild = new Builder(builder: builder);
return new SafeArea(
child: new Builder(
builder: (_) => theme != null
? new Theme(data: theme, child: pageChild)
: pageChild)
);
},
barrierDismissible: barrierDismissible,
barrierColor: Colors.black54,
transitionDuration: new TimeSpan(0, 0, 0, 0, 150),
transitionBuilder: _buildMaterialDialogTransitions
);
}
}
}

11
Runtime/material/dialog.cs.meta


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

69
Runtime/material/dialog_theme.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class DialogTheme : Diagnosticable, IEquatable<DialogTheme> {
public DialogTheme(ShapeBorder shape = null) {
this.shape = shape;
}
public readonly ShapeBorder shape;
public DialogTheme copyWith(ShapeBorder shape = null) {
return new DialogTheme(shape: shape ?? this.shape);
}
public static DialogTheme of(BuildContext context) {
return Theme.of(context).dialogTheme;
}
public static DialogTheme lerp(DialogTheme a, DialogTheme b, float t) {
return new DialogTheme(
shape: ShapeBorder.lerp(a?.shape, b?.shape, t)
);
}
public bool Equals(DialogTheme other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return Equals(this.shape, other.shape);
}
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((DialogTheme) obj);
}
public override int GetHashCode() {
return (this.shape != null ? this.shape.GetHashCode() : 0);
}
public static bool operator ==(DialogTheme left, DialogTheme right) {
return Equals(left, right);
}
public static bool operator !=(DialogTheme left, DialogTheme right) {
return !Equals(left, right);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape,
defaultValue: Diagnostics.kNullDefaultValue));
}
}
}

11
Runtime/material/dialog_theme.cs.meta


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

390
Runtime/material/material_localizations.cs


using System;
using System.Collections.Generic;
using System.Text;
using RSG;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public abstract class MaterialLocalizations {
public abstract string openAppDrawerTooltip { get; }
public abstract string backButtonTooltip { get; }
public abstract string closeButtonTooltip { get; }
public abstract string deleteButtonTooltip { get; }
public abstract string nextMonthTooltip { get; }
public abstract string previousMonthTooltip { get; }
public abstract string nextPageTooltip { get; }
public abstract string previousPageTooltip { get; }
public abstract string showMenuTooltip { get; }
public abstract string aboutListTileTitle(string applicationName);
public abstract string licensesPageTitle { get; }
public abstract string pageRowsInfoTitle(int firstRow, int lastRow, int rowCount, bool rowCountIsApproximate);
public abstract string rowsPerPageTitle { get; }
public abstract string tabLabel(int tabIndex, int tabCount);
public abstract string selectedRowCountTitle(int selectedRowCount);
public abstract string cancelButtonLabel { get; }
public abstract string closeButtonLabel { get; }
public abstract string continueButtonLabel { get; }
public abstract string copyButtonLabel { get; }
public abstract string cutButtonLabel { get; }
public abstract string okButtonLabel { get; }
public abstract string pasteButtonLabel { get; }
public abstract string selectAllButtonLabel { get; }
public abstract string viewLicensesButtonLabel { get; }
public abstract string anteMeridiemAbbreviation { get; }
public abstract string postMeridiemAbbreviation { get; }
public abstract string searchFieldLabel { get; }
public abstract TimeOfDayFormat timeOfDayFormat(bool alwaysUse24HourFormat = false);
public abstract ScriptCategory scriptCategory { get; }
public abstract string formatDecimal(int number);
public abstract string formatHour(TimeOfDay timeOfDay, bool alwaysUse24HourFormat = false);
public abstract string formatMinute(TimeOfDay timeOfDay);
public abstract string formatTimeOfDay(TimeOfDay timeOfDay, bool alwaysUse24HourFormat = false);
public abstract string formatYear(DateTime date);
public abstract string formatMediumDate(DateTime date);
public abstract string formatFullDate(DateTime date);
public abstract string formatMonthYear(DateTime date);
public abstract List<string> narrowWeekdays { get; }
public abstract int firstDayOfWeekIndex { get; }
public static MaterialLocalizations of(BuildContext context) {
return Localizations.of<MaterialLocalizations>(context, typeof(MaterialLocalizations));
}
}
class _MaterialLocalizationsDelegate : LocalizationsDelegate<MaterialLocalizations> {
public _MaterialLocalizationsDelegate() {
}
public override bool isSupported(Locale locale) {
return locale.languageCode == "en";
}
public override IPromise<object> load(Locale locale) {
return DefaultMaterialLocalizations.load(locale);
}
public override bool shouldReload(LocalizationsDelegate old) {
return false;
}
public override string ToString() {
return "DefaultMaterialLocalizations.delegate(en_US)";
}
}
public class DefaultMaterialLocalizations : MaterialLocalizations {
public DefaultMaterialLocalizations() {
}
static readonly List<string> _shortWeekdays = new List<string>() {
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun",
};
static readonly List<String> _weekdays = new List<string>() {
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
};
static readonly List<String> _narrowWeekdays = new List<string>() {
"S",
"M",
"T",
"W",
"T",
"F",
"S",
};
static readonly List<String> _shortMonths = new List<string>() {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
};
static readonly List<String> _months = new List<string>() {
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
};
public override string formatHour(TimeOfDay timeOfDay, bool alwaysUse24HourFormat = false) {
TimeOfDayFormat format = this.timeOfDayFormat(alwaysUse24HourFormat: alwaysUse24HourFormat);
switch (format) {
case TimeOfDayFormat.h_colon_mm_space_a:
return this.formatDecimal(timeOfDay.hourOfPeriod == 0 ? 12 : timeOfDay.hourOfPeriod);
case TimeOfDayFormat.HH_colon_mm:
return this._formatTwoDigitZeroPad(timeOfDay.hour);
default:
throw new AssertionError($"runtimeType does not support {format}.");
}
}
string _formatTwoDigitZeroPad(int number) {
D.assert(0 <= number && number < 100);
if (number < 10) {
return "0" + number;
}
return number.ToString();
}
public override string formatMinute(TimeOfDay timeOfDay) {
int minute = timeOfDay.minute;
return minute < 10 ? "0" + minute : minute.ToString();
}
public override string formatYear(DateTime date) {
return date.Year.ToString();
}
public override string formatMediumDate(DateTime date) {
string day = _shortWeekdays[((int) date.DayOfWeek + 6) % 7];
string month = _shortMonths[date.Month - 1];
return $"{day}, {month} ${date.Day}";
}
public override string formatFullDate(DateTime date) {
string month = _months[date.Month - 1];
return $"{_weekdays[((int) date.DayOfWeek + 6) % 7]}, {month} {date.Day}, {date.Year}";
}
public override string formatMonthYear(DateTime date) {
string year = this.formatYear(date);
string month = _months[date.Month - 1];
return $"{month} {year}";
}
public override List<string> narrowWeekdays {
get { return _narrowWeekdays; }
}
public override int firstDayOfWeekIndex {
get { return 0; }
}
string _formatDayPeriod(TimeOfDay timeOfDay) {
switch (timeOfDay.period) {
case DayPeriod.am:
return this.anteMeridiemAbbreviation;
case DayPeriod.pm:
return this.postMeridiemAbbreviation;
}
return null;
}
public override string formatDecimal(int number) {
if (number > -1000 && number < 1000) {
return number.ToString();
}
string digits = number.abs().ToString();
StringBuilder result = new StringBuilder(number < 0 ? "-" : "");
int maxDigitIndex = digits.Length - 1;
for (int i = 0; i <= maxDigitIndex; i += 1) {
result.Append(digits[i]);
if (i < maxDigitIndex && (maxDigitIndex - i) % 3 == 0) {
result.Append(',');
}
}
return result.ToString();
}
public override string formatTimeOfDay(TimeOfDay timeOfDay, bool alwaysUse24HourFormat = false) {
StringBuilder buffer = new StringBuilder();
buffer.Append(this.formatHour(timeOfDay, alwaysUse24HourFormat: alwaysUse24HourFormat));
buffer.Append(":");
buffer.Append(this.formatMinute(timeOfDay));
if (alwaysUse24HourFormat) {
return buffer.ToString();
}
buffer.Append(" ");
buffer.Append(this._formatDayPeriod(timeOfDay));
return buffer.ToString();
}
public override string openAppDrawerTooltip {
get { return "Open navigation menu"; }
}
public override string backButtonTooltip {
get { return "Back"; }
}
public override string closeButtonTooltip {
get { return "Close"; }
}
public override string deleteButtonTooltip {
get { return "Delete"; }
}
public override string nextMonthTooltip {
get { return "Next month"; }
}
public override string previousMonthTooltip {
get { return "Previous month"; }
}
public override string nextPageTooltip {
get { return "Next page"; }
}
public override string previousPageTooltip {
get { return "Previous page"; }
}
public override string showMenuTooltip {
get { return "Show menu"; }
}
public override string searchFieldLabel {
get { return "Search"; }
}
public override string aboutListTileTitle(string applicationName) {
return "About " + applicationName;
}
public override string licensesPageTitle {
get { return "Licenses"; }
}
public override string pageRowsInfoTitle(int firstRow, int lastRow, int rowCount, bool rowCountIsApproximate) {
return rowCountIsApproximate
? $"{firstRow}–{lastRow} of about {rowCount}"
: $"{firstRow}–{lastRow} of {rowCount}";
}
public override string rowsPerPageTitle {
get { return "Rows per page:"; }
}
public override string tabLabel(int tabIndex, int tabCount) {
D.assert(tabIndex >= 1);
D.assert(tabCount >= 1);
return $"Tab {tabIndex} of {tabCount}";
}
public override string selectedRowCountTitle(int selectedRowCount) {
switch (selectedRowCount) {
case 0:
return "No items selected";
case 1:
return "1 item selected";
default:
return selectedRowCount + " items selected";
}
}
public override string cancelButtonLabel {
get { return "CANCEL"; }
}
public override string closeButtonLabel {
get { return "CLOSE"; }
}
public override string continueButtonLabel {
get { return "CONTINUE"; }
}
public override string copyButtonLabel {
get { return "COPY"; }
}
public override string cutButtonLabel {
get { return "CUT"; }
}
public override string okButtonLabel {
get { return "OK"; }
}
public override string pasteButtonLabel {
get { return "PASTE"; }
}
public override string selectAllButtonLabel {
get { return "SELECT ALL"; }
}
public override string viewLicensesButtonLabel {
get { return "VIEW LICENSES"; }
}
public override string anteMeridiemAbbreviation {
get { return "AM"; }
}
public override string postMeridiemAbbreviation {
get { return "PM"; }
}
public override ScriptCategory scriptCategory {
get { return ScriptCategory.englishLike; }
}
public override TimeOfDayFormat timeOfDayFormat(bool alwaysUse24HourFormat = false) {
return alwaysUse24HourFormat
? TimeOfDayFormat.HH_colon_mm
: TimeOfDayFormat.h_colon_mm_space_a;
}
public static IPromise<object> load(Locale locale) {
return Promise<object>.Resolved(new DefaultMaterialLocalizations());
}
public static readonly LocalizationsDelegate<MaterialLocalizations> del = new _MaterialLocalizationsDelegate();
}
}

11
Runtime/material/material_localizations.cs.meta


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

62
Runtime/material/page.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class MaterialPageRoute : PageRoute {
public MaterialPageRoute(
WidgetBuilder builder = null,
RouteSettings settings = null,
bool maintainState = true,
bool fullscreenDialog = false) : base(settings: settings, fullscreenDialog: fullscreenDialog) {
D.assert(builder != null);
this.builder = builder;
this.maintainState = maintainState;
D.assert(this.opaque);
}
public readonly WidgetBuilder builder;
public override bool maintainState { get; }
public override TimeSpan transitionDuration {
get { return new TimeSpan(0, 0, 0, 0, 300); }
}
public override Color barrierColor {
get { return null; }
}
public override bool canTransitionFrom(TransitionRoute previousRoute) {
return previousRoute is MaterialPageRoute;
}
public override bool canTransitionTo(TransitionRoute nextRoute) {
return nextRoute is MaterialPageRoute && !((MaterialPageRoute) nextRoute).fullscreenDialog;
}
public override Widget buildPage(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) {
Widget result = this.builder(context);
D.assert(() => {
if (result == null) {
throw new UIWidgetsError(
"The builder for route " + this.settings.name + "returned null. \n" +
"Route builders must never return null."
);
}
return true;
});
return result;
}
public override Widget buildTransitions(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation, Widget child) {
PageTransitionsTheme theme = Theme.of(context).pageTransitionsTheme;
return theme.buildTranstions(this, context, animation, secondaryAnimation, child);
}
}
}

11
Runtime/material/page.cs.meta


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

151
Runtime/material/page_transitions_theme.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class _FadeUpwardsPageTransition : StatelessWidget {
public _FadeUpwardsPageTransition(
Key key = null,
Animation<float> routeAnimation = null,
Widget child = null) : base(key: key) {
D.assert(routeAnimation != null);
D.assert(child != null);
this._positionAnimation = routeAnimation.drive(_bottomUpTween.chain(_fastOutSlowInTween));
this._opacityAnimation = routeAnimation.drive(_easeInTween);
this.child = child;
}
static readonly Tween<Offset> _bottomUpTween = new OffsetTween(
begin: new Offset(0.0f, 0.25f),
end: Offset.zero
);
static readonly Animatable<float> _fastOutSlowInTween = new CurveTween(
curve: Curves.fastOutSlowIn);
static readonly Animatable<float> _easeInTween = new CurveTween(
curve: Curves.easeIn);
public readonly Animation<Offset> _positionAnimation;
public readonly Animation<float> _opacityAnimation;
public readonly Widget child;
public override Widget build(BuildContext context) {
return new SlideTransition(
position: this._positionAnimation,
child: new FadeTransition(
opacity: this._opacityAnimation,
child: this.child));
}
}
public abstract class PageTransitionsBuilder {
public PageTransitionsBuilder() {
}
public abstract Widget buildTransitions(
PageRoute route,
BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation,
Widget child);
}
public class FadeUpwardsPageTransitionsBuilder : PageTransitionsBuilder {
public FadeUpwardsPageTransitionsBuilder() {
}
public override Widget buildTransitions(
PageRoute route,
BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation,
Widget child) {
return new _FadeUpwardsPageTransition(
routeAnimation: animation,
child: child);
}
}
public class PageTransitionsTheme : Diagnosticable, IEquatable<PageTransitionsTheme> {
public PageTransitionsTheme(
PageTransitionsBuilder builder = null) {
this._builder = builder;
}
static PageTransitionsBuilder _defaultBuilder = new FadeUpwardsPageTransitionsBuilder();
public PageTransitionsBuilder builder {
get { return this._builder ?? _defaultBuilder; }
}
readonly PageTransitionsBuilder _builder;
public Widget buildTranstions(
PageRoute route,
BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation,
Widget child) {
PageTransitionsBuilder matchingBuilder = this.builder;
return matchingBuilder.buildTransitions(route, context, animation, secondaryAnimation, child);
}
List<PageTransitionsBuilder> _all(PageTransitionsBuilder builder) {
return new List<PageTransitionsBuilder> {this.builder};
}
public bool Equals(PageTransitionsTheme other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this._all(this.builder) == this._all(other.builder);
}
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((PageTransitionsTheme) obj);
}
public static bool operator ==(PageTransitionsTheme left, PageTransitionsTheme right) {
return Equals(left, right);
}
public static bool operator !=(PageTransitionsTheme left, PageTransitionsTheme right) {
return !Equals(left, right);
}
public override int GetHashCode() {
unchecked {
var hashCode = this._all(this.builder).GetHashCode();
return hashCode;
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<PageTransitionsBuilder>("builder", this.builder,
defaultValue: _defaultBuilder));
}
}
}

11
Runtime/material/page_transitions_theme.cs.meta


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

608
Runtime/material/popup_menu.cs


using System;
using System.Collections.Generic;
using RSG;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public static partial class PopupMenuUtils {
internal static readonly TimeSpan _kMenuDuration = new TimeSpan(0, 0, 0, 0, 300);
internal const float _kBaselineOffsetFromBottom = 20.0f;
internal const float _kMenuCloseIntervalEnd = 2.0f / 3.0f;
internal const float _kMenuHorizontalPadding = 16.0f;
internal const float _kMenuItemHeight = 48.0f;
internal const float _kMenuDividerHeight = 16.0f;
internal const float _kMenuMaxWidth = 5.0f * _kMenuWidthStep;
internal const float _kMenuMinWidth = 2.0f * _kMenuWidthStep;
internal const float _kMenuVerticalPadding = 8.0f;
internal const float _kMenuWidthStep = 56.0f;
internal const float _kMenuScreenPadding = 8.0f;
}
public abstract class PopupMenuEntry<T> : StatefulWidget {
protected PopupMenuEntry(Key key = null) : base(key: key) {
}
public abstract float height { get; }
public abstract bool represents(T value);
}
public class PopupMenuDivider : PopupMenuEntry<object> {
public PopupMenuDivider(Key key = null, float height = PopupMenuUtils._kMenuDividerHeight) : base(key: key) {
this._height = height;
}
readonly float _height;
public override float height {
get { return this._height; }
}
public override bool represents(object value) {
return false;
}
public override State createState() {
return new _PopupMenuDividerState();
}
}
class _PopupMenuDividerState : State<PopupMenuDivider> {
public override Widget build(BuildContext context) {
return new Divider(height: this.widget.height);
}
}
public class PopupMenuItem<T> : PopupMenuEntry<T> {
public PopupMenuItem(
Key key = null,
T value = default,
bool enabled = true,
float height = PopupMenuUtils._kMenuItemHeight,
Widget child = null
) : base(key: key) {
this.value = value;
this.enabled = enabled;
this._height = height;
this.child = child;
}
public readonly T value;
public readonly bool enabled;
readonly float _height;
public override float height {
get { return this._height; }
}
public readonly Widget child;
public override bool represents(T value) {
return Equals(value, this.value);
}
public override State createState() {
return new PopupMenuItemState<T, PopupMenuItem<T>>();
}
}
public class PopupMenuItemState<T, W> : State<W> where W : PopupMenuItem<T> {
protected virtual Widget buildChild() {
return this.widget.child;
}
protected virtual void handleTap() {
Navigator.pop(this.context, this.widget.value);
}
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
TextStyle style = theme.textTheme.subhead;
if (!this.widget.enabled) {
style = style.copyWith(color: theme.disabledColor);
}
Widget item = new AnimatedDefaultTextStyle(
style: style,
duration: Constants.kThemeChangeDuration,
child: new Baseline(
baseline: this.widget.height - PopupMenuUtils._kBaselineOffsetFromBottom,
baselineType: style.textBaseline,
child: this.buildChild()
)
);
if (!this.widget.enabled) {
bool isDark = theme.brightness == Brightness.dark;
item = IconTheme.merge(
data: new IconThemeData(opacity: isDark ? 0.5f : 0.38f),
child: item
);
}
return new InkWell(
onTap: this.widget.enabled ? this.handleTap : (GestureTapCallback) null,
child: new Container(
height: this.widget.height,
padding: EdgeInsets.symmetric(horizontal: PopupMenuUtils._kMenuHorizontalPadding),
child: item
)
);
}
}
public class PopupMenuItemSingleTickerProviderState<T, W> : SingleTickerProviderStateMixin<W>
where W : PopupMenuItem<T> {
protected virtual Widget buildChild() {
return this.widget.child;
}
protected virtual void handleTap() {
Navigator.pop(this.context, this.widget.value);
}
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
TextStyle style = theme.textTheme.subhead;
if (!this.widget.enabled) {
style = style.copyWith(color: theme.disabledColor);
}
Widget item = new AnimatedDefaultTextStyle(
style: style,
duration: Constants.kThemeChangeDuration,
child: new Baseline(
baseline: this.widget.height - PopupMenuUtils._kBaselineOffsetFromBottom,
baselineType: style.textBaseline,
child: this.buildChild()
)
);
if (!this.widget.enabled) {
bool isDark = theme.brightness == Brightness.dark;
item = IconTheme.merge(
data: new IconThemeData(opacity: isDark ? 0.5f : 0.38f),
child: item
);
}
return new InkWell(
onTap: this.widget.enabled ? this.handleTap : (GestureTapCallback) null,
child: new Container(
height: this.widget.height,
padding: EdgeInsets.symmetric(horizontal: PopupMenuUtils._kMenuHorizontalPadding),
child: item
)
);
}
}
class CheckedPopupMenuItem<T> : PopupMenuItem<T> {
public CheckedPopupMenuItem(
Key key = null,
T value = default,
bool isChecked = false,
bool enabled = true,
Widget child = null
) : base(
key: key,
value: value,
enabled: enabled,
child: child
) {
this.isChecked = isChecked;
}
public readonly bool isChecked;
public override State createState() {
return new _CheckedPopupMenuItemState<T>();
}
}
class _CheckedPopupMenuItemState<T> : PopupMenuItemSingleTickerProviderState<T, CheckedPopupMenuItem<T>> {
static readonly TimeSpan _fadeDuration = new TimeSpan(0, 0, 0, 0, 150);
AnimationController _controller;
Animation<float> _opacity {
get { return this._controller.view; }
}
public override void initState() {
base.initState();
this._controller = new AnimationController(duration: _fadeDuration, vsync: this);
this._controller.setValue(this.widget.isChecked ? 1.0f : 0.0f);
this._controller.addListener(() => this.setState(() => {
/* animation changed */
}));
}
protected override void handleTap() {
if (this.widget.isChecked) {
this._controller.reverse();
} else {
this._controller.forward();
}
base.handleTap();
}
protected override Widget buildChild() {
return new ListTile(
enabled: this.widget.enabled,
leading: new FadeTransition(
opacity: this._opacity,
child: new Icon(this._controller.isDismissed ? null : Icons.done)
),
title: this.widget.child
);
}
}
class _PopupMenu<T> : StatelessWidget {
public _PopupMenu(
Key key = null,
_PopupMenuRoute<T> route = null
) : base(key: key) {
this.route = route;
}
public readonly _PopupMenuRoute<T> route;
public override Widget build(BuildContext context) {
float unit = 1.0f / (this.route.items.Count + 1.5f);
List<Widget> children = new List<Widget>();
for (int i = 0; i < this.route.items.Count; i += 1) {
float start = (i + 1) * unit;
float end = (start + 1.5f * unit).clamp(0.0f, 1.0f);
Widget item = this.route.items[i];
if (this.route.initialValue != null && this.route.items[i].represents((T) this.route.initialValue)) {
item = new Container(
color: Theme.of(context).highlightColor,
child: item
);
}
children.Add(new FadeTransition(
opacity: new CurvedAnimation(
parent: this.route.animation,
curve: new Interval(start, end)
),
child: item
));
}
CurveTween opacity = new CurveTween(curve: new Interval(0.0f, 1.0f / 3.0f));
CurveTween width = new CurveTween(curve: new Interval(0.0f, unit));
CurveTween height = new CurveTween(curve: new Interval(0.0f, unit * this.route.items.Count));
Widget child = new ConstrainedBox(
constraints: new BoxConstraints(
minWidth: PopupMenuUtils._kMenuMinWidth,
maxWidth: PopupMenuUtils._kMenuMaxWidth
),
child: new IntrinsicWidth(
stepWidth: PopupMenuUtils._kMenuWidthStep,
child: new SingleChildScrollView(
padding: EdgeInsets.symmetric(
vertical: PopupMenuUtils._kMenuVerticalPadding
),
child: new ListBody(children: children)
)
)
);
return new AnimatedBuilder(
animation: this.route.animation,
builder: (_, builderChild) => {
return new Opacity(
opacity: opacity.evaluate(this.route.animation),
child: new Material(
type: MaterialType.card,
elevation: this.route.elevation,
child: new Align(
alignment: Alignment.topRight,
widthFactor: width.evaluate(this.route.animation),
heightFactor: height.evaluate(this.route.animation),
child: builderChild
)
)
);
},
child: child
);
}
}
class _PopupMenuRouteLayout : SingleChildLayoutDelegate {
public _PopupMenuRouteLayout(RelativeRect position, float? selectedItemOffset) {
this.position = position;
this.selectedItemOffset = selectedItemOffset;
}
public readonly RelativeRect position;
public readonly float? selectedItemOffset;
public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
return BoxConstraints.loose(constraints.biggest -
new Offset(
PopupMenuUtils._kMenuScreenPadding * 2.0f,
PopupMenuUtils._kMenuScreenPadding * 2.0f));
}
public override Offset getPositionForChild(Size size, Size childSize) {
float y;
if (this.selectedItemOffset == null) {
y = this.position.top;
} else {
y = this.position.top + (size.height - this.position.top - this.position.bottom) / 2.0f -
this.selectedItemOffset.Value;
}
float x;
if (this.position.left > this.position.right) {
x = size.width - this.position.right - childSize.width;
} else if (this.position.left < this.position.right) {
x = this.position.left;
} else {
x = this.position.left;
}
if (x < PopupMenuUtils._kMenuScreenPadding) {
x = PopupMenuUtils._kMenuScreenPadding;
} else if (x + childSize.width > size.width - PopupMenuUtils._kMenuScreenPadding) {
x = size.width - childSize.width - PopupMenuUtils._kMenuScreenPadding;
}
if (y < PopupMenuUtils._kMenuScreenPadding) {
y = PopupMenuUtils._kMenuScreenPadding;
} else if (y + childSize.height > size.height - PopupMenuUtils._kMenuScreenPadding) {
y = size.height - childSize.height - PopupMenuUtils._kMenuScreenPadding;
}
return new Offset(x, y);
}
public override bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) {
return this.position != ((_PopupMenuRouteLayout) oldDelegate).position;
}
}
class _PopupMenuRoute<T> : PopupRoute {
public _PopupMenuRoute(
RelativeRect position = null,
List<PopupMenuEntry<T>> items = null,
object initialValue = null,
float elevation = 8.0f,
ThemeData theme = null
) {
this.position = position;
this.items = items;
this.initialValue = initialValue;
this.elevation = elevation;
this.theme = theme;
}
public readonly RelativeRect position;
public readonly List<PopupMenuEntry<T>> items;
public readonly object initialValue;
public readonly float elevation;
public readonly ThemeData theme;
public override Animation<float> createAnimation() {
return new CurvedAnimation(
parent: base.createAnimation(),
curve: Curves.linear,
reverseCurve: new Interval(0.0f, PopupMenuUtils._kMenuCloseIntervalEnd)
);
}
public override TimeSpan transitionDuration {
get { return PopupMenuUtils._kMenuDuration; }
}
public override bool barrierDismissible {
get { return true; }
}
public override Color barrierColor {
get { return null; }
}
public override Widget buildPage(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation) {
float? selectedItemOffset = null;
if (this.initialValue != null) {
float y = PopupMenuUtils._kMenuVerticalPadding;
foreach (PopupMenuEntry<T> entry in this.items) {
if (entry.represents((T) this.initialValue)) {
selectedItemOffset = y + entry.height / 2.0f;
break;
}
y += entry.height;
}
}
Widget menu = new _PopupMenu<T>(route: this);
if (this.theme != null) {
menu = new Theme(data: this.theme, child: menu);
}
return MediaQuery.removePadding(
context: context,
removeTop: true,
removeBottom: true,
removeLeft: true,
removeRight: true,
child: new Builder(
builder: _ => new CustomSingleChildLayout(
layoutDelegate: new _PopupMenuRouteLayout(
this.position,
selectedItemOffset
),
child: menu
))
);
}
}
public static partial class PopupMenuUtils {
public static IPromise<T> showMenu<T>(
BuildContext context,
RelativeRect position,
List<PopupMenuEntry<T>> items,
T initialValue,
float elevation = 8.0f
) {
D.assert(context != null);
D.assert(items != null && items.isNotEmpty());
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
return Navigator.push(context, new _PopupMenuRoute<T>(
position: position,
items: items,
initialValue: initialValue,
elevation: elevation,
theme: Theme.of(context, shadowThemeOnly: true)
)).Then(result => (T) result);
}
}
public delegate void PopupMenuItemSelected<T>(T value);
public delegate void PopupMenuCanceled();
public delegate List<PopupMenuEntry<T>> PopupMenuItemBuilder<T>(BuildContext context);
public class PopupMenuButton<T> : StatefulWidget {
public PopupMenuButton(
Key key = null,
PopupMenuItemBuilder<T> itemBuilder = null,
T initialValue = default,
PopupMenuItemSelected<T> onSelected = null,
PopupMenuCanceled onCanceled = null,
string tooltip = null,
float elevation = 8.0f,
EdgeInsets padding = null,
Widget child = null,
Icon icon = null,
Offset offset = null
) : base(key: key) {
D.assert(itemBuilder != null);
D.assert(offset != null);
D.assert(!(child != null && icon != null));
this.itemBuilder = itemBuilder;
this.initialValue = initialValue;
this.onSelected = onSelected;
this.onCanceled = onCanceled;
this.tooltip = tooltip;
this.elevation = elevation;
this.padding = padding ?? EdgeInsets.all(8.0f);
this.child = child;
this.icon = icon;
this.offset = offset ?? Offset.zero;
}
public readonly PopupMenuItemBuilder<T> itemBuilder;
public readonly T initialValue;
public readonly PopupMenuItemSelected<T> onSelected;
public readonly PopupMenuCanceled onCanceled;
public readonly string tooltip;
public readonly float elevation;
public readonly EdgeInsets padding;
public readonly Widget child;
public readonly Icon icon;
public readonly Offset offset;
public override State createState() {
return new _PopupMenuButtonState<T>();
}
}
class _PopupMenuButtonState<T> : State<PopupMenuButton<T>> {
void showButtonMenu() {
RenderBox button = (RenderBox) this.context.findRenderObject();
RenderBox overlay = (RenderBox) Overlay.of(this.context).context.findRenderObject();
RelativeRect position = RelativeRect.fromRect(
Rect.fromPoints(
button.localToGlobal(this.widget.offset, ancestor: overlay),
button.localToGlobal(button.size.bottomRight(Offset.zero), ancestor: overlay)
),
Offset.zero & overlay.size
);
PopupMenuUtils.showMenu<T>(
context: this.context,
elevation: this.widget.elevation,
items: this.widget.itemBuilder(this.context),
initialValue: this.widget.initialValue,
position: position
)
.Then(newValue => {
if (!this.mounted) {
return;
}
if (newValue == null) {
if (this.widget.onCanceled != null) {
this.widget.onCanceled();
}
return;
}
if (this.widget.onSelected != null) {
this.widget.onSelected(newValue);
}
});
}
Icon _getIcon(RuntimePlatform platform) {
switch (platform) {
case RuntimePlatform.IPhonePlayer:
return new Icon(Icons.more_horiz);
default:
return new Icon(Icons.more_vert);
}
}
public override Widget build(BuildContext context) {
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
return this.widget.child != null
? (Widget) new InkWell(
onTap: this.showButtonMenu,
child: this.widget.child
)
: new IconButton(
icon: this.widget.icon ?? this._getIcon(Theme.of(context).platform),
padding: this.widget.padding,
tooltip: this.widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
onPressed: this.showButtonMenu
);
}
}
}

11
Runtime/material/popup_menu.cs.meta


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

527
Runtime/material/switch.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using ImageUtils = Unity.UIWidgets.widgets.ImageUtils;
namespace Unity.UIWidgets.material {
enum _SwitchType {
material,
adaptive
}
public class Switch : StatefulWidget {
internal const float _kTrackHeight = 14.0f;
internal const float _kTrackWidth = 33.0f;
internal const float _kTrackRadius = _kTrackHeight / 2.0f;
internal const float _kThumbRadius = 10.0f;
internal const float _kSwitchWidth = _kTrackWidth - 2 * _kTrackRadius + 2 * Constants.kRadialReactionRadius;
internal const float _kSwitchHeight = 2 * Constants.kRadialReactionRadius + 8.0f;
internal const float _kSwitchHeightCollapsed = 2 * Constants.kRadialReactionRadius;
public Switch(
Key key = null,
bool? value = null,
ValueChanged<bool?> onChanged = null,
Color activeColor = null,
Color activeTrackColor = null,
Color inactiveThumbColor = null,
Color inactiveTrackColor = null,
ImageProvider activeThumbImage = null,
ImageProvider inactiveThumbImage = null,
MaterialTapTargetSize? materialTapTargetSize = null
) : this(
key: key,
value: value,
onChanged: onChanged,
activeColor: activeColor,
activeTrackColor: activeTrackColor,
inactiveThumbColor: inactiveThumbColor,
inactiveTrackColor: inactiveTrackColor,
activeThumbImage: activeThumbImage,
inactiveThumbImage: inactiveThumbImage,
materialTapTargetSize: materialTapTargetSize,
switchType: _SwitchType.material
) {
}
Switch(
Key key = null,
bool? value = null,
ValueChanged<bool?> onChanged = null,
Color activeColor = null,
Color activeTrackColor = null,
Color inactiveThumbColor = null,
Color inactiveTrackColor = null,
ImageProvider activeThumbImage = null,
ImageProvider inactiveThumbImage = null,
MaterialTapTargetSize? materialTapTargetSize = null,
_SwitchType switchType = _SwitchType.material
) : base(key: key) {
D.assert(value != null);
this.value = value.Value;
D.assert(onChanged != null);
this.onChanged = onChanged;
this.activeColor = activeColor;
this.activeTrackColor = activeTrackColor;
this.inactiveThumbColor = inactiveThumbColor;
this.inactiveTrackColor = inactiveTrackColor;
this.activeThumbImage = activeThumbImage;
this.inactiveThumbImage = inactiveThumbImage;
this.materialTapTargetSize = materialTapTargetSize;
this._switchType = switchType;
}
public static Switch adaptive(
Key key = null,
bool? value = null,
ValueChanged<bool?> onChanged = null,
Color activeColor = null,
Color activeTrackColor = null,
Color inactiveThumbColor = null,
Color inactiveTrackColor = null,
ImageProvider activeThumbImage = null,
ImageProvider inactiveThumbImage = null,
MaterialTapTargetSize? materialTapTargetSize = null
) {
return new Switch(key: key,
value: value,
onChanged: onChanged,
activeColor: activeColor,
activeTrackColor: activeTrackColor,
inactiveThumbColor: inactiveThumbColor,
inactiveTrackColor: inactiveTrackColor,
activeThumbImage: activeThumbImage,
inactiveThumbImage: inactiveThumbImage,
materialTapTargetSize: materialTapTargetSize,
switchType: _SwitchType.adaptive
);
}
public readonly bool value;
public readonly ValueChanged<bool?> onChanged;
public readonly Color activeColor;
public readonly Color activeTrackColor;
public readonly Color inactiveThumbColor;
public readonly Color inactiveTrackColor;
public readonly ImageProvider activeThumbImage;
public readonly ImageProvider inactiveThumbImage;
public readonly MaterialTapTargetSize? materialTapTargetSize;
internal readonly _SwitchType _switchType;
public override State createState() {
return new _SwitchState();
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("value", value: this.value, ifTrue: "on", ifFalse: "off", showName: true));
properties.add(new ObjectFlagProperty<ValueChanged<bool?>>("onChanged", this.onChanged, ifNull: "disabled"));
}
}
class _SwitchState : TickerProviderStateMixin<Switch> {
Size getSwitchSize(ThemeData theme) {
switch (this.widget.materialTapTargetSize ?? theme.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
return new Size(Switch._kSwitchWidth, Switch._kSwitchHeight);
break;
case MaterialTapTargetSize.shrinkWrap:
return new Size(Switch._kSwitchWidth, Switch._kSwitchHeightCollapsed);
break;
}
D.assert(false);
return null;
}
Widget buildMaterialSwitch(BuildContext context) {
D.assert(MaterialD.debugCheckHasMaterial(context));
ThemeData theme = Theme.of(context);
bool isDark = theme.brightness == Brightness.dark;
Color activeThumbColor = this.widget.activeColor ?? theme.toggleableActiveColor;
Color activeTrackColor = this.widget.activeTrackColor ?? activeThumbColor.withAlpha(0x80);
Color inactiveThumbColor;
Color inactiveTrackColor;
if (this.widget.onChanged != null) {
Color black32 = new Color(0x52000000); // Black with 32% opacity
inactiveThumbColor = this.widget.inactiveThumbColor ??
(isDark ? Colors.grey.shade400 : Colors.grey.shade50);
inactiveTrackColor = this.widget.inactiveTrackColor ?? (isDark ? Colors.white30 : black32);
} else {
inactiveThumbColor = this.widget.inactiveThumbColor ??
(isDark ? Colors.grey.shade800 : Colors.grey.shade400);
inactiveTrackColor = this.widget.inactiveTrackColor ?? (isDark ? Colors.white10 : Colors.black12);
}
return new _SwitchRenderObjectWidget(
value: this.widget.value,
activeColor: activeThumbColor,
inactiveColor: inactiveThumbColor,
activeThumbImage: this.widget.activeThumbImage,
inactiveThumbImage: this.widget.inactiveThumbImage,
activeTrackColor: activeTrackColor,
inactiveTrackColor: inactiveTrackColor,
configuration: ImageUtils.createLocalImageConfiguration(context),
onChanged: this.widget.onChanged,
additionalConstraints: BoxConstraints.tight(this.getSwitchSize(theme)),
vsync: this
);
}
// Widget buildCupertinoSwitch(BuildContext context) {
// Size size = this.getSwitchSize(Theme.of(context));
// return new Container(
// width: size.width, // Same size as the Material switch.
// height: size.height,
// alignment: Alignment.center,
// child: CupertinoSwitch(
// value: this.widget.value,
// onChanged: this.widget.onChanged,
// activeColor: this.widget.activeColor
// )
// );
// }
public override Widget build(BuildContext context) {
switch (this.widget._switchType) {
case _SwitchType.material:
return this.buildMaterialSwitch(context);
case _SwitchType.adaptive: {
return this.buildMaterialSwitch(context);
// ThemeData theme = Theme.of(context);
// D.assert(theme.platform != null);
// switch (theme.platform) {
// case TargetPlatform.android:
// return buildMaterialSwitch(context);
// case TargetPlatform.iOS:
// return buildCupertinoSwitch(context);
// }
// break;
}
}
D.assert(false);
return null;
}
}
class _SwitchRenderObjectWidget : LeafRenderObjectWidget {
public _SwitchRenderObjectWidget(
Key key = null,
bool? value = null,
Color activeColor = null,
Color inactiveColor = null,
ImageProvider activeThumbImage = null,
ImageProvider inactiveThumbImage = null,
Color activeTrackColor = null,
Color inactiveTrackColor = null,
ImageConfiguration configuration = null,
ValueChanged<bool?> onChanged = null,
TickerProvider vsync = null,
BoxConstraints additionalConstraints = null
) : base(key: key) {
D.assert(value != null);
this.value = value.Value;
this.activeColor = activeColor;
this.inactiveColor = inactiveColor;
this.activeThumbImage = activeThumbImage;
this.inactiveThumbImage = inactiveThumbImage;
this.activeTrackColor = activeTrackColor;
this.inactiveTrackColor = inactiveTrackColor;
this.configuration = configuration;
this.onChanged = onChanged;
this.vsync = vsync;
this.additionalConstraints = additionalConstraints;
}
public readonly bool value;
public readonly Color activeColor;
public readonly Color inactiveColor;
public readonly ImageProvider activeThumbImage;
public readonly ImageProvider inactiveThumbImage;
public readonly Color activeTrackColor;
public readonly Color inactiveTrackColor;
public readonly ImageConfiguration configuration;
public readonly ValueChanged<bool?> onChanged;
public readonly TickerProvider vsync;
public readonly BoxConstraints additionalConstraints;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderSwitch(
value: this.value,
activeColor: this.activeColor,
inactiveColor: this.inactiveColor,
activeThumbImage: this.activeThumbImage,
inactiveThumbImage: this.inactiveThumbImage,
activeTrackColor: this.activeTrackColor,
inactiveTrackColor: this.inactiveTrackColor,
configuration: this.configuration,
onChanged: this.onChanged,
additionalConstraints: this.additionalConstraints,
vsync: this.vsync
);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObjectRaw) {
_RenderSwitch renderObject = (_RenderSwitch) renderObjectRaw;
renderObject.value = this.value;
renderObject.activeColor = this.activeColor;
renderObject.inactiveColor = this.inactiveColor;
renderObject.activeThumbImage = this.activeThumbImage;
renderObject.inactiveThumbImage = this.inactiveThumbImage;
renderObject.activeTrackColor = this.activeTrackColor;
renderObject.inactiveTrackColor = this.inactiveTrackColor;
renderObject.configuration = this.configuration;
renderObject.onChanged = this.onChanged;
renderObject.additionalConstraints = this.additionalConstraints;
renderObject.vsync = this.vsync;
}
}
class _RenderSwitch : RenderToggleable {
public _RenderSwitch(
bool? value = null,
Color activeColor = null,
Color inactiveColor = null,
ImageProvider activeThumbImage = null,
ImageProvider inactiveThumbImage = null,
Color activeTrackColor = null,
Color inactiveTrackColor = null,
ImageConfiguration configuration = null,
BoxConstraints additionalConstraints = null,
ValueChanged<bool?> onChanged = null,
TickerProvider vsync = null
) : base(
value: value,
tristate: false,
activeColor: activeColor,
inactiveColor: inactiveColor,
onChanged: onChanged,
additionalConstraints: additionalConstraints,
vsync: vsync
) {
this._activeThumbImage = activeThumbImage;
this._inactiveThumbImage = inactiveThumbImage;
this._activeTrackColor = activeTrackColor;
this._inactiveTrackColor = inactiveTrackColor;
this._configuration = configuration;
this._drag = new HorizontalDragGestureRecognizer {
onStart = this._handleDragStart,
onUpdate = this._handleDragUpdate,
onEnd = this._handleDragEnd,
};
}
public ImageProvider activeThumbImage {
get { return this._activeThumbImage; }
set {
if (value == this._activeThumbImage) {
return;
}
this._activeThumbImage = value;
this.markNeedsPaint();
}
}
ImageProvider _activeThumbImage;
public ImageProvider inactiveThumbImage {
get { return this._inactiveThumbImage; }
set {
if (value == this._inactiveThumbImage) {
return;
}
this._inactiveThumbImage = value;
this.markNeedsPaint();
}
}
ImageProvider _inactiveThumbImage;
public Color activeTrackColor {
get { return this._activeTrackColor; }
set {
D.assert(value != null);
if (value == this._activeTrackColor) {
return;
}
this._activeTrackColor = value;
this.markNeedsPaint();
}
}
Color _activeTrackColor;
public Color inactiveTrackColor {
get { return this._inactiveTrackColor; }
set {
D.assert(value != null);
if (value == this._inactiveTrackColor) {
return;
}
this._inactiveTrackColor = value;
this.markNeedsPaint();
}
}
Color _inactiveTrackColor;
public ImageConfiguration configuration {
get { return this._configuration; }
set {
D.assert(value != null);
if (value == this._configuration) {
return;
}
this._configuration = value;
this.markNeedsPaint();
}
}
ImageConfiguration _configuration;
public override void detach() {
this._cachedThumbPainter?.Dispose();
this._cachedThumbPainter = null;
base.detach();
}
float _trackInnerLength {
get { return this.size.width - 2.0f * Constants.kRadialReactionRadius; }
}
HorizontalDragGestureRecognizer _drag;
void _handleDragStart(DragStartDetails details) {
if (this.isInteractive) {
this.reactionController.forward();
}
}
void _handleDragUpdate(DragUpdateDetails details) {
if (this.isInteractive) {
this.position.curve = null;
this.position.reverseCurve = null;
float delta = details.primaryDelta.Value / this._trackInnerLength;
this.positionController.setValue(this.positionController.value + delta);
}
}
void _handleDragEnd(DragEndDetails details) {
if (this.position.value >= 0.5) {
this.positionController.forward();
} else {
this.positionController.reverse();
}
this.reactionController.reverse();
}
public override void handleEvent(PointerEvent evt, HitTestEntry entry) {
D.assert(this.debugHandleEvent(evt, entry));
if (evt is PointerDownEvent && this.onChanged != null) {
this._drag.addPointer((PointerDownEvent) evt);
}
base.handleEvent(evt, entry);
}
Color _cachedThumbColor;
ImageProvider _cachedThumbImage;
BoxPainter _cachedThumbPainter;
BoxDecoration _createDefaultThumbDecoration(Color color, ImageProvider image) {
return new BoxDecoration(
color: color,
image: image == null ? null : new DecorationImage(image: image),
shape: BoxShape.circle,
boxShadow: ShadowConstants.kElevationToShadow[1]
);
}
bool _isPainting = false;
void _handleDecorationChanged() {
if (!this._isPainting) {
this.markNeedsPaint();
}
}
public override void paint(PaintingContext context, Offset offset) {
Canvas canvas = context.canvas;
bool isActive = this.onChanged != null;
float currentValue = this.position.value;
float visualPosition = currentValue;
Color trackColor = isActive
? Color.lerp(this.inactiveTrackColor, this.activeTrackColor, currentValue)
: this.inactiveTrackColor;
// Paint the track
Paint paint = new Paint {color = trackColor};
float trackHorizontalPadding = Constants.kRadialReactionRadius - Switch._kTrackRadius;
Rect trackRect = Rect.fromLTWH(
offset.dx + trackHorizontalPadding,
offset.dy + (this.size.height - Switch._kTrackHeight) / 2.0f,
this.size.width - 2.0f * trackHorizontalPadding,
Switch._kTrackHeight
);
RRect trackRRect = RRect.fromRectAndRadius(trackRect, Radius.circular(Switch._kTrackRadius));
canvas.drawRRect(trackRRect, paint);
Offset thumbPosition = new Offset(
Constants.kRadialReactionRadius + visualPosition * this._trackInnerLength,
this.size.height / 2.0f
);
this.paintRadialReaction(canvas, offset, thumbPosition);
try {
this._isPainting = true;
BoxPainter thumbPainter;
Color thumbColor = isActive
? Color.lerp(this.inactiveColor, this.activeColor, currentValue)
: this.inactiveColor;
ImageProvider thumbImage = isActive
? (currentValue < 0.5 ? this.inactiveThumbImage : this.activeThumbImage)
: this.inactiveThumbImage;
if (this._cachedThumbPainter == null || thumbColor != this._cachedThumbColor ||
thumbImage != this._cachedThumbImage) {
this._cachedThumbColor = thumbColor;
this._cachedThumbImage = thumbImage;
this._cachedThumbPainter = this._createDefaultThumbDecoration(thumbColor, thumbImage)
.createBoxPainter(this._handleDecorationChanged);
}
thumbPainter = this._cachedThumbPainter;
float inset = 1.0f - (currentValue - 0.5f).abs() * 2.0f;
float radius = Switch._kThumbRadius - inset;
thumbPainter.paint(
canvas,
thumbPosition + offset - new Offset(radius, radius),
this.configuration.copyWith(size: Size.fromRadius(radius))
);
} finally {
this._isPainting = false;
}
}
}
}

11
Runtime/material/switch.cs.meta


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

153
Runtime/material/timer.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public enum DayPeriod {
am,
pm,
}
public class TimeOfDay : IEquatable<TimeOfDay> {
public TimeOfDay(int hour, int minute) {
this.hour = hour;
this.minute = minute;
}
public static TimeOfDay fromDateTime(DateTime time) {
return new TimeOfDay(
hour: time.Hour,
minute: time.Minute
);
}
public static TimeOfDay now() {
return TimeOfDay.fromDateTime(DateTime.Now);
}
public static readonly int hoursPerDay = 24;
public static readonly int hoursPerPeriod = 12;
public static readonly int minutesPerHour = 60;
public TimeOfDay replacing(int? hour = null, int? minute = null) {
D.assert(hour == null || (hour >= 0 && hour < hoursPerDay));
D.assert(minute == null || (minute >= 0 && minute < minutesPerHour));
return new TimeOfDay(hour: hour ?? this.hour, minute: minute ?? this.minute);
}
public readonly int hour;
public readonly int minute;
public DayPeriod period {
get { return this.hour < hoursPerPeriod ? DayPeriod.am : DayPeriod.pm; }
}
public int hourOfPeriod {
get { return this.hour - this.periodOffset; }
}
public int periodOffset {
get { return this.period == DayPeriod.am ? 0 : hoursPerPeriod; }
}
public string format(BuildContext context) {
D.assert(WidgetsD.debugCheckHasMediaQuery(context));
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
MaterialLocalizations localizations = MaterialLocalizations.of(context);
return localizations.formatTimeOfDay(
this,
alwaysUse24HourFormat: MediaQuery.of(context).alwaysUse24HourFormat
);
}
static string _addLeadingZeroIfNeeded(int value) {
if (value < 10) {
return "0" + value;
}
return value.ToString();
}
public bool Equals(TimeOfDay other) {
if (ReferenceEquals(null, other)) {
return false;
}
if (ReferenceEquals(this, other)) {
return true;
}
return this.hour == other.hour && this.minute == other.minute;
}
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((TimeOfDay) obj);
}
public override int GetHashCode() {
unchecked {
return (this.hour * 397) ^ this.minute;
}
}
public static bool operator ==(TimeOfDay left, TimeOfDay right) {
return Equals(left, right);
}
public static bool operator !=(TimeOfDay left, TimeOfDay right) {
return !Equals(left, right);
}
public override string ToString() {
string hourLabel = _addLeadingZeroIfNeeded(this.hour);
string minuteLabel = _addLeadingZeroIfNeeded(this.minute);
return $"TimeOfDay({hourLabel}:{minuteLabel})";
}
}
public enum TimeOfDayFormat {
HH_colon_mm,
HH_dot_mm,
frenchCanadian,
H_colon_mm,
h_colon_mm_space_a,
a_space_h_colon_mm,
}
public enum HourFormat {
HH,
H,
h,
}
public static class HourFormatUtils {
public static HourFormat hourFormat(TimeOfDayFormat of) {
switch (of) {
case TimeOfDayFormat.h_colon_mm_space_a:
case TimeOfDayFormat.a_space_h_colon_mm:
return HourFormat.h;
case TimeOfDayFormat.H_colon_mm:
return HourFormat.H;
case TimeOfDayFormat.HH_dot_mm:
case TimeOfDayFormat.HH_colon_mm:
case TimeOfDayFormat.frenchCanadian:
return HourFormat.HH;
}
throw new Exception("unknown format: " + of);
}
}
}

11
Runtime/material/timer.cs.meta


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

317
Runtime/material/toggleable.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
static class ToggleableUtils {
public static readonly TimeSpan _kToggleDuration = new TimeSpan(0, 0, 0, 0, 200);
public static readonly Animatable<float> _kRadialReactionRadiusTween =
new FloatTween(begin: 0.0f, end: Constants.kRadialReactionRadius);
}
public abstract class RenderToggleable : RenderConstrainedBox {
protected RenderToggleable(
bool? value = null,
bool tristate = false,
Color activeColor = null,
Color inactiveColor = null,
ValueChanged<bool?> onChanged = null,
BoxConstraints additionalConstraints = null,
TickerProvider vsync = null
) : base(additionalConstraints: additionalConstraints) {
D.assert(tristate || value != null);
D.assert(activeColor != null);
D.assert(inactiveColor != null);
D.assert(vsync != null);
this._value = value;
this._tristate = tristate;
this._activeColor = activeColor;
this._inactiveColor = inactiveColor;
this._onChanged = onChanged;
this._vsync = vsync;
this._tap = new TapGestureRecognizer {
onTapDown = this._handleTapDown,
onTap = this._handleTap,
onTapUp = this._handleTapUp,
onTapCancel = this._handleTapCancel
};
this._positionController = new AnimationController(
duration: ToggleableUtils._kToggleDuration,
value: value == false ? 0.0f : 1.0f,
vsync: vsync);
this._position = new CurvedAnimation(
parent: this._positionController,
curve: Curves.linear);
this._position.addListener(this.markNeedsPaint);
this._position.addStatusListener(this._handlePositionStateChanged);
this._reactionController = new AnimationController(
duration: Constants.kRadialReactionDuration,
vsync: vsync);
this._reaction = new CurvedAnimation(
parent: this._reactionController,
curve: Curves.fastOutSlowIn);
this._reaction.addListener(this.markNeedsPaint);
}
protected AnimationController positionController {
get { return this._positionController; }
}
AnimationController _positionController;
public CurvedAnimation position {
get { return this._position; }
}
CurvedAnimation _position;
protected AnimationController reactionController {
get { return this._reactionController; }
}
AnimationController _reactionController;
Animation<float> _reaction;
public TickerProvider vsync {
get { return this._vsync; }
set {
D.assert(value != null);
if (value == this._vsync) {
return;
}
this._vsync = value;
this.positionController.resync(this.vsync);
this.reactionController.resync(this.vsync);
}
}
TickerProvider _vsync;
public bool? value {
get { return this._value; }
set {
D.assert(this.tristate || value != null);
if (value == this._value) {
return;
}
this._value = value;
this._position.curve = Curves.easeIn;
this._position.reverseCurve = Curves.easeOut;
if (this.tristate) {
switch (this._positionController.status) {
case AnimationStatus.forward:
case AnimationStatus.completed: {
this._positionController.reverse();
break;
}
default: {
this._positionController.forward();
break;
}
}
}
else {
if (value == true) {
this._positionController.forward();
}
else {
this._positionController.reverse();
}
}
}
}
bool? _value;
public bool tristate {
get { return this._tristate; }
set {
if (value == this._tristate) {
return;
}
this._tristate = value;
}
}
bool _tristate;
public Color activeColor {
get { return this._activeColor; }
set {
D.assert(value != null);
if (value == this._activeColor) {
return;
}
this._activeColor = value;
this.markNeedsPaint();
}
}
Color _activeColor;
public Color inactiveColor {
get { return this._inactiveColor; }
set {
D.assert(value != null);
if (value == this._inactiveColor) {
return;
}
this._inactiveColor = value;
this.markNeedsPaint();
}
}
Color _inactiveColor;
public ValueChanged<bool?> onChanged {
get { return this._onChanged; }
set {
if (value == this._onChanged) {
return;
}
bool wasInteractive = this.isInteractive;
this._onChanged = value;
if (wasInteractive != this.isInteractive) {
this.markNeedsPaint();
}
}
}
ValueChanged<bool?> _onChanged;
public bool isInteractive {
get { return this.onChanged != null; }
}
TapGestureRecognizer _tap;
Offset _downPosition;
public override void attach(object owner) {
base.attach(owner);
if (this.value == false) {
this._positionController.reverse();
}
else {
this._positionController.forward();
}
if (this.isInteractive) {
switch (this._reactionController.status) {
case AnimationStatus.forward: {
this._reactionController.forward();
break;
}
case AnimationStatus.reverse: {
this._reactionController.reverse();
break;
}
case AnimationStatus.dismissed:
case AnimationStatus.completed: {
break;
}
}
}
}
public override void detach() {
this._positionController.stop();
this._reactionController.stop();
base.detach();
}
void _handlePositionStateChanged(AnimationStatus status) {
if (this.isInteractive && !this.tristate) {
if (status == AnimationStatus.completed && this._value == false) {
this.onChanged(true);
}
else if (status == AnimationStatus.dismissed && this._value != false) {
this.onChanged(false);
}
}
}
void _handleTapDown(TapDownDetails details) {
if (this.isInteractive) {
this._downPosition = this.globalToLocal(details.globalPosition);
this._reactionController.forward();
}
}
void _handleTap() {
if (!this.isInteractive) {
return;
}
switch (this.value) {
case false:
this.onChanged(true);
break;
case true:
this.onChanged(this.tristate ? (bool?) null : false);
break;
default:
this.onChanged(false);
break;
}
}
void _handleTapUp(TapUpDetails details) {
this._downPosition = null;
if (this.isInteractive) {
this._reactionController.reverse();
}
}
void _handleTapCancel() {
this._downPosition = null;
if (this.isInteractive) {
this._reactionController.reverse();
}
}
protected override bool hitTestSelf(Offset position) {
return true;
}
public override void handleEvent(PointerEvent pEvent, HitTestEntry entry) {
D.assert(this.debugHandleEvent(pEvent, entry));
if (pEvent is PointerDownEvent && this.isInteractive) {
this._tap.addPointer((PointerDownEvent) pEvent);
}
}
public void paintRadialReaction(Canvas canvas, Offset offset, Offset origin) {
if (!this._reaction.isDismissed) {
Paint reactionPaint = new Paint {color = this.activeColor.withAlpha(Constants.kRadialReactionAlpha)};
Offset center = Offset.lerp(this._downPosition ?? origin, origin, this._reaction.value);
float radius = ToggleableUtils._kRadialReactionRadiusTween.evaluate(this._reaction);
canvas.drawCircle(center + offset, radius, reactionPaint);
}
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FlagProperty("value", value: this.value, ifTrue: "checked", ifFalse: "unchecked",
showName: true));
properties.add(new FlagProperty("isInteractive", value: this.isInteractive, ifTrue: "enabled",
ifFalse: "disabled", defaultValue: true));
}
}
}

11
Runtime/material/toggleable.cs.meta


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

81
Runtime/rendering/performance_overlay.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.rendering {
public enum PerformanceOverlayOption {
drawFPS, //default
drawFrameCost
}
public class RenderPerformanceOverlay : RenderBox {
public RenderPerformanceOverlay(
int optionsMask = 0
) {
this._optionMask = optionsMask;
}
public int optionsMask {
get { return this._optionMask; }
set {
if (value == this._optionMask) {
return;
}
this._optionMask = value;
this.markNeedsPaint();
}
}
int _optionMask;
protected override bool sizedByParent {
get { return true; }
}
protected override bool alwaysNeedsCompositing {
get { return true; }
}
protected override float computeMinIntrinsicWidth(float height) {
return 0.0f;
}
protected override float computeMaxIntrinsicWidth(float height) {
return 0.0f;
}
float _intrinsicHeight {
get {
const float kDefaultGraphHeight = 80.0f;
float result = 20f;
if ((this.optionsMask | (1 << (int) PerformanceOverlayOption.drawFrameCost)) > 0) {
result += kDefaultGraphHeight;
}
return result;
}
}
protected override float computeMinIntrinsicHeight(float width) {
return this._intrinsicHeight;
}
protected override float computeMaxIntrinsicHeight(float width) {
return this._intrinsicHeight;
}
protected override void performResize() {
this.size = this.constraints.constrain(new Size(float.PositiveInfinity, this._intrinsicHeight));
}
public override void paint(PaintingContext context, Offset offset) {
D.assert(this.needsCompositing);
context.addLayer(new PerformanceOverlayLayer(
overlayRect: Rect.fromLTWH(offset.dx, offset.dy, this.size.width, this.size.height),
optionsMask: this.optionsMask
));
}
}
}

11
Runtime/rendering/performance_overlay.cs.meta


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

58
Runtime/rendering/texture.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using UnityEngine;
using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.rendering {
public class TextureBox : RenderBox {
public TextureBox(Texture texture) {
D.assert(texture != null);
this._texture = texture;
}
public Texture texture {
get { return this._texture; }
set {
D.assert(value != null);
if (value != this._texture) {
this._texture = value;
this.markNeedsPaint();
}
}
}
Texture _texture;
protected override bool sizedByParent {
get { return true; }
}
protected override bool alwaysNeedsCompositing {
get { return true; }
}
public override bool isRepaintBoundary {
get { return true; }
}
protected override void performResize() {
this.size = this.constraints.biggest;
}
protected override bool hitTestSelf(Offset position) {
return true;
}
public override void paint(PaintingContext context, Offset offset) {
if (this._texture == null) {
return;
}
context.addLayer(new TextureLayer(
rect: Rect.fromLTWH(offset.dx, offset.dy, this.size.width, this.size.height),
texture: this._texture
));
}
}
}

11
Runtime/rendering/texture.cs.meta


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

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

正在加载...
取消
保存