xingwei.zhu
6 年前
当前提交
36c1fd37
共有 51 个文件被更改,包括 5833 次插入 和 45 次删除
-
5Runtime/animation/animation.cs
-
8Runtime/animation/tween.cs
-
2Runtime/material/colors.cs
-
697Runtime/material/theme_data.cs
-
73Runtime/material/utils.cs
-
158Runtime/painting/text_style.cs
-
408Runtime/rendering/proxy_box.cs
-
9Runtime/ui/geometry.cs
-
14Runtime/ui/painting/painting.cs
-
119Runtime/widgets/basic.cs
-
8Runtime/widgets/icon_theme_data.cs
-
325Runtime/widgets/implicit_animations.cs
-
75Samples/UIWidgetSample/UIWidgetSample.unity
-
8Runtime/material.meta
-
145Runtime/material/button.cs
-
11Runtime/material/button.cs.meta
-
499Runtime/material/button_theme.cs
-
11Runtime/material/button_theme.cs.meta
-
338Runtime/material/color_scheme.cs
-
11Runtime/material/color_scheme.cs.meta
-
11Runtime/material/colors.cs.meta
-
11Runtime/material/constants.cs.meta
-
51Runtime/material/debug.cs
-
11Runtime/material/debug.cs.meta
-
224Runtime/material/ink_decoration.cs
-
11Runtime/material/ink_decoration.cs.meta
-
129Runtime/material/ink_highlight.cs
-
11Runtime/material/ink_highlight.cs.meta
-
170Runtime/material/ink_splash.cs
-
11Runtime/material/ink_splash.cs.meta
-
359Runtime/material/ink_well.cs
-
11Runtime/material/ink_well.cs.meta
-
497Runtime/material/material.cs
-
11Runtime/material/material.cs.meta
-
133Runtime/material/material_button.cs
-
11Runtime/material/material_button.cs.meta
-
351Runtime/material/text_theme.cs
-
11Runtime/material/text_theme.cs.meta
-
134Runtime/material/theme.cs
-
11Runtime/material/theme.cs.meta
-
11Runtime/material/theme_data.cs.meta
-
451Runtime/material/typography.cs
-
11Runtime/material/typography.cs.meta
-
11Runtime/material/utils.cs.meta
-
11Runtime/painting/colors.cs.meta
-
11Runtime/service/system_chrome.cs.meta
-
11Runtime/widgets/implicit_animations.cs.meta
-
176Runtime/widgets/layout_builder.cs
-
11Runtime/widgets/layout_builder.cs.meta
-
70Samples/UIWidgetSample/MaterialCanvas.cs
-
11Samples/UIWidgetSample/MaterialCanvas.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Runtime.CompilerServices; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
public readonly Color _kLightThemeHighlightColor = new Color(0x66BCBCBC); |
|||
public static readonly Color _kLightThemeHighlightColor = new Color(0x66BCBCBC); |
|||
|
|||
public static readonly Color _kLightThemeSplashColor = new Color(0x66C8C8C8); |
|||
public readonly Color _kLightThemeSplashColor = new Color(0x66C8C8C8); |
|||
public static readonly Color _kDarkThemeHighlightColor = new Color(0x40CCCCCC); |
|||
public readonly Color _kDarkThemeHighlightColor = new Color(0x40CCCCCC); |
|||
public static readonly Color _kDarkThemeSplashColor = new Color(0x40CCCCCC); |
|||
} |
|||
|
|||
public class ThemeUtils { |
|||
public static readonly TimeSpan kThemeAnimationDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public class MaterialUtils { |
|||
public static Dictionary<MaterialType, BorderRadius> kMaterialEdges = |
|||
new Dictionary<MaterialType, BorderRadius>() { |
|||
{MaterialType.canvas, null}, |
|||
{MaterialType.card, BorderRadius.all(2.0)}, |
|||
{MaterialType.circle, null}, |
|||
{MaterialType.button, BorderRadius.all(2.0)}, |
|||
{MaterialType.transparency, null} |
|||
}; |
|||
} |
|||
|
|||
public class InkHighlightUtils { |
|||
public static readonly TimeSpan _kHighlightFadeDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
} |
|||
|
|||
public class InkSplashUtils { |
|||
public static readonly TimeSpan _kUnconfirmedSplashDuration = new TimeSpan(0, 0, 0, 1, 0); |
|||
public readonly Color _kDarkThemeSplashColor = new Color(0x40CCCCCC); |
|||
public static readonly TimeSpan _kSplashFadeDuration = new TimeSpan(0, 0, 0, 0, 200); |
|||
|
|||
public static double _kSplashInitialSize = 0.0; |
|||
|
|||
public static double _kSplashConfirmedVelocity = 1.0; |
|||
|
|||
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell, |
|||
RectCallback rectCallback) { |
|||
if (rectCallback != null) { |
|||
D.assert(containedInkWell); |
|||
return rectCallback; |
|||
} |
|||
|
|||
if (containedInkWell) |
|||
return () => Offset.zero & referenceBox.size; |
|||
return null; |
|||
} |
|||
|
|||
public static double _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, |
|||
Offset position) { |
|||
if (containedInkWell) { |
|||
Size size = rectCallback != null ? rectCallback().size : referenceBox.size; |
|||
return _getSplashRadiusForPositionInSize(size, position); |
|||
} |
|||
|
|||
return Material.defaultSplashRadius; |
|||
} |
|||
|
|||
public static double _getSplashRadiusForPositionInSize(Size bounds, Offset position) { |
|||
double d1 = (position - bounds.topLeft(Offset.zero)).distance; |
|||
double d2 = (position - bounds.topRight(Offset.zero)).distance; |
|||
double d3 = (position - bounds.bottomLeft(Offset.zero)).distance; |
|||
double d4 = (position - bounds.bottomRight(Offset.zero)).distance; |
|||
return Math.Max(Math.Max(d1, d2), Math.Max(d3, d4)).ceil(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 52a35ef46dd5544709a97aaf50d86159 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.widgets; |
|||
using Unity.UIWidgets.ui; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public class RawMaterialButton : StatefulWidget { |
|||
public RawMaterialButton( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
TextStyle textStyle = null, |
|||
Color fillColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
double elevation = 2.0, |
|||
double highlightElevation = 8.0, |
|||
double disabledElevation = 0.0, |
|||
EdgeInsets padding = null, |
|||
BoxConstraints constraints = null, |
|||
ShapeBorder shape = null, |
|||
TimeSpan? animationDuration = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget child = null) : base(key: key) { |
|||
D.assert(onPressed != null); |
|||
MaterialTapTargetSize _materialTapTargetSize = materialTapTargetSize ?? MaterialTapTargetSize.padded; |
|||
shape = shape ?? new RoundedRectangleBorder(); |
|||
padding = padding ?? EdgeInsets.zero; |
|||
constraints = constraints ?? new BoxConstraints(minWidth: 88.0, minHeight: 36.0); |
|||
TimeSpan _animationDuration = animationDuration ?? Constants.kThemeChangeDuration; |
|||
|
|||
this.onPressed = onPressed; |
|||
this.onHighlightChanged = onHighlightChanged; |
|||
this.textStyle = textStyle; |
|||
this.fillColor = fillColor; |
|||
this.highlightColor = highlightColor; |
|||
this.splashColor = splashColor; |
|||
this.elevation = elevation; |
|||
this.highlightElevation = highlightElevation; |
|||
this.disabledElevation = disabledElevation; |
|||
this.padding = padding; |
|||
this.constraints = constraints; |
|||
this.shape = shape; |
|||
this.animationDuration = _animationDuration; |
|||
this.clipBehavior = clipBehavior; |
|||
this.materialTapTargetSize = _materialTapTargetSize; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly VoidCallback onPressed; |
|||
|
|||
public readonly ValueChanged<bool> onHighlightChanged; |
|||
|
|||
public readonly TextStyle textStyle; |
|||
|
|||
public readonly Color fillColor; |
|||
|
|||
public readonly Color highlightColor; |
|||
|
|||
public readonly Color splashColor; |
|||
|
|||
public readonly double elevation; |
|||
|
|||
public readonly double highlightElevation; |
|||
|
|||
public readonly double disabledElevation; |
|||
|
|||
public readonly EdgeInsets padding; |
|||
|
|||
public readonly BoxConstraints constraints; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public readonly TimeSpan animationDuration; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public bool enabled => this.onPressed != null; |
|||
|
|||
public readonly MaterialTapTargetSize materialTapTargetSize; |
|||
|
|||
public readonly Clip clipBehavior; |
|||
|
|||
public override State createState() => new _RawMaterialButtonState(); |
|||
} |
|||
|
|||
|
|||
class _RawMaterialButtonState : State<RawMaterialButton> { |
|||
bool _highlight = false; |
|||
|
|||
void _handleHighlightChanged(bool value) { |
|||
this.setState(() => { |
|||
this._highlight = value; |
|||
if (this.widget.onHighlightChanged != null) { |
|||
this.widget.onHighlightChanged(value); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
double elevation = this.widget.enabled |
|||
? (this._highlight ? this.widget.highlightElevation : this.widget.elevation) |
|||
: this.widget.disabledElevation; |
|||
|
|||
Widget result = new ConstrainedBox( |
|||
constraints: this.widget.constraints, |
|||
child: new Material( |
|||
elevation: elevation, |
|||
textStyle: this.widget.textStyle, |
|||
shape: this.widget.shape, |
|||
color: this.widget.fillColor, |
|||
type: this.widget.fillColor == null ? MaterialType.transparency : MaterialType.button, |
|||
animationDuration: this.widget.animationDuration, |
|||
clipBehavior: this.widget.clipBehavior, |
|||
child: new InkWell( |
|||
onHighlightChanged: this._handleHighlightChanged, |
|||
splashColor: this.widget.splashColor, |
|||
highlightColor: this.widget.highlightColor, |
|||
onTap: () => this.widget.onPressed(), |
|||
customBorder: this.widget.shape, |
|||
child: IconTheme.merge( |
|||
data: new IconThemeData(color: this.widget.textStyle?.color), |
|||
child: new Container( |
|||
padding: this.widget.padding, |
|||
child: new Center( |
|||
widthFactor: 1.0, |
|||
heightFactor: 1.0, |
|||
child: this.widget.child) |
|||
) |
|||
) |
|||
) |
|||
) |
|||
); |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5452e0dd1a19646fda9cc8dc0b388ee4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Runtime.CompilerServices; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.widgets; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.service; |
|||
using System; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public enum ButtonTextTheme { |
|||
normal, |
|||
|
|||
accent, |
|||
|
|||
primary |
|||
} |
|||
|
|||
public enum ButtonBarLayoutBehavior { |
|||
constrained, |
|||
|
|||
padded |
|||
} |
|||
|
|||
public class ButtonTheme : InheritedWidget { |
|||
public ButtonTheme( |
|||
Key key = null, |
|||
ButtonTextTheme textTheme = ButtonTextTheme.normal, |
|||
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded, |
|||
double minWidth = 88.0, |
|||
double height = 36.0, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
bool alignedDropdown = false, |
|||
Color buttonColor = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
ColorScheme colorScheme = null, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
D.assert(minWidth >= 0.0); |
|||
D.assert(height >= 0.0); |
|||
this.data = new ButtonThemeData( |
|||
textTheme: textTheme, |
|||
minWidth: minWidth, |
|||
height: height, |
|||
padding: padding, |
|||
shape: shape, |
|||
alignedDropdown: alignedDropdown, |
|||
layoutBehavior: layoutBehavior, |
|||
buttonColor: buttonColor, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorScheme: colorScheme, |
|||
materialTapTargetSize: materialTapTargetSize); |
|||
} |
|||
|
|||
public ButtonTheme( |
|||
Key key = null, |
|||
ButtonThemeData data = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
D.assert(data != null); |
|||
this.data = data; |
|||
} |
|||
|
|||
public readonly ButtonThemeData data; |
|||
|
|||
public static ButtonThemeData of(BuildContext context) { |
|||
ButtonTheme inheritedButtonTheme = (ButtonTheme) context.inheritFromWidgetOfExactType(typeof(ButtonTheme)); |
|||
ButtonThemeData buttonTheme = inheritedButtonTheme?.data; |
|||
if (buttonTheme?.colorScheme == null) { |
|||
ThemeData theme = Theme.of(context); |
|||
buttonTheme = buttonTheme ?? theme.buttonTheme; |
|||
if (buttonTheme.colorScheme == null) { |
|||
buttonTheme = buttonTheme.copyWith( |
|||
colorScheme: theme.buttonTheme.colorScheme ?? theme.colorScheme); |
|||
D.assert(buttonTheme.colorScheme != null); |
|||
} |
|||
} |
|||
|
|||
return buttonTheme; |
|||
} |
|||
|
|||
public override bool updateShouldNotify(InheritedWidget oldWidget) => this.data != ((ButtonTheme)oldWidget).data; |
|||
} |
|||
|
|||
|
|||
public class ButtonThemeData : Diagnosticable { |
|||
public ButtonThemeData( |
|||
ButtonTextTheme textTheme = ButtonTextTheme.normal, |
|||
double minWidth = 88.0, |
|||
double height = 36.0, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
ButtonBarLayoutBehavior layoutBehavior = ButtonBarLayoutBehavior.padded, |
|||
bool alignedDropdown = false, |
|||
Color buttonColor = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
ColorScheme colorScheme = null, |
|||
MaterialTapTargetSize? materialTapTargetSize = null |
|||
) { |
|||
D.assert(textTheme != null); |
|||
D.assert(minWidth >= 0.0); |
|||
D.assert(height >= 0.0); |
|||
this.textTheme = textTheme; |
|||
this.minWidth = minWidth; |
|||
this.height = height; |
|||
this.layoutBehavior = layoutBehavior; |
|||
this.alignedDropdown = alignedDropdown; |
|||
this.colorScheme = colorScheme; |
|||
this._buttonColor = buttonColor; |
|||
this._disabledColor = disabledColor; |
|||
this._highlightColor = highlightColor; |
|||
this._splashColor = splashColor; |
|||
this._padding = padding; |
|||
this._shape = shape; |
|||
this._materialTapTargetSize = materialTapTargetSize; |
|||
} |
|||
|
|||
|
|||
public readonly double minWidth; |
|||
|
|||
public readonly double height; |
|||
|
|||
public readonly ButtonTextTheme textTheme; |
|||
|
|||
public readonly ButtonBarLayoutBehavior layoutBehavior; |
|||
|
|||
public BoxConstraints constraints { |
|||
get { return new BoxConstraints(minWidth: this.minWidth, |
|||
minHeight: this.height);} |
|||
} |
|||
|
|||
public EdgeInsets padding { |
|||
get { |
|||
if (this._padding != null) |
|||
return this._padding; |
|||
switch (this.textTheme) { |
|||
case ButtonTextTheme.normal: |
|||
case ButtonTextTheme.accent: |
|||
return EdgeInsets.symmetric(horizontal: 16.0); |
|||
case ButtonTextTheme.primary: |
|||
return EdgeInsets.symmetric(horizontal: 24.0); |
|||
} |
|||
D.assert(false); |
|||
return EdgeInsets.zero; |
|||
} |
|||
} |
|||
|
|||
readonly EdgeInsets _padding; |
|||
|
|||
public ShapeBorder shape { |
|||
get { |
|||
if (this._shape != null) |
|||
return this._shape; |
|||
switch (this.textTheme) { |
|||
case ButtonTextTheme.normal: |
|||
case ButtonTextTheme.accent: |
|||
return new RoundedRectangleBorder( |
|||
borderRadius: BorderRadius.all(Radius.circular(2.0))); |
|||
case ButtonTextTheme.primary: |
|||
return new RoundedRectangleBorder( |
|||
borderRadius: BorderRadius.all(Radius.circular(4.0))); |
|||
} |
|||
return new RoundedRectangleBorder(); |
|||
} |
|||
} |
|||
|
|||
readonly ShapeBorder _shape; |
|||
|
|||
public readonly bool alignedDropdown; |
|||
|
|||
readonly Color _buttonColor; |
|||
|
|||
readonly Color _disabledColor; |
|||
|
|||
readonly Color _highlightColor; |
|||
|
|||
readonly Color _splashColor; |
|||
|
|||
public readonly ColorScheme colorScheme; |
|||
|
|||
readonly MaterialTapTargetSize? _materialTapTargetSize; |
|||
|
|||
public Brightness getBrightness(MaterialButton button) { |
|||
return button.colorBrightness ?? this.colorScheme.brightness; |
|||
} |
|||
|
|||
public ButtonTextTheme getTextTheme(MaterialButton button) { |
|||
return button.textTheme ?? this.textTheme; |
|||
} |
|||
|
|||
Color _getDisabledColor(MaterialButton button) { |
|||
return this.getBrightness(button) == Brightness.dark |
|||
? this.colorScheme.onSurface.withOpacity(0.30) |
|||
: this.colorScheme.onSurface.withOpacity(0.38); |
|||
} |
|||
|
|||
|
|||
Color getDisabledTextColor(MaterialButton button) { |
|||
if (button.disabledTextColor != null) |
|||
return button.disabledTextColor; |
|||
return this._getDisabledColor(button); |
|||
} |
|||
|
|||
|
|||
Color getDisabledFillColor(MaterialButton button) { |
|||
if (button.disabledColor != null) |
|||
return button.disabledColor; |
|||
if (this._disabledColor != null) |
|||
return this._disabledColor; |
|||
return this._getDisabledColor(button); |
|||
} |
|||
|
|||
|
|||
Color getFillColor(MaterialButton button) { |
|||
Color fillColor = button.enabled ? button.color : button.disabledColor; |
|||
if (fillColor != null) |
|||
return fillColor; |
|||
|
|||
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton & RaisedButton are ready
|
|||
// if (button is FlatButton || button is OutlineButton)
|
|||
// return null;
|
|||
//
|
|||
//
|
|||
// if (button.enabled && button is RaisedButton && this._buttonColor != null)
|
|||
// return this._buttonColor;
|
|||
|
|||
switch (this.getTextTheme(button)) { |
|||
case ButtonTextTheme.normal: |
|||
case ButtonTextTheme.accent: |
|||
return button.enabled ? this.colorScheme.primary : this.getDisabledFillColor(button); |
|||
case ButtonTextTheme.primary: |
|||
return button.enabled |
|||
? this._buttonColor ?? this.colorScheme.primary |
|||
: this.colorScheme.onSurface.withOpacity(0.12); |
|||
} |
|||
D.assert(false); |
|||
return null; |
|||
} |
|||
|
|||
public Color getTextColor(MaterialButton button) { |
|||
if (!button.enabled) |
|||
return this.getDisabledTextColor(button); |
|||
|
|||
if (button.textColor != null) |
|||
return button.textColor; |
|||
|
|||
switch (this.getTextTheme(button)) { |
|||
case ButtonTextTheme.normal: |
|||
return this.getBrightness(button) == Brightness.dark ? Colors.white : Colors.black87; |
|||
case ButtonTextTheme.accent: |
|||
return this.colorScheme.secondary; |
|||
case ButtonTextTheme.primary: { |
|||
Color fillColor = this.getFillColor(button); |
|||
bool fillIsDark = fillColor != null |
|||
? ThemeData.estimateBrightnessForColor(fillColor) == Brightness.dark |
|||
: this.getBrightness(button) == Brightness.dark; |
|||
if (fillIsDark) |
|||
return Colors.white; |
|||
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton are ready
|
|||
// if (button is FlatButton || button is OutlineButton)
|
|||
// return this.colorScheme.primary;
|
|||
return Colors.black; |
|||
} |
|||
} |
|||
D.assert(false); |
|||
return null; |
|||
} |
|||
|
|||
public Color getSplashColor(MaterialButton button) { |
|||
if (button.splashColor != null) |
|||
return button.splashColor; |
|||
|
|||
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton & RaisedButton are ready
|
|||
// if (this._splashColor != null && (button is RaisedButton || button is OutlineButton)) {
|
|||
// return this._splashColor;
|
|||
// }
|
|||
//
|
|||
// if (this._splashColor != null && button is FlatButton) {
|
|||
// switch (this.getTextTheme(button)) {
|
|||
// case ButtonTextTheme.normal:
|
|||
// case ButtonTextTheme.accent:
|
|||
// return this._splashColor;
|
|||
// case ButtonTextTheme.primary:
|
|||
// break;
|
|||
// }
|
|||
// }
|
|||
return this.getTextColor(button).withOpacity(0.12); |
|||
} |
|||
|
|||
public Color getHighlightColor(MaterialButton button) { |
|||
if (button.highlightColor != null) |
|||
return button.highlightColor; |
|||
|
|||
switch (this.getTextTheme(button)) { |
|||
case ButtonTextTheme.normal: |
|||
case ButtonTextTheme.accent: |
|||
return this._highlightColor ?? this.getTextColor(button).withOpacity(0.16); |
|||
case ButtonTextTheme.primary: |
|||
return Colors.transparent; |
|||
} |
|||
|
|||
D.assert(false); |
|||
return Colors.transparent; |
|||
} |
|||
|
|||
|
|||
public double getElevation(MaterialButton button) { |
|||
if (button.elevation != null) |
|||
return button.elevation ?? 0.0; |
|||
// todo xingwei.zhu: uncomment these when FlatButton are ready
|
|||
// if (button is FlatButton)
|
|||
// return 0.0;
|
|||
return 2.0; |
|||
} |
|||
|
|||
|
|||
public double getHighlightElevation(MaterialButton button) { |
|||
if (button.highlightElevation != null) |
|||
return button.highlightElevation ?? 0.0; |
|||
// todo xingwei.zhu: uncomment these when FlatButton & OutlineButton are ready
|
|||
// if (button is FlatButton)
|
|||
// return 0.0;
|
|||
// if (button is OutlineButton)
|
|||
// return 2.0;
|
|||
return 8.0; |
|||
} |
|||
|
|||
|
|||
public double getDisabledElevation(MaterialButton button) { |
|||
if (button.disabledElevation != null) |
|||
return button.disabledElevation ?? 0.0; |
|||
return 0.0; |
|||
} |
|||
|
|||
|
|||
public EdgeInsets getPadding(MaterialButton button) { |
|||
if (button.padding != null) |
|||
return button.padding; |
|||
|
|||
// todo xingwei.zhu: uncomment these when MaterialButtonWithIconMixin are ready
|
|||
// if (button is MaterialButtonWithIconMixin)
|
|||
// return const EdgeInsetsDirectional.only(start: 12.0, end: 16.0);
|
|||
|
|||
if (this._padding != null) |
|||
return this._padding; |
|||
|
|||
switch (this.getTextTheme(button)) { |
|||
case ButtonTextTheme.normal: |
|||
case ButtonTextTheme.accent: |
|||
return EdgeInsets.symmetric(horizontal: 16.0); |
|||
case ButtonTextTheme.primary: |
|||
return EdgeInsets.symmetric(horizontal: 24.0); |
|||
} |
|||
D.assert(false); |
|||
return EdgeInsets.zero; |
|||
} |
|||
|
|||
public ShapeBorder getShape(MaterialButton button) { |
|||
return button.shape ?? this.shape; |
|||
} |
|||
|
|||
|
|||
public TimeSpan getAnimationDuration(MaterialButton button) { |
|||
return button.animationDuration ?? Constants.kThemeChangeDuration; |
|||
} |
|||
|
|||
public BoxConstraints getConstraints(MaterialButton button) => this.constraints; |
|||
|
|||
|
|||
public MaterialTapTargetSize getMaterialTapTargetSize(MaterialButton button) { |
|||
return button.materialTapTargetSize ?? this._materialTapTargetSize ?? MaterialTapTargetSize.padded; |
|||
} |
|||
|
|||
|
|||
public ButtonThemeData copyWith( |
|||
ButtonTextTheme? textTheme = null, |
|||
ButtonBarLayoutBehavior? layoutBehavior = null, |
|||
double? minWidth = null, |
|||
double? height = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
bool? alignedDropdown = null, |
|||
Color buttonColor = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
ColorScheme colorScheme = null, |
|||
MaterialTapTargetSize? materialTapTargetSize = null) { |
|||
|
|||
return new ButtonThemeData( |
|||
textTheme: textTheme ?? this.textTheme, |
|||
layoutBehavior: layoutBehavior ?? this.layoutBehavior, |
|||
minWidth: minWidth ?? this.minWidth, |
|||
height: height ?? this.height, |
|||
padding: padding ?? this.padding, |
|||
shape: shape ?? this.shape, |
|||
alignedDropdown: alignedDropdown ?? this.alignedDropdown, |
|||
buttonColor: buttonColor ?? this._buttonColor, |
|||
disabledColor: disabledColor ?? this._disabledColor, |
|||
highlightColor: highlightColor ?? this._highlightColor, |
|||
splashColor: splashColor ?? this._splashColor, |
|||
colorScheme: colorScheme ?? this.colorScheme, |
|||
materialTapTargetSize: materialTapTargetSize ?? this._materialTapTargetSize); |
|||
} |
|||
|
|||
public bool Equals(ButtonThemeData other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return this.textTheme == other.textTheme |
|||
&& this.minWidth == other.minWidth |
|||
&& this.height == other.height |
|||
&& this.padding == other.padding |
|||
&& this.shape == other.shape |
|||
&& this.alignedDropdown == other.alignedDropdown |
|||
&& this._buttonColor == other._buttonColor |
|||
&& this._disabledColor == other._disabledColor |
|||
&& this._highlightColor == other._highlightColor |
|||
&& this._splashColor == other._splashColor |
|||
&& this.colorScheme == other.colorScheme |
|||
&& this._materialTapTargetSize == other._materialTapTargetSize; |
|||
} |
|||
|
|||
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((ButtonThemeData) obj); |
|||
} |
|||
|
|||
public static bool operator ==(ButtonThemeData left, ButtonThemeData right) { |
|||
return Equals(left, right); |
|||
} |
|||
|
|||
public static bool operator !=(ButtonThemeData left, ButtonThemeData right) { |
|||
return !Equals(left, right); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = this.textTheme.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.minWidth.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.height.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.padding.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.shape.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.alignedDropdown.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this._buttonColor.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this._disabledColor.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this._highlightColor.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this._splashColor.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.colorScheme.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this._materialTapTargetSize.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
ButtonThemeData defaultTheme = new ButtonThemeData(); |
|||
properties.add(new EnumProperty<ButtonTextTheme>("textTheme", this.textTheme, defaultValue: defaultTheme.textTheme)); |
|||
properties.add(new DoubleProperty("minWidth", this.minWidth, defaultValue: defaultTheme.minWidth)); |
|||
properties.add(new DoubleProperty("height", this.height, defaultValue: defaultTheme.height)); |
|||
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding, defaultValue: defaultTheme.padding)); |
|||
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: defaultTheme.shape)); |
|||
properties.add(new FlagProperty("alignedDropdown", |
|||
value: this.alignedDropdown, |
|||
defaultValue: defaultTheme.alignedDropdown, |
|||
ifTrue: "dropdown width matches button" |
|||
)); |
|||
properties.add(new DiagnosticsProperty<Color>("buttonColor", this._buttonColor, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("disabledColor", this._disabledColor, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("highlightColor", this._highlightColor, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("splashColor", this._splashColor, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<ColorScheme>("colorScheme", this.colorScheme, defaultValue: defaultTheme.colorScheme)); |
|||
properties.add(new DiagnosticsProperty<MaterialTapTargetSize>("materialTapTargetSize", this._materialTapTargetSize ?? MaterialTapTargetSize.padded, defaultValue: null)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c00e9535ad31f481cbe2b83d490d714d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class ColorScheme : Diagnosticable { |
|||
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); |
|||
D.assert(brightness != 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(0xFF03AC6); |
|||
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) { |
|||
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) => 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, double 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 == this.primary |
|||
&& other.primaryVariant == this.primaryVariant |
|||
&& other.secondary == this.secondary |
|||
&& other.secondaryVariant == this.secondaryVariant |
|||
&& other.surface == this.surface |
|||
&& other.background == this.background |
|||
&& other.error == this.error |
|||
&& other.onPrimary == this.onPrimary |
|||
&& other.onSecondary == this.onSecondary |
|||
&& other.onSurface == this.onSurface |
|||
&& other.onBackground == this.onBackground |
|||
&& other.onError == this.onError |
|||
&& other.brightness == this.brightness; |
|||
} |
|||
|
|||
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((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 = this.primary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.primaryVariant.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.secondary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.secondaryVariant.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.surface.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.background.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.error.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.onPrimary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.onSecondary.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.onSurface.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.onBackground.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.onError.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.brightness.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
ColorScheme defaultScheme = ColorScheme.light(); |
|||
properties.add(new DiagnosticsProperty<Color>("primary", this.primary, defaultValue: defaultScheme.primary)); |
|||
properties.add(new DiagnosticsProperty<Color>("primaryVariant", this.primaryVariant, defaultValue: defaultScheme.primaryVariant)); |
|||
properties.add(new DiagnosticsProperty<Color>("secondary", this.secondary, defaultValue: defaultScheme.secondary)); |
|||
properties.add(new DiagnosticsProperty<Color>("secondaryVariant", this.secondaryVariant, defaultValue: defaultScheme.secondaryVariant)); |
|||
properties.add(new DiagnosticsProperty<Color>("surface", this.surface, defaultValue: defaultScheme.surface)); |
|||
properties.add(new DiagnosticsProperty<Color>("background", this.background, defaultValue: defaultScheme.background)); |
|||
properties.add(new DiagnosticsProperty<Color>("error", this.error, defaultValue: defaultScheme.error)); |
|||
properties.add(new DiagnosticsProperty<Color>("onPrimary", this.onPrimary, defaultValue: defaultScheme.onPrimary)); |
|||
properties.add(new DiagnosticsProperty<Color>("onSecondary", this.onSecondary, defaultValue: defaultScheme.onSecondary)); |
|||
properties.add(new DiagnosticsProperty<Color>("onSurface", this.onSurface, defaultValue: defaultScheme.onSurface)); |
|||
properties.add(new DiagnosticsProperty<Color>("onBackground", this.onBackground, defaultValue: defaultScheme.onBackground)); |
|||
properties.add(new DiagnosticsProperty<Color>("onError", this.onError, defaultValue: defaultScheme.onError)); |
|||
properties.add(new DiagnosticsProperty<Brightness>("brightness", this.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: |
|
|||
fileFormatVersion: 2 |
|||
guid: 0364fdae877454fb1babca8f67c2561e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.widgets; |
|||
using Unity.UIWidgets.foundation; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public class MaterialDebug { |
|||
|
|||
public static bool debugCheckHasMaterial(BuildContext context) { |
|||
D.assert(() => { |
|||
if (!(context.widget is Material) && context.ancestorWidgetOfExactType(typeof(Material)) == null) { |
|||
string message = "No Material widget found."; |
|||
message += context.widget.GetType() + " widgets require a Material widget ancestor."; |
|||
|
|||
message += "In material design, most widgets are conceptually \"printed\" on " + |
|||
"a sheet of material. In Flutter\'s material library, that " + |
|||
"material is represented by the Material widget. It is the " + |
|||
"Material widget that renders ink splashes, for instance. " + |
|||
"Because of this, many material library widgets require that " + |
|||
"there be a Material widget in the tree above them."; |
|||
|
|||
message += "To introduce a Material widget, you can either directly " + |
|||
"include one, or use a widget that contains Material itself, " + |
|||
"such as a Card, Dialog, Drawer, or Scaffold."; |
|||
|
|||
message += "The specific widget that could not find a Material ancestor was:"; |
|||
|
|||
message += context.widget.toString(); |
|||
List<Widget> ancestors = new List<Widget>(); |
|||
|
|||
context.visitAncestorElements((Element element) => { |
|||
ancestors.Add(element.widget); |
|||
return true; |
|||
}); |
|||
if (ancestors.isNotEmpty()) { |
|||
message += "The ancestors of this widget were:"; |
|||
foreach (Widget ancestor in ancestors) |
|||
message += "\n $ancestor"; |
|||
} else { |
|||
message +="This widget is the root of the tree, so it has no " + |
|||
"ancestors, let alone a \"Material\" ancestor."; |
|||
} |
|||
|
|||
throw new UIWidgetsError(message); |
|||
} |
|||
return true; |
|||
}); |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 353f6a1d0791640349fe94187f15ad33 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Runtime.InteropServices.WindowsRuntime; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.widgets; |
|||
using Unity.UIWidgets.ui; |
|||
using ImageUtils = Unity.UIWidgets.widgets.ImageUtils; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class Ink : StatefulWidget { |
|||
public Ink( |
|||
Key key = null, |
|||
EdgeInsets padding = null, |
|||
Color color = null, |
|||
Decoration decoration = null, |
|||
double? width = null, |
|||
double? height = null, |
|||
Widget child = null) : base(key: key) { |
|||
D.assert(padding == null || padding.isNonNegative); |
|||
D.assert(decoration == null || decoration.debugAssertIsValid()); |
|||
D.assert(color == null || decoration == null, |
|||
"Cannot provide both a color and a decoration\n" + |
|||
"The color argument is just a shorthand for \"decoration: new BoxDecoration(color: color)\"."); |
|||
decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null); |
|||
this.padding = padding; |
|||
this.width = width; |
|||
this.height = height; |
|||
this.child = child; |
|||
this.decoration = decoration; |
|||
} |
|||
|
|||
public static Ink image( |
|||
Key key = null, |
|||
EdgeInsets padding = null, |
|||
ImageProvider image = null, |
|||
ColorFilter colorFilter = null, |
|||
BoxFit? fit = null, |
|||
Alignment alignment = null, |
|||
Rect centerSlice = null, |
|||
ImageRepeat repeat = ImageRepeat.noRepeat, |
|||
double? width = null, |
|||
double? height = null, |
|||
Widget child = null |
|||
) { |
|||
D.assert(padding == null || padding.isNonNegative); |
|||
D.assert(image != null); |
|||
D.assert(repeat != null); |
|||
|
|||
alignment = alignment ?? Alignment.center; |
|||
Decoration decoration = new BoxDecoration( |
|||
image: new DecorationImage(image, |
|||
colorFilter: colorFilter, |
|||
fit: fit, |
|||
alignment: alignment, |
|||
centerSlice: centerSlice, |
|||
repeat: repeat) |
|||
); |
|||
|
|||
return new Ink( |
|||
key: key, |
|||
padding: padding, |
|||
decoration: decoration, |
|||
width: width, |
|||
height: height, |
|||
child: child); |
|||
} |
|||
|
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly EdgeInsets padding; |
|||
|
|||
public readonly Decoration decoration; |
|||
|
|||
public readonly double? width; |
|||
|
|||
public readonly double? height; |
|||
|
|||
public EdgeInsets _paddingIncludingDecoration { |
|||
get { |
|||
if (this.decoration == null || this.decoration.padding == null) |
|||
return this.padding; |
|||
EdgeInsets decorationPadding = this.decoration.padding; |
|||
if (this.padding == null) { |
|||
return decorationPadding; |
|||
} |
|||
return this.padding.add(decorationPadding); |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", this.padding, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Decoration>("bg", this.decoration, defaultValue: null)); |
|||
} |
|||
|
|||
public override State createState() => new _InkState(); |
|||
} |
|||
|
|||
|
|||
class _InkState : State<Ink> { |
|||
InkDecoration _ink; |
|||
|
|||
void _handleRemoved() { |
|||
this._ink = null; |
|||
} |
|||
|
|||
public override void deactivate() { |
|||
this._ink?.dispose(); |
|||
D.assert(this._ink == null); |
|||
base.deactivate(); |
|||
} |
|||
|
|||
public Widget _build(BuildContext context, BoxConstraints contraints) { |
|||
if (this._ink == null) { |
|||
this._ink = new InkDecoration( |
|||
decoration: this.widget.decoration, |
|||
configuration: ImageUtils.createLocalImageConfiguration(context), |
|||
controller: Material.of(context), |
|||
referenceBox: (RenderBox)context.findRenderObject(), |
|||
onRemoved: this._handleRemoved); |
|||
} |
|||
else { |
|||
this._ink.decoration = this.widget.decoration; |
|||
this._ink.configuration = ImageUtils.createLocalImageConfiguration(context); |
|||
} |
|||
|
|||
Widget current = this.widget.child; |
|||
EdgeInsets effectivePadding = this.widget._paddingIncludingDecoration; |
|||
if (effectivePadding != null) |
|||
current = new Padding( |
|||
padding: effectivePadding, |
|||
child: current); |
|||
|
|||
return current; |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
D.assert(MaterialDebug.debugCheckHasMaterial(context)); |
|||
Widget result = new LayoutBuilder( |
|||
builder: this._build); |
|||
if (this.widget.width != null || this.widget.height != null) { |
|||
result = new SizedBox( |
|||
width: this.widget.width, |
|||
height: this.widget.height, |
|||
child: result); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
} |
|||
|
|||
|
|||
class InkDecoration : InkFeature { |
|||
public InkDecoration( |
|||
Decoration decoration = null, |
|||
ImageConfiguration configuration = null, |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
VoidCallback onRemoved = null |
|||
) : base(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved) { |
|||
D.assert(configuration != null); |
|||
D.assert(decoration != null); |
|||
D.assert(controller != null); |
|||
D.assert(referenceBox != null); |
|||
this.decoration = decoration; |
|||
this.controller.addInkFeature(this); |
|||
} |
|||
|
|||
BoxPainter _painter; |
|||
|
|||
public Decoration decoration { |
|||
get { return this._decoration; } |
|||
set { |
|||
if (value == this._decoration) |
|||
return; |
|||
this._decoration = value; |
|||
this._painter?.Dispose(); |
|||
this._painter = this._decoration?.createBoxPainter(this._handleChanged); |
|||
this.controller.markNeedsPaint(); |
|||
} |
|||
} |
|||
Decoration _decoration; |
|||
|
|||
public ImageConfiguration configuration { |
|||
get { return this._configuration; } |
|||
set { |
|||
D.assert(value != null); |
|||
if (value == this._configuration) |
|||
return; |
|||
this._configuration = value; |
|||
this.controller.markNeedsPaint(); |
|||
} |
|||
} |
|||
ImageConfiguration _configuration; |
|||
|
|||
void _handleChanged() { |
|||
this.controller.markNeedsPaint(); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this._painter?.Dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
protected override void paintFeature(Canvas canvas, Matrix3 transform) { |
|||
if (this._painter == null) |
|||
return; |
|||
Offset originOffset = transform.getAsTranslation(); |
|||
ImageConfiguration sizedConfiguration = this.configuration.copyWith( |
|||
size: this.referenceBox.size); |
|||
|
|||
if (originOffset == null) { |
|||
canvas.save(); |
|||
canvas.concat(transform); |
|||
this._painter.paint(canvas, Offset.zero, sizedConfiguration); |
|||
canvas.restore(); |
|||
} |
|||
else { |
|||
this._painter.paint(canvas, originOffset, sizedConfiguration); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 2aa14ff76c10f4d459b55674f0a2b57f |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public class InkHighlight : InteractiveInkFeature { |
|||
public InkHighlight( |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
Color color = null, |
|||
BoxShape shape = BoxShape.rectangle, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder customBorder = null, |
|||
RectCallback rectCallback = null, |
|||
VoidCallback onRemoved = null) : base( |
|||
controller: controller, |
|||
referenceBox: referenceBox, |
|||
color: color, |
|||
onRemoved: onRemoved) { |
|||
D.assert(color != null); |
|||
D.assert(controller != null); |
|||
D.assert(referenceBox != null); |
|||
this._shape = shape; |
|||
this._borderRadius = borderRadius ?? BorderRadius.zero; |
|||
this._customBorder = customBorder; |
|||
this._rectCallback = rectCallback; |
|||
this._alphaController = new AnimationController( |
|||
duration: InkHighlightUtils._kHighlightFadeDuration, |
|||
vsync: controller.vsync); |
|||
this._alphaController.addListener(controller.markNeedsPaint); |
|||
this._alphaController.addStatusListener(this._handleAlphaStatusChanged); |
|||
this._alphaController.forward(); |
|||
|
|||
this._alpha = this._alphaController.drive(new IntTween( |
|||
begin: 0, end: color.alpha)); |
|||
|
|||
this.controller.addInkFeature(this); |
|||
} |
|||
|
|||
readonly BoxShape _shape; |
|||
|
|||
readonly BorderRadius _borderRadius; |
|||
|
|||
readonly ShapeBorder _customBorder; |
|||
|
|||
readonly RectCallback _rectCallback; |
|||
|
|||
Animation<int> _alpha; |
|||
AnimationController _alphaController; |
|||
|
|||
public bool active { |
|||
get { return this._active; } |
|||
} |
|||
|
|||
bool _active = true; |
|||
|
|||
public void activate() { |
|||
this._active = true; |
|||
this._alphaController.forward(); |
|||
} |
|||
|
|||
public void deactivate() { |
|||
this._active = false; |
|||
this._alphaController.reverse(); |
|||
} |
|||
|
|||
void _handleAlphaStatusChanged(AnimationStatus status) { |
|||
if (status == AnimationStatus.dismissed && !this._active) |
|||
this.dispose(); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this._alphaController.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
void _paintHighlight(Canvas canvas, Rect rect, Paint paint) { |
|||
D.assert(this._shape != null); |
|||
canvas.save(); |
|||
if (this._customBorder != null) { |
|||
canvas.clipPath(this._customBorder.getOuterPath(rect)); |
|||
} |
|||
|
|||
switch (this._shape) { |
|||
case BoxShape.circle: { |
|||
canvas.drawCircle(rect.center, Material.defaultSplashRadius, paint); |
|||
break; |
|||
} |
|||
case BoxShape.rectangle: { |
|||
if (this._borderRadius != BorderRadius.zero) { |
|||
RRect clipRRect = RRect.fromRectAndCorners( |
|||
rect, |
|||
topLeft: this._borderRadius.topLeft, |
|||
topRight: this._borderRadius.topRight, |
|||
bottomLeft: this._borderRadius.bottomLeft, |
|||
bottomRight: this._borderRadius.bottomRight); |
|||
canvas.drawRRect(clipRRect, paint); |
|||
} |
|||
else { |
|||
canvas.drawRect(rect, paint); |
|||
} |
|||
|
|||
break; |
|||
} |
|||
} |
|||
canvas.restore(); |
|||
} |
|||
|
|||
protected override void paintFeature(Canvas canvas, Matrix3 transform) { |
|||
Paint paint = new Paint(); |
|||
paint.color = this.color.withAlpha(this._alpha.value); |
|||
Offset originOffset = transform.getAsTranslation(); |
|||
Rect rect = this._rectCallback != null ? this._rectCallback() : Offset.zero & this.referenceBox.size; |
|||
if (originOffset == null) { |
|||
canvas.save(); |
|||
canvas.concat(transform); |
|||
this._paintHighlight(canvas, rect, paint); |
|||
canvas.restore(); |
|||
} |
|||
else { |
|||
this._paintHighlight(canvas, rect.shift(originOffset), paint); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 96f34a8540bb74c7687149b4b2514998 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class _InkSplashFactory : InteractiveInkFeatureFactory { |
|||
public _InkSplashFactory() { |
|||
} |
|||
|
|||
public override InteractiveInkFeature create( |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
Offset position = null, |
|||
Color color = null, |
|||
bool containedInkWell = false, |
|||
RectCallback rectCallback = null, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder customBorder = null, |
|||
double? radius = null, |
|||
VoidCallback onRemoved = null |
|||
) { |
|||
return new InkSplash( |
|||
controller: controller, |
|||
referenceBox: referenceBox, |
|||
position: position, |
|||
color: color, |
|||
containedInkWell: containedInkWell, |
|||
rectCallback: rectCallback, |
|||
borderRadius: borderRadius, |
|||
customBorder: customBorder, |
|||
radius: radius, |
|||
onRemoved: onRemoved); |
|||
} |
|||
} |
|||
|
|||
public class InkSplash : InteractiveInkFeature { |
|||
public InkSplash( |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
Offset position = null, |
|||
Color color = null, |
|||
bool containedInkWell = false, |
|||
RectCallback rectCallback = null, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder customBorder = null, |
|||
double? radius = null, |
|||
VoidCallback onRemoved = null) : base( |
|||
controller: controller, |
|||
referenceBox: referenceBox, |
|||
color: color, |
|||
onRemoved: onRemoved) { |
|||
D.assert(controller != null); |
|||
D.assert(referenceBox != null); |
|||
this._position = position; |
|||
this._borderRadius = borderRadius ?? BorderRadius.zero; |
|||
this._customBorder = customBorder; |
|||
this._targetRadius = |
|||
radius ?? InkSplashUtils._getTargetRadius(referenceBox, containedInkWell, rectCallback, position); |
|||
this._clipCallback = InkSplashUtils._getClipCallback(referenceBox, containedInkWell, rectCallback); |
|||
this._repositionToReferenceBox = !containedInkWell; |
|||
D.assert(this._borderRadius != null); |
|||
this._radiusController = new AnimationController(duration: |
|||
InkSplashUtils._kUnconfirmedSplashDuration, |
|||
vsync: controller.vsync); |
|||
this._radiusController.addListener(controller.markNeedsPaint); |
|||
this._radiusController.forward(); |
|||
this._radius = this._radiusController.drive(new DoubleTween( |
|||
begin: InkSplashUtils._kSplashInitialSize, |
|||
end: this._targetRadius)); |
|||
|
|||
this._alphaController = new AnimationController(duration: |
|||
InkSplashUtils._kSplashFadeDuration, |
|||
vsync: controller.vsync); |
|||
this._alphaController.addListener(controller.markNeedsPaint); |
|||
this._alphaController.addStatusListener(this._handleAlphaStatusChanged); |
|||
this._alpha = this._alphaController.drive(new IntTween( |
|||
begin: color.alpha, |
|||
end: 0)); |
|||
|
|||
controller.addInkFeature(this); |
|||
} |
|||
|
|||
readonly Offset _position; |
|||
|
|||
readonly BorderRadius _borderRadius; |
|||
|
|||
readonly ShapeBorder _customBorder; |
|||
|
|||
readonly double _targetRadius; |
|||
|
|||
readonly RectCallback _clipCallback; |
|||
|
|||
readonly bool _repositionToReferenceBox; |
|||
|
|||
Animation<double> _radius; |
|||
AnimationController _radiusController; |
|||
|
|||
Animation<int> _alpha; |
|||
AnimationController _alphaController; |
|||
|
|||
public static InteractiveInkFeatureFactory splashFactory = new _InkSplashFactory(); |
|||
|
|||
public override void confirm() { |
|||
int duration = (this._targetRadius / InkSplashUtils._kSplashConfirmedVelocity).floor(); |
|||
this._radiusController.duration = new TimeSpan(0, 0, 0, 0, duration); |
|||
this._radiusController.forward(); |
|||
this._alphaController.forward(); |
|||
} |
|||
|
|||
public override void cancel() { |
|||
this._alphaController?.forward(); |
|||
} |
|||
|
|||
void _handleAlphaStatusChanged(AnimationStatus status) { |
|||
if (status == AnimationStatus.completed) |
|||
this.dispose(); |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this._radiusController.dispose(); |
|||
this._alphaController.dispose(); |
|||
this._alphaController = null; |
|||
base.dispose(); |
|||
} |
|||
|
|||
protected override void paintFeature(Canvas canvas, Matrix3 transform) { |
|||
Paint paint = new Paint(); |
|||
paint.color = this.color.withAlpha(this._alpha.value); |
|||
Offset center = this._position; |
|||
if (this._repositionToReferenceBox) |
|||
center = Offset.lerp(center, this.referenceBox.size.center(Offset.zero), this._radiusController.value); |
|||
Offset originOffset = transform.getAsTranslation(); |
|||
canvas.save(); |
|||
if (originOffset == null) { |
|||
canvas.concat(transform); |
|||
} |
|||
else { |
|||
canvas.translate(originOffset.dx, originOffset.dy); |
|||
} |
|||
|
|||
if (this._clipCallback != null) { |
|||
Rect rect = this._clipCallback(); |
|||
if (this._customBorder != null) { |
|||
canvas.clipPath(this._customBorder.getOuterPath(rect)); |
|||
} |
|||
else if (this._borderRadius != BorderRadius.zero) { |
|||
canvas.clipRRect(RRect.fromRectAndCorners( |
|||
rect, |
|||
topLeft: this._borderRadius.topLeft, |
|||
topRight: this._borderRadius.topRight, |
|||
bottomLeft: this._borderRadius.bottomLeft, |
|||
bottomRight: this._borderRadius.bottomRight)); |
|||
} |
|||
else { |
|||
canvas.clipRect(rect); |
|||
} |
|||
} |
|||
|
|||
//todo xingwei.zhu: remove this condition when drawCircle bug fixed (when radius.value == 0)
|
|||
if (this._radius.value != 0) |
|||
canvas.drawCircle(center, this._radius.value, paint); |
|||
|
|||
canvas.restore(); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 068260026dcf947b0af4c9d7f706ab97 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using System.Collections.Generic; |
|||
using System.Runtime.CompilerServices; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public abstract class InteractiveInkFeature : InkFeature { |
|||
public InteractiveInkFeature( |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
Color color = null, |
|||
VoidCallback onRemoved = null |
|||
) : base(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved) { |
|||
D.assert(controller != null); |
|||
D.assert(referenceBox != null); |
|||
this._color = color; |
|||
} |
|||
|
|||
public virtual void confirm() {} |
|||
|
|||
public virtual void cancel() {} |
|||
|
|||
public Color color { |
|||
get { return this._color; } |
|||
set { |
|||
if (value == this._color) { |
|||
return; |
|||
} |
|||
|
|||
this._color = value; |
|||
this.controller.markNeedsPaint(); |
|||
} |
|||
} |
|||
|
|||
Color _color; |
|||
} |
|||
|
|||
public abstract class InteractiveInkFeatureFactory { |
|||
public InteractiveInkFeatureFactory() {} |
|||
|
|||
public abstract InteractiveInkFeature create( |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
Offset position = null, |
|||
Color color = null, |
|||
bool containedInkWell = false, |
|||
RectCallback rectCallback = null, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder customBorder = null, |
|||
double? radius = null, |
|||
VoidCallback onRemoved = null); |
|||
} |
|||
|
|||
|
|||
public class InkResponse : StatefulWidget { |
|||
public InkResponse( |
|||
Key key = null, |
|||
Widget child = null, |
|||
GestureTapCallback onTap = null, |
|||
GestureTapDownCallback onTapDown = null, |
|||
GestureTapCancelCallback onTapCancel = null, |
|||
GestureTapCallback onDoubleTap = null, |
|||
GestureLongPressCallback onLongPress = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
bool containedInkWell = false, |
|||
BoxShape highlightShape = BoxShape.circle, |
|||
double? radius = null, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder customBorder = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
InteractiveInkFeatureFactory splashFactory = null) : base(key: key) { |
|||
this.child = child; |
|||
this.onTap = onTap; |
|||
this.onTapDown = onTapDown; |
|||
this.onTapCancel = onTapCancel; |
|||
this.onDoubleTap = onDoubleTap; |
|||
this.onLongPress = onLongPress; |
|||
this.onHighlightChanged = onHighlightChanged; |
|||
this.containedInkWell = containedInkWell; |
|||
this.highlightShape = highlightShape; |
|||
this.radius = radius; |
|||
this.borderRadius = borderRadius; |
|||
this.customBorder = customBorder; |
|||
this.highlightColor = highlightColor; |
|||
this.splashColor = splashColor; |
|||
this.splashFactory = splashFactory; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly GestureTapCallback onTap; |
|||
|
|||
public readonly GestureTapDownCallback onTapDown; |
|||
|
|||
public readonly GestureTapCancelCallback onTapCancel; |
|||
|
|||
public readonly GestureTapCallback onDoubleTap; |
|||
|
|||
public readonly GestureLongPressCallback onLongPress; |
|||
|
|||
public readonly ValueChanged<bool> onHighlightChanged; |
|||
|
|||
public readonly bool containedInkWell; |
|||
|
|||
public readonly BoxShape highlightShape; |
|||
|
|||
public readonly double? radius; |
|||
|
|||
public readonly BorderRadius borderRadius; |
|||
|
|||
public readonly ShapeBorder customBorder; |
|||
|
|||
public readonly Color highlightColor; |
|||
|
|||
public readonly Color splashColor; |
|||
|
|||
public readonly InteractiveInkFeatureFactory splashFactory; |
|||
|
|||
public virtual RectCallback getRectCallback(RenderBox referenceBox) => null; |
|||
|
|||
|
|||
public virtual bool debugCheckContext(BuildContext context) { |
|||
D.assert(MaterialDebug.debugCheckHasMaterial(context)); |
|||
return true; |
|||
} |
|||
|
|||
public override State createState() => new _InkResponseState<InkResponse>(); |
|||
|
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
List<string> gestures = new List<string>(); |
|||
if (this.onTap != null) |
|||
gestures.Add("tap"); |
|||
if (this.onDoubleTap != null) |
|||
gestures.Add("double tap"); |
|||
if (this.onLongPress != null) |
|||
gestures.Add("long press"); |
|||
if (this.onTapDown != null) |
|||
gestures.Add("tap down"); |
|||
if (this.onTapCancel != null) |
|||
gestures.Add("tap cancel"); |
|||
properties.add(new EnumerableProperty<string>("gestures", gestures, ifEmpty: "<none>")); |
|||
properties.add(new DiagnosticsProperty<bool>("containedInkWell", this.containedInkWell, level: DiagnosticLevel.fine)); |
|||
properties.add(new DiagnosticsProperty<BoxShape>( |
|||
"highlightShape", |
|||
this.highlightShape, |
|||
description: (this.containedInkWell ? "clipped to" : "") + this.highlightShape, |
|||
showName: false |
|||
)); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class _InkResponseState<T> : AutomaticKeepAliveClientMixin<T> where T : InkResponse { |
|||
HashSet<InteractiveInkFeature> _splashes; |
|||
InteractiveInkFeature _currentSplash; |
|||
InkHighlight _lastHighlight; |
|||
|
|||
protected override bool wantKeepAlive { |
|||
get { return this._lastHighlight != null || (this._splashes != null && this._splashes.isNotEmpty()); } |
|||
} |
|||
|
|||
public void updateHighlight(bool value) { |
|||
if (value == (this._lastHighlight != null && this._lastHighlight.active)) |
|||
return; |
|||
if (value) { |
|||
if (this._lastHighlight == null) { |
|||
RenderBox referenceBox = (RenderBox)this.context.findRenderObject(); |
|||
this._lastHighlight = new InkHighlight( |
|||
controller: Material.of(this.context), |
|||
referenceBox: referenceBox, |
|||
color: this.widget.highlightColor ?? Theme.of(this.context).highlightColor, |
|||
shape: this.widget.highlightShape, |
|||
borderRadius: this.widget.borderRadius, |
|||
customBorder: this.widget.customBorder, |
|||
rectCallback: this.widget.getRectCallback(referenceBox), |
|||
onRemoved: this._handleInkHighlightRemoval); |
|||
this.updateKeepAlive(); |
|||
} |
|||
else { |
|||
this._lastHighlight.activate(); |
|||
} |
|||
} |
|||
else { |
|||
this._lastHighlight.deactivate(); |
|||
} |
|||
D.assert(value == (this._lastHighlight != null && this._lastHighlight.active)); |
|||
if (this.widget.onHighlightChanged != null) |
|||
this.widget.onHighlightChanged(value); |
|||
} |
|||
|
|||
void _handleInkHighlightRemoval() { |
|||
D.assert(this._lastHighlight != null); |
|||
this._lastHighlight = null; |
|||
this.updateKeepAlive(); |
|||
} |
|||
|
|||
InteractiveInkFeature _createInkFeature(TapDownDetails details) { |
|||
MaterialInkController inkController = Material.of(this.context); |
|||
RenderBox referenceBox = (RenderBox) this.context.findRenderObject(); |
|||
Offset position = referenceBox.globalToLocal(details.globalPosition); |
|||
Color color = this.widget.splashColor ?? Theme.of(this.context).splashColor; |
|||
RectCallback rectCallback = this.widget.containedInkWell ? this.widget.getRectCallback(referenceBox) : null; |
|||
BorderRadius borderRadius = this.widget.borderRadius; |
|||
ShapeBorder customBorder = this.widget.customBorder; |
|||
|
|||
InteractiveInkFeature splash = null; |
|||
|
|||
VoidCallback onRemoved = () => { |
|||
if (this._splashes != null) { |
|||
D.assert(this._splashes.Contains(splash)); |
|||
this._splashes.Remove(splash); |
|||
if (this._currentSplash == splash) |
|||
this._currentSplash = null; |
|||
this.updateKeepAlive(); |
|||
} |
|||
}; |
|||
|
|||
splash = (this.widget.splashFactory ?? Theme.of(this.context).splashFactory).create( |
|||
controller: inkController, |
|||
referenceBox: referenceBox, |
|||
position: position, |
|||
color: color, |
|||
containedInkWell: this.widget.containedInkWell, |
|||
rectCallback: rectCallback, |
|||
radius: this.widget.radius, |
|||
borderRadius: borderRadius, |
|||
customBorder: customBorder, |
|||
onRemoved: onRemoved); |
|||
|
|||
return splash; |
|||
} |
|||
|
|||
|
|||
void _handleTapDown(TapDownDetails details) { |
|||
InteractiveInkFeature splash = this._createInkFeature(details); |
|||
this._splashes = this._splashes ?? new HashSet<InteractiveInkFeature>(); |
|||
this._splashes.Add(splash); |
|||
this._currentSplash = splash; |
|||
if (this.widget.onTapDown != null) { |
|||
this.widget.onTapDown(details); |
|||
} |
|||
this.updateKeepAlive(); |
|||
this.updateHighlight(true); |
|||
} |
|||
|
|||
void _handleTap(BuildContext context) { |
|||
this._currentSplash?.confirm(); |
|||
this._currentSplash = null; |
|||
this.updateHighlight(false); |
|||
if (this.widget.onTap != null) { |
|||
this.widget.onTap(); |
|||
} |
|||
} |
|||
|
|||
void _handleTapCancel() { |
|||
this._currentSplash?.cancel(); |
|||
this._currentSplash = null; |
|||
if (this.widget.onTapCancel != null) { |
|||
this.widget.onTapCancel(); |
|||
} |
|||
this.updateHighlight(false); |
|||
} |
|||
|
|||
void _handleDoubleTap() { |
|||
this._currentSplash?.confirm(); |
|||
this._currentSplash = null; |
|||
if (this.widget.onDoubleTap != null) { |
|||
this.widget.onDoubleTap(); |
|||
} |
|||
} |
|||
|
|||
void _handleLongPress(BuildContext context) { |
|||
this._currentSplash?.confirm(); |
|||
this._currentSplash = null; |
|||
if (this.widget.onLongPress != null) { |
|||
this.widget.onLongPress(); |
|||
} |
|||
} |
|||
|
|||
public override void deactivate() { |
|||
if (this._splashes != null) { |
|||
HashSet<InteractiveInkFeature> splashes = this._splashes; |
|||
this._splashes = null; |
|||
foreach (InteractiveInkFeature splash in splashes) |
|||
splash.dispose(); |
|||
this._currentSplash = null; |
|||
} |
|||
D.assert(this._currentSplash == null); |
|||
this._lastHighlight?.dispose(); |
|||
this._lastHighlight = null; |
|||
base.deactivate(); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
D.assert(this.widget.debugCheckContext(context)); |
|||
base.build(context); |
|||
ThemeData themeData = Theme.of(context); |
|||
if (this._lastHighlight != null) |
|||
this._lastHighlight.color = this.widget.highlightColor ?? themeData.highlightColor; |
|||
if (this._currentSplash != null) |
|||
this._currentSplash.color = this.widget.splashColor ?? themeData.splashColor; |
|||
bool enabled = this.widget.onTap != null || this.widget.onDoubleTap != null || |
|||
this.widget.onLongPress != null; |
|||
|
|||
return new GestureDetector( |
|||
onTapDown: enabled? (GestureTapDownCallback)this._handleTapDown : null, |
|||
onTap: enabled? (GestureTapCallback)(() => this._handleTap(context)) : null, |
|||
onTapCancel: enabled? (GestureTapCancelCallback)this._handleTapCancel : null, |
|||
onDoubleTap: this.widget.onDoubleTap != null ? (GestureDoubleTapCallback)this._handleDoubleTap : null, |
|||
onLongPress: this.widget.onLongPress != null ? (GestureLongPressCallback)(() => this._handleLongPress(context)) : null, |
|||
behavior: HitTestBehavior.opaque, |
|||
child: this.widget.child |
|||
); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class InkWell : InkResponse { |
|||
public InkWell( |
|||
Key key = null, |
|||
Widget child = null, |
|||
GestureTapCallback onTap = null, |
|||
GestureTapCallback onDoubleTap = null, |
|||
GestureLongPressCallback onLongPress = null, |
|||
GestureTapDownCallback onTapDown = null, |
|||
GestureTapCancelCallback onTapCancel = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
InteractiveInkFeatureFactory splashFactory = null, |
|||
double? radius = null, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder customBorder = null |
|||
) : base(key: key, |
|||
child: child, |
|||
onTap: onTap, |
|||
onDoubleTap: onDoubleTap, |
|||
onLongPress: onLongPress, |
|||
onTapDown: onTapDown, |
|||
onTapCancel: onTapCancel, |
|||
onHighlightChanged: onHighlightChanged, |
|||
containedInkWell: true, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
splashFactory: splashFactory, |
|||
radius: radius, |
|||
borderRadius: borderRadius, |
|||
customBorder: customBorder){} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9a7302f1a187741b88618822daf7a657 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.scheduler; |
|||
using Unity.UIWidgets.widgets; |
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public delegate Rect RectCallback(); |
|||
|
|||
public enum MaterialType { |
|||
canvas, |
|||
card, |
|||
circle, |
|||
button, |
|||
transparency |
|||
} |
|||
|
|||
|
|||
public interface MaterialInkController { |
|||
|
|||
Color color { get; set; } |
|||
|
|||
TickerProvider vsync { get; } |
|||
|
|||
void addInkFeature(InkFeature feature); |
|||
|
|||
void markNeedsPaint(); |
|||
} |
|||
|
|||
|
|||
public class Material : StatefulWidget { |
|||
public Material( |
|||
Key key = null, |
|||
MaterialType type = MaterialType.canvas, |
|||
double elevation = 0.0, |
|||
Color color = null, |
|||
Color shadowColor = null, |
|||
TextStyle textStyle = null, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
TimeSpan? animationDuration = null, |
|||
Widget child = null |
|||
) : base(key: key) { |
|||
D.assert(type != null); |
|||
D.assert(elevation != null); |
|||
D.assert(!(shape != null && borderRadius != null)); |
|||
D.assert(type != MaterialType.circle && (borderRadius != null || shape != null)); |
|||
D.assert(clipBehavior != null); |
|||
|
|||
this.type = type; |
|||
this.elevation = elevation; |
|||
this.color = color; |
|||
this.shadowColor = shadowColor ?? new Color(0xFF000000); |
|||
this.textStyle = textStyle; |
|||
this.borderRadius = borderRadius; |
|||
this.shape = shape; |
|||
this.clipBehavior = clipBehavior; |
|||
this.animationDuration = animationDuration ?? Constants.kThemeChangeDuration; |
|||
this.child = child; |
|||
} |
|||
|
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly MaterialType type; |
|||
|
|||
public readonly double elevation; |
|||
|
|||
public readonly Color color; |
|||
|
|||
public readonly Color shadowColor; |
|||
|
|||
public readonly TextStyle textStyle; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public readonly Clip clipBehavior; |
|||
|
|||
public readonly TimeSpan animationDuration; |
|||
|
|||
public readonly BorderRadius borderRadius; |
|||
|
|||
|
|||
public static MaterialInkController of(BuildContext context) { |
|||
_RenderInkFeatures result = (_RenderInkFeatures) context.ancestorRenderObjectOfType(new TypeMatcher<_RenderInkFeatures>()); |
|||
return result; |
|||
} |
|||
|
|||
public override State createState() => new _MaterialState(); |
|||
|
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new EnumProperty<MaterialType>("type", this.type)); |
|||
properties.add(new DoubleProperty("elevation", this.elevation, defaultValue: 0.0)); |
|||
properties.add(new DiagnosticsProperty<Color>("color", this.color, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor, defaultValue: new Color(0xFF000000))); |
|||
this.textStyle?.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: null)); |
|||
properties.add(new EnumProperty<BorderRadius>("borderRadius", this.borderRadius, defaultValue: null)); |
|||
} |
|||
|
|||
public static double defaultSplashRadius = 35.0; |
|||
} |
|||
|
|||
|
|||
class _MaterialState : TickerProviderStateMixin<Material> { |
|||
readonly GlobalKey _inkFeatureRenderer = GlobalKey.key(debugLabel:"ink renderer"); |
|||
|
|||
Color _getBackgroundColor(BuildContext context) { |
|||
if (this.widget.color != null) |
|||
return this.widget.color; |
|||
switch (this.widget.type) { |
|||
case MaterialType.canvas: |
|||
return Theme.of(context).canvasColor; |
|||
case MaterialType.card: |
|||
return Theme.of(context).cardColor; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
Color backgroundColor = this._getBackgroundColor(context); |
|||
D.assert(backgroundColor != null || this.widget.type == MaterialType.transparency); |
|||
Widget contents = this.widget.child; |
|||
if (contents != null) { |
|||
contents = new AnimatedDefaultTextStyle( |
|||
style: this.widget.textStyle ?? Theme.of(context).textTheme.body1, |
|||
duration: this.widget.animationDuration, |
|||
child: contents |
|||
); |
|||
} |
|||
|
|||
contents = new NotificationListener<LayoutChangedNotification>( |
|||
onNotification: (LayoutChangedNotification notification) => { |
|||
_RenderInkFeatures renderer = (_RenderInkFeatures) this._inkFeatureRenderer.currentContext.findRenderObject(); |
|||
renderer._didChangeLayout(); |
|||
return true; |
|||
}, |
|||
child: new _InkFeatures( |
|||
key: this._inkFeatureRenderer, |
|||
color: backgroundColor, |
|||
child: contents, |
|||
vsync: this |
|||
) |
|||
); |
|||
|
|||
if (this.widget.type == MaterialType.canvas && this.widget.shape == null && |
|||
this.widget.borderRadius == null) { |
|||
return new AnimatedPhysicalModel( |
|||
curve: Curves.fastOutSlowIn, |
|||
duration: this.widget.animationDuration, |
|||
shape: BoxShape.rectangle, |
|||
clipBehavior: this.widget.clipBehavior, |
|||
borderRadius: BorderRadius.zero, |
|||
elevation: this.widget.elevation, |
|||
color: backgroundColor, |
|||
shadowColor: this.widget.shadowColor, |
|||
animateColor: false, |
|||
child: contents |
|||
); |
|||
} |
|||
|
|||
ShapeBorder shape = this._getShape(); |
|||
|
|||
if (this.widget.type == MaterialType.transparency) { |
|||
D.assert(false, "material widget is not completely implemented yet."); |
|||
return null; |
|||
// return this._transparentInterior(
|
|||
// shape: shape,
|
|||
// clipBehavior: this.widget.clipBehavior,
|
|||
// contents: contents);
|
|||
} |
|||
|
|||
return new _MaterialInterior( |
|||
curve: Curves.fastOutSlowIn, |
|||
duration: this.widget.animationDuration, |
|||
shape: shape, |
|||
clipBehavior: this.widget.clipBehavior, |
|||
elevation: this.widget.elevation, |
|||
color: backgroundColor, |
|||
shadowColor: this.widget.shadowColor, |
|||
child: contents |
|||
); |
|||
} |
|||
|
|||
|
|||
ShapeBorder _getShape() { |
|||
if (this.widget.shape != null) |
|||
return this.widget.shape; |
|||
if (this.widget.borderRadius != null) |
|||
return new RoundedRectangleBorder(borderRadius: this.widget.borderRadius); |
|||
switch (this.widget.type) { |
|||
case MaterialType.canvas: |
|||
case MaterialType.transparency: |
|||
return new RoundedRectangleBorder(); |
|||
case MaterialType.card: |
|||
case MaterialType.button: |
|||
return new RoundedRectangleBorder( |
|||
borderRadius: this.widget.borderRadius ?? MaterialUtils.kMaterialEdges[this.widget.type]); |
|||
case MaterialType.circle: |
|||
return new CircleBorder(); |
|||
} |
|||
return new RoundedRectangleBorder(); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class _RenderInkFeatures : RenderProxyBox, MaterialInkController { |
|||
public _RenderInkFeatures( |
|||
RenderBox child = null, |
|||
TickerProvider vsync = null, |
|||
Color color = null) : base(child: child) { |
|||
D.assert(vsync != null); |
|||
this._vsync = vsync; |
|||
this._color = color; |
|||
} |
|||
|
|||
public TickerProvider vsync { |
|||
get { return this._vsync; } |
|||
} |
|||
|
|||
readonly TickerProvider _vsync; |
|||
|
|||
public Color color { |
|||
get { return this._color; } |
|||
set { this._color = value; } |
|||
} |
|||
|
|||
Color _color; |
|||
|
|||
List<InkFeature> _inkFeatures; |
|||
|
|||
public void addInkFeature(InkFeature feature) { |
|||
D.assert(!feature._debugDisposed); |
|||
D.assert(feature._controller == this); |
|||
this._inkFeatures = this._inkFeatures ?? new List<InkFeature>(); |
|||
D.assert(!this._inkFeatures.Contains(feature)); |
|||
this._inkFeatures.Add(feature); |
|||
this.markNeedsPaint(); |
|||
} |
|||
|
|||
public void _removeFeature(InkFeature feature) { |
|||
D.assert(this._inkFeatures != null); |
|||
this._inkFeatures.Remove(feature); |
|||
this.markNeedsPaint(); |
|||
} |
|||
|
|||
public void _didChangeLayout() { |
|||
if (this._inkFeatures != null && this._inkFeatures.isNotEmpty()) |
|||
this.markNeedsPaint(); |
|||
} |
|||
|
|||
protected override bool hitTestSelf(Offset position) => true; |
|||
|
|||
public override void paint(PaintingContext context, Offset offset) { |
|||
if (this._inkFeatures != null && this._inkFeatures.isNotEmpty()) { |
|||
Canvas canvas = context.canvas; |
|||
canvas.save(); |
|||
canvas.translate(offset.dx, offset.dy); |
|||
canvas.clipRect(Offset.zero & this.size); |
|||
foreach (InkFeature inkFeature in this._inkFeatures) |
|||
inkFeature._paint(canvas); |
|||
canvas.restore(); |
|||
} |
|||
base.paint(context, offset); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class _InkFeatures : SingleChildRenderObjectWidget { |
|||
public _InkFeatures( |
|||
Key key = null, |
|||
Color color = null, |
|||
TickerProvider vsync = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
D.assert(vsync != null); |
|||
this.color = color; |
|||
this.vsync = vsync; |
|||
} |
|||
|
|||
public readonly Color color; |
|||
|
|||
public readonly TickerProvider vsync; |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new _RenderInkFeatures( |
|||
color: this.color, |
|||
vsync: this.vsync); |
|||
} |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
_RenderInkFeatures _renderObject = (_RenderInkFeatures) renderObject; |
|||
_renderObject.color = this.color; |
|||
D.assert(this.vsync == _renderObject.vsync); |
|||
} |
|||
} |
|||
|
|||
public abstract class InkFeature { |
|||
public InkFeature( |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
VoidCallback onRemoved = null) { |
|||
D.assert(controller != null); |
|||
D.assert(referenceBox != null); |
|||
this._controller = (_RenderInkFeatures)controller; |
|||
this.referenceBox = referenceBox; |
|||
this.onRemoved = onRemoved; |
|||
} |
|||
|
|||
public MaterialInkController controller { |
|||
get { return this._controller; } |
|||
} |
|||
|
|||
public _RenderInkFeatures _controller; |
|||
|
|||
public readonly RenderBox referenceBox; |
|||
|
|||
public readonly VoidCallback onRemoved; |
|||
|
|||
public bool _debugDisposed = false; |
|||
|
|||
public virtual void dispose() { |
|||
D.assert(!this._debugDisposed); |
|||
D.assert(() => { |
|||
this._debugDisposed = true; |
|||
return true; |
|||
}); |
|||
this._controller._removeFeature(this); |
|||
if (this.onRemoved != null) |
|||
this.onRemoved(); |
|||
} |
|||
|
|||
public void _paint(Canvas canvas) { |
|||
D.assert(this.referenceBox.attached); |
|||
D.assert(!this._debugDisposed); |
|||
|
|||
List<RenderObject> descendants = new List<RenderObject> { this.referenceBox }; |
|||
RenderObject node = this.referenceBox; |
|||
while (node != this._controller) { |
|||
node = (RenderObject)node.parent; |
|||
D.assert(node != null); |
|||
descendants.Add(node); |
|||
} |
|||
|
|||
Matrix3 transform = Matrix3.I(); |
|||
D.assert(descendants.Count >= 2); |
|||
for(int index = descendants.Count - 1; index > 0; index -= 1) |
|||
descendants[index].applyPaintTransform(descendants[index - 1], transform); |
|||
this.paintFeature(canvas, transform); |
|||
} |
|||
|
|||
protected abstract void paintFeature(Canvas canvas, Matrix3 transform); |
|||
|
|||
public string toString() => this.GetType() + ""; |
|||
} |
|||
|
|||
public class ShapeBorderTween : Tween<ShapeBorder> { |
|||
public ShapeBorderTween( |
|||
ShapeBorder begin = null, |
|||
ShapeBorder end = null) : base(begin: begin, end: end) {} |
|||
|
|||
public override ShapeBorder lerp(double t) { |
|||
return ShapeBorder.lerp(this.begin, this.end, t); |
|||
} |
|||
} |
|||
|
|||
public class _MaterialInterior : ImplicitlyAnimatedWidget { |
|||
public _MaterialInterior( |
|||
Key key = null, |
|||
Widget child = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
double? elevation = null, |
|||
Color color = null, |
|||
Color shadowColor = null, |
|||
Curve curve = null, |
|||
TimeSpan? duration = null |
|||
) : base(key : key, curve : curve ?? Curves.linear, duration : duration){ |
|||
D.assert(child != null); |
|||
D.assert(shape != null); |
|||
D.assert(elevation != null); |
|||
D.assert(color != null); |
|||
D.assert(shadowColor != null); |
|||
D.assert(duration != null); |
|||
this.child = child; |
|||
this.shape = shape; |
|||
this.clipBehavior = clipBehavior; |
|||
this.elevation = elevation ?? 0.0; |
|||
this.color = color; |
|||
this.shadowColor = shadowColor; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public readonly Clip clipBehavior; |
|||
|
|||
public readonly double elevation; |
|||
|
|||
public readonly Color color; |
|||
|
|||
public readonly Color shadowColor; |
|||
|
|||
public override State createState() => new _MaterialInteriorState(); |
|||
|
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder description) { |
|||
base.debugFillProperties(description); |
|||
description.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape)); |
|||
description.add(new DoubleProperty("elevation", this.elevation)); |
|||
description.add(new DiagnosticsProperty<Color>("color", this.color)); |
|||
description.add(new DiagnosticsProperty<Color>("shadowColor", this.shadowColor)); |
|||
} |
|||
} |
|||
|
|||
public class _MaterialInteriorState : AnimatedWidgetBaseState<_MaterialInterior> { |
|||
DoubleTween _elevation; |
|||
ColorTween _shadowColor; |
|||
ShapeBorderTween _border; |
|||
|
|||
protected override void forEachTween(ITweenVisitor visitor) { |
|||
this._elevation = (DoubleTween) visitor.visit(this, this._elevation, this.widget.elevation, |
|||
(double value) => new DoubleTween(begin: value, end: value)); |
|||
this._shadowColor = (ColorTween) visitor.visit(this, this._shadowColor, this.widget.shadowColor, |
|||
(Color value) => new ColorTween(begin: value)); |
|||
this._border = (ShapeBorderTween) visitor.visit(this, this._border, this.widget.shape, |
|||
(ShapeBorder value) => new ShapeBorderTween(begin: value)); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ShapeBorder shape = this._border.evaluate(this.animation); |
|||
return new PhysicalShape( |
|||
child : new _ShapeBorderPaint( |
|||
child : this.widget.child, |
|||
shape: shape), |
|||
clipper: new ShapeBorderClipper( |
|||
shape: shape), |
|||
clipBehavior: this.widget.clipBehavior, |
|||
elevation: this._elevation.evaluate(this.animation), |
|||
color: this.widget.color, |
|||
shadowColor: this._shadowColor.evaluate(this.animation) |
|||
); |
|||
} |
|||
} |
|||
|
|||
class _ShapeBorderPaint : StatelessWidget { |
|||
public _ShapeBorderPaint( |
|||
Widget child = null, |
|||
ShapeBorder shape = null) { |
|||
D.assert(child != null); |
|||
D.assert(shape != null); |
|||
this.child = child; |
|||
this.shape = shape; |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new CustomPaint( |
|||
child :this.child, |
|||
foregroundPainter: new _ShapeBorderPainter(this.shape)); |
|||
} |
|||
} |
|||
|
|||
class _ShapeBorderPainter : CustomPainter { |
|||
public _ShapeBorderPainter ( |
|||
ShapeBorder border = null, |
|||
Listenable repaint = null) : base(repaint) { |
|||
this.border = border; |
|||
} |
|||
|
|||
public readonly ShapeBorder border; |
|||
|
|||
|
|||
public override void paint(Canvas canvas, Size size) { |
|||
this.border.paint(canvas, Offset.zero & size); |
|||
} |
|||
|
|||
public override bool shouldRepaint(CustomPainter oldDelegate) { |
|||
_ShapeBorderPainter _oldDelegate = (_ShapeBorderPainter) oldDelegate; |
|||
return _oldDelegate.border != this.border; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7c1f7bd49df00452d9a3be75a9e7b213 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Runtime.CompilerServices; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public class MaterialButton : StatelessWidget { |
|||
public MaterialButton( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme? textTheme = null, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness? colorBrightness = null, |
|||
double? elevation = null, |
|||
double? highlightElevation = null, |
|||
double? disabledElevation = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
TimeSpan? animationDuration = null, |
|||
double? minWidth = null, |
|||
double? height = null, |
|||
Widget child = null |
|||
) : base(key : key) { |
|||
D.assert(onPressed != null); |
|||
this.onPressed = onPressed; |
|||
this.onHighlightChanged = onHighlightChanged; |
|||
this.textTheme = textTheme; |
|||
this.textColor = textColor; |
|||
this.disabledTextColor = disabledTextColor; |
|||
this.color = color; |
|||
this.disabledColor = disabledColor; |
|||
this.highlightColor = highlightColor; |
|||
this.splashColor = splashColor; |
|||
this.colorBrightness = colorBrightness; |
|||
this.elevation = elevation; |
|||
this.highlightElevation = highlightElevation; |
|||
this.disabledElevation = disabledElevation; |
|||
this.padding = padding; |
|||
this.shape = shape; |
|||
this.clipBehavior = clipBehavior; |
|||
this.materialTapTargetSize = materialTapTargetSize; |
|||
this.animationDuration = animationDuration; |
|||
this.minWidth = minWidth; |
|||
this.height = height; |
|||
this.child = child; |
|||
} |
|||
|
|||
public readonly VoidCallback onPressed; |
|||
|
|||
public readonly ValueChanged<bool> onHighlightChanged; |
|||
|
|||
public readonly ButtonTextTheme? textTheme; |
|||
|
|||
public readonly Color textColor; |
|||
|
|||
public readonly Color disabledTextColor; |
|||
|
|||
public readonly Color color; |
|||
|
|||
public readonly Color disabledColor; |
|||
|
|||
public readonly Color splashColor; |
|||
|
|||
public readonly Color highlightColor; |
|||
|
|||
public readonly double? elevation; |
|||
|
|||
public readonly double? highlightElevation; |
|||
|
|||
public readonly double? disabledElevation; |
|||
|
|||
public readonly Brightness? colorBrightness; |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public bool enabled => this.onPressed != null; |
|||
|
|||
public readonly EdgeInsets padding; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public readonly Clip? clipBehavior; |
|||
|
|||
public readonly TimeSpan? animationDuration; |
|||
|
|||
public readonly MaterialTapTargetSize? materialTapTargetSize; |
|||
|
|||
public readonly double? minWidth; |
|||
|
|||
public readonly double? height; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ThemeData theme = Theme.of(context); |
|||
ButtonThemeData buttonTheme = ButtonTheme.of(context); |
|||
|
|||
return new RawMaterialButton( |
|||
onPressed: this.onPressed, |
|||
fillColor: this.color, |
|||
textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)), |
|||
highlightColor: this.highlightColor ?? theme.highlightColor, |
|||
splashColor: this.splashColor ?? theme.splashColor, |
|||
elevation: buttonTheme.getElevation(this), |
|||
highlightElevation: buttonTheme.getHighlightElevation(this), |
|||
padding: buttonTheme.getPadding(this), |
|||
constraints: buttonTheme.getConstraints(this).copyWith( |
|||
minWidth: this.minWidth, |
|||
minHeight: this.height), |
|||
shape: buttonTheme.shape, |
|||
clipBehavior: this.clipBehavior ?? Clip.none, |
|||
animationDuration: buttonTheme.getAnimationDuration(this), |
|||
child: this.child, |
|||
materialTapTargetSize: this.materialTapTargetSize ?? theme.materialTapTargetSize); |
|||
} |
|||
|
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new FlagProperty("enabled", value: this.enabled, ifFalse: "disabled")); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ea3964e7af24d4b059ac6e10ec862a3b |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class TextTheme : Diagnosticable { |
|||
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, |
|||
TextStyle display3, |
|||
TextStyle display2, |
|||
TextStyle display1, |
|||
TextStyle headline, |
|||
TextStyle title, |
|||
TextStyle subhead, |
|||
TextStyle body2, |
|||
TextStyle body1, |
|||
TextStyle caption, |
|||
TextStyle button, |
|||
TextStyle subtitle, |
|||
TextStyle overline |
|||
) { |
|||
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 this.copyWith( |
|||
display4: this.display4?.merge(other.display4) ?? other.display4, |
|||
display3: this.display3?.merge(other.display3) ?? other.display3, |
|||
display2: this.display2?.merge(other.display2) ?? other.display2, |
|||
display1: this.display1?.merge(other.display1) ?? other.display1, |
|||
headline: this.headline?.merge(other.headline) ?? other.headline, |
|||
title: this.title?.merge(other.title) ?? other.title, |
|||
subhead: this.subhead?.merge(other.subhead) ?? other.subhead, |
|||
body2: this.body2?.merge(other.body2) ?? other.body2, |
|||
body1: this.body1?.merge(other.body1) ?? other.body1, |
|||
caption: this.caption?.merge(other.caption) ?? other.caption, |
|||
button: this.button?.merge(other.button) ?? other.button, |
|||
subtitle: this.subtitle?.merge(other.subtitle) ?? other.subtitle, |
|||
overline: this.overline?.merge(other.overline) ?? other.overline |
|||
); |
|||
} |
|||
|
|||
|
|||
public TextTheme apply( |
|||
string fontFamily = null, |
|||
double fontSizeFactor = 1.0, |
|||
double fontSizeDelta = 0.0, |
|||
Color displayColor = null, |
|||
Color bodyColor = null, |
|||
TextDecoration decoration = null, |
|||
Color decorationColor = null, |
|||
TextDecorationStyle? decorationStyle = null |
|||
) { |
|||
return new TextTheme( |
|||
display4: this.display4?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display3: this.display3?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display2: this.display2?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
display1: this.display1?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
headline: this.headline?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
title: this.title?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
subhead: this.subhead?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
body2: this.body2?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
body1: this.body1?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
caption: this.caption?.apply( |
|||
color: displayColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
button: this.button?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
subtitle: this.subtitle?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
), |
|||
overline: this.overline?.apply( |
|||
color: bodyColor, |
|||
decoration: decoration, |
|||
decorationColor: decorationColor, |
|||
decorationStyle: decorationStyle, |
|||
fontFamily: fontFamily, |
|||
fontSizeFactor: fontSizeFactor, |
|||
fontSizeDelta: fontSizeDelta |
|||
) |
|||
); |
|||
} |
|||
|
|||
public static TextTheme lerp(TextTheme a, TextTheme b, double t) { |
|||
D.assert(a != null); |
|||
D.assert(b != null); |
|||
D.assert(t != null); |
|||
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 this.display4 == other.display4 |
|||
&& this.display3 == other.display3 |
|||
&& this.display2 == other.display2 |
|||
&& this.display1 == other.display1 |
|||
&& this.headline == other.headline |
|||
&& this.title == other.title |
|||
&& this.subhead == other.subhead |
|||
&& this.body2 == other.body2 |
|||
&& this.body1 == other.body1 |
|||
&& this.caption == other.caption |
|||
&& this.button == other.button |
|||
&& this.subtitle == other.subtitle |
|||
&& this.overline == other.overline; |
|||
} |
|||
|
|||
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((TextTheme) obj); |
|||
} |
|||
|
|||
public static bool operator ==(TextTheme a, TextTheme b) { |
|||
return ReferenceEquals(a, null) ? ReferenceEquals(b, null) : a.Equals(b); |
|||
} |
|||
|
|||
public static bool operator !=(TextTheme a, TextTheme b) { |
|||
return !(a == b); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = this.display4.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.display3.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.display2.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.display1.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.headline.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.title.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.subhead.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.body2.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.body1.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.caption.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.button.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.subtitle.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.overline.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
TextTheme defaultTheme = new Typography().black; |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display4", this.display4, defaultValue: defaultTheme.display4)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display3", this.display3, defaultValue: defaultTheme.display3)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display2", this.display2, defaultValue: defaultTheme.display2)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("display1", this.display1, defaultValue: defaultTheme.display1)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("headline", this.headline, defaultValue: defaultTheme.headline)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("title", this.title, defaultValue: defaultTheme.title)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("subhead", this.subhead, defaultValue: defaultTheme.subhead)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("body2", this.body2, defaultValue: defaultTheme.body2)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("body1", this.body1, defaultValue: defaultTheme.body1)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("caption", this.caption, defaultValue: defaultTheme.caption)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("button", this.button, defaultValue: defaultTheme.button)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("subtitle)", this.subtitle, defaultValue: defaultTheme.subtitle)); |
|||
properties.add(new DiagnosticsProperty<TextStyle>("overline", this.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 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; |
|||
} |
|||
|
|||
//todo:xingwei.zhu: materialLocalizations
|
|||
return inheritedTheme?.theme?.data ?? _kFallbackTheme; |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new _InheritedTheme( |
|||
theme: this, |
|||
child: new IconTheme( |
|||
data: this.data.iconTheme, |
|||
child: this.child |
|||
) |
|||
); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
properties.add(new DiagnosticsProperty<ThemeData>("data", this.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) => |
|||
this.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(double t) => ThemeData.lerp(this.begin, this.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() => new _AnimatedThemeState(); |
|||
} |
|||
|
|||
|
|||
class _AnimatedThemeState : AnimatedWidgetBaseState<AnimatedTheme> { |
|||
ThemeDataTween _data; |
|||
|
|||
protected override void forEachTween(ITweenVisitor visitor) { |
|||
this._data = (ThemeDataTween) visitor.visit<ThemeData, AnimatedTheme>(this, this._data, this.widget.data, (ThemeData value) => new ThemeDataTween(begin: value)); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
return new Theme( |
|||
isMaterialAppTheme: this.widget.isMaterialAppTheme, |
|||
child: this.widget.child, |
|||
data: this._data.evaluate(this.animation) |
|||
); |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder description) { |
|||
base.debugFillProperties(description); |
|||
description.add(new DiagnosticsProperty<ThemeDataTween>("data", this._data, showName: false, defaultValue: null)); |
|||
} |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8aeba6b651be2405387572671ac527f6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 68fb5edae4e8440669205d4e5b27ea30 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.ui; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
using UnityEngine; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public enum ScriptCategory { |
|||
englishLike, |
|||
|
|||
dense, |
|||
|
|||
tall |
|||
} |
|||
|
|||
|
|||
public class Typography : Diagnosticable { |
|||
public Typography( |
|||
TextTheme black = null, |
|||
TextTheme white = null, |
|||
TextTheme englishLike = null, |
|||
TextTheme dense = null, |
|||
TextTheme tall = null |
|||
) { |
|||
black = black ?? blackMountainView; |
|||
white = white ?? whiteMountainView; |
|||
englishLike = englishLike ?? englishLike2014; |
|||
dense = dense ?? dense2014; |
|||
tall = tall ?? tall2014; |
|||
|
|||
D.assert(black != null); |
|||
D.assert(white != null); |
|||
D.assert(englishLike != null); |
|||
D.assert(dense != null); |
|||
D.assert(tall != null); |
|||
|
|||
this.black = black; |
|||
this.white = white; |
|||
this.englishLike = englishLike; |
|||
this.dense = dense; |
|||
this.tall = tall; |
|||
} |
|||
|
|||
|
|||
public readonly TextTheme black; |
|||
|
|||
public readonly TextTheme white; |
|||
|
|||
public readonly TextTheme englishLike; |
|||
|
|||
public readonly TextTheme dense; |
|||
|
|||
public readonly TextTheme tall; |
|||
|
|||
public TextTheme geometryThemeFor(ScriptCategory? category) { |
|||
D.assert(category != null); |
|||
switch (category) { |
|||
case ScriptCategory.englishLike: |
|||
return this.englishLike; |
|||
case ScriptCategory.dense: |
|||
return this.dense; |
|||
case ScriptCategory.tall: |
|||
return this.tall; |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
|
|||
public Typography copyWith( |
|||
TextTheme black = null, |
|||
TextTheme white = null, |
|||
TextTheme englishLike = null, |
|||
TextTheme dense = null, |
|||
TextTheme tall = null) { |
|||
return new Typography( |
|||
black: black ?? this.black, |
|||
white: white ?? this.white, |
|||
englishLike: englishLike ?? this.englishLike, |
|||
dense: dense ?? this.dense, |
|||
tall: tall ?? this.tall); |
|||
} |
|||
|
|||
public static Typography lerp(Typography a, Typography b, double t) { |
|||
return new Typography( |
|||
black: TextTheme.lerp(a.black, b.black, t), |
|||
white: TextTheme.lerp(a.white, b.white, t), |
|||
englishLike: TextTheme.lerp(a.englishLike, b.englishLike, t), |
|||
dense: TextTheme.lerp(a.dense, b.dense, t), |
|||
tall: TextTheme.lerp(a.tall, b.tall, t) |
|||
); |
|||
} |
|||
|
|||
|
|||
public bool Equals(Typography other) { |
|||
if (ReferenceEquals(null, other)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, other)) { |
|||
return true; |
|||
} |
|||
|
|||
return this.black == other.black |
|||
&& this.white == other.white |
|||
&& this.englishLike == other.englishLike |
|||
&& this.dense == other.dense |
|||
&& this.tall == other.tall; |
|||
} |
|||
|
|||
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((Typography) obj); |
|||
} |
|||
|
|||
public static bool operator ==(Typography a, Typography b) { |
|||
return ReferenceEquals(a, null) ? ReferenceEquals(b, null) : a.Equals(b); |
|||
} |
|||
|
|||
public static bool operator !=(Typography a, Typography b) { |
|||
return !(a == b); |
|||
} |
|||
|
|||
public override int GetHashCode() { |
|||
unchecked { |
|||
var hashCode = this.black.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.white.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.englishLike.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.dense.GetHashCode(); |
|||
hashCode = (hashCode * 397) ^ this.tall.GetHashCode(); |
|||
return hashCode; |
|||
} |
|||
} |
|||
|
|||
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) { |
|||
base.debugFillProperties(properties); |
|||
Typography defaultTypography = new Typography(); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextTheme>("black", this.black, defaultValue: defaultTypography.black)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextTheme>("white", this.white, defaultValue: defaultTypography.white)); |
|||
properties.add(new DiagnosticsProperty<TextTheme>("englishLike", this.englishLike, |
|||
defaultValue: defaultTypography.englishLike)); |
|||
properties.add( |
|||
new DiagnosticsProperty<TextTheme>("dense", this.dense, defaultValue: defaultTypography.dense)); |
|||
properties.add(new DiagnosticsProperty<TextTheme>("tall", this.tall, defaultValue: defaultTypography.tall)); |
|||
} |
|||
|
|||
public static TextTheme blackMountainView = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "blackMountainView display4", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display3: new TextStyle(debugLabel: "blackMountainView display3", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display2: new TextStyle(debugLabel: "blackMountainView display2", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display1: new TextStyle(debugLabel: "blackMountainView display1", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
headline: new TextStyle(debugLabel: "blackMountainView headline", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
title: new TextStyle(debugLabel: "blackMountainView title", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
subhead: new TextStyle(debugLabel: "blackMountainView subhead", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
body2: new TextStyle(debugLabel: "blackMountainView body2", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
body1: new TextStyle(debugLabel: "blackMountainView body1", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
caption: new TextStyle(debugLabel: "blackMountainView caption", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
button: new TextStyle(debugLabel: "blackMountainView button", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
subtitle: new TextStyle(debugLabel: "blackMountainView subtitle", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black, decoration: TextDecoration.none), |
|||
overline: new TextStyle(debugLabel: "blackMountainView overline", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.black, decoration: TextDecoration.none) |
|||
); |
|||
|
|||
public static TextTheme whiteMountainView = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "whiteMountainView display4", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display3: new TextStyle(debugLabel: "whiteMountainView display3", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display2: new TextStyle(debugLabel: "whiteMountainView display2", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display1: new TextStyle(debugLabel: "whiteMountainView display1", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
headline: new TextStyle(debugLabel: "whiteMountainView headline", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
title: new TextStyle(debugLabel: "whiteMountainView title", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
subhead: new TextStyle(debugLabel: "whiteMountainView subhead", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
body2: new TextStyle(debugLabel: "whiteMountainView body2", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
body1: new TextStyle(debugLabel: "whiteMountainView body1", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
caption: new TextStyle(debugLabel: "whiteMountainView caption", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
button: new TextStyle(debugLabel: "whiteMountainView button", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
subtitle: new TextStyle(debugLabel: "whiteMountainView subtitle", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
overline: new TextStyle(debugLabel: "whiteMountainView overline", fontFamily: "Roboto", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none) |
|||
); |
|||
|
|||
public static TextTheme blackCupertino = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "blackCupertino display4", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display3: new TextStyle(debugLabel: "blackCupertino display3", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display2: new TextStyle(debugLabel: "blackCupertino display2", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
display1: new TextStyle(debugLabel: "blackCupertino display1", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
headline: new TextStyle(debugLabel: "blackCupertino headline", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
title: new TextStyle(debugLabel: "blackCupertino title", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
subhead: new TextStyle(debugLabel: "blackCupertino subhead", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
body2: new TextStyle(debugLabel: "blackCupertino body2", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
body1: new TextStyle(debugLabel: "blackCupertino body1", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
caption: new TextStyle(debugLabel: "blackCupertino caption", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black54, decoration: TextDecoration.none), |
|||
button: new TextStyle(debugLabel: "blackCupertino button", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black87, decoration: TextDecoration.none), |
|||
subtitle: new TextStyle(debugLabel: "blackCupertino subtitle", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black, decoration: TextDecoration.none), |
|||
overline: new TextStyle(debugLabel: "blackCupertino overline", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.black, decoration: TextDecoration.none) |
|||
); |
|||
|
|||
public static TextTheme whiteCupertino = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "whiteCupertino display4", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display3: new TextStyle(debugLabel: "whiteCupertino display3", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display2: new TextStyle(debugLabel: "whiteCupertino display2", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
display1: new TextStyle(debugLabel: "whiteCupertino display1", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
headline: new TextStyle(debugLabel: "whiteCupertino headline", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
title: new TextStyle(debugLabel: "whiteCupertino title", fontFamily: ".SF UI Display", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
subhead: new TextStyle(debugLabel: "whiteCupertino subhead", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
body2: new TextStyle(debugLabel: "whiteCupertino body2", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
body1: new TextStyle(debugLabel: "whiteCupertino body1", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
caption: new TextStyle(debugLabel: "whiteCupertino caption", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white70, decoration: TextDecoration.none), |
|||
button: new TextStyle(debugLabel: "whiteCupertino button", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
subtitle: new TextStyle(debugLabel: "whiteCupertino subtitle", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none), |
|||
overline: new TextStyle(debugLabel: "whiteCupertino overline", fontFamily: ".SF UI Text", inherit: true, |
|||
color: Colors.white, decoration: TextDecoration.none) |
|||
); |
|||
|
|||
|
|||
public static TextTheme englishLike2014 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "englishLike display4 2014", inherit: false, fontSize: 112.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display3: new TextStyle(debugLabel: "englishLike display3 2014", inherit: false, fontSize: 56.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display2: new TextStyle(debugLabel: "englishLike display2 2014", inherit: false, fontSize: 45.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display1: new TextStyle(debugLabel: "englishLike display1 2014", inherit: false, fontSize: 34.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
headline: new TextStyle(debugLabel: "englishLike headline 2014", inherit: false, fontSize: 24.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
title: new TextStyle(debugLabel: "englishLike title 2014", inherit: false, fontSize: 20.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
subhead: new TextStyle(debugLabel: "englishLike subhead 2014", inherit: false, fontSize: 16.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
body2: new TextStyle(debugLabel: "englishLike body2 2014", inherit: false, fontSize: 14.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
body1: new TextStyle(debugLabel: "englishLike body1 2014", inherit: false, fontSize: 14.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
caption: new TextStyle(debugLabel: "englishLike caption 2014", inherit: false, fontSize: 12.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
button: new TextStyle(debugLabel: "englishLike button 2014", inherit: false, fontSize: 14.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2014", inherit: false, fontSize: 14.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1), |
|||
overline: new TextStyle(debugLabel: "englishLike overline 2014", inherit: false, fontSize: 10.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5) |
|||
); |
|||
|
|||
public static TextTheme englishLike2018 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "englishLike display4 2018", fontSize: 96.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -1.5), |
|||
display3: new TextStyle(debugLabel: "englishLike display3 2018", fontSize: 60.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: -0.5), |
|||
display2: new TextStyle(debugLabel: "englishLike display2 2018", fontSize: 48.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0), |
|||
display1: new TextStyle(debugLabel: "englishLike display1 2018", fontSize: 34.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25), |
|||
headline: new TextStyle(debugLabel: "englishLike headline 2018", fontSize: 24.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.0), |
|||
title: new TextStyle(debugLabel: "englishLike title 2018", fontSize: 20.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15), |
|||
subhead: new TextStyle(debugLabel: "englishLike subhead 2018", fontSize: 16.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.15), |
|||
body2: new TextStyle(debugLabel: "englishLike body2 2018", fontSize: 14.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.25), |
|||
body1: new TextStyle(debugLabel: "englishLike body1 2018", fontSize: 16.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.5), |
|||
button: new TextStyle(debugLabel: "englishLike button 2018", fontSize: 14.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.75), |
|||
caption: new TextStyle(debugLabel: "englishLike caption 2018", fontSize: 12.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic, letterSpacing: 0.4), |
|||
subtitle: new TextStyle(debugLabel: "englishLike subtitle 2018", fontSize: 14.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 0.1), |
|||
overline: new TextStyle(debugLabel: "englishLike overline 2018", fontSize: 10.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic, letterSpacing: 1.5) |
|||
); |
|||
|
|||
public static TextTheme dense2014 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "dense display4 2014", inherit: false, fontSize: 112.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
display3: new TextStyle(debugLabel: "dense display3 2014", inherit: false, fontSize: 56.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
display2: new TextStyle(debugLabel: "dense display2 2014", inherit: false, fontSize: 45.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
display1: new TextStyle(debugLabel: "dense display1 2014", inherit: false, fontSize: 34.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
headline: new TextStyle(debugLabel: "dense headline 2014", inherit: false, fontSize: 24.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
title: new TextStyle(debugLabel: "dense title 2014", inherit: false, fontSize: 21.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
subhead: new TextStyle(debugLabel: "dense subhead 2014", inherit: false, fontSize: 17.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
body2: new TextStyle(debugLabel: "dense body2 2014", inherit: false, fontSize: 15.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
body1: new TextStyle(debugLabel: "dense body1 2014", inherit: false, fontSize: 15.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
caption: new TextStyle(debugLabel: "dense caption 2014", inherit: false, fontSize: 13.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
button: new TextStyle(debugLabel: "dense button 2014", inherit: false, fontSize: 15.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
subtitle: new TextStyle(debugLabel: "dense subtitle 2014", inherit: false, fontSize: 15.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic), |
|||
overline: new TextStyle(debugLabel: "dense overline 2014", inherit: false, fontSize: 11.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.ideographic) |
|||
); |
|||
|
|||
public static TextTheme dense2018 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "dense display4 2018", fontSize: 96.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
display3: new TextStyle(debugLabel: "dense display3 2018", fontSize: 60.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
display2: new TextStyle(debugLabel: "dense display2 2018", fontSize: 48.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
display1: new TextStyle(debugLabel: "dense display1 2018", fontSize: 34.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
headline: new TextStyle(debugLabel: "dense headline 2018", fontSize: 24.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
title: new TextStyle(debugLabel: "dense title 2018", fontSize: 21.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
subhead: new TextStyle(debugLabel: "dense subhead 2018", fontSize: 17.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
body2: new TextStyle(debugLabel: "dense body2 2018", fontSize: 17.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
body1: new TextStyle(debugLabel: "dense body1 2018", fontSize: 15.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
caption: new TextStyle(debugLabel: "dense caption 2018", fontSize: 13.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
button: new TextStyle(debugLabel: "dense button 2018", fontSize: 15.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
subtitle: new TextStyle(debugLabel: "dense subtitle 2018", fontSize: 15.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic), |
|||
overline: new TextStyle(debugLabel: "dense overline 2018", fontSize: 11.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.ideographic) |
|||
); |
|||
|
|||
|
|||
public static TextTheme tall2014 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "tall display4 2014", inherit: false, fontSize: 112.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display3: new TextStyle(debugLabel: "tall display3 2014", inherit: false, fontSize: 56.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display2: new TextStyle(debugLabel: "tall display2 2014", inherit: false, fontSize: 45.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
display1: new TextStyle(debugLabel: "tall display1 2014", inherit: false, fontSize: 34.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
headline: new TextStyle(debugLabel: "tall headline 2014", inherit: false, fontSize: 24.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
title: new TextStyle(debugLabel: "tall title 2014", inherit: false, fontSize: 21.0, |
|||
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic), |
|||
subhead: new TextStyle(debugLabel: "tall subhead 2014", inherit: false, fontSize: 17.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
body2: new TextStyle(debugLabel: "tall body2 2014", inherit: false, fontSize: 15.0, |
|||
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic), |
|||
body1: new TextStyle(debugLabel: "tall body1 2014", inherit: false, fontSize: 15.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
caption: new TextStyle(debugLabel: "tall caption 2014", inherit: false, fontSize: 13.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
button: new TextStyle(debugLabel: "tall button 2014", inherit: false, fontSize: 15.0, |
|||
fontWeight: FontWeight.w700, textBaseline: TextBaseline.alphabetic), |
|||
subtitle: new TextStyle(debugLabel: "tall subtitle 2014", inherit: false, fontSize: 15.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic), |
|||
overline: new TextStyle(debugLabel: "tall overline 2014", inherit: false, fontSize: 11.0, |
|||
fontWeight: FontWeight.w400, textBaseline: TextBaseline.alphabetic) |
|||
); |
|||
|
|||
public static TextTheme tall2018 = new TextTheme( |
|||
display4: new TextStyle(debugLabel: "tall display4 2018", fontSize: 96.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
display3: new TextStyle(debugLabel: "tall display3 2018", fontSize: 60.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
display2: new TextStyle(debugLabel: "tall display2 2018", fontSize: 48.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
display1: new TextStyle(debugLabel: "tall display1 2018", fontSize: 34.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
headline: new TextStyle(debugLabel: "tall headline 2018", fontSize: 24.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
title: new TextStyle(debugLabel: "tall title 2018", fontSize: 21.0, fontWeight: FontWeight.w700, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
subhead: new TextStyle(debugLabel: "tall subhead 2018", fontSize: 17.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
body2: new TextStyle(debugLabel: "tall body2 2018", fontSize: 17.0, fontWeight: FontWeight.w700, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
body1: new TextStyle(debugLabel: "tall body1 2018", fontSize: 15.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
caption: new TextStyle(debugLabel: "tall caption 2018", fontSize: 13.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
button: new TextStyle(debugLabel: "tall button 2018", fontSize: 15.0, fontWeight: FontWeight.w700, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
subtitle: new TextStyle(debugLabel: "tall subtitle 2018", fontSize: 15.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic), |
|||
overline: new TextStyle(debugLabel: "tall overline 2018", fontSize: 11.0, fontWeight: FontWeight.w400, |
|||
textBaseline: TextBaseline.alphabetic) |
|||
); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a7dbdefd2b4fd44dd9ff8d23eb224a31 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 39236c38160ee4c0e928e3658102fd71 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 8589f247e5dcd4f4e8cc22eee9fdbf36 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7dec1d416078846ec89141bd833cb550 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ecf39d43bfae547a7ba543edafc67b19 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.widgets { |
|||
|
|||
public delegate Widget LayoutWidgetBuilder(BuildContext context, BoxConstraints constraints); |
|||
|
|||
|
|||
class LayoutBuilder : RenderObjectWidget { |
|||
|
|||
public LayoutBuilder( |
|||
Key key = null, |
|||
LayoutWidgetBuilder builder = null) : base(key: key) { |
|||
D.assert(builder != null); |
|||
this.builder = builder; |
|||
} |
|||
|
|||
public readonly LayoutWidgetBuilder builder; |
|||
|
|||
public override Element createElement() => new _LayoutBuilderElement(this); |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) => new _RenderLayoutBuilder(); |
|||
} |
|||
|
|||
class _LayoutBuilderElement : RenderObjectElement { |
|||
public _LayoutBuilderElement( |
|||
LayoutBuilder widget) : base(widget){} |
|||
|
|||
new LayoutBuilder widget => (LayoutBuilder) base.widget; |
|||
|
|||
new _RenderLayoutBuilder renderObject => (_RenderLayoutBuilder) base.renderObject; |
|||
|
|||
Element _child; |
|||
|
|||
public override void visitChildren(ElementVisitor visitor) { |
|||
if (this._child != null) |
|||
visitor(this._child); |
|||
} |
|||
|
|||
protected override void forgetChild(Element child) { |
|||
D.assert(child == this._child); |
|||
this._child = null; |
|||
} |
|||
|
|||
public override void mount(Element parent, object newSlot) { |
|||
base.mount(parent, newSlot); |
|||
this.renderObject.callback = this._layout; |
|||
} |
|||
|
|||
public override void update(Widget newWidget) { |
|||
D.assert(this.widget != newWidget); |
|||
base.update(newWidget); |
|||
D.assert(this.widget == newWidget); |
|||
this.renderObject.callback = this._layout; |
|||
this.renderObject.markNeedsLayout(); |
|||
} |
|||
|
|||
protected override void performRebuild() { |
|||
this.renderObject.markNeedsLayout(); |
|||
base.performRebuild(); |
|||
} |
|||
|
|||
public override void unmount() { |
|||
this.renderObject.callback = null; |
|||
base.unmount(); |
|||
} |
|||
|
|||
void _layout(BoxConstraints constraints) { |
|||
this.owner.buildScope(this, () => { |
|||
Widget built = null; |
|||
if (this.widget.builder != null) { |
|||
built = this.widget.builder(this, constraints); |
|||
WidgetsD.debugWidgetBuilderValue(this.widget, built); |
|||
} |
|||
|
|||
this._child = this.updateChild(this._child, built, null); |
|||
D.assert(this._child != null); |
|||
}); |
|||
} |
|||
|
|||
protected override void insertChildRenderObject(RenderObject child, object slot) { |
|||
_RenderLayoutBuilder renderObject = (_RenderLayoutBuilder) this.renderObject; |
|||
D.assert(slot == null); |
|||
D.assert(renderObject.debugValidateChild(child)); |
|||
renderObject.child = (RenderBox) child; |
|||
D.assert(renderObject == this.renderObject); |
|||
} |
|||
|
|||
protected override void moveChildRenderObject(RenderObject child, object slot) { |
|||
D.assert(false); |
|||
} |
|||
|
|||
protected override void removeChildRenderObject(RenderObject child) { |
|||
_RenderLayoutBuilder renderObject = (_RenderLayoutBuilder) this.renderObject; |
|||
D.assert(renderObject.child == child); |
|||
renderObject.child = null; |
|||
D.assert(renderObject == this.renderObject); |
|||
} |
|||
} |
|||
|
|||
|
|||
public class _RenderLayoutBuilder : RenderObjectWithChildMixinRenderBox<RenderBox> { |
|||
public _RenderLayoutBuilder( |
|||
LayoutCallback<BoxConstraints> callback = null) { |
|||
this._callback = callback; |
|||
} |
|||
|
|||
public LayoutCallback<BoxConstraints> callback { |
|||
get { return this._callback; } |
|||
set { |
|||
if (value == this._callback) |
|||
return; |
|||
this._callback = value; |
|||
this.markNeedsLayout(); |
|||
} |
|||
} |
|||
LayoutCallback<BoxConstraints> _callback; |
|||
|
|||
bool _debugThrowIfNotCheckingIntrinsics() { |
|||
D.assert(() => { |
|||
if (!RenderObject.debugCheckingIntrinsics) { |
|||
throw new UIWidgetsError( |
|||
"LayoutBuilder does not support returning intrinsic dimensions.\n" + |
|||
"Calculating the intrinsic dimensions would require running the layout " + |
|||
"callback speculatively, which might mutate the live render object tree." |
|||
); |
|||
} |
|||
return true; |
|||
}); |
|||
return true; |
|||
} |
|||
|
|||
protected override double computeMinIntrinsicWidth(double height) { |
|||
D.assert(this._debugThrowIfNotCheckingIntrinsics()); |
|||
return 0.0; |
|||
} |
|||
|
|||
protected override double computeMaxIntrinsicWidth(double height) { |
|||
D.assert(this._debugThrowIfNotCheckingIntrinsics()); |
|||
return 0.0; |
|||
} |
|||
|
|||
protected override double computeMinIntrinsicHeight(double width) { |
|||
D.assert(this._debugThrowIfNotCheckingIntrinsics()); |
|||
return 0.0; |
|||
} |
|||
|
|||
protected override double computeMaxIntrinsicHeight(double width) { |
|||
D.assert(this._debugThrowIfNotCheckingIntrinsics()); |
|||
return 0.0; |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
D.assert(this.callback != null); |
|||
this.invokeLayoutCallback(this.callback); |
|||
if (this.child != null) { |
|||
this.child.layout(this.constraints, parentUsesSize: true); |
|||
this.size = this.constraints.constrain(this.child.size); |
|||
} |
|||
else { |
|||
this.size = this.constraints.biggest; |
|||
} |
|||
} |
|||
|
|||
protected override bool hitTestChildren(HitTestResult result, Offset position = null) { |
|||
return this.child?.hitTest(result, position: position) ?? false; |
|||
} |
|||
|
|||
public override void paint(PaintingContext context, Offset offset) { |
|||
if (this.child != null) |
|||
context.paintChild(this.child, offset); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d29b34cdfd63d4edb97960beede8a990 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.engine; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.painting; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class MaterialCanvas : WidgetCanvas { |
|||
protected override Widget getWidget() { |
|||
return new MaterialApp(); |
|||
} |
|||
|
|||
class MaterialApp : StatefulWidget { |
|||
public MaterialApp(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new MaterialWidgetState(); |
|||
} |
|||
} |
|||
|
|||
class MaterialWidget : StatefulWidget { |
|||
public MaterialWidget(Key key = null) : base(key) { |
|||
} |
|||
|
|||
public override State createState() { |
|||
return new MaterialWidgetState(); |
|||
} |
|||
} |
|||
|
|||
// test-case: material button
|
|||
class MaterialWidgetState : State<MaterialWidget> { |
|||
public override Widget build(BuildContext context) { |
|||
return new Material( |
|||
child : new Center( |
|||
child : new Container( |
|||
width: 30, |
|||
height : 30, |
|||
child: new MaterialButton( |
|||
color: Colors.blue, |
|||
splashColor: new Color(0xFFFF0011), |
|||
highlightColor: new Color(0x88000011), |
|||
onPressed : () => { })))); |
|||
} |
|||
} |
|||
|
|||
// // test-case: ink well
|
|||
// class MaterialWidgetState : State<MaterialWidget> {
|
|||
// public override Widget build(BuildContext context) {
|
|||
// return new Material(
|
|||
// child: new Center(
|
|||
// child: new Container(
|
|||
// width: 30,
|
|||
// height: 30,
|
|||
// child : new InkWell(
|
|||
// borderRadius: BorderRadius.circular(2.0),
|
|||
// highlightColor: new Color(0xAAFF0000),
|
|||
// splashColor: new Color(0xAA0000FF),
|
|||
// //radius : 20,
|
|||
// onTap: () => { }
|
|||
// ))
|
|||
// )
|
|||
// );
|
|||
// }
|
|||
// }
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d7c3be43dd8b94a349f26e3e7173c3f6 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue