浏览代码

update more

/siyaoH-1.17-PlatformMessage
xingweizhu 4 年前
当前提交
bf76abc7
共有 5 个文件被更改,包括 335 次插入39 次删除
  1. 155
      com.unity.uiwidgets/Runtime/material/radio.cs
  2. 59
      com.unity.uiwidgets/Runtime/material/raised_button.cs
  3. 16
      com.unity.uiwidgets/Runtime/material/snack_bar_theme.cs
  4. 27
      com.unity.uiwidgets/Runtime/material/theme_data.cs
  5. 117
      com.unity.uiwidgets/Runtime/material/ratio_list_tile.cs

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

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

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

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

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
)
);
}
}
}
正在加载...
取消
保存