浏览代码

code style + bug fix

/main
xingwei.zhu 6 年前
当前提交
854d9b4d
共有 17 个文件被更改,包括 245 次插入172 次删除
  1. 13
      Runtime/flow/physical_shape_layer.cs
  2. 47
      Runtime/material/app_bar.cs
  3. 3
      Runtime/material/back_button.cs
  4. 45
      Runtime/material/bottom_sheet.cs
  5. 2
      Runtime/material/button_theme.cs
  6. 60
      Runtime/material/flexible_space_bar.cs
  7. 31
      Runtime/material/float_action_button.cs
  8. 24
      Runtime/material/float_action_button_location.cs
  9. 35
      Runtime/material/scaffold.cs
  10. 4
      Runtime/material/snack_bar.cs
  11. 15
      Runtime/rendering/layer.cs
  12. 109
      Runtime/rendering/proxy_box.cs
  13. 4
      Runtime/ui/compositing.cs
  14. 5
      Runtime/widgets/annotated_region.cs
  15. 8
      Runtime/widgets/perferred_size.cs
  16. 11
      Runtime/widgets/transitions.cs
  17. 1
      Samples/UIWidgetSample/MaterialSample.cs

13
Runtime/flow/physical_shape_layer.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.flow {
public class PhysicalShapeLayer : ContainerLayer {
public PhysicalShapeLayer(

}
float elevation_;
Color color_;
Color shadow_color_;

Clip clip_behavior_;
public void set_path(Path path) {
//todo: xingwei.zhu : try to do path => rect transfer
this.path_ = path;
this.isRect_ = false;
this.frameRRect_ = path.getBounds();

}
else {
Rect bounds = this.path_.getBounds();
//todo xingwei.zhu: draw & clip shadow
//todo xingwei.zhu: outter set shadow
//bounds.outset(20.0f, 20.0f);
this.paintBounds = bounds;
}

if (this.elevation_ != 0) {
this.drawShadow(context.canvas, this.path_, this.shadow_color_, this.elevation_,
this.drawShadow(context.canvas, this.path_, this.shadow_color_, this.elevation_,
this.color_.alpha != 255, this.device_pixel_ratio_);
}

//todo xingwei.zhu: drawPaint
context.canvas.drawPath(this.path_, paint);
}
this.paintChildren(context);
for (int i = 0; i < saveCount; i++) {
context.canvas.restore();

void drawShadow(Canvas canvas, Path path, Color color, float elevation, bool transparentOccluder, float dpr) {
//todo xingwei.zhu: to be implemented
}
}

47
Runtime/material/app_bar.cs


}
class _ToolbarContainerLayout : SingleChildLayoutDelegate {
public _ToolbarContainerLayout() {}
public _ToolbarContainerLayout() {
}
public override Offset getPositionForChild(Size size, Size childSize) {
return new Offset(0.0f, size.height - childSize.height);
}

}
}
public class AppBar : StatefulWidget, IPreferredSizeWidget {
public class AppBar : PreferredSizeWidget {
public AppBar(
Key key = null,
Widget leading = null,

bool? centerTitle = null,
float titleSpacing = NavigationToolbar.kMiddleSpacing,
float toolbarOpacity = 1.0f,
float bottomOpacity = 1.0f) : base(key: key) {
float bottomOpacity = 1.0f
) : base(key: key) {
this.leading = leading;
this.automaticallyImplyLeading = automaticallyImplyLeading;
this.title = title;

public readonly float toolbarOpacity;
public readonly float bottomOpacity;
public Size preferredSize { get; }
public override Size preferredSize { get; }
D.assert(themeData.platform != null);
switch (themeData.platform) {
case RuntimePlatform.IPhonePlayer:

}
public override Widget build(BuildContext context) {
D.assert(!this.widget.primary);
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
ThemeData themeData = Theme.of(context);
ScaffoldState scaffold = Scaffold.of(context, nullOk: true);

bool hasEndDrawer = scaffold?.hasEndDrawer ?? false;
bool canPop = parentRoute?.canPop ?? false;
bool useCloseButton = parentRoute is PageRoute && ((PageRoute) parentRoute).fullscreenDialog;
float opacity = new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget.toolbarOpacity);
if (centerStyle?.color != null)
float opacity =
new Interval(0.25f, 1.0f, curve: Curves.fastOutSlowIn).transform(this.widget.toolbarOpacity);
if (centerStyle?.color != null) {
if (sideStyle?.color != null)
}
if (sideStyle?.color != null) {
}
appBarIconTheme = appBarIconTheme.copyWith(
opacity: opacity * (appBarIconTheme.opacity ?? 1.0f)
);

namesRoute = true;
break;
}
title = new DefaultTextStyle(
style: centerStyle,
softWrap: false,

mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: this.widget.actions);
} else if (hasEndDrawer) {
}
else if (hasEndDrawer) {
actions = new IconButton(
icon: new Icon(Icons.menu),
onPressed: this._handleDrawerButtonEnd,

trailing: actions,
centerMiddle: this.widget._getEffectiveCenterTitle(themeData).Value,
middleSpacing: this.widget.titleSpacing);
Widget appBar = new ClipRect(
child: new CustomSingleChildLayout(
layoutDelegate: new _ToolbarContainerLayout(),

style: sideStyle,
child: toolbar)
)
);
)
);
if (this.widget.bottom != null) {
appBar = new Column(

top: true,
child: appBar);
}
appBar = new Align(
alignment: Alignment.topCenter,
child: appBar);

}
);
}
Brightness brightness = this.widget.brightness ?? themeData.primaryColorBrightness;
SystemUiOverlayStyle overlayStyle = brightness == Brightness.dark
? SystemUiOverlayStyle.light

3
Runtime/material/back_button.cs


public CloseButton(
Key key = null) : base(key: key) {
}
D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));
return new IconButton(
icon: new Icon(Icons.close),
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,

45
Runtime/material/bottom_sheet.cs


using Unity.UIWidgets.widgets;
namespace Unity.UIWidgets.material {
public static TimeSpan _kBottomSheetDuration = new TimeSpan(0, 0, 0, 0, 200);
public static readonly TimeSpan _kBottomSheetDuration = new TimeSpan(0, 0, 0, 0, 200);
public const float _kMinFlingVelocity = 700.0f;
public const float _kCloseProgressThreshold = 0.5f;
}

class _BottomSheetState : State<BottomSheet> {
public readonly GlobalKey _childKey = GlobalKey.key(debugLabel: "BottomSheet child");
readonly GlobalKey _childKey = GlobalKey.key(debugLabel: "BottomSheet child");
RenderBox renderBox = (RenderBox)this._childKey.currentContext.findRenderObject();
RenderBox renderBox = (RenderBox) this._childKey.currentContext.findRenderObject();
return renderBox.size.height;
}
}

if (this._dismissUnderway) {
return;
}
this.widget.animationController.value - details.primaryDelta.Value / (this._childHeight ?? details.primaryDelta.Value));
this.widget.animationController.value -
details.primaryDelta.Value / (this._childHeight ?? details.primaryDelta.Value));
}
void _handleDragEnd(DragEndDetails details) {

if (flingVelocity < 0.0f) {
this.widget.onClosing();
}
else if (this.widget.animationController.value < BottomSheetUtils._kCloseProgressThreshold) {
if (this.widget.animationController.value > 0.0f) {
this.widget.animationController.fling(velocity: -1.0f);
}
}
else if (this.widget.animationController.value < BottomSheetUtils._kCloseProgressThreshold) {
if (this.widget.animationController.value > 0.0f) {
this.widget.animationController.fling(velocity: -1.0f);
}
this.widget.onClosing();
}
else {
this.widget.animationController.forward();
}
this.widget.onClosing();
}
else {
this.widget.animationController.forward();
public override Widget build(BuildContext context) {
Widget bottomSheet = new Material(
key: this._childKey,

return !this.widget.enableDrag ? bottomSheet : new GestureDetector(
onVerticalDragUpdate: this._handleDragUpdate,
onVerticalDragEnd: this._handleDragEnd,
child: bottomSheet
);
return !this.widget.enableDrag
? bottomSheet
: new GestureDetector(
onVerticalDragUpdate: this._handleDragUpdate,
onVerticalDragEnd: this._handleDragEnd,
child: bottomSheet
);
}
}
}

2
Runtime/material/button_theme.cs


Key key = null,
ButtonThemeData data = null,
Widget child = null) {
return new ButtonTheme(key, data, child);
return new ButtonTheme(key, data, child);
}
public static ButtonTheme bar(

60
Runtime/material/flexible_space_bar.cs


if (this.widget.centerTitle != null) {
return this.widget.centerTitle;
}
D.assert(themeData.platform != null);
switch (themeData.platform) {
case RuntimePlatform.IPhonePlayer:

if (effectiveCenterTitle) {
return Alignment.bottomCenter;
}
return Alignment.bottomLeft;
}

return -(settings.maxExtent.Value - settings.currentExtent.Value);
case CollapseMode.none:
return 0.0f;
case CollapseMode.parallax:
float deltaExtent = settings.maxExtent.Value - settings.minExtent.Value;
return -new FloatTween(begin: 0.0f, end: deltaExtent / 4.0f).lerp(t);

}
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().");
FlexibleSpaceBarSettings settings =
(FlexibleSpaceBarSettings) context.inheritFromWidgetOfExactType(typeof(FlexibleSpaceBarSettings));
D.assert(settings != null,
"A FlexibleSpaceBar must be wrapped in the widget returned by FlexibleSpaceBar.createSettings().");
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 (this.widget.background != null) {
float fadeStart = Mathf.Max(0.0f, 1.0f - Constants.kToolbarHeight / deltaExtent);

float opacity = 1.0f - new Interval(fadeStart, fadeEnd).transform(t);
if (opacity > 0.0f) {
children.Add(new Positioned(
top: this._getCollapsePadding(t, settings),
left: 0.0f,
right: 0.0f,
height: settings.maxExtent,
child: new Opacity(
opacity: opacity,
child: this.widget.background)
top: this._getCollapsePadding(t, settings),
left: 0.0f,
right: 0.0f,
height: settings.maxExtent,
child: new Opacity(
opacity: opacity,
child: this.widget.background)
)
);
}

TextStyle titleStyle = theme.primaryTextTheme.title;
titleStyle = titleStyle.copyWith(
color: titleStyle.color.withOpacity(toolbarOpacity));
padding: EdgeInsets.fromLTRB(
effectiveCenterTitle ? 0.0f : 72.0f,
0f,
0f,
16.0f),
child: new Transform(
alignment: titleAlignment,
transform: scaleTransform,
child: new Align(
padding: EdgeInsets.fromLTRB(
effectiveCenterTitle ? 0.0f : 72.0f,
0f,
0f,
16.0f),
child: new Transform(
child: new DefaultTextStyle(
style: titleStyle,
child: title)
transform: scaleTransform,
child: new Align(
alignment: titleAlignment,
child: new DefaultTextStyle(
style: titleStyle,
child: title)
);
);
}

Widget child = null
) : base(key: key, child: child) {
D.assert(currentExtent != null);
D.assert(child != null);
this.toolbarOpacity = toolbarOpacity;
this.minExtent = minExtent;
this.maxExtent = maxExtent;

31
Runtime/material/float_action_button.cs


namespace Unity.UIWidgets.material {
static class FloatActionButtonUtils {
public static readonly BoxConstraints _kSizeConstraints = BoxConstraints.tightFor(width: 56.0f, height: 56.0f);
public static readonly BoxConstraints _kMiniSizeConstraints = BoxConstraints.tightFor(width: 40.0f, height: 40.0f);
public static readonly BoxConstraints _kExtendedSizeConstraints = new BoxConstraints(minHeight: 48.0f, maxHeight: 48.0f);
public static readonly BoxConstraints _kMiniSizeConstraints =
BoxConstraints.tightFor(width: 40.0f, height: 40.0f);
public static readonly BoxConstraints _kExtendedSizeConstraints =
new BoxConstraints(minHeight: 48.0f, maxHeight: 48.0f);
}

}
public class FloatingActionButton : StatefulWidget {
protected FloatingActionButton(
FloatingActionButton(
Key key = null,
Widget child = null,
string tooltip = null,

this.clipBehavior = clipBehavior;
this.materialTapTargetSize = materialTapTargetSize;
this.isExtended = isExtended;
this._sizeConstraints = _sizeConstraints ??
(mini ? FloatActionButtonUtils._kMiniSizeConstraints : FloatActionButtonUtils._kSizeConstraints);
this._sizeConstraints = _sizeConstraints ??
(mini
? FloatActionButtonUtils._kMiniSizeConstraints
: FloatActionButtonUtils._kSizeConstraints);
public FloatingActionButton(
Key key = null,
Widget child = null,

Clip clipBehavior = Clip.none,
MaterialTapTargetSize? materialTapTargetSize = null,
bool isExtended = false
) : this(key : key,
) : this(key: key,
child: child,
tooltip: tooltip,
foregroundColor: foregroundColor,

Widget icon = null,
Widget label = null
) {
heroTag = heroTag ?? new _DefaultHeroTag();
shape = shape ?? new StadiumBorder();
heroTag = heroTag ?? new _DefaultHeroTag();
shape = shape ?? new StadiumBorder();
BoxConstraints _sizeConstraints = FloatActionButtonUtils._kExtendedSizeConstraints;
bool mini = false;
Widget child = new _ChildOverflowBox(

materialTapTargetSize: materialTapTargetSize,
isExtended: isExtended,
_sizeConstraints: _sizeConstraints
);
);
}
public readonly Widget child;

}
public override void updateRenderObject(BuildContext context, RenderObject renderObject) {
}
}

RenderBox child = null) : base(child: child, alignment: Alignment.center) {}
RenderBox child = null) : base(child: child, alignment: Alignment.center) {
}
protected override float computeMinIntrinsicWidth(float height) {
return 0.0f;

24
Runtime/material/float_action_button_location.cs


public abstract class FloatingActionButtonLocation {
protected FloatingActionButtonLocation() {
}
public static FloatingActionButtonLocation endFloat = new _EndFloatFabLocation();
public static FloatingActionButtonLocation centerFloat = new _CenterFloatFabLocation();
public static FloatingActionButtonLocation endDocked = new _EndDockedFloatingActionButtonLocation();
public static FloatingActionButtonLocation centerDocked = new _CenterDockedFloatingActionButtonLocation();
public static readonly FloatingActionButtonLocation endFloat = new _EndFloatFabLocation();
public static readonly FloatingActionButtonLocation centerFloat = new _CenterFloatFabLocation();
public static readonly FloatingActionButtonLocation endDocked = new _EndDockedFloatingActionButtonLocation();
public static readonly FloatingActionButtonLocation centerDocked =
new _CenterDockedFloatingActionButtonLocation();
public abstract Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry);

}
float maxFabY = scaffoldGeometry.scaffoldSize.height - fabHeight;
return Math.Min(maxFabY, fabY);
return Mathf.Min(maxFabY, fabY);
}
}

protected FloatingActionButtonAnimator() {
}
public static FloatingActionButtonAnimator scaling = new _ScalingFabMotionAnimator();
public static readonly FloatingActionButtonAnimator scaling = new _ScalingFabMotionAnimator();
public abstract Offset getOffset(Offset begin, Offset end, float progress);

Animation<T> first,
Animation<T> next,
Animation<float> parent,
float swapThreshold) : base(first: first, next: next) {
float swapThreshold
) : base(first: first, next: next) {
this.parent = parent;
this.swapThreshold = swapThreshold;
}

35
Runtime/material/scaffold.cs


}
public readonly FloatingActionButtonLocation begin;
public readonly float progress;
public override Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {

public readonly BuildContext context;
float floatingActionButtonScale;
ScaffoldGeometry geometry;
public new ScaffoldGeometry value {

public readonly float floatingActionButtonMoveAnimationProgress;
public readonly FloatingActionButtonAnimator floatingActionButtonMotionAnimator;
public override void performLayout(Size size) {
BoxConstraints looseConstraints = BoxConstraints.loose(size);

class _FloatingActionButtonTransitionState : TickerProviderStateMixin<_FloatingActionButtonTransition> {
AnimationController _previousController;
Widget _previousChild;
public override void initState() {

}
}
static Animatable<float> _entranceTurnTween = new FloatTween(
static readonly Animatable<float> _entranceTurnTween = new FloatTween(
begin: 1.0f - FloatingActionButtonLocationUtils.kFloatingActionButtonTurnInterval,
end: 1.0f
).chain(new CurveTween(curve: Curves.easeIn));

public class Scaffold : StatefulWidget {
public Scaffold(
Key key = null,
AppBar appBar = null,
PreferredSizeWidget appBar = null,
Widget body = null,
Widget floatingActionButton = null,
FloatingActionButtonLocation floatingActionButtonLocation = null,

Widget bottomSheet = null,
Color backgroundColor = null,
bool resizeToAvoidBottomPadding = true,
bool primary = true) : base(key: key) {
bool primary = true
) : base(key: key) {
this.appBar = appBar;
this.body = body;
this.floatingActionButton = floatingActionButton;

this.primary = primary;
}
public readonly AppBar appBar;
public readonly PreferredSizeWidget appBar;
public readonly Widget body;

}
public class ScaffoldState : TickerProviderStateMixin<Scaffold> {
// DRAWER API
public readonly GlobalKey<DrawerControllerState> _drawerKey = GlobalKey<DrawerControllerState>.key();
public readonly GlobalKey<DrawerControllerState> _endDrawerKey = GlobalKey<DrawerControllerState>.key();

this._endDrawerKey.currentState?.open();
}
// SNACK BAR API
readonly Queue<ScaffoldFeatureController<SnackBar, SnackBarClosedReason>> _snackBars =
new Queue<ScaffoldFeatureController<SnackBar, SnackBarClosedReason>>();

this._snackBarTimer = null;
}
// PERSISTENT BOTTOM SHEET API
readonly List<_PersistentBottomSheet> _dismissedBottomSheets = new List<_PersistentBottomSheet>();
PersistentBottomSheetController<object> _currentBottomSheet;

return this._currentBottomSheet;
}
// FLOATING ACTION BUTTON API
AnimationController _floatingActionButtonMoveController;
FloatingActionButtonAnimator _floatingActionButtonAnimator;
FloatingActionButtonLocation _previousFloatingActionButtonLocation;

this._floatingActionButtonMoveController.forward(from: restartAnimationFrom);
}
ScrollController _primaryScrollController = new ScrollController();
// IOS FEATURES
readonly ScrollController _primaryScrollController = new ScrollController();
void _handleStatusBarTap() {
if (this._primaryScrollController.hasClients) {

}
}
// INTERNALS
_ScaffoldGeometryNotifier _geometryNotifier;

}
public readonly AnimationController animationController;
public readonly WidgetBuilder builder;
public override State createState() {

Widget child = null
) : base(child: child) {
D.assert(hasDrawer != null);
D.assert(child != null);
D.assert(geometryNotifier != null);
this.hasDrawer = hasDrawer.Value;
this.geometryNotifier = geometryNotifier;
}

4
Runtime/material/snack_bar.cs


Color backgroundColor = null,
SnackBarAction action = null,
TimeSpan? duration = null,
Animation<float> animation = null) : base(key: key) {
Animation<float> animation = null
) : base(key: key) {
duration = duration ?? SnackBarUtils._kSnackBarDisplayDuration;
D.assert(content != null);
this.content = content;

public readonly TimeSpan duration;
public readonly Animation<float> animation;
public override Widget build(BuildContext context) {
MediaQueryData mediaQueryData = MediaQuery.of(context);

15
Runtime/rendering/layer.cs


}
}
public class AnnotatedRegionLayer<T> : ContainerLayer
where T : class {
public class AnnotatedRegionLayer<T> : ContainerLayer
where T : class {
Size size = null) {
Size size = null) {
D.assert(value != null);
this.value = value;
this.size = size;

public readonly Size size;
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<T>("value", this.value));

internal override flow.Layer addToScene(SceneBuilder builder, Offset layerOffset = null) {
layerOffset = layerOffset ?? Offset.zero;
builder.pushPhysicalShape(
path: this.clipPath.shift(layerOffset),
elevation: this.elevation,

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new FloatProperty("elevation", this.elevation));

109
Runtime/rendering/proxy_box.cs


using Unity.UIWidgets.gestures;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using UnityEditor.Rendering;
namespace Unity.UIWidgets.rendering {
public class RenderProxyBox : RenderProxyBoxMixinRenderObjectWithChildMixinRenderBox<RenderBox> {

};
context.canvas.drawRect(offset & this.size, paint);
}
return true;
});
}

if (value == this._stepWidth) {
return;
}
this._stepWidth = value;
this.markNeedsLayout();
}

if (value == this._stepHeight) {
return;
}
this._stepHeight = value;
this.markNeedsLayout();
}

if (step == null) {
return input;
}
return (input / step.Value).ceil() * step.Value;
}

if (this.child == null) {
return 0.0f;
}
float width = this.child.getMaxIntrinsicWidth(height);
return _applyStep(width, this._stepWidth);
}

return 0.0f;
}
D.assert(width.isFinite());
float height = this.child.getMinIntrinsicHeight(width);
return _applyStep(height, this._stepHeight);

if (this.child == null) {
return 0.0f;
}
D.assert(width.isFinite());
float height = this.child.getMaxIntrinsicHeight(width);
return _applyStep(height, this._stepHeight);

D.assert(width.isFinite());
childConstraints = childConstraints.tighten(width: _applyStep(width, this._stepWidth));
}
} else {
}
else {
this.performResize();
}
}

if (this.child == null) {
return 0.0f;
}
D.assert(height.isFinite());
return this.child.getMinIntrinsicWidth(height);
}

return 0.0f;
}
D.assert(height.isFinite());
return this.child.getMaxIntrinsicWidth(height);
}

D.assert(height.isFinite());
childConstraints = childConstraints.tighten(height: height);
}
} else {
}
else {
this.performResize();
}
}

return base.hitTest(result, position: position);
}
//todo:xingwei.zhu: implementation shadow + compositeLayer (issue: no color when composite)
//todo:xingwei.zhu: implementation shadow
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();

offsetRRectAsPath.addRRect(offsetRRect);
Canvas canvas = context.canvas;
if (this.elevation != 0.0) {
//draw Shadow
/*canvas.drawRect(
offsetBounds.inflate(20.0),
_RenderPhysicalModelBase<RRect>._transparentPaint
);
canvas.drawShadow(
offsetRRectAsPath,
this.shadowColor,
this.elevation,
this.color.alpha != 0xFF
);*/
}
if (this.needsCompositing) {
PhysicalModelLayer physicalModel = new PhysicalModelLayer(
clipPath: offsetRRectAsPath,

shadowColor: this.shadowColor);
context.pushLayer(physicalModel, base.paint, offset, childPaintBounds: offsetBounds);
return;
else {
Canvas canvas = context.canvas;
if (this.elevation != 0.0) {
//draw Shadow
/*canvas.drawRect(
offsetBounds.inflate(20.0),
_RenderPhysicalModelBase<RRect>._transparentPaint
);
canvas.drawShadow(
offsetRRectAsPath,
this.shadowColor,
this.elevation,
this.color.alpha != 0xFF
);*/
}
Paint paint = new Paint {color = this.color};
canvas.drawRRect(offsetRRect, paint);
context.clipRRectAndPaint(offsetRRect, this.clipBehavior, offsetBounds,
() => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
Paint paint = new Paint {color = this.color};
canvas.drawRRect(offsetRRect, paint);
context.clipRRectAndPaint(offsetRRect, this.clipBehavior, offsetBounds,
() => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
}
}
}

return base.hitTest(result, position: position);
}
//todo:xingwei.zhu: implementation shadow + compositeLayer (issue: no color when composite)
//todo:xingwei.zhu: implementation shadow
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {
this._updateClip();

Canvas canvas = context.canvas;
if (this.needsCompositing) {
PhysicalModelLayer physicalModel = new PhysicalModelLayer(
clipPath: offsetPath,
clipBehavior: this.clipBehavior,
elevation: this.elevation,
color: this.color,
shadowColor: this.shadowColor);
context.pushLayer(physicalModel, base.paint, offset, childPaintBounds: offsetBounds);
}
else {
Canvas canvas = context.canvas;
// if (this.elevation != 0.0 && paintShadows) {
// canvas.drawRect(
// offsetBounds.inflate(20.0),

// this.color.alpha != 0xFF,
// );
// }
if (this.needsCompositing) {
PhysicalModelLayer physicalModel = new PhysicalModelLayer(
clipPath: offsetPath,
clipBehavior: this.clipBehavior,
elevation: this.elevation,
color: this.color,
shadowColor: this.shadowColor);
context.pushLayer(physicalModel, base.paint, offset, childPaintBounds: offsetBounds);
return;
Paint paint = new Paint {color = this.color, style = PaintingStyle.fill};
canvas.drawPath(offsetPath, paint);
context.clipPathAndPaint(offsetPath, this.clipBehavior,
offsetBounds, () => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
Paint paint = new Paint {color = this.color, style = PaintingStyle.fill};
canvas.drawPath(offsetPath, paint);
context.clipPathAndPaint(offsetPath, this.clipBehavior,
offsetBounds, () => base.paint(context, offset));
D.assert(context.canvas == canvas, "canvas changed even though needsCompositing was false");
}
}

}
}
public class RenderAnnotatedRegion<T> : RenderProxyBox
where T : class {
public class RenderAnnotatedRegion<T> : RenderProxyBox
where T : class {
public RenderAnnotatedRegion(
T value = null,
bool? sized = null,

}
public override void paint(PaintingContext context, Offset offset) {
AnnotatedRegionLayer<T> layer = new AnnotatedRegionLayer<T>(this.value, size: this.sized ? this.size : null);
AnnotatedRegionLayer<T> layer =
new AnnotatedRegionLayer<T>(value: this.value, size: this.sized ? this.size : null);
context.pushLayer(layer, base.paint, offset);
}
}

4
Runtime/ui/compositing.cs


public Layer pushOpacity(int alpha, Offset offset = null) {
offset = offset ?? Offset.zero;
var layer = new OpacityLayer();
layer.alpha = alpha;
layer.offset = offset;

bool isComplexHint = false, bool willChangeHint = false) {
D.assert(offset != null);
D.assert(picture != null);
if (this._currentLayer == null) {
return;
}

5
Runtime/widgets/annotated_region.cs


namespace Unity.UIWidgets.widgets {
public class AnnotatedRegion<T> : SingleChildRenderObjectWidget
where T : class {
where T : class {
bool sized = true) : base(key: key, child: child) {
bool sized = true
) : base(key: key, child: child) {
D.assert(value != null);
D.assert(child != null);
this.value = value;

8
Runtime/widgets/perferred_size.cs


using Unity.UIWidgets.ui;
namespace Unity.UIWidgets.widgets {
public abstract class PreferredSizeWidget : Widget, IPreferredSizeWidget {
public Size preferredSize { get; }
public abstract class PreferredSizeWidget : StatefulWidget, IPreferredSizeWidget {
protected PreferredSizeWidget(Key key = null) : base(key: key) {
}
public virtual Size preferredSize { get; }
}

11
Runtime/widgets/transitions.cs


using System;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;

Key key = null,
Animation<float> scale = null,
Alignment alignment = null,
Widget child = null) : base(key: key, listenable: scale) {
Widget child = null
) : base(key: key, listenable: scale) {
alignment = alignment ?? Alignment.center;
this.alignment = alignment ?? Alignment.center;
this.alignment = alignment;
this.child = child;
}

public readonly Alignment alignment;
public readonly Widget child;
protected internal override Widget build(BuildContext context) {
float scaleValue = this.scale.value;
Matrix3 transform = Matrix3.makeScale(scaleValue, scaleValue);

1
Samples/UIWidgetSample/MaterialSample.cs


public override Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
backgroundColor : Colors.blue,
title: new Text("Basic AppBar"),
actions: new List<Widget> {
new IconButton(

正在加载...
取消
保存