浏览代码

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

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
0c86e6e7
共有 72 个文件被更改,包括 11823 次插入1386 次删除
  1. 3
      com.unity.uiwidgets/Runtime/animation/tween_sequence.cs
  2. 2
      com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs
  3. 36
      com.unity.uiwidgets/Runtime/material/bottom_sheet.cs
  4. 2
      com.unity.uiwidgets/Runtime/material/data_table.cs
  5. 2
      com.unity.uiwidgets/Runtime/material/drawer_header.cs
  6. 695
      com.unity.uiwidgets/Runtime/material/dropdown.cs
  7. 3
      com.unity.uiwidgets/Runtime/material/elevation_overlay.cs
  8. 44
      com.unity.uiwidgets/Runtime/material/expand_icon.cs
  9. 104
      com.unity.uiwidgets/Runtime/material/expansion_panel.cs
  10. 7
      com.unity.uiwidgets/Runtime/material/expansion_tile.cs
  11. 22
      com.unity.uiwidgets/Runtime/material/feedback.cs
  12. 69
      com.unity.uiwidgets/Runtime/material/flat_button.cs
  13. 215
      com.unity.uiwidgets/Runtime/material/flexible_space_bar.cs
  14. 179
      com.unity.uiwidgets/Runtime/material/floating_action_button.cs
  15. 35
      com.unity.uiwidgets/Runtime/material/floating_action_button_location.cs
  16. 114
      com.unity.uiwidgets/Runtime/material/floatting_action_button_theme.cs
  17. 74
      com.unity.uiwidgets/Runtime/material/icon_button.cs
  18. 61
      com.unity.uiwidgets/Runtime/material/input_border.cs
  19. 36
      com.unity.uiwidgets/Runtime/material/list_tile.cs
  20. 46
      com.unity.uiwidgets/Runtime/material/material.cs
  21. 2
      com.unity.uiwidgets/Runtime/material/material_state.cs
  22. 40
      com.unity.uiwidgets/Runtime/material/mergeable_material.cs
  23. 160
      com.unity.uiwidgets/Runtime/material/outline_button.cs
  24. 4
      com.unity.uiwidgets/Runtime/material/page.cs
  25. 224
      com.unity.uiwidgets/Runtime/material/page_transitions_theme.cs
  26. 385
      com.unity.uiwidgets/Runtime/material/popup_menu.cs
  27. 2
      com.unity.uiwidgets/Runtime/material/popup_menu_theme.cs
  28. 155
      com.unity.uiwidgets/Runtime/material/radio.cs
  29. 59
      com.unity.uiwidgets/Runtime/material/raised_button.cs
  30. 94
      com.unity.uiwidgets/Runtime/material/refresh_indicator.cs
  31. 34
      com.unity.uiwidgets/Runtime/material/reorderable_list.cs
  32. 710
      com.unity.uiwidgets/Runtime/material/scaffold.cs
  33. 110
      com.unity.uiwidgets/Runtime/material/scrollbar.cs
  34. 70
      com.unity.uiwidgets/Runtime/material/search.cs
  35. 203
      com.unity.uiwidgets/Runtime/material/slider.cs
  36. 846
      com.unity.uiwidgets/Runtime/material/slider_theme.cs
  37. 297
      com.unity.uiwidgets/Runtime/material/snack_bar.cs
  38. 20
      com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs
  39. 24
      com.unity.uiwidgets/Runtime/material/stepper.cs
  40. 341
      com.unity.uiwidgets/Runtime/material/switch.cs
  41. 14
      com.unity.uiwidgets/Runtime/material/theme.cs
  42. 27
      com.unity.uiwidgets/Runtime/material/theme_data.cs
  43. 3
      com.unity.uiwidgets/Runtime/rendering/box.cs
  44. 360
      com.unity.uiwidgets/Runtime/widgets/draggable_scrollable_sheet.cs
  45. 24
      com.unity.uiwidgets/Runtime/widgets/editable_text.cs
  46. 2
      com.unity.uiwidgets/Runtime/widgets/media_query.cs
  47. 2
      com.unity.uiwidgets/Runtime/widgets/scroll_position_with_single_context.cs
  48. 1001
      com.unity.uiwidgets/Runtime/material/animated_icons/data/ellipsis_search.g.cs
  49. 3
      com.unity.uiwidgets/Runtime/material/animated_icons/data/ellipsis_search.g.cs.meta
  50. 1001
      com.unity.uiwidgets/Runtime/material/animated_icons/data/event_add.g.cs
  51. 3
      com.unity.uiwidgets/Runtime/material/animated_icons/data/event_add.g.cs.meta
  52. 118
      com.unity.uiwidgets/Runtime/material/grid_tile_bar.cs
  53. 3
      com.unity.uiwidgets/Runtime/material/grid_tile_bar.cs.meta
  54. 390
      com.unity.uiwidgets/Runtime/material/paginated_data_table.cs
  55. 1001
      com.unity.uiwidgets/Runtime/material/range_slider.cs
  56. 117
      com.unity.uiwidgets/Runtime/material/ratio_list_tile.cs
  57. 572
      com.unity.uiwidgets/Runtime/material/selectable_text.cs
  58. 187
      com.unity.uiwidgets/Runtime/material/swtich_list_tile.cs
  59. 1001
      com.unity.uiwidgets/Runtime/material/time_picker.cs
  60. 160
      com.unity.uiwidgets/Runtime/material/pickers/date_picker_head.cs
  61. 416
      com.unity.uiwidgets/Runtime/material/pickers/date_picker_dialog.cs
  62. 11
      com.unity.uiwidgets/Runtime/material/pickers/date_picker_dialog.cs.meta
  63. 238
      com.unity.uiwidgets/Runtime/material/pickers/input_date_picker.cs
  64. 11
      com.unity.uiwidgets/Runtime/material/pickers/input_date_picker.cs.meta
  65. 928
      com.unity.uiwidgets/Runtime/material/pickers/calendar_date_picker.cs
  66. 3
      com.unity.uiwidgets/Runtime/material/pickers/calendar_date_picker.cs.meta
  67. 3
      com.unity.uiwidgets/Runtime/material/pickers/date_picker_common.cs.meta
  68. 58
      com.unity.uiwidgets/Runtime/material/pickers/date_utils.cs
  69. 3
      com.unity.uiwidgets/Runtime/material/pickers/date_utils.cs.meta
  70. 20
      com.unity.uiwidgets/Runtime/material/pickers/date_picker_common.cs
  71. 0
      /com.unity.uiwidgets/Runtime/material/time.cs

3
com.unity.uiwidgets/Runtime/animation/tween_sequence.cs


}
class FlippedTweenSequence : TweenSequence<float> {
FlippedTweenSequence(List<TweenSequenceItem<float>> items)
public FlippedTweenSequence(List<TweenSequenceItem<float>> items)
: base(items) {
D.assert(items != null);
}

2
com.unity.uiwidgets/Runtime/cupertino/action_Sheet.cs


);
}
Orientation orientation = MediaQuery.of(context).orientation;
Orientation? orientation = MediaQuery.of(context).orientation;
float actionSheetWidth;
if (orientation == Orientation.portrait) {

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})";
}
}
}

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


this.onTap = onTap;
}
static readonly DataCell empty = new DataCell(new Container(width: 0.0f, height: 0.0f));
public static readonly DataCell empty = new DataCell(new Container(width: 0.0f, height: 0.0f));
public readonly Widget child;

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


child: child == null
? null
: new DefaultTextStyle(
style: theme.textTheme.body2,
style: theme.textTheme.bodyText1,
child: MediaQuery.removePadding(
context: context,
removeTop: true,

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


using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.services;
using Material = UnityEngine.Material;
using Rect = Unity.UIWidgets.ui.Rect;
using TextStyle = Unity.UIWidgets.painting.TextStyle;

public const float _kMenuItemHeight = 48.0f;
public const float _kMenuItemHeight = kMinInteractiveDimension;
public const float _kDenseButtonHeight = 24.0f;
public static readonly EdgeInsets _kMenuItemPadding = EdgeInsets.symmetric(horizontal: 16.0f);
public static readonly EdgeInsets _kAlignedButtonPadding = EdgeInsets.only(left: 16.0f, right: 4.0f);

public delegate List<Widget> DropdownButtonBuilder(BuildContext context);
}
class _DropdownMenuPainter : AbstractCustomPainter {

int? selectedIndex = null,
Animation<float> resize = null
Animation<float> resize = null,
ValueGetter<float> getSelectedItemOffset = null
) : base(repaint: resize) {
D.assert(elevation != null);
_painter = new BoxDecoration(

this.elevation = elevation;
this.selectedIndex = selectedIndex;
this.resize = resize;
this.getSelectedItemOffset = getSelectedItemOffset;
}
public readonly Color color;

public readonly ValueGetter<float> getSelectedItemOffset;
float selectedItemOffset = selectedIndex ?? 0 * material_._kMenuItemHeight +
material_.kMaterialListPadding.top;
float selectedItemOffset = getSelectedItemOffset();
FloatTween top = new FloatTween(
begin: selectedItemOffset.clamp(0.0f, size.height - material_._kMenuItemHeight),
end: 0.0f

}
}
class _DropdownMenu<T> : StatefulWidget where T : class {
class _DropdownMenuItemButton<T> : StatefulWidget {
internal _DropdownMenuItemButton(
Key key = null,
_DropdownRoute<T> route = null,
EdgeInsets padding = null,
Rect buttonRect = null,
BoxConstraints constraints = null,
int? itemIndex = null
) : base(key: key) {
this.route = route;
this.padding = padding;
this.buttonRect = buttonRect;
this.constraints = constraints;
this.itemIndex = itemIndex;
}
public _DropdownRoute<T> route;
public EdgeInsets padding;
public Rect buttonRect;
public BoxConstraints constraints;
public int? itemIndex;
public override State createState() => new _DropdownMenuItemButtonState<T>();
}
class _DropdownMenuItemButtonState<T> : State<_DropdownMenuItemButton<T>> {
void _handleFocusChange(bool focused) {
bool inTraditionalMode = false;
switch (FocusManager.instance.highlightMode) {
case FocusHighlightMode.touch:
inTraditionalMode = false;
break;
case FocusHighlightMode.traditional:
inTraditionalMode = true;
break;
}
if (focused && inTraditionalMode) {
_MenuLimits menuLimits = widget.route.getMenuLimits(
widget.buttonRect, widget.constraints.maxHeight, widget.itemIndex ?? 0);
widget.route.scrollController.animateTo(
menuLimits.scrollOffset ?? 0,
curve: Curves.easeInOut,
duration: new TimeSpan(0, 0, 0, 0, 100)
);
}
}
void _handleOnTap() {
DropdownMenuItem<T> dropdownMenuItem = widget.route.items[widget.itemIndex ?? 0].item;
if (dropdownMenuItem.onTap != null) {
dropdownMenuItem.onTap();
}
Navigator.pop(
context,
new _DropdownRouteResult<T>(dropdownMenuItem.value)
);
}
static readonly Dictionary<LogicalKeySet, Intent> _webShortcuts = new Dictionary<LogicalKeySet, Intent> {
{new LogicalKeySet(LogicalKeyboardKey.enter), new Intent(ActivateAction.key)}
};
public override Widget build(BuildContext context) {
CurvedAnimation opacity;
float unit = 0.5f / (widget.route.items.Count + 1.5f);
if (widget.itemIndex == widget.route.selectedIndex) {
opacity = new CurvedAnimation(parent: widget.route.animation, curve: new Threshold(0.0f));
}
else {
float start = ((0.5f + (widget.itemIndex + 1) * unit) ?? 0).clamp(0.0f, 1.0f);
float end = (start + 1.5f * unit).clamp(0.0f, 1.0f);
opacity = new CurvedAnimation(parent: widget.route.animation, curve: new Interval(start, end));
}
Widget child = new FadeTransition(
opacity: opacity,
child: new InkWell(
autofocus: widget.itemIndex == widget.route.selectedIndex,
child: new Container(
padding: widget.padding,
child: widget.route.items[widget.itemIndex ?? 0]
),
onTap: _handleOnTap,
onFocusChange: _handleFocusChange
)
);
return child;
}
}
class _DropdownMenu<T> : StatefulWidget {
_DropdownRoute<T> route = null
_DropdownRoute<T> route = null,
Rect buttonRect = null,
BoxConstraints constraints = null,
Color dropdownColor = null
this.buttonRect = buttonRect;
this.constraints = constraints;
this.dropdownColor = dropdownColor;
public readonly Rect buttonRect;
public readonly BoxConstraints constraints;
public readonly Color dropdownColor;
public override State createState() {
return new _DropdownMenuState<T>();

class _DropdownMenuState<T> : State<_DropdownMenu<T>> where T : class {
class _DropdownMenuState<T> : State<_DropdownMenu<T>> {
CurvedAnimation _fadeOpacity;
CurvedAnimation _resize;

D.assert(material_.debugCheckHasMaterialLocalizations(context));
MaterialLocalizations localizations = MaterialLocalizations.of(context);
_DropdownRoute<T> route = widget.route;
float unit = 0.5f / (route.items.Count + 1.5f);
CurvedAnimation opacity;
if (itemIndex == route.selectedIndex) {
opacity = new CurvedAnimation(parent: route.animation, curve: new Threshold(0.0f));
}
else {
float start = (0.5f + (itemIndex + 1) * unit).clamp(0.0f, 1.0f);
float end = (start + 1.5f * unit).clamp(0.0f, 1.0f);
opacity = new CurvedAnimation(parent: route.animation, curve: new Interval(start, end));
}
var index = itemIndex;
children.Add(new FadeTransition(
opacity: opacity,
child: new InkWell(
child: new Container(
padding: widget.padding,
child: route.items[itemIndex]
),
onTap: () => Navigator.pop(
context,
new _DropdownRouteResult<T>(route.items[index].value)
)
)
children.Add(new _DropdownMenuItemButton<T>(
route: widget.route,
padding: widget.padding,
buttonRect: widget.buttonRect,
constraints: widget.constraints,
itemIndex: itemIndex
));
}

painter: new _DropdownMenuPainter(
color: Theme.of(context).canvasColor,
color: widget.dropdownColor ?? Theme.of(context).canvasColor,
resize: _resize
resize: _resize,
getSelectedItemOffset: () => route.getItemOffset(route.selectedIndex ?? 0)
),
child: new Material(
type: MaterialType.transparency,

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

class _DropdownMenuRouteLayout<T> : SingleChildLayoutDelegate {
public _DropdownMenuRouteLayout(
Rect buttonRect,
float menuTop,
float menuHeight
_DropdownRoute<T> route = null,
TextDirection? textDirection = null
this.menuTop = menuTop;
this.menuHeight = menuHeight;
this.route = route;
this.textDirection = textDirection;
public readonly float menuTop;
public readonly float menuHeight;
public readonly _DropdownRoute<T> route;
public readonly TextDirection? textDirection;
public override BoxConstraints getConstraintsForChild(BoxConstraints constraints) {
float maxHeight = Mathf.Max(0.0f, constraints.maxHeight - 2 * material_._kMenuItemHeight);

}
public override Offset getPositionForChild(Size size, Size childSize) {
_MenuLimits menuLimits = route.getMenuLimits(buttonRect, size.height, route.selectedIndex ?? 0);
D.assert(menuTop >= 0.0f);
D.assert(menuTop + menuHeight <= size.height);
D.assert(menuLimits.top >= 0.0f);
D.assert(menuLimits.top + menuLimits.height <= size.height);
float left = buttonRect.right.clamp(0.0f, size.width) - childSize.width;
return new Offset(left, menuTop);
D.assert(textDirection != null);
float left = 0;
switch (textDirection) {
case TextDirection.rtl:
left = (buttonRect.right.clamp(0.0f, size.width)) - childSize.width;
break;
case TextDirection.ltr:
left = buttonRect.left.clamp(0.0f, size.width - childSize.width);
break;
}
return new Offset(left, menuLimits.top ?? 0);
return buttonRect != oldDelegate.buttonRect
|| menuTop != oldDelegate.menuTop
|| menuHeight != oldDelegate.menuHeight;
return buttonRect != oldDelegate.buttonRect || textDirection != oldDelegate.textDirection;
class _DropdownRouteResult<T> where T: class {
class _DropdownRouteResult<T> {
public _DropdownRouteResult(T result) {
this.result = result;
}

}
public bool Equals(_DropdownRouteResult<T> other) {
return result == other.result;
return result.Equals(other.result);
return Equals((_DropdownRouteResult<T>) obj);
}

}
class _DropdownRoute<T> : PopupRoute<_DropdownRouteResult<T>> where T : class {
class _MenuLimits {
internal _MenuLimits(float? top, float? bottom, float? height, float? scrollOffset) {
this.top = top;
this.bottom = bottom;
this.height = height;
this.scrollOffset = scrollOffset;
}
public readonly float? top;
public readonly float? bottom;
public readonly float? height;
public readonly float? scrollOffset;
}
class _DropdownRoute<T> : PopupRoute<_DropdownRouteResult<T>> {
List<DropdownMenuItem<T>> items = null,
List<_MenuItem<T>> items = null,
EdgeInsets padding = null,
Rect buttonRect = null,
int? selectedIndex = null,

string barrierLabel = null
string barrierLabel = null,
float? itemHeight = null,
Color dropdownColor = null
) {
D.assert(style != null);
this.items = items;

this.theme = theme;
this.style = style;
this.barrierLabel = barrierLabel;
this.itemHeight = itemHeight;
this.dropdownColor = dropdownColor;
itemHeights = Enumerable.Repeat(itemHeight ?? material_.kMinInteractiveDimension, items.Count).ToList();
public readonly List<DropdownMenuItem<T>> items;
public readonly List<_MenuItem<T>> items;
public readonly EdgeInsets padding;
public readonly Rect buttonRect;
public readonly int? selectedIndex;

public readonly float? itemHeight;
public readonly Color dropdownColor;
public readonly List<float> itemHeights;
public ScrollController scrollController;
public override TimeSpan transitionDuration {

selectedIndex: selectedIndex,
elevation: elevation,
theme: theme,
style: style
style: style,
dropdownColor: dropdownColor
);
}
);

navigator?.removeRoute(this);
}
public float getItemOffset(int index) {
float offset = material_.kMaterialListPadding.top;
if (items.isNotEmpty() && index > 0) {
D.assert(items.Count == itemHeights?.Count);
offset += itemHeights
.Aggregate(0, (float total, float height) => total + height);
}
return offset;
}
public _MenuLimits getMenuLimits(Rect buttonRect, float availableHeight, int index) {
float maxMenuHeight = availableHeight - 2.0f * material_._kMenuItemHeight;
float buttonTop = buttonRect.top;
float buttonBottom = Mathf.Min(buttonRect.bottom, availableHeight);
float selectedItemOffset = getItemOffset(index);
float topLimit = Mathf.Min(material_._kMenuItemHeight, buttonTop);
float bottomLimit = Mathf.Max(availableHeight - material_._kMenuItemHeight, buttonBottom);
float menuTop = (buttonTop - selectedItemOffset) -
(itemHeights[selectedIndex ?? 0] - buttonRect.height) / 2.0f;
float preferredMenuHeight = material_.kMaterialListPadding.vertical;
if (items.isNotEmpty())
preferredMenuHeight += itemHeights.Aggregate((float total, float height) => total + height);
float menuHeight = Mathf.Min(maxMenuHeight, preferredMenuHeight);
float menuBottom = menuTop + menuHeight;
if (menuTop < topLimit)
menuTop = Mathf.Min(buttonTop, topLimit);
if (menuBottom > bottomLimit) {
menuBottom = Mathf.Max(buttonBottom, bottomLimit);
menuTop = menuBottom - menuHeight;
}
float scrollOffset = preferredMenuHeight <= maxMenuHeight
? 0
: Mathf.Max(0.0f, selectedItemOffset - (buttonTop - menuTop));
return new _MenuLimits(menuTop, menuBottom, menuHeight, scrollOffset);
}
class _DropdownRoutePage<T> : StatelessWidget where T : class {
class _DropdownRoutePage<T> : StatelessWidget {
List<DropdownMenuItem<T>> items = null,
List<_MenuItem<T>> items = null,
TextStyle style = null
TextStyle style = null,
Color dropdownColor = null
) : base(key: key) {
this.route = route;
this.constraints = constraints;

this.elevation = elevation;
this.theme = theme;
this.style = style;
this.dropdownColor = dropdownColor;
public readonly List<DropdownMenuItem<T>> items;
public readonly List<_MenuItem<T>> items;
public readonly EdgeInsets padding;
public readonly Rect buttonRect;
public readonly int? selectedIndex;

public readonly Color dropdownColor;
float availableHeight = constraints.maxHeight;
float maxMenuHeight = availableHeight - 2.0f * material_._kMenuItemHeight;
float buttonTop = buttonRect.top;
float buttonBottom = Mathf.Min(buttonRect.bottom, availableHeight);
float topLimit = Mathf.Min(material_._kMenuItemHeight, buttonTop);
float bottomLimit = Mathf.Max(availableHeight - material_._kMenuItemHeight, buttonBottom);
float? selectedItemOffset = selectedIndex * material_._kMenuItemHeight +
material_.kMaterialListPadding.top;
float? menuTop = (buttonTop - selectedItemOffset) -
(material_._kMenuItemHeight - buttonRect.height) / 2.0f;
float preferredMenuHeight = (items.Count * material_._kMenuItemHeight) +
material_.kMaterialListPadding.vertical;
float menuHeight = Mathf.Min(maxMenuHeight, preferredMenuHeight);
float? menuBottom = menuTop + menuHeight;
if (menuTop < topLimit) {
menuTop = Mathf.Min(buttonTop, topLimit);
}
if (menuBottom > bottomLimit) {
menuBottom = Mathf.Max(buttonBottom, bottomLimit);
menuTop = menuBottom - menuHeight;
}
float scrollOffset = preferredMenuHeight > maxMenuHeight
? Mathf.Max(0.0f, selectedItemOffset ?? 0.0f - (buttonTop - (menuTop ?? 0.0f)))
: 0.0f;
route.scrollController = new ScrollController(initialScrollOffset: scrollOffset);
_MenuLimits menuLimits = route.getMenuLimits(buttonRect, constraints.maxHeight, selectedIndex ?? 0);
route.scrollController = new ScrollController(initialScrollOffset: menuLimits.scrollOffset ?? 0);
TextDirection textDirection = Directionality.of(context);
padding: padding
padding: padding.resolve(textDirection),
buttonRect: buttonRect,
constraints: constraints,
dropdownColor: dropdownColor
);
if (theme != null) {

return new CustomSingleChildLayout(
layoutDelegate: new _DropdownMenuRouteLayout<T>(
buttonRect: buttonRect,
menuTop: menuTop ?? 0.0f,
menuHeight: menuHeight
route: route,
textDirection: textDirection
),
child: menu
);

}
}
public class DropdownMenuItem<T> : StatelessWidget where T : class {
public DropdownMenuItem(
class _MenuItem<T> : SingleChildRenderObjectWidget {
internal _MenuItem(
Key key = null,
ValueChanged<Size> onLayout = null,
DropdownMenuItem<T> item = null
) : base(key: key, child: item) {
D.assert(onLayout != null);
this.onLayout = onLayout;
this.item = item;
}
public readonly ValueChanged<Size> onLayout;
public readonly DropdownMenuItem<T> item;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderMenuItem(onLayout);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
if (renderObject is _RenderMenuItem renderMenuItem) {
renderMenuItem.onLayout = onLayout;
}
}
}
class _RenderMenuItem : RenderProxyBox {
internal _RenderMenuItem(ValueChanged<Size> onLayout = null, RenderBox child = null) : base(child) {
D.assert(onLayout != null);
this.onLayout = onLayout;
}
public ValueChanged<Size> onLayout;
protected override void performLayout() {
base.performLayout();
onLayout(size);
}
}
public class _DropdownMenuItemContainer : StatelessWidget {
internal _DropdownMenuItemContainer(
T value = null,
this.value = value;
public readonly T value;
height: material_._kMenuItemHeight,
alignment: Alignment.centerLeft,
constraints: new BoxConstraints(minHeight: material_._kMenuItemHeight),
alignment: AlignmentDirectional.centerStart,
public class DropdownMenuItem<T> : _DropdownMenuItemContainer {
public DropdownMenuItem(
Key key = null,
VoidCallback onTap = null,
T value = default,
Widget child = null
) : base(key: key, child: child) {
D.assert(child != null);
this.onTap = onTap;
this.value = value;
}
public readonly VoidCallback onTap;
public readonly T value;
}
public class DropdownButtonHideUnderline : InheritedWidget {
public DropdownButtonHideUnderline(
Key key = null,

}
public static bool at(BuildContext context) {
return context.inheritFromWidgetOfExactType(typeof(DropdownButtonHideUnderline)) != null;
return context.dependOnInheritedWidgetOfExactType<DropdownButtonHideUnderline>() != null;
}
public override bool updateShouldNotify(InheritedWidget oldWidget) {

public class DropdownButton<T> : StatefulWidget where T : class {
public class DropdownButton<T> : StatefulWidget{
T value = null,
material_.DropdownButtonBuilder selectedItemBuilder = null,
T value = default,
VoidCallback onTap = null,
int elevation = 8,
TextStyle style = null,
Widget underline = null,

float iconSize = 24.0f,
bool isDense = false,
bool isExpanded = false
bool isExpanded = false,
float? itemHeight = material_.kMinInteractiveDimension,
Color focusColor = null,
FocusNode focusNode = null,
bool autofocus = false,
Color dropdownColor = null
D.assert(items == null || value == null ||
items.Where<DropdownMenuItem<T>>((DropdownMenuItem<T> item) => item.value.Equals(value)).ToList()
.Count == 1);
D.assert(items == null || items.isEmpty() || value == null ||
items.Where((DropdownMenuItem<T> item) => { return item.value.Equals(value); }).Count() == 1,
() => "There should be exactly one item with [DropdownButton]'s value: " +
$"{value}. \n" +
"Either zero or 2 or more [DropdownMenuItem]s were detected " +
"with the same value"
);
D.assert(itemHeight == null || itemHeight >= material_.kMinInteractiveDimension);
this.selectedItemBuilder = selectedItemBuilder;
this.onTap = onTap;
this.elevation = elevation;
this.style = style;
this.underline = underline;

this.iconSize = iconSize;
this.isDense = isDense;
this.isExpanded = isExpanded;
this.itemHeight = itemHeight;
this.focusColor = focusColor;
this.focusNode = focusNode;
this.autofocus = autofocus;
this.dropdownColor = dropdownColor;
}
public readonly List<DropdownMenuItem<T>> items;

public readonly ValueChanged<T> onChanged;
public readonly VoidCallback onTap;
public readonly material_.DropdownButtonBuilder selectedItemBuilder;
public readonly Color iconEnabledColor;
public readonly float iconSize;

public readonly bool isExpanded;
public readonly float? itemHeight;
public readonly Color focusColor;
public readonly FocusNode focusNode;
public readonly bool autofocus;
public readonly Color dropdownColor;
class _DropdownButtonState<T> : State<DropdownButton<T>>, WidgetsBindingObserver where T : class {
class _DropdownButtonState<T> : State<DropdownButton<T>>, WidgetsBindingObserver{
Orientation? _lastOrientation;
FocusNode _internalNode;
public void didChangeTextScaleFactor() {
public FocusNode focusNode {
get { return widget.focusNode ?? _internalNode; }
public void didChangeLocales(List<Locale> locale) {
}
bool _hasPrimaryFocus = false;
Dictionary<LocalKey, ActionFactory> _actionMap;
FocusHighlightMode _focusHighlightMode;
public Future<bool> didPopRoute() {
return Future.value(false).to<bool>();
}
public Future<bool> didPushRoute(string route) {
return Future.value(false).to<bool>();
}
public void didChangeAccessibilityFeatures() {
//FIX ME!!!!
throw new NotImplementedException();
}
public void didChangePlatformBrightness() {
FocusNode _createFocusNode() {
return new FocusNode(debugLabel: $"{widget.GetType()}");
WidgetsBinding.instance.addObserver(this);
if (widget.focusNode == null) {
_internalNode = _internalNode ?? _createFocusNode();
}
_actionMap = new Dictionary<LocalKey, ActionFactory>() {
{ActivateAction.key, _createAction}
};
focusNode.addListener(_handleFocusChanged);
FocusManager focusManager = WidgetsBinding.instance.focusManager;
_focusHighlightMode = focusManager.highlightMode;
focusManager.addHighlightModeListener(_handleFocusHighlightModeChange);
WidgetsBinding.instance.focusManager.removeHighlightModeListener(_handleFocusHighlightModeChange);
focusNode.removeListener(_handleFocusChanged);
_internalNode?.dispose();
base.dispose();
}

void _removeDropdownRoute() {
_dropdownRoute?._dismiss();
_dropdownRoute = null;
_lastOrientation = null;
}
void _handleFocusChanged() {
if (_hasPrimaryFocus != focusNode.hasPrimaryFocus) {
setState(() => { _hasPrimaryFocus = focusNode.hasPrimaryFocus; });
}
}
void _handleFocusHighlightModeChange(FocusHighlightMode mode) {
if (!mounted) {
return;
}
setState(() => { _focusHighlightMode = mode; });
if (oldWidget is DropdownButton<T> dropdownButton && widget.focusNode != dropdownButton.focusNode) {
dropdownButton.focusNode?.removeListener(_handleFocusChanged);
if (widget.focusNode == null) {
_internalNode = _internalNode ?? _createFocusNode();
}
_hasPrimaryFocus = focusNode.hasPrimaryFocus;
focusNode.addListener(_handleFocusChanged);
}
public void didChangeTextScaleFactor() {
}
public void didChangeLocales(List<Locale> locale) {
}
public Future<bool> didPopRoute() {
return Future.value(false).to<bool>();
}
public Future<bool> didPushRoute(string route) {
return Future.value(false).to<bool>();
}
public void didChangeAccessibilityFeatures() {
//FIX ME!!!!
throw new NotImplementedException();
}
public void didChangePlatformBrightness() {
}
void _updateSelectedIndex() {
if (!_enabled) {
return;

}
TextStyle _textStyle {
get { return widget.style ?? Theme.of(context).textTheme.subhead; }
get { return widget.style ?? Theme.of(context).textTheme.subtitle1; }
}
void _handleTap() {

? material_._kAlignedMenuMargin
: material_._kUnalignedMenuMargin;
List<_MenuItem<T>> menuItems = new List<_MenuItem<T>>(widget.items.Count);
for (int index = 0; index < widget.items.Count; index += 1) {
menuItems[index] = new _MenuItem<T>(
item: widget.items[index],
onLayout: (Size size) => {
if (_dropdownRoute == null)
return;
_dropdownRoute.itemHeights[index] = size.height;
}
);
}
items: widget.items,
items: menuItems,
buttonRect: menuMargin.inflateRect(itemRect),
padding: material_._kMenuItemPadding,
selectedIndex: _selectedIndex ?? 0,

barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
itemHeight: widget.itemHeight,
dropdownColor: widget.dropdownColor
_dropdownRoute = null;
_removeDropdownRoute();
if (!mounted || newValue == null) {
return;
}

}
});
if (widget.onTap != null) {
widget.onTap();
}
}
UiWidgetAction _createAction() {
return new CallbackAction(
ActivateAction.key,
onInvoke: (FocusNode node, Intent intent) => { _handleTap(); }
);
return Mathf.Max(_textStyle.fontSize ?? 0.0f,
Mathf.Max(widget.iconSize, material_._kDenseButtonHeight));
float fontSize = _textStyle.fontSize ?? Theme.of(context).textTheme.subtitle1.fontSize ?? 0;
return Mathf.Max(fontSize, Mathf.Max(widget.iconSize, material_._kDenseButtonHeight));
}
}

return Colors.white10;
}
}
D.assert(false);
return null;
}

get { return widget.items != null && widget.items.isNotEmpty() && widget.onChanged != null; }
}
Orientation? _getOrientation(BuildContext context) {
Orientation? result = MediaQuery.of(context, nullOk: true)?.orientation;
if (result == null) {
// If there's no MediaQuery, then use the window aspect to determine
// orientation.
Size size = Window.instance.physicalSize;
result = size.width > size.height ? Orientation.landscape : Orientation.portrait;
}
return result;
}
bool? _showHighlight {
get {
switch (_focusHighlightMode) {
case FocusHighlightMode.touch:
return false;
case FocusHighlightMode.traditional:
return _hasPrimaryFocus;
}
return null;
}
}
Orientation? newOrientation = _getOrientation(context);
_lastOrientation = _lastOrientation ?? newOrientation;
if (newOrientation != _lastOrientation) {
_removeDropdownRoute();
_lastOrientation = newOrientation;
}
List<Widget> items = _enabled ? new List<Widget>(widget.items) : new List<Widget>();
List<Widget> items = null;
if (_enabled) {
items = widget.selectedItemBuilder == null
? new List<Widget>(widget.items)
: widget.selectedItemBuilder(context);
}
else {
items = widget.selectedItemBuilder == null
? new List<Widget>()
: widget.selectedItemBuilder(context);
}
Widget emplacedHint =
_enabled
? widget.hint
: new DropdownMenuItem<Widget>(child: widget.disabledHint ?? widget.hint);
Widget displayedHint = _enabled ? widget.hint : widget.disabledHint ?? widget.hint;
if (widget.selectedItemBuilder == null) {
displayedHint = new _DropdownMenuItemContainer(child: displayedHint);
}
child: emplacedHint
child: displayedHint
)
));
}

: material_._kUnalignedButtonPadding;
IndexedStack innerItemsWidget = new IndexedStack(
index: _enabled ? (_selectedIndex ?? hintIndex) : hintIndex,
alignment: Alignment.centerLeft,
children: items
);
int index = _enabled ? (_selectedIndex ?? hintIndex) : hintIndex;
Widget innerItemsWidget = null;
if (items.isEmpty()) {
innerItemsWidget = new Container();
}
else {
innerItemsWidget = new IndexedStack(
index: index,
alignment: AlignmentDirectional.centerStart,
children: widget.isDense
? items
: items.Select((Widget item) => {
return widget.itemHeight != null
? new SizedBox(height: widget.itemHeight, child: item)
: (Widget) new Column(mainAxisSize: MainAxisSize.min,
children: new List<Widget>() {item});
}).ToList()
);
}
decoration: _showHighlight ?? false
? new BoxDecoration(
color: widget.focusColor ?? Theme.of(context).focusColor,
borderRadius: BorderRadius.all(Radius.circular(4.0f))
)
: null,
padding: padding,
height: widget.isDense ? _denseButtonHeight : null,
child: new Row(

);
if (!DropdownButtonHideUnderline.at(context)) {
float bottom = widget.isDense ? 0.0f : 8.0f;
float bottom = widget.isDense || widget.itemHeight == null ? 0.0f : 8.0f;
result = new Stack(
children: new List<Widget> {
result,

);
}
return new GestureDetector(
onTap: _enabled ? (GestureTapCallback) _handleTap : null,
behavior: HitTestBehavior.opaque,
child: result
return new Focus(
canRequestFocus: _enabled,
focusNode: focusNode,
autofocus: widget.autofocus,
child: new GestureDetector(
onTap: _enabled ? (GestureTapCallback) _handleTap : null,
behavior: HitTestBehavior.opaque,
child: result
)
);
}
}

3
com.unity.uiwidgets/Runtime/material/elevation_overlay.cs


using Unity.UIWidgets.material;
namespace uiwidgets {
namespace Unity.UIWidgets.material {
public class ElevationOverlay {
private ElevationOverlay() {
}

44
com.unity.uiwidgets/Runtime/material/expand_icon.cs


using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
public class ExpandIcon : StatefulWidget {

float size = 24.0f,
ValueChanged<bool> onPressed = null,
EdgeInsets padding = null) : base(key: key) {
EdgeInsets padding = null,
Color color = null,
Color disabledColor = null,
Color expandedColor = null
) : base(key: key) {
this.color = color;
this.disabledColor = disabledColor;
this.expandedColor = expandedColor;
}
public readonly bool isExpanded;

public readonly ValueChanged<bool> onPressed;
public readonly EdgeInsets padding;
public readonly Color color;
public readonly Color disabledColor;
public readonly Color expandedColor;
public override State createState() {
return new _ExpandIconState();

}
}
Color _iconColor {
get {
if (widget.isExpanded && widget.expandedColor != null) {
return widget.expandedColor;
}
if (widget.color != null) {
return widget.color;
}
switch (Theme.of(context).brightness) {
case Brightness.light:
return Colors.black54;
case Brightness.dark:
return Colors.white60;
}
D.assert(false);
return null;
}
}
ThemeData theme = Theme.of(context);
D.assert(material_.debugCheckHasMaterialLocalizations(context));
color: theme.brightness == Brightness.dark ? Colors.white54 : Colors.black54,
iconSize: widget.size,
color: _iconColor,
disabledColor: widget.disabledColor,
onPressed: widget.onPressed == null ? (VoidCallback) null : _handlePressed,
icon: new RotationTransition(
turns: _iconTurns,

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


using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
static class ExpansionPanelUtils {
public const float _kPanelHeaderCollapsedHeight = 48.0f;
public const float _kPanelHeaderExpandedHeight = 64.0f;
public partial class material_ {
public const float _kPanelHeaderCollapsedHeight = kMinInteractiveDimension;
public static readonly EdgeInsets _kPanelHeaderExpandedDefaultPadding = EdgeInsets.symmetric(
vertical: 64.0f - _kPanelHeaderCollapsedHeight);
}

Key key = null,
List<ExpansionPanel> children = null,
ExpansionPanelCallback expansionCallback = null,
TimeSpan? animationDuration = null) : base(key: key) {
TimeSpan? animationDuration = null,
EdgeInsets expandedHeaderPadding = null
) : base(key: key) {
this.expandedHeaderPadding = expandedHeaderPadding ?? material_._kPanelHeaderExpandedDefaultPadding;
_allowOnlyOnePanelOpen = false;
initialOpenPanelValue = null;
}

List<ExpansionPanel> children = null,
ExpansionPanelCallback expansionCallback = null,
TimeSpan? animationDuration = null,
object initialOpenPanelValue = null) : base(key: key) {
object initialOpenPanelValue = null,
EdgeInsets expandedHeaderPadding = null
) : base(key: key) {
this.expandedHeaderPadding = expandedHeaderPadding ?? material_._kPanelHeaderExpandedDefaultPadding;
_allowOnlyOnePanelOpen = true;
this.initialOpenPanelValue = initialOpenPanelValue;
}

public readonly object initialOpenPanelValue;
public readonly EdgeInsets expandedHeaderPadding;
public override State createState() {
return new _ExpansionPanelListState();
}

public override void initState() {
base.initState();
if (widget._allowOnlyOnePanelOpen) {
D.assert(_allIdentifierUnique(), () => "All object identifiers are not unique!");
D.assert(_allIdentifierUnique(), () => "All ExpansionPanelRadio identifier values must be unique.");
if (widget.initialOpenPanelValue != null &&
child.value == widget.initialOpenPanelValue) {
_currentOpenPanel = child;
if (widget.initialOpenPanelValue != null) {
_currentOpenPanel =
searchPanelByValue(widget.children.Cast<ExpansionPanelRadio>().ToList(),
widget.initialOpenPanelValue);
}
}
}

base.didUpdateWidget(oldWidget);
ExpansionPanelList _oldWidget = (ExpansionPanelList) oldWidget;
if (widget._allowOnlyOnePanelOpen) {
D.assert(_allIdentifierUnique(), () => "All object identifiers are not unique!");
foreach (ExpansionPanelRadio newChild in widget.children) {
if (widget.initialOpenPanelValue != null &&
newChild.value == widget.initialOpenPanelValue) {
_currentOpenPanel = newChild;
}
D.assert(_allIdentifierUnique(), () => "All ExpansionPanelRadio identifier values must be unique.");
if (!_oldWidget._allowOnlyOnePanelOpen) {
_currentOpenPanel =
searchPanelByValue(widget.children.Cast<ExpansionPanelRadio>().ToList(),
widget.initialOpenPanelValue);
else if (_oldWidget._allowOnlyOnePanelOpen) {
else {
_currentOpenPanel = null;
}
}

foreach (ExpansionPanelRadio child in widget.children) {
foreach (ExpansionPanelRadio child in widget.children.Cast<ExpansionPanelRadio>()) {
identifierMap[child.value] = true;
}

}
}
_currentOpenPanel = isExpanded ? null : pressedChild;
setState(() => { _currentOpenPanel = isExpanded ? null : pressedChild; });
}
setState(() => { });
public ExpansionPanelRadio searchPanelByValue(List<ExpansionPanelRadio> panels, Object value) {
foreach (ExpansionPanelRadio panel in panels) {
if (panel.value == value)
return panel;
}
return null;
EdgeInsets kExpandedEdgeInsets = EdgeInsets.symmetric(
vertical: ExpansionPanelUtils._kPanelHeaderExpandedHeight -
ExpansionPanelUtils._kPanelHeaderCollapsedHeight);
for (int index = 0; index < widget.children.Count; index++) {
int expandIndex = index;

context,
_isChildExpanded(index)
);
Row header = new Row(
Widget expandIconContainer = new Container(
//TODO: update to EdgeInsetsGeometry
margin: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(end: 8.0f),
child: new ExpandIcon(
isExpanded: _isChildExpanded(index),
padding: EdgeInsets.all(16.0f),
onPressed: !child.canTapOnHeader
? (bool isExpanded) => _handlePressed(isExpanded, index)
: (ValueChanged<bool>) null
)
);
Widget header = new Row(
margin: _isChildExpanded(index) ? kExpandedEdgeInsets : EdgeInsets.zero,
margin: _isChildExpanded(index) ? widget.expandedHeaderPadding : EdgeInsets.zero,
minHeight: ExpansionPanelUtils._kPanelHeaderCollapsedHeight),
minHeight: material_._kPanelHeaderCollapsedHeight),
new Container(
margin: EdgeInsets.fromLTRB(0, 0, 8, 0),
child: new ExpandIcon(
isExpanded: _isChildExpanded(index),
padding: EdgeInsets.all(16.0f),
onPressed: !child.canTapOnHeader
? (ValueChanged<bool>) ((bool isExpanded) => {
_handlePressed(isExpanded, expandIndex);
})
: null
)
)
expandIconContainer,
if (child.canTapOnHeader) {
header = new InkWell(
onTap: () => _handlePressed(_isChildExpanded(index), index),
child: header
);
}
child.canTapOnHeader
? (Widget) new InkWell(
onTap: () =>
_handlePressed(_isChildExpanded(expandIndex), expandIndex),
child: header
)
: header,
header,
new AnimatedCrossFade(
firstChild: new Container(height: 0.0f),
secondChild: child.body,

7
com.unity.uiwidgets/Runtime/material/expansion_tile.cs


Key key = null,
Widget leading = null,
Widget title = null,
Widget subtitle = null,
Color backgroundColor = null,
ValueChanged<bool> onExpansionChanged = null,
List<Widget> children = null,

D.assert(title != null);
this.leading = leading;
this.title = title;
this.subtitle = subtitle;
this.backgroundColor = backgroundColor;
this.onExpansionChanged = onExpansionChanged;
this.children = children ?? new List<Widget>();

public readonly Widget leading;
public readonly Widget title;
public readonly Widget subtitle;
public readonly ValueChanged<bool> onExpansionChanged;

onTap: _handleTap,
leading: widget.leading,
title: widget.title,
subtitle: widget.subtitle,
trailing: widget.trailing ?? new RotationTransition(
turns: _iconTurns,
child: new Icon(Icons.expand_more)

public override void didChangeDependencies() {
ThemeData theme = Theme.of(context);
_borderColorTween.end = theme.dividerColor;
_headerColorTween.begin = theme.textTheme.subhead.color;
_headerColorTween.begin = theme.textTheme.subtitle1.color;
_headerColorTween.end = theme.accentColor;
_iconColorTween.begin = theme.unselectedWidgetColor;
_iconColorTween.end = theme.accentColor;

22
com.unity.uiwidgets/Runtime/material/feedback.cs


using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.widgets;
using UnityEngine;

case RuntimePlatform.Android:
return
Future.value(); // SystemSound.play(SystemSoundType.click); TODO: replace with unity equivalent
default:
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.LinuxEditor:
case RuntimePlatform.LinuxPlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.WindowsPlayer:
D.assert(false, () => $"Unhandled TargetPlatform {_platform(context)}");
return Future.value();
}
public static GestureTapCallback wrapForTap(GestureTapCallback callback, BuildContext context) {

switch (_platform(context)) {
case RuntimePlatform.Android:
return Future.value(); // HapticFeedback.vibrate(); TODO
default:
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.LinuxEditor:
case RuntimePlatform.LinuxPlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.WindowsPlayer:
D.assert(false, ()=>$"Unhandled TargetPlatform {_platform(context)}");
return Future.value();
}
public static GestureLongPressCallback

69
com.unity.uiwidgets/Runtime/material/flat_button.cs


Key key = null,
VoidCallback onPressed = null,
ValueChanged<bool> onHighlightChanged = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
VisualDensity visualDensity = null,
Clip? clipBehavior = Clip.none,
Clip clipBehavior = Clip.none,
FocusNode focusNode = null,
bool autofocus = false,
onLongPress: onLongPress,
focusColor: focusColor,
hoverColor: hoverColor,
color: color,
disabledColor: disabledColor,
highlightColor: highlightColor,

visualDensity: visualDensity,
focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
child: child) {
}

VoidCallback onPressed = null,
ValueChanged<bool> onHighlightChanged = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
Clip? clipBehavior = null,
Clip clipBehavior = Clip.none,
FocusNode focusNode = null,
bool autofocus = false,
MaterialTapTargetSize? materialTapTargetSize = null,
Widget icon = null,
Widget label = null) {

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

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

focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
icon: icon,
label: label

return new RawMaterialButton(
onPressed: onPressed,
onLongPress: () => onLongPress(),
clipBehavior: clipBehavior ?? Clip.none,
focusColor: buttonTheme.getFocusColor(this),
hoverColor: buttonTheme.getHoverColor(this),
focusElevation: buttonTheme.getFocusElevation(this),
hoverElevation: buttonTheme.getHoverElevation(this),
visualDensity: visualDensity ?? theme.visualDensity,
clipBehavior: clipBehavior ?? Clip.none,
focusNode: focusNode,
autofocus: autofocus ?? false,
materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this),
materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this),
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new ObjectFlagProperty<VoidCallback>("onPressed", onPressed, ifNull: "disabled"));
properties.add(new DiagnosticsProperty<ButtonTextTheme?>("textTheme", textTheme, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("textColor", textColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("disabledTextColor", disabledTextColor,
defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("color", color, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("disabledColor", disabledColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("highlightColor", highlightColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("splashColor", splashColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Brightness?>("colorBrightness", colorBrightness,
defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", padding, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null));
properties.add(new DiagnosticsProperty<MaterialTapTargetSize?>("materialTapTargetSize",
materialTapTargetSize, defaultValue: null));
}
}
class _FlatButtonWithIcon : FlatButton, MaterialButtonWithIconMixin {

ValueChanged<bool> onHighlightChanged = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
Clip? clipBehavior = null,
Clip clipBehavior = Clip.none,
FocusNode focusNode = null,
bool autofocus = false,
onLongPress: onLongPress,
onHighlightChanged: onHighlightChanged,
textTheme: textTheme,
textColor: textColor,

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

focusNode: focusNode,
autofocus: autofocus,
materialTapTargetSize: materialTapTargetSize,
child: new Row(
mainAxisSize: MainAxisSize.min,

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


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

none
}
public enum StretchMode {
zoomBackground,
blurBackground,
fadeTitle,
}
public class FlexibleSpaceBar : StatefulWidget {
public FlexibleSpaceBar(
Key key = null,

EdgeInsets titlePadding = null,
CollapseMode collapseMode = CollapseMode.parallax
CollapseMode collapseMode = CollapseMode.parallax,
List<StretchMode> stretchModes = null
) : base(key: key) {
this.title = title;
this.background = background;

this.stretchModes = stretchModes ?? new List<StretchMode> {StretchMode.zoomBackground};
}
public readonly Widget title;

public readonly bool? centerTitle;
public readonly List<StretchMode> stretchModes;
public readonly EdgeInsets titlePadding;

switch (themeData.platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
return true;
default:
return false;

}
public override Widget build(BuildContext context) {
FlexibleSpaceBarSettings settings =
(FlexibleSpaceBarSettings) context.inheritFromWidgetOfExactType(typeof(FlexibleSpaceBarSettings));
D.assert(settings != null,
() => "A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings().");
return new LayoutBuilder(
builder: (BuildContext _context, BoxConstraints constraints) => {
FlexibleSpaceBarSettings settings =
_context.dependOnInheritedWidgetOfExactType<FlexibleSpaceBarSettings>();
D.assert(settings != null,
() =>
"A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings().");
List<Widget> children = new List<Widget>();
float deltaExtent = settings.maxExtent.Value - settings.minExtent.Value;
List<Widget> children = new List<Widget>();
float deltaExtent = settings.maxExtent.Value - settings.minExtent.Value;
float t = (1.0f - (settings.currentExtent.Value - settings.minExtent.Value) / deltaExtent)
.clamp(0.0f, 1.0f);
float t = (1.0f - (settings.currentExtent.Value - settings.minExtent.Value) / deltaExtent)
.clamp(0.0f, 1.0f);
if (widget.background != null) {
float fadeStart = Mathf.Max(0.0f, 1.0f - material_.kToolbarHeight / deltaExtent);
float fadeEnd = 1.0f;
D.assert(fadeStart <= fadeEnd);
if (widget.background != null) {
float fadeStart = Mathf.Max(0.0f, 1.0f - material_.kToolbarHeight / deltaExtent);
float fadeEnd = 1.0f;
D.assert(fadeStart <= fadeEnd);
float opacity = 1.0f - new Interval(fadeStart, fadeEnd).transform(t);
if (opacity > 0.0f) {
children.Add(new Positioned(
top: _getCollapsePadding(t, settings),
left: 0.0f,
right: 0.0f,
height: settings.maxExtent,
child: new Opacity(
opacity: opacity,
child: widget.background)
)
);
}
}
float opacity = 1.0f - new Interval(fadeStart, fadeEnd).transform(t);
if (opacity > 0.0f) {
float height = settings.maxExtent ?? 0;
if (widget.stretchModes.Contains(StretchMode.zoomBackground) &&
constraints.maxHeight > height) {
height = constraints.maxHeight;
}
children.Add(new Positioned(
top: _getCollapsePadding(t, settings),
left: 0.0f,
right: 0.0f,
height: height,
child: new Opacity(
opacity: opacity,
child: widget.background)
)
);
if (widget.stretchModes.Contains(StretchMode.blurBackground) &&
constraints.maxHeight > settings.maxExtent) {
float blurAmount = (constraints.maxHeight - settings.maxExtent) / 10 ?? 0;
children.Add(Positioned.fill(
child: new BackdropFilter(
child: new Container(
color: Colors.transparent
),
filter: ui.ImageFilter.blur(
sigmaX: blurAmount,
sigmaY: blurAmount
)
)
));
}
}
}
Widget title = null;
if (widget.title != null) {
switch (Application.platform) {
case RuntimePlatform.IPhonePlayer:
title = widget.title;
break;
default:
title = widget.title;
break;
}
}
Widget title = null;
if (widget.title != null) {
switch (Application.platform) {
case RuntimePlatform.IPhonePlayer:
title = widget.title;
break;
default:
title = widget.title;
break;
}
}
if (widget.stretchModes.Contains(StretchMode.fadeTitle) &&
constraints.maxHeight > settings.maxExtent) {
float stretchOpacity =
1 - (((constraints.maxHeight - settings.maxExtent) / 100)?.clamp(0.0f, 1.0f) ?? 0);
title = new Opacity(
opacity: stretchOpacity,
child: title
);
}
ThemeData theme = Theme.of(context);
float toolbarOpacity = settings.toolbarOpacity.Value;
if (toolbarOpacity > 0.0f) {
TextStyle titleStyle = theme.primaryTextTheme.title;
titleStyle = titleStyle.copyWith(
color: titleStyle.color.withOpacity(toolbarOpacity));
ThemeData theme = Theme.of(_context);
float toolbarOpacity = settings.toolbarOpacity.Value;
if (toolbarOpacity > 0.0f) {
TextStyle titleStyle = theme.primaryTextTheme.title;
titleStyle = titleStyle.copyWith(
color: titleStyle.color.withOpacity(toolbarOpacity));
bool effectiveCenterTitle = _getEffectiveCenterTitle(theme).Value;
EdgeInsets padding = widget.titlePadding ??
EdgeInsets.only(
left: effectiveCenterTitle ? 0.0f : 72.0f,
bottom: 16.0f
);
float scaleValue = new FloatTween(begin: 1.5f, end: 1.0f).lerp(t);
Matrix4 scaleTransform = Matrix4.diagonal3Values(scaleValue, scaleValue, 1);
Alignment titleAlignment = _getTitleAlignment(effectiveCenterTitle);
bool effectiveCenterTitle = _getEffectiveCenterTitle(theme).Value;
EdgeInsets padding = widget.titlePadding ??
EdgeInsets.only(
left: effectiveCenterTitle ? 0.0f : 72.0f,
bottom: 16.0f
);
float scaleValue = new FloatTween(begin: 1.5f, end: 1.0f).lerp(t);
Matrix4 scaleTransform = Matrix4.diagonal3Values(scaleValue, scaleValue, 1);
Alignment titleAlignment = _getTitleAlignment(effectiveCenterTitle);
children.Add(new Container(
padding: padding,
child: new Transform(
alignment: titleAlignment,
transform: scaleTransform,
child: new Align(
alignment: titleAlignment,
child: new DefaultTextStyle(
style: titleStyle,
child: title)
children.Add(new Container(
padding: padding,
child: new Transform(
alignment: titleAlignment,
transform: scaleTransform,
child: new Align(
alignment: titleAlignment,
child: new DefaultTextStyle(
style: titleStyle,
child: new LayoutBuilder(
builder: (BuildContext __context, BoxConstraints _constraints) => {
return new Container(
width: _constraints.maxWidth / scaleValue,
alignment: titleAlignment,
child: title
);
}
)
)
)
)
)
)
);
}
);
}
return new ClipRect(
child: new Stack(
children: children)
return new ClipRect(
child: new Stack(
children: children)
);
}
);
}
}

float? currentExtent = null,
Widget child = null
) : base(key: key, child: child) {
D.assert(currentExtent != null);
D.assert(child != null);
D.assert(toolbarOpacity != null);
D.assert(minExtent != null && minExtent >= 0);
D.assert(maxExtent != null && maxExtent >= 0);
D.assert(currentExtent != null && currentExtent >= 0);
D.assert(toolbarOpacity >= 0.0);
D.assert(minExtent <= maxExtent);
D.assert(minExtent <= currentExtent);
D.assert(currentExtent <= maxExtent);
this.toolbarOpacity = toolbarOpacity;
this.minExtent = minExtent;
this.maxExtent = maxExtent;

179
com.unity.uiwidgets/Runtime/material/floating_action_button.cs


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

using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
static class FloatActionButtonUtils {
public partial class material_ {
public static readonly BoxConstraints _kSizeConstraints = BoxConstraints.tightFor(width: 56.0f, height: 56.0f);
public static readonly BoxConstraints _kMiniSizeConstraints =

}
public class FloatingActionButton : StatelessWidget {
FloatingActionButton(
public FloatingActionButton(
Color focusColor = null,
Color hoverColor = null,
Color splashColor = null,
float? focusElevation = null,
float? hoverElevation = null,
float? highlightElevation = null,
float? disabledElevation = null,
VoidCallback onPressed = null,

FocusNode focusNode = null,
bool autofocus = false,
D.assert(focusElevation == null || focusElevation >= 0.0);
D.assert(hoverElevation == null || hoverElevation >= 0.0);
D.assert(highlightElevation == null || highlightElevation >= 0.0f);
D.assert(disabledElevation == null || disabledElevation >= 0.0f);
heroTag = heroTag ?? new _DefaultHeroTag();

this.backgroundColor = backgroundColor;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.splashColor = splashColor;
this.focusElevation = focusElevation;
this.hoverElevation = hoverElevation;
this.focusNode = focusNode;
this.autofocus = autofocus;
? FloatActionButtonUtils._kMiniSizeConstraints
: FloatActionButtonUtils._kSizeConstraints);
}
public FloatingActionButton(
Key key = null,
Widget child = null,
string tooltip = null,
Color foregroundColor = null,
Color backgroundColor = null,
object heroTag = null,
float elevation = 6.0f,
float highlightElevation = 12.0f,
VoidCallback onPressed = null,
bool mini = false,
ShapeBorder shape = null,
Clip clipBehavior = Clip.none,
MaterialTapTargetSize? materialTapTargetSize = null,
bool isExtended = false
) : this(key: key,
child: child,
tooltip: tooltip,
foregroundColor: foregroundColor,
backgroundColor: backgroundColor,
heroTag: heroTag,
elevation: elevation,
highlightElevation: highlightElevation,
onPressed: onPressed,
mini: mini,
shape: shape,
clipBehavior: clipBehavior,
materialTapTargetSize: materialTapTargetSize,
isExtended: isExtended,
_sizeConstraints: null) {
? material_._kMiniSizeConstraints
: material_._kSizeConstraints);
}
public static FloatingActionButton extended(

Color backgroundColor = null,
Color focusColor = null,
Color hoverColor = null,
float? focusElevation = null,
float? hoverElevation = null,
float? splashColor = null,
float? highlightElevation = null,
float? disabledElevation = null,
VoidCallback onPressed = null,

Clip clipBehavior = Clip.none,
FocusNode focusNode = null,
bool autofocus = false,
D.assert(focusElevation == null || focusElevation >= 0.0);
D.assert(hoverElevation == null || hoverElevation >= 0.0);
BoxConstraints _sizeConstraints = FloatActionButtonUtils._kExtendedSizeConstraints;
BoxConstraints _sizeConstraints = material_._kExtendedSizeConstraints;
bool mini = false;
Widget child = new _ChildOverflowBox(
child: new Row(

public readonly Color backgroundColor;
public readonly Color focusColor;
public readonly Color hoverColor;
public readonly Color splashColor;
public readonly object heroTag;
public readonly VoidCallback onPressed;

public readonly float? focusElevation;
public readonly float? hoverElevation;
public readonly float? highlightElevation;
public readonly float? disabledElevation;

public readonly bool isExtended;
public readonly FocusNode focusNode;
public readonly bool autofocus;
const float _defaultFocusElevation = 8;
const float _defaultHoverElevation = 10;
const float _defaultElevation = 6;
const float _defaultHighlightElevation = 12;
readonly ShapeBorder _defaultShape = new CircleBorder();

ThemeData theme = Theme.of(context);
FloatingActionButtonThemeData floatingActionButtonTheme = theme.floatingActionButtonTheme;
if (this.foregroundColor == null && floatingActionButtonTheme.foregroundColor == null) {
bool accentIsDark = theme.accentColorBrightness == Brightness.dark;
Color defaultAccentIconThemeColor = accentIsDark ? Colors.white : Colors.black;
if (theme.accentIconTheme.color != defaultAccentIconThemeColor) {
Debug.Log(
"Warning: " +
"The support for configuring the foreground color of " +
"FloatingActionButtons using ThemeData.accentIconTheme " +
"has been deprecated. Please use ThemeData.floatingActionButtonTheme " +
"instead. "
);
}
}
Color foregroundColor = this.foregroundColor
?? floatingActionButtonTheme.foregroundColor
?? theme.colorScheme.onSecondary;
Color foregroundColor = this.foregroundColor
?? floatingActionButtonTheme.foregroundColor
?? theme.accentIconTheme.color
?? theme.colorScheme.onSecondary;
Color focusColor = this.focusColor
?? floatingActionButtonTheme.focusColor
?? theme.focusColor;
Color hoverColor = this.hoverColor
?? floatingActionButtonTheme.hoverColor
?? theme.hoverColor;
Color splashColor = this.splashColor
?? floatingActionButtonTheme.splashColor
?? theme.splashColor;
float focusElevation = this.focusElevation
?? floatingActionButtonTheme.focusElevation
?? _defaultFocusElevation;
float hoverElevation = this.hoverElevation
?? floatingActionButtonTheme.hoverElevation
?? _defaultHoverElevation;
TextStyle textStyle = theme.accentTextTheme.button.copyWith(
TextStyle textStyle = theme.textTheme.button.copyWith(
color: foregroundColor,
letterSpacing: 1.2f
);

Widget result = null;
if (child != null) {
result = IconTheme.merge(
data: new IconThemeData(
color: foregroundColor),
child: child
);
}
result = new RawMaterialButton(
Widget result = new RawMaterialButton(
focusElevation: focusElevation,
hoverElevation: hoverElevation,
focusColor: focusColor,
hoverColor: hoverColor,
splashColor: splashColor,
child: result);
focusNode: focusNode,
autofocus: autofocus,
child: child
);
child: result);
child: result
);
child: result);
child: result
);
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new ObjectFlagProperty<VoidCallback>("onPressed", onPressed, ifNull: "disabled"));
properties.add(new StringProperty("tooltip", tooltip, defaultValue: null));
properties.add(new ColorProperty("foregroundColor", foregroundColor, defaultValue: null));
properties.add(new ColorProperty("backgroundColor", backgroundColor, defaultValue: null));
properties.add(new ColorProperty("focusColor", focusColor, defaultValue: null));
properties.add(new ColorProperty("hoverColor", hoverColor, defaultValue: null));
properties.add(new ColorProperty("splashColor", splashColor, defaultValue: null));
properties.add(new ObjectFlagProperty<object>("heroTag", heroTag, ifPresent: "hero"));
properties.add(new FloatProperty("elevation", elevation, defaultValue: null));
properties.add(new FloatProperty("focusElevation", focusElevation, defaultValue: null));
properties.add(new FloatProperty("hoverElevation", hoverElevation, defaultValue: null));
properties.add(new FloatProperty("highlightElevation", highlightElevation, defaultValue: null));
properties.add(new FloatProperty("disabledElevation", disabledElevation, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null));
properties.add(new DiagnosticsProperty<FocusNode>("focusNode", focusNode, defaultValue: null));
properties.add(new FlagProperty("isExtended", value: isExtended, ifTrue: "extended"));
properties.add(new DiagnosticsProperty<MaterialTapTargetSize?>("materialTapTargetSize",
materialTapTargetSize, defaultValue: null));
}
}
class _ChildOverflowBox : SingleChildRenderObjectWidget {

}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
if (renderObject is _RenderChildOverflowBox renderChildOverflowBox) {
renderChildOverflowBox.textDirection = Directionality.of(context);
}
}
}

}
protected override void performLayout() {
BoxConstraints constraints = this.constraints;
if (child != null) {
child.layout(new BoxConstraints(), parentUsesSize: true);
size = new Size(

35
com.unity.uiwidgets/Runtime/material/floating_action_button_location.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
public static class FloatingActionButtonLocationUtils {
public partial class material_ {
public const float kFloatingActionButtonMargin = 16.0f;
public static readonly TimeSpan kFloatingActionButtonSegue = new TimeSpan(0, 0, 0, 0, 200);

public abstract Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry);
public override string ToString() {
return GetType().ToString();
return foundation_.objectRuntimeType(this, "FloatingActionButtonLocation");
}
}

float bottomSheetHeight = scaffoldGeometry.bottomSheetSize.height;
float fabHeight = scaffoldGeometry.floatingActionButtonSize.height;
float snackBarHeight = scaffoldGeometry.snackBarSize.height;
float fabY = contentBottom - fabHeight - FloatingActionButtonLocationUtils.kFloatingActionButtonMargin;
float fabY = contentBottom - fabHeight - material_.kFloatingActionButtonMargin;
FloatingActionButtonLocationUtils.kFloatingActionButtonMargin);
material_.kFloatingActionButtonMargin);
}
if (bottomSheetHeight > 0.0f) {

}
public override Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
float fabX = FloatingActionButtonLocationUtils._endOffset(scaffoldGeometry);
float fabX = material_._endOffset(scaffoldGeometry);
float contentBottom = scaffoldGeometry.contentBottom;
float bottomSheetHeight = scaffoldGeometry.bottomSheetSize.height;

float fabY = contentBottom - fabHeight - FloatingActionButtonLocationUtils.kFloatingActionButtonMargin;
float fabY = contentBottom - fabHeight - material_.kFloatingActionButtonMargin;
FloatingActionButtonLocationUtils.kFloatingActionButtonMargin);
material_.kFloatingActionButtonMargin);
}
if (bottomSheetHeight > 0.0f) {

if (snackBarHeight > 0.0f) {
fabY = Mathf.Min(fabY,
contentBottom - snackBarHeight - fabHeight -
FloatingActionButtonLocationUtils.kFloatingActionButtonMargin);
material_.kFloatingActionButtonMargin);
}
if (bottomSheetHeight > 0.0f) {

}
public override Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
float fabX = FloatingActionButtonLocationUtils._endOffset(scaffoldGeometry);
float fabX = material_._endOffset(scaffoldGeometry);
return new Offset(fabX, getDockedY(scaffoldGeometry));
}

}
public override Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
return new Offset(FloatingActionButtonLocationUtils._startOffset(scaffoldGeometry),
FloatingActionButtonLocationUtils._straddleAppBar(scaffoldGeometry));
return new Offset(material_._startOffset(scaffoldGeometry),
material_._straddleAppBar(scaffoldGeometry));
}
public override string ToString() {

}
public override Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
return new Offset(FloatingActionButtonLocationUtils._startOffset(scaffoldGeometry, offset: 4.0f),
FloatingActionButtonLocationUtils._straddleAppBar(scaffoldGeometry));
return new Offset(material_._startOffset(scaffoldGeometry, offset: 4.0f),
material_._straddleAppBar(scaffoldGeometry));
}
public override string ToString() {

}
public override Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
return new Offset(FloatingActionButtonLocationUtils._endOffset(scaffoldGeometry),
FloatingActionButtonLocationUtils._straddleAppBar(scaffoldGeometry));
return new Offset(material_._endOffset(scaffoldGeometry),
material_._straddleAppBar(scaffoldGeometry));
}
public override string ToString() {

}
public override string ToString() {
return GetType().ToString();
return foundation_.objectRuntimeType(this, "FloatingActionButtonAnimator");
}
}

}
static readonly Animatable<float> _rotationTween = new FloatTween(
begin: 1.0f - FloatingActionButtonLocationUtils.kFloatingActionButtonTurnInterval * 2.0f,
begin: 1.0f - material_.kFloatingActionButtonTurnInterval * 2.0f,
end: 1.0f
);

114
com.unity.uiwidgets/Runtime/material/floatting_action_button_theme.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using UnityEngine;

public class FloatingActionButtonThemeData : Diagnosticable {
public class FloatingActionButtonThemeData : Diagnosticable, IEquatable<FloatingActionButtonThemeData> {
Color backgroundColor = null,
Color backgroundColor = null,
Color focusColor = null,
Color hoverColor = null,
Color splashColor = null,
float? focusElevation = null,
float? hoverElevation = null,
this.foregroundColor = foregroundColor;
this.foregroundColor = foregroundColor;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.splashColor = splashColor;
this.focusElevation = focusElevation;
this.hoverElevation = hoverElevation;
public readonly Color foregroundColor;
public readonly Color foregroundColor;
public readonly Color focusColor;
public readonly Color hoverColor;
public readonly Color splashColor;
public readonly float? focusElevation;
public readonly float? hoverElevation;
public readonly float? disabledElevation;

public FloatingActionButtonThemeData copyWith(
Color backgroundColor,
Color foregroundColor,
float? elevation,
float? disabledElevation,
float? highlightElevation,
ShapeBorder shape
Color foregroundColor = null,
Color backgroundColor = null,
Color focusColor = null,
Color hoverColor = null,
Color splashColor = null,
float? elevation = null,
float? focusElevation = null,
float? hoverElevation = null,
float? disabledElevation = null,
float? highlightElevation = null,
ShapeBorder shape = null
foregroundColor: foregroundColor ?? this.foregroundColor,
foregroundColor: foregroundColor ?? this.foregroundColor,
focusColor: focusColor ?? this.focusColor,
hoverColor: hoverColor ?? this.hoverColor,
splashColor: splashColor ?? this.splashColor,
focusElevation: focusElevation ?? this.focusElevation,
hoverElevation: hoverElevation ?? this.hoverElevation,
disabledElevation: disabledElevation ?? this.disabledElevation,
highlightElevation: highlightElevation ?? this.highlightElevation,
shape: shape ?? this.shape

public static FloatingActionButtonThemeData lerp(FloatingActionButtonThemeData a, FloatingActionButtonThemeData b,
public static FloatingActionButtonThemeData lerp(FloatingActionButtonThemeData a,
FloatingActionButtonThemeData b,
float t) {
if (a == null && b == null) {
return null;

backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
focusColor: Color.lerp(a?.focusColor, b?.focusColor, t),
hoverColor: Color.lerp(a?.hoverColor, b?.hoverColor, t),
splashColor: Color.lerp(a?.splashColor, b?.splashColor, t),
focusElevation: Mathf.Lerp(a?.focusElevation ?? 0, b?.focusElevation ?? 0, t),
hoverElevation: Mathf.Lerp(a?.hoverElevation ?? 0, b?.hoverElevation ?? 0, t),
disabledElevation: Mathf.Lerp(a?.disabledElevation ?? 0, b?.disabledElevation ?? 0, t),
highlightElevation: Mathf.Lerp(a?.highlightElevation ?? 0, b?.highlightElevation ?? 0, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t)

public override int GetHashCode() {
var hashCode = backgroundColor?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ foregroundColor?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ elevation?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ disabledElevation?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ highlightElevation?.GetHashCode() ?? 0;
hashCode = (hashCode * 397) ^ shape?.GetHashCode() ?? 0;
var hashCode = (foregroundColor != null ? foregroundColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (backgroundColor != null ? backgroundColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (focusColor != null ? focusColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (hoverColor != null ? hoverColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (splashColor != null ? splashColor.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ elevation.GetHashCode();
hashCode = (hashCode * 397) ^ focusElevation.GetHashCode();
hashCode = (hashCode * 397) ^ hoverElevation.GetHashCode();
hashCode = (hashCode * 397) ^ disabledElevation.GetHashCode();
hashCode = (hashCode * 397) ^ highlightElevation.GetHashCode();
hashCode = (hashCode * 397) ^ (shape != null ? shape.GetHashCode() : 0);
return hashCode;
}

return true;
}
return Equals(backgroundColor, other.backgroundColor)
&& Equals(elevation, other.elevation)
&& Equals(shape, other.shape)
&& Equals(foregroundColor, other.foregroundColor)
&& Equals(disabledElevation, other.disabledElevation)
&& Equals(highlightElevation, other.highlightElevation);
return Equals(foregroundColor, other.foregroundColor) && Equals(backgroundColor, other.backgroundColor) &&
Equals(focusColor, other.focusColor) && Equals(hoverColor, other.hoverColor) &&
Equals(splashColor, other.splashColor) && Nullable.Equals(elevation, other.elevation) &&
Nullable.Equals(focusElevation, other.focusElevation) &&
Nullable.Equals(hoverElevation, other.hoverElevation) &&
Nullable.Equals(disabledElevation, other.disabledElevation) &&
Nullable.Equals(highlightElevation, other.highlightElevation) && Equals(shape, other.shape);
public override bool Equals(object obj) {
if (ReferenceEquals(null, obj)) {

base.debugFillProperties(properties);
FloatingActionButtonThemeData defaultData = new FloatingActionButtonThemeData();
properties.add(new DiagnosticsProperty<Color>("backgroundColor", backgroundColor,
defaultValue: defaultData.backgroundColor));
properties.add(new DiagnosticsProperty<Color>("foregroundColor", foregroundColor,
properties.add(new ColorProperty("foregroundColor", foregroundColor,
properties.add(new DiagnosticsProperty<float?>("elevation", elevation,
defaultValue: defaultData.elevation));
properties.add(new DiagnosticsProperty<float?>("disabledElevation", disabledElevation,
properties.add(new ColorProperty("backgroundColor", backgroundColor,
defaultValue: defaultData.backgroundColor));
properties.add(new ColorProperty("focusColor", focusColor, defaultValue: defaultData.focusColor));
properties.add(new ColorProperty("hoverColor", hoverColor, defaultValue: defaultData.hoverColor));
properties.add(new ColorProperty("splashColor", splashColor, defaultValue: defaultData.splashColor));
properties.add(new FloatProperty("elevation", elevation, defaultValue: defaultData.elevation));
properties.add(
new FloatProperty("focusElevation", focusElevation, defaultValue: defaultData.focusElevation));
properties.add(
new FloatProperty("hoverElevation", hoverElevation, defaultValue: defaultData.hoverElevation));
properties.add(new FloatProperty("disabledElevation", disabledElevation,
properties.add(new DiagnosticsProperty<float?>("highlightElevation", highlightElevation,
properties.add(new FloatProperty("highlightElevation", highlightElevation,
defaultValue: defaultData.highlightElevation));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: defaultData.shape));
}

74
com.unity.uiwidgets/Runtime/material/icon_button.cs


using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
static class IconButtonUtils {
public const float _kMinButtonSize = 48.0f;
public partial class material_ {
public const float _kMinButtonSize = kMinInteractiveDimension;
}

float iconSize = 24.0f,
VisualDensity visualDensity = null,
Color focusColor = null,
Color hoverColor = null,
Color disableColor = null,
Color disabledColor = null,
string tooltip = null) : base(key: key) {
FocusNode focusNode = null,
bool autofocus = false,
string tooltip = null,
bool? enableFeedback = true,
BoxConstraints constraints = null
) : base(key: key) {
this.visualDensity = visualDensity;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
disabledColor = disableColor;
this.disabledColor = disabledColor;
this.focusNode = focusNode;
this.autofocus = autofocus;
this.enableFeedback = enableFeedback;
this.constraints = constraints;
public readonly VisualDensity visualDensity;
public readonly EdgeInsets padding;

public readonly Color focusColor;
public readonly Color hoverColor;
public readonly Color color;
public readonly Color splashColor;

public readonly VoidCallback onPressed;
public readonly FocusNode focusNode;
public readonly bool autofocus;
public readonly bool? enableFeedback;
public readonly BoxConstraints constraints;
ThemeData theme = Theme.of(context);
Color currentColor;
if (onPressed != null) {
currentColor = color;

}
VisualDensity effectiveVisualDensity = visualDensity ?? theme.visualDensity;
BoxConstraints unadjustedConstraints = constraints ?? new BoxConstraints(
minWidth: material_._kMinButtonSize,
minHeight: material_._kMinButtonSize
);
BoxConstraints adjustedConstraints = effectiveVisualDensity.effectiveConstraints(unadjustedConstraints);
constraints: new BoxConstraints(minWidth: IconButtonUtils._kMinButtonSize,
minHeight: IconButtonUtils._kMinButtonSize),
constraints: adjustedConstraints,
child: new Padding(
padding: padding,
child: new SizedBox(

child: IconTheme.merge(
data: new IconThemeData(
size: iconSize,
color: currentColor),
child: icon)
color: currentColor
),
child: icon
)
)
)
)

}
return new InkResponse(
focusNode: focusNode,
autofocus: autofocus,
canRequestFocus: onPressed != null,
enableFeedback: enableFeedback ?? false,
focusColor: focusColor ?? Theme.of(context).focusColor,
hoverColor: hoverColor ?? Theme.of(context).hoverColor,
highlightColor: highlightColor ?? Theme.of(context).highlightColor,
splashColor: splashColor ?? Theme.of(context).splashColor,
radius: Mathf.Max(

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<Widget>("icon", icon, showName: false));
properties.add(new StringProperty("tooltip", tooltip, defaultValue: null, quoted: false));
properties.add(new ColorProperty("color", color, defaultValue: null));
properties.add(new ColorProperty("disabledColor", disabledColor, defaultValue: null));
properties.add(new ColorProperty("focusColor", focusColor, defaultValue: null));
properties.add(new ColorProperty("hoverColor", hoverColor, defaultValue: null));
properties.add(new ColorProperty("highlightColor", highlightColor, defaultValue: null));
properties.add(new ColorProperty("splashColor", splashColor, defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsetsGeometry>("padding", padding, defaultValue: null));
properties.add(new DiagnosticsProperty<FocusNode>("focusNode", focusNode, defaultValue: null));
}
}
}

61
com.unity.uiwidgets/Runtime/material/input_border.cs


}
Path _gapBorderPath(Canvas canvas, RRect center, float start, float extent) {
RRect scaledRRect = center.scaleRadii();
center.left,
center.top,
center.tlRadiusX * 2.0f,
center.tlRadiusY * 2.0f
scaledRRect.left,
scaledRRect.top,
scaledRRect.tlRadiusX * 2.0f,
scaledRRect.tlRadiusY * 2.0f
center.right - center.trRadiusX * 2.0f,
center.top,
center.trRadiusX * 2.0f,
center.trRadiusY * 2.0f
scaledRRect.right - scaledRRect.trRadiusX * 2.0f,
scaledRRect.top,
scaledRRect.trRadiusX * 2.0f,
scaledRRect.trRadiusY * 2.0f
center.right - center.brRadiusX * 2.0f,
center.bottom - center.brRadiusY * 2.0f,
center.brRadiusX * 2.0f,
center.brRadiusY * 2.0f
scaledRRect.right - scaledRRect.brRadiusX * 2.0f,
scaledRRect.bottom - scaledRRect.brRadiusY * 2.0f,
scaledRRect.brRadiusX * 2.0f,
scaledRRect.brRadiusY * 2.0f
center.left,
center.bottom - center.brRadiusY * 2.0f,
center.blRadiusX * 2.0f,
center.blRadiusY * 2.0f
scaledRRect.left,
scaledRRect.bottom - scaledRRect.brRadiusY * 2.0f,
scaledRRect.blRadiusX * 2.0f,
scaledRRect.blRadiusY * 2.0f
float tlCornerArcSweep = start < center.tlRadiusX
? Mathf.Asin((start / center.tlRadiusX).clamp(-1.0f, 1.0f))
float tlCornerArcSweep = start < scaledRRect.tlRadiusX
? Mathf.Asin((start / scaledRRect.tlRadiusX).clamp(-1.0f, 1.0f))
path.moveTo(center.left + center.tlRadiusX, center.top);
path.moveTo(scaledRRect.left + scaledRRect.tlRadiusX, scaledRRect.top);
if (start > center.tlRadiusX) {
path.lineTo(center.left + start, center.top);
if (start > scaledRRect.tlRadiusX) {
path.lineTo(scaledRRect.left + start, scaledRRect.top);
if (start + extent < center.width - center.trRadiusX) {
if (start + extent < scaledRRect.width - scaledRRect.trRadiusX) {
path.lineTo(center.right - center.trRadiusX, center.top);
path.lineTo(scaledRRect.right - scaledRRect.trRadiusX, scaledRRect.top);
else if (start + extent < center.width) {
float dx = center.width - (start + extent);
float sweep = Mathf.Acos(dx / center.trRadiusX);
else if (start + extent < scaledRRect.width) {
float dx = scaledRRect.width - (start + extent);
float sweep = Mathf.Acos(dx / scaledRRect.trRadiusX);
path.moveTo(center.right, center.top + center.trRadiusY);
path.lineTo(center.right, center.bottom - center.brRadiusY);
path.moveTo(scaledRRect.right, scaledRRect.top + scaledRRect.trRadiusY);
path.lineTo(scaledRRect.right, scaledRRect.bottom - scaledRRect.brRadiusY);
path.lineTo(center.left + center.blRadiusX, center.bottom);
path.lineTo(scaledRRect.left + scaledRRect.blRadiusX, scaledRRect.bottom);
path.lineTo(center.left, center.top + center.trRadiusY);
path.lineTo(scaledRRect.left, scaledRRect.top + scaledRRect.trRadiusY);
return path;
}

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


drawer
}
public class ListTileTheme : InheritedWidget {
public class ListTileTheme : InheritedTheme {
public ListTileTheme(
Key key = null,
bool dense = false,

public readonly EdgeInsets contentPadding;
public static ListTileTheme of(BuildContext context) {
ListTileTheme result = (ListTileTheme) context.inheritFromWidgetOfExactType(typeof(ListTileTheme));
ListTileTheme result = context.dependOnInheritedWidgetOfExactType<ListTileTheme>();
public override Widget wrap(BuildContext context, Widget child) {
ListTileTheme ancestorTheme = context.findAncestorWidgetOfExactType<ListTileTheme>();
return ReferenceEquals(this, ancestorTheme)
? child
: new ListTileTheme(
dense: dense,
style: style,
selectedColor: selectedColor,
iconColor: iconColor,
textColor: textColor,
contentPadding: contentPadding,
child: child
);
}
public override bool updateShouldNotify(InheritedWidget oldWidget) {
ListTileTheme _oldWidget = (ListTileTheme) oldWidget;
return dense != _oldWidget.dense ||

}
bool _isDenseLayout(ListTileTheme tileTheme) {
return dense != null ? dense ?? false : (tileTheme?.dense ?? false);
return dense ?? tileTheme?.dense ?? false;
}
TextStyle _titleTextStyle(ThemeData theme, ListTileTheme tileTheme) {

case ListTileStyle.drawer:
style = theme.textTheme.body2;
style = theme.textTheme.bodyText1;
style = theme.textTheme.subhead;
style = theme.textTheme.subtitle1;
style = theme.textTheme.subhead;
style = theme.textTheme.subtitle1;
}
Color color = _textColor(theme, tileTheme, style.color);

}
TextStyle _subtitleTextStyle(ThemeData theme, ListTileTheme tileTheme) {
TextStyle style = theme.textTheme.body1;
TextStyle style = theme.textTheme.bodyText2;
Color color = _textColor(theme, tileTheme, theme.textTheme.caption.color);
return _isDenseLayout(tileTheme)
? style.copyWith(color: color, fontSize: 12.0f)

return new InkWell(
onTap: enabled ? onTap : null,
onLongPress: enabled ? onLongPress : null,
canRequestFocus: enabled,
child: new SafeArea(
top: false,
bottom: false,

_ListTileSlot slot = childToSlot[child];
childToSlot.Remove(child);
slotToChild.Remove(slot);
base.forgetChild(child);
}
void _mountChild(Widget widget, _ListTileSlot slot) {

_updateChild(widget.trailing, _ListTileSlot.trailing);
}
void _updateRenderObject(RenderObject child, _ListTileSlot slot) {
void _updateRenderObject(RenderBox child, _ListTileSlot slot) {
switch (slot) {
case _ListTileSlot.leading:
renderObject.leading = (RenderBox) child;

D.assert(child is RenderBox);
D.assert(slotValue is _ListTileSlot);
_ListTileSlot slot = (_ListTileSlot) slotValue;
_updateRenderObject(child, slot);
_updateRenderObject((RenderBox) child, slot);
D.assert(renderObject.childToSlot.Keys.Contains(child));
D.assert(renderObject.slotToChild.Keys.Contains(slot));
}

}
protected override void performLayout() {
BoxConstraints constraints = this.constraints;
bool hasLeading = leading != null;
bool hasSubtitle = subtitle != null;
bool hasTrailing = trailing != null;

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


public static MaterialInkController of(BuildContext context) {
_RenderInkFeatures result =
(_RenderInkFeatures) context.ancestorRenderObjectOfType(new TypeMatcher<_RenderInkFeatures>());
(_RenderInkFeatures) context.findAncestorRenderObjectOfType<_RenderInkFeatures>();
return result;
}

base.debugFillProperties(properties);
properties.add(new EnumProperty<MaterialType>("type", type));
properties.add(new FloatProperty("elevation", elevation, defaultValue: 0.0f));
properties.add(new DiagnosticsProperty<Color>("color", color, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("shadowColor", shadowColor,
defaultValue: new Color(0xFF000000)));
properties.add(new ColorProperty("color", color, defaultValue: null));
properties.add(new ColorProperty("shadowColor", shadowColor, defaultValue: new Color(0xFF000000)));
textStyle?.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null));
properties.add(new DiagnosticsProperty<bool>("borderOnForeground", borderOnForeground,

readonly GlobalKey _inkFeatureRenderer = GlobalKey.key(debugLabel: "ink renderer");
Color _getBackgroundColor(BuildContext context) {
if (widget.color != null) {
return widget.color;
ThemeData theme = Theme.of(context);
Color color = widget.color;
if (color == null) {
switch (widget.type) {
case MaterialType.canvas:
color = theme.canvasColor;
break;
case MaterialType.card:
color = theme.cardColor;
break;
default:
break;
}
switch (widget.type) {
case MaterialType.canvas:
return Theme.of(context).canvasColor;
case MaterialType.card:
return Theme.of(context).cardColor;
default:
return null;
}
return color;
}
public override Widget build(BuildContext context) {

Widget contents = widget.child;
if (contents != null) {
contents = new AnimatedDefaultTextStyle(
style: widget.textStyle ?? Theme.of(context).textTheme.body1,
style: widget.textStyle ?? Theme.of(context).textTheme.bodyText2,
duration: widget.animationDuration,
child: contents
);

_RenderInkFeatures renderer =
(_RenderInkFeatures) _inkFeatureRenderer.currentContext.findRenderObject();
renderer._didChangeLayout();
return true;
return false;
},
child: new _InkFeatures(
key: _inkFeatureRenderer,

clipBehavior: widget.clipBehavior,
borderRadius: BorderRadius.zero,
elevation: widget.elevation,
color: backgroundColor,
color: ElevationOverlay.applyOverlay(context, backgroundColor, widget.elevation),
shadowColor: widget.shadowColor,
animateColor: false,
child: contents

get { return _controller; }
}
public _RenderInkFeatures _controller;
public readonly _RenderInkFeatures _controller;
public readonly RenderBox referenceBox;

base.debugFillProperties(description);
description.add(new DiagnosticsProperty<ShapeBorder>("shape", shape));
description.add(new FloatProperty("elevation", elevation));
description.add(new DiagnosticsProperty<Color>("color", color));
description.add(new DiagnosticsProperty<Color>("shadowColor", shadowColor));
description.add(new ColorProperty("color", color));
description.add(new ColorProperty("shadowColor", shadowColor));
}
}

public override Widget build(BuildContext context) {
ShapeBorder shape = _border.evaluate(animation);
float elevation = _elevation.evaluate(animation);
return new PhysicalShape(
child: new _ShapeBorderPaint(
child: widget.child,

shape: shape),
clipBehavior: widget.clipBehavior,
elevation: _elevation.evaluate(animation),
color: widget.color,
color: ElevationOverlay.applyOverlay(context, widget.color, elevation),
shadowColor: _shadowColor.evaluate(animation)
);
}

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


}
static MaterialStateColor resolveWith(material_.MaterialPropertyResolver<Color> callback) =>
new material._MaterialStateColor(callback);
new _MaterialStateColor(callback);
public abstract Color resolve(HashSet<MaterialState> states);

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


_children.AddRange(widget.children);
for (int i = 0; i < _children.Count; i++) {
if (_children[i] is MaterialGap) {
MergeableMaterialItem child = _children[i];
if (child is MaterialGap) {
_animationTuples[_children[i].key].controller.setValue(1.0f);
_animationTuples[child.key].controller.setValue(1.0f);
}
}

float gapSizeSum = 0.0f;
while (startOld < j) {
if (_children[startOld] is MaterialGap) {
MaterialGap gap = (MaterialGap) _children[startOld];
MergeableMaterialItem child = _children[startOld];
if (child is MaterialGap materialGap) {
MaterialGap gap = materialGap;
gapSizeSum += gap.size;
}

float gapSizeSum = 0.0f;
for (int k = startNew; k < i; k++) {
if (newChildren[k] is MaterialGap) {
MaterialGap gap = (MaterialGap) newChildren[k];
gapSizeSum += gap.size;
MergeableMaterialItem newChild = newChildren[k];
if (newChild is MaterialGap materialGap) {
gapSizeSum += materialGap.size;
if (newChildren[k] is MaterialGap) {
MaterialGap gap = (MaterialGap) newChildren[k];
_animationTuples[gap.key].gapStart = gapSize * gap.size / gapSizeSum;
_animationTuples[gap.key].controller.setValue(0.0f);
_animationTuples[gap.key].controller.forward();
MergeableMaterialItem newChild = newChildren[k];
if (newChild is MaterialGap materialGap) {
_animationTuples[materialGap.key].gapStart =
gapSize * materialGap.size / gapSizeSum;
_animationTuples[materialGap.key].controller.setValue(0.0f);
_animationTuples[materialGap.key].controller.forward();
}
}
}

_insertChild(startOld + k, newChildren[startNew + k]);
MergeableMaterialItem newChild = newChildren[startNew + k];
_insertChild(startOld + k, newChild);
if (newChildren[startNew + k] is MaterialGap) {
MaterialGap gap = (MaterialGap) newChildren[startNew + k];
if (newChild is MaterialGap gap) {
_animationTuples[gap.key].controller.forward();
}
}

float gapSizeSum = 0.0f;
while (startOld < j) {
if (_children[startOld] is MaterialGap) {
MaterialGap gap = (MaterialGap) _children[startOld];
gapSizeSum += gap.size;
MergeableMaterialItem child = _children[startOld];
if (child is MaterialGap materialGap) {
gapSizeSum += materialGap.size;
}
_removeChild(startOld);

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


public OutlineButton(
Key key = null,
VoidCallback onPressed = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
Color highlightColor = null,
Color splashColor = null,
float? highlightElevation = null,

EdgeInsets padding = null,
VisualDensity visualDensity = null,
FocusNode focusNode = null,
bool autofocus = false,
onLongPress: onLongPress,
focusColor: focusColor,
hoverColor: hoverColor,
visualDensity: visualDensity,
focusNode: focusNode,
autofocus: autofocus,
child: child
) {
D.assert(highlightElevation == null || highlightElevation >= 0.0f);

public static OutlineButton icon(
Key key = null,
VoidCallback onPressed = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
Color highlightColor = null,
Color splashColor = null,
float? highlightElevation = null,

EdgeInsets padding = null,
VisualDensity visualDensity = null,
FocusNode focusNode = null,
bool autofocus = false,
key,
onPressed,
textTheme,
textColor,
disabledTextColor,
color,
highlightColor,
splashColor,
highlightElevation,
highlightedBorderColor,
disabledBorderColor,
borderSide,
padding,
shape,
clipBehavior,
icon,
label
key: key,
onPressed: onPressed,
onLongPress: onLongPress,
textTheme: textTheme,
textColor: textColor,
disabledTextColor: disabledTextColor,
color: color,
focusColor: focusColor,
hoverColor: hoverColor,
highlightColor: highlightColor,
splashColor: splashColor,
highlightElevation: highlightElevation,
highlightedBorderColor: highlightedBorderColor,
disabledBorderColor: disabledBorderColor,
borderSide: borderSide,
padding: padding,
visualDensity: visualDensity,
shape: shape,
clipBehavior: clipBehavior,
focusNode: focusNode,
autofocus: autofocus,
label: label
);
}

ButtonThemeData buttonTheme = ButtonTheme.of(context);
return new _OutlineButton(
onPressed: onPressed,
onLongPress: onLongPress,
focusColor: buttonTheme.getFocusColor(this),
hoverColor: buttonTheme.getHoverColor(this),
highlightColor: buttonTheme.getHighlightColor(this),
splashColor: buttonTheme.getSplashColor(this),
highlightElevation: buttonTheme.getHighlightElevation(this),

padding: buttonTheme.getPadding(this),
visualDensity: visualDensity,
focusNode: focusNode,
child: child
);
}

properties.add(new ObjectFlagProperty<VoidCallback>("onPressed", onPressed, ifNull: "disabled"));
properties.add(new DiagnosticsProperty<ButtonTextTheme?>("textTheme", textTheme, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("textColor", textColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("disabledTextColor", disabledTextColor,
defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("color", color, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("highlightColor", highlightColor, defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("splashColor", splashColor, defaultValue: null));
properties.add(new DiagnosticsProperty<float?>("highlightElevation", highlightElevation,
defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("disabledBorderColor", disabledBorderColor,
defaultValue: null));
properties.add(new DiagnosticsProperty<Color>("highlightedBorderColor", highlightedBorderColor,
defaultValue: null));
properties.add(new DiagnosticsProperty<EdgeInsets>("padding", padding, defaultValue: null));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", shape, defaultValue: null));
properties.add(new ColorProperty("disabledBorderColor", disabledBorderColor, defaultValue: null));
properties.add(new ColorProperty("highlightedBorderColor", highlightedBorderColor, defaultValue: null));
}
}

VoidCallback onPressed = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
Color highlightColor = null,
Color splashColor = null,
float? highlightElevation = null,

EdgeInsets padding = null,
VisualDensity visualDensity = null,
FocusNode focusNode = null,
bool autofocus = false,
Widget icon = null,
Widget label = null
) :

onLongPress: onLongPress,
focusColor: focusColor,
hoverColor: hoverColor,
highlightColor: highlightColor,
splashColor: splashColor,
highlightElevation: highlightElevation,

padding: padding,
visualDensity: visualDensity,
focusNode: focusNode,
autofocus: autofocus,
child: new Row(
mainAxisSize: MainAxisSize.min,
children: new List<Widget> {

public _OutlineButton(
Key key = null,
VoidCallback onPressed = null,
VoidCallback onLongPress = null,
Color focusColor = null,
Color hoverColor = null,
Color highlightColor = null,
Color splashColor = null,
float? highlightElevation = null,

EdgeInsets padding = null,
VisualDensity visualDensity = null,
FocusNode focusNode = null,
bool autofocus = false,
this.onLongPress = onLongPress;
this.focusColor = focusColor;
this.hoverColor = hoverColor;
this.highlightColor = highlightColor;
this.splashColor = splashColor;
this.highlightElevation = highlightElevation;

this.padding = padding;
this.visualDensity = visualDensity;
this.focusNode = focusNode;
this.autofocus = autofocus;
public readonly VoidCallback onLongPress;
public readonly Color focusColor;
public readonly Color hoverColor;
public readonly Color highlightColor;
public readonly Color splashColor;
public readonly float? highlightElevation;

public readonly EdgeInsets padding;
public readonly VisualDensity visualDensity;
public readonly FocusNode focusNode;
public readonly bool autofocus;
get { return onPressed != null; }
get { return onPressed != null || onLongPress != null; }
}
public override State createState() {

return colorTween.evaluate(_fillAnimation);
}
Color _outlineColor {
get {
// TODO: what is the meaning of this line?
if (widget.borderSide?.color is MaterialStateProperty<Color>)
return widget.borderSide.color;
if (!widget.enabled)
return widget.disabledBorderColor;
if (_pressed)
return widget.highlightedBorderColor;
return widget.borderSide?.color;
}
}
BorderSide _getOutline() {
if (widget.borderSide?.style == BorderStyle.none) {
return widget.borderSide;

Color themeColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.12f);
return new BorderSide(
color: specifiedColor ?? themeColor,
color: _outlineColor ?? themeColor,
width: widget.borderSide?.width ?? 1.0f
);
}

}
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
return new AnimatedBuilder(
animation: _controller,
builder: (BuildContext _context, Widget child) => {

color: _getFillColor(),
splashColor: widget.splashColor,
focusColor: widget.focusColor,
hoverColor: widget.hoverColor,
onLongPress: widget.onLongPress,
focusElevation: 0.0f,
hoverElevation: 0.0f,
visualDensity: widget.visualDensity ?? theme.visualDensity,
clipBehavior:
widget.clipBehavior,
clipBehavior: widget.clipBehavior,
focusNode: widget.focusNode,
animationDuration: material_._kElevationDuration,
child:
widget.child

public override int GetHashCode() {
return (shape.GetHashCode() * 397) ^ side.GetHashCode();
}
public ShapeBorder resolve(HashSet<MaterialState> states) {
return new _OutlineBorder(
shape: shape,
side: side.copyWith(color: MaterialStateProperty<Color>.resolveAs(side.color, states)
)
);
}
public static ShapeBorder resolveAs<ShapeBorder>(ShapeBorder value, HashSet<MaterialState> states) {
if (value is MaterialStateProperty<ShapeBorder> materialStateProperty) {
MaterialStateProperty<ShapeBorder> property = materialStateProperty;
return property.resolve(states);
}
return value;
}
public static MaterialStateProperty<ShapeBorder> resolveWith<ShapeBorder>(
material_.MaterialPropertyResolver<ShapeBorder> callback) =>
new _MaterialStateProperty<ShapeBorder>(callback);
}
}

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


get { return null; }
}
public override bool canTransitionFrom(TransitionRoute previousRoute) {
return previousRoute is MaterialPageRoute;
}
public override bool canTransitionTo(TransitionRoute nextRoute) {
return nextRoute is MaterialPageRoute && !((MaterialPageRoute) nextRoute).fullscreenDialog;
}

224
com.unity.uiwidgets/Runtime/material/page_transitions_theme.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.cupertino;
using UnityEngine;
namespace Unity.UIWidgets.material {
public class _FadeUpwardsPageTransition : StatelessWidget {

}
}
class _ZoomPageTransition : StatefulWidget {
internal _ZoomPageTransition(
Key key = null,
Animation<float> animation = null,
Animation<float> secondaryAnimation = null,
Widget child = null
) : base(key: key) {
this.animation = animation;
this.secondaryAnimation = secondaryAnimation;
this.child = child;
}
// The scrim obscures the old page by becoming increasingly opaque.
internal static readonly Tween<float> _scrimOpacityTween = new Tween<float>(
begin: 0.0f,
end: 0.60f
);
// A curve sequence that is similar to the 'fastOutExtraSlowIn' curve used in
// the native transition.
public static readonly List<TweenSequenceItem<float>> fastOutExtraSlowInTweenSequenceItems =
new List<TweenSequenceItem<float>> {
new TweenSequenceItem<float>(
tween: new Tween<float>(begin: 0.0f, end: 0.4f)
.chain(new CurveTween(curve: new Cubic(0.05f, 0.0f, 0.133333f, 0.06f))),
weight: 0.166666f
),
new TweenSequenceItem<float>(
tween: new Tween<float>(begin: 0.4f, end: 1.0f)
.chain(new CurveTween(curve: new Cubic(0.208333f, 0.82f, 0.25f, 1.0f))),
weight: 1.0f - 0.166666f
)
};
internal static readonly TweenSequence<float> _scaleCurveSequence =
new TweenSequence<float>(fastOutExtraSlowInTweenSequenceItems);
internal static readonly FlippedTweenSequence _flippedScaleCurveSequence =
new FlippedTweenSequence(fastOutExtraSlowInTweenSequenceItems);
public readonly Animation<float> animation;
public readonly Animation<float> secondaryAnimation;
public readonly Widget child;
public override State createState() => new __ZoomPageTransitionState();
}
class __ZoomPageTransitionState : State<_ZoomPageTransition> {
AnimationStatus _currentAnimationStatus;
AnimationStatus _lastAnimationStatus;
public override void initState() {
base.initState();
widget.animation.addStatusListener((AnimationStatus animationStatus) => {
_lastAnimationStatus = _currentAnimationStatus;
_currentAnimationStatus = animationStatus;
});
}
// This check ensures that the animation reverses the original animation if
// the transition were interruped midway. This prevents a disjointed
// experience since the reverse animation uses different fade and scaling
// curves.
bool _transitionWasInterrupted {
get {
bool wasInProgress = false;
bool isInProgress = false;
switch (_currentAnimationStatus) {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
isInProgress = false;
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
isInProgress = true;
break;
}
switch (_lastAnimationStatus) {
case AnimationStatus.completed:
case AnimationStatus.dismissed:
wasInProgress = false;
break;
case AnimationStatus.forward:
case AnimationStatus.reverse:
wasInProgress = true;
break;
}
return wasInProgress && isInProgress;
}
}
public override Widget build(BuildContext context) {
Animation<float> _forwardScrimOpacityAnimation = widget.animation.drive(
_ZoomPageTransition._scrimOpacityTween
.chain(new CurveTween(curve: new Interval(0.2075f, 0.4175f))));
Animation<float> _forwardEndScreenScaleTransition = widget.animation.drive(
new Tween<float>(begin: 0.85f, end: 1.00f)
.chain(_ZoomPageTransition._scaleCurveSequence));
Animation<float> _forwardStartScreenScaleTransition = widget.secondaryAnimation.drive(
new Tween<float>(begin: 1.00f, end: 1.05f)
.chain(_ZoomPageTransition._scaleCurveSequence));
Animation<float> _forwardEndScreenFadeTransition = widget.animation.drive(
new Tween<float>(begin: 0.0f, end: 1.00f)
.chain(new CurveTween(curve: new Interval(0.125f, 0.250f))));
Animation<float> _reverseEndScreenScaleTransition = widget.secondaryAnimation.drive(
new Tween<float>(begin: 1.00f, end: 1.10f)
.chain(_ZoomPageTransition._flippedScaleCurveSequence));
Animation<float> _reverseStartScreenScaleTransition = widget.animation.drive(
new Tween<float>(begin: 0.9f, end: 1.0f)
.chain(_ZoomPageTransition._flippedScaleCurveSequence));
Animation<float> _reverseStartScreenFadeTransition = widget.animation.drive(
new Tween<float>(begin: 0.0f, end: 1.00f)
.chain(new CurveTween(curve: new Interval(1 - 0.2075f, 1 - 0.0825f))));
return new AnimatedBuilder(
animation: widget.animation,
builder: (BuildContext _context, Widget child) => {
if (widget.animation.status == AnimationStatus.forward || _transitionWasInterrupted) {
return new Container(
color: Colors.black.withOpacity(_forwardScrimOpacityAnimation.value),
child: new FadeTransition(
opacity: _forwardEndScreenFadeTransition,
child: new ScaleTransition(
scale: _forwardEndScreenScaleTransition,
child: child
)
)
);
}
else if (widget.animation.status == AnimationStatus.reverse) {
return new ScaleTransition(
scale: _reverseStartScreenScaleTransition,
child: new FadeTransition(
opacity: _reverseStartScreenFadeTransition,
child: child
)
);
}
return child;
},
child: new AnimatedBuilder(
animation: widget.secondaryAnimation,
builder: (BuildContext _context, Widget child) => {
if (widget.secondaryAnimation.status == AnimationStatus.forward || _transitionWasInterrupted) {
return new ScaleTransition(
scale: _forwardStartScreenScaleTransition,
child: child
);
}
else if (widget.secondaryAnimation.status == AnimationStatus.reverse) {
return new ScaleTransition(
scale: _reverseEndScreenScaleTransition,
child: child
);
}
return child;
},
child: widget.child
)
);
}
}
public abstract class PageTransitionsBuilder {
public PageTransitionsBuilder() {
}

Widget child);
}
public class ZoomPageTransitionsBuilder : PageTransitionsBuilder {
public ZoomPageTransitionsBuilder() {
}
public override Widget buildTransitions(
PageRoute route,
BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation,
Widget child
) {
return new _ZoomPageTransition(
animation: animation,
secondaryAnimation: secondaryAnimation,
child: child
);
}
}
public class FadeUpwardsPageTransitionsBuilder : PageTransitionsBuilder {
public FadeUpwardsPageTransitionsBuilder() {

}
}
public class CupertinoPageTransitionsBuilder : PageTransitionsBuilder {
public CupertinoPageTransitionsBuilder() {
}
public override Widget buildTransitions(
PageRoute route,
BuildContext context,
Animation<float> animation,
Animation<float> secondaryAnimation,
Widget child
) {
return CupertinoPageRoute.buildPageTransitions(route, context, animation, secondaryAnimation, child);
}
}
static readonly Dictionary<RuntimePlatform, PageTransitionsBuilder> _defaultBuilders =
new Dictionary<RuntimePlatform, PageTransitionsBuilder> {
{RuntimePlatform.Android, new FadeUpwardsPageTransitionsBuilder()},
{RuntimePlatform.IPhonePlayer, new CupertinoPageTransitionsBuilder()},
{RuntimePlatform.LinuxEditor, new FadeUpwardsPageTransitionsBuilder()},
{RuntimePlatform.LinuxPlayer, new FadeUpwardsPageTransitionsBuilder()},
{RuntimePlatform.OSXEditor, new CupertinoPageTransitionsBuilder()},
{RuntimePlatform.OSXPlayer, new CupertinoPageTransitionsBuilder()},
{RuntimePlatform.WindowsEditor, new FadeUpwardsPageTransitionsBuilder()},
{RuntimePlatform.WindowsPlayer, new FadeUpwardsPageTransitionsBuilder()}
};
static PageTransitionsBuilder _defaultBuilder = new FadeUpwardsPageTransitionsBuilder();

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


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

using Unity.UIWidgets.service;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;

namespace Unity.UIWidgets.material {
public static partial class PopupMenuUtils {
public partial class material_ {
internal const float _kBaselineOffsetFromBottom = 20.0f;
internal const float _kMenuItemHeight = 48.0f;
internal const float _kMenuDividerHeight = 16.0f;
internal const float _kMenuMaxWidth = 5.0f * _kMenuWidthStep;
internal const float _kMenuMinWidth = 2.0f * _kMenuWidthStep;

public class PopupMenuDivider : PopupMenuEntry<object> {
public PopupMenuDivider(Key key = null, float height = PopupMenuUtils._kMenuDividerHeight) : base(key: key) {
public PopupMenuDivider(Key key = null, float height = material_._kMenuDividerHeight) : base(key: key) {
_height = height;
}

}
}
class _MenuItem : SingleChildRenderObjectWidget {
internal _MenuItem(
Key key = null,
ValueChanged<Size> onLayout = null,
Widget child = null
) : base(key: key, child: child) {
Debug.Log(onLayout != null);
this.onLayout = onLayout;
}
public readonly ValueChanged<Size> onLayout;
public override RenderObject createRenderObject(BuildContext context) {
return new _RenderMenuItemDuplicated(onLayout);
}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
if (renderObject is _RenderMenuItemDuplicated renderMenuItemDuplicated) {
renderMenuItemDuplicated.onLayout = onLayout;
}
}
}
class _RenderMenuItemDuplicated : RenderShiftedBox {
internal _RenderMenuItemDuplicated(
ValueChanged<Size> onLayout,
RenderBox child = null
) : base(child) {
D.assert(onLayout != null);
this.onLayout = onLayout;
}
public ValueChanged<Size> onLayout;
protected override void performLayout() {
if (child == null) {
size = Size.zero;
}
else {
child.layout(constraints, parentUsesSize: true);
size = constraints.constrain(child.size);
}
BoxParentData childParentData = child.parentData as BoxParentData;
childParentData.offset = Offset.zero;
onLayout(size);
}
}
float height = PopupMenuUtils._kMenuItemHeight,
float height = material_.kMinInteractiveDimension,
TextStyle textStyle = null,
this.textStyle = textStyle;
this.child = child;
}

readonly float _height;
public readonly TextStyle textStyle;
public override float height {
get { return _height; }
}

public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
TextStyle style = theme.textTheme.subhead;
PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context);
TextStyle style = widget.textStyle ?? popupMenuTheme.textStyle ?? theme.textTheme.subtitle1;
if (!widget.enabled) {
style = style.copyWith(color: theme.disabledColor);
}

duration: material_.kThemeChangeDuration,
child: new Baseline(
baseline: widget.height - PopupMenuUtils._kBaselineOffsetFromBottom,
baselineType: style.textBaseline,
child: new Container(
alignment: AlignmentDirectional.centerStart,
constraints: new BoxConstraints(minHeight: widget.height),
padding: EdgeInsets.symmetric(horizontal: material_._kMenuHorizontalPadding),
child: buildChild()
)
);

return new InkWell(
onTap: widget.enabled ? handleTap : (GestureTapCallback) null,
child: new Container(
height: widget.height,
padding: EdgeInsets.symmetric(horizontal: PopupMenuUtils._kMenuHorizontalPadding),
child: item
)
canRequestFocus: widget.enabled,
child: item
);
}
}

public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
TextStyle style = theme.textTheme.subhead;
PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context);
TextStyle style = widget.textStyle ?? popupMenuTheme.textStyle ?? theme.textTheme.subtitle1;
if (!widget.enabled) {
style = style.copyWith(color: theme.disabledColor);
}

duration: material_.kThemeChangeDuration,
child: new Baseline(
baseline: widget.height - PopupMenuUtils._kBaselineOffsetFromBottom,
baselineType: style.textBaseline,
child: new Container(
alignment: AlignmentDirectional.centerStart,
constraints: new BoxConstraints(minHeight: widget.height),
padding: EdgeInsets.symmetric(horizontal: material_._kMenuHorizontalPadding),
child: buildChild()
)
);

return new InkWell(
onTap: widget.enabled ? handleTap : (GestureTapCallback) null,
child: new Container(
height: widget.height,
padding: EdgeInsets.symmetric(horizontal: PopupMenuUtils._kMenuHorizontalPadding),
child: item
)
canRequestFocus: widget.enabled,
child: item
);
}
}

public override Widget build(BuildContext context) {
float unit = 1.0f / (route.items.Count + 1.5f);
List<Widget> children = new List<Widget>();
PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context);
CurvedAnimation opacityCurvedAnimation = new CurvedAnimation(
parent: route.animation,
curve: new Interval(start, end)
);
Widget item = route.items[i];
if (route.initialValue != null && route.items[i].represents((T) route.initialValue)) {
item = new Container(

}
children.Add(new FadeTransition(
opacity: new CurvedAnimation(
parent: route.animation,
curve: new Interval(start, end)
),
child: item
));
children.Add(
new _MenuItem(
onLayout: (Size size) => { route.itemSizes[i] = size; },
child: new FadeTransition(
opacity: opacityCurvedAnimation,
child: item
)
)
);
}
CurveTween opacity = new CurveTween(curve: new Interval(0.0f, 1.0f / 3.0f));

Widget child = new ConstrainedBox(
constraints: new BoxConstraints(
minWidth: PopupMenuUtils._kMenuMinWidth,
maxWidth: PopupMenuUtils._kMenuMaxWidth
minWidth: material_._kMenuMinWidth,
maxWidth: material_._kMenuMaxWidth
stepWidth: PopupMenuUtils._kMenuWidthStep,
stepWidth: material_._kMenuWidthStep,
vertical: PopupMenuUtils._kMenuVerticalPadding
vertical: material_._kMenuVerticalPadding
),
child: new ListBody(children: children)
)

return new Opacity(
opacity: opacity.evaluate(route.animation),
child: new Material(
shape: route.shape ?? popupMenuTheme.shape,
color: route.color ?? popupMenuTheme.color,
elevation: route.elevation,
elevation: route.elevation ?? popupMenuTheme.elevation ?? 8.0f,
child: new Align(
alignment: Alignment.topRight,
widthFactor: width.evaluate(route.animation),

}
class _PopupMenuRouteLayout : SingleChildLayoutDelegate {
public _PopupMenuRouteLayout(RelativeRect position, float? selectedItemOffset) {
public _PopupMenuRouteLayout(RelativeRect position, List<Size> itemSizes, int selectedItemIndex,
TextDirection? textDirection) {
this.selectedItemOffset = selectedItemOffset;
this.itemSizes = itemSizes;
this.selectedItemIndex = selectedItemIndex;
this.textDirection = textDirection;
public readonly float? selectedItemOffset;
public List<Size> itemSizes;
public readonly int selectedItemIndex;
public readonly TextDirection? textDirection;
return BoxConstraints.loose(constraints.biggest -
new Offset(
PopupMenuUtils._kMenuScreenPadding * 2.0f,
PopupMenuUtils._kMenuScreenPadding * 2.0f));
return BoxConstraints.loose(
constraints.biggest - new Offset(material_._kMenuScreenPadding * 2.0f,
material_._kMenuScreenPadding * 2.0f)
);
float y;
if (selectedItemOffset == null) {
y = position.top;
}
else {
y = position.top + (size.height - position.top - position.bottom) / 2.0f -
selectedItemOffset.Value;
float y = position.top;
if (selectedItemIndex != null && itemSizes != null) {
float selectedItemOffset = material_._kMenuVerticalPadding;
for (int index = 0; index < selectedItemIndex; index += 1)
selectedItemOffset += itemSizes[index].height;
selectedItemOffset += itemSizes[selectedItemIndex].height / 2;
y = position.top + (size.height - position.top - position.bottom) / 2.0f - selectedItemOffset;
float x;
float x = 0;
if (position.left > position.right) {
x = size.width - position.right - childSize.width;
}

else {
x = position.left;
D.assert(textDirection != null);
switch (textDirection) {
case TextDirection.rtl:
x = size.width - position.right - childSize.width;
break;
case TextDirection.ltr:
x = position.left;
break;
}
if (x < PopupMenuUtils._kMenuScreenPadding) {
x = PopupMenuUtils._kMenuScreenPadding;
if (x < material_._kMenuScreenPadding) {
x = material_._kMenuScreenPadding;
else if (x + childSize.width > size.width - PopupMenuUtils._kMenuScreenPadding) {
x = size.width - childSize.width - PopupMenuUtils._kMenuScreenPadding;
else if (x + childSize.width > size.width - material_._kMenuScreenPadding) {
x = size.width - childSize.width - material_._kMenuScreenPadding;
if (y < PopupMenuUtils._kMenuScreenPadding) {
y = PopupMenuUtils._kMenuScreenPadding;
if (y < material_._kMenuScreenPadding) {
y = material_._kMenuScreenPadding;
else if (y + childSize.height > size.height - PopupMenuUtils._kMenuScreenPadding) {
y = size.height - childSize.height - PopupMenuUtils._kMenuScreenPadding;
else if (y + childSize.height > size.height - material_._kMenuScreenPadding) {
y = size.height - childSize.height - material_._kMenuScreenPadding;
}
return new Offset(x, y);

return position != ((_PopupMenuRouteLayout) oldDelegate).position;
if (oldDelegate is _PopupMenuRouteLayout popupMenu) {
D.assert(itemSizes.Count == popupMenu.itemSizes.Count);
return position != popupMenu.position
|| selectedItemIndex != popupMenu.selectedItemIndex
|| textDirection != popupMenu.textDirection
|| !itemSizes.equalsList(popupMenu.itemSizes);
}
else {
return false;
}
}
}

List<PopupMenuEntry<T>> items = null,
object initialValue = null,
float elevation = 8.0f,
ThemeData theme = null
T initialValue = default,
float? elevation = 8.0f,
ThemeData theme = null,
PopupMenuThemeData popupMenuTheme = null,
string barrierLabel = null,
ShapeBorder shape = null,
Color color = null,
BuildContext showMenuContext = null,
bool? captureInheritedThemes = null
) {
this.position = position;
this.items = items;

this.popupMenuTheme = popupMenuTheme;
this.barrierLabel = barrierLabel;
this.shape = shape;
this.color = color;
this.showMenuContext = showMenuContext;
this.captureInheritedThemes = captureInheritedThemes;
itemSizes = new List<Size>(items.Count);
public readonly object initialValue;
public readonly float elevation;
public readonly List<Size> itemSizes;
public readonly T initialValue;
public readonly float? elevation;
public readonly ShapeBorder shape;
public readonly Color color;
public readonly PopupMenuThemeData popupMenuTheme;
public readonly BuildContext showMenuContext;
public readonly bool? captureInheritedThemes;
reverseCurve: new Interval(0.0f, PopupMenuUtils._kMenuCloseIntervalEnd)
reverseCurve: new Interval(0.0f, material_._kMenuCloseIntervalEnd)
get { return PopupMenuUtils._kMenuDuration; }
get { return material_._kMenuDuration; }
}
public override bool barrierDismissible {

get { return null; }
}
public override string barrierLabel { get; }
float? selectedItemOffset = null;
int? selectedItemIndex = null;
float y = PopupMenuUtils._kMenuVerticalPadding;
foreach (PopupMenuEntry<T> entry in items) {
if (entry.represents((T) initialValue)) {
selectedItemOffset = y + entry.height / 2.0f;
break;
}
y += entry.height;
for (int index = 0; selectedItemIndex == null && index < items.Count; index += 1) {
if (items[index].represents(initialValue))
selectedItemIndex = index;
if (theme != null) {
menu = new Theme(data: theme, child: menu);
if (captureInheritedThemes ?? false) {
menu = InheritedTheme.captureAll(showMenuContext, menu);
}
else {
if (theme != null)
menu = new Theme(data: theme, child: menu);
}
return MediaQuery.removePadding(

builder: _ => new CustomSingleChildLayout(
layoutDelegate: new _PopupMenuRouteLayout(
position,
selectedItemOffset
itemSizes,
selectedItemIndex ?? 0,
Directionality.of(context)
),
child: menu
))

public static partial class PopupMenuUtils {
public partial class material_ {
float elevation = 8.0f
float? elevation,
ShapeBorder shape,
Color color,
bool captureInheritedThemes = true,
bool useRootNavigator = false
) {
D.assert(context != null);
D.assert(position != null);

return Navigator.push<T>(context, new _PopupMenuRoute<T>(
return Navigator.of(context, rootNavigator: useRootNavigator).push(new _PopupMenuRoute<T>(
theme: Theme.of(context, shadowThemeOnly: true)
));
theme: Theme.of(context, shadowThemeOnly: true),
popupMenuTheme: PopupMenuTheme.of(context),
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
shape: shape,
color: color,
showMenuContext: context,
captureInheritedThemes: captureInheritedThemes
)).to<T>();
}
}

PopupMenuItemSelected<T> onSelected = null,
PopupMenuCanceled onCanceled = null,
string tooltip = null,
float elevation = 8.0f,
float? elevation = null,
Offset offset = null
Offset offset = null,
bool enabled = true,
ShapeBorder shape = null,
Color color = null,
bool captureInheritedThemes = true
D.assert(!(child != null && icon != null));
D.assert(!(child != null && icon != null), () => "You can only pass [child] or [icon], not both.");
this.itemBuilder = itemBuilder;
this.initialValue = initialValue;

public readonly string tooltip;
public readonly float elevation;
public readonly float? elevation;
public readonly Icon icon;
public readonly Widget icon;
public readonly bool enabled;
public readonly ShapeBorder shape;
public readonly Color color;
public readonly bool captureInheritedThemes;
return new _PopupMenuButtonState<T>();
return new PopupMenuButtonState<T>();
class _PopupMenuButtonState<T> : State<PopupMenuButton<T>> {
public class PopupMenuButtonState<T> : State<PopupMenuButton<T>> {
PopupMenuThemeData popupMenuTheme = PopupMenuTheme.of(context);
RenderBox button = (RenderBox) context.findRenderObject();
RenderBox overlay = (RenderBox) Overlay.of(context).context.findRenderObject();
RelativeRect position = RelativeRect.fromRect(

),
Offset.zero & overlay.size
);
PopupMenuUtils.showMenu(
context: context,
elevation: widget.elevation,
items: widget.itemBuilder(context),
initialValue: widget.initialValue,
position: position
)
.then(newValue => {
if (!mounted) {
return;
}
if (newValue == null) {
if (widget.onCanceled != null) {
widget.onCanceled();
List<PopupMenuEntry<T>> items = widget.itemBuilder(context);
if (items.isNotEmpty()) {
material_.showMenu<T>(
context: context,
elevation: widget.elevation ?? popupMenuTheme.elevation,
items: items,
initialValue: widget.initialValue,
position: position,
shape: widget.shape ?? popupMenuTheme.shape,
color: widget.color ?? popupMenuTheme.color,
captureInheritedThemes: widget.captureInheritedThemes
)
.then(newValue => {
if (!mounted)
return;
if (newValue == null) {
if (widget.onCanceled != null)
widget.onCanceled();
return;
return;
}
if (widget.onSelected != null) {
widget.onSelected((T) newValue);
}
});
if (widget.onSelected != null)
widget.onSelected((T) newValue);
});
}
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
return new Icon(Icons.more_horiz);
default:
return new Icon(Icons.more_vert);

public override Widget build(BuildContext context) {
D.assert(material_.debugCheckHasMaterialLocalizations(context));
return widget.child != null
? (Widget) new InkWell(
onTap: showButtonMenu,
child: widget.child
)
: new IconButton(
icon: widget.icon ?? _getIcon(Theme.of(context).platform),
padding: widget.padding,
tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
onPressed: showButtonMenu
if (widget.child != null)
return new Tooltip(
message: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
child: new InkWell(
onTap: widget.enabled ? showButtonMenu : (GestureTapCallback) null,
canRequestFocus: widget.enabled,
child: widget.child
)
return new IconButton(
icon: widget.icon ?? _getIcon(Theme.of(context).platform),
padding: widget.padding,
tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
onPressed: widget.enabled ? showButtonMenu : (VoidCallback) null
);
}
}
}

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


public readonly PopupMenuThemeData data;
static PopupMenuThemeData of(BuildContext context) {
public static PopupMenuThemeData of(BuildContext context) {
PopupMenuTheme popupMenuTheme = context.dependOnInheritedWidgetOfExactType<PopupMenuTheme>();
return popupMenuTheme?.data ?? Theme.of(context).popupMenuTheme;
}

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);
}
}
}

94
com.unity.uiwidgets/Runtime/material/refresh_indicator.cs


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

RefreshCallback onRefresh = null,
Color color = null,
Color backgroundColor = null,
ScrollNotificationPredicate notificationPredicate = null
ScrollNotificationPredicate notificationPredicate = null,
float strokenWidth = 2.0f
) : base(key: key) {
D.assert(child != null);
D.assert(onRefresh != null);

public readonly Color backgroundColor;
public readonly ScrollNotificationPredicate notificationPredicate;
public readonly float strokeWidth;
public override State createState() {
return new RefreshIndicatorState();

return _pendingRefreshFuture;
}
GlobalKey _key = GlobalKey.key();
key: _key,
onNotification: _handleScrollNotification,
child: new NotificationListener<OverscrollIndicatorNotification>(
onNotification: _handleGlowNotification,

if (_mode == null) {
D.assert(_dragOffset == null);
D.assert(_isIndicatorAtTop == null);
return child;
}
D.assert(() => {
if (_mode == null) {
D.assert(_dragOffset == null);
D.assert(_isIndicatorAtTop == null);
}
else {
D.assert(_dragOffset != null);
D.assert(_isIndicatorAtTop != null);
}
D.assert(_dragOffset != null);
D.assert(_isIndicatorAtTop != null);
return true;
});
return new Stack(
children: new List<Widget> {
child,
new Positioned(
top: _isIndicatorAtTop == true ? 0.0f : (float?) null,
bottom: _isIndicatorAtTop != true ? 0.0f : (float?) null,
left: 0.0f,
right: 0.0f,
child: new SizeTransition(
axisAlignment: _isIndicatorAtTop == true ? 1.0f : -1.0f,
sizeFactor: _positionFactor, // this is what brings it down
child: new Container(
padding: _isIndicatorAtTop == true
? EdgeInsets.only(top: widget.displacement)
: EdgeInsets.only(bottom: widget.displacement),
alignment: _isIndicatorAtTop == true
? Alignment.topCenter
: Alignment.bottomCenter,
child: new ScaleTransition(
scale: _scaleFactor,
child: new AnimatedBuilder(
animation: _positionController,
builder: (BuildContext _context, Widget _child) => {
return new RefreshProgressIndicator(
value: showIndeterminateIndicator ? (float?) null : _value.value,
valueColor: _valueColor,
backgroundColor: widget.backgroundColor
);
}
)
List<Widget> children = new List<Widget> {child};
if (_mode != null) {
children.Add(new Positioned(
top: _isIndicatorAtTop == true ? 0.0f : (float?) null,
bottom: _isIndicatorAtTop != true ? 0.0f : (float?) null,
left: 0.0f,
right: 0.0f,
child: new SizeTransition(
axisAlignment: _isIndicatorAtTop == true ? 1.0f : -1.0f,
sizeFactor: _positionFactor, // this is what brings it down
child: new Container(
padding: _isIndicatorAtTop == true
? EdgeInsets.only(top: widget.displacement)
: EdgeInsets.only(bottom: widget.displacement),
alignment: _isIndicatorAtTop == true
? Alignment.topCenter
: Alignment.bottomCenter,
child: new ScaleTransition(
scale: _scaleFactor,
child: new AnimatedBuilder(
animation: _positionController,
builder: (BuildContext _context, Widget _child) => {
return new RefreshProgressIndicator(
value: showIndeterminateIndicator ? (float?) null : _value.value,
valueColor: _valueColor,
backgroundColor: widget.backgroundColor,
strokeWidth: widget.strokeWidth
);
}
}
));
}
return new Stack(
children: children
}
}

34
com.unity.uiwidgets/Runtime/material/reorderable_list.cs


public class ReorderableListView : StatefulWidget {
public ReorderableListView(
Key key = null,
ScrollController scrollController = null,
) {
) : base(key: key) {
D.assert(onReorder != null);
D.assert(children != null);
D.assert(

this.header = header;
this.children = children;
this.scrollController = scrollController;
this.scrollDirection = scrollDirection;
this.padding = padding;
this.onReorder = onReorder;

public readonly List<Widget> children;
public readonly Axis scrollDirection;
public readonly ScrollController scrollController;
public readonly EdgeInsets padding;

return new _ReorderableListContent(
header: widget.header,
children: widget.children,
scrollController: widget.scrollController,
scrollDirection: widget.scrollDirection,
onReorder: widget.onReorder,
padding: widget.padding,

public _ReorderableListContent(
Widget header,
List<Widget> children,
ScrollController scrollController,
Axis scrollDirection,
EdgeInsets padding,
ReorderCallback onReorder,

this.children = children;
this.scrollController = scrollController;
this.scrollDirection = scrollDirection;
this.padding = padding;
this.onReorder = onReorder;

public readonly Widget header;
public readonly List<Widget> children;
public readonly ScrollController scrollController;
public readonly Axis scrollDirection;
public readonly EdgeInsets padding;
public readonly ReorderCallback onReorder;

}
public override void didChangeDependencies() {
_scrollController = PrimaryScrollController.of(context) ?? new ScrollController();
_scrollController = widget.scrollController ?? PrimaryScrollController.of(context) ?? new ScrollController();
base.didChangeDependencies();
}

D.assert(material_.debugCheckHasMaterialLocalizations(context));
return new LayoutBuilder(builder: (BuildContext _, BoxConstraints constraints) => {
List<Widget> wrappedChildren = new List<Widget> { };
if (widget.header != null) {
wrappedChildren.Add(widget.header);
}
for (int i = 0; i < widget.children.Count; i += 1) {
wrappedChildren.Add(_wrap(widget.children[i], i, constraints));
}
Key endWidgetKey = Key.key("DraggableList - End Widget");
Widget finalDropArea;
switch (widget.scrollDirection) {

}
if (widget.reverse == true) {
wrappedChildren.Insert(0, _wrap(
wrappedChildren.Add(_wrap(
else {
if (widget.header != null) {
wrappedChildren.Add(widget.header);
}
for (int i = 0; i < widget.children.Count; i += 1) {
wrappedChildren.Add(_wrap(widget.children[i], i, constraints));
}
if (widget.reverse != true) {
wrappedChildren.Add(_wrap(
finalDropArea, widget.children.Count,
constraints)

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

110
com.unity.uiwidgets/Runtime/material/scrollbar.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async;
using Unity.UIWidgets.cupertino;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
namespace Unity.UIWidgets.material {
static class ScrollbarUtils {

public class Scrollbar : StatefulWidget {
public Scrollbar(
Key key = null,
Widget child = null) : base(key: key) {
Widget child = null,
ScrollController controller = null,
bool isAlwaysShown = false) : base(key: key) {
this.controller = controller;
this.isAlwaysShown = isAlwaysShown;
public readonly ScrollController controller;
public readonly bool isAlwaysShown;
public override State createState() {
return new _ScrollbarState();

public TextDirection _textDirection;
public Color _themeColor;
bool? _useCupertinoScrollbar = null;
public Animation<float> _FadeoutOpacityAnimation;
public Animation<float> _fadeoutOpacityAnimation;
public Timer _fadeoutTimer;
public override void initState() {

duration: ScrollbarUtils._kScrollbarFadeDuration
);
_FadeoutOpacityAnimation = new CurvedAnimation(
_fadeoutOpacityAnimation = new CurvedAnimation(
parent: _fadeoutAnimationController,
curve: Curves.fastOutSlowIn
);

base.didChangeDependencies();
D.assert((() => {
_useCupertinoScrollbar = null;
return true;
}));
_themeColor = theme.highlightColor.withOpacity(1.0f);
_textDirection = Directionality.of(context);
_materialPainter = _BuildMaterialScrollbarPainter();
switch (theme.platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXPlayer:
case RuntimePlatform.OSXEditor:
_fadeoutTimer?.cancel();
_fadeoutTimer = null;
_fadeoutAnimationController.reset();
_useCupertinoScrollbar = true;
break;
default:
_themeColor = theme.highlightColor.withOpacity(1.0f);
_textDirection = Directionality.of(context);
_materialPainter = _buildMaterialScrollbarPainter();
_useCupertinoScrollbar = false;
WidgetsBinding.instance.addPostFrameCallback((TimeSpan duration) => {
if (widget.isAlwaysShown) {
D.assert(widget.controller != null);
widget.controller.position.didUpdateScrollPositionBy(0);
}
});
break;
}
D.assert(_useCupertinoScrollbar != null);
public ScrollbarPainter _BuildMaterialScrollbarPainter() {
public override void didUpdateWidget(StatefulWidget oldWidget) {
var _oldWidget = (Scrollbar) oldWidget;
base.didUpdateWidget(oldWidget);
if (widget.isAlwaysShown != _oldWidget.isAlwaysShown) {
D.assert(widget.controller != null);
if (widget.isAlwaysShown == false) {
_fadeoutAnimationController.reverse();
}
else {
_fadeoutAnimationController.animateTo(1.0f);
}
}
}
public ScrollbarPainter _buildMaterialScrollbarPainter() {
textDirection: _textDirection,
thickness: ScrollbarUtils._kScrollbarThickness,
fadeoutOpacityAnimation: _FadeoutOpacityAnimation
textDirection: _textDirection,
thickness: ScrollbarUtils._kScrollbarThickness,
fadeoutOpacityAnimation: _fadeoutOpacityAnimation,
padding: MediaQuery.of(context).padding
if (notification is ScrollUpdateNotification || notification is OverscrollNotification) {
ScrollMetrics metrics = notification.metrics;
if (metrics.maxScrollExtent <= metrics.minScrollExtent) {
return false;
}
if (!_useCupertinoScrollbar.Value &&
(notification is ScrollUpdateNotification ||
notification is OverscrollNotification)) {
_materialPainter.update(notification.metrics, notification.metrics.axisDirection);
_fadeoutTimer?.cancel();
_fadeoutTimer = Timer.create(ScrollbarUtils._kScrollbarTimeToFade, () => {
_fadeoutAnimationController.reverse();
_fadeoutTimer = null;
});
_materialPainter.update(
notification.metrics,
notification.metrics.axisDirection
);
if (!widget.isAlwaysShown) {
_fadeoutTimer?.cancel();
_fadeoutTimer = Timer.create(ScrollbarUtils._kScrollbarTimeToFade, () => {
_fadeoutAnimationController.reverse();
_fadeoutTimer = null;
});
}
return false;
}

}
public override Widget build(BuildContext context) {
//TODO:uncomment here when cupertino updates are merged
/*if (_useCupertinoScrollbar.Value) {
return new CupertinoScrollbar(
child: widget.child,
isAlwaysShown: widget.isAlwaysShown,
controller: widget.controller
);
}*/
return new NotificationListener<ScrollNotification>(
onNotification: _handleScrollNotification,
child: new RepaintBoundary(

70
com.unity.uiwidgets/Runtime/material/search.cs


}
public abstract class SearchDelegate<T> {
public SearchDelegate(
string searchFieldLabel = null,
TextInputType keyboardType = null,
TextInputAction textInputAction = TextInputAction.search
) {
this.searchFieldLabel = searchFieldLabel;
this.keyboardType = keyboardType;
this.textInputAction = textInputAction;
}
public abstract Widget buildSuggestions(BuildContext context);
public abstract Widget buildResults(BuildContext context);
public abstract Widget buildLeading(BuildContext context);

}
public virtual void showResults(BuildContext context) {
_focusNode.unfocus();
_focusNode?.unfocus();
FocusScope.of(context).requestFocus(_focusNode);
D.assert(_focusNode != null, () => "_focusNode must be set by route before showSuggestions is called.");
_focusNode.requestFocus();
_focusNode.unfocus();
_focusNode?.unfocus();
public readonly string searchFieldLabel;
public readonly TextInputType keyboardType;
public readonly TextInputAction textInputAction;
readonly internal FocusNode _focusNode = new FocusNode();
internal FocusNode _focusNode;
readonly internal TextEditingController _queryTextController = new TextEditingController();

public override Color barrierColor {
get { return null; }
}
public override string barrierLabel => null;
public override TimeSpan transitionDuration {
get { return new TimeSpan(0, 0, 0, 0, 300); }

}
class _SearchPageState<T> : State<_SearchPage<T>> {
FocusNode focusNode = new FocusNode();
queryTextController.addListener(_onQueryChanged);
widget.del._queryTextController.addListener(_onQueryChanged);
widget.del._focusNode.addListener(_onFocusChanged);
focusNode.addListener(_onFocusChanged);
widget.del._focusNode = focusNode;
queryTextController.removeListener(_onQueryChanged);
widget.del._queryTextController.removeListener(_onQueryChanged);
widget.del._focusNode.removeListener(_onFocusChanged);
widget.del._focusNode = null;
focusNode.dispose();
}
void _onAnimationStatusChanged(AnimationStatus status) {

widget.animation.removeStatusListener(_onAnimationStatusChanged);
if (widget.del._currentBody == _SearchBody.suggestions) {
FocusScope.of(context).requestFocus(widget.del._focusNode);
focusNode.requestFocus();
}
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
var _oldWidget = (_SearchPage<T>) oldWidget;
base.didUpdateWidget(oldWidget);
if (widget.del != _oldWidget.del) {
_oldWidget.del._queryTextController.removeListener(_onQueryChanged);
widget.del._queryTextController.addListener(_onQueryChanged);
_oldWidget.del._currentBodyNotifier.removeListener(_onSearchBodyChanged);
widget.del._currentBodyNotifier.addListener(_onSearchBodyChanged);
_oldWidget.del._focusNode = null;
widget.del._focusNode = focusNode;
if (widget.del._focusNode.hasFocus && widget.del._currentBody != _SearchBody.suggestions) {
if (focusNode.hasFocus && widget.del._currentBody != _SearchBody.suggestions) {
widget.del.showSuggestions(context);
}
}

material_.debugCheckHasMaterialLocalizations(context);
ThemeData theme = widget.del.appBarTheme(context);
string searchFieldLabel = MaterialLocalizations.of(context).searchFieldLabel;
string searchFieldLabel = widget.del.searchFieldLabel ?? MaterialLocalizations.of(context).searchFieldLabel;
Widget body = null;
switch (widget.del._currentBody) {
case _SearchBody.suggestions:

string routeName;
switch (Theme.of(this.context).platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
routeName = "";
break;
case RuntimePlatform.Android:

brightness: theme.primaryColorBrightness,
leading: widget.del.buildLeading(context),
title: new TextField(
controller: queryTextController,
focusNode: widget.del._focusNode,
style: theme.textTheme.title,
textInputAction: TextInputAction.search,
controller: widget.del._queryTextController,
focusNode: focusNode,
style: theme.textTheme.headline6,
textInputAction: widget.del.textInputAction,
keyboardType: widget.del.keyboardType,
hintText: searchFieldLabel
hintText: searchFieldLabel,
hintStyle: theme.inputDecorationTheme.hintStyle
)
),
actions: widget.del.buildActions(context)

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/box.cs


information.Add(new DiagnosticsProperty<BoxConstraints>("The constraints that applied to the ${runtimeType} were", constraints, style: DiagnosticsTreeStyle.errorProperty));
information.Add(new DiagnosticsProperty<Size>("The exact size it was given was", _size, style: DiagnosticsTreeStyle.errorProperty));
information.Add(new ErrorHint("See https://flutter.dev/docs/development/ui/layout/box-constraints for more information."));
throw new UIWidgetsError(information);
}

new DiagnosticsProperty<Size>("Size", _size, style: DiagnosticsTreeStyle.errorProperty),
new ErrorHint(
"If you are not writing your own RenderBox subclass, then this is not " +
"your fault. Contact support: https://github.com/flutter/flutter/issues/new?template=BUG.md"
"your fault."
)
});
}

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;
}
}
}

24
com.unity.uiwidgets/Runtime/widgets/editable_text.cs


public class EditableText : StatefulWidget {
public EditableText(
SmartDashesType smartDashesType,
SmartQuotesType smartQuotesType,
Key key = null,
TextEditingController controller = null,
FocusNode focusNode = null,

SmartDashesType? smartDashesType = null,
SmartQuotesType? smartQuotesType = null,
bool enableSuggestions = true,
TextStyle style = null,
StrutStyle strutStyle = null,

) : base(key) {
D.assert(controller != null);
D.assert(focusNode != null);
smartDashesType = (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
smartQuotesType = (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
smartDashesType = smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
smartQuotesType = smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
D.assert(enableInteractiveSelection != null);
D.assert(style != null);
D.assert(cursorColor != null);

this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.style = style;
this.smartDashesType = smartDashesType;
this.smartQuotesType = smartQuotesType;
this.smartDashesType = smartDashesType.Value;
this.smartQuotesType = smartQuotesType.Value;
this.showCursor = showCursor;
this.textWidthBasis = textWidthBasis;
this.onSelectionHandleTapped = onSelectionHandleTapped;

inputType: widget.keyboardType,
obscureText: widget.obscureText,
autocorrect: widget.autocorrect,
smartDashesType: widget.obscureText ? SmartDashesType.disabled : SmartDashesType.enabled,
smartQuotesType: widget.obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled,
smartDashesType: widget.smartDashesType,
smartQuotesType: widget.smartQuotesType,
enableSuggestions: widget.enableSuggestions,
inputAction: widget.textInputAction ?? (widget.keyboardType == TextInputType.multiline
? TextInputAction.newline

Locale locale = null,
bool obscureText = false,
bool autocorrect = false,
SmartDashesType smartDashesType = SmartDashesType.disabled,
SmartQuotesType smartQuotesType = SmartQuotesType.disabled,
SmartDashesType? smartDashesType = null,
SmartQuotesType? smartQuotesType = null,
bool? enableSuggestions = null,
ViewportOffset offset = null,
SelectionChangedHandler onSelectionChanged = null,

this.textDirection = textDirection;
this.obscureText = obscureText;
this.autocorrect = autocorrect;
this.smartDashesType = smartDashesType;
this.smartQuotesType = smartQuotesType;
this.smartDashesType = smartDashesType.Value;
this.smartQuotesType = smartQuotesType.Value;
this.enableSuggestions = enableSuggestions;
this.offset = offset;
this.onSelectionChanged = onSelectionChanged;

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


public readonly bool boldText;
public Orientation orientation {
public Orientation? orientation {
get { return size.width > size.height ? Orientation.landscape : Orientation.portrait; }
}

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) {

1001
com.unity.uiwidgets/Runtime/material/animated_icons/data/ellipsis_search.g.cs
文件差异内容过多而无法显示
查看文件

3
com.unity.uiwidgets/Runtime/material/animated_icons/data/ellipsis_search.g.cs.meta


fileFormatVersion: 2
guid: 898296900a3f42f6a2c88a23b8cd3ab7
timeCreated: 1611815012

1001
com.unity.uiwidgets/Runtime/material/animated_icons/data/event_add.g.cs
文件差异内容过多而无法显示
查看文件

3
com.unity.uiwidgets/Runtime/material/animated_icons/data/event_add.g.cs.meta


fileFormatVersion: 2
guid: ccce6da1a5a3452f8b264aeefea4439d
timeCreated: 1611816735

118
com.unity.uiwidgets/Runtime/material/grid_tile_bar.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
class GridTileBar : StatelessWidget {
public GridTileBar(
Key key = null,
Color backgroundColor = null,
Widget leading = null,
Widget title = null,
Widget subtitle = null,
Widget trailing = null
) : base(key: key) {
this.backgroundColor = backgroundColor;
this.leading = leading;
this.title = title;
this.subtitle = subtitle;
this.trailing = trailing;
}
public readonly Color backgroundColor;
public readonly Widget leading;
public readonly Widget title;
public readonly Widget subtitle;
public readonly Widget trailing;
public override Widget build(BuildContext context) {
BoxDecoration decoration = null;
if (backgroundColor != null)
decoration = new BoxDecoration(color: backgroundColor);
EdgeInsetsDirectional padding = EdgeInsetsDirectional.only(
start: leading != null ? 8.0f : 16.0f,
end: trailing != null ? 8.0f : 16.0f
);
ThemeData theme = Theme.of(context);
ThemeData darkTheme = new ThemeData(
brightness: Brightness.dark,
accentColor: theme.accentColor,
accentColorBrightness: theme.accentColorBrightness
);
var expandChildren = new List<widgets.Widget>();
if (leading != null) {
//TODO: EdgeInsetsGeometry
expandChildren.Add(new Padding(
padding: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(end: 8.0f), child:
leading));
}
if (title != null && subtitle != null) {
expandChildren.Add(new Expanded(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new DefaultTextStyle(
style: darkTheme.textTheme.subtitle1,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: title
),
new DefaultTextStyle(
style: darkTheme.textTheme.caption,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: subtitle
)
}
)
));
}
else if (title != null || subtitle != null)
expandChildren.Add(new Expanded(
child: new DefaultTextStyle(
style: darkTheme.textTheme.subtitle1,
softWrap: false,
overflow: TextOverflow.ellipsis,
child: title ?? subtitle
)
));
if (trailing != null) {
//TODO: EdgeInsetsGeometry
expandChildren.Add(new Padding(
padding: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(start: 8.0f),
child: trailing));
}
return new Container(
//TODO: EdgeInsetsGeometry
padding: (EdgeInsets) (EdgeInsetsGeometry) padding,
decoration: decoration,
height: (title != null && subtitle != null) ? 68.0f : 48.0f,
child: new Theme(
data: darkTheme,
child: IconTheme.merge(
data: new IconThemeData(color: Colors.white),
child: new Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: expandChildren
)
)
)
);
}
}
}

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


fileFormatVersion: 2
guid: c7f1b23a6b52430d95ef28b3586542df
timeCreated: 1611735180

390
com.unity.uiwidgets/Runtime/material/paginated_data_table.cs


using System.Collections.Generic;
using System.Linq;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.gestures;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public class PaginatedDataTable : StatefulWidget {
public PaginatedDataTable(
Key key = null,
Widget header = null,
List<Widget> actions = null,
List<DataColumn> columns = null,
int? sortColumnIndex = null,
bool sortAscending = false,
ValueSetter<bool> onSelectAll = null,
float dataRowHeight = material_.kMinInteractiveDimension,
float headingRowHeight = 56.0f,
float horizontalMargin = 24.0f,
float columnSpacing = 56.0f,
bool showCheckboxColumn = true,
int? initialFirstRowIndex = 0,
ValueChanged<int> onPageChanged = null,
int rowsPerPage = defaultRowsPerPage,
List<int> availableRowsPerPage = null,
ValueChanged<int> onRowsPerPageChanged = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
DataTableSource source = null
) : base(key: key) {
availableRowsPerPage = availableRowsPerPage ?? new List<int> {
defaultRowsPerPage, defaultRowsPerPage * 2, defaultRowsPerPage * 5, defaultRowsPerPage * 10
};
D.assert(columns.isNotEmpty);
D.assert(() => {
if (onRowsPerPageChanged != null)
D.assert(availableRowsPerPage != null && availableRowsPerPage.Contains(rowsPerPage));
return true;
});
D.assert(source != null);
this.header = header;
this.actions = actions;
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.initialFirstRowIndex = initialFirstRowIndex;
this.onPageChanged = onPageChanged;
this.rowsPerPage = rowsPerPage;
this.availableRowsPerPage = availableRowsPerPage;
this.onRowsPerPageChanged = onRowsPerPageChanged;
this.dragStartBehavior = dragStartBehavior;
}
public readonly Widget header;
public readonly List<Widget> actions;
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 int? initialFirstRowIndex;
public readonly ValueChanged<int> onPageChanged;
public readonly int rowsPerPage;
public const int defaultRowsPerPage = 10;
public readonly List<int> availableRowsPerPage;
public readonly ValueChanged<int> onRowsPerPageChanged;
public readonly DataTableSource source;
public readonly DragStartBehavior dragStartBehavior;
public override State createState() => new PaginatedDataTableState();
}
class PaginatedDataTableState : State<PaginatedDataTable> {
int _firstRowIndex;
int _rowCount;
bool _rowCountApproximate;
int _selectedRowCount;
public readonly Dictionary<int, DataRow> _rows = new Dictionary<int, DataRow>();
public override void initState() {
base.initState();
_firstRowIndex = (PageStorage.of(context)?.readState(context)) as int? ?? widget.initialFirstRowIndex ?? 0;
widget.source.addListener(_handleDataSourceChanged);
_handleDataSourceChanged();
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
base.didUpdateWidget(oldWidget);
if (oldWidget is PaginatedDataTable painPaginatedDataTable) {
if (painPaginatedDataTable.source != widget.source) {
painPaginatedDataTable.source.removeListener(_handleDataSourceChanged);
widget.source.addListener(_handleDataSourceChanged);
_handleDataSourceChanged();
}
}
}
public override void dispose() {
widget.source.removeListener(_handleDataSourceChanged);
base.dispose();
}
void _handleDataSourceChanged() {
setState(() => {
_rowCount = widget.source.rowCount;
_rowCountApproximate = widget.source.isRowCountApproximate;
_selectedRowCount = widget.source.selectedRowCount;
_rows.Clear();
});
}
void pageTo(int rowIndex) {
int oldFirstRowIndex = _firstRowIndex;
setState(() => {
int rowsPerPage = widget.rowsPerPage;
_firstRowIndex = ((int) (1.0f * rowIndex / rowsPerPage)) * rowsPerPage;
});
if ((widget.onPageChanged != null) &&
(oldFirstRowIndex != _firstRowIndex))
widget.onPageChanged(_firstRowIndex);
}
DataRow _getBlankRowFor(int index) {
return DataRow.byIndex(
index: index,
cells: widget.columns.Select((DataColumn column) => DataCell.empty).ToList()
);
}
DataRow _getProgressIndicatorRowFor(int index) {
bool haveProgressIndicator = false;
List<DataCell> cells = widget.columns.Select((DataColumn column) => {
if (!column.numeric) {
haveProgressIndicator = true;
return new DataCell(new CircularProgressIndicator());
}
return DataCell.empty;
}).ToList();
if (!haveProgressIndicator) {
haveProgressIndicator = true;
cells[0] = new DataCell(new CircularProgressIndicator());
}
return DataRow.byIndex(
index: index,
cells: cells
);
}
List<DataRow> _getRows(int firstRowIndex, int rowsPerPage) {
List<DataRow> result = new List<DataRow>();
int nextPageFirstRowIndex = firstRowIndex + rowsPerPage;
bool haveProgressIndicator = false;
for (int index = firstRowIndex;
index < nextPageFirstRowIndex;
index += 1) {
DataRow row = null;
if (index < _rowCount || _rowCountApproximate) {
row = _rows.putIfAbsent(index, () => widget.source.getRow(index));
if (row == null && !haveProgressIndicator) {
row = row ?? _getProgressIndicatorRowFor(index);
haveProgressIndicator = true;
}
}
row = row ?? _getBlankRowFor(index);
result.Add(row);
}
return result;
}
void _handlePrevious() {
pageTo(Mathf.Max(_firstRowIndex - widget.rowsPerPage, 0));
}
void _handleNext() {
pageTo(_firstRowIndex + widget.rowsPerPage);
}
public readonly GlobalKey _tableKey = GlobalKey.key();
public override Widget build(BuildContext context) {
D.assert(material_.debugCheckHasMaterialLocalizations(context));
ThemeData themeData = Theme.of(context);
MaterialLocalizations localizations = MaterialLocalizations.of(context);
List<Widget> headerWidgets = new List<Widget>();
float startPadding = 24.0f;
if (_selectedRowCount == 0) {
headerWidgets.Add(new Expanded(child: widget.header));
if (widget.header is ButtonBar) {
startPadding = 12.0f;
}
}
else {
headerWidgets.Add(new Expanded(
child: new Text(localizations.selectedRowCountTitle(_selectedRowCount))
));
}
if (widget.actions != null) {
headerWidgets.AddRange(
widget.actions.Select((Widget action) => {
return new Padding(
// TODO: up EdgeInsetsGeometry
padding: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(
start: 24.0f - 8.0f * 2.0f),
child: action
);
}).ToList()
);
}
TextStyle footerTextStyle = themeData.textTheme.caption;
List<Widget> footerWidgets = new List<Widget>();
if (widget.onRowsPerPageChanged != null) {
List<Widget> availableRowsPerPage = widget.availableRowsPerPage
.Where((int value) => value <= _rowCount || value == widget.rowsPerPage)
.Select((int value) => {
return (Widget) new DropdownMenuItem<int>(
value: value,
child: new Text($"{value}")
);
}).ToList();
footerWidgets.AddRange(new List<Widget>() {
new Container(width: 14.0f), // to match trailing padding in case we overflow and end up scrolling
new Text(localizations.rowsPerPageTitle),
new ConstrainedBox(
constraints: new BoxConstraints(minWidth: 64.0f), // 40.0 for the text, 24.0 for the icon
child: new Align(
alignment: AlignmentDirectional.centerEnd,
child: new DropdownButtonHideUnderline(
child: new DropdownButton<int>(
items: availableRowsPerPage.Cast<DropdownMenuItem<int>>().ToList(),
value: widget.rowsPerPage,
onChanged: widget.onRowsPerPageChanged,
style: footerTextStyle,
iconSize: 24.0f
)
)
)
),
});
}
footerWidgets.AddRange(new List<Widget>() {
new Container(width: 32.0f),
new Text(
localizations.pageRowsInfoTitle(
_firstRowIndex + 1,
_firstRowIndex + widget.rowsPerPage,
_rowCount,
_rowCountApproximate
)
),
new Container(width: 32.0f),
new IconButton(
icon: new Icon(Icons.chevron_left),
padding: EdgeInsets.zero,
tooltip:
localizations.previousPageTooltip,
onPressed: _firstRowIndex <= 0 ? (VoidCallback) null : _handlePrevious),
new Container(width: 24.0f),
new IconButton(
icon: new Icon(Icons.chevron_right),
padding: EdgeInsets.zero,
tooltip:
localizations.nextPageTooltip,
onPressed: (!_rowCountApproximate && (_firstRowIndex + widget.rowsPerPage >= _rowCount))
? (VoidCallback) null
: _handleNext
),
new Container(width: 14.0f),
});
return new LayoutBuilder(
builder: (BuildContext _context, BoxConstraints constraints) => {
return new Card(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
new DefaultTextStyle(
style: _selectedRowCount > 0
? themeData.textTheme.subtitle1.copyWith(color: themeData.accentColor)
: themeData.textTheme.headline6.copyWith(fontWeight: FontWeight.w400),
child: IconTheme.merge(
data: new IconThemeData(
opacity: 0.54f
),
child: new Ink(
height: 64.0f,
color: _selectedRowCount > 0 ? themeData.secondaryHeaderColor : null,
child: new Padding(
//TODO: update EdgeInsets
padding: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(
start: startPadding, end: 14.0f),
child: new Row(
mainAxisAlignment: MainAxisAlignment.end,
children: headerWidgets
)
)
)
)
),
new SingleChildScrollView(
scrollDirection: Axis.horizontal,
dragStartBehavior: widget.dragStartBehavior,
child: new ConstrainedBox(
constraints: new BoxConstraints(minWidth: constraints.minWidth),
child: new DataTable(
key: _tableKey,
columns: widget.columns,
sortColumnIndex: widget.sortColumnIndex,
sortAscending: widget.sortAscending,
onSelectAll: widget.onSelectAll,
dataRowHeight: widget.dataRowHeight,
headingRowHeight: widget.headingRowHeight,
horizontalMargin: widget.horizontalMargin,
columnSpacing: widget.columnSpacing,
rows: _getRows(_firstRowIndex, widget.rowsPerPage)
)
)
),
new DefaultTextStyle(
style: footerTextStyle,
child: IconTheme.merge(
data: new IconThemeData(
opacity: 0.54f
),
child:
new Container(
height: 56.0f,
child: new SingleChildScrollView(
dragStartBehavior: widget.dragStartBehavior,
scrollDirection: Axis.horizontal,
reverse: true,
child: new Row(
children: footerWidgets
)
)
)
)
)
}
)
);
}
);
}
}
}

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

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
)
);
}
}
}

572
com.unity.uiwidgets/Runtime/material/selectable_text.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.cupertino;
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 StrutStyle = Unity.UIWidgets.painting.StrutStyle;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public static class SelectableTextUtils {
internal const int iOSHorizontalOffset = -2;
}
class _TextSpanEditingController : TextEditingController {
public _TextSpanEditingController(TextSpan textSpan = null) : base(text: textSpan?.toPlainText()) {
D.assert(textSpan != null);
_textSpan = textSpan;
}
public readonly TextSpan _textSpan;
public override TextSpan buildTextSpan(TextStyle style = null ,bool withComposing = false) {
return new TextSpan(
style: style,
children: new List<InlineSpan> {_textSpan}
);
}
public new string text {
get { return value.text; }
set {
}
}
}
class _SelectableTextSelectionGestureDetectorBuilder : TextSelectionGestureDetectorBuilder {
public _SelectableTextSelectionGestureDetectorBuilder(
_SelectableTextState state
) : base(_delegate: state) {
_state = state;
}
public readonly _SelectableTextState _state;
protected override void onForcePressStart(ForcePressDetails details) {
base.onForcePressStart(details);
if (_delegate.selectionEnabled && shouldShowSelectionToolbar) {
editableText.showToolbar();
}
}
protected override void onForcePressEnd(ForcePressDetails details) {
// Not required.
}
protected override void onSingleLongTapMoveUpdate(LongPressMoveUpdateDetails details) {
if (_delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
renderEditable.selectPositionAt(
from: details.globalPosition,
cause: SelectionChangedCause.longPress
);
break;
default:
renderEditable.selectWordsInRange(
from: details.globalPosition - details.offsetFromOrigin,
to: details.globalPosition,
cause: SelectionChangedCause.longPress
);
break;
}
}
}
protected override void onSingleTapUp(TapUpDetails details) {
editableText.hideToolbar();
if (_delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
break;
default:
renderEditable.selectPosition(cause: SelectionChangedCause.tap);
break;
}
}
if (_state.widget.onTap != null)
_state.widget.onTap();
}
protected override void onSingleLongTapStart(LongPressStartDetails details) {
if (_delegate.selectionEnabled) {
switch (Theme.of(_state.context).platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
renderEditable.selectPositionAt(
from: details.globalPosition,
cause: SelectionChangedCause.longPress
);
break;
default:
renderEditable.selectWord(cause: SelectionChangedCause.longPress);
Feedback.forLongPress(_state.context);
break;
}
}
}
}
class SelectableText : StatefulWidget {
public SelectableText(
string data,
Key key = null,
FocusNode focusNode = null,
TextStyle style = null,
StrutStyle strutStyle = null,
TextAlign? textAlign = null,
TextDirection? textDirection = null,
float? textScaleFactor = null,
bool showCursor = false,
bool autofocus = false,
ToolbarOptions toolbarOptions = null,
int? minLines = null,
int? maxLines = null,
float cursorWidth = 2.0f,
Radius cursorRadius = null,
Color cursorColor = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
bool enableInteractiveSelection = true,
GestureTapCallback onTap = null,
ScrollPhysics scrollPhysics = null,
TextWidthBasis? textWidthBasis = null
) : this(
data: data,
textSpan: null,
key: key,
focusNode: focusNode,
style: style,
strutStyle: strutStyle,
textAlign: textAlign,
textDirection: textDirection,
textScaleFactor: textScaleFactor,
showCursor: showCursor,
autofocus: autofocus,
toolbarOptions: toolbarOptions,
minLines: minLines,
maxLines: maxLines,
cursorWidth: cursorWidth,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
dragStartBehavior: dragStartBehavior,
enableInteractiveSelection: enableInteractiveSelection,
onTap: onTap,
scrollPhysics: scrollPhysics,
textWidthBasis: textWidthBasis
) {
D.assert(
data != null,
() => "A non-null String must be provided to a SelectableText widget."
);
}
SelectableText(
string data,
TextSpan textSpan,
Key key = null,
FocusNode focusNode = null,
TextStyle style = null,
StrutStyle strutStyle = null,
TextAlign? textAlign = null,
TextDirection? textDirection = null,
float? textScaleFactor = null,
bool showCursor = false,
bool autofocus = false,
ToolbarOptions toolbarOptions = null,
int? minLines = null,
int? maxLines = null,
float cursorWidth = 2.0f,
Radius cursorRadius = null,
Color cursorColor = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
bool enableInteractiveSelection = true,
GestureTapCallback onTap = null,
ScrollPhysics scrollPhysics = null,
TextWidthBasis? textWidthBasis = null
) : base(key: key) {
D.assert(maxLines == null || maxLines > 0);
D.assert(minLines == null || minLines > 0);
D.assert(
(maxLines == null) || (minLines == null) || (maxLines >= minLines),
() => "minLines can\'t be greater than maxLines"
);
toolbarOptions = toolbarOptions ??
new ToolbarOptions(
selectAll: true,
copy: true
);
this.data = data;
this.textSpan = textSpan;
this.focusNode = focusNode;
this.style = style;
this.strutStyle = strutStyle;
this.textAlign = textAlign;
this.textDirection = textDirection;
this.textScaleFactor = textScaleFactor;
this.showCursor = showCursor;
this.autofocus = autofocus;
this.toolbarOptions = toolbarOptions;
this.minLines = minLines;
this.maxLines = maxLines;
this.cursorWidth = cursorWidth;
this.cursorRadius = cursorRadius;
this.cursorColor = cursorColor;
this.dragStartBehavior = dragStartBehavior;
this.enableInteractiveSelection = enableInteractiveSelection;
this.onTap = onTap;
this.scrollPhysics = scrollPhysics;
this.textWidthBasis = textWidthBasis;
}
public static SelectableText rich(
TextSpan textSpan,
Key key = null,
FocusNode focusNode = null,
TextStyle style = null,
StrutStyle strutStyle = null,
TextAlign? textAlign = null,
TextDirection? textDirection = null,
float? textScaleFactor = null,
bool showCursor = false,
bool autofocus = false,
ToolbarOptions toolbarOptions = null,
int? minLines = null,
int? maxLines = null,
float cursorWidth = 2.0f,
Radius cursorRadius = null,
Color cursorColor = null,
DragStartBehavior dragStartBehavior = DragStartBehavior.start,
bool enableInteractiveSelection = true,
GestureTapCallback onTap = null,
ScrollPhysics scrollPhysics = null,
TextWidthBasis? textWidthBasis = null
) {
D.assert(
textSpan != null,
() => "A non-null TextSpan must be provided to a SelectableText.rich widget."
);
return new SelectableText(
data: null,
textSpan: textSpan,
key: key,
focusNode: focusNode,
style: style,
strutStyle: strutStyle,
textAlign: textAlign,
textDirection: textDirection,
textScaleFactor: textScaleFactor,
showCursor: showCursor,
autofocus: autofocus,
toolbarOptions: toolbarOptions,
minLines: minLines,
maxLines: maxLines,
cursorWidth: cursorWidth,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
dragStartBehavior: dragStartBehavior,
enableInteractiveSelection: enableInteractiveSelection,
onTap: onTap,
scrollPhysics: scrollPhysics,
textWidthBasis: textWidthBasis
);
}
public readonly string data;
public readonly TextSpan textSpan;
public readonly FocusNode focusNode;
public readonly TextStyle style;
public readonly StrutStyle strutStyle;
public readonly TextAlign? textAlign;
public readonly TextDirection? textDirection;
public readonly float? textScaleFactor;
public readonly bool autofocus;
public readonly int? minLines;
public readonly int? maxLines;
public readonly bool showCursor;
public readonly float cursorWidth;
public readonly Radius cursorRadius;
public readonly Color cursorColor;
public readonly bool enableInteractiveSelection;
public readonly DragStartBehavior dragStartBehavior;
public readonly ToolbarOptions toolbarOptions;
internal bool selectionEnabled {
get { return enableInteractiveSelection; }
}
public readonly GestureTapCallback onTap;
public readonly ScrollPhysics scrollPhysics;
public readonly TextWidthBasis? textWidthBasis;
public override State createState() => new _SelectableTextState();
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add( new DiagnosticsProperty<String>("data", data, defaultValue: null));
properties.add( new DiagnosticsProperty<FocusNode>("focusNode", focusNode, defaultValue: null));
properties.add( new DiagnosticsProperty<TextStyle>("style", style, defaultValue: null));
properties.add( new DiagnosticsProperty<bool>("autofocus", autofocus, defaultValue: false));
properties.add( new DiagnosticsProperty<bool>("showCursor", showCursor, defaultValue: false));
properties.add( new IntProperty("minLines", minLines, defaultValue: null));
properties.add( new IntProperty("maxLines", maxLines, defaultValue: null));
properties.add( new EnumProperty<TextAlign?>("textAlign", textAlign, defaultValue: null));
properties.add( new EnumProperty<TextDirection?>("textDirection", textDirection, defaultValue: null));
properties.add( new FloatProperty("textScaleFactor", textScaleFactor, defaultValue: null));
properties.add( new FloatProperty("cursorWidth", cursorWidth, defaultValue: 2.0f));
properties.add( new DiagnosticsProperty<Radius>("cursorRadius", cursorRadius, defaultValue: null));
properties.add( new DiagnosticsProperty<Color>("cursorColor", cursorColor, defaultValue: null));
properties.add( new FlagProperty("selectionEnabled", value: selectionEnabled, defaultValue: true, ifFalse: "selection disabled"));
properties.add( new DiagnosticsProperty<ScrollPhysics>("scrollPhysics", scrollPhysics, defaultValue: null));
}
}
class _SelectableTextState : AutomaticKeepAliveClientMixin<SelectableText>,
TextSelectionGestureDetectorBuilderDelegate {
EditableTextState _editableText => editableTextKey.currentState;
_TextSpanEditingController _controller;
FocusNode _focusNode;
FocusNode _effectiveFocusNode => widget.focusNode ?? (_focusNode = _focusNode ?? new FocusNode());
bool _showSelectionHandles = false;
_SelectableTextSelectionGestureDetectorBuilder _selectionGestureDetectorBuilder;
public bool forcePressEnabled {
get { return _forcePressEnabled; }
set { _forcePressEnabled = value; }
}
bool _forcePressEnabled;
public GlobalKey<EditableTextState> editableTextKey {
get { return _editableTextKey; }
}
readonly GlobalKey<EditableTextState> _editableTextKey = GlobalKey<EditableTextState>.key();
public bool selectionEnabled => widget.selectionEnabled;
public override void initState() {
base.initState();
_selectionGestureDetectorBuilder = new _SelectableTextSelectionGestureDetectorBuilder(state: this);
_controller = new _TextSpanEditingController(
textSpan: widget.textSpan ?? new TextSpan(text: widget.data)
);
}
public override void didUpdateWidget(StatefulWidget oldWidget) {
var _oldWidget = (SelectableText) oldWidget;
base.didUpdateWidget(oldWidget);
if (widget.data != _oldWidget.data || widget.textSpan != _oldWidget.textSpan) {
_controller = new _TextSpanEditingController(
textSpan: widget.textSpan ?? new TextSpan(text: widget.data)
);
}
if (_effectiveFocusNode.hasFocus && _controller.selection.isCollapsed) {
_showSelectionHandles = false;
}
}
public override void dispose() {
_focusNode?.dispose();
base.dispose();
}
void _handleSelectionChanged(TextSelection selection, SelectionChangedCause cause) {
bool willShowSelectionHandles = _shouldShowSelectionHandles(cause);
if (willShowSelectionHandles != _showSelectionHandles) {
setState(() => {
_showSelectionHandles = willShowSelectionHandles;
});
}
switch (Theme.of(context).platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
if (cause == SelectionChangedCause.longPress) {
_editableText?.bringIntoView(selection.basePos);
}
return;
default:
// Do nothing.
break;
}
}
void _handleSelectionHandleTapped() {
if (_controller.selection.isCollapsed) {
_editableText.toggleToolbar();
}
}
bool _shouldShowSelectionHandles(SelectionChangedCause cause) {
if (!_selectionGestureDetectorBuilder.shouldShowSelectionToolbar)
return false;
if (_controller.selection.isCollapsed)
return false;
if (cause == SelectionChangedCause.keyboard)
return false;
if (cause == SelectionChangedCause.longPress)
return true;
if (_controller.text.isNotEmpty())
return true;
return false;
}
protected override bool wantKeepAlive => true;
Widget build(BuildContext context) {
base.build(context);
D.assert(() => {
return _controller._textSpan.visitChildren((InlineSpan span) => span is TextSpan);
}, () => "SelectableText only supports TextSpan; Other type of InlineSpan is not allowed");
D.assert(WidgetsD.debugCheckHasMediaQuery(context));
D.assert(WidgetsD.debugCheckHasDirectionality(context));
D.assert(
!(widget.style != null && widget.style.inherit == false &&
(widget.style.fontSize == null || widget.style.textBaseline == null)),
() => "inherit false style must supply fontSize and textBaseline"
);
ThemeData themeData = Theme.of(context);
FocusNode focusNode = _effectiveFocusNode;
TextSelectionControls textSelectionControls;
bool paintCursorAboveText;
bool cursorOpacityAnimates;
Offset cursorOffset = Offset.zero;
Color cursorColor = widget.cursorColor;
Radius cursorRadius = widget.cursorRadius;
switch (themeData.platform) {
case RuntimePlatform.IPhonePlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
forcePressEnabled = true;
textSelectionControls = CupertinoTextSelectionUtils.cupertinoTextSelectionControls;
paintCursorAboveText = true;
cursorOpacityAnimates = true;
cursorColor = cursorColor ?? CupertinoTheme.of(context).primaryColor;
cursorRadius = cursorRadius?? Radius.circular(2.0f);
cursorOffset = new Offset(SelectableTextUtils.iOSHorizontalOffset / MediaQuery.of(context).devicePixelRatio, 0);
break;
default:
forcePressEnabled = false;
textSelectionControls = _MaterialTextSelectionControls.materialTextSelectionControls;
paintCursorAboveText = false;
cursorOpacityAnimates = false;
cursorColor = cursorColor ?? themeData.cursorColor;
break;
}
DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context);
TextStyle effectiveTextStyle = widget.style;
if (widget.style == null || widget.style.inherit)
effectiveTextStyle = defaultTextStyle.style.merge(widget.style);
if (MediaQuery.boldTextOverride(context))
effectiveTextStyle = effectiveTextStyle.merge(new TextStyle(fontWeight: FontWeight.bold));
Widget child = new RepaintBoundary(
child: new EditableText(
key: editableTextKey,
style: effectiveTextStyle,
readOnly: true,
textWidthBasis: widget.textWidthBasis ?? defaultTextStyle.textWidthBasis,
showSelectionHandles: _showSelectionHandles,
showCursor: widget.showCursor,
controller: _controller,
focusNode: focusNode,
strutStyle: widget.strutStyle ?? new StrutStyle(),
textAlign: widget.textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start,
textDirection: widget.textDirection,
textScaleFactor: widget.textScaleFactor,
autofocus: widget.autofocus,
forceLine: false,
toolbarOptions: widget.toolbarOptions,
minLines: widget.minLines,
maxLines: widget.maxLines ?? defaultTextStyle.maxLines,
selectionColor: themeData.textSelectionColor,
selectionControls: widget.selectionEnabled ? textSelectionControls : null,
onSelectionChanged: _handleSelectionChanged,
onSelectionHandleTapped: _handleSelectionHandleTapped,
rendererIgnoresPointer: true,
cursorWidth: widget.cursorWidth,
cursorRadius: cursorRadius,
cursorColor: cursorColor,
cursorOpacityAnimates: cursorOpacityAnimates,
cursorOffset: cursorOffset,
paintCursorAboveText: paintCursorAboveText,
backgroundCursorColor: CupertinoColors.inactiveGray,
enableInteractiveSelection: widget.enableInteractiveSelection,
dragStartBehavior: widget.dragStartBehavior,
scrollPhysics: widget.scrollPhysics
)
);
return _selectionGestureDetectorBuilder.buildGestureDetector(
behavior: HitTestBehavior.translucent,
child: child
);
}
}
}

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
)
);
}
}
}

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

160
com.unity.uiwidgets/Runtime/material/pickers/date_picker_head.cs


using System.Collections.Generic;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public static class DatePickerHeaderUtils {
public const float _datePickerHeaderLandscapeWidth = 152.0f;
public const float _datePickerHeaderPortraitHeight = 120.0f;
public const float _headerPaddingLandscape = 16.0f;
}
class DatePickerHeader : StatelessWidget {
public DatePickerHeader(
Key key = null,
string helpText = null,
string titleText = null,
TextStyle titleStyle = null,
Orientation? orientation = null,
bool isShort = false,
IconData icon = null,
string iconTooltip = null,
VoidCallback onIconPressed = null
) : base(key: key) {
D.assert(helpText != null);
D.assert(orientation != null);
this.helpText = helpText;
this.titleText = titleText;
this.titleStyle = titleStyle;
this.orientation = orientation.Value;
this.isShort = isShort;
this.icon = icon;
this.iconTooltip = iconTooltip;
this.onIconPressed = onIconPressed;
}
public readonly string helpText;
public readonly string titleText;
public readonly TextStyle titleStyle;
public readonly Orientation orientation;
public readonly bool isShort;
public readonly IconData icon;
public readonly string iconTooltip;
public readonly VoidCallback onIconPressed;
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
ColorScheme colorScheme = theme.colorScheme;
TextTheme textTheme = theme.textTheme;
bool isDark = colorScheme.brightness == Brightness.dark;
Color primarySurfaceColor = isDark ? colorScheme.surface : colorScheme.primary;
Color onPrimarySurfaceColor = isDark ? colorScheme.onSurface : colorScheme.onPrimary;
TextStyle helpStyle = textTheme.overline?.copyWith(
color: onPrimarySurfaceColor
);
Text help = new Text(
helpText,
style: helpStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis
);
Text title = new Text(
titleText,
style: titleStyle,
maxLines: (isShort || orientation == Orientation.portrait) ? 1 : 2,
overflow: TextOverflow.ellipsis
);
IconButton icon = new IconButton(
icon: new Icon(this.icon),
color: onPrimarySurfaceColor,
tooltip: iconTooltip,
onPressed: onIconPressed
);
switch (orientation) {
case Orientation.portrait:
return new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new Container(
height: DatePickerHeaderUtils._datePickerHeaderPortraitHeight,
color: primarySurfaceColor,
//FixMe: uncomment this after EdgeInsetsGeometry is ready for use
/*padding: EdgeInsetsDirectional.only(
start: 24f,
end: 12f
),*/
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new SizedBox(height: 16f),
new Flexible(child: help),
new SizedBox(height: 38),
new Row(
children: new List<Widget> {
new Expanded(child: title),
icon,
}
),
}
)
)
}
);
case Orientation.landscape:
return new Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new Container(
width: DatePickerHeaderUtils._datePickerHeaderLandscapeWidth,
color: primarySurfaceColor,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: new List<Widget> {
new SizedBox(height: 16),
new Padding(
padding: EdgeInsets.symmetric(
horizontal: DatePickerHeaderUtils._headerPaddingLandscape
),
child: help
),
new SizedBox(height: isShort ? 16 : 56),
new Padding(
padding: EdgeInsets.symmetric(
horizontal: DatePickerHeaderUtils._headerPaddingLandscape
),
child: title
),
new Spacer(),
new Padding(
padding: EdgeInsets.symmetric(
horizontal: 4
),
child: icon
),
}
)
),
}
);
}
return null;
}
}
}

416
com.unity.uiwidgets/Runtime/material/pickers/date_picker_dialog.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.async2;
using Unity.UIWidgets.foundation;
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 TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public partial class material_ {
public static readonly Size _calendarPortraitDialogSize = new Size(330.0f, 518.0f);
public static readonly Size _calendarLandscapeDialogSize = new Size(496.0f, 346.0f);
public static readonly Size _inputPortraitDialogSize = new Size(330.0f, 270.0f);
public static readonly Size _inputLandscapeDialogSize = new Size(496f, 160.0f);
public static readonly TimeSpan _dialogSizeAnimationDuration = new TimeSpan(0, 0, 0, 0, 200);
public Future<DateTime> showDatePicker(
BuildContext context,
DateTime initialDate,
DateTime firstDate,
DateTime lastDate,
DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar,
material_.SelectableDayPredicate selectableDayPredicate = null,
string helpText = null,
string cancelText = null,
string confirmText = null,
Locale locale = null,
bool useRootNavigator = true,
RouteSettings routeSettings = null,
TextDirection? textDirection = null,
TransitionBuilder builder = null,
DatePickerMode initialDatePickerMode = DatePickerMode.day,
string errorFormatText = null,
string errorInvalidText = null,
string fieldHintText = null,
string fieldLabelText = null
) {
D.assert(context != null);
initialDate = utils.dateOnly(initialDate);
firstDate = utils.dateOnly(firstDate);
lastDate = utils.dateOnly(lastDate);
D.assert(
!lastDate.isBefore(firstDate),
() => $"lastDate {lastDate} must be on or after firstDate {firstDate}."
);
D.assert(
!initialDate.isBefore(firstDate),
() => $"initialDate {initialDate} must be on or after firstDate {firstDate}."
);
D.assert(
!initialDate.isAfter(lastDate),
() => $"initialDate {initialDate} must be on or before lastDate {lastDate}."
);
D.assert(
selectableDayPredicate == null || selectableDayPredicate(initialDate),
() => $"Provided initialDate {initialDate} must satisfy provided selectableDayPredicate."
);
D.assert(initialEntryMode != null);
D.assert(initialDatePickerMode != null);
D.assert(material_.debugCheckHasMaterialLocalizations(context));
Widget dialog = new _DatePickerDialog(
initialDate: initialDate,
firstDate: firstDate,
lastDate: lastDate,
initialEntryMode: initialEntryMode,
selectableDayPredicate: selectableDayPredicate,
helpText: helpText,
cancelText: cancelText,
confirmText: confirmText,
initialCalendarMode: initialDatePickerMode,
errorFormatText: errorFormatText,
errorInvalidText: errorInvalidText,
fieldHintText: fieldHintText,
fieldLabelText: fieldLabelText
);
if (textDirection != null) {
dialog = new Directionality(
textDirection: textDirection.Value,
child: dialog
);
}
if (locale != null) {
dialog = Localizations.overrides(
context: context,
locale: locale,
child: dialog
);
}
return material_.showDialog<DateTime>(
context: context,
useRootNavigator: useRootNavigator,
routeSettings: routeSettings,
builder: (BuildContext subContext) => { return builder == null ? dialog : builder(subContext, dialog); }
);
}
}
class _DatePickerDialog : StatefulWidget {
public _DatePickerDialog(
Key key = null,
DateTime? initialDate = null,
DateTime? firstDate = null,
DateTime? lastDate = null,
DatePickerEntryMode initialEntryMode = DatePickerEntryMode.calendar,
material_.SelectableDayPredicate selectableDayPredicate = null,
string cancelText = null,
string confirmText = null,
string helpText = null,
DatePickerMode initialCalendarMode = DatePickerMode.day,
string errorFormatText = null,
string errorInvalidText = null,
string fieldHintText = null,
string fieldLabelText = null
) : base(key: key) {
D.assert(initialDate != null);
D.assert(firstDate != null);
D.assert(lastDate != null);
initialDate = utils.dateOnly(initialDate.Value);
firstDate = utils.dateOnly(firstDate.Value);
lastDate = utils.dateOnly(lastDate.Value);
D.assert(
!lastDate.Value.isBefore(firstDate.Value),
() => $"lastDate {lastDate} must be on or after firstDate {firstDate}."
);
D.assert(
initialDate == null || !initialDate.Value.isBefore(firstDate.Value),
() => $"initialDate {initialDate} must be on or after firstDate {firstDate}."
);
D.assert(
initialDate == null || !initialDate.Value.isAfter(lastDate.Value),
() => $"initialDate {initialDate} must be on or before lastDate {lastDate}."
);
D.assert(
selectableDayPredicate == null || initialDate == null || selectableDayPredicate(initialDate.Value),
() => $"Provided initialDate {initialDate} must satisfy provided selectableDayPredicate."
);
this.initialDate = initialDate.Value;
this.firstDate = firstDate.Value;
this.lastDate = lastDate.Value;
this.initialEntryMode = initialEntryMode;
this.selectableDayPredicate = selectableDayPredicate;
this.cancelText = cancelText;
this.confirmText = confirmText;
this.helpText = helpText;
this.initialCalendarMode = initialCalendarMode;
this.errorFormatText = errorFormatText;
this.errorInvalidText = errorInvalidText;
this.fieldHintText = fieldHintText;
this.fieldLabelText = fieldLabelText;
}
public readonly DateTime initialDate;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly DatePickerEntryMode initialEntryMode;
public readonly material_.SelectableDayPredicate selectableDayPredicate;
public readonly string cancelText;
public readonly string confirmText;
public readonly string helpText;
public readonly DatePickerMode initialCalendarMode;
public readonly string errorFormatText;
public readonly string errorInvalidText;
public readonly string fieldHintText;
public readonly string fieldLabelText;
public override State createState() {
return new _DatePickerDialogState();
}
}
class _DatePickerDialogState : State<_DatePickerDialog> {
DatePickerEntryMode _entryMode;
DateTime _selectedDate;
bool _autoValidate;
public readonly GlobalKey _calendarPickerKey = GlobalKey.key();
public readonly GlobalKey<FormState> _formKey = GlobalKey<FormState>.key();
public override void initState() {
base.initState();
_entryMode = widget.initialEntryMode;
_selectedDate = widget.initialDate;
_autoValidate = false;
}
void _handleOk() {
if (_entryMode == DatePickerEntryMode.input) {
FormState form = _formKey.currentState;
if (!form.validate()) {
setState(() => _autoValidate = true);
return;
}
form.save();
}
Navigator.pop(context, _selectedDate);
}
void _handleCancel() {
Navigator.pop<object>(context);
}
void _handelEntryModeToggle() {
setState(() => {
switch (_entryMode) {
case DatePickerEntryMode.calendar:
_autoValidate = false;
_entryMode = DatePickerEntryMode.input;
break;
case DatePickerEntryMode.input:
_formKey.currentState.save();
_entryMode = DatePickerEntryMode.calendar;
break;
}
});
}
void _handleDateChanged(DateTime date) {
setState(() => _selectedDate = date);
}
Size _dialogSize(BuildContext context) {
Orientation? orientation = MediaQuery.of(context).orientation;
switch (_entryMode) {
case DatePickerEntryMode.calendar:
switch (orientation) {
case Orientation.portrait:
return material_._calendarPortraitDialogSize;
case Orientation.landscape:
return material_._calendarLandscapeDialogSize;
}
break;
case DatePickerEntryMode.input:
switch (orientation) {
case Orientation.portrait:
return material_._inputPortraitDialogSize;
case Orientation.landscape:
return material_._inputLandscapeDialogSize;
}
break;
}
return null;
}
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
ColorScheme colorScheme = theme.colorScheme;
MaterialLocalizations localizations = MaterialLocalizations.of(context);
Orientation? orientation = MediaQuery.of(context).orientation;
TextTheme textTheme = theme.textTheme;
float textScaleFactor = Mathf.Min(MediaQuery.of(context).textScaleFactor, 1.3f);
string dateText = _selectedDate != null
? localizations.formatMediumDate(_selectedDate)
: "Date";
Color dateColor = colorScheme.brightness == Brightness.light
? colorScheme.onPrimary
: colorScheme.onSurface;
TextStyle dateStyle = orientation == Orientation.landscape
? textTheme.headline5?.copyWith(color: dateColor)
: textTheme.headline4?.copyWith(color: dateColor);
Widget actions = new ButtonBar(
buttonTextTheme: ButtonTextTheme.primary,
layoutBehavior: ButtonBarLayoutBehavior.constrained,
children: new List<Widget> {
new FlatButton(
child: new Text(widget.cancelText ?? localizations.cancelButtonLabel),
onPressed: _handleCancel
),
new FlatButton(
child: new Text(widget.confirmText ?? localizations.okButtonLabel),
onPressed: _handleOk
),
}
);
Widget picker = null;
IconData entryModeIcon = null;
string entryModeTooltip = null;
switch (_entryMode) {
case DatePickerEntryMode.calendar:
picker = new CalendarDatePicker(
key: _calendarPickerKey,
initialDate: _selectedDate,
firstDate: widget.firstDate,
lastDate: widget.lastDate,
onDateChanged: _handleDateChanged,
selectableDayPredicate: widget.selectableDayPredicate,
initialCalendarMode: widget.initialCalendarMode
);
entryModeIcon = Icons.edit;
entryModeTooltip = "Switch to input";
break;
case DatePickerEntryMode.input:
picker = new Form(
key: _formKey,
autovalidate: _autoValidate,
child: new InputDatePickerFormField(
initialDate: _selectedDate,
firstDate: widget.firstDate,
lastDate: widget.lastDate,
onDateSubmitted: _handleDateChanged,
onDateSaved: _handleDateChanged,
selectableDayPredicate: widget.selectableDayPredicate,
errorFormatText: widget.errorFormatText,
errorInvalidText: widget.errorInvalidText,
fieldHintText: widget.fieldHintText,
fieldLabelText: widget.fieldLabelText,
autofocus: true
)
);
entryModeIcon = Icons.calendar_today;
entryModeTooltip = "Switch to calendar";
break;
}
Widget header = new DatePickerHeader(
helpText: widget.helpText ?? "SELECT DATE",
titleText: dateText,
titleStyle: dateStyle,
orientation: orientation,
isShort: orientation == Orientation.landscape,
icon: entryModeIcon,
iconTooltip: entryModeTooltip,
onIconPressed: _handelEntryModeToggle
);
Size dialogSize = _dialogSize(context) * textScaleFactor;
DialogTheme dialogTheme = Theme.of(context).dialogTheme;
return new Dialog(
child: new AnimatedContainer(
width: dialogSize.width,
height: dialogSize.height,
duration: material_._dialogSizeAnimationDuration,
curve: Curves.easeIn,
child: new MediaQuery(
data: MediaQuery.of(context).copyWith(
textScaleFactor: textScaleFactor
),
child: new Builder(builder: (BuildContext subContext) => {
switch (orientation) {
case Orientation.portrait:
return new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
header,
new Expanded(child: picker),
actions,
}
);
case Orientation.landscape:
return new Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
header,
new Flexible(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: new List<Widget> {
new Expanded(child: picker),
actions,
}
)
),
}
);
}
return null;
})
)
),
insetPadding: EdgeInsets.symmetric(horizontal: 16.0f, vertical: 24.0f),
shape: dialogTheme.shape ?? new RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(4.0f))
),
clipBehavior: Clip.antiAlias
);
}
}
}

11
com.unity.uiwidgets/Runtime/material/pickers/date_picker_dialog.cs.meta


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

238
com.unity.uiwidgets/Runtime/material/pickers/input_date_picker.cs


using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UIWidgets.Runtime.material;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.service;
using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public static class InputDatePickerUtils {
public const float _inputPortraitHeight = 98.0f;
public const float _inputLandscapeHeight = 108.0f;
public static bool isBefore(this DateTime t1, DateTime t2) {
return t1.CompareTo(t2) < 0;
}
public static bool isAfter(this DateTime t1, DateTime t2) {
return t1.CompareTo(t2) > 0;
}
}
class InputDatePickerFormField : StatefulWidget {
public InputDatePickerFormField(
Key key = null,
DateTime? initialDate = null,
DateTime? firstDate = null,
DateTime? lastDate = null,
ValueChanged<DateTime> onDateSubmitted = null,
ValueChanged<DateTime> onDateSaved = null,
material_.SelectableDayPredicate selectableDayPredicate = null,
string errorFormatText = null,
string errorInvalidText = null,
string fieldHintText = null,
string fieldLabelText = null,
bool autofocus = false
) : base(key: key) {
D.assert(firstDate != null);
D.assert(lastDate != null);
initialDate = initialDate != null ? utils.dateOnly(initialDate.Value) : (DateTime?)null;
firstDate = utils.dateOnly(firstDate.Value);
lastDate = utils.dateOnly(lastDate.Value);
D.assert(
!lastDate.Value.isBefore(firstDate.Value),
() => $"lastDate {lastDate} must be on or after firstDate {firstDate}."
);
D.assert(
initialDate == null || !initialDate.Value.isBefore(firstDate.Value),
() => $"initialDate {initialDate} must be on or after firstDate {firstDate}."
);
D.assert(
initialDate == null || !initialDate.Value.isAfter(lastDate.Value),
() => $"initialDate {initialDate} must be on or before lastDate {lastDate}."
);
D.assert(
selectableDayPredicate == null || initialDate == null || selectableDayPredicate(initialDate.Value),
() => $"Provided initialDate {initialDate} must satisfy provided selectableDayPredicate."
);
this.initialDate = initialDate;
this.firstDate = firstDate.Value;
this.lastDate = lastDate.Value;
this.onDateSubmitted = onDateSubmitted;
this.onDateSaved = onDateSaved;
this.selectableDayPredicate = selectableDayPredicate;
this.errorFormatText = errorFormatText;
this.errorInvalidText = errorInvalidText;
this.fieldHintText = fieldHintText;
this.fieldLabelText = fieldLabelText;
this.autofocus = autofocus;
}
public readonly DateTime? initialDate;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly ValueChanged<DateTime> onDateSubmitted;
public readonly ValueChanged<DateTime> onDateSaved;
public readonly material_.SelectableDayPredicate selectableDayPredicate;
public readonly string errorFormatText;
public readonly string errorInvalidText;
public readonly string fieldHintText;
public readonly string fieldLabelText;
public readonly bool autofocus;
public override State createState() {
return new _InputDatePickerFormFieldState();
}
}
class _InputDatePickerFormFieldState : State<InputDatePickerFormField> {
public readonly TextEditingController _controller = new TextEditingController();
DateTime? _selectedDate;
string _inputText;
bool _autoSelected = false;
public override void initState() {
base.initState();
_selectedDate = widget.initialDate;
}
public override void dispose() {
_controller.dispose();
base.dispose();
}
public override void didChangeDependencies() {
base.didChangeDependencies();
if (_selectedDate != null) {
MaterialLocalizations localizations = MaterialLocalizations.of(context);
_inputText = localizations.formatCompactDate(_selectedDate.Value);
TextEditingValue textEditingValue = _controller.value.copyWith(text: _inputText);
if (widget.autofocus && !_autoSelected) {
textEditingValue = textEditingValue.copyWith(selection: new TextSelection(
baseOffset: 0,
extentOffset: _inputText.Length
));
_autoSelected = true;
}
_controller.value = textEditingValue;
}
}
DateTime? _parseDate(string text) {
MaterialLocalizations localizations = MaterialLocalizations.of(context);
return localizations.parseCompactDate(text);
}
bool _isValidAcceptableDate(DateTime? date) {
return
date != null &&
!date.Value.isBefore(widget.firstDate) &&
!date.Value.isAfter(widget.lastDate) &&
(widget.selectableDayPredicate == null || widget.selectableDayPredicate(date));
}
string _validateDate(string text) {
DateTime? date = _parseDate(text);
if (date == null) {
return widget.errorFormatText ?? "Invalid format.";
}
else if (!_isValidAcceptableDate(date)) {
return widget.errorInvalidText ?? "Out of range.";
}
return null;
}
void _handleSaved(string text) {
if (widget.onDateSaved != null) {
DateTime? date = _parseDate(text);
if (_isValidAcceptableDate(date)) {
_selectedDate = date;
_inputText = text;
widget.onDateSaved(date.Value);
}
}
}
void _handleSubmitted(string text) {
if (widget.onDateSubmitted != null) {
DateTime? date = _parseDate(text);
if (_isValidAcceptableDate(date)) {
_selectedDate = date;
_inputText = text;
widget.onDateSubmitted(date.Value);
}
}
}
public override Widget build(BuildContext context) {
return new OrientationBuilder(builder: (BuildContext subContext, Orientation orientation) => {
return new Container(
padding: EdgeInsets.symmetric(horizontal: 24f),
height: orientation == Orientation.portrait
? InputDatePickerUtils._inputPortraitHeight
: InputDatePickerUtils._inputLandscapeHeight,
child: new Column(
children: new List<Widget> {
new Spacer(),
new TextFormField(
decoration: new InputDecoration(
border: new UnderlineInputBorder(),
filled: true,
hintText: widget.fieldHintText ?? "mm/dd/yyyy",
labelText: widget.fieldLabelText ?? "Enter Date"
),
validator: _validateDate,
inputFormatters: new List<TextInputFormatter> {
new _DateTextInputFormatter("/")
},
keyboardType: TextInputType.datetime,
onSaved: _handleSaved,
onFieldSubmitted: _handleSubmitted,
autofocus: widget.autofocus,
controller: _controller
),
new Spacer(),
}
)
);
});
}
}
class _DateTextInputFormatter : TextInputFormatter {
public _DateTextInputFormatter(string separator) {
this.separator = separator;
}
public readonly string separator;
public readonly WhitelistingTextInputFormatter _filterFormatter =
// Only allow digits and separators (slash, dot, comma, hyphen, space).
new WhitelistingTextInputFormatter(new Regex(@"[\d\/\.,-\s]+"));
public override TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
TextEditingValue filteredValue = _filterFormatter.formatEditUpdate(oldValue, newValue);
return filteredValue.copyWith(
text: Regex.Replace(filteredValue.text, @"[\D]", separator)
);
}
}
}

11
com.unity.uiwidgets/Runtime/material/pickers/input_date_picker.cs.meta


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

928
com.unity.uiwidgets/Runtime/material/pickers/calendar_date_picker.cs


using System;
using System.Collections.Generic;
using com.unity.uiwidgets.Runtime.rendering;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
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 TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace Unity.UIWidgets.material {
public partial class material_ {
public static readonly TimeSpan _monthScrollDuration = new TimeSpan(0, 0, 0, 0, 200);
public const float _dayPickerRowHeight = 42.0f;
public const int _maxDayPickerRowCount = 6; // A 31 day month that starts on Saturday.
public const float _maxDayPickerHeight = _dayPickerRowHeight * (_maxDayPickerRowCount + 1);
public const float _monthPickerHorizontalPadding = 8.0f;
public const int _yearPickerColumnCount = 3;
public const float _yearPickerPadding = 16.0f;
public const float _yearPickerRowHeight = 52.0f;
public const float _yearPickerRowSpacing = 8.0f;
public const float _subHeaderHeight = 52.0f;
public const float _monthNavButtonsWidth = 108.0f;
}
public class CalendarDatePicker : StatefulWidget {
public CalendarDatePicker(
Key key = null,
DateTime? initialDate = null,
DateTime? firstDate = null,
DateTime? lastDate = null,
ValueChanged<DateTime> onDateChanged = null,
ValueChanged<DateTime> onDisplayedMonthChanged = null,
DatePickerMode initialCalendarMode = DatePickerMode.day,
material_.SelectableDayPredicate selectableDayPredicate = null
) : base(key: key) {
D.assert(initialDate != null);
D.assert(firstDate != null);
D.assert(lastDate != null);
initialDate = utils.dateOnly(initialDate.Value);
firstDate = utils.dateOnly(firstDate.Value);
lastDate = utils.dateOnly(lastDate.Value);
D.assert(onDateChanged != null);
D.assert(initialCalendarMode != null);
this.onDateChanged = onDateChanged;
this.onDisplayedMonthChanged = onDisplayedMonthChanged;
this.initialCalendarMode = initialCalendarMode;
this.selectableDayPredicate = selectableDayPredicate;
D.assert(
!(this.lastDate < this.firstDate),
() => $"lastDate {lastDate} must be on or after firstDate {firstDate}."
);
D.assert(
!(this.initialDate < this.firstDate),
() => $"initialDate {initialDate} must be on or after firstDate {firstDate}."
);
D.assert(
!(this.initialDate > this.lastDate),
() => $"initialDate {initialDate} must be on or before lastDate {lastDate}."
);
D.assert(
selectableDayPredicate == null || selectableDayPredicate(this.initialDate),
() => $"Provided initialDate {initialDate} must satisfy provided selectableDayPredicate."
);
}
public readonly DateTime initialDate;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly ValueChanged<DateTime> onDateChanged;
public readonly ValueChanged<DateTime> onDisplayedMonthChanged;
public readonly DatePickerMode initialCalendarMode;
public readonly material_.SelectableDayPredicate selectableDayPredicate;
public override State createState() => new UIWidgets.material._CalendarDatePickerState();
}
internal class _CalendarDatePickerState : State<CalendarDatePicker> {
bool _announcedInitialDate = false;
DatePickerMode _mode;
DateTime _currentDisplayedMonthDate;
DateTime _selectedDate;
public readonly GlobalKey _monthPickerKey = GlobalKey.key();
public readonly GlobalKey _yearPickerKey = GlobalKey.key();
MaterialLocalizations _localizations;
TextDirection _textDirection;
public override void initState() {
base.initState();
_mode = widget.initialCalendarMode;
_currentDisplayedMonthDate = new DateTime(widget.initialDate.Year, widget.initialDate.Month, 1);
_selectedDate = widget.initialDate;
}
public override void didChangeDependencies() {
base.didChangeDependencies();
_localizations = MaterialLocalizations.of(context);
_textDirection = Directionality.of(context);
if (!_announcedInitialDate) {
_announcedInitialDate = true;
// SemanticsService.announce(
// _localizations.formatFullDate(_selectedDate),
// _textDirection,
// );
}
}
void _vibrate() {
// switch (Theme.of(context).platform) {
// case TargetPlatform.android:
// case TargetPlatform.fuchsia:
// case TargetPlatform.linux:
// case TargetPlatform.windows:
// // HapticFeedback.vibrate();
// break;
// case TargetPlatform.iOS:
// case TargetPlatform.macOS:
// 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 _handleMonthChanged(DateTime date) {
setState(() => {
if (_currentDisplayedMonthDate.Year != date.Year || _currentDisplayedMonthDate.Month != date.Month) {
_currentDisplayedMonthDate = new DateTime(date.Year, date.Month, 1);
widget.onDisplayedMonthChanged?.Invoke(_currentDisplayedMonthDate);
}
});
}
void _handleYearChanged(DateTime value) {
_vibrate();
if (value < widget.firstDate) {
value = widget.firstDate;
}
else if (value > widget.lastDate) {
value = widget.lastDate;
}
setState(() => {
_mode = DatePickerMode.day;
_handleMonthChanged(value);
});
}
void _handleDayChanged(DateTime value) {
_vibrate();
setState(() => {
_selectedDate = value;
widget.onDateChanged?.Invoke(_selectedDate);
});
}
Widget _buildPicker() {
D.assert(_mode != null);
switch (_mode) {
case DatePickerMode.day:
return new _MonthPicker(
key: _monthPickerKey,
initialMonth: _currentDisplayedMonthDate,
currentDate: DateTime.Now,
firstDate: widget.firstDate,
lastDate: widget.lastDate,
selectedDate: _selectedDate,
onChanged: _handleDayChanged,
onDisplayedMonthChanged: _handleMonthChanged,
selectableDayPredicate: widget.selectableDayPredicate
);
case DatePickerMode.year:
return new Padding(
padding: EdgeInsets.only(top: material_._subHeaderHeight),
child: new _YearPicker(
key: _yearPickerKey,
currentDate: DateTime.Now,
firstDate: widget.firstDate,
lastDate: widget.lastDate,
initialDate: _currentDisplayedMonthDate,
selectedDate: _selectedDate,
onChanged: _handleYearChanged
)
);
}
return null;
}
public override Widget build(BuildContext context) {
return new Stack(
children: new List<Widget> {
new SingleChildScrollView(
child: new SizedBox(
height: material_._maxDayPickerHeight,
child: _buildPicker()
)
),
// Put the mode toggle button on top so that it won"t be covered up by the _MonthPicker
new _DatePickerModeToggleButton(
mode: _mode,
title: _localizations.formatMonthYear(_currentDisplayedMonthDate),
onTitlePressed: () => {
// Toggle the day/year mode.
_handleModeChanged(_mode == DatePickerMode.day ? DatePickerMode.year : DatePickerMode.day);
}
)
}
);
}
}
class _DatePickerModeToggleButton : StatefulWidget {
internal _DatePickerModeToggleButton(
DatePickerMode mode,
string title,
VoidCallback onTitlePressed
) {
this.mode = mode;
this.title = title;
this.onTitlePressed = onTitlePressed;
}
public readonly DatePickerMode mode;
public readonly string title;
public readonly VoidCallback onTitlePressed;
public override State createState() => new _DatePickerModeToggleButtonState();
}
class _DatePickerModeToggleButtonState : SingleTickerProviderStateMixin<_DatePickerModeToggleButton> {
AnimationController _controller;
public override void initState() {
base.initState();
_controller = new AnimationController(
value: widget.mode == DatePickerMode.year ? 0.5f : 0,
upperBound: 0.5f,
duration: new TimeSpan(0, 0, 0, 0, 200),
vsync: this
);
}
public override void didUpdateWidget(StatefulWidget statefulWidget) {
base.didUpdateWidget(statefulWidget);
if (statefulWidget is _DatePickerModeToggleButton oldWidget) {
if (oldWidget.mode == widget.mode) {
return;
}
if (widget.mode == DatePickerMode.year) {
_controller.forward();
}
else {
_controller.reverse();
}
}
}
public override Widget build(BuildContext context) {
ColorScheme colorScheme = Theme.of(context).colorScheme;
TextTheme textTheme = Theme.of(context).textTheme;
Color controlColor = colorScheme.onSurface.withOpacity(0.60f);
var rowChildren = new List<Widget> {
new Flexible(
child: new Container(
height: material_._subHeaderHeight,
child: new InkWell(
onTap: () => widget.onTitlePressed(),
child: new Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
child: new Row(
children: new List<Widget> {
new Flexible(
child: new Text(
widget.title,
overflow: TextOverflow.ellipsis,
style: textTheme.subtitle2?.copyWith(
color: controlColor
)
)
),
new RotationTransition(
turns: _controller,
child: new Icon(
Icons.arrow_drop_down,
color: controlColor
)
),
}
)
)
)
)
)
};
if (widget.mode == DatePickerMode.day) {
// Give space for the prev/next month buttons that are underneath this row
rowChildren.Add(new SizedBox(width: material_._monthNavButtonsWidth));
}
return new Container(
//TODO: update to EdgeInsetsGeometry
padding: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(start: 16, end: 4),
height: material_._subHeaderHeight,
child: new Row(
children: rowChildren
)
);
}
public override void dispose() {
_controller.dispose();
base.dispose();
}
}
class _MonthPicker : StatefulWidget {
internal _MonthPicker(
Key key = null,
DateTime? initialMonth = null,
DateTime? currentDate = null,
DateTime? firstDate = null,
DateTime? lastDate = null,
DateTime? selectedDate = null,
ValueChanged<DateTime> onChanged = null,
ValueChanged<DateTime> onDisplayedMonthChanged = null,
material_.SelectableDayPredicate selectableDayPredicate = null
) : base(key: key) {
D.assert(selectedDate != null);
D.assert(currentDate != null);
D.assert(onChanged != null);
D.assert(firstDate != null);
D.assert(lastDate != null);
D.assert(!(firstDate > lastDate));
D.assert(!(selectedDate < firstDate));
D.assert(!(selectedDate > lastDate));
this.initialMonth = initialMonth.Value;
this.currentDate = currentDate.Value;
this.firstDate = firstDate.Value;
this.lastDate = lastDate.Value;
this.selectedDate = selectedDate.Value;
this.onChanged = onChanged;
this.onDisplayedMonthChanged = onDisplayedMonthChanged;
this.selectableDayPredicate = selectableDayPredicate;
}
public readonly DateTime initialMonth;
public readonly DateTime currentDate;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly DateTime selectedDate;
public readonly ValueChanged<DateTime> onChanged;
public readonly ValueChanged<DateTime> onDisplayedMonthChanged;
public readonly material_.SelectableDayPredicate selectableDayPredicate;
public override State createState() => new _MonthPickerState();
}
class _MonthPickerState : State<_MonthPicker> {
DateTime _currentMonth;
DateTime _nextMonthDate;
DateTime _previousMonthDate;
PageController _pageController;
MaterialLocalizations _localizations;
TextDirection _textDirection;
public override void initState() {
base.initState();
_currentMonth = widget.initialMonth;
_previousMonthDate = utils.addMonthsToMonthDate(_currentMonth, -1);
_nextMonthDate = utils.addMonthsToMonthDate(_currentMonth, 1);
_pageController = new PageController(initialPage: utils.monthDelta(widget.firstDate, _currentMonth));
}
public override void didChangeDependencies() {
base.didChangeDependencies();
_localizations = MaterialLocalizations.of(context);
_textDirection = Directionality.of(context);
}
public override void dispose() {
_pageController?.dispose();
base.dispose();
}
void _handleMonthPageChanged(int monthPage) {
DateTime monthDate = utils.addMonthsToMonthDate(widget.firstDate, monthPage);
if (_currentMonth.Year != monthDate.Year || _currentMonth.Month != monthDate.Month) {
_currentMonth = new DateTime(monthDate.Year, monthDate.Month, 1);
_previousMonthDate = utils.addMonthsToMonthDate(_currentMonth, -1);
_nextMonthDate = utils.addMonthsToMonthDate(_currentMonth, 1);
widget.onDisplayedMonthChanged?.Invoke(_currentMonth);
}
}
void _handleNextMonth() {
if (!_isDisplayingLastMonth) {
// SemanticsService.announce(
// _localizations.formatMonthYear(_nextMonthDate),
// _textDirection,
// );
_pageController.nextPage(
duration: material_._monthScrollDuration,
curve: Curves.ease
);
}
}
void _handlePreviousMonth() {
if (!_isDisplayingFirstMonth) {
// SemanticsService.announce(
// _localizations.formatMonthYear(_previousMonthDate),
// _textDirection,
// );
_pageController.previousPage(
duration: material_._monthScrollDuration,
curve: Curves.ease
);
}
}
bool _isDisplayingFirstMonth {
get { return !(_currentMonth > new DateTime(widget.firstDate.Year, widget.firstDate.Month, 1)); }
}
bool _isDisplayingLastMonth {
get {
return !(_currentMonth < new DateTime(widget.lastDate.Year, widget.lastDate.Month, 1)
);
}
}
Widget _buildItems(BuildContext context, int index) {
DateTime month = utils.addMonthsToMonthDate(widget.firstDate, index);
return new _DayPicker(
key: new ValueKey<DateTime>(month),
selectedDate: widget.selectedDate,
currentDate: widget.currentDate,
onChanged: widget.onChanged,
firstDate: widget.firstDate,
lastDate: widget.lastDate,
displayedMonth: month,
selectableDayPredicate: widget.selectableDayPredicate
);
}
public override Widget build(BuildContext context) {
string previousTooltipText =
$"{_localizations.previousMonthTooltip} {_localizations.formatMonthYear(_previousMonthDate)}";
string nextTooltipText =
$"{_localizations.nextMonthTooltip} {_localizations.formatMonthYear(_nextMonthDate)}";
Color controlColor = Theme.of(context).colorScheme.onSurface.withOpacity(0.60f);
return new Column(
children: new List<Widget> {
new Container(
//TODO: update EdgeInsetsGeometry
padding: (EdgeInsets) (EdgeInsetsGeometry) EdgeInsetsDirectional.only(start: 16, end: 4),
height: material_._subHeaderHeight,
child:
new Row(
children: new List<Widget> {
new Spacer(),
new IconButton(
icon: new Icon(Icons.chevron_left),
color: controlColor,
tooltip: _isDisplayingFirstMonth ? null : previousTooltipText,
onPressed: _isDisplayingFirstMonth ? (VoidCallback) null : _handlePreviousMonth
),
new IconButton(icon: new Icon(Icons.chevron_right),
color: controlColor,
tooltip: _isDisplayingLastMonth ? null : nextTooltipText,
onPressed: _isDisplayingLastMonth ? (VoidCallback) null : _handleNextMonth
)
}
)
),
new _DayHeaders(),
new Expanded(
child: PageView.builder(
controller: _pageController,
itemBuilder: _buildItems,
itemCount: utils.monthDelta(widget.firstDate, widget.lastDate) + 1,
scrollDirection: Axis.horizontal,
onPageChanged: _handleMonthPageChanged
)
)
}
);
}
}
class _DayPicker : StatelessWidget {
internal _DayPicker(
Key key = null,
DateTime? currentDate = null,
DateTime? displayedMonth = null,
DateTime? firstDate = null,
DateTime? lastDate = null,
DateTime? selectedDate = null,
ValueChanged<DateTime> onChanged = null,
material_.SelectableDayPredicate selectableDayPredicate = null
) : base(key: key) {
D.assert(currentDate != null);
D.assert(displayedMonth != null);
D.assert(firstDate != null);
D.assert(lastDate != null);
D.assert(selectedDate != null);
D.assert(onChanged != null);
D.assert(!(firstDate > lastDate));
D.assert(!(selectedDate < firstDate));
D.assert(!(selectedDate > lastDate));
this.currentDate = currentDate.Value;
this.displayedMonth = displayedMonth.Value;
this.firstDate = firstDate.Value;
this.lastDate = lastDate.Value;
this.selectedDate = selectedDate.Value;
this.onChanged = onChanged;
this.selectableDayPredicate = selectableDayPredicate;
}
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 material_.SelectableDayPredicate selectableDayPredicate;
public override Widget build(BuildContext context) {
ColorScheme colorScheme = Theme.of(context).colorScheme;
MaterialLocalizations localizations = MaterialLocalizations.of(context);
TextTheme textTheme = Theme.of(context).textTheme;
TextStyle dayStyle = textTheme.caption;
Color enabledDayColor = colorScheme.onSurface.withOpacity(0.87f);
Color disabledDayColor = colorScheme.onSurface.withOpacity(0.38f);
Color selectedDayColor = colorScheme.onPrimary;
Color selectedDayBackground = colorScheme.primary;
Color todayColor = colorScheme.primary;
int year = displayedMonth.Year;
int month = displayedMonth.Month;
int daysInMonth = utils.getDaysInMonth(year, month);
int dayOffset = utils.firstDayOffset(year, month, localizations);
List<Widget> dayItems = new List<Widget>();
// 1-based day of month, e.g. 1-31 for January, and 1-29 for February on
// a leap year.
int day = -dayOffset;
while (day < daysInMonth) {
day++;
if (day < 1) {
dayItems.Add(new Container());
}
else {
DateTime dayToBuild = new DateTime(year, month, day);
bool isDisabled = dayToBuild > lastDate ||
dayToBuild < firstDate ||
(selectableDayPredicate != null && !selectableDayPredicate(dayToBuild));
BoxDecoration decoration = null;
Color dayColor = enabledDayColor;
bool isSelectedDay = utils.isSameDay(selectedDate, dayToBuild);
if (isSelectedDay) {
// The selected day gets a circle background highlight, and a
// contrasting text color.
dayColor = selectedDayColor;
decoration = new BoxDecoration(
color: selectedDayBackground,
shape: BoxShape.circle
);
}
else if (isDisabled) {
dayColor = disabledDayColor;
}
else if (utils.isSameDay(currentDate, dayToBuild)) {
// The current day gets a different text color and a circle stroke
// border.
dayColor = todayColor;
decoration = new BoxDecoration(
border: Border.all(color: todayColor, width: 1),
shape: BoxShape.circle
);
}
Widget dayWidget = new Container(
decoration: decoration,
child: new Center(
child: new Text(localizations.formatDecimal(day), style: dayStyle.apply(color: dayColor))
)
);
if (isDisabled) {
dayWidget = dayWidget;
}
else {
dayWidget = new GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => onChanged(dayToBuild),
child: dayWidget
);
}
dayItems.Add(dayWidget);
}
}
return new Padding(
padding: EdgeInsets.symmetric(
horizontal: material_._monthPickerHorizontalPadding
),
child: GridView.custom(
physics: new ClampingScrollPhysics(),
gridDelegate: material_._dayPickerGridDelegate,
childrenDelegate: new SliverChildListDelegate(
dayItems,
addRepaintBoundaries: false
)
)
);
}
}
class _DayPickerGridDelegate : SliverGridDelegate {
internal _DayPickerGridDelegate() {
}
const int daysPerWeek = 7;
public override SliverGridLayout getLayout(SliverConstraints constraints) {
const int columnCount = daysPerWeek;
float tileWidth = constraints.crossAxisExtent / columnCount;
float tileHeight = Mathf.Min(material_._dayPickerRowHeight,
constraints.viewportMainAxisExtent / material_._maxDayPickerRowCount);
return new SliverGridRegularTileLayout(
childCrossAxisExtent: tileWidth,
childMainAxisExtent: tileHeight,
crossAxisCount: columnCount,
crossAxisStride: tileWidth,
mainAxisStride: tileHeight,
reverseCrossAxis: AxisUtils.axisDirectionIsReversed(constraints.crossAxisDirection)
);
}
public override bool shouldRelayout(SliverGridDelegate sliverGridDelegate) => false;
}
public partial class material_ {
internal static readonly _DayPickerGridDelegate _dayPickerGridDelegate = new _DayPickerGridDelegate();
}
class _DayHeaders : StatelessWidget {
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 - 1) % 7)
break;
}
return result;
}
public override Widget build(BuildContext context) {
ThemeData theme = Theme.of(context);
ColorScheme colorScheme = theme.colorScheme;
TextStyle dayHeaderStyle = theme.textTheme.caption?.apply(
color: colorScheme.onSurface.withOpacity(0.60f)
);
MaterialLocalizations localizations = MaterialLocalizations.of(context);
List<Widget>
labels = _getDayHeaders(dayHeaderStyle, localizations);
return new Padding(
padding: EdgeInsets.symmetric(horizontal: material_._monthPickerHorizontalPadding),
child:
GridView.custom(
shrinkWrap: true,
gridDelegate: material_._dayPickerGridDelegate,
childrenDelegate: new SliverChildListDelegate(
labels,
addRepaintBoundaries: false
)
)
);
}
}
class _YearPicker : StatefulWidget {
internal _YearPicker(
Key key = null,
DateTime? currentDate = null,
DateTime? firstDate = null,
DateTime? lastDate = null,
DateTime? initialDate = null,
DateTime? selectedDate = null,
ValueChanged<DateTime> onChanged = null
) : base(key: key) {
D.assert(currentDate != null);
D.assert(firstDate != null);
D.assert(lastDate != null);
D.assert(initialDate != null);
D.assert(selectedDate != null);
D.assert(onChanged != null);
D.assert(!(firstDate > lastDate));
this.currentDate = currentDate.Value;
this.firstDate = firstDate.Value;
this.lastDate = lastDate.Value;
this.initialDate = initialDate.Value;
this.selectedDate = selectedDate.Value;
this.onChanged = onChanged;
}
public readonly DateTime currentDate;
public readonly DateTime firstDate;
public readonly DateTime lastDate;
public readonly DateTime initialDate;
public readonly DateTime selectedDate;
public readonly ValueChanged<DateTime> onChanged;
public override
State createState() => new _YearPickerState();
}
class _YearPickerState : State<_YearPicker> {
ScrollController scrollController;
// The approximate number of years necessary to fill the available space.
public const int minYears = 18;
public override void initState() {
base.initState();
// Set the scroll position to approximately center the initial year.
int initialYearIndex = widget.selectedDate.Year - widget.firstDate.Year;
int initialYearRow = (int) (1.0f * initialYearIndex / material_._yearPickerColumnCount);
// Move the offset down by 2 rows to approximately center it.
int centeredYearRow = initialYearRow - 2;
float scrollOffset = _itemCount < minYears ? 0 : centeredYearRow * material_._yearPickerRowHeight;
scrollController = new ScrollController(initialScrollOffset: scrollOffset);
}
Widget _buildYearItem(BuildContext context, int index) {
ColorScheme colorScheme = Theme.of(context).colorScheme;
TextTheme textTheme = Theme.of(context).textTheme;
// Backfill the _YearPicker with disabled years if necessary.
int offset = _itemCount < minYears ? (int) (1.0f * (minYears - _itemCount) / 2) : 0;
int year = widget.firstDate.Year + index - offset;
bool isSelected = year == widget.selectedDate.Year;
bool isCurrentYear = year == widget.currentDate.Year;
bool isDisabled = year < widget.firstDate.Year || year > widget.lastDate.Year;
const float decorationHeight = 36.0f;
const float decorationWidth = 72.0f;
Color textColor;
if (isSelected) {
textColor = colorScheme.onPrimary;
}
else if (isDisabled) {
textColor = colorScheme.onSurface.withOpacity(0.38f);
}
else if (isCurrentYear) {
textColor = colorScheme.primary;
}
else {
textColor = colorScheme.onSurface.withOpacity(0.87f);
}
TextStyle itemStyle = textTheme.bodyText1?.apply(color: textColor);
BoxDecoration decoration = null;
if (isSelected) {
decoration = new BoxDecoration(
color: colorScheme.primary,
borderRadius: BorderRadius.circular(decorationHeight / 2),
shape: BoxShape.rectangle
);
}
else if (isCurrentYear && !isDisabled) {
decoration = new BoxDecoration(
border: Border.all(
color: colorScheme.primary,
width: 1
),
borderRadius: BorderRadius.circular(decorationHeight / 2),
shape: BoxShape.rectangle
);
}
Widget yearItem = new Center(
child: new Container(
decoration: decoration,
height: decorationHeight,
width: decorationWidth,
child: new Center(
child: new Text(year.ToString(), style: itemStyle)
)
)
);
if (isDisabled) {
yearItem = yearItem;
}
else {
yearItem = new InkWell(
key: new ValueKey<int>(year),
onTap: () => {
widget.onChanged(
new DateTime(
year,
widget.initialDate.Month,
widget.initialDate.Day
)
);
},
child: yearItem
);
}
return yearItem;
}
int _itemCount {
get { return widget.lastDate.Year - widget.firstDate.Year + 1; }
}
public override Widget build(BuildContext context) {
return new Column(
children: new List<Widget> {
new Divider(),
new Expanded(
child: GridView.builder(
controller: scrollController,
gridDelegate: material_._yearPickerGridDelegate,
itemBuilder: _buildYearItem,
itemCount: Math.Max(_itemCount, minYears),
padding: EdgeInsets.symmetric(horizontal: material_._yearPickerPadding)
)
),
new Divider(),
}
);
}
}
class _YearPickerGridDelegate : SliverGridDelegate {
internal _YearPickerGridDelegate() {
}
public override SliverGridLayout getLayout(SliverConstraints constraints) {
float tileWidth =
(constraints.crossAxisExtent -
(material_._yearPickerColumnCount - 1) * material_._yearPickerRowSpacing) /
material_._yearPickerColumnCount;
return new SliverGridRegularTileLayout(
childCrossAxisExtent: tileWidth,
childMainAxisExtent: material_._yearPickerRowHeight,
crossAxisCount: material_._yearPickerColumnCount,
crossAxisStride: tileWidth + material_._yearPickerRowSpacing,
mainAxisStride: material_._yearPickerRowHeight,
reverseCrossAxis: AxisUtils.axisDirectionIsReversed(constraints.crossAxisDirection)
);
}
public override bool shouldRelayout(SliverGridDelegate sliverGridDelegate) => false;
}
public partial class material_ {
internal static readonly _YearPickerGridDelegate _yearPickerGridDelegate = new _YearPickerGridDelegate();
}
}

3
com.unity.uiwidgets/Runtime/material/pickers/calendar_date_picker.cs.meta


fileFormatVersion: 2
guid: b29a37617b764cbe8c7174802e4792f7
timeCreated: 1611818184

3
com.unity.uiwidgets/Runtime/material/pickers/date_picker_common.cs.meta


fileFormatVersion: 2
guid: c80395d6c7ce4450a7c24ab750bbed67
timeCreated: 1611820996

58
com.unity.uiwidgets/Runtime/material/pickers/date_utils.cs


using System;
using System.Collections.Generic;
namespace Unity.UIWidgets.material {
public static partial class utils {
public static DateTime dateOnly(DateTime date) {
return new DateTime(date.Year, date.Month, date.Day);
}
public static bool isSameDay(DateTime dateA, DateTime dateB) {
return
dateA.Year == dateB.Year &&
dateA.Month == dateB.Month &&
dateA.Day == dateB.Day;
}
public static int monthDelta(DateTime startDate, DateTime endDate) {
return (endDate.Year - startDate.Year) * 12 + endDate.Month - startDate.Month;
}
public static DateTime addMonthsToMonthDate(DateTime monthDate, int monthsToAdd) {
return new DateTime(monthDate.Year, monthDate.Month + monthsToAdd, 1);
}
public static int firstDayOffset(int year, int month, MaterialLocalizations localizations) {
// 0-based day of week for the month and year, with 0 representing Monday.
int weekdayFromMonday = (int) ((new DateTime(year, month, 1)).DayOfWeek) - 1;
// 0-based start of week depending on the locale, with 0 representing Sunday.
int firstDayOfWeekIndex = localizations.firstDayOfWeekIndex;
// firstDayOfWeekIndex recomputed to be Monday-based, in order to compare with
// weekdayFromMonday.
firstDayOfWeekIndex = (firstDayOfWeekIndex - 1) % 7;
// Number of days between the first day of week appearing on the calendar,
// and the day corresponding to the first of the month.
return (weekdayFromMonday - firstDayOfWeekIndex) % 7;
}
public const int february = 2;
public static int getDaysInMonth(int year, int month) {
if (month == february) {
bool isLeapYear = (year % 4 == 0) && (year % 100 != 0) ||
(year % 400 == 0);
if (isLeapYear)
return 29;
return 28;
}
List<int> daysInMonth = new List<int> {
31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
return daysInMonth[month - 1];
}
}
}

3
com.unity.uiwidgets/Runtime/material/pickers/date_utils.cs.meta


fileFormatVersion: 2
guid: 5a5006599804476d959581f0fa09860f
timeCreated: 1611819837

20
com.unity.uiwidgets/Runtime/material/pickers/date_picker_common.cs


using System;
namespace Unity.UIWidgets.material {
public enum DatePickerEntryMode {
calendar,
input,
}
public enum DatePickerMode {
day,
year,
}
public partial class material_ {
public delegate bool SelectableDayPredicate(DateTime? day);
}
}

/com.unity.uiwidgets/Runtime/material/timer.cs → /com.unity.uiwidgets/Runtime/material/time.cs

正在加载...
取消
保存