浏览代码

Merge branch 'siyaoH/1.17/material' of github.com:Unity-Technologies/com.unity.uiwidgets into zxw/1.17/material

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
94c8f9c9
共有 51 个文件被更改,包括 1772 次插入1241 次删除
  1. 16
      com.unity.uiwidgets/Runtime/material/app_bar.cs
  2. 2
      com.unity.uiwidgets/Runtime/material/bottom_navigation_bar.cs
  3. 6
      com.unity.uiwidgets/Runtime/material/button.cs
  4. 2
      com.unity.uiwidgets/Runtime/material/button_theme.cs
  5. 8
      com.unity.uiwidgets/Runtime/material/card.cs
  6. 12
      com.unity.uiwidgets/Runtime/material/card_theme.cs
  7. 190
      com.unity.uiwidgets/Runtime/material/checkbox.cs
  8. 573
      com.unity.uiwidgets/Runtime/material/chip.cs
  9. 38
      com.unity.uiwidgets/Runtime/material/chip_theme.cs
  10. 15
      com.unity.uiwidgets/Runtime/material/circle_avatar.cs
  11. 2
      com.unity.uiwidgets/Runtime/material/constants.cs
  12. 2
      com.unity.uiwidgets/Runtime/material/constants.cs.meta
  13. 50
      com.unity.uiwidgets/Runtime/material/dropdown.cs
  14. 4
      com.unity.uiwidgets/Runtime/material/expansion_panel.cs
  15. 2
      com.unity.uiwidgets/Runtime/material/flexible_space_bar.cs
  16. 6
      com.unity.uiwidgets/Runtime/material/ink_ripple.cs
  17. 30
      com.unity.uiwidgets/Runtime/material/ink_splash.cs
  18. 82
      com.unity.uiwidgets/Runtime/material/ink_well.cs
  19. 38
      com.unity.uiwidgets/Runtime/material/input_decorator.cs
  20. 4
      com.unity.uiwidgets/Runtime/material/list_tile.cs
  21. 2
      com.unity.uiwidgets/Runtime/material/material.cs
  22. 2
      com.unity.uiwidgets/Runtime/material/mergeable_material.cs
  23. 6
      com.unity.uiwidgets/Runtime/material/outline_button.cs
  24. 4
      com.unity.uiwidgets/Runtime/material/popup_menu.cs
  25. 6
      com.unity.uiwidgets/Runtime/material/radio.cs
  26. 2
      com.unity.uiwidgets/Runtime/material/shadows.cs
  27. 2
      com.unity.uiwidgets/Runtime/material/slider.cs
  28. 14
      com.unity.uiwidgets/Runtime/material/switch.cs
  29. 2
      com.unity.uiwidgets/Runtime/material/tab_controller.cs
  30. 8
      com.unity.uiwidgets/Runtime/material/tabs.cs
  31. 4
      com.unity.uiwidgets/Runtime/material/toggle_buttons.cs
  32. 12
      com.unity.uiwidgets/Runtime/material/toggleable.cs
  33. 2
      com.unity.uiwidgets/Runtime/material/banner.cs.meta
  34. 11
      com.unity.uiwidgets/Runtime/material/banner_theme.cs.meta
  35. 11
      com.unity.uiwidgets/Runtime/material/button_bar_theme.cs.meta
  36. 11
      com.unity.uiwidgets/Runtime/material/button_sheet_theme.cs.meta
  37. 84
      com.unity.uiwidgets/Runtime/material/checkbox_list_tile.cs
  38. 11
      com.unity.uiwidgets/Runtime/material/checkbox_list_tile.cs.meta
  39. 11
      com.unity.uiwidgets/Runtime/material/curves.cs.meta
  40. 702
      com.unity.uiwidgets/Runtime/material/data_table.cs
  41. 3
      com.unity.uiwidgets/Runtime/material/data_table.cs.meta
  42. 13
      com.unity.uiwidgets/Runtime/material/data_table_source.cs
  43. 3
      com.unity.uiwidgets/Runtime/material/data_table_source.cs.meta
  44. 11
      com.unity.uiwidgets/Runtime/material/divider_theme.cs.meta
  45. 11
      com.unity.uiwidgets/Runtime/material/material_state.cs.meta
  46. 11
      com.unity.uiwidgets/Runtime/material/popup_menu_theme.cs.meta
  47. 11
      com.unity.uiwidgets/Runtime/material/toggle_buttons.cs.meta
  48. 11
      com.unity.uiwidgets/Runtime/material/toggle_buttons_theme.cs.meta
  49. 11
      com.unity.uiwidgets/Runtime/material/tooltip_theme.cs.meta
  50. 939
      com.unity.uiwidgets/Runtime/material/date_picker.cs
  51. 0
      /com.unity.uiwidgets/Runtime/material/banner.cs.meta

16
com.unity.uiwidgets/Runtime/material/app_bar.cs


namespace Unity.UIWidgets.material {
static class AppBarUtils {
internal const float _kLeadingWidth = Constants.kToolbarHeight;
internal const float _kLeadingWidth = material_.kToolbarHeight;
}
class _ToolbarContainerLayout : SingleChildLayoutDelegate {

public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
return constraints.tighten(height: Constants.kToolbarHeight);
return constraints.tighten(height: material_.kToolbarHeight);
return new Size(constraints.maxWidth, Constants.kToolbarHeight);
return new Size(constraints.maxWidth, material_.kToolbarHeight);
}
public override Offset getPositionForChild(Size size, Size childSize) {

this.titleSpacing = titleSpacing;
this.toolbarOpacity = toolbarOpacity;
this.bottomOpacity = bottomOpacity;
preferredSize = Size.fromHeight(Constants.kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0f));
preferredSize = Size.fromHeight(material_.kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0f));
}
public readonly Widget leading;

children: new List<Widget> {
new Flexible(
child: new ConstrainedBox(
constraints: new BoxConstraints(maxHeight: Constants.kToolbarHeight),
constraints: new BoxConstraints(maxHeight: material_.kToolbarHeight),
child: appBar
)
),

readonly float _bottomHeight;
public override float? minExtent {
get { return collapsedHeight ?? (topPadding + Constants.kToolbarHeight + _bottomHeight); }
get { return collapsedHeight ?? (topPadding + material_.kToolbarHeight + _bottomHeight); }
(topPadding ?? 0.0f) + (expandedHeight ?? Constants.kToolbarHeight + _bottomHeight),
(topPadding ?? 0.0f) + (expandedHeight ?? material_.kToolbarHeight + _bottomHeight),
minExtent ?? 0.0f);
}
}

public override Widget build(BuildContext context, float shrinkOffset, bool overlapsContent) {
float? visibleMainHeight = maxExtent - shrinkOffset - topPadding;
float toolbarOpacity = !pinned || (!floating && bottom != null)
? ((visibleMainHeight - _bottomHeight) / Constants.kToolbarHeight)?.clamp(0.0f, 1.0f) ?? 1.0f
? ((visibleMainHeight - _bottomHeight) / material_.kToolbarHeight)?.clamp(0.0f, 1.0f) ?? 1.0f
: 1.0f;
Widget appBar = FlexibleSpaceBar.createSettings(
minExtent: minExtent,

2
com.unity.uiwidgets/Runtime/material/bottom_navigation_bar.cs


color: backgroundColor,
child: new ConstrainedBox(
constraints: new BoxConstraints(
minHeight: Constants.kBottomNavigationBarHeight + additionalBottomPadding),
minHeight: material_.kBottomNavigationBarHeight + additionalBottomPadding),
child: new CustomPaint(
painter: new _RadialPainter(
circles: _circles.ToList()

6
com.unity.uiwidgets/Runtime/material/button.cs


visualDensity = visualDensity ?? new VisualDensity();
padding = padding ?? EdgeInsets.zero;
constraints = constraints ?? new BoxConstraints(minWidth: 88.0f, minHeight: 36.0f);
TimeSpan _animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
TimeSpan _animationDuration = animationDuration ?? material_.kThemeChangeDuration;
this.onPressed = onPressed;
this.onLongPress = onLongPress;

switch (widget.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
minSize = new Size(
Constants.kMinInteractiveDimension + densityAdjustment.dx,
Constants.kMinInteractiveDimension + densityAdjustment.dy
material_.kMinInteractiveDimension + densityAdjustment.dx,
material_.kMinInteractiveDimension + densityAdjustment.dy
);
D.assert(minSize.width >= 0.0f);
D.assert(minSize.height >= 0.0f);

2
com.unity.uiwidgets/Runtime/material/button_theme.cs


public TimeSpan getAnimationDuration(MaterialButton button) {
return button.animationDuration ?? Constants.kThemeChangeDuration;
return button.animationDuration ?? material_.kThemeChangeDuration;
}
public BoxConstraints getConstraints(MaterialButton button) {

8
com.unity.uiwidgets/Runtime/material/card.cs


using uiwidgets;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;

public Card(
Key key = null,
Color color = null,
Color shadowColor = null,
float? elevation = null,
ShapeBorder shape = null,
bool borderOnForeground = true,

D.assert(elevation == null || elevation >= 0.0f);
this.color = color;
this.shadowColor = shadowColor;
this.elevation = elevation;
this.shape = shape;
this.borderOnForeground = borderOnForeground;

public readonly Color color;
public readonly Color shadowColor;
public readonly float? elevation;
public readonly ShapeBorder shape;

child: new Material(
type: MaterialType.card,
color: color ?? cardTheme.color ?? Theme.of(context).cardColor,
shadowColor: shadowColor ?? cardTheme.shadowColor ?? Colors.black,
clipBehavior: clipBehavior ?? cardTheme.clipBehavior ?? _defaultClipBehavior,
clipBehavior: clipBehavior ?? cardTheme.clipBehavior ?? Clip.none,
child: child)
);
}

12
com.unity.uiwidgets/Runtime/material/card_theme.cs


public CardTheme(
Clip? clipBehavior = null,
Color color = null,
Color shadowColor = null,
float? elevation = null,
EdgeInsets margin = null,
ShapeBorder shape = null

this.color = color;
this.shadowColor = shadowColor;
this.elevation = elevation;
this.margin = margin;
this.shape = shape;

public readonly Color color;
public readonly Color shadowColor;
public readonly float? elevation;
public readonly EdgeInsets margin;

CardTheme copyWith(
Clip? clipBehavior = null,
Color color = null,
Color shadowColor = null,
float? elevation = null,
EdgeInsets margin = null,
ShapeBorder shape = null

color: color ?? this.color,
shadowColor: shadowColor ?? this.shadowColor,
elevation: elevation ?? this.elevation,
margin: margin ?? this.margin,
shape: shape ?? this.shape

return new CardTheme(
clipBehavior: t < 0.5f ? a?.clipBehavior : b?.clipBehavior,
color: Color.lerp(a?.color, b?.color, t),
shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t),
elevation: Mathf.Lerp(a?.elevation ?? 0.0f, b?.elevation ?? 0.0f, t),
margin: EdgeInsets.lerp(a?.margin, b?.margin, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t)

public override int GetHashCode() {
var hashCode = clipBehavior?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ color?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ shadowColor?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ elevation?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ margin?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ shape?.GetHashCode() ?? 0;

public bool Equals(CardTheme other) {
return other.clipBehavior == clipBehavior
&& other.color == color
&& other.shadowColor == shadowColor
&& other.elevation == elevation
&& other.margin == margin
&& other.shape == shape;

base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Clip?>("clipBehavior", clipBehavior, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("color", color, defaultValue: null));
properties.add(new ColorProperty("color", color, defaultValue: null));
properties.add(new ColorProperty("shadowColor", shadowColor, defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("elevation", elevation, defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsets>("margin", margin, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null));

190
com.unity.uiwidgets/Runtime/material/checkbox.cs


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

ValueChanged<bool?> onChanged = null,
Color activeColor = null,
Color checkColor = null,
MaterialTapTargetSize? materialTapTargetSize = null
Color focusColor = null,
Color hoverColor = null,
MaterialTapTargetSize? materialTapTargetSize = null,
VisualDensity visualDensity = null,
FocusNode focusNode = null,
bool autofocus = false
) : base(key: key) {
D.assert(tristate || value != null);
this.value = value;

this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.visualDensity = visualDensity;
this.focusNode = focusNode;
this.autofocus = autofocus;
}
public readonly bool? value;

public readonly MaterialTapTargetSize? materialTapTargetSize;
public readonly VisualDensity visualDensity;
public readonly Color focusColor;
public readonly Color hoverColor;
public readonly FocusNode focusNode;
public readonly bool autofocus;
public const float width = 18.0f;
public override State createState() {

class _CheckboxState : TickerProviderStateMixin<Checkbox> {
bool enabled {
get { return widget.onChanged != null; }
}
Dictionary<LocalKey, ActionFactory> _actionMap;
public override void initState() {
base.initState();
_actionMap = new Dictionary<LocalKey, ActionFactory> {
{ActivateAction.key, _createAction}
};
}
void _actionHandler(FocusNode node, Intent intent) {
if (widget.onChanged != null) {
switch (widget.value) {
case false:
widget.onChanged(true);
break;
case true:
widget.onChanged(widget.tristate);
break;
default: // case null:
widget.onChanged(false);
break;
}
}
RenderObject renderObject = node.context.findRenderObject();
// renderObject.sendSemanticsEvent(const TapSemanticEvent());
}
UiWidgetAction _createAction() {
return new CallbackAction(
ActivateAction.key,
onInvoke: _actionHandler
);
}
bool _focused = false;
void _handleFocusHighlightChanged(bool focused) {
if (focused != _focused) {
setState(() => { _focused = focused; });
}
}
bool _hovering = false;
void _handleHoverChanged(bool hovering) {
if (hovering != _hovering) {
setState(() => { _hovering = hovering; });
}
}
public override Widget build(BuildContext context) {
D.assert(material_.debugCheckHasMaterial(context));
ThemeData themeData = Theme.of(context);

size = new Size(2 * Constants.kRadialReactionRadius + 8.0f,
2 * Constants.kRadialReactionRadius + 8.0f);
size = new Size(2 * material_.kRadialReactionRadius + 8.0f,
2 * material_.kRadialReactionRadius + 8.0f);
size = new Size(2 * Constants.kRadialReactionRadius, 2 * Constants.kRadialReactionRadius);
size = new Size(2 * material_.kRadialReactionRadius, 2 * material_.kRadialReactionRadius);
size += (widget.visualDensity ?? themeData.visualDensity).baseSizeAdjustment;
return new _CheckboxRenderObjectWidget(
value: widget.value,
tristate: widget.tristate,
activeColor: widget.activeColor ?? themeData.toggleableActiveColor,
checkColor: widget.checkColor ?? new Color(0xFFFFFFFF),
inactiveColor: widget.onChanged != null
? themeData.unselectedWidgetColor
: themeData.disabledColor,
onChanged: widget.onChanged,
additionalConstraints: additionalConstraints,
vsync: this
return new FocusableActionDetector(
actions: _actionMap,
focusNode: widget.focusNode,
autofocus: widget.autofocus,
enabled: enabled,
onShowFocusHighlight: _handleFocusHighlightChanged,
onShowHoverHighlight: _handleHoverChanged,
child: new Builder(
builder: (BuildContext _context) => {
return new _CheckboxRenderObjectWidget(
value: widget.value,
tristate: widget.tristate,
activeColor: widget.activeColor ?? themeData.toggleableActiveColor,
checkColor: widget.checkColor ?? new Color(0xFFFFFFFF),
inactiveColor: enabled ? themeData.unselectedWidgetColor : themeData.disabledColor,
focusColor: widget.focusColor ?? themeData.focusColor,
hoverColor: widget.hoverColor ?? themeData.hoverColor,
onChanged: widget.onChanged,
additionalConstraints: additionalConstraints,
vsync: this,
hasFocus: _focused,
hovering: _hovering
);
}
)
);
}
}

Color activeColor = null,
Color checkColor = null,
Color inactiveColor = null,
Color focusColor = null,
Color hoverColor = null,
BoxConstraints additionalConstraints = null
BoxConstraints additionalConstraints = null,
bool? hasFocus = null,
bool? hovering = null
) : base(key: key) {
D.assert(tristate || value != null);
D.assert(activeColor != null);

this.activeColor = activeColor;
this.checkColor = checkColor;
this.inactiveColor = inactiveColor;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.hasFocus = hasFocus;
this.hovering = hovering;
public readonly bool? hasFocus;
public readonly bool? hovering;
public readonly Color focusColor;
public readonly Color hoverColor;
public readonly ValueChanged<bool?> onChanged;
public readonly TickerProvider vsync;
public readonly BoxConstraints additionalConstraints;

activeColor: activeColor,
checkColor: checkColor,
inactiveColor: inactiveColor,
focusColor: focusColor,
hoverColor: hoverColor,
additionalConstraints: additionalConstraints
additionalConstraints: additionalConstraints,
hasFocus: hasFocus,
hovering: hovering
);
}

renderObject.tristate = tristate;
renderObject.activeColor = activeColor;
renderObject.checkColor = checkColor;
renderObject.focusColor = focusColor;
renderObject.hoverColor = hoverColor;
renderObject.hasFocus = hasFocus ?? false;
renderObject.hovering = hovering ?? false;
}
}

Color activeColor = null,
Color checkColor = null,
Color inactiveColor = null,
Color focusColor = null,
Color hoverColor = null,
TickerProvider vsync = null
TickerProvider vsync = null,
bool? hasFocus = null,
bool? hovering = null
value: value,
tristate: tristate,
activeColor: activeColor,
inactiveColor: inactiveColor,
onChanged: onChanged,
additionalConstraints: additionalConstraints,
vsync: vsync
) {
value: value,
tristate: tristate,
activeColor: activeColor,
inactiveColor: inactiveColor,
focusColor: focusColor,
hoverColor: hoverColor,
onChanged: onChanged,
additionalConstraints: additionalConstraints,
vsync: vsync,
hasFocus: hasFocus ?? false,
hovering: hovering ?? false
) {
_oldValue = value;
this.checkColor = checkColor;
}

: (t >= 0.25f ? activeColor : Color.lerp(inactiveColor, activeColor, t * 4.0f));
}
void _initStrokePaint(Paint paint) {
Paint _createStrokePaint() {
var paint = new Paint();
return paint;
}
void _drawBorder(Canvas canvas, RRect outer, float t, Paint paint) {

Canvas canvas = context.canvas;
paintRadialReaction(canvas, offset, size.center(Offset.zero));
Paint strokePaint = _createStrokePaint();
Offset origin = offset + (size / 2.0f - Size.square(CheckboxUtils._kEdgeSize) / 2.0f);
AnimationStatus status = position.status;
float tNormalized = status == AnimationStatus.forward || status == AnimationStatus.completed

else {
canvas.drawRRect(outer, paint);
_initStrokePaint(paint);
_drawDash(canvas, origin, tShrink, paint);
_drawDash(canvas, origin, tShrink, strokePaint);
_drawCheck(canvas, origin, tShrink, paint);
_drawCheck(canvas, origin, tShrink, strokePaint);
}
}
}

paint.color = _colorAt(1.0f);
canvas.drawRRect(outer, paint);
_initStrokePaint(paint);
_drawCheck(canvas, origin, tShrink, paint);
_drawCheck(canvas, origin, tShrink, strokePaint);
_drawDash(canvas, origin, tShrink, paint);
_drawDash(canvas, origin, tShrink, strokePaint);
_drawCheck(canvas, origin, tExpand, paint);
_drawCheck(canvas, origin, tExpand, strokePaint);
_drawDash(canvas, origin, tExpand, paint);
_drawDash(canvas, origin, tExpand, strokePaint);
}
}
}

573
com.unity.uiwidgets/Runtime/material/chip.cs
文件差异内容过多而无法显示
查看文件

38
com.unity.uiwidgets/Runtime/material/chip_theme.cs


using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public class ChipTheme : InheritedWidget {
public class ChipTheme : InheritedTheme {
public ChipTheme(
Key key = null,
ChipThemeData data = null,

public readonly ChipThemeData data;
public static ChipThemeData of(BuildContext context) {
ChipTheme inheritedTheme = (ChipTheme) context.inheritFromWidgetOfExactType(typeof(ChipTheme));
ChipTheme inheritedTheme = (ChipTheme) context.dependOnInheritedWidgetOfExactType<ChipTheme>();
public override Widget wrap(BuildContext context, Widget child) {
ChipTheme ancestorTheme = context.findAncestorWidgetOfExactType<ChipTheme>();
return ReferenceEquals(this, ancestorTheme) ? child : new ChipTheme(data: data, child: child);
}
public override bool updateShouldNotify(InheritedWidget _oldWidget) {
ChipTheme oldWidget = _oldWidget as ChipTheme;
return data != oldWidget.data;

Color secondarySelectedColor = null,
Color shadowColor = null,
Color selectedShadowColor = null,
bool? showCheckmark = null,
Color checkmarkColor = null,
EdgeInsets labelPadding = null,
EdgeInsets padding = null,
ShapeBorder shape = null,

this.secondarySelectedColor = secondarySelectedColor;
this.shadowColor = shadowColor;
this.selectedShadowColor = selectedShadowColor;
this.showCheckmark = showCheckmark;
this.checkmarkColor = checkmarkColor;
this.labelPadding = labelPadding;
this.padding = padding;
this.shape = shape;

public readonly Color selectedShadowColor;
public readonly bool? showCheckmark;
public readonly Color checkmarkColor;
public readonly EdgeInsets labelPadding;
public readonly EdgeInsets padding;

Color secondarySelectedColor = null,
Color shadowColor = null,
Color selectedShadowColor = null,
Color checkmarkColor = null,
EdgeInsets labelPadding = null,
EdgeInsets padding = null,
ShapeBorder shape = null,

secondarySelectedColor: secondarySelectedColor ?? this.secondarySelectedColor,
shadowColor: shadowColor ?? this.shadowColor,
selectedShadowColor: selectedShadowColor ?? this.selectedShadowColor,
checkmarkColor: checkmarkColor ?? this.checkmarkColor,
labelPadding: labelPadding ?? this.labelPadding,
padding: padding ?? this.padding,
shape: shape ?? this.shape,

secondarySelectedColor: Color.lerp(a?.secondarySelectedColor, b?.secondarySelectedColor, t),
shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t),
selectedShadowColor: Color.lerp(a?.selectedShadowColor, b?.selectedShadowColor, t),
checkmarkColor: Color.lerp(a?.checkmarkColor, b?.checkmarkColor, t),
labelPadding: EdgeInsets.lerp(a?.labelPadding, b?.labelPadding, t),
padding: EdgeInsets.lerp(a?.padding, b?.padding, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),

hashCode = (hashCode * 397) ^ secondarySelectedColor.GetHashCode();
hashCode = (hashCode * 397) ^ shadowColor?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ selectedShadowColor?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ checkmarkColor?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ labelPadding.GetHashCode();
hashCode = (hashCode * 397) ^ padding.GetHashCode();
hashCode = (hashCode * 397) ^ shape.GetHashCode();

&& other.secondarySelectedColor == secondarySelectedColor
&& other.shadowColor == shadowColor
&& other.selectedShadowColor == selectedShadowColor
&& other.checkmarkColor == checkmarkColor
&& other.labelPadding == labelPadding
&& other.padding == padding
&& other.shape == shape

brightness: defaultTheme.brightness,
labelStyle: defaultTheme.textTheme.body2
);
properties.add(new DiagnosticsProperty<Color>("backgroundColor", backgroundColor,
properties.add(new ColorProperty("backgroundColor", backgroundColor,
properties.add(new DiagnosticsProperty<Color>("deleteIconColor", deleteIconColor,
properties.add(new ColorProperty("deleteIconColor", deleteIconColor,
properties.add(new DiagnosticsProperty<Color>("disabledColor", disabledColor,
properties.add(new ColorProperty("disabledColor", disabledColor,
properties.add(new DiagnosticsProperty<Color>("selectedColor", selectedColor,
properties.add(new ColorProperty("selectedColor", selectedColor,
properties.add(new DiagnosticsProperty<Color>("secondarySelectedColor", secondarySelectedColor,
properties.add(new ColorProperty("secondarySelectedColor", secondarySelectedColor,
properties.add(new DiagnosticsProperty<Color>("shadowColor", shadowColor,
properties.add(new ColorProperty("shadowColor", shadowColor,
properties.add(new DiagnosticsProperty<Color>("selectedShadowColor", selectedShadowColor,
properties.add(new ColorProperty("selectedShadowColor", selectedShadowColor,
properties.add(new ColorProperty("checkMarkColor", checkmarkColor,
defaultValue: defaultData.checkmarkColor));
properties.add(new DiagnosticsProperty<EdgeInsets>("labelPadding", labelPadding,
defaultValue: defaultData.labelPadding));
properties.add(

15
com.unity.uiwidgets/Runtime/material/circle_avatar.cs


Widget child = null,
Color backgroundColor = null,
ImageProvider backgroundImage = null,
ImageErrorListener onBackgroundImageError = null,
Color foregroundColor = null,
float? radius = null,
float? minRadius = null,

D.assert(backgroundImage != null || onBackgroundImageError == null);
this.onBackgroundImageError = onBackgroundImageError;
this.foregroundColor = foregroundColor;
this.radius = radius;
this.minRadius = minRadius;

public readonly ImageProvider backgroundImage;
public readonly ImageErrorListener onBackgroundImageError;
public readonly float? radius;
public readonly float? minRadius;

public override Widget build(BuildContext context) {
D.assert(WidgetsD.debugCheckHasMediaQuery(context));
ThemeData theme = Theme.of(context);
TextStyle textStyle = theme.primaryTextTheme.subhead.copyWith(color: foregroundColor);
TextStyle textStyle = theme.primaryTextTheme.subtitle1.copyWith(color: foregroundColor);
Color effectiveBackgroundColor = backgroundColor;
if (effectiveBackgroundColor == null) {
switch (ThemeData.estimateBrightnessForColor(textStyle.color)) {

maxWidth: maxDiameter,
maxHeight: maxDiameter
),
duration: Constants.kThemeChangeDuration,
duration: material_.kThemeChangeDuration,
? new DecorationImage(image: backgroundImage, fit: BoxFit.cover)
? new DecorationImage(
image: backgroundImage,
onError: onBackgroundImageError,
fit: BoxFit.cover
)
: null,
shape: BoxShape.circle
),

2
com.unity.uiwidgets/Runtime/material/constants.cs


using Unity.UIWidgets.painting;
namespace Unity.UIWidgets.material {
public static class Constants {
public partial class material_ {
public const float kMinInteractiveDimension = 48.0f;
public const float kToolbarHeight = 56.0f;

2
com.unity.uiwidgets/Runtime/material/constants.cs.meta


fileFormatVersion: 2
guid: f20dccf2a552abc49bd30ca75acd19b1
guid: 458362f6f20be1348bf63c0a5a912024
MonoImporter:
externalObjects: {}
serializedVersion: 2

50
com.unity.uiwidgets/Runtime/material/dropdown.cs


using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
class DropdownConstants {
public partial class material_ {
public static readonly TimeSpan _kDropdownMenuDuration = new TimeSpan(0, 0, 0, 0, 300);
public const float _kMenuItemHeight = 48.0f;
public const float _kDenseButtonHeight = 24.0f;

_painter = new BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(2.0f),
boxShadow: ShadowConstants.kElevationToShadow[elevation ?? 0]
boxShadow: material_.kElevationToShadow[elevation ?? 0]
).createBoxPainter();
this.color = color;
this.elevation = elevation;

public readonly BoxPainter _painter;
public override void paint(Canvas canvas, Size size) {
float selectedItemOffset = selectedIndex ?? 0 * DropdownConstants._kMenuItemHeight +
Constants.kMaterialListPadding.top;
float selectedItemOffset = selectedIndex ?? 0 * material_._kMenuItemHeight +
material_.kMaterialListPadding.top;
begin: selectedItemOffset.clamp(0.0f, size.height - DropdownConstants._kMenuItemHeight),
begin: selectedItemOffset.clamp(0.0f, size.height - material_._kMenuItemHeight),
begin: (top.begin + DropdownConstants._kMenuItemHeight).clamp(DropdownConstants._kMenuItemHeight,
begin: (top.begin + material_._kMenuItemHeight).clamp(material_._kMenuItemHeight,
size.height),
end: size.height
);

child: new Scrollbar(
child: new ListView(
controller: widget.route.scrollController,
padding: Constants.kMaterialListPadding,
itemExtent: DropdownConstants._kMenuItemHeight,
padding: material_.kMaterialListPadding,
itemExtent: material_._kMenuItemHeight,
shrinkWrap: true,
children: children
)

public readonly float menuHeight;
public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
float maxHeight = Mathf.Max(0.0f, constraints.maxHeight - 2 * DropdownConstants._kMenuItemHeight);
float maxHeight = Mathf.Max(0.0f, constraints.maxHeight - 2 * material_._kMenuItemHeight);
float width = Mathf.Min(constraints.maxWidth, buttonRect.width);
return new BoxConstraints(
minWidth: width,

public ScrollController scrollController;
public override TimeSpan transitionDuration {
get { return DropdownConstants._kDropdownMenuDuration; }
get { return material_._kDropdownMenuDuration; }
}
public override bool barrierDismissible {

public override Widget build(BuildContext context) {
D.assert(WidgetsD.debugCheckHasDirectionality(context));
float availableHeight = constraints.maxHeight;
float maxMenuHeight = availableHeight - 2.0f * DropdownConstants._kMenuItemHeight;
float maxMenuHeight = availableHeight - 2.0f * material_._kMenuItemHeight;
float topLimit = Mathf.Min(DropdownConstants._kMenuItemHeight, buttonTop);
float bottomLimit = Mathf.Max(availableHeight - DropdownConstants._kMenuItemHeight, buttonBottom);
float topLimit = Mathf.Min(material_._kMenuItemHeight, buttonTop);
float bottomLimit = Mathf.Max(availableHeight - material_._kMenuItemHeight, buttonBottom);
float? selectedItemOffset = selectedIndex * DropdownConstants._kMenuItemHeight +
Constants.kMaterialListPadding.top;
float? selectedItemOffset = selectedIndex * material_._kMenuItemHeight +
material_.kMaterialListPadding.top;
(DropdownConstants._kMenuItemHeight - buttonRect.height) / 2.0f;
float preferredMenuHeight = (items.Count * DropdownConstants._kMenuItemHeight) +
Constants.kMaterialListPadding.vertical;
(material_._kMenuItemHeight - buttonRect.height) / 2.0f;
float preferredMenuHeight = (items.Count * material_._kMenuItemHeight) +
material_.kMaterialListPadding.vertical;
float menuHeight = Mathf.Min(maxMenuHeight, preferredMenuHeight);

public override Widget build(BuildContext context) {
return new Container(
height: DropdownConstants._kMenuItemHeight,
height: material_._kMenuItemHeight,
alignment: Alignment.centerLeft,
child: child
);

RenderBox itemBox = (RenderBox) context.findRenderObject();
Rect itemRect = itemBox.localToGlobal(Offset.zero) & itemBox.size;
EdgeInsets menuMargin = ButtonTheme.of(context).alignedDropdown
? DropdownConstants._kAlignedMenuMargin
: DropdownConstants._kUnalignedMenuMargin;
? material_._kAlignedMenuMargin
: material_._kUnalignedMenuMargin;
padding: DropdownConstants._kMenuItemPadding,
padding: material_._kMenuItemPadding,
selectedIndex: _selectedIndex ?? 0,
elevation: widget.elevation,
theme: Theme.of(context, shadowThemeOnly: true),

float? _denseButtonHeight {
get {
return Mathf.Max(_textStyle.fontSize ?? 0.0f,
Mathf.Max(widget.iconSize, DropdownConstants._kDenseButtonHeight));
Mathf.Max(widget.iconSize, material_._kDenseButtonHeight));
}
}

}
EdgeInsets padding = ButtonTheme.of(context).alignedDropdown
? DropdownConstants._kAlignedButtonPadding
: DropdownConstants._kUnalignedButtonPadding;
? material_._kAlignedButtonPadding
: material_._kUnalignedButtonPadding;
IndexedStack innerItemsWidget = new IndexedStack(
index: _enabled ? (_selectedIndex ?? hintIndex) : hintIndex,

4
com.unity.uiwidgets/Runtime/material/expansion_panel.cs


TimeSpan? animationDuration = null) : base(key: key) {
this.children = children ?? new List<ExpansionPanel>();
this.expansionCallback = expansionCallback;
this.animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
this.animationDuration = animationDuration ?? material_.kThemeChangeDuration;
_allowOnlyOnePanelOpen = false;
initialOpenPanelValue = null;
}

object initialOpenPanelValue = null) : base(key: key) {
this.children = children ?? new List<ExpansionPanel>();
this.expansionCallback = expansionCallback;
this.animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
this.animationDuration = animationDuration ?? material_.kThemeChangeDuration;
_allowOnlyOnePanelOpen = true;
this.initialOpenPanelValue = initialOpenPanelValue;
}

2
com.unity.uiwidgets/Runtime/material/flexible_space_bar.cs


.clamp(0.0f, 1.0f);
if (widget.background != null) {
float fadeStart = Mathf.Max(0.0f, 1.0f - Constants.kToolbarHeight / deltaExtent);
float fadeStart = Mathf.Max(0.0f, 1.0f - material_.kToolbarHeight / deltaExtent);
float fadeEnd = 1.0f;
D.assert(fadeStart <= fadeEnd);

6
com.unity.uiwidgets/Runtime/material/ink_ripple.cs


RenderBox referenceBox = null,
Offset position = null,
Color color = null,
TextDirection? textDirection = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,

D.assert(referenceBox != null);
D.assert(position != null);
D.assert(color != null);
D.assert(textDirection != null);
return new InkRipple(
controller: controller,
referenceBox: referenceBox,

borderRadius: borderRadius,
customBorder: customBorder,
radius: radius,
onRemoved: onRemoved);
onRemoved: onRemoved,
textDiretion: textDirection
);
}
}

30
com.unity.uiwidgets/Runtime/material/ink_splash.cs


RenderBox referenceBox = null,
Offset position = null,
Color color = null,
TextDirection? textDirection = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,

D.assert(referenceBox != null);
D.assert(position != null);
D.assert(color != null);
D.assert(textDirection != null);
return new InkSplash(
controller: controller,
referenceBox: referenceBox,

borderRadius: borderRadius,
customBorder: customBorder,
radius: radius,
onRemoved: onRemoved);
onRemoved: onRemoved,
textDirection: textDirection
);
}
}

readonly RectCallback _clipCallback;
readonly bool _repositionToReferenceBox;
readonly TextDirection _textDirection;
readonly TextDirection _textDirection;
Animation<float> _radius;
AnimationController _radiusController;

}
paintInkCircle(
canvas: canvas,
transform: transform,
paint: paint,
center: center,
textDirection: _textDirection,
radius: _radius.value,
customBorder: _customBorder,
borderRadius: _borderRadius,
clipCallback: _clipCallback
);
canvas: canvas,
transform: transform,
paint: paint,
center: center,
textDirection: _textDirection,
radius: _radius.value,
customBorder: _customBorder,
borderRadius: _borderRadius,
clipCallback: _clipCallback
);
}
}
}

82
com.unity.uiwidgets/Runtime/material/ink_well.cs


}
Color _color;
protected void paintInkCircle(
Canvas canvas,
Matrix4 transform,

ShapeBorder customBorder = null,
BorderRadius borderRadius = null,
RectCallback clipCallback = null) {
borderRadius = borderRadius ?? BorderRadius.zero;
D.assert(canvas != null);
D.assert(transform != null);

canvas.save();
if (originOffset == null) {
canvas.transform(transform.storage);
} else {
}
else {
}
}
else if (borderRadius != BorderRadius.zero) {
canvas.clipRRect(RRect.fromRectAndCorners(
rect,

}
}
canvas.drawCircle(center, radius, paint);
canvas.restore();
}

RenderBox referenceBox = null,
Offset position = null,
Color color = null,
TextDirection? textDirection = null,
bool containedInkWell = false,
RectCallback rectCallback = null,
BorderRadius borderRadius = null,

public class _InkResponseState<T> : AutomaticKeepAliveClientMixin<T> where T : InkResponse {
HashSet<InteractiveInkFeature> _splashes;
InteractiveInkFeature _currentSplash;
void _handleAction(FocusNode node, Intent intent) {
_startSplash(context: node.context);
_handleTap(node.context);

return new CallbackAction(
ActivateAction.key,
onInvoke: _handleAction
onInvoke: _handleAction
);
}

protected override bool wantKeepAlive {
get { return highlightsExist || (_splashes != null && _splashes.isNotEmpty()); }
}
Color getHighlightColorForType(_HighlightType type) {
switch (type) {
case _HighlightType.pressed:

case _HighlightType.hover:
return widget.hoverColor ?? Theme.of(context).hoverColor;
}
return new TimeSpan(0, 0, 0, 0, 200);
return new TimeSpan(0, 0, 0, 0, 200);
D.assert(false, () => $"Unhandled {typeof(_HighlightType)} {type}");
return TimeSpan.Zero;
}

onRemoved: handleInkRemoval,
textDirection: Directionality.of(context),
fadeDuration: getFadeDurationForType(type)
);
);
updateKeepAlive();
}
else {

if (_currentSplash == splash) {
_currentSplash = null;
}
updateKeepAlive();
}
}

return splash;
}
setState(() =>{
_updateFocusHighlights();
});
setState(() => { _updateFocusHighlights(); });
}
void _updateFocusHighlights() {

break;
}
}
void _handleFocusUpdate(bool hasFocus) {
_hasFocus = hasFocus;
_updateFocusHighlights();

widget.onTapDown(details);
}
}
void _startSplash(TapDownDetails details = null, BuildContext context = null) {
void _startSplash(TapDownDetails details = null, BuildContext context = null) {
D.assert(details != null || context != null);
Offset globalPosition;

globalPosition = referenceBox.localToGlobal(referenceBox.paintBounds.center);
} else {
}
else {
InteractiveInkFeature splash = _createInkFeature(globalPosition);
_splashes = _splashes ?? new HashSet<InteractiveInkFeature>();
_splashes.Add(splash);

}
D.assert(_currentSplash == null);
foreach ( _HighlightType highlight in _highlights.Keys) {
foreach (_HighlightType highlight in _highlights.Keys) {
get {
return _isWidgetEnabled(widget);
}
get { return _isWidgetEnabled(widget); }
void _handleMouseEnter(PointerEnterEvent Event) {
_handleHoverChange(true);
}

public override Widget build(BuildContext context) {
D.assert(widget.debugCheckContext(context));
base.build(context);
foreach ( _HighlightType type in _highlights.Keys) {
foreach (_HighlightType type in _highlights.Keys) {
if (_highlights[type] != null) {
_highlights[type].color = getHighlightColorForType(type);
}

_currentSplash.color = widget.splashColor ?? Theme.of(context).splashColor;
}
return new Actions(
actions: _actionMap,
child: new Focus(

autofocus: widget.autofocus,
child: new MouseRegion(
onEnter: enabled ? _handleMouseEnter : (PointerEnterEventListener)null,
onExit: enabled ? _handleMouseExit : (PointerExitEventListener)null,
onEnter: enabled ? _handleMouseEnter : (PointerEnterEventListener) null,
onExit: enabled ? _handleMouseExit : (PointerExitEventListener) null,
onTapDown: enabled ? _handleTapDown : (GestureTapDownCallback)null,
onTapDown: enabled ? _handleTapDown : (GestureTapDownCallback) null,
onTapCancel: enabled ? _handleTapCancel : (GestureTapCancelCallback)null,
onDoubleTap: widget.onDoubleTap != null ? _handleDoubleTap : (GestureDoubleTapCallback)null,
onLongPress: widget.onLongPress != null ? () => _handleLongPress(context) : (GestureLongPressCallback)null,
onTapCancel: enabled ? _handleTapCancel : (GestureTapCancelCallback) null,
onDoubleTap: widget.onDoubleTap != null
? _handleDoubleTap
: (GestureDoubleTapCallback) null,
onLongPress: widget.onLongPress != null
? () => _handleLongPress(context)
: (GestureLongPressCallback) null,
behavior: HitTestBehavior.opaque,
child: widget.child
)

38
com.unity.uiwidgets/Runtime/material/input_decorator.cs


using Transform = Unity.UIWidgets.widgets.Transform;
namespace Unity.UIWidgets.material {
class InputDecoratorConstants {
public partial class material_ {
public static readonly TimeSpan _kTransitionDuration = new TimeSpan(0, 0, 0, 0, 200);
public static readonly Curve _kTransitionCurve = Curves.fastOutSlowIn;
}

vsync: this
);
_controller = new AnimationController(
duration: InputDecoratorConstants._kTransitionDuration,
duration: material_._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve
curve: material_._kTransitionCurve
);
_border = new _InputBorderTween(
begin: widget.border,

public override void initState() {
base.initState();
_controller = new AnimationController(
duration: InputDecoratorConstants._kTransitionDuration,
duration: material_._kTransitionDuration,
vsync: this
);
if (widget.errorText != null) {

);
float minContainerHeight = decoration.isDense.Value || expands
? 0.0f
: Constants.kMinInteractiveDimension + densityOffset.dy;
: material_.kMinInteractiveDimension + densityOffset.dy;
float maxContainerHeight = boxConstraints.maxHeight - bottomHeight + densityOffset.dy;
float containerHeight = expands
? maxContainerHeight

return DefaultTextStyle.merge(
style: style,
child: new AnimatedOpacity(
duration: InputDecoratorConstants._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve,
duration: material_._kTransitionDuration,
curve: material_._kTransitionCurve,
opacity: labelIsFloating ? 1.0f : 0.0f,
child: child ?? new Text(text, style: style)
)

(widget.decoration.hasFloatingPlaceholder == true &&
widget._labelShouldWithdraw);
_floatingLabelController = new AnimationController(
duration: InputDecoratorConstants._kTransitionDuration,
duration: material_._kTransitionDuration,
vsync: this,
value: labelIsInitiallyFloating ? 1.0f : 0.0f
);

duration: InputDecoratorConstants._kTransitionDuration,
duration: material_._kTransitionDuration,
vsync: this
);
}

? null
: new AnimatedOpacity(
opacity: (isEmpty && !_hasInlineLabel) ? 1.0f : 0.0f,
duration: InputDecoratorConstants._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve,
duration: material_._kTransitionDuration,
curve: material_._kTransitionCurve,
child: new Text(decoration.hintText,
style: hintStyle,
overflow: TextOverflow.ellipsis,

: new _Shaker(
animation: _shakingLabelController.view,
child: new AnimatedOpacity(
duration: InputDecoratorConstants._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve,
duration: material_._kTransitionDuration,
curve: material_._kTransitionCurve,
duration: InputDecoratorConstants._kTransitionDuration,
curve: InputDecoratorConstants._kTransitionCurve,
duration: material_._kTransitionDuration,
curve: material_._kTransitionCurve,
style: widget._labelShouldWithdraw
? _getFloatingLabelStyle(themeData)
: inlineLabelStyle,

child: new ConstrainedBox(
constraints: decoration.prefixIconConstraints ?? themeData.visualDensity.effectiveConstraints(
new BoxConstraints(
minWidth: Constants.kMinInteractiveDimension,
minHeight: Constants.kMinInteractiveDimension
minWidth: material_.kMinInteractiveDimension,
minHeight: material_.kMinInteractiveDimension
)),
child: IconTheme.merge(
data: new IconThemeData(

child: new ConstrainedBox(
constraints: decoration.suffixIconConstraints ?? themeData.visualDensity.effectiveConstraints(
new BoxConstraints(
minWidth: Constants.kMinInteractiveDimension,
minHeight: Constants.kMinInteractiveDimension
minWidth: material_.kMinInteractiveDimension,
minHeight: material_.kMinInteractiveDimension
)),
child: IconTheme.merge(
data: new IconThemeData(

4
com.unity.uiwidgets/Runtime/material/list_tile.cs


TextStyle titleStyle = _titleTextStyle(theme, tileTheme);
Widget titleText = new AnimatedDefaultTextStyle(
style: titleStyle,
duration: Constants.kThemeChangeDuration,
duration: material_.kThemeChangeDuration,
child: title ?? new SizedBox()
);

subtitleStyle = _subtitleTextStyle(theme, tileTheme);
subtitleText = new AnimatedDefaultTextStyle(
style: subtitleStyle,
duration: Constants.kThemeChangeDuration,
duration: material_.kThemeChangeDuration,
child: subtitle);
}

2
com.unity.uiwidgets/Runtime/material/material.cs


this.shape = shape;
this.borderOnForeground = borderOnForeground;
this.clipBehavior = clipBehavior;
this.animationDuration = animationDuration ?? Constants.kThemeChangeDuration;
this.animationDuration = animationDuration ?? material_.kThemeChangeDuration;
this.child = child;
}

2
com.unity.uiwidgets/Runtime/material/mergeable_material.cs


return new _MergeableMaterialListBody(
mainAxis: widget.mainAxis,
boxShadows: ShadowConstants.kElevationToShadow[widget.elevation],
boxShadows: material_.kElevationToShadow[widget.elevation],
items: _children,
children: widgets
);

6
com.unity.uiwidgets/Runtime/material/outline_button.cs


using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
class OutlineButtonConstants {
public partial class material_ {
public static readonly TimeSpan _kPressDuration = new TimeSpan(0, 0, 0, 0, 150);
public static readonly TimeSpan _kElevationDuration = new TimeSpan(0, 0, 0, 0, 75);

_controller = new AnimationController(
duration: OutlineButtonConstants._kPressDuration,
duration: material_._kPressDuration,
vsync: this
);
_fillAnimation = new CurvedAnimation(

),
clipBehavior:
widget.clipBehavior,
animationDuration: OutlineButtonConstants._kElevationDuration,
animationDuration: material_._kElevationDuration,
child:
widget.child
);

4
com.unity.uiwidgets/Runtime/material/popup_menu.cs


Widget item = new AnimatedDefaultTextStyle(
style: style,
duration: Constants.kThemeChangeDuration,
duration: material_.kThemeChangeDuration,
child: new Baseline(
baseline: widget.height - PopupMenuUtils._kBaselineOffsetFromBottom,
baselineType: style.textBaseline,

Widget item = new AnimatedDefaultTextStyle(
style: style,
duration: Constants.kThemeChangeDuration,
duration: material_.kThemeChangeDuration,
child: new Baseline(
baseline: widget.height - PopupMenuUtils._kBaselineOffsetFromBottom,
baselineType: style.textBaseline,

6
com.unity.uiwidgets/Runtime/material/radio.cs


Size size;
switch (widget.materialTapTargetSize ?? themeData.materialTapTargetSize) {
case MaterialTapTargetSize.padded:
size = new Size(2 * Constants.kRadialReactionRadius + 8.0f,
2 * Constants.kRadialReactionRadius + 8.0f);
size = new Size(2 * material_.kRadialReactionRadius + 8.0f,
2 * material_.kRadialReactionRadius + 8.0f);
size = new Size(2 * Constants.kRadialReactionRadius, 2 * Constants.kRadialReactionRadius);
size = new Size(2 * material_.kRadialReactionRadius, 2 * material_.kRadialReactionRadius);
break;
default:
throw new Exception("Unknown material tap target size");

2
com.unity.uiwidgets/Runtime/material/shadows.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.material {
public class ShadowConstants {
public partial class material_ {
static readonly Color _kKeyUmbraOpacity = new Color(0x33000000); // alpha = 0.2
static readonly Color _kKeyPenumbraOpacity = new Color(0x24000000); // alpha = 0.14
static readonly Color _kAmbientShadowOpacity = new Color(0x1F000000); // alpha = 0.12

2
com.unity.uiwidgets/Runtime/material/slider.cs


public override void initState() {
base.initState();
overlayController = new AnimationController(
duration: Constants.kRadialReactionDuration,
duration: material_.kRadialReactionDuration,
vsync: this
);
valueIndicatorController = new AnimationController(

14
com.unity.uiwidgets/Runtime/material/switch.cs


internal const float _kTrackWidth = 33.0f;
internal const float _kTrackRadius = _kTrackHeight / 2.0f;
internal const float _kThumbRadius = 10.0f;
internal const float _kSwitchWidth = _kTrackWidth - 2 * _kTrackRadius + 2 * Constants.kRadialReactionRadius;
internal const float _kSwitchHeight = 2 * Constants.kRadialReactionRadius + 8.0f;
internal const float _kSwitchHeightCollapsed = 2 * Constants.kRadialReactionRadius;
internal const float _kSwitchWidth = _kTrackWidth - 2 * _kTrackRadius + 2 * material_.kRadialReactionRadius;
internal const float _kSwitchHeight = 2 * material_.kRadialReactionRadius + 8.0f;
internal const float _kSwitchHeightCollapsed = 2 * material_.kRadialReactionRadius;
public Switch(
Key key = null,

}
float _trackInnerLength {
get { return size.width - 2.0f * Constants.kRadialReactionRadius; }
get { return size.width - 2.0f * material_.kRadialReactionRadius; }
}
HorizontalDragGestureRecognizer _drag;

color: color,
image: image == null ? null : new DecorationImage(image: image, onError: errorListener),
shape: BoxShape.circle,
boxShadow: ShadowConstants.kElevationToShadow[1]
boxShadow: material_.kElevationToShadow[1]
);
}

// Paint the track
Paint paint = new Paint {color = trackColor};
float trackHorizontalPadding = Constants.kRadialReactionRadius - Switch._kTrackRadius;
float trackHorizontalPadding = material_.kRadialReactionRadius - Switch._kTrackRadius;
Rect trackRect = Rect.fromLTWH(
offset.dx + trackHorizontalPadding,
offset.dy + (size.height - Switch._kTrackHeight) / 2.0f,

canvas.drawRRect(trackRRect, paint);
Offset thumbPosition = new Offset(
Constants.kRadialReactionRadius + visualPosition * _trackInnerLength,
material_.kRadialReactionRadius + visualPosition * _trackInnerLength,
size.height / 2.0f
);

2
com.unity.uiwidgets/Runtime/material/tab_controller.cs


int _indexIsChangingCount = 0;
public void animateTo(int value, TimeSpan? duration = null, Curve curve = null) {
duration = duration ?? Constants.kTabScrollDuration;
duration = duration ?? material_.kTabScrollDuration;
curve = curve ?? Curves.ease;
_changeIndex(value, duration: duration, curve: curve);
}

8
com.unity.uiwidgets/Runtime/material/tabs.cs


void _scrollToCurrentIndex() {
float offset = _tabCenteredScrollOffset(_currentIndex);
_scrollController.animateTo(offset, duration: Constants.kTabScrollDuration, curve: Curves.ease);
_scrollController.animateTo(offset, duration: material_.kTabScrollDuration, curve: Curves.ease);
}
void _scrollToControllerValue() {

wrappedTabs.Add(new Center(
heightFactor: 1.0f,
child: new Padding(
padding: widget.labelPadding ?? tabBarTheme.labelPadding ?? Constants.kTabLabelPadding,
padding: widget.labelPadding ?? tabBarTheme.labelPadding ?? material_.kTabLabelPadding,
child: new KeyedSubtree(
key: _tabKeys[i],
child: widget.tabs[i]

int previousIndex = _controller.previousIndex;
if ((_currentIndex.Value - previousIndex).abs() == 1) {
_pageController.animateToPage(_currentIndex.Value, duration: Constants.kTabScrollDuration,
_pageController.animateToPage(_currentIndex.Value, duration: material_.kTabScrollDuration,
curve: Curves.ease);
return;
}

});
_pageController.jumpToPage(initialPage);
_pageController.animateToPage(_currentIndex.Value, duration: Constants.kTabScrollDuration,
_pageController.animateToPage(_currentIndex.Value, duration: material_.kTabScrollDuration,
curve: Curves.ease).then((value) => {
if (!mounted) {
return Future.value();

4
com.unity.uiwidgets/Runtime/material/toggle_buttons.cs


TextStyle currentTextStyle = textStyle ?? toggleButtonsTheme.textStyle ?? theme.textTheme.bodyText2;
BoxConstraints currentConstraints = constraints ?? toggleButtonsTheme.constraints ??
new BoxConstraints(minWidth: Constants.kMinInteractiveDimension,
minHeight: Constants.kMinInteractiveDimension);
new BoxConstraints(minWidth: material_.kMinInteractiveDimension,
minHeight: material_.kMinInteractiveDimension);
Widget result = new ClipRRect(
borderRadius: clipRadius,

12
com.unity.uiwidgets/Runtime/material/toggleable.cs


public static readonly TimeSpan _kToggleDuration = new TimeSpan(0, 0, 0, 0, 200);
public static readonly Animatable<float> _kRadialReactionRadiusTween =
new FloatTween(begin: 0.0f, end: Constants.kRadialReactionRadius);
new FloatTween(begin: 0.0f, end: material_.kRadialReactionRadius);
public static readonly TimeSpan _kReactionFadeDuration = new TimeSpan(0, 0, 0, 0, 50);
}

_tristate = tristate;
_activeColor = activeColor;
_inactiveColor = inactiveColor;
_hoverColor = hoverColor ?? activeColor.withAlpha(Constants.kRadialReactionAlpha);
_focusColor = focusColor ?? activeColor.withAlpha(Constants.kRadialReactionAlpha);
_hoverColor = hoverColor ?? activeColor.withAlpha(material_.kRadialReactionAlpha);
_focusColor = focusColor ?? activeColor.withAlpha(material_.kRadialReactionAlpha);
_onChanged = onChanged;
_hasFocus = hasFocus;
_hovering = hovering;

_position.addListener(markNeedsPaint);
_reactionController = new AnimationController(
duration: Constants.kRadialReactionDuration,
duration: material_.kRadialReactionDuration,
vsync: vsync);
_reaction = new CurvedAnimation(
parent: _reactionController,

if (!_reaction.isDismissed || !_reactionFocusFade.isDismissed || !_reactionHoverFade.isDismissed) {
Paint reactionPaint = new Paint();
reactionPaint.color = Color.lerp(
Color.lerp(activeColor.withAlpha(Constants.kRadialReactionAlpha), hoverColor,
Color.lerp(activeColor.withAlpha(material_.kRadialReactionAlpha), hoverColor,
? Constants.kRadialReactionRadius
? material_.kRadialReactionRadius
: ToggleableUtils._kRadialReactionRadiusTween.evaluate(_reaction);
if (reactionRadius > 0.0f) {

2
com.unity.uiwidgets/Runtime/material/banner.cs.meta


fileFormatVersion: 2
guid: a56231ebee8e54b6599292d673909844
guid: 4c7a66fe1d2a44bb9e405ba3c042cb7e
MonoImporter:
externalObjects: {}
serializedVersion: 2

11
com.unity.uiwidgets/Runtime/material/banner_theme.cs.meta


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

11
com.unity.uiwidgets/Runtime/material/button_bar_theme.cs.meta


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

11
com.unity.uiwidgets/Runtime/material/button_sheet_theme.cs.meta


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

84
com.unity.uiwidgets/Runtime/material/checkbox_list_tile.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public class CheckboxListTile : StatelessWidget {
public CheckboxListTile(
Key key,
bool? value = null,
ValueChanged<bool?> onChanged = null,
Color activeColor = null,
Color checkColor = null,
Widget title = null,
Widget subtitle = null,
bool isThreeLine = false,
bool? dense = null,
Widget secondary = null,
bool selected = false,
ListTileControlAffinity controlAffinity = ListTileControlAffinity.platform
) : base(key: key) {
D.assert(value != null);
D.assert(!isThreeLine || subtitle != null);
this.checkColor = checkColor;
this.title = title;
this.subtitle = subtitle;
this.isThreeLine = isThreeLine;
this.dense = dense;
this.secondary = secondary;
this.selected = selected;
this.controlAffinity = controlAffinity;
}
public readonly bool? value;
public readonly ValueChanged<bool?> onChanged;
public readonly Color activeColor;
public readonly Color checkColor;
public readonly Widget title;
public readonly Widget subtitle;
public readonly Widget secondary;
public readonly bool isThreeLine;
public readonly bool? dense;
public readonly bool selected;
public readonly ListTileControlAffinity controlAffinity;
public override Widget build(BuildContext context) {
Widget control = new Checkbox(
value: value,
onChanged: onChanged,
activeColor: activeColor,
checkColor: checkColor,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
);
Widget leading = null;
Widget trailing = null;
switch (controlAffinity) {
case ListTileControlAffinity.leading:
leading = control;
trailing = secondary;
break;
case ListTileControlAffinity.trailing:
case ListTileControlAffinity.platform:
leading = secondary;
trailing = control;
break;
}
return ListTileTheme.merge(
selectedColor: activeColor ?? Theme.of(context).accentColor,
child: new ListTile(
leading: leading,
title: title,
subtitle: subtitle,
trailing: trailing,
isThreeLine: isThreeLine,
dense: dense,
enabled: onChanged != null,
onTap: onChanged != null ? () => { onChanged(!value); } : (GestureTapCallback) null,
selected: selected
)
);
}
}
}

11
com.unity.uiwidgets/Runtime/material/checkbox_list_tile.cs.meta


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

11
com.unity.uiwidgets/Runtime/material/curves.cs.meta


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

702
com.unity.uiwidgets/Runtime/material/data_table.cs


using System;
using System.Collections.Generic;
using System.Linq;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public partial class material_ {
public delegate void DataColumnSortCallback(int columnIndex, bool ascending);
}
public class DataColumn {
public DataColumn(
Widget label,
string tooltip = null,
bool numeric = false,
material_.DataColumnSortCallback onSort = null
) {
D.assert(label != null);
this.label = label;
this.tooltip = tooltip;
this.numeric = numeric;
this.onSort = onSort;
}
public readonly Widget label;
public readonly string tooltip;
public readonly bool numeric;
public readonly material_.DataColumnSortCallback onSort;
internal bool _debugInteractive {
get { return onSort != null; }
}
}
public class DataRow {
public DataRow(
LocalKey key = null,
bool selected = false,
ValueChanged<bool> onSelectChanged = null,
List<DataCell> cells = null
) {
D.assert(cells != null);
this.key = key;
this.selected = selected;
this.onSelectChanged = onSelectChanged;
this.cells = cells;
}
public static DataRow byIndex(
int index = 0,
bool selected = false,
ValueChanged<bool> onSelectChanged = null,
List<DataCell> cells = null
) {
D.assert(cells != null);
return new DataRow(
new ValueKey<int>(index),
selected,
onSelectChanged,
cells
);
}
public readonly LocalKey key;
public readonly ValueChanged<bool> onSelectChanged;
public readonly bool selected;
public readonly List<DataCell> cells;
internal bool _debugInteractive {
get { return onSelectChanged != null || cells.Any((DataCell cell) => cell._debugInteractive); }
}
}
public class DataCell {
public DataCell(
Widget child,
bool placeholder = false,
bool showEditIcon = false,
VoidCallback onTap = null
) {
D.assert(child != null);
this.child = child;
this.placeholder = placeholder;
this.showEditIcon = showEditIcon;
this.onTap = onTap;
}
static readonly DataCell empty = new DataCell(new Container(width: 0.0f, height: 0.0f));
public readonly Widget child;
public readonly bool placeholder;
public readonly bool showEditIcon;
public readonly VoidCallback onTap;
internal bool _debugInteractive {
get { return onTap != null; }
}
}
public class DataTable : StatelessWidget {
public DataTable(
Key key = null,
List<DataColumn> columns = null,
int? sortColumnIndex = 0,
bool sortAscending = true,
ValueSetter<bool> onSelectAll = null,
float dataRowHeight = material_.kMinInteractiveDimension,
float headingRowHeight = 56.0f,
float horizontalMargin = 24.0f,
float columnSpacing = 56.0f,
bool showCheckboxColumn = true,
float dividerThickness = 1.0f,
List<DataRow> rows = null
) : base(key: key) {
D.assert(columns != null);
D.assert(columns.isNotEmpty);
D.assert(sortColumnIndex == null || (sortColumnIndex >= 0 && sortColumnIndex < columns.Count));
D.assert(rows != null);
D.assert(!rows.Any((DataRow row) => row.cells.Count != columns.Count));
D.assert(dividerThickness >= 0);
this.columns = columns;
this.sortColumnIndex = sortColumnIndex;
this.sortAscending = sortAscending;
this.onSelectAll = onSelectAll;
this.dataRowHeight = dataRowHeight;
this.headingRowHeight = headingRowHeight;
this.horizontalMargin = horizontalMargin;
this.columnSpacing = columnSpacing;
this.showCheckboxColumn = showCheckboxColumn;
this.dividerThickness = dividerThickness;
this.rows = rows;
_onlyTextColumn = _initOnlyTextColumn(columns);
}
public readonly List<DataColumn> columns;
public readonly int? sortColumnIndex;
public readonly bool sortAscending;
public readonly ValueSetter<bool> onSelectAll;
public readonly float dataRowHeight;
public readonly float headingRowHeight;
public readonly float horizontalMargin;
public readonly float columnSpacing;
public readonly bool showCheckboxColumn;
public readonly List<DataRow> rows;
public readonly int? _onlyTextColumn;
static int? _initOnlyTextColumn(List<DataColumn> columns) {
int? result = null;
for (int index = 0; index < columns.Count; index += 1) {
DataColumn column = columns[index];
if (!column.numeric) {
if (result != null) {
return null;
}
result = index;
}
}
return result;
}
bool _debugInteractive {
get {
return columns.Any((DataColumn column) => column._debugInteractive)
|| rows.Any((DataRow row) => row._debugInteractive);
}
}
static readonly LocalKey _headingRowKey = new UniqueKey();
void _handleSelectAll(bool isChecked) {
if (onSelectAll != null) {
onSelectAll(isChecked);
}
else {
foreach (DataRow row in rows) {
if ((row.onSelectChanged != null) && (row.selected != isChecked))
row.onSelectChanged(isChecked);
}
}
}
static readonly float _sortArrowPadding = 2.0f;
static readonly float _headingFontSize = 12.0f;
static readonly TimeSpan _sortArrowAnimationDuration = new TimeSpan(0, 0, 0, 0, 150);
static readonly Color _grey100Opacity = new Color(0x0A000000);
static readonly Color _grey300Opacity = new Color(0x1E000000);
public readonly float dividerThickness;
Widget _buildCheckbox(
Color color = null,
bool isChecked = false,
VoidCallback onRowTap = null,
ValueChanged<bool?> onCheckboxChanged = null
) {
Widget contents = new Padding(
//TODO: update EdgeInsets
padding: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(start: horizontalMargin,
end: horizontalMargin / 2.0f),
child: new Center(
child: new Checkbox(
activeColor: color,
value: isChecked,
onChanged: onCheckboxChanged
)
)
);
if (onRowTap != null) {
contents = new TableRowInkWell(
onTap: () => onRowTap(),
child: contents
);
}
return new TableCell(
verticalAlignment: TableCellVerticalAlignment.fill,
child: contents
);
}
Widget _buildHeadingCell(
BuildContext context = null,
EdgeInsetsGeometry padding = null,
Widget label = null,
string tooltip = null,
bool? numeric = null,
VoidCallback onSort = null,
bool? sorted = null,
bool? ascending = null
) {
List<Widget> arrowWithPadding() {
return onSort == null
? new List<Widget>()
: new List<
Widget>() {
new _SortArrow(
visible: sorted,
down: sorted ?? false ? ascending : null,
duration: _sortArrowAnimationDuration
),
new SizedBox(width: _sortArrowPadding)
};
}
var rowChild = new List<Widget>();
rowChild.Add(label);
rowChild.AddRange(arrowWithPadding());
label = new Row(
textDirection: numeric ?? false ? TextDirection.rtl : (TextDirection?) null,
children: rowChild
);
label = new Container(
// TODO: udpate to EdgetInsets
padding: (EdgeInsets) padding,
height: headingRowHeight,
alignment: numeric ?? false
? Alignment.centerRight
: (AlignmentGeometry) AlignmentDirectional.centerStart,
child: new AnimatedDefaultTextStyle(
style: new TextStyle(
fontWeight: FontWeight.w500,
fontSize: _headingFontSize,
height: Mathf.Min(1.0f, headingRowHeight / _headingFontSize),
color: (Theme.of(context).brightness == Brightness.light)
? ((onSort != null && (sorted ?? false)) ? Colors.black87 : Colors.black54)
: ((onSort != null && (sorted ?? false)) ? Colors.white : Colors.white70)
),
softWrap: false,
duration: _sortArrowAnimationDuration,
child: label
)
);
if (tooltip != null) {
label = new Tooltip(
message: tooltip,
child: label
);
}
// TODO(dkwingsmt): Only wrap Inkwell if onSort != null. Blocked by
// https://github.com/flutter/flutter/issues/51152
label = new InkWell(
onTap: () => onSort(),
child: label
);
return label;
}
Widget _buildDataCell(
BuildContext context,
EdgeInsetsGeometry padding,
Widget label,
bool numeric,
bool placeholder,
bool showEditIcon,
VoidCallback onTap,
VoidCallback onSelectChanged
) {
bool isLightTheme = Theme.of(context).brightness == Brightness.light;
if (showEditIcon) {
Widget icon = new Icon(Icons.edit, size: 18.0f);
label = new Expanded(child: label);
label = new Row(
textDirection: numeric ? TextDirection.rtl : (TextDirection?) null,
children: new List<Widget> {label, icon}
);
}
label = new Container(
padding: (EdgeInsets) padding,
height: dataRowHeight,
alignment: numeric ? Alignment.centerRight : (AlignmentGeometry) AlignmentDirectional.centerStart,
child: new DefaultTextStyle(
style: new TextStyle(
// TODO(ianh): font family should be Roboto; see https://github.com/flutter/flutter/issues/3116
fontSize: 13.0f,
color: isLightTheme
? (placeholder ? Colors.black38 : Colors.black87)
: (placeholder ? Colors.white38 : Colors.white70)
),
child: IconTheme.merge(
data: new IconThemeData(
color: isLightTheme ? Colors.black54 : Colors.white70
),
child: new DropdownButtonHideUnderline(child: label)
)
)
);
if (onTap != null) {
label = new InkWell(
onTap: () => onTap(),
child: label
);
}
else if (onSelectChanged != null) {
label = new TableRowInkWell(
onTap: () => onSelectChanged(),
child: label
);
}
return label;
}
public override Widget build(BuildContext context) {
D.assert(!_debugInteractive || material_.debugCheckHasMaterial(context));
ThemeData theme = Theme.of(context);
BoxDecoration _kSelectedDecoration = new BoxDecoration(
border: new Border(bottom: Divider.createBorderSide(context, width: dividerThickness)),
// The backgroundColor has to be transparent so you can see the ink on the material
color: (Theme.of(context).brightness == Brightness.light) ? _grey100Opacity : _grey300Opacity
);
BoxDecoration _kUnselectedDecoration = new BoxDecoration(
border: new Border(bottom: Divider.createBorderSide(context, width: dividerThickness))
);
bool displayCheckboxColumn =
showCheckboxColumn && rows.Any((DataRow row) => row.onSelectChanged != null);
bool allChecked = displayCheckboxColumn &&
!rows.Any((DataRow row) => row.onSelectChanged != null && !row.selected);
List<TableColumnWidth> tableColumns =
new List<TableColumnWidth>(columns.Count + (displayCheckboxColumn ? 1 : 0));
List<TableRow> tableRows = Enumerable.Range(1, 10).Select((index) => {
return new TableRow(
key: index == 0 ? _headingRowKey : rows[index - 1].key,
decoration: index > 0 && rows[index - 1].selected
? _kSelectedDecoration
: _kUnselectedDecoration,
children: new List<Widget>(tableColumns.Count)
);
}).ToList();
// List<TableRow> tableRows = List<TableRow>.gegenerate(
// rows.length + 1, // the +1 is for the header row
// (int index) {
// return TableRow(
// key: index == 0 ? _headingRowKey : rows[index - 1].key,
// decoration: index > 0 && rows[index - 1].selected
// ? _kSelectedDecoration
// : _kUnselectedDecoration,
// children: List<Widget>(tableColumns.length),
// );
// },
// );
int rowIndex;
int displayColumnIndex = 0;
if (displayCheckboxColumn) {
tableColumns[0] = new FixedColumnWidth(horizontalMargin + Checkbox.width + horizontalMargin / 2.0f);
tableRows[0].children[0] = _buildCheckbox(
color: theme.accentColor,
isChecked: allChecked,
onCheckboxChanged: _check => _handleSelectAll(_check ?? false)
);
rowIndex = 1;
foreach (DataRow row in rows) {
tableRows[rowIndex].children[0] = _buildCheckbox(
color: theme.accentColor,
isChecked: row.selected,
onRowTap: () => {
if (row.onSelectChanged != null) {
row.onSelectChanged(!row.selected);
}
},
onCheckboxChanged: _select => row.onSelectChanged(_select ?? false)
);
rowIndex += 1;
}
displayColumnIndex += 1;
}
for (int dataColumnIndex = 0; dataColumnIndex < columns.Count; dataColumnIndex += 1) {
DataColumn column = columns[dataColumnIndex];
float paddingStart;
if (dataColumnIndex == 0 && displayCheckboxColumn) {
paddingStart = horizontalMargin / 2.0f;
}
else if (dataColumnIndex == 0 && !displayCheckboxColumn) {
paddingStart = horizontalMargin;
}
else {
paddingStart = columnSpacing / 2.0f;
}
float paddingEnd;
if (dataColumnIndex == columns.Count - 1) {
paddingEnd = horizontalMargin;
}
else {
paddingEnd = columnSpacing / 2.0f;
}
EdgeInsetsDirectional padding = EdgeInsetsDirectional.only(
start: paddingStart,
end: paddingEnd
);
if (dataColumnIndex == _onlyTextColumn) {
tableColumns[displayColumnIndex] = new IntrinsicColumnWidth(flex: 1.0f);
}
else {
tableColumns[displayColumnIndex] = new IntrinsicColumnWidth();
}
tableRows[0].children[displayColumnIndex] = _buildHeadingCell(
context: context,
padding: padding,
label: column.label,
tooltip: column.tooltip,
numeric: column.numeric,
onSort: column.onSort != null
? () => column.onSort(dataColumnIndex, sortColumnIndex != dataColumnIndex || !sortAscending)
: (VoidCallback) null,
sorted: dataColumnIndex == sortColumnIndex,
ascending: sortAscending
);
rowIndex = 1;
foreach (DataRow row in rows) {
DataCell cell = row.cells[dataColumnIndex];
tableRows[rowIndex].children[displayColumnIndex] = _buildDataCell(
context: context,
padding: padding,
label: cell.child,
numeric: column.numeric,
placeholder: cell.placeholder,
showEditIcon: cell.showEditIcon,
onTap: cell.onTap,
onSelectChanged: () => {
if (row.onSelectChanged != null) {
row.onSelectChanged(!row.selected);
}
});
rowIndex += 1;
}
displayColumnIndex += 1;
}
return new Table(
columnWidths: tableColumns.Select((x, i) => new {x, i})
.ToDictionary(a => a.i, a => a.x),
children: tableRows
);
}
}
public class TableRowInkWell : InkResponse {
public TableRowInkWell(
Key key = null,
Widget child = null,
GestureTapCallback onTap = null,
GestureTapCallback onDoubleTap = null,
GestureLongPressCallback onLongPress = null,
ValueChanged<bool> onHighlightChanged = null
) : base(
key: key,
child: child,
onTap: onTap,
onDoubleTap: onDoubleTap,
onLongPress: onLongPress,
onHighlightChanged: onHighlightChanged,
containedInkWell: true,
highlightShape: BoxShape.rectangle
) {
}
public override RectCallback getRectCallback(RenderBox referenceBox) {
return () => {
RenderObject cell = referenceBox;
AbstractNodeMixinDiagnosticableTree table = cell.parent;
Matrix4 transform = Matrix4.identity();
while (table is RenderObject && !(table is RenderTable)) {
RenderObject parentBox = table as RenderObject;
parentBox.applyPaintTransform(cell, transform);
D.assert(table == cell.parent);
cell = parentBox;
table = table.parent;
}
if (table is RenderTable renderTable) {
TableCellParentData cellParentData = cell.parentData as TableCellParentData;
D.assert(cellParentData.y != null);
Rect rect = renderTable.getRowBox(cellParentData.y);
// The rect is in the table's coordinate space. We need to change it to the
// TableRowInkWell's coordinate space.
renderTable.applyPaintTransform(cell, transform);
Offset offset = MatrixUtils.getAsTranslation(transform);
if (offset != null)
return rect.shift(-offset);
}
return Rect.zero;
}
;
}
public override bool debugCheckContext(BuildContext context) {
D.assert(WidgetsD.debugCheckHasTable(context));
return base.debugCheckContext(context);
}
}
internal class _SortArrow : StatefulWidget {
internal _SortArrow(
Key key = null,
bool? visible = null,
bool? down = null,
TimeSpan? duration = null
) : base(key: key) {
this.visible = visible;
this.down = down;
this.duration = duration;
}
public readonly bool? visible;
public readonly bool? down;
public readonly TimeSpan? duration;
public override State createState() => new _SortArrowState();
}
class _SortArrowState : TickerProviderStateMixin<_SortArrow> {
AnimationController _opacityController;
Animation<float> _opacityAnimation;
AnimationController _orientationController;
Animation<float> _orientationAnimation;
float _orientationOffset = 0.0f;
bool _down;
static readonly Animatable<float> _turnTween =
new Tween<float>(begin: 0.0f, end: Mathf.PI).chain(new CurveTween(curve: Curves.easeIn));
public override void initState() {
base.initState();
_opacityAnimation = new CurvedAnimation(
parent: _opacityController = new AnimationController(
duration: widget.duration,
vsync: this
),
curve: Curves.fastOutSlowIn
);
_opacityAnimation.addListener(_rebuild);
_opacityController.setValue(widget.visible ?? false ? 1.0f : 0.0f);
_orientationController = new AnimationController(
duration: widget.duration,
vsync: this
);
_orientationAnimation = _orientationController.drive(_turnTween);
_orientationAnimation.addListener(_rebuild);
_orientationAnimation.addStatusListener(_resetOrientationAnimation);
if (widget.visible ?? false) {
_orientationOffset = widget.down ?? false ? 0.0f : Mathf.PI;
}
}
void _rebuild() {
setState(() => {
// The animations changed, so we need to rebuild.
});
}
void _resetOrientationAnimation(AnimationStatus status) {
if (status == AnimationStatus.completed) {
D.assert(_orientationAnimation.value == Mathf.PI);
_orientationOffset += Mathf.PI;
_orientationController.setValue(0.0f); // TODO(ianh): This triggers a pointless rebuild.
}
}
public override void didUpdateWidget(StatefulWidget oldStatefullWidget) {
var oldWidget = oldStatefullWidget as _SortArrow;
if (oldWidget == null) {
return;
}
base.didUpdateWidget(oldWidget);
bool skipArrow = false;
bool newDown = widget.down ?? _down;
if (oldWidget.visible != widget.visible) {
if ((widget.visible ?? false) && (_opacityController.status == AnimationStatus.dismissed)) {
_orientationController.stop();
_orientationController.setValue(0.0f);
_orientationOffset = newDown ? 0.0f : Mathf.PI;
skipArrow = true;
}
if (widget.visible ?? false) {
_opacityController.forward();
}
else {
_opacityController.reverse();
}
}
if ((_down != newDown) && !skipArrow) {
if (_orientationController.status == AnimationStatus.dismissed) {
_orientationController.forward();
}
else {
_orientationController.reverse();
}
}
_down = newDown;
}
public override void dispose() {
_opacityController.dispose();
_orientationController.dispose();
base.dispose();
}
const float _arrowIconBaselineOffset = -1.5f;
const float _arrowIconSize = 16.0f;
public override Widget build(BuildContext context) {
var transform = Matrix4.rotationZ(_orientationOffset + _orientationAnimation.value);
transform.setTranslationRaw(0.0f, _arrowIconBaselineOffset, 0.0f);
return new Opacity(
opacity: _opacityAnimation.value,
child: new widgets.Transform(
transform: transform,
alignment: Alignment.center,
child: new Icon(
Icons.arrow_downward,
size: _arrowIconSize,
color: (Theme.of(context).brightness == Brightness.light) ? Colors.black87 : Colors.white70
)
)
);
}
}
}

3
com.unity.uiwidgets/Runtime/material/data_table.cs.meta


fileFormatVersion: 2
guid: c56625425d4442ca967966944751b3b9
timeCreated: 1611566744

13
com.unity.uiwidgets/Runtime/material/data_table_source.cs


using Unity.UIWidgets.foundation;
namespace Unity.UIWidgets.material {
public abstract class DataTableSource : ChangeNotifier {
public abstract DataRow getRow(int index);
public int rowCount { get; }
public bool isRowCountApproximate { get; }
public int selectedRowCount { get; }
}
}

3
com.unity.uiwidgets/Runtime/material/data_table_source.cs.meta


fileFormatVersion: 2
guid: 29a8053dc21e4bba8f4062327f37e024
timeCreated: 1611566587

11
com.unity.uiwidgets/Runtime/material/divider_theme.cs.meta


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

11
com.unity.uiwidgets/Runtime/material/material_state.cs.meta


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

11
com.unity.uiwidgets/Runtime/material/popup_menu_theme.cs.meta


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

11
com.unity.uiwidgets/Runtime/material/toggle_buttons.cs.meta


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

11
com.unity.uiwidgets/Runtime/material/toggle_buttons_theme.cs.meta


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

11
com.unity.uiwidgets/Runtime/material/tooltip_theme.cs.meta


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

939
com.unity.uiwidgets/Runtime/material/date_picker.cs


using System;
using System.Collections.Generic;
using com.unity.uiwidgets.Runtime.rendering;
using uiwidgets;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
/*
* Differences between Dart & C#
* Duration => TimeSpan
* -1 % 4 = 3 => -1 % 4 = -1
* [Dart] [DateTime.weekday] provides a 1-based index (Start with Monday)
* [C#] [DateTime.DayOfWeek] provides a 0-based index (Start with Sunday)
* @IIzzaya
*/
namespace Unity.UIWidgets.material {
public class DatePickerUtils {
public const float _kDatePickerHeaderPortraitHeight = 100.0f;
public const float _kDatePickerHeaderLandscapeWidth = 168.0f;
public static readonly TimeSpan _kMonthScrollDuration = new TimeSpan(0, 0, 0, 0, 200);
public const float _kDayPickerRowHeight = 42.0f;
public const int _kMaxDayPickerRowCount = 6;
public const float _kMaxDayPickerHeight = _kDayPickerRowHeight * (_kMaxDayPickerRowCount + 2);
public const float _kMonthPickerPortraitWidth = 330.0f;
public const float _kMonthPickerLandscapeWidth = 344.0f;
public const float _kDialogActionBarHeight = 52.0f;
public const float _kDatePickerLandscapeHeight = _kMaxDayPickerHeight + _kDialogActionBarHeight;
internal static readonly _DayPickerGridDelegate _kDayPickerGridDelegate = new _DayPickerGridDelegate();
public static Future<object> showDatePicker(
BuildContext context,
DateTime initialDate,
DateTime firstDate,
DateTime lastDate,
SelectableDayPredicate selectableDayPredicate = null,
DatePickerMode initialDatePickerMode = DatePickerMode.day,
Locale locale = null,
TransitionBuilder builder = null
) {
D.assert(initialDate >= firstDate, () => "initialDate must be on or after firstDate");
D.assert(initialDate <= lastDate, () => "initialDate must be on or before lastDate");
D.assert(firstDate <= lastDate, () => "lastDate must be on or after firstDate");
D.assert(
selectableDayPredicate == null || selectableDayPredicate(initialDate),
() => "Provided initialDate must satisfy provided selectableDayPredicate"
);
D.assert(context != null);
D.assert(material_.debugCheckHasMaterialLocalizations(context));
Widget child = new _DatePickerDialog(
initialDate: initialDate,
firstDate: firstDate,
lastDate: lastDate,
selectableDayPredicate: selectableDayPredicate,
initialDatePickerMode: initialDatePickerMode
);
if (locale != null) {
child = Localizations.overrides(
context: context,
locale: locale,
child: child
);
}
return material_.showDialog<object>(
context: context,
builder: (BuildContext _context) => { return builder == null ? child : builder(_context, child); }
);
}
}
public enum DatePickerMode {
day,
year
}
class _DatePickerHeader : StatelessWidget {
public _DatePickerHeader(
DateTime selectedDate,
DatePickerMode mode,
ValueChanged<DatePickerMode> onModeChanged,
Orientation orientation,
Key key = null
) : base(key: key) {
this.selectedDate = selectedDate;
this.mode = mode;
this.onModeChanged = onModeChanged;
this.orientation = orientation;
}
public readonly DateTime selectedDate;
public readonly DatePickerMode mode;
public readonly ValueChanged<DatePickerMode> onModeChanged;
public readonly Orientation orientation;
void _handleChangeMode(DatePickerMode value) {
if (value != mode) {
onModeChanged(value);
}
}
public override Widget build(BuildContext context) {
MaterialLocalizations localizations = MaterialLocalizations.of(context);
ThemeData themeData = Theme.of(context);
TextTheme headerTextTheme = themeData.primaryTextTheme;
Color dayColor = null;
Color yearColor = null;
switch (themeData.primaryColorBrightness) {
case Brightness.light:
dayColor = mode == DatePickerMode.day ? Colors.black87 : Colors.black54;
yearColor = mode == DatePickerMode.year ? Colors.black87 : Colors.black54;
break;
case Brightness.dark:
dayColor = mode == DatePickerMode.day ? Colors.white : Colors.white70;
yearColor = mode == DatePickerMode.year ? Colors.white : Colors.white70;
break;
}
TextStyle dayStyle = headerTextTheme.display1.copyWith(color: dayColor, height: 1.4f);
TextStyle yearStyle = headerTextTheme.subhead.copyWith(color: yearColor, height: 1.4f);
Color backgroundColor = null;
switch (themeData.brightness) {
case Brightness.light:
backgroundColor = themeData.primaryColor;
break;
case Brightness.dark:
backgroundColor = themeData.backgroundColor;
break;
}
float width = 0f;
float height = 0f;
EdgeInsets padding = null;
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.center;
switch (orientation) {
case Orientation.portrait:
height = DatePickerUtils._kDatePickerHeaderPortraitHeight;
padding = EdgeInsets.symmetric(horizontal: 16.0f);
mainAxisAlignment = MainAxisAlignment.center;
break;
case Orientation.landscape:
width = DatePickerUtils._kDatePickerHeaderLandscapeWidth;
padding = EdgeInsets.all(8.0f);
mainAxisAlignment = MainAxisAlignment.start;
break;
}
Widget yearButton = new IgnorePointer(
ignoring: mode != DatePickerMode.day,
child: new _DateHeaderButton(
color: backgroundColor,
onTap: Feedback.wrapForTap(() => _handleChangeMode(DatePickerMode.year), context),
child: new Text(localizations.formatYear(selectedDate), style: yearStyle)
)
);
Widget dayButton = new IgnorePointer(
ignoring: mode == DatePickerMode.day,
child: new _DateHeaderButton(
color: backgroundColor,
onTap: Feedback.wrapForTap(() => _handleChangeMode(DatePickerMode.day), context),
child: new Text(localizations.formatMediumDate(selectedDate), style: dayStyle)
)
);
return new Container(
width: width,
height: height,
padding: padding,
color: backgroundColor,
child: new Column(
mainAxisAlignment: mainAxisAlignment,
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {yearButton, dayButton}
)
);
}
}
class _DateHeaderButton : StatelessWidget {
public _DateHeaderButton(
GestureTapCallback onTap,
Color color,
Widget child,
Key key = null
) : base(key: key) {
this.onTap = onTap;
this.color = color;
this.child = child;
}
public readonly GestureTapCallback onTap;
public readonly Color color;
public readonly Widget child;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
return new Material(
type: MaterialType.button,
color: color,
child: new InkWell(
borderRadius: MaterialConstantsUtils.kMaterialEdges[MaterialType.button],
highlightColor: theme.highlightColor,
splashColor: theme.splashColor,
onTap: onTap,
child: new Container(
padding: EdgeInsets.symmetric(horizontal: 8.0f),
child: child
)
)
);
}
}
class _DayPickerGridDelegate : SliverGridDelegate {
public _DayPickerGridDelegate() { }
public override SliverGridLayout getLayout(SliverConstraints constraints) {
const int columnCount = 7; // DateTime.daysPerWeek = 7
float tileWidth = constraints.crossAxisExtent / columnCount;
float tileHeight = Mathf.Min(
DatePickerUtils._kDayPickerRowHeight,
constraints.viewportMainAxisExtent / (DatePickerUtils._kMaxDayPickerRowCount + 1)
);
return new SliverGridRegularTileLayout(
crossAxisCount: columnCount,
mainAxisStride: tileHeight,
crossAxisStride: tileWidth,
childMainAxisExtent: tileHeight,
childCrossAxisExtent: tileWidth,
reverseCrossAxis: AxisUtils.axisDirectionIsReversed(constraints.crossAxisDirection)
);
}
public override bool shouldRelayout(SliverGridDelegate oldDelegate) {
return false;
}
}
public class DayPicker : StatelessWidget {
public DayPicker(
DateTime selectedDate,
DateTime currentDate,
ValueChanged<DateTime> onChanged,
DateTime firstDate,
DateTime lastDate,
DateTime displayedMonth,
SelectableDayPredicate selectableDayPredicate = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Key key = null
) : base(key: key) {
D.assert(onChanged != null);
D.assert(firstDate <= lastDate);
D.assert(selectedDate >= firstDate);
this.selectedDate = selectedDate;
this.currentDate = currentDate;
this.onChanged = onChanged;
this.firstDate = firstDate;
this.lastDate = lastDate;
this.displayedMonth = displayedMonth;
this.selectableDayPredicate = selectableDayPredicate;
this.dragStartBehavior = dragStartBehavior;
}
public readonly DateTime selectedDate;
public readonly DateTime currentDate;
public readonly ValueChanged<DateTime> onChanged;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly DateTime displayedMonth;
public readonly SelectableDayPredicate selectableDayPredicate;
public readonly DragStartBehavior dragStartBehavior;
List<Widget> _getDayHeaders(TextStyle headerStyle, MaterialLocalizations localizations) {
List<Widget> result = new List<Widget>();
for (int i = localizations.firstDayOfWeekIndex; true; i = (i + 1) % 7) {
string weekday = localizations.narrowWeekdays[i];
result.Add(new Center(child: new Text(weekday, style: headerStyle)));
if (i == (localizations.firstDayOfWeekIndex + 6) % 7) {
break;
}
}
return result;
}
static readonly List<int> _daysInMonth = new List<int> {31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static int getDaysInMonth(int year, int month) {
if (month == 2) {
bool isLeapYear = (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0);
if (isLeapYear) {
return 29;
}
return 28;
}
return _daysInMonth[month - 1];
}
int _computeFirstDayOffset(int year, int month, MaterialLocalizations localizations) {
int weekdayFromMonday = new DateTime(year, month, 1).DayOfWeek.GetHashCode();
if (weekdayFromMonday == 0) {
weekdayFromMonday = 7;
}
weekdayFromMonday--;
int firstDayOfWeekFromSunday = localizations.firstDayOfWeekIndex;
int firstDayOfWeekFromMonday = (firstDayOfWeekFromSunday - 1) % 7;
return (weekdayFromMonday - firstDayOfWeekFromMonday) % 7;
}
public override Widget build(BuildContext context) {
ThemeData themeData = Theme.of(context);
MaterialLocalizations localizations = MaterialLocalizations.of(context);
int year = displayedMonth.Year;
int month = displayedMonth.Month;
int daysInMonth = getDaysInMonth(year, month);
int firstDayOffset = _computeFirstDayOffset(year, month, localizations);
List<Widget> labels = new List<Widget>();
labels.AddRange(_getDayHeaders(themeData.textTheme.caption, localizations));
for (int i = 0; true; i += 1) {
int day = i - firstDayOffset + 1;
if (day > daysInMonth) {
break;
}
if (day < 1) {
labels.Add(new Container());
}
else {
DateTime dayToBuild = new DateTime(year, month, day);
bool disabled = dayToBuild > lastDate
|| dayToBuild < firstDate
|| (selectableDayPredicate != null &&
!selectableDayPredicate(dayToBuild));
BoxDecoration decoration = null;
TextStyle itemStyle = themeData.textTheme.body1;
bool isSelectedDay = selectedDate.Year == year && selectedDate.Month == month &&
selectedDate.Day == day;
if (isSelectedDay) {
itemStyle = themeData.accentTextTheme.body2;
decoration = new BoxDecoration(
color: themeData.accentColor,
shape: BoxShape.circle
);
}
else if (disabled) {
itemStyle = themeData.textTheme.body1.copyWith(color: themeData.disabledColor);
}
else if (currentDate.Year == year && currentDate.Month == month &&
currentDate.Day == day) {
itemStyle = themeData.textTheme.body2.copyWith(color: themeData.accentColor);
}
Widget dayWidget = new Container(
decoration: decoration,
child: new Center(
child: new Text(localizations.formatDecimal(day), style: itemStyle)
)
);
if (!disabled) {
dayWidget = new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => { onChanged(dayToBuild); },
child: dayWidget,
dragStartBehavior: dragStartBehavior
);
}
labels.Add(dayWidget);
}
}
return new Padding(
padding: EdgeInsets.symmetric(horizontal: 8.0f),
child: new Column(
children: new List<Widget> {
new Container(
height: DatePickerUtils._kDayPickerRowHeight,
child: new Center(
child: new Text(
localizations.formatMonthYear(displayedMonth),
style: themeData.textTheme.subhead
)
)
),
new Flexible(
child: GridView.custom(
gridDelegate: DatePickerUtils._kDayPickerGridDelegate,
childrenDelegate: new SliverChildListDelegate(labels, addRepaintBoundaries: false)
)
)
}
)
);
}
}
class MonthPicker : StatefulWidget {
public MonthPicker(
DateTime selectedDate,
ValueChanged<DateTime> onChanged,
DateTime firstDate,
DateTime lastDate,
SelectableDayPredicate selectableDayPredicate,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Key key = null
) : base(key: key) {
D.assert(selectedDate != null);
D.assert(onChanged != null);
D.assert(firstDate <= lastDate);
D.assert(selectedDate >= firstDate);
this.selectedDate = selectedDate;
this.onChanged = onChanged;
this.firstDate = firstDate;
this.lastDate = lastDate;
this.selectableDayPredicate = selectableDayPredicate;
this.dragStartBehavior = dragStartBehavior;
}
public readonly DateTime selectedDate;
public readonly ValueChanged<DateTime> onChanged;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly SelectableDayPredicate selectableDayPredicate;
public readonly DragStartBehavior dragStartBehavior;
public override State createState() {
return new _MonthPickerState();
}
}
class _MonthPickerState : SingleTickerProviderStateMixin<MonthPicker> {
static Animatable<float> __chevronOpacityTween;
static Animatable<float> _chevronOpacityTween {
get {
if (__chevronOpacityTween == null) {
__chevronOpacityTween = new FloatTween(begin: 1.0f, end: 0.0f) { };
__chevronOpacityTween.chain(new CurveTween(curve: Curves.easeInOut));
}
return __chevronOpacityTween;
}
}
public override void initState() {
base.initState();
int monthPage = _monthDelta(widget.firstDate, widget.selectedDate);
_dayPickerController = new PageController(initialPage: monthPage);
_handleMonthPageChanged(monthPage);
_updateCurrentDate();
_chevronOpacityController = new AnimationController(
duration: new TimeSpan(0, 0, 0, 0, 250),
vsync: this
);
_chevronOpacityAnimation = _chevronOpacityController.drive(_chevronOpacityTween);
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
if (widget.selectedDate != ((MonthPicker) oldWidget).selectedDate) {
int monthPage = _monthDelta(widget.firstDate, widget.selectedDate);
_dayPickerController = new PageController(initialPage: monthPage);
_handleMonthPageChanged(monthPage);
}
}
MaterialLocalizations localizations;
public override void didChangeDependencies() {
base.didChangeDependencies();
localizations = MaterialLocalizations.of(context);
}
DateTime _todayDate;
DateTime _currentDisplayedMonthDate;
Timer _timer;
PageController _dayPickerController;
AnimationController _chevronOpacityController;
Animation<float> _chevronOpacityAnimation;
void _updateCurrentDate() {
_todayDate = DateTime.Now;
DateTime tomorrow = _todayDate.AddDays(1);
TimeSpan timeUntilTomorrow = tomorrow.TimeOfDay - _todayDate.TimeOfDay;
_timer?.cancel();
_timer = Timer.create(timeUntilTomorrow,
() => { setState(() => { _updateCurrentDate(); }); });
}
static int _monthDelta(DateTime startDate, DateTime endDate) {
return (endDate.Year - startDate.Year) * 12 + endDate.Month - startDate.Month;
}
DateTime _addMonthsToMonthDate(DateTime monthDate, int monthsToAdd) {
return monthDate.AddMonths(monthsToAdd);
}
Widget _buildItems(BuildContext context, int index) {
DateTime month = _addMonthsToMonthDate(widget.firstDate, index);
return new DayPicker(
key: new ValueKey<DateTime>(month),
selectedDate: widget.selectedDate,
currentDate: _todayDate,
onChanged: widget.onChanged,
firstDate: widget.firstDate,
lastDate: widget.lastDate,
displayedMonth: month,
selectableDayPredicate: widget.selectableDayPredicate,
dragStartBehavior: widget.dragStartBehavior
);
}
void _handleNextMonth() {
if (!_isDisplayingLastMonth) {
_dayPickerController.nextPage(duration: DatePickerUtils._kMonthScrollDuration, curve: Curves.ease);
}
}
void _handlePreviousMonth() {
if (!_isDisplayingFirstMonth) {
_dayPickerController.previousPage(duration: DatePickerUtils._kMonthScrollDuration,
curve: Curves.ease);
}
}
bool _isDisplayingFirstMonth {
get {
return _currentDisplayedMonthDate <=
new DateTime(widget.firstDate.Year, widget.firstDate.Month, 1);
}
}
bool _isDisplayingLastMonth {
get {
return _currentDisplayedMonthDate >=
new DateTime(widget.lastDate.Year, widget.lastDate.Month, 1);
}
}
DateTime _previousMonthDate;
DateTime _nextMonthDate;
void _handleMonthPageChanged(int monthPage) {
setState(() => {
_previousMonthDate = _addMonthsToMonthDate(widget.firstDate, monthPage - 1);
_currentDisplayedMonthDate = _addMonthsToMonthDate(widget.firstDate, monthPage);
_nextMonthDate = _addMonthsToMonthDate(widget.firstDate, monthPage + 1);
});
}
public override Widget build(BuildContext context) {
return new SizedBox(
width: DatePickerUtils._kMonthPickerPortraitWidth,
height: DatePickerUtils._kMaxDayPickerHeight,
child: new Stack(
children: new List<Widget> {
new NotificationListener<ScrollStartNotification>(
onNotification: (_) => {
_chevronOpacityController.forward();
return false;
},
child: new NotificationListener<ScrollEndNotification>(
onNotification: (_) => {
_chevronOpacityController.reverse();
return false;
},
child: PageView.builder(
dragStartBehavior: widget.dragStartBehavior,
key: new ValueKey<DateTime>(widget.selectedDate),
controller: _dayPickerController,
scrollDirection: Axis.horizontal,
itemCount: _monthDelta(widget.firstDate, widget.lastDate) + 1,
itemBuilder: _buildItems,
onPageChanged: _handleMonthPageChanged
)
)
),
new Positioned(
top: 0.0f,
left: 8.0f,
child: new FadeTransition(
opacity: _chevronOpacityAnimation,
child: new IconButton(
icon: new Icon(Icons.chevron_left),
tooltip: _isDisplayingFirstMonth
? null
: $"{localizations.previousMonthTooltip} {localizations.formatMonthYear(_previousMonthDate)}",
onPressed: _isDisplayingFirstMonth
? (VoidCallback) null
: _handlePreviousMonth
)
)
),
new Positioned(
top: 0.0f,
right: 8.0f,
child: new FadeTransition(
opacity: _chevronOpacityAnimation,
child: new IconButton(
icon: new Icon(Icons.chevron_right),
tooltip: _isDisplayingLastMonth
? null
: $"{localizations.nextMonthTooltip} {localizations.formatMonthYear(_nextMonthDate)}",
onPressed: _isDisplayingLastMonth
? (VoidCallback) null
: _handleNextMonth
)
)
)
}
)
);
}
public override void dispose() {
_timer?.cancel();
_dayPickerController?.dispose();
base.dispose();
}
}
class _MonthPickerSortKey : Diagnosticable {
public _MonthPickerSortKey(float order) { }
public static readonly _MonthPickerSortKey previousMonth = new _MonthPickerSortKey(1.0f);
public static readonly _MonthPickerSortKey nextMonth = new _MonthPickerSortKey(2.0f);
public static readonly _MonthPickerSortKey calendar = new _MonthPickerSortKey(3.0f);
}
public class YearPicker : StatefulWidget {
public YearPicker(
DateTime selectedDate,
ValueChanged<DateTime> onChanged,
DateTime firstDate,
DateTime lastDate,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Key key = null
) : base(key: key) {
D.assert(selectedDate != null);
D.assert(onChanged != null);
D.assert(firstDate <= lastDate);
this.selectedDate = selectedDate;
this.onChanged = onChanged;
this.firstDate = firstDate;
this.lastDate = lastDate;
this.dragStartBehavior = dragStartBehavior;
}
public readonly DateTime selectedDate;
public readonly ValueChanged<DateTime> onChanged;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly DragStartBehavior dragStartBehavior;
public override State createState() {
return new _YearPickerState();
}
}
class _YearPickerState : State<YearPicker> {
const float _itemExtent = 50.0f;
ScrollController scrollController;
public override void initState() {
base.initState();
scrollController = new ScrollController(
initialScrollOffset: (widget.selectedDate.Year - widget.firstDate.Year) * _itemExtent
);
}
public override Widget build(BuildContext context) {
D.assert(material_.debugCheckHasMaterial(context));
ThemeData themeData = Theme.of(context);
TextStyle style = themeData.textTheme.body1;
return ListView.builder(
dragStartBehavior: widget.dragStartBehavior,
controller: scrollController,
itemExtent: _itemExtent,
itemCount: widget.lastDate.Year - widget.firstDate.Year + 1,
itemBuilder: (BuildContext _context, int index) => {
int year = widget.firstDate.Year + index;
bool isSelected = year == widget.selectedDate.Year;
TextStyle itemStyle = isSelected
? themeData.textTheme.headline.copyWith(color: themeData.accentColor)
: style;
return new InkWell(
key: new ValueKey<int>(year),
onTap: () => {
widget.onChanged(new DateTime(year, widget.selectedDate.Month,
widget.selectedDate.Day));
},
child: new Center(
child: new Text(year.ToString(), style: itemStyle)
)
);
}
);
}
}
class _DatePickerDialog : StatefulWidget {
public _DatePickerDialog(
DateTime initialDate,
DateTime firstDate,
DateTime lastDate,
SelectableDayPredicate selectableDayPredicate,
DatePickerMode initialDatePickerMode,
Key key = null
) : base(key: key) {
this.initialDate = initialDate;
this.firstDate = firstDate;
this.lastDate = lastDate;
this.selectableDayPredicate = selectableDayPredicate;
this.initialDatePickerMode = initialDatePickerMode;
}
public readonly DateTime initialDate;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly SelectableDayPredicate selectableDayPredicate;
public readonly DatePickerMode initialDatePickerMode;
public override State createState() {
return new _DatePickerDialogState();
}
}
class _DatePickerDialogState : State<_DatePickerDialog> {
public override void initState() {
base.initState();
_selectedDate = widget.initialDate;
_mode = widget.initialDatePickerMode;
}
bool _announcedInitialDate = false;
public MaterialLocalizations localizations;
public override void didChangeDependencies() {
base.didChangeDependencies();
localizations = MaterialLocalizations.of(context);
if (!_announcedInitialDate) {
_announcedInitialDate = true;
}
}
DateTime _selectedDate;
DatePickerMode _mode;
GlobalKey _pickerKey = GlobalKey.key();
void _vibrate() {
switch (Theme.of(context).platform) {
case RuntimePlatform.Android:
// case RuntimePlatform.fuchsia:
// HapticFeedback.vibrate();
break;
}
}
void _handleModeChanged(DatePickerMode mode) {
_vibrate();
setState(() => {
_mode = mode;
if (_mode == DatePickerMode.day) {
// SemanticsService.announce(localizations.formatMonthYear(_selectedDate), textDirection);
}
else {
// SemanticsService.announce(localizations.formatYear(_selectedDate), textDirection);
}
});
}
void _handleYearChanged(DateTime value) {
if (value < widget.firstDate) {
value = widget.firstDate;
}
else if (value > widget.lastDate) {
value = widget.lastDate;
}
if (value == _selectedDate) {
return;
}
_vibrate();
setState(() => {
_mode = DatePickerMode.day;
_selectedDate = value;
});
}
void _handleDayChanged(DateTime value) {
_vibrate();
setState(() => { _selectedDate = value; });
}
void _handleCancel() {
Navigator.pop<object>(context);
}
void _handleOk() {
Navigator.pop(context, _selectedDate);
}
Widget _buildPicker() {
switch (_mode) {
case DatePickerMode.day:
return new MonthPicker(
key: _pickerKey,
selectedDate: _selectedDate,
onChanged: _handleDayChanged,
firstDate: widget.firstDate,
lastDate: widget.lastDate,
selectableDayPredicate: widget.selectableDayPredicate
);
case DatePickerMode.year:
return new YearPicker(
key: _pickerKey,
selectedDate: _selectedDate,
onChanged: _handleYearChanged,
firstDate: widget.firstDate,
lastDate: widget.lastDate
);
}
return null;
}
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
Widget picker = new Flexible(
child: new SizedBox(
height: DatePickerUtils._kMaxDayPickerHeight,
child: _buildPicker()
)
);
Widget actions = ButtonTheme.bar(
child: new ButtonBar(
children: new List<Widget> {
new FlatButton(
child: new Text(localizations.cancelButtonLabel),
onPressed: _handleCancel
),
new FlatButton(
child: new Text(localizations.okButtonLabel),
onPressed: _handleOk
)
}
)
);
Dialog dialog = new Dialog(
child: new OrientationBuilder(
builder: (BuildContext _context, Orientation orientation) => {
Widget header = new _DatePickerHeader(
selectedDate: _selectedDate,
mode: _mode,
onModeChanged: _handleModeChanged,
orientation: orientation
);
switch (orientation) {
case Orientation.portrait:
return new SizedBox(
width: DatePickerUtils._kMonthPickerPortraitWidth,
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
header,
new Container(
color: theme.dialogBackgroundColor,
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
picker,
actions,
}
)
)
}
)
);
case Orientation.landscape:
return new SizedBox(
height: DatePickerUtils._kDatePickerLandscapeHeight,
child: new Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
header,
new Flexible(
child: new Container(
width: DatePickerUtils._kMonthPickerLandscapeWidth,
color: theme.dialogBackgroundColor,
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {picker, actions}
)
)
)
}
)
);
}
return null;
}
)
);
return new Theme(
data: theme.copyWith(
dialogBackgroundColor: Colors.transparent
),
child: dialog
);
}
}
public delegate bool SelectableDayPredicate(DateTime day);
}

/com.unity.uiwidgets/Runtime/material/date_picker.cs.meta → /com.unity.uiwidgets/Runtime/material/banner.cs.meta

正在加载...
取消
保存