浏览代码
Merge branch 'siyaoH/skiaBase' of https://github.com/Unity-Technologies/com.unity.uiwidgets into zxw/skiaBase
Merge branch 'siyaoH/skiaBase' of https://github.com/Unity-Technologies/com.unity.uiwidgets into zxw/skiaBase
# Conflicts: # com.unity.uiwidgets/Runtime/rendering/editable.cs/siyaoH-1.17-PlatformMessage
xingweizhu
4 年前
当前提交
6fd6d3fa
共有 263 个文件被更改,包括 1289 次插入 和 2219 次删除
-
17Samples/UIWidgetsSamples_2019_4/Assets/TextTest.cs
-
4com.unity.uiwidgets/Runtime/animation/animation_controller.cs
-
4com.unity.uiwidgets/Runtime/async2/future.cs
-
3com.unity.uiwidgets/Runtime/external/SplayTree.cs
-
1com.unity.uiwidgets/Runtime/foundation/binding.cs
-
1com.unity.uiwidgets/Runtime/foundation/debug.cs
-
70com.unity.uiwidgets/Runtime/material/colors.cs
-
71com.unity.uiwidgets/Runtime/painting/alignment.cs
-
1com.unity.uiwidgets/Runtime/painting/binding.cs
-
19com.unity.uiwidgets/Runtime/painting/box_decoration.cs
-
2com.unity.uiwidgets/Runtime/painting/colors.cs
-
6com.unity.uiwidgets/Runtime/painting/decoration_image.cs
-
59com.unity.uiwidgets/Runtime/painting/gradient.cs
-
148com.unity.uiwidgets/Runtime/painting/image_provider.cs
-
8com.unity.uiwidgets/Runtime/painting/image_resolution.cs
-
32com.unity.uiwidgets/Runtime/painting/image_stream.cs
-
36com.unity.uiwidgets/Runtime/painting/matrix_utils.cs
-
7com.unity.uiwidgets/Runtime/painting/shader_warmup.cs
-
2com.unity.uiwidgets/Runtime/painting/strut_style.cs
-
239com.unity.uiwidgets/Runtime/painting/text_painter.cs
-
190com.unity.uiwidgets/Runtime/painting/text_span.cs
-
40com.unity.uiwidgets/Runtime/painting/text_style.cs
-
6com.unity.uiwidgets/Runtime/rendering/debug_overflow_indicator.cs
-
122com.unity.uiwidgets/Runtime/rendering/editable.cs
-
18com.unity.uiwidgets/Runtime/rendering/image.cs
-
20com.unity.uiwidgets/Runtime/rendering/paragraph.cs
-
12com.unity.uiwidgets/Runtime/rendering/viewport_offset.cs
-
12com.unity.uiwidgets/Runtime/service/clipboard.cs
-
182com.unity.uiwidgets/Runtime/service/text_editing.cs
-
4com.unity.uiwidgets/Runtime/service/text_input.cs
-
4com.unity.uiwidgets/Runtime/ui/painting/codec.cs
-
2com.unity.uiwidgets/Runtime/ui2/painting.cs
-
89com.unity.uiwidgets/Runtime/ui2/window.cs
-
1com.unity.uiwidgets/Runtime/widgets/animated_switcher.cs
-
19com.unity.uiwidgets/Runtime/widgets/app.cs
-
4com.unity.uiwidgets/Runtime/widgets/automatic_keep_alive.cs
-
1com.unity.uiwidgets/Runtime/widgets/basic.cs
-
46com.unity.uiwidgets/Runtime/widgets/binding.cs
-
12com.unity.uiwidgets/Runtime/widgets/dismissible.cs
-
26com.unity.uiwidgets/Runtime/widgets/editable_text.cs
-
15com.unity.uiwidgets/Runtime/widgets/focus_manager.cs
-
21com.unity.uiwidgets/Runtime/widgets/image.cs
-
11com.unity.uiwidgets/Runtime/widgets/list_wheel_scroll_view.cs
-
42com.unity.uiwidgets/Runtime/widgets/localizations.cs
-
1com.unity.uiwidgets/Runtime/widgets/media_query.cs
-
65com.unity.uiwidgets/Runtime/widgets/navigator.cs
-
10com.unity.uiwidgets/Runtime/widgets/nested_scroll_view.cs
-
9com.unity.uiwidgets/Runtime/widgets/overscroll_indicator.cs
-
8com.unity.uiwidgets/Runtime/widgets/page_view.cs
-
105com.unity.uiwidgets/Runtime/widgets/routes.cs
-
16com.unity.uiwidgets/Runtime/widgets/scroll_activity.cs
-
8com.unity.uiwidgets/Runtime/widgets/scroll_controller.cs
-
10com.unity.uiwidgets/Runtime/widgets/scroll_position.cs
-
6com.unity.uiwidgets/Runtime/widgets/scroll_position_with_single_context.cs
-
15com.unity.uiwidgets/Runtime/widgets/scrollable.cs
-
25com.unity.uiwidgets/Runtime/widgets/selectable_text.cs
-
1com.unity.uiwidgets/Runtime/widgets/text.cs
-
20com.unity.uiwidgets/Runtime/widgets/text_selection.cs
-
16com.unity.uiwidgets/Runtime/widgets/texture.cs
-
16com.unity.uiwidgets/Runtime/widgets/widget_inspector.cs
-
5engine/src/lib/ui/window/window.cc
-
206com.unity.uiwidgets/Runtime/painting/inline_span.cs
-
8Samples/UIWidgetsSamples_2019_4/Assets/Editor.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/RaycastableSample.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/ReduxSample.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/Resources.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/Scenes.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsGallery.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsSample.meta
-
8Samples/UIWidgetsSamples_2019_4/Assets/UIWidgetsTheatre.meta
-
204com.unity.uiwidgets/Runtime/material/text_selection.cs
-
11com.unity.uiwidgets/Runtime/material/text_selection.cs.meta
-
11com.unity.uiwidgets/Runtime/material/button.cs.meta
-
11com.unity.uiwidgets/Runtime/material/button_theme.cs.meta
-
352com.unity.uiwidgets/Runtime/material/color_scheme.cs
-
11com.unity.uiwidgets/Runtime/material/color_scheme.cs.meta
-
11com.unity.uiwidgets/Runtime/material/colors.cs.meta
-
26com.unity.uiwidgets/Runtime/material/constants.cs
-
11com.unity.uiwidgets/Runtime/material/constants.cs.meta
-
11com.unity.uiwidgets/Runtime/material/debug.cs.meta
-
11com.unity.uiwidgets/Runtime/material/ink_decoration.cs.meta
-
11com.unity.uiwidgets/Runtime/material/ink_highlight.cs.meta
-
11com.unity.uiwidgets/Runtime/material/ink_splash.cs.meta
-
11com.unity.uiwidgets/Runtime/material/ink_well.cs.meta
-
11com.unity.uiwidgets/Runtime/material/material.cs.meta
-
11com.unity.uiwidgets/Runtime/material/material_button.cs.meta
-
371com.unity.uiwidgets/Runtime/material/text_theme.cs
-
11com.unity.uiwidgets/Runtime/material/text_theme.cs.meta
-
147com.unity.uiwidgets/Runtime/material/theme.cs
-
11com.unity.uiwidgets/Runtime/material/theme.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.painting { |
|||
public class Accumulator { |
|||
public Accumulator(int _value = 0) { |
|||
this._value = _value; |
|||
} |
|||
|
|||
public int value { |
|||
get { return _value; } |
|||
} |
|||
|
|||
int _value; |
|||
|
|||
public void increment(int addend) { |
|||
D.assert(addend >= 0); |
|||
_value += addend; |
|||
} |
|||
} |
|||
|
|||
public delegate bool InlineSpanVisitor(InlineSpan span); |
|||
|
|||
public delegate bool TextSpanVisitor(TextSpan span); |
|||
|
|||
public class InlineSpanSemanticsInformation : IEquatable<InlineSpanSemanticsInformation> { |
|||
public InlineSpanSemanticsInformation( |
|||
string text, |
|||
bool isPlaceholder = false, |
|||
string semanticsLabel = null, |
|||
GestureRecognizer recognizer = null |
|||
) { |
|||
D.assert(text != null); |
|||
D.assert(isPlaceholder != null); |
|||
D.assert(isPlaceholder == false || (text == "\uFFFC" && semanticsLabel == null && recognizer == null)); |
|||
requiresOwnNode = isPlaceholder || recognizer != null; |
|||
} |
|||
|
|||
public static readonly InlineSpanSemanticsInformation placeholder = |
|||
new InlineSpanSemanticsInformation("\uFFFC", isPlaceholder: true); |
|||
|
|||
public readonly string text; |
|||
|
|||
public readonly string semanticsLabel; |
|||
|
|||
public readonly GestureRecognizer recognizer; |
|||
|
|||
public readonly bool isPlaceholder; |
|||
|
|||
public readonly bool requiresOwnNode; |
|||
|
|||
|
|||
public override string ToString() => |
|||
$"{foundation_.objectRuntimeType(this, "InlineSpanSemanticsInformation")}" + |
|||
$"{text: $text, semanticsLabel: $semanticsLabel, recognizer: $recognizer}"; |
|||
|
|||
public bool Equals(InlineSpanSemanticsInformation other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return text == other.text && semanticsLabel == other.semanticsLabel && |
|||
Equals(recognizer, other.recognizer) && isPlaceholder == other.isPlaceholder; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((InlineSpanSemanticsInformation) obj); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = (text != null ? text.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (semanticsLabel != null ? semanticsLabel.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ (recognizer != null ? recognizer.GetHashCode() : 0); |
|||
hashCode = (hashCode * 397) ^ isPlaceholder.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
} |
|||
|
|||
public abstract class InlineSpan : DiagnosticableTree, IEquatable<InlineSpan> { |
|||
public InlineSpan( |
|||
TextStyle style = null |
|||
) { |
|||
this.style = style; |
|||
} |
|||
|
|||
public readonly TextStyle style; |
|||
|
|||
public abstract void build(ParagraphBuilder builder, |
|||
float textScaleFactor = 1, List<PlaceholderDimensions> dimensions = null |
|||
); |
|||
|
|||
public abstract bool visitChildren(InlineSpanVisitor visitor); |
|||
|
|||
public InlineSpan getSpanForPosition(TextPosition position) { |
|||
D.assert(debugAssertIsValid()); |
|||
Accumulator offset = new Accumulator(); |
|||
InlineSpan result = null; |
|||
visitChildren((InlineSpan span) => { |
|||
result = span.getSpanForPositionVisitor(position, offset); |
|||
return result == null; |
|||
}); |
|||
return result; |
|||
} |
|||
|
|||
protected abstract InlineSpan getSpanForPositionVisitor(TextPosition position, Accumulator offset); |
|||
|
|||
public string toPlainText( |
|||
bool includeSemanticsLabels = true, bool includePlaceholders = true) { |
|||
StringBuilder buffer = new StringBuilder(); |
|||
computeToPlainText(buffer, includeSemanticsLabels: includeSemanticsLabels, |
|||
includePlaceholders: includePlaceholders); |
|||
return buffer.ToString(); |
|||
} |
|||
|
|||
List<InlineSpanSemanticsInformation> getSemanticsInformation() { |
|||
List<InlineSpanSemanticsInformation> collector = new List<InlineSpanSemanticsInformation>(); |
|||
|
|||
computeSemanticsInformation(collector); |
|||
return collector; |
|||
} |
|||
|
|||
public abstract void computeSemanticsInformation(List<InlineSpanSemanticsInformation> collector); |
|||
|
|||
public abstract void computeToPlainText(StringBuilder buffer, |
|||
bool includeSemanticsLabels = true, bool includePlaceholders = true); |
|||
|
|||
public int? codeUnitAt(int index) { |
|||
if (index < 0) |
|||
return null; |
|||
Accumulator offset = new Accumulator(); |
|||
int? result = null; |
|||
visitChildren((InlineSpan span) => { |
|||
result = span.codeUnitAtVisitor(index, offset); |
|||
return result == null; |
|||
}); |
|||
return result; |
|||
} |
|||
|
|||
protected abstract int? codeUnitAtVisitor(int index, Accumulator offset); |
|||
|
|||
public bool debugAssertIsValid() => true; |
|||
public abstract RenderComparison compareTo(InlineSpan other); |
|||
|
|||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace; |
|||
if (style != null) { |
|||
style.debugFillProperties(properties); |
|||
} |
|||
} |
|||
|
|||
public bool Equals(InlineSpan other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return Equals(style, other.style); |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((InlineSpan) obj); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
return (style != null ? style.GetHashCode() : 0); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0ae90c343ee0e4f7daf768fe6383340f |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 611706478d8aa410983272ad601895d3 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4e70bfdbd732446138a5acef1423b347 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5d9b41f3c48f94f93b5aaf521adbe0bf |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 77196fe8699ab4d4ebcdcd40d51ad725 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 1bcee10b13adf455985ead00596cf877 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: d5570637d1b25467596ae3c19ff7f0b2 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3663814d042c44976a72d5fb8a41cdf9 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: b54f053c2c5d34691b30237abaf17e14 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
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 Canvas = Unity.UIWidgets.ui.Canvas; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using Rect = Unity.UIWidgets.ui.Rect; |
|||
using Transform = Unity.UIWidgets.widgets.Transform; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public static class MaterialUtils { |
|||
public static readonly TextSelectionControls materialTextSelectionControls = |
|||
new _MaterialTextSelectionControls(); |
|||
|
|||
internal const float _kHandleSize = 22.0f; |
|||
|
|||
internal const float _kToolbarScreenPadding = 8.0f; |
|||
|
|||
} |
|||
|
|||
class _TextSelectionToolbar : StatelessWidget { |
|||
public _TextSelectionToolbar(Key key = null, VoidCallback handleCut = null, |
|||
VoidCallback handleCopy = null, VoidCallback handlePaste = null, VoidCallback handleSelectAll = null) : base(key: key) { |
|||
this.handleCut = handleCut; |
|||
this.handleCopy = handleCopy; |
|||
this.handlePaste = handlePaste; |
|||
this.handleSelectAll = handleSelectAll; |
|||
} |
|||
|
|||
public readonly VoidCallback handleCut; |
|||
public readonly VoidCallback handleCopy; |
|||
public readonly VoidCallback handlePaste; |
|||
public readonly VoidCallback handleSelectAll; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
List<Widget> items = new List<Widget>(); |
|||
MaterialLocalizations localizations = MaterialLocalizations.of(context); |
|||
if (handleCut != null) { |
|||
items.Add(new FlatButton(child: new Text(localizations.cutButtonLabel), onPressed: handleCut)); |
|||
} |
|||
|
|||
if (handleCopy != null) { |
|||
items.Add(new FlatButton(child: new Text(localizations.copyButtonLabel), onPressed: handleCopy)); |
|||
} |
|||
|
|||
if (handlePaste != null) { |
|||
|
|||
items.Add(new FlatButton(child: new Text(localizations.pasteButtonLabel), onPressed: handlePaste)); |
|||
} |
|||
|
|||
if (handleSelectAll != null) { |
|||
items.Add(new FlatButton(child: new Text(localizations.selectAllButtonLabel), |
|||
onPressed: handleSelectAll)); |
|||
} |
|||
|
|||
return new Material( |
|||
elevation: 1.0f, |
|||
child: new Container( |
|||
color: new Color(0xFFEFEFEF), |
|||
height: 44.0f, child: new Row(mainAxisSize: MainAxisSize.min, children: items)) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _TextSelectionToolbarLayout : SingleChildLayoutDelegate { |
|||
internal _TextSelectionToolbarLayout(Size screenSize = null, Rect globalEditableRegion = null, |
|||
Offset position = null) { |
|||
this.screenSize = screenSize; |
|||
this.globalEditableRegion = globalEditableRegion; |
|||
this.position = position; |
|||
} |
|||
|
|||
public readonly Size screenSize; |
|||
public readonly Rect globalEditableRegion; |
|||
public readonly Offset position; |
|||
|
|||
public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { |
|||
return constraints.loosen(); |
|||
} |
|||
|
|||
public override Offset getPositionForChild(Size size, Size childSize) { |
|||
Offset globalPosition = globalEditableRegion.topLeft + position; |
|||
|
|||
float x = globalPosition.dx - childSize.width / 2.0f; |
|||
float y = globalPosition.dy - childSize.height; |
|||
|
|||
if (x < MaterialUtils._kToolbarScreenPadding) { |
|||
x = MaterialUtils._kToolbarScreenPadding; |
|||
} |
|||
else if (x + childSize.width > screenSize.width - MaterialUtils._kToolbarScreenPadding) { |
|||
x = screenSize.width - childSize.width - MaterialUtils._kToolbarScreenPadding; |
|||
} |
|||
|
|||
if (y < MaterialUtils._kToolbarScreenPadding) { |
|||
y = MaterialUtils._kToolbarScreenPadding; |
|||
} |
|||
else if (y + childSize.height > screenSize.height - MaterialUtils._kToolbarScreenPadding) { |
|||
y = screenSize.height - childSize.height - MaterialUtils._kToolbarScreenPadding; |
|||
} |
|||
|
|||
return new Offset(x, y); |
|||
} |
|||
|
|||
public override bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) { |
|||
return position != ((_TextSelectionToolbarLayout) oldDelegate).position; |
|||
} |
|||
} |
|||
|
|||
class _TextSelectionHandlePainter : AbstractCustomPainter { |
|||
internal _TextSelectionHandlePainter(Color color) { |
|||
this.color = color; |
|||
} |
|||
|
|||
public readonly Color color; |
|||
|
|||
public override void paint(Canvas canvas, Size size) { |
|||
Paint paint = new Paint(); |
|||
paint.color = color; |
|||
float radius = size.width / 2.0f; |
|||
canvas.drawCircle(new Offset(radius, radius), radius, paint); |
|||
canvas.drawRect(Rect.fromLTWH(0.0f, 0.0f, radius, radius), paint); |
|||
} |
|||
|
|||
|
|||
public override bool shouldRepaint(CustomPainter oldPainter) { |
|||
return color != ((_TextSelectionHandlePainter) oldPainter).color; |
|||
} |
|||
} |
|||
|
|||
class _MaterialTextSelectionControls : TextSelectionControls { |
|||
public override Size handleSize { |
|||
get { |
|||
return new Size(MaterialUtils._kHandleSize, |
|||
MaterialUtils._kHandleSize); |
|||
} |
|||
} |
|||
|
|||
public override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, Offset position, |
|||
TextSelectionDelegate selectionDelegate) { |
|||
return new ConstrainedBox( |
|||
constraints: BoxConstraints.tight(globalEditableRegion.size), |
|||
child: new CustomSingleChildLayout( |
|||
layoutDelegate: new _TextSelectionToolbarLayout( |
|||
MediaQuery.of(context).size, |
|||
globalEditableRegion, |
|||
position |
|||
), |
|||
child: new _TextSelectionToolbar( |
|||
handleCut: canCut(selectionDelegate) |
|||
? () => handleCut(selectionDelegate) |
|||
: (VoidCallback) null, |
|||
handleCopy: canCopy(selectionDelegate) |
|||
? () => handleCopy(selectionDelegate) |
|||
: (VoidCallback) null, |
|||
handlePaste: canPaste(selectionDelegate) |
|||
? () => handlePaste(selectionDelegate) |
|||
: (VoidCallback) null, |
|||
handleSelectAll: canSelectAll(selectionDelegate) |
|||
? () => handleSelectAll(selectionDelegate) |
|||
: (VoidCallback) null |
|||
) |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override Widget buildHandle(BuildContext context, TextSelectionHandleType type, float textLineHeight) { |
|||
Widget handle = new Padding( |
|||
padding: EdgeInsets.only(right: 26.0f, bottom: 26.0f), |
|||
child: new SizedBox( |
|||
width: MaterialUtils._kHandleSize, |
|||
height: MaterialUtils._kHandleSize, |
|||
child: new CustomPaint( |
|||
painter: new _TextSelectionHandlePainter( |
|||
color: Theme.of(context).textSelectionHandleColor |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
switch (type) { |
|||
case TextSelectionHandleType.left: // points up-right
|
|||
return new Transform( |
|||
transform: new Matrix4().rotationZ(Mathf.PI / 2), |
|||
child: handle |
|||
); |
|||
case TextSelectionHandleType.right: // points up-left
|
|||
return handle; |
|||
case TextSelectionHandleType.collapsed: // points up
|
|||
return new Transform( |
|||
transform: new Matrix4().rotationZ(Mathf.PI / 4), |
|||
child: handle |
|||
); |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 33685d6edaab14322aa1b854fdd7c3e6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5452e0dd1a19646fda9cc8dc0b388ee4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: c00e9535ad31f481cbe2b83d490d714d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class ColorScheme : Diagnosticable, IEquatable<ColorScheme> { |
|||
public ColorScheme( |
|||
Color primary, |
|||
Color primaryVariant, |
|||
Color secondary, |
|||
Color secondaryVariant, |
|||
Color surface, |
|||
Color background, |
|||
Color error, |
|||
Color onPrimary, |
|||
Color onSecondary, |
|||
Color onSurface, |
|||
Color onBackground, |
|||
Color onError, |
|||
Brightness brightness) { |
|||
D.assert(primary != null); |
|||
D.assert(primaryVariant != null); |
|||
D.assert(secondary != null); |
|||
D.assert(secondaryVariant != null); |
|||
D.assert(surface != null); |
|||
D.assert(background != null); |
|||
D.assert(error != null); |
|||
D.assert(onPrimary != null); |
|||
D.assert(onSecondary != null); |
|||
D.assert(onSurface != null); |
|||
D.assert(onBackground != null); |
|||
D.assert(onError != null); |
|||
|
|||
this.primary = primary; |
|||
this.primaryVariant = primaryVariant; |
|||
this.secondary = secondary; |
|||
this.secondaryVariant = secondaryVariant; |
|||
this.surface = surface; |
|||
this.background = background; |
|||
this.error = error; |
|||
this.onPrimary = onPrimary; |
|||
this.onSecondary = onSecondary; |
|||
this.onSurface = onSurface; |
|||
this.onBackground = onBackground; |
|||
this.onError = onError; |
|||
this.brightness = brightness; |
|||
} |
|||
|
|||
public static ColorScheme light( |
|||
Color primary = null, |
|||
Color primaryVariant = null, |
|||
Color secondary = null, |
|||
Color secondaryVariant = null, |
|||
Color surface = null, |
|||
Color background = null, |
|||
Color error = null, |
|||
Color onPrimary = null, |
|||
Color onSecondary = null, |
|||
Color onSurface = null, |
|||
Color onBackground = null, |
|||
Color onError = null, |
|||
Brightness brightness = Brightness.light |
|||
) { |
|||
primary = primary ?? new Color(0xFF6200EE); |
|||
primaryVariant = primaryVariant ?? new Color(0xFF3700B3); |
|||
secondary = secondary ?? new Color(0xFF03DAC6); |
|||
secondaryVariant = secondaryVariant ?? new Color(0xFF018786); |
|||
surface = surface ?? Colors.white; |
|||
background = background ?? Colors.white; |
|||
error = error ?? new Color(0xFFB00020); |
|||
onPrimary = onPrimary ?? Colors.white; |
|||
onSecondary = onSecondary ?? Colors.black; |
|||
onSurface = onSurface ?? Colors.black; |
|||
onBackground = onBackground ?? Colors.black; |
|||
onError = onError ?? Colors.white; |
|||
|
|||
return new ColorScheme( |
|||
primary: primary, |
|||
primaryVariant: primaryVariant, |
|||
secondary: secondary, |
|||
secondaryVariant: secondaryVariant, |
|||
surface: surface, |
|||
background: background, |
|||
error: error, |
|||
onPrimary: onPrimary, |
|||
onSecondary: onSecondary, |
|||
onSurface: onSurface, |
|||
onBackground: onBackground, |
|||
onError: onError, |
|||
brightness: brightness |
|||
); |
|||
} |
|||
|
|||
public static ColorScheme dark( |
|||
Color primary = null, |
|||
Color primaryVariant = null, |
|||
Color secondary = null, |
|||
Color secondaryVariant = null, |
|||
Color surface = null, |
|||
Color background = null, |
|||
Color error = null, |
|||
Color onPrimary = null, |
|||
Color onSecondary = null, |
|||
Color onSurface = null, |
|||
Color onBackground = null, |
|||
Color onError = null, |
|||
Brightness brightness = Brightness.dark |
|||
) { |
|||
primary = primary ?? new Color(0xFFBB86FC); |
|||
primaryVariant = primaryVariant ?? new Color(0xFF4B01D0); |
|||
secondary = secondary ?? new Color(0xFF03DAC6); |
|||
secondaryVariant = secondaryVariant ?? new Color(0xFF03DAC6); |
|||
surface = surface ?? Colors.black; |
|||
background = background ?? Colors.black; |
|||
error = error ?? new Color(0xFFB00020); |
|||
onPrimary = onPrimary ?? Colors.black; |
|||
onSecondary = onSecondary ?? Colors.black; |
|||
onSurface = onSurface ?? Colors.white; |
|||
onBackground = onBackground ?? Colors.white; |
|||
onError = onError ?? Colors.black; |
|||
|
|||
return new ColorScheme( |
|||
primary: primary, |
|||
primaryVariant: primaryVariant, |
|||
secondary: secondary, |
|||
secondaryVariant: secondaryVariant, |
|||
surface: surface, |
|||
background: background, |
|||
error: error, |
|||
onPrimary: onPrimary, |
|||
onSecondary: onSecondary, |
|||
onSurface: onSurface, |
|||
onBackground: onBackground, |
|||
onError: onError, |
|||
brightness: brightness |
|||
); |
|||
} |
|||
|
|||
public static ColorScheme fromSwatch( |
|||
MaterialColor primarySwatch = null, |
|||
Color primaryColorDark = null, |
|||
Color accentColor = null, |
|||
Color cardColor = null, |
|||
Color backgroundColor = null, |
|||
Color errorColor = null, |
|||
Brightness? brightness = Brightness.light) { |
|||
D.assert(brightness != null); |
|||
primarySwatch = primarySwatch ?? Colors.blue; |
|||
|
|||
bool isDark = brightness == Brightness.dark; |
|||
bool primaryIsDark = _brightnessFor(primarySwatch) == Brightness.dark; |
|||
Color secondary = accentColor ?? (isDark ? Colors.tealAccent[200] : primarySwatch); |
|||
bool secondaryIsDark = _brightnessFor(secondary) == Brightness.dark; |
|||
|
|||
return new ColorScheme( |
|||
primary: primarySwatch, |
|||
primaryVariant: primaryColorDark ?? (isDark ? Colors.black : primarySwatch[700]), |
|||
secondary: secondary, |
|||
secondaryVariant: isDark ? Colors.tealAccent[700] : primarySwatch[700], |
|||
surface: cardColor ?? (isDark ? Colors.grey[800] : Colors.white), |
|||
background: backgroundColor ?? (isDark ? Colors.grey[700] : primarySwatch[200]), |
|||
error: errorColor ?? Colors.red[700], |
|||
onPrimary: primaryIsDark ? Colors.white : Colors.black, |
|||
onSecondary: secondaryIsDark ? Colors.white : Colors.black, |
|||
onSurface: isDark ? Colors.white : Colors.black, |
|||
onBackground: primaryIsDark ? Colors.white : Colors.black, |
|||
onError: isDark ? Colors.black : Colors.white, |
|||
brightness: brightness ?? Brightness.light |
|||
); |
|||
} |
|||
|
|||
|
|||
static Brightness _brightnessFor(Color color) { |
|||
return ThemeData.estimateBrightnessForColor(color); |
|||
} |
|||
|
|||
|
|||
public readonly Color primary; |
|||
|
|||
public readonly Color primaryVariant; |
|||
|
|||
public readonly Color secondary; |
|||
|
|||
public readonly Color secondaryVariant; |
|||
|
|||
public readonly Color surface; |
|||
|
|||
public readonly Color background; |
|||
|
|||
public readonly Color error; |
|||
|
|||
public readonly Color onPrimary; |
|||
|
|||
public readonly Color onSecondary; |
|||
|
|||
public readonly Color onSurface; |
|||
|
|||
public readonly Color onBackground; |
|||
|
|||
public readonly Color onError; |
|||
|
|||
public readonly Brightness brightness; |
|||
|
|||
public ColorScheme copyWith( |
|||
Color primary = null, |
|||
Color primaryVariant = null, |
|||
Color secondary = null, |
|||
Color secondaryVariant = null, |
|||
Color surface = null, |
|||
Color background = null, |
|||
Color error = null, |
|||
Color onPrimary = null, |
|||
Color onSecondary = null, |
|||
Color onSurface = null, |
|||
Color onBackground = null, |
|||
Color onError = null, |
|||
Brightness? brightness = null) { |
|||
return new ColorScheme( |
|||
primary: primary ?? this.primary, |
|||
primaryVariant: primaryVariant ?? this.primaryVariant, |
|||
secondary: secondary ?? this.secondary, |
|||
secondaryVariant: secondaryVariant ?? this.secondaryVariant, |
|||
surface: surface ?? this.surface, |
|||
background: background ?? this.background, |
|||
error: error ?? this.error, |
|||
onPrimary: onPrimary ?? this.onPrimary, |
|||
onSecondary: onSecondary ?? this.onSecondary, |
|||
onSurface: onSurface ?? this.onSurface, |
|||
onBackground: onBackground ?? this.onBackground, |
|||
onError: onError ?? this.onError, |
|||
brightness: brightness ?? this.brightness |
|||
); |
|||
} |
|||
|
|||
public static ColorScheme lerp(ColorScheme a, ColorScheme b, float t) { |
|||
return new ColorScheme( |
|||
primary: Color.lerp(a.primary, b.primary, t), |
|||
primaryVariant: Color.lerp(a.primaryVariant, b.primaryVariant, t), |
|||
secondary: Color.lerp(a.secondary, b.secondary, t), |
|||
secondaryVariant: Color.lerp(a.secondaryVariant, b.secondaryVariant, t), |
|||
surface: Color.lerp(a.surface, b.surface, t), |
|||
background: Color.lerp(a.background, b.background, t), |
|||
error: Color.lerp(a.error, b.error, t), |
|||
onPrimary: Color.lerp(a.onPrimary, b.onPrimary, t), |
|||
onSecondary: Color.lerp(a.onSecondary, b.onSecondary, t), |
|||
onSurface: Color.lerp(a.onSurface, b.onSurface, t), |
|||
onBackground: Color.lerp(a.onBackground, b.onBackground, t), |
|||
onError: Color.lerp(a.onError, b.onError, t), |
|||
brightness: t < 0.5 ? a.brightness : b.brightness |
|||
); |
|||
} |
|||
|
|||
|
|||
public bool Equals(ColorScheme other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return other.primary == primary |
|||
&& other.primaryVariant == primaryVariant |
|||
&& other.secondary == secondary |
|||
&& other.secondaryVariant == secondaryVariant |
|||
&& other.surface == surface |
|||
&& other.background == background |
|||
&& other.error == error |
|||
&& other.onPrimary == onPrimary |
|||
&& other.onSecondary == onSecondary |
|||
&& other.onSurface == onSurface |
|||
&& other.onBackground == onBackground |
|||
&& other.onError == onError |
|||
&& other.brightness == brightness; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((ColorScheme) obj); |
|||
} |
|||
|
|||
public static bool operator ==(ColorScheme left, ColorScheme right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(ColorScheme left, ColorScheme right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = primary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ primaryVariant.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ secondary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ secondaryVariant.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ surface.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ background.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ error.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onPrimary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onSecondary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onSurface.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onBackground.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ onError.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ brightness.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
ColorScheme defaultScheme = light(); |
|||
properties.add(new DiagnosticsProperty<Color>("primary", primary, |
|||
defaultValue: defaultScheme.primary)); |
|||
properties.add(new DiagnosticsProperty<Color>("primaryVariant", primaryVariant, |
|||
defaultValue: defaultScheme.primaryVariant)); |
|||
properties.add(new DiagnosticsProperty<Color>("secondary", secondary, |
|||
defaultValue: defaultScheme.secondary)); |
|||
properties.add(new DiagnosticsProperty<Color>("secondaryVariant", secondaryVariant, |
|||
defaultValue: defaultScheme.secondaryVariant)); |
|||
properties.add(new DiagnosticsProperty<Color>("surface", surface, |
|||
defaultValue: defaultScheme.surface)); |
|||
properties.add(new DiagnosticsProperty<Color>("background", background, |
|||
defaultValue: defaultScheme.background)); |
|||
properties.add(new DiagnosticsProperty<Color>("error", error, defaultValue: defaultScheme.error)); |
|||
properties.add(new DiagnosticsProperty<Color>("onPrimary", onPrimary, |
|||
defaultValue: defaultScheme.onPrimary)); |
|||
properties.add(new DiagnosticsProperty<Color>("onSecondary", onSecondary, |
|||
defaultValue: defaultScheme.onSecondary)); |
|||
properties.add(new DiagnosticsProperty<Color>("onSurface", onSurface, |
|||
defaultValue: defaultScheme.onSurface)); |
|||
properties.add(new DiagnosticsProperty<Color>("onBackground", onBackground, |
|||
defaultValue: defaultScheme.onBackground)); |
|||
properties.add(new DiagnosticsProperty<Color>("onError", onError, |
|||
defaultValue: defaultScheme.onError)); |
|||
properties.add(new DiagnosticsProperty<Brightness>("brightness", brightness, |
|||
defaultValue: defaultScheme.brightness)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a610420b7a8ec44bfa84e81a1e5ff449 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: dfc0e036c07e1441d8dbd3158bb6f923 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.painting; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public static class Constants { |
|||
public const float kToolbarHeight = 56.0f; |
|||
|
|||
public const float kBottomNavigationBarHeight = 56.0f; |
|||
|
|||
public const float kTextTabBarHeight = 48.0f; |
|||
|
|||
public static readonly TimeSpan kThemeChangeDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
|
|||
public const float kRadialReactionRadius = 20.0f; |
|||
|
|||
public static readonly TimeSpan kRadialReactionDuration = new TimeSpan(0, 0, 0, 0, 100); |
|||
|
|||
public const int kRadialReactionAlpha = 0x1F; |
|||
|
|||
public static readonly TimeSpan kTabScrollDuration = new TimeSpan(0, 0, 0, 0, 300); |
|||
|
|||
public static readonly EdgeInsets kTabLabelPadding = EdgeInsets.symmetric(horizontal: 16.0f); |
|||
|
|||
public static readonly EdgeInsets kMaterialListPadding = EdgeInsets.symmetric(vertical: 8.0f); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0364fdae877454fb1babca8f67c2561e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 353f6a1d0791640349fe94187f15ad33 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2aa14ff76c10f4d459b55674f0a2b57f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 96f34a8540bb74c7687149b4b2514998 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 068260026dcf947b0af4c9d7f706ab97 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9a7302f1a187741b88618822daf7a657 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7c1f7bd49df00452d9a3be75a9e7b213 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ea3964e7af24d4b059ac6e10ec862a3b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class TextTheme : Diagnosticable, IEquatable<TextTheme> { |
|||
public TextTheme( |
|||
TextStyle display4 = null, |
|||
TextStyle display3 = null, |
|||
TextStyle display2 = null, |
|||
TextStyle display1 = null, |
|||
TextStyle headline = null, |
|||
TextStyle title = null, |
|||
TextStyle subhead = null, |
|||
TextStyle body2 = null, |
|||
TextStyle body1 = null, |
|||
TextStyle caption = null, |
|||
TextStyle button = null, |
|||
TextStyle subtitle = null, |
|||
TextStyle overline = null |
|||
) { |
|||
this.display4 = display4; |
|||
this.display3 = display3; |
|||
this.display2 = display2; |
|||
this.display1 = display1; |
|||
this.headline = headline; |
|||
this.title = title; |
|||
this.subhead = subhead; |
|||
this.body2 = body2; |
|||
this.body1 = body1; |
|||
this.caption = caption; |
|||
this.button = button; |
|||
this.subtitle = subtitle; |
|||
this.overline = overline; |
|||
} |
|||
|
|||
|
|||
public readonly TextStyle display4; |
|||
|
|||
public readonly TextStyle display3; |
|||
|
|||
public readonly TextStyle display2; |
|||
|
|||
public readonly TextStyle display1; |
|||
|
|||
public readonly TextStyle headline; |
|||
|
|||
public readonly TextStyle title; |
|||
|
|||
public readonly TextStyle subhead; |
|||
|
|||
public readonly TextStyle body2; |
|||
|
|||
public readonly TextStyle body1; |
|||
|
|||
public readonly TextStyle caption; |
|||
|
|||
public readonly TextStyle button; |
|||
|
|||
public readonly TextStyle subtitle; |
|||
|
|||
public readonly TextStyle overline; |
|||
|
|||
|
|||
public TextTheme copyWith( |
|||
TextStyle display4 = null, |
|||
TextStyle display3 = null, |
|||
TextStyle display2 = null, |
|||
TextStyle display1 = null, |
|||
TextStyle headline = null, |
|||
TextStyle title = null, |
|||
TextStyle subhead = null, |
|||
TextStyle body2 = null, |
|||
TextStyle body1 = null, |
|||
TextStyle caption = null, |
|||
TextStyle button = null, |
|||
TextStyle subtitle = null, |
|||
TextStyle overline = null |
|||
) { |
|||
return new TextTheme( |
|||
display4: display4 ?? this.display4, |
|||
display3: display3 ?? this.display3, |
|||
display2: display2 ?? this.display2, |
|||
display1: display1 ?? this.display1, |
|||
headline: headline ?? this.headline, |
|||
title: title ?? this.title, |
|||
subhead: subhead ?? this.subhead, |
|||
body2: body2 ?? this.body2, |
|||
body1: body1 ?? this.body1, |
|||
caption: caption ?? this.caption, |
|||
button: button ?? this.button, |
|||
subtitle: subtitle ?? this.subtitle, |
|||
overline: overline ?? this.overline |
|||
); |
|||
} |
|||
|
|||
public TextTheme merge(TextTheme other) { |
|||
if (other == null) { |
|||
return this; |
|||
} |
|||
|
|||
return copyWith( |
|||
display4: display4?.merge(other.display4) ?? other.display4, |
|||
display3: display3?.merge(other.display3) ?? other.display3, |
|||
display2: display2?.merge(other.display2) ?? other.display2, |
|||
display1: display1?.merge(other.display1) ?? other.display1, |
|||
headline: headline?.merge(other.headline) ?? other.headline, |
|||
title: title?.merge(other.title) ?? other.title, |
|||
subhead: subhead?.merge(other.subhead) ?? other.subhead, |
|||
body2: body2?.merge(other.body2) ?? other.body2, |
|||
body1: body1?.merge(other.body1) ?? other.body1, |
|||
caption: caption?.merge(other.caption) ?? other.caption, |
|||
button: button?.merge(other.button) ?? other.button, |
|||
subtitle: subtitle?.merge(other.subtitle) ?? other.subtitle, |
|||
overline: overline?.merge(other.overline) ?? other.overline |
|||
); |
|||
} |
|||
|
|||
|
|||
public TextTheme apply( |
|||
string fontFamily = null, |
|||
float fontSizeFactor = 1.0f, |
|||
float fontSizeDelta = 0.0f, |
|||
Color displayColor = null, |
|||
Color bodyColor = null, |
|||
TextDecoration decoration = null, |
|||
Color decorationColor = null, |
|||
TextDecorationStyle? decorationStyle = null |
|||
) { |
|||
return new TextTheme( |
|||
display4: display4?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display3: display3?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display2: display2?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display1: display1?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
headline: headline?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
title: title?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
subhead: subhead?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
body2: body2?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
body1: body1?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
caption: caption?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
button: button?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
subtitle: subtitle?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
overline: overline?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
) |
|||
); |
|||
} |
|||
|
|||
public static TextTheme lerp(TextTheme a, TextTheme b, float t) { |
|||
return new TextTheme( |
|||
display4: TextStyle.lerp(a?.display4, b?.display4, t), |
|||
display3: TextStyle.lerp(a?.display3, b?.display3, t), |
|||
display2: TextStyle.lerp(a?.display2, b?.display2, t), |
|||
display1: TextStyle.lerp(a?.display1, b?.display1, t), |
|||
headline: TextStyle.lerp(a?.headline, b?.headline, t), |
|||
title: TextStyle.lerp(a?.title, b?.title, t), |
|||
subhead: TextStyle.lerp(a?.subhead, b?.subhead, t), |
|||
body2: TextStyle.lerp(a?.body2, b?.body2, t), |
|||
body1: TextStyle.lerp(a?.body1, b?.body1, t), |
|||
caption: TextStyle.lerp(a?.caption, b?.caption, t), |
|||
button: TextStyle.lerp(a?.button, b?.button, t), |
|||
subtitle: TextStyle.lerp(a?.subtitle, b?.subtitle, t), |
|||
overline: TextStyle.lerp(a?.overline, b?.overline, t) |
|||
); |
|||
} |
|||
|
|||
public bool Equals(TextTheme other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return display4 == other.display4 |
|||
&& display3 == other.display3 |
|||
&& display2 == other.display2 |
|||
&& display1 == other.display1 |
|||
&& headline == other.headline |
|||
&& title == other.title |
|||
&& subhead == other.subhead |
|||
&& body2 == other.body2 |
|||
&& body1 == other.body1 |
|||
&& caption == other.caption |
|||
&& button == other.button |
|||
&& subtitle == other.subtitle |
|||
&& overline == other.overline; |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return Equals((TextTheme) obj); |
|||
} |
|||
|
|||
public static bool operator ==(TextTheme left, TextTheme right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(TextTheme left, TextTheme right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
int? _cachedHashCode = null; |
|||
public override int GetHashCode() { |
|||
if (_cachedHashCode != null) { |
|||
return _cachedHashCode.Value; |
|||
} |
|||
unchecked { |
|||
var hashCode = display4?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ display3?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ display2?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ display1?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ headline?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ title?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ subhead?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ body2?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ body1?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ caption?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ button?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ subtitle?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ overline?.GetHashCode() ?? 0; |
|||
|
|||
_cachedHashCode = hashCode; |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
TextTheme defaultTheme = new Typography().black; |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display4", display4, |
|||
defaultValue: defaultTheme.display4)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display3", display3, |
|||
defaultValue: defaultTheme.display3)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display2", display2, |
|||
defaultValue: defaultTheme.display2)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display1", display1, |
|||
defaultValue: defaultTheme.display1)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("headline", headline, |
|||
defaultValue: defaultTheme.headline)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("title", title, defaultValue: defaultTheme.title)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextStyle>("subhead", subhead, defaultValue: defaultTheme.subhead)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("body2", body2, defaultValue: defaultTheme.body2)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("body1", body1, defaultValue: defaultTheme.body1)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextStyle>("caption", caption, defaultValue: defaultTheme.caption)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextStyle>("button", button, defaultValue: defaultTheme.button)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("subtitle)", subtitle, |
|||
defaultValue: defaultTheme.subtitle)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("overline", overline, |
|||
defaultValue: defaultTheme.overline)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 48eff72daf6ec48e5805ff0698990499 |
|||
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.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public static class ThemeUtils { |
|||
public static readonly TimeSpan kThemeAnimationDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public class Theme : StatelessWidget { |
|||
public Theme( |
|||
Key key = null, |
|||
ThemeData data = null, |
|||
bool isMaterialAppTheme = false, |
|||
Widget child = null |
|||
) : base(key: key) { |
|||
D.assert(child != null); |
|||
D.assert(data != null); |
|||
this.data = data; |
|||
this.isMaterialAppTheme = isMaterialAppTheme; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly ThemeData data; |
|||
|
|||
public readonly bool isMaterialAppTheme; |
|||
|
|||
readonly Widget child; |
|||
|
|||
static readonly ThemeData _kFallbackTheme = ThemeData.fallback(); |
|||
|
|||
public static ThemeData of(BuildContext context, bool shadowThemeOnly = false) { |
|||
_InheritedTheme inheritedTheme = |
|||
(_InheritedTheme) context.inheritFromWidgetOfExactType(typeof(_InheritedTheme)); |
|||
if (shadowThemeOnly) { |
|||
if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme) { |
|||
return null; |
|||
} |
|||
|
|||
return inheritedTheme.theme.data; |
|||
} |
|||
|
|||
MaterialLocalizations localizations = MaterialLocalizations.of(context); |
|||
ScriptCategory category = ScriptCategory.englishLike; |
|||
ThemeData theme = inheritedTheme?.theme?.data ?? _kFallbackTheme; |
|||
return ThemeData.localize(theme, theme.typography.geometryThemeFor(category)); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new _InheritedTheme( |
|||
theme: this, |
|||
child: new IconTheme( |
|||
data: data.iconTheme, |
|||
child: child |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<ThemeData>("data", data, showName: false)); |
|||
} |
|||
} |
|||
|
|||
|
|||
class _InheritedTheme : InheritedWidget { |
|||
public _InheritedTheme( |
|||
Key key = null, |
|||
Theme theme = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
D.assert(theme != null); |
|||
D.assert(child != null); |
|||
this.theme = theme; |
|||
} |
|||
|
|||
public readonly Theme theme; |
|||
|
|||
public override bool updateShouldNotify(InheritedWidget old) { |
|||
return theme.data != ((_InheritedTheme) old).theme.data; |
|||
} |
|||
} |
|||
|
|||
class ThemeDataTween : Tween<ThemeData> { |
|||
public ThemeDataTween( |
|||
ThemeData begin = null, |
|||
ThemeData end = null |
|||
) : base(begin: begin, end: end) { |
|||
} |
|||
|
|||
public override ThemeData lerp(float t) { |
|||
return ThemeData.lerp(begin, end, t); |
|||
} |
|||
} |
|||
|
|||
class AnimatedTheme : ImplicitlyAnimatedWidget { |
|||
public AnimatedTheme( |
|||
Key key = null, |
|||
ThemeData data = null, |
|||
bool isMaterialAppTheme = false, |
|||
Curve curve = null, |
|||
TimeSpan? duration = null, |
|||
Widget child = null |
|||
) : base(key: key, curve: curve ?? Curves.linear, duration: duration ?? ThemeUtils.kThemeAnimationDuration) { |
|||
D.assert(child != null); |
|||
D.assert(data != null); |
|||
this.data = data; |
|||
this.isMaterialAppTheme = isMaterialAppTheme; |
|||
this.child = child; |
|||
} |
|||
|
|||
|
|||
public readonly ThemeData data; |
|||
|
|||
public readonly bool isMaterialAppTheme; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public override State createState() { |
|||
return new _AnimatedThemeState(); |
|||
} |
|||
} |
|||
|
|||
|
|||
class _AnimatedThemeState : AnimatedWidgetBaseState<AnimatedTheme> { |
|||
ThemeDataTween _data; |
|||
|
|||
protected override void forEachTween(TweenVisitor visitor) { |
|||
_data = (ThemeDataTween) visitor.visit(this, _data, widget.data, |
|||
(ThemeData value) => new ThemeDataTween(begin: value)); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Theme( |
|||
isMaterialAppTheme: widget.isMaterialAppTheme, |
|||
child: widget.child, |
|||
data: _data.evaluate(animation) |
|||
); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder description) { |
|||
base.debugFillProperties(description); |
|||
description.add( |
|||
new DiagnosticsProperty<ThemeDataTween>("data", _data, showName: false, defaultValue: null)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8aeba6b651be2405387572671ac527f6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue