浏览代码

Merge pull request #70 from Unity-Technologies/zxw/1.17/material

upgrade more material widgets
/siyaoH-1.17-PlatformMessage
GitHub 4 年前
当前提交
47846b43
共有 19 个文件被更改,包括 2796 次插入604 次删除
  1. 36
      com.unity.uiwidgets/Runtime/material/bottom_sheet.cs
  2. 155
      com.unity.uiwidgets/Runtime/material/radio.cs
  3. 59
      com.unity.uiwidgets/Runtime/material/raised_button.cs
  4. 705
      com.unity.uiwidgets/Runtime/material/scaffold.cs
  5. 203
      com.unity.uiwidgets/Runtime/material/slider.cs
  6. 846
      com.unity.uiwidgets/Runtime/material/slider_theme.cs
  7. 297
      com.unity.uiwidgets/Runtime/material/snack_bar.cs
  8. 20
      com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs
  9. 24
      com.unity.uiwidgets/Runtime/material/stepper.cs
  10. 341
      com.unity.uiwidgets/Runtime/material/switch.cs
  11. 14
      com.unity.uiwidgets/Runtime/material/theme.cs
  12. 27
      com.unity.uiwidgets/Runtime/material/theme_data.cs
  13. 3
      com.unity.uiwidgets/Runtime/rendering/editable.cs
  14. 2
      com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs
  15. 2
      com.unity.uiwidgets/Runtime/rendering/object.mixin.njk
  16. 360
      com.unity.uiwidgets/Runtime/widgets/draggable_scrollable_sheet.cs
  17. 2
      com.unity.uiwidgets/Runtime/widgets/scroll_position_with_single_context.cs
  18. 117
      com.unity.uiwidgets/Runtime/material/ratio_list_tile.cs
  19. 187
      com.unity.uiwidgets/Runtime/material/swtich_list_tile.cs

36
com.unity.uiwidgets/Runtime/material/bottom_sheet.cs


return bottomSheet;
}
}
class _BottomSheetSuspendedCurve : ParametricCurve<float> {
internal _BottomSheetSuspendedCurve(
float startingPoint,
Curve curve = null
) {
D.assert(curve != null);
this.startingPoint = startingPoint;
this.curve = curve ?? Curves.easeOutCubic;
}
public readonly float startingPoint;
public readonly Curve curve;
public override float transform(float t) {
D.assert(t >= 0.0 && t <= 1.0);
D.assert(startingPoint >= 0.0 && startingPoint <= 1.0);
if (t < startingPoint) {
return t;
}
if (t == 1.0) {
return t;
}
float curveProgress = (t - startingPoint) / (1 - startingPoint);
float transformed = curve.transform(curveProgress);
return Mathf.Lerp(startingPoint, 1, transformed);
}
public override string ToString() {
return $"{foundation_.describeIdentity(this)}({startingPoint}, {curve})";
}
}
}

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


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

T value = null,
T groupValue = null,
ValueChanged<T> onChanged = null,
bool toggleable = false,
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(value != null);
D.assert(groupValue != null);

this.onChanged = onChanged;
this.toggleable = toggleable;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.visualDensity = visualDensity;
this.focusNode = focusNode;
this.autofocus = autofocus;
}
public readonly T value;

public readonly ValueChanged<T> onChanged;
public readonly bool toggleable;
public readonly VisualDensity visualDensity;
public readonly Color focusColor;
public readonly Color hoverColor;
public readonly FocusNode focusNode;
public readonly bool autofocus;
public override State createState() {
return new _RadioState<T>();

class _RadioState<T> : TickerProviderStateMixin<Radio<T>> where T : class {
bool _enabled {
bool enabled {
Dictionary<LocalKey, ActionFactory> _actionMap;
public override void initState() {
base.initState();
_actionMap = new Dictionary<LocalKey, ActionFactory>();
_actionMap[ActivateAction.key] = _createAction;
}
void _actionHandler(FocusNode node, Intent intent) {
if (widget.onChanged != null) {
widget.onChanged(widget.value);
}
RenderObject renderObject = node.context.findRenderObject();
}
UiWidgetAction _createAction() {
return new CallbackAction(
ActivateAction.key,
onInvoke: _actionHandler
);
}
bool _focused = false;
void _handleHighlightChanged(bool focused) {
if (_focused != focused) {
setState(() =>{ _focused = focused; });
}
}
bool _hovering = false;
void _handleHoverChanged(bool hovering) {
if (_hovering != hovering) {
setState(() => { _hovering = hovering; });
}
}
return _enabled ? themeData.unselectedWidgetColor : themeData.disabledColor;
return enabled ? themeData.unselectedWidgetColor : themeData.disabledColor;
if (selected == null) {
widget.onChanged(null);
return;
}
if (selected == true) {
widget.onChanged(widget.value);
}

default:
throw new Exception("Unknown material tap target size");
}
size += (widget.visualDensity ?? themeData.visualDensity).baseSizeAdjustment;
return new _RadioRenderObjectWidget(
selected: widget.value == widget.groupValue,
activeColor: widget.activeColor ?? themeData.toggleableActiveColor,
inactiveColor: _getInactiveColor(themeData),
onChanged: _enabled ? _handleChanged : (ValueChanged<bool?>) null,
additionalConstraints: additionalConstraints,
vsync: this
return new FocusableActionDetector(
actions: _actionMap,
focusNode: widget.focusNode,
autofocus: widget.autofocus,
enabled: enabled,
onShowFocusHighlight: _handleHighlightChanged,
onShowHoverHighlight: _handleHoverChanged,
child: new Builder(
builder: (BuildContext subContext) => {
return new _RadioRenderObjectWidget(
selected: widget.value == widget.groupValue,
activeColor: widget.activeColor ?? themeData.toggleableActiveColor,
inactiveColor: _getInactiveColor(themeData),
focusColor: widget.focusColor ?? themeData.focusColor,
hoverColor: widget.hoverColor ?? themeData.hoverColor,
onChanged: enabled ? _handleChanged : (ValueChanged<bool?>)null,
toggleable: widget.toggleable,
additionalConstraints: additionalConstraints,
vsync: this,
hasFocus: _focused,
hovering: _hovering
);
}
)
);
}
}

bool? selected = null,
Color activeColor = null,
Color inactiveColor = null,
Color focusColor = null,
Color hoverColor = null,
TickerProvider vsync = null
bool? toggleable = null,
TickerProvider vsync = null,
bool hasFocus = false,
bool hovering = false
) : base(key: key) {
D.assert(selected != null);
D.assert(activeColor != null);

this.selected = selected;
D.assert(toggleable != null);
this.selected = selected.Value;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.toggleable = toggleable.Value;
this.hasFocus = hasFocus;
this.hovering = hovering;
public readonly bool? selected;
public readonly bool selected;
public readonly bool hasFocus;
public readonly bool hovering;
public readonly BoxConstraints additionalConstraints;
public readonly Color focusColor;
public readonly Color hoverColor;
public readonly bool toggleable;
public readonly BoxConstraints additionalConstraints;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderRadio(

focusColor: focusColor,
hoverColor: hoverColor,
tristate: toggleable,
additionalConstraints: additionalConstraints
additionalConstraints: additionalConstraints,
hasFocus: hasFocus,
hovering: hovering
);
}

renderObject.activeColor = activeColor;
renderObject.inactiveColor = inactiveColor;
renderObject.focusColor = focusColor;
renderObject.hoverColor = hoverColor;
renderObject.tristate = toggleable;
renderObject.hasFocus = hasFocus;
renderObject.hovering = hovering;
}
}

Color activeColor,
Color inactiveColor,
Color focusColor,
Color hoverColor,
bool tristate,
TickerProvider vsync
TickerProvider vsync,
bool hasFocus,
bool hovering
tristate: false,
focusColor: focusColor,
hoverColor: hoverColor,
tristate: tristate,
vsync: vsync
vsync: vsync,
hasFocus: hasFocus,
hovering: hovering
) {
}

59
com.unity.uiwidgets/Runtime/material/raised_button.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

Key key = null,
VoidCallback onPressed = null,
VoidCallback onLongPress = null,
ValueChanged<bool> onHighlightChanged = null,
ButtonTextTheme? textTheme = null,
Color textColor = null,

Color focusColor = null,
Color hoverColor = null,
float? focusElevation = null,
float? hoverElevation = null,
VisualDensity visualDensity = null,
FocusNode focusNode = null,
bool autofocus = false,
MaterialTapTargetSize? materialTapTargetSize = null,
TimeSpan? animationDuration = null,
Widget child = null

onLongPress: onLongPress,
onHighlightChanged: onHighlightChanged,
textTheme: textTheme,
textColor: textColor,

focusColor: focusColor,
hoverColor: hoverColor,
focusElevation: focusElevation,
hoverElevation: hoverElevation,
visualDensity: visualDensity,
focusNode: focusNode,
autofocus: autofocus,
D.assert(focusElevation == null || focusElevation >= 0.0);
D.assert(hoverElevation == null || hoverElevation >= 0.0);
D.assert(clipBehavior != null);
VoidCallback onLongPress = null,
ValueChanged<bool> onHighlightChanged = null,
ButtonTextTheme? textTheme = null,
Color textColor = null,

Color focusColor = null,
Color hoverColor = null,
Color highlightColor = null,
Color splashColor = null,
Brightness? colorBrightness = null,

EdgeInsets padding = null,
FocusNode focusNode = null,
bool autofocus = false,
EdgeInsets padding = null,
MaterialTapTargetSize? materialTapTargetSize = null,
TimeSpan? animationDuration = null,
Widget icon = null,

return new _RaisedButtonWithIcon(
key: key,
onPressed: onPressed,
onLongPress: onLongPress,
onHighlightChanged: onHighlightChanged,
textTheme: textTheme,
textColor: textColor,

focusColor: focusColor,
hoverColor: hoverColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorBrightness: colorBrightness,

padding: padding,
shape: shape,
clipBehavior: clipBehavior,
focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
animationDuration: animationDuration,
icon: icon,

return new RawMaterialButton(
onPressed: onPressed,
onLongPress: () => onLongPress(),
clipBehavior: clipBehavior ?? Clip.none,
clipBehavior: clipBehavior.Value,
focusColor: buttonTheme.getFocusColor(this),
hoverColor: buttonTheme.getHoverColor(this),
focusElevation: buttonTheme.getFocusElevation(this),
hoverElevation: buttonTheme.getHoverElevation(this),
visualDensity: visualDensity ?? theme.visualDensity,
focusNode: focusNode,
autofocus: autofocus.Value,
animationDuration: buttonTheme.getAnimationDuration(this),
materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this),
child: child

properties.add(new DiagnosticsProperty<Brightness?>("colorBrightness", colorBrightness,
defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("elevation", elevation, defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("focusElevation", focusElevation, defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("hoverElevation", hoverElevation, defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("highlightElevation", highlightElevation,
defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("disabledElevation", disabledElevation,

public _RaisedButtonWithIcon(
Key key = null,
VoidCallback onPressed = null,
VoidCallback onLongPress = null,
ValueChanged<bool> onHighlightChanged = null,
ButtonTextTheme? textTheme = null,
Color textColor = null,

Color focusColor = null,
Color hoverColor = null,
Color highlightColor = null,
Color splashColor = null,
Brightness? colorBrightness = null,

EdgeInsets padding = null,
FocusNode focusNode = null,
bool autofocus = false,
EdgeInsets padding = null,
MaterialTapTargetSize? materialTapTargetSize = null,
TimeSpan? animationDuration = null,
Widget icon = null,

onPressed: onPressed,
onLongPress: onLongPress,
onHighlightChanged: onHighlightChanged,
textTheme: textTheme,
textColor: textColor,

focusColor: focusColor,
hoverColor: hoverColor,
highlightColor: highlightColor,
splashColor: splashColor,
colorBrightness: colorBrightness,

padding: padding,
focusNode: focusNode,
autofocus: autofocus,
padding: padding,
materialTapTargetSize: materialTapTargetSize,
animationDuration: animationDuration,
child: new Row(

D.assert(disabledElevation == null || disabledElevation >= 0.0);
D.assert(icon != null);
D.assert(label != null);
D.assert(clipBehavior != null);
}
}
}

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

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


using Rect = Unity.UIWidgets.ui.Rect;
namespace Unity.UIWidgets.material {
public enum _SliderType {
material,
adaptive
}
public class Slider : StatefulWidget {
public Slider(
Key key = null,

int? divisions = null,
string label = null,
Color activeColor = null,
Color inactiveColor = null
Color inactiveColor = null,
_SliderType _sliderType = _SliderType.material
) : base(key: key) {
D.assert(value != null);
D.assert(min <= max);

this.label = label;
this.activeColor = activeColor;
this.inactiveColor = inactiveColor;
this._sliderType = _sliderType;
}
public static Slider adaptive(
Key key = null,
float? value = null,
ValueChanged<float> onChanged = null,
ValueChanged<float> onChangeStart = null,
ValueChanged<float> onChangeEnd = null,
float min = 0.0f,
float max = 1.0f,
int? divisions = null,
string label = null,
Color activeColor = null,
Color inactiveColor = null
) {
return new Slider(
key: key,
value: value,
onChanged: onChanged,
onChangeStart: onChangeStart,
onChangeEnd: onChangeEnd,
min: min,
max: max,
divisions: divisions,
label: label,
activeColor: activeColor,
inactiveColor: inactiveColor,
_sliderType: _SliderType.adaptive
);
}
public readonly float value;

public readonly Color inactiveColor;
public readonly _SliderType _sliderType;
public override State createState() {
return new _SliderState();
}

base.debugFillProperties(properties);
properties.add(new FloatProperty("value", value));
properties.add(new ObjectFlagProperty<ValueChanged<float>>("onChanged", onChanged, ifNull: "disabled"));
properties.add(ObjectFlagProperty<ValueChanged<float>>.has("onChangeStart", onChangeStart));
properties.add(ObjectFlagProperty<ValueChanged<float>>.has("onChangeEnd", onChangeEnd));
properties.add(new IntProperty("divisions", divisions));
properties.add(new StringProperty("label", label));
properties.add(new ColorProperty("activeColor", activeColor));
properties.add(new ColorProperty("inactiveColor", inactiveColor));
}
}

? (value - widget.min) / (widget.max - widget.min)
: 0.0f;
}
const float _defaultTrackHeight = 2f;
static readonly SliderTrackShape _defaultTrackShape = new RoundedRectSliderTrackShape();
static readonly SliderTickMarkShape _defaultTickMarkShape = new RoundSliderTickMarkShape();
static readonly SliderComponentShape _defaultOverlayShape = new RoundSliderOverlayShape();
static readonly SliderComponentShape _defaultThumbShape = new RoundSliderThumbShape();
static readonly SliderComponentShape _defaultValueIndicatorShape = new PaddleSliderValueIndicatorShape();
static readonly ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;
SliderThemeData sliderTheme = SliderTheme.of(context);
switch (widget._sliderType) {
case _SliderType.material:
return _buildMaterialSlider(context);
case _SliderType.adaptive: {
ThemeData theme = Theme.of(context);
return _buildMaterialSlider(context);
}
}
D.assert(false);
return null;
}
Widget _buildMaterialSlider(BuildContext context) {
ThemeData theme = Theme.of(context);
SliderThemeData sliderTheme = SliderTheme.of(context);
sliderTheme = sliderTheme.copyWith(
trackHeight: sliderTheme.trackHeight ?? _defaultTrackHeight,
activeTrackColor: widget.activeColor ?? sliderTheme.activeTrackColor ?? theme.colorScheme.primary,
inactiveTrackColor: widget.inactiveColor ?? sliderTheme.inactiveTrackColor ?? theme.colorScheme.primary.withOpacity(0.24f),
disabledActiveTrackColor: sliderTheme.disabledActiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.32f),
disabledInactiveTrackColor: sliderTheme.disabledInactiveTrackColor ?? theme.colorScheme.onSurface.withOpacity(0.12f),
activeTickMarkColor: widget.inactiveColor ?? sliderTheme.activeTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.54f),
inactiveTickMarkColor: widget.activeColor ?? sliderTheme.inactiveTickMarkColor ?? theme.colorScheme.primary.withOpacity(0.54f),
disabledActiveTickMarkColor: sliderTheme.disabledActiveTickMarkColor ?? theme.colorScheme.onPrimary.withOpacity(0.12f),
disabledInactiveTickMarkColor: sliderTheme.disabledInactiveTickMarkColor ?? theme.colorScheme.onSurface.withOpacity(0.12f),
thumbColor: widget.activeColor ?? sliderTheme.thumbColor ?? theme.colorScheme.primary,
disabledThumbColor: sliderTheme.disabledThumbColor ?? theme.colorScheme.onSurface.withOpacity(0.38f),
overlayColor: widget.activeColor?.withOpacity(0.12f) ?? sliderTheme.overlayColor ?? theme.colorScheme.primary.withOpacity(0.12f),
valueIndicatorColor: widget.activeColor ?? sliderTheme.valueIndicatorColor ?? theme.colorScheme.primary,
trackShape: sliderTheme.trackShape ?? _defaultTrackShape,
tickMarkShape: sliderTheme.tickMarkShape ?? _defaultTickMarkShape,
thumbShape: sliderTheme.thumbShape ?? _defaultThumbShape,
overlayShape: sliderTheme.overlayShape ?? _defaultOverlayShape,
valueIndicatorShape: sliderTheme.valueIndicatorShape ?? _defaultValueIndicatorShape,
showValueIndicator: sliderTheme.showValueIndicator ?? _defaultShowValueIndicator,
valueIndicatorTextStyle: sliderTheme.valueIndicatorTextStyle ?? theme.textTheme.bodyText1.copyWith(
color: theme.colorScheme.onPrimary
)
);
if (widget.activeColor != null || widget.inactiveColor != null) {
sliderTheme = sliderTheme.copyWith(
activeTrackColor: widget.activeColor,
inactiveTrackColor: widget.inactiveColor,
activeTickMarkColor: widget.inactiveColor,
inactiveTickMarkColor: widget.activeColor,
thumbColor: widget.activeColor,
valueIndicatorColor: widget.activeColor,
overlayColor: widget.activeColor?.withAlpha(0x29)
);
}
return new _SliderRenderObjectWidget(
value: _unlerp(widget.value),
divisions: widget.divisions,
label: widget.label,
sliderTheme: sliderTheme,
mediaQueryData: MediaQuery.of(context),
onChanged: (widget.onChanged != null) && (widget.max > widget.min)
? _handleChanged
: (ValueChanged<float>) null,
onChangeStart: widget.onChangeStart != null ? _handleDragStart : (ValueChanged<float>) null,
onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : (ValueChanged<float>) null,
state: this
);
}
return new _SliderRenderObjectWidget(
value: _unlerp(widget.value),
divisions: widget.divisions,
label: widget.label,
sliderTheme: sliderTheme,
mediaQueryData: MediaQuery.of(context),
onChanged: (widget.onChanged != null) && (widget.max > widget.min) ? _handleChanged : (ValueChanged<float>)null,
onChangeStart: widget.onChangeStart != null ? _handleDragStart : (ValueChanged<float>)null,
onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : (ValueChanged<float>)null,
state: this
);
}
}
class _SliderRenderObjectWidget : LeafRenderObjectWidget {

divisions: divisions,
label: label,
sliderTheme: sliderTheme,
theme: Theme.of(context),
textDirection: Directionality.of(context),
platform: Theme.of(context).platform
);
}

_renderObject.onChanged = onChanged;
_renderObject.onChangeStart = onChangeStart;
_renderObject.onChangeEnd = onChangeEnd;
_renderObject.textDirection = Directionality.of(context);
class _RenderSlider : RenderBox {
class _RenderSlider : RelayoutWhenSystemFontsChangeMixinRenderBox {
static float _positionAnimationDurationMilliSeconds = 75;
static float _minimumInteractionTimeMilliSeconds = 500;

int? divisions = null,
string label = null,
SliderThemeData sliderTheme = null,
ThemeData theme = null,
_SliderState state = null
_SliderState state = null,
TextDirection? textDirection = null
D.assert(textDirection != null);
this.onChangeStart = onChangeStart;
this.onChangeEnd = onChangeEnd;
_platform = platform;

_sliderTheme = sliderTheme;
_theme = theme;
_textDirection = textDirection.Value;
_updateLabelPainter();
GestureArenaTeam team = new GestureArenaTeam();

float maxValue = 0;
foreach (Size size in _sliderPartSizes) {
if (size.width > maxValue) {
maxValue = size.width;
maxValue = size.height;
}
}

}
float _minPreferredTrackHeight {
get { return _sliderTheme.trackHeight; }
get { return _sliderTheme.trackHeight.Value; }
}
_SliderState _state;

public ValueChanged<float> onChangeStart;
public ValueChanged<float> onChangeEnd;
public TextDirection textDirection {
get { return _textDirection; }
set {
if (value == _textDirection) {
return;
}
_textDirection = value;
_updateLabelPainter();
}
}
TextDirection _textDirection;
public bool showValueIndicator {
get {
bool showValueIndicator = false;

get {
switch (_platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXPlayer:
case RuntimePlatform.OSXEditor:
return 0.1f;
default:
return 0.05f;

style: _sliderTheme.valueIndicatorTextStyle,
text: label
);
_labelPainter.textDirection = textDirection;
_labelPainter.textScaleFactor = _mediaQueryData.textScaleFactor;
_labelPainter.layout();
}

markNeedsLayout();
}
protected override void systemFontsDidChange() {
base.systemFontsDidChange();
_labelPainter.markNeedsLayout();
_updateLabelPainter();
}
public override void attach(object owner) {
base.attach(owner);

}
float _getValueFromVisualPosition(float visualPosition) {
switch (textDirection) {
case TextDirection.rtl:
return 1.0f - visualPosition;
case TextDirection.ltr:
return visualPosition;
}
return visualPosition;
}

void _handleDragUpdate(DragUpdateDetails details) {
if (isInteractive) {
float valueDelta = details.primaryDelta.Value / _trackRect.width;
_currentDragValue += valueDelta;
switch (textDirection) {
case TextDirection.rtl:
_currentDragValue -= valueDelta;
break;
case TextDirection.ltr:
_currentDragValue += valueDelta;
break;
}
onChanged(_discretize(_currentDragValue));
}
}

public override void paint(PaintingContext context, Offset offset) {
float value = _state.positionController.value;
float visualPosition = value;
switch (textDirection) {
case TextDirection.rtl:
visualPosition = 1.0f - value;
break;
case TextDirection.ltr:
visualPosition = value;
break;
}
Rect trackRect = _sliderTheme.trackShape.getPreferredRect(
parentBox: this,

parentBox: this,
sliderTheme: _sliderTheme,
enableAnimation: _enableAnimation,
textDirection: _textDirection,
thumbCenter: thumbCenter,
isDiscrete: isDiscrete,
isEnabled: isInteractive

labelPainter: _labelPainter,
parentBox: this,
sliderTheme: _sliderTheme,
textDirection: _textDirection,
value: _value
);
}

parentBox: this,
sliderTheme: _sliderTheme,
enableAnimation: _enableAnimation,
textDirection: _textDirection,
thumbCenter: thumbCenter,
isEnabled: isInteractive
);

labelPainter: _labelPainter,
parentBox: this,
sliderTheme: _sliderTheme,
textDirection: _textDirection,
value: _value
);
}

labelPainter: _labelPainter,
parentBox: this,
sliderTheme: _sliderTheme,
textDirection: _textDirection,
value: _value
);
}

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

297
com.unity.uiwidgets/Runtime/material/snack_bar.cs


using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.service;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
public const float _kSnackBarPadding = 24.0f;
public const float _kSingleLineVerticalPadding = 14.0f;
public static readonly Color _kSnackBackground = new Color(0xFF323232);
public const float _singleLineVerticalPadding = 14.0f;
public static readonly TimeSpan _kSnackBarTransitionDuration = new TimeSpan(0, 0, 0, 0, 250);
public static readonly TimeSpan _kSnackBarDisplayDuration = new TimeSpan(0, 0, 0, 0, 4000);
public static readonly TimeSpan _snackBarTransitionDuration = new TimeSpan(0, 0, 0, 0, 250);
public static readonly TimeSpan _snackBarDisplayDuration = new TimeSpan(0, 0, 0, 0, 4000);
public static readonly Curve _snackBarFadeCurve = new Interval(0.72f, 1.0f, curve: Curves.fastOutSlowIn);
public static readonly Curve _snackBarFadeInCurve = new Interval(0.45f, 1.0f, curve: Curves.fastOutSlowIn);
public static readonly Curve _snackBarFadeOutCurve = new Interval(0.72f, 1.0f, curve: Curves.fastOutSlowIn);
}
public enum SnackBarClosedReason {

}
public override Widget build(BuildContext context) {
SnackBarThemeData snackBarTheme = Theme.of(context).snackBarTheme;
Color textColor = widget.textColor ?? snackBarTheme.actionTextColor;
Color disabledTextColor = widget.disabledTextColor ?? snackBarTheme.disabledActionTextColor;
textColor: widget.textColor,
disabledTextColor: widget.disabledTextColor
textColor: textColor,
disabledTextColor: disabledTextColor
public class SnackBar : StatelessWidget {
public class SnackBar : StatefulWidget {
float? elevation = null,
ShapeBorder shape = null,
SnackBarBehavior? behavior = null,
Animation<float> animation = null
Animation<float> animation = null,
VoidCallback onVisible = null
duration = duration ?? SnackBarUtils._kSnackBarDisplayDuration;
duration = duration ?? SnackBarUtils._snackBarDisplayDuration;
D.assert(elevation == null || elevation >= 0.0);
this.elevation = elevation;
this.shape = shape;
this.behavior = behavior;
this.onVisible = onVisible;
}
public readonly Widget content;

public readonly float? elevation;
public readonly ShapeBorder shape;
public readonly SnackBarBehavior? behavior;
public readonly SnackBarAction action;
public readonly TimeSpan duration;

public readonly VoidCallback onVisible;
internal static AnimationController createAnimationController(TickerProvider vsync) {
return new AnimationController(
duration: SnackBarUtils._snackBarTransitionDuration,
debugLabel: "SnackBar",
vsync: vsync
);
}
internal SnackBar withAnimation(Animation<float> newAnimation, Key fallbackKey = null) {
return new SnackBar(
key: key ?? fallbackKey,
content: content,
backgroundColor: backgroundColor,
elevation: elevation,
shape: shape,
behavior: behavior,
action: action,
duration: duration,
animation: newAnimation,
onVisible: onVisible
);
}
public override State createState() {
return new _SnackBarState();
}
}
class _SnackBarState : State<SnackBar> {
bool _wasVisible = false;
public override void initState() {
base.initState();
widget.animation.addStatusListener(_onAnimationStatusChanged);
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
var _oldWidget = (SnackBar) oldWidget;
if (widget.animation != _oldWidget.animation) {
_oldWidget.animation.removeStatusListener(_onAnimationStatusChanged);
widget.animation.addStatusListener(_onAnimationStatusChanged);
}
base.didUpdateWidget(oldWidget);
}
public override void dispose() {
widget.animation.removeStatusListener(_onAnimationStatusChanged);
base.dispose();
}
void _onAnimationStatusChanged(AnimationStatus animationStatus) {
switch (animationStatus) {
case AnimationStatus.dismissed:
case AnimationStatus.forward:
case AnimationStatus.reverse:
break;
case AnimationStatus.completed:
if (widget.onVisible != null && !_wasVisible) {
widget.onVisible();
}
_wasVisible = true;
break;
}
}
D.assert(animation != null);
D.assert(widget.animation != null);
ThemeData theme = Theme.of(context);
ColorScheme colorScheme = theme.colorScheme;
SnackBarThemeData snackBarTheme = theme.snackBarTheme;
bool isThemeDark = theme.brightness == Brightness.dark;
ThemeData theme = Theme.of(context);
ThemeData darkTheme = new ThemeData(
brightness: Brightness.dark,
accentColor: theme.accentColor,
accentColorBrightness: theme.accentColorBrightness
Brightness brightness = isThemeDark ? Brightness.light : Brightness.dark;
Color themeBackgroundColor = isThemeDark
? colorScheme.onSurface
: Color.alphaBlend(colorScheme.onSurface.withOpacity(0.80f), colorScheme.surface);
ThemeData inverseTheme = new ThemeData(
brightness: brightness,
backgroundColor: themeBackgroundColor,
colorScheme: new ColorScheme(
primary: colorScheme.onPrimary,
primaryVariant: colorScheme.onPrimary,
secondary: isThemeDark ? colorScheme.primaryVariant : colorScheme.secondary,
secondaryVariant: colorScheme.onSecondary,
surface: colorScheme.onSurface,
background: themeBackgroundColor,
error: colorScheme.onError,
onPrimary: colorScheme.primary,
onSecondary: colorScheme.secondary,
onSurface: colorScheme.surface,
onBackground: colorScheme.background,
onError: colorScheme.error,
brightness: brightness
),
snackBarTheme: snackBarTheme
);
TextStyle contentTextStyle = snackBarTheme.contentTextStyle ?? inverseTheme.textTheme.subtitle1;
SnackBarBehavior snackBarBehavior = widget.behavior ?? snackBarTheme.behavior ?? SnackBarBehavior.fix;
bool isFloatingSnackBar = snackBarBehavior == SnackBarBehavior.floating;
float snackBarPadding = isFloatingSnackBar ? 16.0f : 24.0f;
CurvedAnimation heightAnimation =
new CurvedAnimation(parent: widget.animation, curve: SnackBarUtils._snackBarHeightCurve);
CurvedAnimation fadeInAnimation =
new CurvedAnimation(parent: widget.animation, curve: SnackBarUtils._snackBarFadeInCurve);
CurvedAnimation fadeOutAnimation = new CurvedAnimation(
parent: widget.animation,
curve: SnackBarUtils._snackBarFadeOutCurve,
reverseCurve: new Threshold(0.0f)
List<Widget> children = new List<Widget> {
new SizedBox(width: SnackBarUtils._kSnackBarPadding),
var childrenList = new List<Widget>() {
new SizedBox(width: snackBarPadding),
padding: EdgeInsets.symmetric(vertical: SnackBarUtils._kSingleLineVerticalPadding),
padding: EdgeInsets.symmetric(vertical: SnackBarUtils._singleLineVerticalPadding),
style: darkTheme.textTheme.subhead,
child: content)
style: contentTextStyle,
child: widget.content
)
if (action != null) {
children.Add(ButtonTheme.bar(
padding: EdgeInsets.symmetric(horizontal: SnackBarUtils._kSnackBarPadding),
if (widget.action != null) {
childrenList.Add(new ButtonTheme(
child: action
minWidth: 64.0f,
padding: EdgeInsets.symmetric(horizontal: snackBarPadding),
child: widget.action
children.Add(new SizedBox(width: SnackBarUtils._kSnackBarPadding));
childrenList.Add(new SizedBox(width: snackBarPadding));
CurvedAnimation heightAnimation =
new CurvedAnimation(parent: animation, curve: SnackBarUtils._snackBarHeightCurve);
CurvedAnimation fadeAnimation = new CurvedAnimation(parent: animation,
curve: SnackBarUtils._snackBarFadeCurve, reverseCurve: new Threshold(0.0f));
Widget snackbar = new SafeArea(
Widget snackBar = new SafeArea(
bottom: !isFloatingSnackBar,
children: children,
crossAxisAlignment: CrossAxisAlignment.center
crossAxisAlignment: CrossAxisAlignment.center,
children: childrenList
)
);
float elevation = widget.elevation ?? snackBarTheme.elevation ?? 6.0f;
Color backgroundColor =
widget.backgroundColor ?? snackBarTheme.backgroundColor ?? inverseTheme.backgroundColor;
ShapeBorder shape = widget.shape
?? snackBarTheme.shape
?? (isFloatingSnackBar
? new RoundedRectangleBorder(borderRadius: BorderRadius.circular(4.0f))
: null);
snackBar = new Material(
shape: shape,
elevation: elevation,
color: backgroundColor,
child: new Theme(
data: inverseTheme,
child: mediaQueryData.accessibleNavigation
? snackBar
: new FadeTransition(
opacity: fadeOutAnimation,
child: snackBar
)
snackbar = new Dismissible(
if (isFloatingSnackBar) {
snackBar = new Padding(
padding: EdgeInsets.fromLTRB(15.0f, 5.0f, 15.0f, 10.0f),
child: snackBar
);
}
snackBar = new Dismissible(
key: Key.key("dismissible"),
direction: DismissDirection.down,
resizeDuration: null,

child: new Material(
elevation: 6.0f,
color: backgroundColor ?? SnackBarUtils._kSnackBackground,
child: new Theme(
data: darkTheme,
child: mediaQueryData.accessibleNavigation
? snackbar
: new FadeTransition(
opacity: fadeAnimation,
child: snackbar
)
)
)
child: snackBar
return new ClipRect(
child: mediaQueryData.accessibleNavigation
? snackbar
: new AnimatedBuilder(
animation: heightAnimation,
builder: (BuildContext subContext, Widget child) => {
return new Align(
alignment: Alignment.topLeft,
heightFactor: heightAnimation.value,
child: child
);
},
child: snackbar
)
);
}
public static AnimationController createAnimationController(TickerProvider vsync) {
return new AnimationController(
duration: SnackBarUtils._kSnackBarTransitionDuration,
debugLabel: "SnackBar",
vsync: vsync
);
}
Widget snackBarTransition = null;
if (mediaQueryData.accessibleNavigation) {
snackBarTransition = snackBar;
}
else if (isFloatingSnackBar) {
snackBarTransition = new FadeTransition(
opacity: fadeInAnimation,
child: snackBar
);
}
else {
snackBarTransition = new AnimatedBuilder(
animation: heightAnimation,
builder: (BuildContext subContext, Widget subChild) => {
return new Align(
alignment: AlignmentDirectional.topStart,
heightFactor: heightAnimation.value,
child: subChild
);
},
child: snackBar
);
}
public SnackBar withAnimation(Animation<float> newAnimation, Key fallbackKey = null) {
return new SnackBar(
key: key ?? fallbackKey,
content: content,
backgroundColor: backgroundColor,
action: action,
duration: duration,
animation: newAnimation
);
return new ClipRect(child: snackBarTransition);
}
}
}

20
com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs


public class SnackBarThemeData : Diagnosticable, IEquatable<SnackBarThemeData> {
public SnackBarThemeData(
Color backgroundColor,
Color actionTextColor,
Color disabledActionTextColor,
TextStyle contentTextStyle,
float? elevation,
ShapeBorder shape,
SnackBarBehavior behavior
Color backgroundColor = null,
Color actionTextColor = null,
Color disabledActionTextColor = null,
TextStyle contentTextStyle = null,
float? elevation = null,
ShapeBorder shape = null,
SnackBarBehavior? behavior = null
) {
D.assert(elevation == null || elevation >= 0.0f);

public readonly ShapeBorder shape;
public readonly SnackBarBehavior behavior;
public readonly SnackBarBehavior? behavior;
public SnackBarThemeData copyWith(
Color backgroundColor,

);
}
static SnackBarThemeData lerp(SnackBarThemeData a, SnackBarThemeData b, float t) {
public static SnackBarThemeData lerp(SnackBarThemeData a, SnackBarThemeData b, float t) {
return new SnackBarThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
actionTextColor: Color.lerp(a?.actionTextColor, b?.actionTextColor, t),

new DiagnosticsProperty<TextStyle>("contentTextStyle", contentTextStyle, defaultValue: null));
properties.add(new FloatProperty("elevation", elevation, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null));
properties.add(new DiagnosticsProperty<SnackBarBehavior>("behavior", behavior, defaultValue: null));
properties.add(new DiagnosticsProperty<SnackBarBehavior?>("behavior", behavior, defaultValue: null));
}
public static bool operator ==(SnackBarThemeData self, SnackBarThemeData other) {

24
com.unity.uiwidgets/Runtime/material/stepper.cs


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 TextStyle = Unity.UIWidgets.painting.TextStyle;

static readonly Color _kCircleActiveLight = Colors.white;
static readonly Color _kCircleActiveDark = Colors.black87;
static readonly Color _kDisabledLight = Colors.black38;
static readonly Color _kDisabledDark = Colors.white30;
static readonly Color _kDisabledDark = Colors.white38;
static readonly float _kStepSize = 24.0f;
static readonly float _kTriangleHeight = 24.0f * 0.866025f;

case StepState.indexed:
case StepState.editing:
case StepState.complete:
return textTheme.body2;
return textTheme.bodyText1;
return textTheme.body2.copyWith(
return textTheme.bodyText1.copyWith(
return textTheme.body2.copyWith(
return textTheme.bodyText1.copyWith(
color: _isDark() ? _kErrorDark : _kErrorLight
);
}

return null;
}
Widget _buildheaderText(int index) {
Widget _buildHeaderText(int index) {
List<Widget> children = new List<Widget> {
new AnimatedDefaultTextStyle(
style: _titleStyle(index),

),
new Container(
margin: EdgeInsets.only(12.0f),
child: _buildheaderText(index)
child: _buildHeaderText(index)
)
}
)

}
}
: (GestureTapCallback) null,
canRequestFocus: widget.steps[_i].state != StepState.disabled,
child: _buildVerticalHeader(_i)
),
_buildVerticalBody(_i)

}
})
: null,
canRequestFocus: widget.steps[i].state != StepState.disabled,
child: new Row(
children: new List<Widget> {
new Container(

new Container(
margin: EdgeInsets.only(left: 12.0f),
child: _buildheaderText(_i)
child: _buildHeaderText(_i)
)
}
)

D.assert(material_.debugCheckHasMaterial(context));
D.assert(material_.debugCheckHasMaterialLocalizations(context));
D.assert(() => {
if (context.ancestorWidgetOfExactType(typeof(Stepper)) != null) {
if (context.findAncestorWidgetOfExactType<Stepper>() != null) {
"Steppers must not be nested. The material specification advises that one should avoid embedding steppers within steppers. "
"Steppers must not be nested.\n" +
" The material specification advises that one should avoid embedding " +
"steppers within steppers. " +
"https://material.io/archive/guidelines/components/steppers.html#steppers-usage"
);
}

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


using System.Collections.Generic;
using Unity.UIWidgets.scheduler2;
using Unity.UIWidgets.service;
using ImageUtils = Unity.UIWidgets.widgets.ImageUtils;
namespace Unity.UIWidgets.material {
enum _SwitchType {

Color inactiveThumbColor = null,
Color inactiveTrackColor = null,
ImageProvider activeThumbImage = null,
ImageErrorListener onActiveThumbImageError = null,
ImageErrorListener onInactiveThumbImageError = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Color focusColor = null,
Color hoverColor = null,
FocusNode focusNode = null,
bool autofocus = false
) : this(
key: key,
value: value,

inactiveThumbColor: inactiveThumbColor,
inactiveTrackColor: inactiveTrackColor,
activeThumbImage: activeThumbImage,
onActiveThumbImageError: onActiveThumbImageError,
onInactiveThumbImageError: onInactiveThumbImageError,
dragStartBehavior: dragStartBehavior
dragStartBehavior: dragStartBehavior,
focusColor: focusColor,
hoverColor: hoverColor,
focusNode: focusNode,
autofocus: autofocus
) {
}

Color inactiveThumbColor = null,
Color inactiveTrackColor = null,
ImageProvider activeThumbImage = null,
ImageErrorListener onActiveThumbImageError = null,
ImageErrorListener onInactiveThumbImageError = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Color focusColor = null,
Color hoverColor = null,
FocusNode focusNode = null,
bool autofocus = false
D.assert(activeThumbImage != null || onActiveThumbImageError == null);
D.assert(inactiveThumbImage != null || onInactiveThumbImageError == null);
this.onChanged = onChanged;
this.activeColor = activeColor;
this.activeTrackColor = activeTrackColor;

this.onActiveThumbImageError = onActiveThumbImageError;
this.onInactiveThumbImageError = onInactiveThumbImageError;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.focusNode = focusNode;
this.autofocus = autofocus;
}
public static Switch adaptive(

Color inactiveThumbColor = null,
Color inactiveTrackColor = null,
ImageProvider activeThumbImage = null,
ImageErrorListener onActiveThumbImageError = null,
ImageErrorListener onInactiveThumbImageError = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.down
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
Color focusColor = null,
Color hoverColor = null,
FocusNode focusNode = null,
bool autofocus = false
) {
return new Switch(key: key,
value: value,

inactiveThumbColor: inactiveThumbColor,
inactiveTrackColor: inactiveTrackColor,
activeThumbImage: activeThumbImage,
onActiveThumbImageError: onActiveThumbImageError,
onInactiveThumbImageError: onInactiveThumbImageError,
switchType: _SwitchType.adaptive
switchType: _SwitchType.adaptive,
dragStartBehavior: dragStartBehavior,
focusColor: focusColor,
hoverColor: hoverColor,
focusNode: focusNode,
autofocus: autofocus
);
}

public readonly ImageProvider activeThumbImage;
public readonly ImageErrorListener onActiveThumbImageError;
public readonly ImageErrorListener onInactiveThumbImageError;
public readonly MaterialTapTargetSize? materialTapTargetSize;

public readonly Color focusColor;
public readonly Color hoverColor;
public readonly FocusNode focusNode;
public readonly bool autofocus;
public override State createState() {
return new _SwitchState();

}
class _SwitchState : TickerProviderStateMixin<Switch> {
Dictionary<LocalKey, ActionFactory> _actionMap;
public override void initState() {
base.initState();
_actionMap = new Dictionary<LocalKey, ActionFactory>();
_actionMap[ActivateAction.key] = _createAction;
}
void _actionHandler(FocusNode node, Intent intent) {
if (widget.onChanged != null) {
widget.onChanged(!widget.value);
}
RenderObject renderObject = node.context.findRenderObject();
}
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; });
}
}
Size getSwitchSize(ThemeData theme) {
switch (widget.materialTapTargetSize ?? theme.materialTapTargetSize) {
case MaterialTapTargetSize.padded:

return null;
}
bool enabled {
get { return widget.onChanged != null; }
}
internal void _didFinishDragging() {
setState(() => { });
}
Widget buildMaterialSwitch(BuildContext context) {
D.assert(material_.debugCheckHasMaterial(context));
ThemeData theme = Theme.of(context);

Color activeTrackColor = widget.activeTrackColor ?? activeThumbColor.withAlpha(0x80);
Color hoverColor = widget.hoverColor ?? theme.hoverColor;
Color focusColor = widget.focusColor ?? theme.focusColor;
if (widget.onChanged != null) {
Color black32 = new Color(0x52000000); // Black with 32% opacity
if (enabled) {
Color black32 = new Color(0x52000000);
inactiveThumbColor = widget.inactiveThumbColor ??
(isDark ? Colors.grey.shade400 : Colors.grey.shade50);
inactiveTrackColor = widget.inactiveTrackColor ?? (isDark ? Colors.white30 : black32);

inactiveTrackColor = widget.inactiveTrackColor ?? (isDark ? Colors.white10 : Colors.black12);
}
return new _SwitchRenderObjectWidget(
dragStartBehavior: widget.dragStartBehavior,
value: widget.value,
activeColor: activeThumbColor,
inactiveColor: inactiveThumbColor,
activeThumbImage: widget.activeThumbImage,
inactiveThumbImage: widget.inactiveThumbImage,
activeTrackColor: activeTrackColor,
inactiveTrackColor: inactiveTrackColor,
configuration: ImageUtils.createLocalImageConfiguration(context),
onChanged: widget.onChanged,
additionalConstraints: BoxConstraints.tight(getSwitchSize(theme)),
vsync: this
return new FocusableActionDetector(
actions: _actionMap,
focusNode: widget.focusNode,
autofocus: widget.autofocus,
enabled: enabled,
onShowFocusHighlight: _handleFocusHighlightChanged,
onShowHoverHighlight: _handleHoverChanged,
child: new Builder(
builder: (BuildContext subContext) => {
return new _SwitchRenderObjectWidget(
dragStartBehavior: widget.dragStartBehavior,
value: widget.value,
activeColor: activeThumbColor,
inactiveColor: inactiveThumbColor,
hoverColor: hoverColor,
focusColor: focusColor,
activeThumbImage: widget.activeThumbImage,
onActiveThumbImageError: widget.onActiveThumbImageError,
inactiveThumbImage: widget.inactiveThumbImage,
onInactiveThumbImageError: widget.onInactiveThumbImageError,
activeTrackColor: activeTrackColor,
inactiveTrackColor: inactiveTrackColor,
configuration: ImageUtils.createLocalImageConfiguration(subContext),
onChanged: widget.onChanged,
additionalConstraints: BoxConstraints.tight(getSwitchSize(theme)),
hasFocus: _focused,
hovering: _hovering,
state: this
);
}
)
// Widget buildCupertinoSwitch(BuildContext context) {
// Size size = this.getSwitchSize(Theme.of(context));
// return new Container(
// width: size.width, // Same size as the Material switch.
// height: size.height,
// alignment: Alignment.center,
// child: CupertinoSwitch(
// value: this.widget.value,
// onChanged: this.widget.onChanged,
// activeColor: this.widget.activeColor
// )
// );
// }
// ThemeData theme = Theme.of(context);
// D.assert(theme.platform != null);
// switch (theme.platform) {
// case TargetPlatform.android:
// return buildMaterialSwitch(context);
// case TargetPlatform.iOS:
// return buildCupertinoSwitch(context);
// }
// break;
}
}

bool? value = null,
Color activeColor = null,
Color inactiveColor = null,
Color hoverColor = null,
Color focusColor = null,
ImageErrorListener onActiveThumbImageError = null,
ImageErrorListener onInactiveThumbImageError = null,
TickerProvider vsync = null,
DragStartBehavior? dragStartBehavior = null
DragStartBehavior? dragStartBehavior = null,
bool hasFocus = false,
bool hovering = false,
_SwitchState state = null
this.hoverColor = hoverColor;
this.focusColor = focusColor;
this.onActiveThumbImageError = onActiveThumbImageError;
this.onInactiveThumbImageError = onInactiveThumbImageError;
this.vsync = vsync;
this.hasFocus = hasFocus;
this.hovering = hovering;
this.state = state;
public readonly Color hoverColor;
public readonly Color focusColor;
public readonly ImageErrorListener onActiveThumbImageError;
public readonly ImageErrorListener onInactiveThumbImageError;
public readonly TickerProvider vsync;
public readonly bool hasFocus;
public readonly bool hovering;
public readonly _SwitchState state;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderSwitch(

inactiveColor: inactiveColor,
hoverColor: hoverColor,
focusColor: focusColor,
onActiveThumbImageError: onActiveThumbImageError,
onInactiveThumbImageError: onInactiveThumbImageError,
vsync: vsync
textDirection: Directionality.of(context),
hasFocus: hasFocus,
hovering: hovering,
state: state
);
}

renderObject.value = value;
renderObject.activeColor = activeColor;
renderObject.inactiveColor = inactiveColor;
renderObject.hoverColor = hoverColor;
renderObject.focusColor = focusColor;
renderObject.onActiveThumbImageError = onActiveThumbImageError;
renderObject.onInactiveThumbImageError = onInactiveThumbImageError;
renderObject.textDirection = Directionality.of(context);
renderObject.vsync = vsync;
renderObject.hasFocus = hasFocus;
renderObject.hovering = hovering;
renderObject.vsync = state;
}
}

Color activeColor = null,
Color inactiveColor = null,
Color hoverColor = null,
Color focusColor = null,
ImageErrorListener onActiveThumbImageError = null,
ImageErrorListener onInactiveThumbImageError = null,
TextDirection? textDirection = null,
TickerProvider vsync = null,
DragStartBehavior? dragStartBehavior = null
DragStartBehavior? dragStartBehavior = null,
bool hasFocus = false,
bool hovering = false,
_SwitchState state = null
hoverColor: hoverColor,
focusColor: focusColor,
vsync: vsync
hasFocus: hasFocus,
hovering: hovering,
vsync: state
D.assert(textDirection != null);
_onActiveThumbImageError = onActiveThumbImageError;
_onInactiveThumbImageError = onInactiveThumbImageError;
_activeTrackColor = activeTrackColor;
_inactiveTrackColor = inactiveTrackColor;
_configuration = configuration;

ImageProvider _activeThumbImage;
public ImageErrorListener onActiveThumbImageError {
get { return _onActiveThumbImageError; }
set {
if (value == _onActiveThumbImageError) {
return;
}
_onActiveThumbImageError = value;
markNeedsPaint();
}
}
ImageErrorListener _onActiveThumbImageError;
public ImageProvider inactiveThumbImage {
get { return _inactiveThumbImage; }
set {

}
ImageProvider _inactiveThumbImage;
public ImageErrorListener onInactiveThumbImageError {
get { return _onInactiveThumbImageError; }
set {
if (value == _onInactiveThumbImageError) {
return;
}
_onInactiveThumbImageError = value;
markNeedsPaint();
}
}
ImageErrorListener _onInactiveThumbImageError;
public Color activeTrackColor {
get { return _activeTrackColor; }

ImageConfiguration _configuration;
public TextDirection textDirection {
get { return _textDirection; }
set {
if (_textDirection == value) {
return;
}
_textDirection = value;
markNeedsPaint();
}
}
TextDirection _textDirection;
_SwitchState state;
public override bool? value {
get { return base.value; }
set {
D.assert(value != null);
base.value = value;
if (_needsPositionAnimation) {
_needsPositionAnimation = false;
position.curve = null;
position.reverseCurve = null;
if (value == true) {
positionController.forward();
}
else {
positionController.reverse();
}
}
}
}
public override void detach() {
_cachedThumbPainter?.Dispose();

}
HorizontalDragGestureRecognizer _drag;
bool _needsPositionAnimation = false;
void _handleDragStart(DragStartDetails details) {
if (isInteractive) {

}
void _handleDragEnd(DragEndDetails details) {
if (position.value >= 0.5) {
positionController.forward();
}
else {
positionController.reverse();
_needsPositionAnimation = true;
if ((position.value >= 0.5f) != value) {
onChanged(!value);
state._didFinishDragging();
}
public override void handleEvent(PointerEvent evt, HitTestEntry entry) {

Color _cachedThumbColor;
ImageProvider _cachedThumbImage;
ImageErrorListener _cachedThumbErrorListener;
BoxDecoration _createDefaultThumbDecoration(Color color, ImageProvider image) {
BoxDecoration _createDefaultThumbDecoration(Color color, ImageProvider image,
ImageErrorListener errorListener) {
image: image == null ? null : new DecorationImage(image: image),
image: image == null ? null : new DecorationImage(image: image, onError: errorListener),
shape: BoxShape.circle,
boxShadow: material_.kElevationToShadow[1]
);

? (currentValue < 0.5 ? inactiveThumbImage : activeThumbImage)
: inactiveThumbImage;
ImageErrorListener thumbErrorListener = isEnabled
? (currentValue < 0.5f ? onInactiveThumbImageError : onActiveThumbImageError)
: onInactiveThumbImageError;
// Paint the track
Paint paint = new Paint {color = trackColor};
float trackHorizontalPadding = material_.kRadialReactionRadius - Switch._kTrackRadius;

_isPainting = true;
BoxPainter thumbPainter;
if (_cachedThumbPainter == null || thumbColor != _cachedThumbColor ||
thumbImage != _cachedThumbImage) {
thumbImage != _cachedThumbImage || thumbErrorListener != _cachedThumbErrorListener) {
_cachedThumbPainter = _createDefaultThumbDecoration(thumbColor, thumbImage)
_cachedThumbErrorListener = thumbErrorListener;
_cachedThumbPainter = _createDefaultThumbDecoration(thumbColor, thumbImage, thumbErrorListener)
.createBoxPainter(_handleDecorationChanged);
}

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


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {

static readonly ThemeData _kFallbackTheme = ThemeData.fallback();
public static ThemeData of(BuildContext context, bool shadowThemeOnly = false) {
_InheritedTheme inheritedTheme =
(_InheritedTheme) context.inheritFromWidgetOfExactType(typeof(_InheritedTheme));
_InheritedTheme inheritedTheme = context.dependOnInheritedWidgetOfExactType<_InheritedTheme>();
if (shadowThemeOnly) {
if (inheritedTheme == null || inheritedTheme.theme.isMaterialAppTheme) {
return null;

}
class _InheritedTheme : InheritedWidget {
class _InheritedTheme : InheritedTheme {
public _InheritedTheme(
Key key = null,
Theme theme = null,

public readonly Theme theme;
public override Widget wrap(BuildContext context, Widget child) {
_InheritedTheme ancestorTheme = context.findAncestorWidgetOfExactType<_InheritedTheme>();
return ReferenceEquals(this, ancestorTheme) ? child : new Theme(data: theme.data, child: child);
}
public override bool updateShouldNotify(InheritedWidget old) {
return theme.data != ((_InheritedTheme) old).theme.data;
}

bool isMaterialAppTheme = false,
Curve curve = null,
TimeSpan? duration = null,
VoidCallback onEnd = null,
) : base(key: key, curve: curve ?? Curves.linear, duration: duration ?? ThemeUtils.kThemeAnimationDuration) {
) : base(key: key, curve: curve ?? Curves.linear, duration: duration ?? ThemeUtils.kThemeAnimationDuration, onEnd: onEnd) {
D.assert(child != null);
D.assert(data != null);
this.data = data;

27
com.unity.uiwidgets/Runtime/material/theme_data.cs


ColorScheme colorScheme = null,
DialogTheme dialogTheme = null,
FloatingActionButtonThemeData floatingActionButtonTheme = null,
Typography typography = null
Typography typography = null,
SnackBarThemeData snackBarTheme = null
) {
brightness = brightness ?? Brightness.light;
bool isDark = brightness == Brightness.dark;

);
dialogTheme = dialogTheme ?? new DialogTheme();
floatingActionButtonTheme = floatingActionButtonTheme ?? new FloatingActionButtonThemeData();
snackBarTheme = snackBarTheme ?? new SnackBarThemeData();
D.assert(brightness != null);
D.assert(primaryColor != null);

D.assert(chipTheme != null);
D.assert(dialogTheme != null);
D.assert(floatingActionButtonTheme != null);
D.assert(snackBarTheme != null);
this.brightness = brightness ?? Brightness.light;
this.primaryColor = primaryColor;

this.dialogTheme = dialogTheme;
this.floatingActionButtonTheme = floatingActionButtonTheme;
this.typography = typography;
this.snackBarTheme = snackBarTheme;
}
public static ThemeData raw(

ColorScheme colorScheme = null,
DialogTheme dialogTheme = null,
FloatingActionButtonThemeData floatingActionButtonTheme = null,
Typography typography = null
Typography typography = null,
SnackBarThemeData snackBarTheme = null
) {
D.assert(brightness != null);
D.assert(primaryColor != null);

D.assert(chipTheme != null);
D.assert(dialogTheme != null);
D.assert(floatingActionButtonTheme != null);
D.assert(snackBarTheme != null);
return new ThemeData(
brightness: brightness,

colorScheme: colorScheme,
dialogTheme: dialogTheme,
floatingActionButtonTheme: floatingActionButtonTheme,
typography: typography);
typography: typography,
snackBarTheme: snackBarTheme);
}
public static ThemeData light() {

ColorScheme colorScheme = null,
DialogTheme dialogTheme = null,
FloatingActionButtonThemeData floatingActionButtonTheme = null,
Typography typography = null
Typography typography = null,
SnackBarThemeData snackBarTheme = null
) {
return raw(
brightness: brightness ?? this.brightness,

colorScheme: colorScheme ?? this.colorScheme,
dialogTheme: dialogTheme ?? this.dialogTheme,
floatingActionButtonTheme: floatingActionButtonTheme ?? this.floatingActionButtonTheme,
typography: typography ?? this.typography
typography: typography ?? this.typography,
snackBarTheme: snackBarTheme ?? this.snackBarTheme
);
}

dialogTheme: DialogTheme.lerp(a.dialogTheme, b.dialogTheme, t),
floatingActionButtonTheme: FloatingActionButtonThemeData.lerp(a.floatingActionButtonTheme,
b.floatingActionButtonTheme, t),
typography: Typography.lerp(a.typography, b.typography, t)
typography: Typography.lerp(a.typography, b.typography, t),
snackBarTheme: SnackBarThemeData.lerp(a.snackBarTheme, b.snackBarTheme, t)
);
}

other.colorScheme == colorScheme &&
other.dialogTheme == dialogTheme &&
other.floatingActionButtonTheme == floatingActionButtonTheme &&
other.typography == typography;
other.typography == typography &&
other.snackBarTheme == snackBarTheme;
}
public override bool Equals(object obj) {

hashCode = (hashCode * 397) ^ dialogTheme.GetHashCode();
hashCode = (hashCode * 397) ^ floatingActionButtonTheme.GetHashCode();
hashCode = (hashCode * 397) ^ typography.GetHashCode();
hashCode = (hashCode * 397) ^ snackBarTheme.GetHashCode();
_cachedHashCode = hashCode;
return hashCode;

floatingActionButtonTheme, defaultValue: defaultData.floatingActionButtonTheme));
properties.add(new DiagnosticsProperty<Typography>("typography", typography,
defaultValue: defaultData.typography));
properties.add(new DiagnosticsProperty<SnackBarThemeData>("snackBarTheme", snackBarTheme, defaultValue: defaultData.snackBarTheme, level: DiagnosticLevel.debug));
}
}

3
com.unity.uiwidgets/Runtime/rendering/editable.cs


markNeedsLayout();
}
public void systemFontsDidChange() {
protected override void systemFontsDidChange() {
base.systemFontsDidChange();
_textPainter.markNeedsLayout();
_textLayoutLastMaxWidth = null;
_textLayoutLastMinWidth = null;

2
com.unity.uiwidgets/Runtime/rendering/object.mixin.gen.cs


public abstract class RelayoutWhenSystemFontsChangeMixinRenderBox : RenderBox {
protected void systemFontsDidChange() {
protected virtual void systemFontsDidChange() {
markNeedsLayout();
}

2
com.unity.uiwidgets/Runtime/rendering/object.mixin.njk


{% macro RelayoutWhenSystemFontsChangeMixin(with) %}
public abstract class RelayoutWhenSystemFontsChangeMixin{{with}} : {{with}} {
protected void systemFontsDidChange() {
protected virtual void systemFontsDidChange() {
markNeedsLayout();
}

360
com.unity.uiwidgets/Runtime/widgets/draggable_scrollable_sheet.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.physics;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
// TODO: complete this file
public delegate Widget ScrollableWidgetBuilder(
BuildContext context,
ScrollController scrollController
);
public class DraggableScrollableSheet : StatefulWidget {
public DraggableScrollableSheet(
Key key = null,
float initialChildSize = 0.5f,
float minChildSize = 0.25f,
bool expand = true,
ScrollableWidgetBuilder builder = null
) : base(key: key) {
D.assert(builder != null);
this.initialChildSize = initialChildSize;
this.minChildSize = minChildSize;
this.expand = expand;
this.builder = builder;
}
public readonly float initialChildSize;
public readonly float minChildSize;
public readonly float maxChildSize;
public readonly bool expand;
public readonly ScrollableWidgetBuilder builder;
public override State createState() {
return new _DraggableScrollableSheetState();
}
}
public class DraggableScrollableNotification : ViewportNotificationMixinNotification {
public DraggableScrollableNotification(
float extent,

D.assert(extent <= maxExtent);
D.assert(initialExtent <= maxExtent);
D.assert(context != null);
this.extent = extent;
this.minExtent = minExtent;
this.maxExtent = maxExtent;
this.initialExtent = initialExtent;
this.context = context;
}
public readonly float extent;

public readonly BuildContext context;
protected override void debugFillDescription(List<String> description) {
protected override void debugFillDescription(List<string> description) {
}
}
class _DraggableSheetExtent {
public _DraggableSheetExtent(
float minExtent,
float maxExtent,
float initialExtent,
VoidCallback listener
) {
D.assert(minExtent >= 0);
D.assert(maxExtent <= 1);
D.assert(minExtent <= initialExtent);
D.assert(initialExtent <= maxExtent);
this.minExtent = minExtent;
this.maxExtent = maxExtent;
this.initialExtent = initialExtent;
_currentExtent = new ValueNotifier<float>(initialExtent);
_currentExtent.addListener(listener);
availablePixels = float.PositiveInfinity;
}
float minExtent;
float maxExtent;
internal float initialExtent;
internal ValueNotifier<float> _currentExtent;
internal float availablePixels;
public bool isAtMin {
get { return minExtent >= _currentExtent.value; }
}
public bool isAtMax {
get { return maxExtent <= _currentExtent.value; }
}
public float currentExtent {
get { return _currentExtent.value; }
set { _currentExtent.value = value.clamp(minExtent, maxExtent); }
}
public float additionalMinExtent {
get { return isAtMin ? 0.0f : 1.0f; }
}
public float additionalMaxExtent {
get { return isAtMax ? 0.0f : 1.0f; }
}
public void addPixelDelta(float delta, BuildContext context) {
if (availablePixels == 0) {
return;
}
currentExtent += delta / availablePixels * maxExtent;
new DraggableScrollableNotification(
minExtent: minExtent,
maxExtent: maxExtent,
extent: currentExtent,
initialExtent: initialExtent,
context: context
).dispatch(context);
}
}
class _DraggableScrollableSheetState : State<DraggableScrollableSheet> {
_DraggableScrollableSheetScrollController _scrollController;
_DraggableSheetExtent _extent;
public override void initState() {
base.initState();
_extent = new _DraggableSheetExtent(
minExtent: widget.minChildSize,
maxExtent: widget.maxChildSize,
initialExtent: widget.initialChildSize,
listener: _setExtent
);
_scrollController = new _DraggableScrollableSheetScrollController(extent: _extent);
}
public override void didChangeDependencies() {
base.didChangeDependencies();
if (_InheritedResetNotifier.shouldReset(context)) {
if (_scrollController.offset != 0.0f) {
_scrollController.animateTo(
0.0f,
duration: new TimeSpan(0, 0, 0, 0, 1),
curve: Curves.linear
);
}
_extent._currentExtent.value = _extent.initialExtent;
}
}
void _setExtent() {
setState(() => { });
}
public override Widget build(BuildContext context) {
return new LayoutBuilder(
builder: (BuildContext subContext, BoxConstraints subConstraints) => {
_extent.availablePixels = widget.maxChildSize * subConstraints.biggest.height;
Widget sheet = new FractionallySizedBox(
heightFactor: _extent.currentExtent,
child: widget.builder(subContext, _scrollController),
alignment: Alignment.bottomCenter
);
return widget.expand ? SizedBox.expand(child: sheet) : sheet;
}
);
}
public override void dispose() {
_scrollController.dispose();
base.dispose();
}
}
class _DraggableScrollableSheetScrollController : ScrollController {
public _DraggableScrollableSheetScrollController(
float initialScrollOffset = 0.0f,
string debugLabel = null,
_DraggableSheetExtent extent = null
) : base(debugLabel: debugLabel, initialScrollOffset: initialScrollOffset) {
D.assert(extent != null);
this.extent = extent;
}
public readonly _DraggableSheetExtent extent;
public override ScrollPosition createScrollPosition(
ScrollPhysics physics,
ScrollContext context,
ScrollPosition oldPosition
) {
return new _DraggableScrollableSheetScrollPosition(
physics: physics,
context: context,
oldPosition: oldPosition,
extent: extent
);
}
protected override void debugFillDescription(List<string> description) {
base.debugFillDescription(description);
description.Add($"extent: {extent}");
}
}
class _DraggableScrollableSheetScrollPosition : ScrollPositionWithSingleContext {
public _DraggableScrollableSheetScrollPosition(
ScrollPhysics physics = null,
ScrollContext context = null,
float initialPixels = 0.0f,
bool keepScrollOffset = true,
ScrollPosition oldPosition = null,
string debugLabel = null,
_DraggableSheetExtent extent = null
) : base(physics: physics,
context: context,
initialPixels: initialPixels,
keepScrollOffset: keepScrollOffset,
oldPosition: oldPosition,
debugLabel: debugLabel) {
D.assert(extent != null);
this.extent = extent;
}
VoidCallback _dragCancelCallback;
public readonly _DraggableSheetExtent extent;
bool listShouldScroll {
get { return pixels > 0.0f; }
}
public override bool applyContentDimensions(float minScrollExtent, float maxScrollExtent) {
return base.applyContentDimensions(
minScrollExtent - extent.additionalMinExtent,
maxScrollExtent + extent.additionalMaxExtent
);
}
public override void applyUserOffset(float delta) {
if (!listShouldScroll &&
(!(extent.isAtMin || extent.isAtMax) ||
(extent.isAtMin && delta < 0) ||
(extent.isAtMax && delta > 0))) {
extent.addPixelDelta(-delta, context.notificationContext);
}
else {
base.applyUserOffset(delta);
}
}
public override void goBallistic(float velocity) {
if (velocity == 0.0f ||
(velocity < 0.0f && listShouldScroll) ||
(velocity > 0.0f && extent.isAtMax)) {
base.goBallistic(velocity);
return;
}
_dragCancelCallback?.Invoke();
_dragCancelCallback = null;
Simulation simulation = new ClampingScrollSimulation(
position: extent.currentExtent,
velocity: velocity,
tolerance: physics.tolerance
);
AnimationController ballisticController = AnimationController.unbounded(
debugLabel: $"{GetType()}",
vsync: context.vsync
);
float lastDelta = 0;
void _tick() {
float delta = ballisticController.value - lastDelta;
lastDelta = ballisticController.value;
extent.addPixelDelta(delta, context.notificationContext);
if ((velocity > 0 && extent.isAtMax) || (velocity < 0 && extent.isAtMin)) {
velocity = ballisticController.velocity +
(physics.tolerance.velocity * ballisticController.velocity.sign());
base.goBallistic(velocity);
ballisticController.stop();
}
else if (ballisticController.isCompleted) {
base.goBallistic(0);
}
}
ballisticController.addListener(_tick);
ballisticController.animateWith(simulation).whenCompleteOrCancel(
ballisticController.dispose
);
}
public override Drag drag(DragStartDetails details, VoidCallback dragCancelCallback) {
_dragCancelCallback = dragCancelCallback;
return base.drag(details, dragCancelCallback);
}
}
public class DraggableScrollableActuator : StatelessWidget {
public DraggableScrollableActuator(
Key key = null,
Widget child = null
) : base(key: key) {
D.assert(child != null);
this.child = child;
}
public readonly Widget child;
readonly _ResetNotifier _notifier = new _ResetNotifier();
public static bool reset(BuildContext context) {
_InheritedResetNotifier notifier = context.dependOnInheritedWidgetOfExactType<_InheritedResetNotifier>();
if (notifier == null) {
return false;
}
return notifier._sendReset();
}
public override Widget build(BuildContext context) {
return new _InheritedResetNotifier(child: child, notifier: _notifier);
}
}
class _ResetNotifier : ChangeNotifier {
internal bool _wasCalled = false;
internal bool sendReset() {
if (!hasListeners) {
return false;
}
_wasCalled = true;
notifyListeners();
return true;
}
}
class _InheritedResetNotifier : InheritedNotifier<_ResetNotifier> {
public _InheritedResetNotifier(
Key key = null,
Widget child = null,
_ResetNotifier notifier = null
) : base(key: key, child: child, notifier: notifier) {
}
internal bool _sendReset() {
return notifier.sendReset();
}
public static bool shouldReset(BuildContext context) {
InheritedWidget widget = context.dependOnInheritedWidgetOfExactType<_InheritedResetNotifier>();
if (widget == null) {
return false;
}
_InheritedResetNotifier inheritedNotifier = widget as _InheritedResetNotifier;
bool wasCalled = inheritedNotifier.notifier._wasCalled;
inheritedNotifier.notifier._wasCalled = false;
return wasCalled;
}
}
}

2
com.unity.uiwidgets/Runtime/widgets/scroll_position_with_single_context.cs


beginActivity(new IdleScrollActivity(this));
}
public void goBallistic(float velocity) {
public virtual void goBallistic(float velocity) {
D.assert(_pixels != null);
Simulation simulation = physics.createBallisticSimulation(this, velocity);
if (simulation != null) {

117
com.unity.uiwidgets/Runtime/material/ratio_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 RadioListTile<T> : StatelessWidget where T : class {
public RadioListTile(
Key key = null,
T value = default,
T groupValue = default,
ValueChanged<T> onChanged = null,
bool toggleable = false,
Color activeColor = 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(!isThreeLine || subtitle != null);
this.value = value;
this.groupValue = groupValue;
this.onChanged = onChanged;
this.toggleable = toggleable;
this.activeColor = activeColor;
this.title = title;
this.subtitle = subtitle;
this.isThreeLine = isThreeLine;
this.dense = dense;
this.secondary = secondary;
this.selected = selected;
this.controlAffinity = controlAffinity;
}
public readonly T value;
public readonly T groupValue;
public readonly ValueChanged<T> onChanged;
public readonly bool toggleable;
public readonly Color activeColor;
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;
bool isChecked {
get { return value.Equals(groupValue); }
}
public override Widget build(BuildContext context) {
Widget control = new Radio<T>(
value: value,
groupValue: groupValue,
onChanged: onChanged,
toggleable: toggleable,
activeColor: activeColor,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap
);
Widget leading = null;
Widget trailing = null;
switch (controlAffinity) {
case ListTileControlAffinity.leading:
case ListTileControlAffinity.platform:
leading = control;
trailing = secondary;
break;
case ListTileControlAffinity.trailing:
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
? () => {
if (toggleable && isChecked) {
onChanged(null);
return;
}
if (!isChecked) {
onChanged(value);
}
}
: (GestureTapCallback) null,
selected: selected
)
);
}
}
}

187
com.unity.uiwidgets/Runtime/material/swtich_list_tile.cs


using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public enum _SwitchListTileType {
material,
adaptive
}
public class SwitchListTile : StatelessWidget {
public SwitchListTile(
Key key = null,
bool? value = null,
ValueChanged<bool?> onChanged = null,
Color activeColor = null,
Color activeTrackColor = null,
Color inactiveThumbColor = null,
Color inactiveTrackColor = null,
ImageProvider activeThumbImage = null,
ImageProvider inactiveThumbImage = null,
Widget title = null,
Widget subtitle = null,
bool isThreeLine = false,
bool? dense = null,
EdgeInsets contentPadding = null,
Widget secondary = null,
bool selected = false,
_SwitchListTileType _switchListTileType = _SwitchListTileType.material
) : base(key: key) {
D.assert(value != null);
D.assert(!isThreeLine || subtitle != null);
this.value = value.Value;
this.onChanged = onChanged;
this.activeColor = activeColor;
this.activeTrackColor = activeTrackColor;
this.inactiveThumbColor = inactiveThumbColor;
this.inactiveTrackColor = inactiveTrackColor;
this.activeThumbImage = activeThumbImage;
this.inactiveThumbImage = inactiveThumbImage;
this.title = title;
this.subtitle = subtitle;
this.isThreeLine = isThreeLine;
this.dense = dense;
this.contentPadding = contentPadding;
this.secondary = secondary;
this.selected = selected;
this._switchListTileType = _switchListTileType;
}
public static SwitchListTile adaptive(
Key key = null,
bool? value = null,
ValueChanged<bool?> onChanged = null,
Color activeColor = null,
Color activeTrackColor = null,
Color inactiveThumbColor = null,
Color inactiveTrackColor = null,
ImageProvider activeThumbImage = null,
ImageProvider inactiveThumbImage = null,
Widget title = null,
Widget subtitle = null,
bool isThreeLine = false,
bool? dense = null,
EdgeInsets contentPadding = null,
Widget secondary = null,
bool selected = false) {
return new SwitchListTile(
key: key,
value: value,
onChanged: onChanged,
activeColor: activeColor,
activeTrackColor: activeTrackColor,
inactiveThumbColor: inactiveThumbColor,
inactiveTrackColor: inactiveTrackColor,
activeThumbImage: activeThumbImage,
inactiveThumbImage: inactiveThumbImage,
title: title,
subtitle: subtitle,
isThreeLine: isThreeLine,
dense: dense,
contentPadding: contentPadding,
secondary: secondary,
selected: selected,
_switchListTileType: _SwitchListTileType.adaptive
);
}
public readonly bool value;
public readonly ValueChanged<bool?> onChanged;
public readonly Color activeColor;
public readonly Color activeTrackColor;
public readonly Color inactiveThumbColor;
public readonly Color inactiveTrackColor;
public readonly ImageProvider activeThumbImage;
public readonly ImageProvider inactiveThumbImage;
public readonly Widget title;
public readonly Widget subtitle;
public readonly Widget secondary;
public readonly bool isThreeLine;
public readonly bool? dense;
public readonly EdgeInsets contentPadding;
public readonly bool selected;
public readonly _SwitchListTileType _switchListTileType;
public override Widget build(BuildContext context) {
Widget control = null;
switch (_switchListTileType) {
case _SwitchListTileType.adaptive:
control = Switch.adaptive(
value: value,
onChanged: onChanged,
activeColor: activeColor,
activeThumbImage: activeThumbImage,
inactiveThumbImage: inactiveThumbImage,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
activeTrackColor: activeTrackColor,
inactiveTrackColor: inactiveTrackColor,
inactiveThumbColor: inactiveThumbColor
);
break;
case _SwitchListTileType.material:
control = new Switch(
value: value,
onChanged: onChanged,
activeColor: activeColor,
activeThumbImage: activeThumbImage,
inactiveThumbImage: inactiveThumbImage,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
activeTrackColor: activeTrackColor,
inactiveTrackColor: inactiveTrackColor,
inactiveThumbColor: inactiveThumbColor
);
break;
}
return ListTileTheme.merge(
selectedColor: activeColor ?? Theme.of(context).accentColor,
child: new ListTile(
leading: secondary,
title: title,
subtitle: subtitle,
trailing: control,
isThreeLine: isThreeLine,
dense: dense,
contentPadding: contentPadding,
enabled: onChanged != null,
onTap: onChanged != null ? () => { onChanged(!value); } : (GestureTapCallback) null,
selected: selected
)
);
}
}
}
正在加载...
取消
保存