Commit 726eff49 authored by Adam Barth's avatar Adam Barth

[rename fixit] *OneChild* -> *SingleChild*

Fixes #1482
parent e71bd77e
......@@ -35,7 +35,7 @@ class RenderDots extends RenderConstrainedBox {
}
}
class Dots extends OneChildRenderObjectWidget {
class Dots extends SingleChildRenderObjectWidget {
Dots({ Key key, Widget child }) : super(key: key, child: child);
RenderDots createRenderObject(BuildContext context) => new RenderDots();
}
......
......@@ -94,7 +94,7 @@ class _BottomSheetState extends State<BottomSheet> {
// MODAL BOTTOM SHEETS
class _ModalBottomSheetLayout extends OneChildLayoutDelegate {
class _ModalBottomSheetLayout extends SingleChildLayoutDelegate {
_ModalBottomSheetLayout(this.progress);
final double progress;
......@@ -133,7 +133,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
animation: config.route.animation,
builder: (BuildContext context, Widget child) {
return new ClipRect(
child: new CustomOneChildLayout(
child: new CustomSingleChildLayout(
delegate: new _ModalBottomSheetLayout(config.route.animation.value),
child: new BottomSheet(
animationController: config.route.animation,
......
......@@ -274,7 +274,7 @@ class RenderInkFeatures extends RenderProxyBox implements MaterialInkController
}
}
class InkFeatures extends OneChildRenderObjectWidget {
class InkFeatures extends SingleChildRenderObjectWidget {
InkFeatures({ Key key, this.color, Widget child }) : super(key: key, child: child);
final Color color;
......
......@@ -233,7 +233,7 @@ class _PopupMenu<T> extends StatelessComponent {
}
}
class _PopupMenuRouteLayout extends OneChildLayoutDelegate {
class _PopupMenuRouteLayout extends SingleChildLayoutDelegate {
_PopupMenuRouteLayout(this.position, this.selectedItemOffset);
final ModalPosition position;
......@@ -316,7 +316,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
final Size screenSize = MediaQuery.of(context).size;
return new ConstrainedBox(
constraints: new BoxConstraints(maxWidth: screenSize.width, maxHeight: screenSize.height),
child: new CustomOneChildLayout(
child: new CustomSingleChildLayout(
delegate: new _PopupMenuRouteLayout(position, selectedItemOffset),
child: new _PopupMenu<T>(route: this)
)
......
......@@ -189,7 +189,7 @@ class _TooltipState extends State<Tooltip> {
}
}
class _TooltipPositionDelegate extends OneChildLayoutDelegate {
class _TooltipPositionDelegate extends SingleChildLayoutDelegate {
_TooltipPositionDelegate({
this.target,
this.verticalOffset,
......@@ -271,7 +271,7 @@ class _TooltipOverlay extends StatelessComponent {
right: 0.0,
bottom: 0.0,
child: new IgnorePointer(
child: new CustomOneChildLayout(
child: new CustomSingleChildLayout(
delegate: new _TooltipPositionDelegate(
target: target,
verticalOffset: verticalOffset,
......
......@@ -5,7 +5,7 @@
import 'box.dart';
import 'object.dart';
// For OneChildLayoutDelegate and RenderCustomOneChildLayoutBox, see shifted_box.dart
// For SingleChildLayoutDelegate and RenderCustomSingleChildLayoutBox, see shifted_box.dart
/// [ParentData] used by [RenderCustomMultiChildLayoutBox].
class MultiChildLayoutParentData extends ContainerBoxParentDataMixin<RenderBox> {
......
......@@ -506,7 +506,7 @@ class RenderOverflowBox extends RenderShiftedBox {
}
/// A delegate for computing the layout of a render object with a single child.
class OneChildLayoutDelegate {
class SingleChildLayoutDelegate {
/// Returns the size of this object given the incoming constraints.
Size getSize(BoxConstraints constraints) => constraints.biggest;
......@@ -517,7 +517,7 @@ class OneChildLayoutDelegate {
Offset getPositionForChild(Size size, Size childSize) => Offset.zero;
/// Override this method to return true when the child needs to be laid out.
bool shouldRelayout(OneChildLayoutDelegate oldDelegate) => true;
bool shouldRelayout(SingleChildLayoutDelegate oldDelegate) => true;
}
/// Defers the layout of its single child to a delegate.
......@@ -526,18 +526,18 @@ class OneChildLayoutDelegate {
/// decide where to position the child. The delegate can also determine the size
/// of the parent, but the size of the parent cannot depend on the size of the
/// child.
class RenderCustomOneChildLayoutBox extends RenderShiftedBox {
RenderCustomOneChildLayoutBox({
class RenderCustomSingleChildLayoutBox extends RenderShiftedBox {
RenderCustomSingleChildLayoutBox({
RenderBox child,
OneChildLayoutDelegate delegate
SingleChildLayoutDelegate delegate
}) : _delegate = delegate, super(child) {
assert(delegate != null);
}
/// A delegate that controls this object's layout.
OneChildLayoutDelegate get delegate => _delegate;
OneChildLayoutDelegate _delegate;
void set delegate (OneChildLayoutDelegate newDelegate) {
SingleChildLayoutDelegate get delegate => _delegate;
SingleChildLayoutDelegate _delegate;
void set delegate (SingleChildLayoutDelegate newDelegate) {
assert(newDelegate != null);
if (_delegate == newDelegate)
return;
......
This diff is collapsed.
......@@ -506,12 +506,12 @@ abstract class LeafRenderObjectWidget extends RenderObjectWidget {
/// A superclass for RenderObjectWidgets that configure RenderObject subclasses
/// that have a single child slot. (This superclass only provides the storage
/// for that child, it doesn't actually provide the updating logic.)
abstract class OneChildRenderObjectWidget extends RenderObjectWidget {
const OneChildRenderObjectWidget({ Key key, this.child }) : super(key: key);
abstract class SingleChildRenderObjectWidget extends RenderObjectWidget {
const SingleChildRenderObjectWidget({ Key key, this.child }) : super(key: key);
final Widget child;
OneChildRenderObjectElement createElement() => new OneChildRenderObjectElement(this);
SingleChildRenderObjectElement createElement() => new SingleChildRenderObjectElement(this);
}
/// A superclass for RenderObjectWidgets that configure RenderObject subclasses
......@@ -1772,10 +1772,10 @@ class LeafRenderObjectElement extends RenderObjectElement {
}
/// Instantiation of RenderObjectWidgets that have up to one child
class OneChildRenderObjectElement extends RenderObjectElement {
OneChildRenderObjectElement(OneChildRenderObjectWidget widget) : super(widget);
class SingleChildRenderObjectElement extends RenderObjectElement {
SingleChildRenderObjectElement(SingleChildRenderObjectWidget widget) : super(widget);
OneChildRenderObjectWidget get widget => super.widget;
SingleChildRenderObjectWidget get widget => super.widget;
Element _child;
......@@ -1796,7 +1796,7 @@ class OneChildRenderObjectElement extends RenderObjectElement {
_child = updateChild(_child, widget.child, null);
}
void update(OneChildRenderObjectWidget newWidget) {
void update(SingleChildRenderObjectWidget newWidget) {
super.update(newWidget);
assert(widget == newWidget);
_child = updateChild(_child, widget.child, null);
......
......@@ -375,7 +375,7 @@ class RawGestureDetectorState extends State<RawGestureDetector> {
}
}
class _GestureSemantics extends OneChildRenderObjectWidget {
class _GestureSemantics extends SingleChildRenderObjectWidget {
_GestureSemantics({
Key key,
Widget child,
......
......@@ -7,7 +7,7 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';
import 'package:test/test.dart';
class TestOneChildLayoutDelegate extends OneChildLayoutDelegate {
class TestSingleChildLayoutDelegate extends SingleChildLayoutDelegate {
BoxConstraints constraintsFromGetSize;
BoxConstraints constraintsFromGetConstraintsForChild;
Size sizeFromGetPositionForChild;
......@@ -46,14 +46,14 @@ class TestOneChildLayoutDelegate extends OneChildLayoutDelegate {
}
}
Widget buildFrame(OneChildLayoutDelegate delegate) {
return new Center(child: new CustomOneChildLayout(delegate: delegate, child: new Container()));
Widget buildFrame(SingleChildLayoutDelegate delegate) {
return new Center(child: new CustomSingleChildLayout(delegate: delegate, child: new Container()));
}
void main() {
test('Control test for CustomOneChildLayout', () {
test('Control test for CustomSingleChildLayout', () {
testWidgets((WidgetTester tester) {
TestOneChildLayoutDelegate delegate = new TestOneChildLayoutDelegate();
TestSingleChildLayoutDelegate delegate = new TestSingleChildLayoutDelegate();
tester.pumpWidget(buildFrame(delegate));
expect(delegate.constraintsFromGetSize.minWidth, 0.0);
......@@ -74,9 +74,9 @@ void main() {
});
});
test('Test OneChildDelegate shouldRelayout method', () {
test('Test SingleChildDelegate shouldRelayout method', () {
testWidgets((WidgetTester tester) {
TestOneChildLayoutDelegate delegate = new TestOneChildLayoutDelegate();
TestSingleChildLayoutDelegate delegate = new TestSingleChildLayoutDelegate();
tester.pumpWidget(buildFrame(delegate));
// Layout happened because the delegate was set.
......@@ -84,14 +84,14 @@ void main() {
expect(delegate.shouldRelayoutCalled, isFalse);
// Layout did not happen because shouldRelayout() returned false.
delegate = new TestOneChildLayoutDelegate();
delegate = new TestSingleChildLayoutDelegate();
delegate.shouldRelayoutValue = false;
tester.pumpWidget(buildFrame(delegate));
expect(delegate.shouldRelayoutCalled, isTrue);
expect(delegate.constraintsFromGetConstraintsForChild, isNull);
// Layout happened because shouldRelayout() returned true.
delegate = new TestOneChildLayoutDelegate();
delegate = new TestSingleChildLayoutDelegate();
delegate.shouldRelayoutValue = true;
tester.pumpWidget(buildFrame(delegate));
expect(delegate.shouldRelayoutCalled, isTrue);
......
......@@ -21,8 +21,8 @@ void main() {
test('RenderObjectWidget smoke test', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(new DecoratedBox(decoration: kBoxDecorationA));
OneChildRenderObjectElement element =
tester.findElement((Element element) => element is OneChildRenderObjectElement);
SingleChildRenderObjectElement element =
tester.findElement((Element element) => element is SingleChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox renderObject = element.renderObject;
......@@ -30,7 +30,7 @@ void main() {
expect(renderObject.position, equals(DecorationPosition.background));
tester.pumpWidget(new DecoratedBox(decoration: kBoxDecorationB));
element = tester.findElement((Element element) => element is OneChildRenderObjectElement);
element = tester.findElement((Element element) => element is SingleChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
renderObject = element.renderObject;
......@@ -43,8 +43,8 @@ void main() {
testWidgets((WidgetTester tester) {
void checkFullTree() {
OneChildRenderObjectElement element =
tester.findElement((Element element) => element is OneChildRenderObjectElement);
SingleChildRenderObjectElement element =
tester.findElement((Element element) => element is SingleChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox renderObject = element.renderObject;
......@@ -59,8 +59,8 @@ void main() {
}
void childBareTree() {
OneChildRenderObjectElement element =
tester.findElement((Element element) => element is OneChildRenderObjectElement);
SingleChildRenderObjectElement element =
tester.findElement((Element element) => element is SingleChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox renderObject = element.renderObject;
......@@ -138,8 +138,8 @@ void main() {
)
));
OneChildRenderObjectElement element =
tester.findElement((Element element) => element is OneChildRenderObjectElement);
SingleChildRenderObjectElement element =
tester.findElement((Element element) => element is SingleChildRenderObjectElement);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox parent = element.renderObject;
expect(parent.child is RenderDecoratedBox, isTrue);
......@@ -155,7 +155,7 @@ void main() {
));
element =
tester.findElement((Element element) => element is OneChildRenderObjectElement);
tester.findElement((Element element) => element is SingleChildRenderObjectElement);
expect(element.renderObject is RenderDecoratedBox, isTrue);
expect(element.renderObject, equals(parent));
expect(parent.child, isNull);
......
......@@ -14,8 +14,8 @@ void main() {
testWidgets((WidgetTester tester) {
void checkTree(BoxDecoration expectedDecoration) {
OneChildRenderObjectElement element =
tester.findElement((Element element) => element is OneChildRenderObjectElement);
SingleChildRenderObjectElement element =
tester.findElement((Element element) => element is SingleChildRenderObjectElement);
expect(element, isNotNull);
expect(element.renderObject is RenderDecoratedBox, isTrue);
RenderDecoratedBox renderObject = element.renderObject;
......
part of flutter_sprites;
/// A widget that uses a [SpriteBox] to render a sprite node tree to the screen.
class SpriteWidget extends OneChildRenderObjectWidget {
class SpriteWidget extends SingleChildRenderObjectWidget {
/// The rootNode of the sprite node tree.
///
......
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