Make BoxDecoration replaceable.
Factor out a reusable interface called Decoration from BoxDecoration. Make all the consumers of BoxDecoration and the erstwhile BoxPainter into consumers of Decoration. Make a BoxPainter be something you get from a Decoration, rather than something to which you pass a BoxDecoration. Rename Shape to BoxShape now that it's documented specifically as applying to boxes. Move EdgeDims to its own file. Move FractionalOffset up so that it's with the other helper classes in its file rather than alone at the end. Minor change to RenderClipOval's hit testing to avoid taking an unnecessary square root. Rename BoxDecorationPosition to DecorationPosition since RenderDecoratedBox now takes any Decoration. Implement hit testing for rounded rects. Rename AnimatedBoxDecorationValue to AnimatedDecorationValue, and make it support lerping across any Decoration (by deferring to the objects involved).
This commit is contained in:
@@ -21,6 +21,8 @@ void main() {
|
||||
backgroundColor: new Color(0xFF0000FF)
|
||||
);
|
||||
|
||||
BoxDecoration actualDecoration;
|
||||
|
||||
tester.pumpWidget(
|
||||
new AnimatedContainer(
|
||||
key: key,
|
||||
@@ -30,7 +32,8 @@ void main() {
|
||||
);
|
||||
|
||||
RenderDecoratedBox box = key.currentState.context.findRenderObject();
|
||||
expect(box.decoration.backgroundColor, equals(decorationA.backgroundColor));
|
||||
actualDecoration = box.decoration;
|
||||
expect(actualDecoration.backgroundColor, equals(decorationA.backgroundColor));
|
||||
|
||||
tester.pumpWidget(
|
||||
new AnimatedContainer(
|
||||
@@ -41,11 +44,13 @@ void main() {
|
||||
);
|
||||
|
||||
expect(key.currentState.context.findRenderObject(), equals(box));
|
||||
expect(box.decoration.backgroundColor, equals(decorationA.backgroundColor));
|
||||
actualDecoration = box.decoration;
|
||||
expect(actualDecoration.backgroundColor, equals(decorationA.backgroundColor));
|
||||
|
||||
tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(box.decoration.backgroundColor, equals(decorationB.backgroundColor));
|
||||
actualDecoration = box.decoration;
|
||||
expect(actualDecoration.backgroundColor, equals(decorationB.backgroundColor));
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ void main() {
|
||||
new Container(
|
||||
padding: new EdgeDims.all(50.0),
|
||||
decoration: new BoxDecoration(
|
||||
shape: Shape.circle,
|
||||
shape: BoxShape.circle,
|
||||
border: new Border.all(width: 10.0, color: const Color(0x80FF00FF)),
|
||||
backgroundColor: Colors.teal[600]
|
||||
)
|
||||
|
||||
@@ -27,7 +27,7 @@ void main() {
|
||||
expect(element.renderObject is RenderDecoratedBox, isTrue);
|
||||
RenderDecoratedBox renderObject = element.renderObject;
|
||||
expect(renderObject.decoration, equals(kBoxDecorationA));
|
||||
expect(renderObject.position, equals(BoxDecorationPosition.background));
|
||||
expect(renderObject.position, equals(DecorationPosition.background));
|
||||
|
||||
tester.pumpWidget(new DecoratedBox(decoration: kBoxDecorationB));
|
||||
element = tester.findElement((Element element) => element is OneChildRenderObjectElement);
|
||||
@@ -35,7 +35,7 @@ void main() {
|
||||
expect(element.renderObject is RenderDecoratedBox, isTrue);
|
||||
renderObject = element.renderObject;
|
||||
expect(renderObject.decoration, equals(kBoxDecorationB));
|
||||
expect(renderObject.position, equals(BoxDecorationPosition.background));
|
||||
expect(renderObject.position, equals(DecorationPosition.background));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,12 +49,12 @@ void main() {
|
||||
expect(element.renderObject is RenderDecoratedBox, isTrue);
|
||||
RenderDecoratedBox renderObject = element.renderObject;
|
||||
expect(renderObject.decoration, equals(kBoxDecorationA));
|
||||
expect(renderObject.position, equals(BoxDecorationPosition.background));
|
||||
expect(renderObject.position, equals(DecorationPosition.background));
|
||||
expect(renderObject.child, isNotNull);
|
||||
expect(renderObject.child is RenderDecoratedBox, isTrue);
|
||||
RenderDecoratedBox child = renderObject.child;
|
||||
expect(child.decoration, equals(kBoxDecorationB));
|
||||
expect(child.position, equals(BoxDecorationPosition.background));
|
||||
expect(child.position, equals(DecorationPosition.background));
|
||||
expect(child.child, isNull);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
expect(element.renderObject is RenderDecoratedBox, isTrue);
|
||||
RenderDecoratedBox renderObject = element.renderObject;
|
||||
expect(renderObject.decoration, equals(kBoxDecorationA));
|
||||
expect(renderObject.position, equals(BoxDecorationPosition.background));
|
||||
expect(renderObject.position, equals(DecorationPosition.background));
|
||||
expect(renderObject.child, isNull);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user