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