fzhangtj
6 年前
当前提交
ece17ad8
共有 144 个文件被更改,包括 5941 次插入 和 520 次删除
-
12.gitignore
-
7.npmignore
-
6CHANGELOG.md
-
28CONTRIBUTING.md
-
27LICENSE.md
-
25README.md
-
46Runtime/animation/listener_helpers.mixin.gen.cs
-
27Runtime/editor/editor_window.cs
-
5Runtime/engine/UIWidgetsPanel.cs
-
31Runtime/foundation/node.mixin.gen.cs
-
8Runtime/foundation/node.mixin.njk
-
30Runtime/material/arc.cs
-
44Runtime/material/button_theme.cs
-
3Runtime/material/color_scheme.cs
-
10Runtime/material/constants.cs
-
53Runtime/material/debug.cs
-
8Runtime/material/drawer.cs
-
7Runtime/material/drawer_header.cs
-
2Runtime/material/expand_icon.cs
-
6Runtime/material/expansion_panel.cs
-
5Runtime/material/expansion_tile.cs
-
8Runtime/material/icon_button.cs
-
998Runtime/material/icons.cs
-
2Runtime/material/ink_decoration.cs
-
5Runtime/material/ink_highlight.cs
-
43Runtime/material/ink_ripple.cs
-
52Runtime/material/ink_splash.cs
-
2Runtime/material/ink_well.cs
-
2Runtime/material/list_tile.cs
-
14Runtime/material/material.cs
-
10Runtime/material/scrollbar.cs
-
3Runtime/material/text_theme.cs
-
6Runtime/material/theme.cs
-
224Runtime/material/theme_data.cs
-
7Runtime/material/tooltip.cs
-
1Runtime/painting/image_resolution.cs
-
7Runtime/promise/Promise_NonGeneric.cs
-
3Runtime/rendering/binding.cs
-
8Runtime/rendering/box.cs
-
18Runtime/rendering/box.mixin.gen.cs
-
68Runtime/rendering/layer.cs
-
88Runtime/rendering/object.mixin.gen.cs
-
157Runtime/rendering/proxy_box.cs
-
20Runtime/rendering/proxy_box.mixin.gen.cs
-
27Runtime/scheduler/binding.cs
-
36Runtime/ui/compositing.cs
-
4Runtime/ui/geometry.cs
-
39Runtime/ui/painting/canvas.cs
-
6Runtime/ui/painting/canvas_impl.cs
-
170Runtime/ui/painting/path.cs
-
16Runtime/ui/window.cs
-
23Runtime/widgets/app.cs
-
117Runtime/widgets/automatic_keep_alive.cs
-
179Runtime/widgets/basic.cs
-
30Runtime/widgets/debug.cs
-
10Runtime/widgets/framework.cs
-
71Runtime/widgets/implicit_animations.cs
-
3Runtime/widgets/layout_builder.cs
-
256Runtime/widgets/navigator.cs
-
6Runtime/widgets/pages.cs
-
13Runtime/widgets/routes.cs
-
60Runtime/widgets/safe_area.cs
-
4Runtime/widgets/scroll_notification.mixin.gen.cs
-
2Runtime/widgets/ticker_provider.cs
-
2Runtime/widgets/transitions.cs
-
9Samples/UIWidgetSample/AsScreenSample.cs
-
30Samples/UIWidgetSample/MaterialSample.cs
-
3Samples/UIWidgetSample/NavigationSample.cs
-
29Tests/Editor/CanvasAndLayers.cs
-
15Tests/Editor/Widgets.cs
-
32Third Party Notices.md
-
8package.json
-
95Runtime/flow/performance_overlay_layer.cs
-
11Runtime/flow/performance_overlay_layer.cs.meta
-
51Runtime/flow/texture_layer.cs
-
11Runtime/flow/texture_layer.cs.meta
-
135Runtime/material/app.cs
-
11Runtime/material/app.cs.meta
-
274Runtime/material/dialog.cs
-
11Runtime/material/dialog.cs.meta
-
69Runtime/material/dialog_theme.cs
-
11Runtime/material/dialog_theme.cs.meta
-
390Runtime/material/material_localizations.cs
-
11Runtime/material/material_localizations.cs.meta
-
62Runtime/material/page.cs
-
11Runtime/material/page.cs.meta
-
151Runtime/material/page_transitions_theme.cs
-
11Runtime/material/page_transitions_theme.cs.meta
-
608Runtime/material/popup_menu.cs
-
11Runtime/material/popup_menu.cs.meta
-
527Runtime/material/switch.cs
-
11Runtime/material/switch.cs.meta
-
153Runtime/material/timer.cs
-
11Runtime/material/timer.cs.meta
-
317Runtime/material/toggleable.cs
-
11Runtime/material/toggleable.cs.meta
-
81Runtime/rendering/performance_overlay.cs
-
11Runtime/rendering/performance_overlay.cs.meta
-
58Runtime/rendering/texture.cs
-
11Runtime/rendering/texture.cs.meta
|
|||
# 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. |
|
|||
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. |
998
Runtime/material/icons.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
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. |
|
|||
{ |
|||
"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": { |
|||
} |
|||
} |
|
|||
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)); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8abf5cb3d8e90423fb0d2476c8dea244 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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()); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 58b198e3ad2fc48dd999a86390611092 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ed3c6aaa36fe54da5b914d3d605903ae |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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 |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 813c881d6861d4a4c899bbd38814134c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 555377d80e88a41b9b9918d8114897ab |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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(); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d140c1ef287754af7adf006964153c07 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0cf29b47589d9439eb891ee6bad724ea |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 847b0cfefeda84e378cd9c72432d109c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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 |
|||
); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ce8e103e04e044eeaa81c9c2ade4369b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4d9cbabd047e4459c890af24af812425 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: eeb5dc81b18e644e69b2b89cf48b8f3b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 79635a8e998444b9ba9cbab4db395efc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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 |
|||
)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2e3164a1dd18d4b4fb226e57522bb7ca |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
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 |
|||
)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6752d156317e44036a1924d168ded7e9 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue