浏览代码
Merge branch 'material_yczhang' into 'material'
Merge branch 'material_yczhang' into 'material'
Material yczhang See merge request upm-packages/ui-widgets/com.unity.uiwidgets!46/main
Xingwei Zhu
6 年前
当前提交
8be59e50
共有 10 个文件被更改,包括 774 次插入 和 3 次删除
-
2Runtime/material/button_theme.cs
-
1Runtime/material/divider.cs
-
7Runtime/material/icon_button.cs
-
28Runtime/material/utils.cs
-
67Runtime/material/button_bar.cs
-
178Runtime/material/flat_button.cs
-
194Runtime/material/ink_ripple.cs
-
206Runtime/material/raised_button.cs
-
94Samples/MaterialSample/DividerButtonCanvas.cs
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
|
|||
public class ButtonBar : StatelessWidget { |
|||
|
|||
public ButtonBar( |
|||
Key key = null, |
|||
MainAxisAlignment alignment = MainAxisAlignment.end, |
|||
MainAxisSize mainAxisSize = MainAxisSize.max, |
|||
List<Widget> children = null |
|||
) : base(key : key) { |
|||
this.alignment = alignment; |
|||
this.mainAxisSize = mainAxisSize; |
|||
this.children = children ?? new List<Widget>(); |
|||
} |
|||
|
|||
public readonly MainAxisAlignment alignment; |
|||
public readonly MainAxisSize mainAxisSize; |
|||
public readonly List<Widget> children; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ButtonThemeData buttonTheme = ButtonTheme.of(context); |
|||
double paddingUnit = buttonTheme.padding.horizontal / 4.0; |
|||
List<Widget> _children = new List<Widget>(); |
|||
foreach(Widget _child in children) { |
|||
_children.Add(new Padding( |
|||
padding: EdgeInsets.symmetric(horizontal: paddingUnit), |
|||
child: _child |
|||
)); |
|||
} |
|||
Widget child = new Row( |
|||
mainAxisAlignment: alignment, |
|||
mainAxisSize: mainAxisSize, |
|||
children: _children |
|||
); |
|||
switch(buttonTheme.layoutBehavior) { |
|||
case ButtonBarLayoutBehavior.padded: |
|||
return new Padding( |
|||
padding: EdgeInsets.symmetric( |
|||
vertical: 2.0 * paddingUnit, |
|||
horizontal: paddingUnit |
|||
), |
|||
child: child |
|||
); |
|||
case ButtonBarLayoutBehavior.constrained: |
|||
return new Container( |
|||
padding: EdgeInsets.symmetric(horizontal: paddingUnit), |
|||
constraints: new BoxConstraints(minHeight: 52.0), |
|||
alignment: Alignment.center, |
|||
child: child |
|||
); |
|||
} |
|||
D.assert(false); |
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class FlatButton : MaterialButton { |
|||
public FlatButton( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme? textTheme = null, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness? colorBrightness = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget child = null) : base( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
elevation: null, |
|||
highlightElevation: null, |
|||
disabledElevation: null, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
animationDuration: null, |
|||
minWidth: null, |
|||
height: null, |
|||
child: child) {} |
|||
|
|||
public static FlatButton icon( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme? textTheme = null, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness? colorBrightness = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget icon = null, |
|||
Widget label = null) { |
|||
return new _FlatButtonWithIcon( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
icon: icon, |
|||
label: label |
|||
); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ThemeData theme = Theme.of(context); |
|||
ButtonThemeData buttonTheme = ButtonTheme.of(context); |
|||
|
|||
return new RawMaterialButton( |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
clipBehavior: clipBehavior ?? Clip.none, |
|||
fillColor: buttonTheme.getFillColor(this), |
|||
textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)), |
|||
highlightColor: buttonTheme.getHighlightColor(this), |
|||
splashColor: buttonTheme.getSplashColor(this), |
|||
elevation: buttonTheme.getElevation(this), |
|||
highlightElevation: buttonTheme.getHighlightElevation(this), |
|||
disabledElevation: buttonTheme.getDisabledElevation(this), |
|||
padding: buttonTheme.getPadding(this), |
|||
constraints: buttonTheme.getConstraints(this), |
|||
shape: buttonTheme.getShape(this), |
|||
animationDuration: buttonTheme.getAnimationDuration(this), |
|||
materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this), |
|||
child: child |
|||
); |
|||
} |
|||
|
|||
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 { |
|||
public _FlatButtonWithIcon( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme? textTheme = null, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness? colorBrightness = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Widget icon = null, |
|||
Widget label = null) : base( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
child: new Row( |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: new List<Widget> { |
|||
icon, |
|||
new SizedBox(width: 8.0), |
|||
label |
|||
} |
|||
)) { |
|||
D.assert(icon != null); |
|||
D.assert(label != null); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using Unity.UIWidgets.animation; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class _InkRippleFactory : InteractiveInkFeatureFactory { |
|||
public _InkRippleFactory() { |
|||
} |
|||
|
|||
public override InteractiveInkFeature create( |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
Offset position = null, |
|||
Color color = null, |
|||
bool containedInkWell = false, |
|||
RectCallback rectCallback = null, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder customBorder = null, |
|||
double? radius = null, |
|||
VoidCallback onRemoved = null |
|||
) { |
|||
D.assert(controller != null); |
|||
D.assert(referenceBox != null); |
|||
D.assert(position != null); |
|||
D.assert(color != null); |
|||
return new InkRipple( |
|||
controller: controller, |
|||
referenceBox: referenceBox, |
|||
position: position, |
|||
color: color, |
|||
containedInkWell: containedInkWell, |
|||
rectCallback: rectCallback, |
|||
borderRadius: borderRadius, |
|||
customBorder: customBorder, |
|||
radius: radius, |
|||
onRemoved: onRemoved); |
|||
} |
|||
} |
|||
|
|||
public class InkRipple : InteractiveInkFeature { |
|||
public InkRipple( |
|||
MaterialInkController controller = null, |
|||
RenderBox referenceBox = null, |
|||
Offset position = null, |
|||
Color color = null, |
|||
bool containedInkWell = false, |
|||
RectCallback rectCallback = null, |
|||
BorderRadius borderRadius = null, |
|||
ShapeBorder customBorder = null, |
|||
double? radius = null, |
|||
VoidCallback onRemoved = null |
|||
) : base( |
|||
controller: controller, |
|||
referenceBox: referenceBox, |
|||
color: color, |
|||
onRemoved: onRemoved) { |
|||
D.assert(controller != null); |
|||
D.assert(referenceBox != null); |
|||
this._position = position; |
|||
this._borderRadius = borderRadius ?? BorderRadius.zero; |
|||
this._customBorder = customBorder; |
|||
this._targetRadius = |
|||
radius ?? InkRippleUtils._getTargetRadius(referenceBox, containedInkWell, rectCallback, position); |
|||
this._clipCallback = InkRippleUtils._getClipCallback(referenceBox, containedInkWell, rectCallback); |
|||
|
|||
D.assert(this._borderRadius != null); |
|||
|
|||
this._fadeInController = new AnimationController(duration: InkRippleUtils._kFadeInDuration, vsync: controller.vsync); |
|||
this._fadeInController.addListener(controller.markNeedsPaint); |
|||
this._fadeInController.forward(); |
|||
this._fadeIn = this._fadeInController.drive(new IntTween( |
|||
begin: 0, |
|||
end: color.alpha |
|||
)); |
|||
|
|||
|
|||
this._radiusController = new AnimationController( |
|||
duration: InkRippleUtils._kUnconfirmedRippleDuration, |
|||
vsync: controller.vsync); |
|||
this._radiusController.addListener(controller.markNeedsPaint); |
|||
this._radiusController.forward(); |
|||
this._radius = this._radiusController.drive(new DoubleTween( |
|||
begin: this._targetRadius * 0.30, |
|||
end: this._targetRadius + 5.0).chain(_easeCurveTween)); |
|||
|
|||
this._fadeOutController = new AnimationController( |
|||
duration: InkRippleUtils._kFadeOutDuration, |
|||
vsync: controller.vsync); |
|||
this._fadeOutController.addListener(controller.markNeedsPaint); |
|||
this._fadeOutController.addStatusListener(this._handleAlphaStatusChanged); |
|||
this._fadeOut = this._fadeOutController.drive(new IntTween( |
|||
begin: color.alpha, |
|||
end: 0).chain(_fadeOutIntervalTween)); |
|||
|
|||
controller.addInkFeature(this); |
|||
} |
|||
|
|||
readonly Offset _position; |
|||
|
|||
readonly BorderRadius _borderRadius; |
|||
|
|||
readonly ShapeBorder _customBorder; |
|||
|
|||
readonly double _targetRadius; |
|||
|
|||
readonly RectCallback _clipCallback; |
|||
|
|||
Animation<double> _radius; |
|||
AnimationController _radiusController; |
|||
|
|||
Animation<int> _fadeIn; |
|||
AnimationController _fadeInController; |
|||
|
|||
Animation<int> _fadeOut; |
|||
AnimationController _fadeOutController; |
|||
|
|||
public static InteractiveInkFeatureFactory rippleFactory = new _InkRippleFactory(); |
|||
|
|||
static Animatable<double> _easeCurveTween = new CurveTween(curve: Curves.ease); |
|||
static Animatable<double> _fadeOutIntervalTween = new CurveTween(curve: new Interval(InkRippleUtils._kFadeOutIntervalStart, 1.0)); |
|||
|
|||
public override void confirm() { |
|||
this._radiusController.duration = InkRippleUtils._kRadiusDuration; |
|||
this._radiusController.forward(); |
|||
this._fadeOutController.animateTo(1.0, duration: InkRippleUtils._kFadeOutDuration); |
|||
} |
|||
|
|||
public override void cancel() { |
|||
_fadeInController.stop(); |
|||
double fadeOutValue = 1.0 - _fadeInController.value; |
|||
_fadeOutController.setValue(fadeOutValue); |
|||
if (fadeOutValue < 1.0) |
|||
_fadeOutController.animateTo(1.0, duration: InkRippleUtils._kCancelDuration); |
|||
} |
|||
|
|||
void _handleAlphaStatusChanged(AnimationStatus status) { |
|||
if (status == AnimationStatus.completed) { |
|||
this.dispose(); |
|||
} |
|||
} |
|||
|
|||
public override void dispose() { |
|||
this._radiusController.dispose(); |
|||
this._fadeInController.dispose(); |
|||
this._fadeOutController.dispose(); |
|||
base.dispose(); |
|||
} |
|||
|
|||
protected override void paintFeature(Canvas canvas, Matrix3 transform) { |
|||
int alpha = _fadeInController.isAnimating ? _fadeIn.value : _fadeOut.value; |
|||
Paint paint = new Paint {color = this.color.withAlpha(alpha)}; |
|||
Offset center = Offset.lerp( |
|||
_position, |
|||
referenceBox.size.center(Offset.zero), |
|||
Curves.ease.transform(_radiusController.value) |
|||
); |
|||
Offset originOffset = MatrixUtils.getAsTranslation(transform); |
|||
canvas.save(); |
|||
if (originOffset == null) { |
|||
canvas.concat(transform); |
|||
} else { |
|||
canvas.translate(originOffset.dx, originOffset.dy); |
|||
} |
|||
|
|||
if (this._clipCallback != null) { |
|||
Rect rect = this._clipCallback(); |
|||
if (this._customBorder != null) { |
|||
canvas.clipPath(this._customBorder.getOuterPath(rect)); |
|||
} |
|||
else if (this._borderRadius != BorderRadius.zero) { |
|||
canvas.clipRRect(RRect.fromRectAndCorners( |
|||
rect, |
|||
topLeft: this._borderRadius.topLeft, |
|||
topRight: this._borderRadius.topRight, |
|||
bottomLeft: this._borderRadius.bottomLeft, |
|||
bottomRight: this._borderRadius.bottomRight)); |
|||
} |
|||
else { |
|||
canvas.clipRect(rect); |
|||
} |
|||
} |
|||
|
|||
//todo xingwei.zhu: remove this condition when drawCircle bug fixed (when radius.value == 0)
|
|||
if (this._radius.value != 0) { |
|||
canvas.drawCircle(center, this._radius.value, paint); |
|||
} |
|||
|
|||
canvas.restore(); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.service; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class RaisedButton : MaterialButton { |
|||
public RaisedButton( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme textTheme = ButtonTextTheme.normal, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness? colorBrightness = null, |
|||
double? elevation = null, |
|||
double? highlightElevation = null, |
|||
double? disabledElevation = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
TimeSpan? animationDuration = null, |
|||
Widget child = null) : base( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
elevation: elevation, |
|||
highlightElevation: highlightElevation, |
|||
disabledElevation: disabledElevation, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
animationDuration: animationDuration, |
|||
child: child) { |
|||
|
|||
D.assert(elevation == null || elevation >= 0.0); |
|||
D.assert(highlightElevation == null || highlightElevation >= 0.0); |
|||
D.assert(disabledElevation == null || disabledElevation >= 0.0); |
|||
} |
|||
|
|||
public static RaisedButton icon( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme textTheme = ButtonTextTheme.normal, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness colorBrightness = Brightness.dark, |
|||
double? elevation = null, |
|||
double? highlightElevation = null, |
|||
double? disabledElevation = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize materialTapTargetSize = MaterialTapTargetSize.padded, |
|||
TimeSpan? animationDuration = null, |
|||
Widget icon = null, |
|||
Widget label = null) { |
|||
return new _RaisedButtonWithIcon( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
elevation: elevation, |
|||
highlightElevation: highlightElevation, |
|||
disabledElevation: disabledElevation, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
animationDuration: animationDuration, |
|||
icon: icon, |
|||
label: label); |
|||
} |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ThemeData theme = Theme.of(context); |
|||
ButtonThemeData buttonTheme = ButtonTheme.of(context); |
|||
|
|||
return new RawMaterialButton( |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
clipBehavior: clipBehavior ?? Clip.none, |
|||
fillColor: buttonTheme.getFillColor(this), |
|||
textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)), |
|||
highlightColor: buttonTheme.getHighlightColor(this), |
|||
splashColor: buttonTheme.getSplashColor(this), |
|||
elevation: buttonTheme.getElevation(this), |
|||
highlightElevation: buttonTheme.getHighlightElevation(this), |
|||
disabledElevation: buttonTheme.getDisabledElevation(this), |
|||
padding: buttonTheme.getPadding(this), |
|||
constraints: buttonTheme.getConstraints(this), |
|||
shape: buttonTheme.getShape(this), |
|||
animationDuration: buttonTheme.getAnimationDuration(this), |
|||
materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this), |
|||
child: child |
|||
); |
|||
} |
|||
|
|||
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<double?>("elevation", elevation, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<double?>("highlightElevation", highlightElevation, defaultValue: null)); |
|||
properties.add(new DiagnosticsProperty<double?>("disabledElevation", disabledElevation, 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 _RaisedButtonWithIcon : RaisedButton { |
|||
public _RaisedButtonWithIcon( |
|||
Key key = null, |
|||
VoidCallback onPressed = null, |
|||
ValueChanged<bool> onHighlightChanged = null, |
|||
ButtonTextTheme textTheme = ButtonTextTheme.normal, |
|||
Color textColor = null, |
|||
Color disabledTextColor = null, |
|||
Color color = null, |
|||
Color disabledColor = null, |
|||
Color highlightColor = null, |
|||
Color splashColor = null, |
|||
Brightness colorBrightness = Brightness.dark, |
|||
double? elevation = null, |
|||
double? highlightElevation = null, |
|||
double? disabledElevation = null, |
|||
EdgeInsets padding = null, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize materialTapTargetSize = MaterialTapTargetSize.padded, |
|||
TimeSpan? animationDuration = null, |
|||
Widget icon = null, |
|||
Widget label = null) : base( |
|||
key: key, |
|||
onPressed: onPressed, |
|||
onHighlightChanged: onHighlightChanged, |
|||
textTheme: textTheme, |
|||
textColor: textColor, |
|||
disabledTextColor: disabledTextColor, |
|||
color: color, |
|||
disabledColor: disabledColor, |
|||
highlightColor: highlightColor, |
|||
splashColor: splashColor, |
|||
colorBrightness: colorBrightness, |
|||
elevation: elevation, |
|||
highlightElevation: highlightElevation, |
|||
disabledElevation: disabledElevation, |
|||
padding: padding, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
animationDuration: animationDuration, |
|||
child: new Row( |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: new List<Widget> { |
|||
icon, |
|||
new SizedBox(width: 8.0), |
|||
label |
|||
} |
|||
)) { |
|||
D.assert(elevation == null || elevation >= 0.0); |
|||
D.assert(highlightElevation == null || highlightElevation >= 0.0); |
|||
D.assert(disabledElevation == null || disabledElevation >= 0.0); |
|||
D.assert(icon != null); |
|||
D.assert(label != null); |
|||
} |
|||
} |
|||
} |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.engine; |
|||
using Unity.UIWidgets.widgets; |
|||
using Unity.UIWidgets.gestures; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.material; |
|||
using Unity.UIWidgets.ui; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace UIWidgetsSample { |
|||
public class DividerButtonCanvas : WidgetCanvas { |
|||
protected override Widget getWidget() { |
|||
return new DemoApp(); |
|||
} |
|||
|
|||
public class DemoApp : StatefulWidget { |
|||
public DemoApp(Key key = null) : base(key) { |
|||
|
|||
} |
|||
public override State createState() { |
|||
return new _DemoAppState(); |
|||
} |
|||
} |
|||
|
|||
public class _DemoAppState : State<DemoApp> { |
|||
string title = "Hello"; |
|||
string subtitle = "World"; |
|||
TextEditingController controller = new TextEditingController(""); |
|||
public override Widget build(BuildContext context) { |
|||
return new Container( |
|||
height: 200, |
|||
padding: EdgeInsets.all(10), |
|||
decoration: new BoxDecoration( |
|||
color: new Color(0xFFEF1F7F), |
|||
border: Border.all(color: Color.fromARGB(255, 0xDF, 0x10, 0x70), width: 5), |
|||
borderRadius: BorderRadius.all(20) |
|||
), |
|||
child: new Center( |
|||
child: new Column( |
|||
children: new List<Widget>() { |
|||
new Text(title), |
|||
new Divider(), |
|||
new Text(subtitle), |
|||
new Divider(), |
|||
new Container( |
|||
width: 500, |
|||
decoration: new BoxDecoration(border: Border.all(new Color(0xFF00FF00), 1)), |
|||
child: new EditableText( |
|||
controller: controller, |
|||
focusNode: new FocusNode(), |
|||
style: new TextStyle( |
|||
fontSize: 18, |
|||
height: 1.5f, |
|||
color: new Color(0xFFFF89FD)), |
|||
cursorColor: Color.fromARGB(255, 0, 0, 0) |
|||
) |
|||
), |
|||
new Divider(), |
|||
new ButtonBar( |
|||
children: new List<Widget> { |
|||
new FlatButton( |
|||
onPressed: () => { |
|||
setState(() => { |
|||
title = controller.text; |
|||
}); |
|||
}, |
|||
padding: EdgeInsets.all(5.0), |
|||
child: new Center( |
|||
child: new Text("Set Title") |
|||
) |
|||
), |
|||
new RaisedButton( |
|||
onPressed: () => { |
|||
setState(() => { |
|||
subtitle = controller.text; |
|||
}); |
|||
}, |
|||
padding: EdgeInsets.all(5.0), |
|||
child: new Center( |
|||
child: new Text("Set Subtitle") |
|||
) |
|||
) |
|||
} |
|||
) |
|||
} |
|||
) |
|||
) |
|||
); |
|||
} |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue