Commit 948f3db2 authored by Ian Hickson's avatar Ian Hickson

Refactor AnimatedContainer to be reusable.

This will allow AnimatedPositioned to reuse all the same logic.
parent 682243ef
......@@ -1023,15 +1023,15 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
Positioned({
Key key,
Widget child,
this.left,
this.top,
this.right,
this.bottom,
this.left,
this.width,
this.height
}) : super(key: key, child: child) {
assert(top == null || bottom == null || height == null);
assert(left == null || right == null || width == null);
assert(top == null || bottom == null || height == null);
}
Positioned.fromRect({
......@@ -1046,6 +1046,9 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
bottom = null,
super(key: key, child: child);
/// The offset of the child's left edge from the left of the stack.
final double left;
/// The offset of the child's top edge from the top of the stack.
final double top;
......@@ -1055,17 +1058,16 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
/// The offset of the child's bottom edge from the bottom of the stack.
final double bottom;
/// The offset of the child's left edge from the left of the stack.
final double left;
/// The child's width.
///
/// Ignored if both left and right are non-null.
/// Only two out of the three horizontal values (left, right, width) can be
/// set. The third must be null.
final double width;
/// The child's height.
///
/// Ignored if both top and bottom are non-null.
/// Only two out of the three vertical values (top, bottom, height) can be
/// set. The third must be null.
final double height;
void applyParentData(RenderObject renderObject) {
......@@ -1073,6 +1075,11 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
final StackParentData parentData = renderObject.parentData;
bool needsLayout = false;
if (parentData.left != left) {
parentData.left = left;
needsLayout = true;
}
if (parentData.top != top) {
parentData.top = top;
needsLayout = true;
......@@ -1088,11 +1095,6 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
needsLayout = true;
}
if (parentData.left != left) {
parentData.left = left;
needsLayout = true;
}
if (parentData.width != width) {
parentData.width = width;
needsLayout = true;
......
......@@ -226,7 +226,11 @@ class AnimatedRelativeRectValue extends AnimatedValue<RelativeRect> {
RelativeRect lerp(double t) => RelativeRect.lerp(begin, end, t);
}
/// Animated version of [Positioned].
/// Animated version of [Positioned] which takes a specific
/// [AnimatedRelativeRectValue] and a [PerformanceView] to transition the
/// child's position from a start position to and end position over the lifetime
/// of the performance.
///
/// Only works if it's the child of a [Stack].
class PositionedTransition extends TransitionWithChild {
PositionedTransition({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment