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> { ...@@ -1023,15 +1023,15 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
Positioned({ Positioned({
Key key, Key key,
Widget child, Widget child,
this.left,
this.top, this.top,
this.right, this.right,
this.bottom, this.bottom,
this.left,
this.width, this.width,
this.height this.height
}) : super(key: key, child: child) { }) : super(key: key, child: child) {
assert(top == null || bottom == null || height == null);
assert(left == null || right == null || width == null); assert(left == null || right == null || width == null);
assert(top == null || bottom == null || height == null);
} }
Positioned.fromRect({ Positioned.fromRect({
...@@ -1046,6 +1046,9 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> { ...@@ -1046,6 +1046,9 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
bottom = null, bottom = null,
super(key: key, child: child); 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. /// The offset of the child's top edge from the top of the stack.
final double top; final double top;
...@@ -1055,17 +1058,16 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> { ...@@ -1055,17 +1058,16 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
/// The offset of the child's bottom edge from the bottom of the stack. /// The offset of the child's bottom edge from the bottom of the stack.
final double bottom; final double bottom;
/// The offset of the child's left edge from the left of the stack.
final double left;
/// The child's width. /// 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; final double width;
/// The child's height. /// 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; final double height;
void applyParentData(RenderObject renderObject) { void applyParentData(RenderObject renderObject) {
...@@ -1073,6 +1075,11 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> { ...@@ -1073,6 +1075,11 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
final StackParentData parentData = renderObject.parentData; final StackParentData parentData = renderObject.parentData;
bool needsLayout = false; bool needsLayout = false;
if (parentData.left != left) {
parentData.left = left;
needsLayout = true;
}
if (parentData.top != top) { if (parentData.top != top) {
parentData.top = top; parentData.top = top;
needsLayout = true; needsLayout = true;
...@@ -1088,11 +1095,6 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> { ...@@ -1088,11 +1095,6 @@ class Positioned extends ParentDataWidget<StackRenderObjectWidgetBase> {
needsLayout = true; needsLayout = true;
} }
if (parentData.left != left) {
parentData.left = left;
needsLayout = true;
}
if (parentData.width != width) { if (parentData.width != width) {
parentData.width = width; parentData.width = width;
needsLayout = true; needsLayout = true;
......
...@@ -226,7 +226,11 @@ class AnimatedRelativeRectValue extends AnimatedValue<RelativeRect> { ...@@ -226,7 +226,11 @@ class AnimatedRelativeRectValue extends AnimatedValue<RelativeRect> {
RelativeRect lerp(double t) => RelativeRect.lerp(begin, end, t); 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]. /// Only works if it's the child of a [Stack].
class PositionedTransition extends TransitionWithChild { class PositionedTransition extends TransitionWithChild {
PositionedTransition({ 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