From b2cf1a2453846e059b929b90a0ace175198332b8 Mon Sep 17 00:00:00 2001 From: Natalie Sampsell Date: Thu, 9 Aug 2018 13:09:11 -0700 Subject: [PATCH] SegmentedControl -> CupertinoSegmentedControl (#20267) --- .../lib/src/cupertino/segmented_control.dart | 12 +-- .../cupertino/segmented_control_test.dart | 81 ++++++++++--------- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index 99071a6530..0a6af17009 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -63,7 +63,7 @@ const Duration _kFadeDuration = Duration(milliseconds: 165); /// See also: /// /// * -class SegmentedControl extends StatefulWidget { +class CupertinoSegmentedControl extends StatefulWidget { /// Creates an iOS-style segmented control bar. /// /// The [children], [onValueChanged], [unselectedColor], [selectedColor], @@ -80,7 +80,7 @@ class SegmentedControl extends StatefulWidget { /// If no [groupValue] is provided, or the [groupValue] is null, no widget will /// appear as selected. The [groupValue] must be either null or one of the keys /// in the [children] map. - SegmentedControl({ + CupertinoSegmentedControl({ Key key, @required this.children, @required this.onValueChanged, @@ -144,7 +144,7 @@ class SegmentedControl extends StatefulWidget { /// @override /// Widget build(BuildContext context) { /// return new Container( - /// child: new SegmentedControl( + /// child: new CupertinoSegmentedControl( /// children: children, /// onValueChanged: (int newValue) { /// setState(() { @@ -198,8 +198,8 @@ class SegmentedControl extends StatefulWidget { _SegmentedControlState createState() => _SegmentedControlState(); } -class _SegmentedControlState extends State> - with TickerProviderStateMixin> { +class _SegmentedControlState extends State> + with TickerProviderStateMixin> { T _pressedKey; final List _selectionControllers = []; @@ -308,7 +308,7 @@ class _SegmentedControlState extends State> } @override - void didUpdateWidget(SegmentedControl oldWidget) { + void didUpdateWidget(CupertinoSegmentedControl oldWidget) { super.didUpdateWidget(oldWidget); if (oldWidget.children.length != widget.children.length) { diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index f4257e9bbf..a142e14ad6 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -27,7 +27,7 @@ StatefulBuilder setupSimpleSegmentedControl() { return new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -65,7 +65,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -92,7 +92,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, ), @@ -107,7 +107,7 @@ void main() { await tester.pumpWidget( boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, ), @@ -128,7 +128,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, groupValue: 2, @@ -147,7 +147,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: null, onValueChanged: (int newValue) {}, ), @@ -165,7 +165,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: null, ), @@ -179,7 +179,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, unselectedColor: null, @@ -204,7 +204,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -218,6 +218,8 @@ void main() { ), ); + await tester.pumpAndSettle(); + DefaultTextStyle textStyle = tester.widget(find.widgetWithText(DefaultTextStyle, 'Child 1')); IconTheme iconTheme = tester.widget(find.widgetWithIcon(IconTheme, const IconData(1))); @@ -246,7 +248,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -260,7 +262,7 @@ void main() { pressedColor: const Color(0x638CFC7B), ), ); - }, + }, ), ); @@ -305,7 +307,7 @@ void main() { child: new SizedBox( width: 200.0, height: 200.0, - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, ), @@ -330,7 +332,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { value = true; @@ -360,7 +362,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, groupValue: sharedValue, @@ -415,7 +417,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -453,7 +455,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -520,7 +522,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, @@ -553,7 +555,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, @@ -591,7 +593,7 @@ void main() { return boilerplate( child: Row( children: [ - new SegmentedControl( + new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, @@ -619,7 +621,7 @@ void main() { Directionality( textDirection: TextDirection.rtl, child: new Center( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, ), @@ -645,7 +647,7 @@ void main() { return Directionality( textDirection: TextDirection.rtl, child: new Center( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -689,7 +691,7 @@ void main() { return Directionality( textDirection: TextDirection.ltr, child: new Center( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -705,7 +707,7 @@ void main() { ); expect( - semantics, + semantics, hasSemantics( new TestSemantics.root( children: [ @@ -735,7 +737,8 @@ void main() { ignoreId: true, ignoreRect: true, ignoreTransform: true, - )); + ), + ); await tester.tap(find.text('Child 2')); await tester.pump(); @@ -787,7 +790,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -859,7 +862,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -879,7 +882,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -899,7 +902,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -920,7 +923,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -941,7 +944,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -962,7 +965,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -983,7 +986,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -1012,7 +1015,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1055,7 +1058,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1146,7 +1149,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1194,7 +1197,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1239,7 +1242,7 @@ void main() { new StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1294,7 +1297,7 @@ void main() { return boilerplate( child: new SizedBox( width: 800.0, - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, @@ -1328,7 +1331,7 @@ void main() { return boilerplate( child: new SizedBox( width: 800.0, - child: new SegmentedControl( + child: new CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {},