Unverified Commit b2cf1a24 authored by Natalie Sampsell's avatar Natalie Sampsell Committed by GitHub

SegmentedControl -> CupertinoSegmentedControl (#20267)

parent a49bffa5
...@@ -63,7 +63,7 @@ const Duration _kFadeDuration = Duration(milliseconds: 165); ...@@ -63,7 +63,7 @@ const Duration _kFadeDuration = Duration(milliseconds: 165);
/// See also: /// See also:
/// ///
/// * <https://developer.apple.com/design/human-interface-guidelines/ios/controls/segmented-controls/> /// * <https://developer.apple.com/design/human-interface-guidelines/ios/controls/segmented-controls/>
class SegmentedControl<T> extends StatefulWidget { class CupertinoSegmentedControl<T> extends StatefulWidget {
/// Creates an iOS-style segmented control bar. /// Creates an iOS-style segmented control bar.
/// ///
/// The [children], [onValueChanged], [unselectedColor], [selectedColor], /// The [children], [onValueChanged], [unselectedColor], [selectedColor],
...@@ -80,7 +80,7 @@ class SegmentedControl<T> extends StatefulWidget { ...@@ -80,7 +80,7 @@ class SegmentedControl<T> extends StatefulWidget {
/// If no [groupValue] is provided, or the [groupValue] is null, no widget will /// 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 /// appear as selected. The [groupValue] must be either null or one of the keys
/// in the [children] map. /// in the [children] map.
SegmentedControl({ CupertinoSegmentedControl({
Key key, Key key,
@required this.children, @required this.children,
@required this.onValueChanged, @required this.onValueChanged,
...@@ -144,7 +144,7 @@ class SegmentedControl<T> extends StatefulWidget { ...@@ -144,7 +144,7 @@ class SegmentedControl<T> extends StatefulWidget {
/// @override /// @override
/// Widget build(BuildContext context) { /// Widget build(BuildContext context) {
/// return new Container( /// return new Container(
/// child: new SegmentedControl<int>( /// child: new CupertinoSegmentedControl<int>(
/// children: children, /// children: children,
/// onValueChanged: (int newValue) { /// onValueChanged: (int newValue) {
/// setState(() { /// setState(() {
...@@ -198,8 +198,8 @@ class SegmentedControl<T> extends StatefulWidget { ...@@ -198,8 +198,8 @@ class SegmentedControl<T> extends StatefulWidget {
_SegmentedControlState<T> createState() => _SegmentedControlState<T>(); _SegmentedControlState<T> createState() => _SegmentedControlState<T>();
} }
class _SegmentedControlState<T> extends State<SegmentedControl<T>> class _SegmentedControlState<T> extends State<CupertinoSegmentedControl<T>>
with TickerProviderStateMixin<SegmentedControl<T>> { with TickerProviderStateMixin<CupertinoSegmentedControl<T>> {
T _pressedKey; T _pressedKey;
final List<AnimationController> _selectionControllers = <AnimationController>[]; final List<AnimationController> _selectionControllers = <AnimationController>[];
...@@ -308,7 +308,7 @@ class _SegmentedControlState<T> extends State<SegmentedControl<T>> ...@@ -308,7 +308,7 @@ class _SegmentedControlState<T> extends State<SegmentedControl<T>>
} }
@override @override
void didUpdateWidget(SegmentedControl<T> oldWidget) { void didUpdateWidget(CupertinoSegmentedControl<T> oldWidget) {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (oldWidget.children.length != widget.children.length) { if (oldWidget.children.length != widget.children.length) {
......
...@@ -27,7 +27,7 @@ StatefulBuilder setupSimpleSegmentedControl() { ...@@ -27,7 +27,7 @@ StatefulBuilder setupSimpleSegmentedControl() {
return new StatefulBuilder( return new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -65,7 +65,7 @@ void main() { ...@@ -65,7 +65,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
...@@ -92,7 +92,7 @@ void main() { ...@@ -92,7 +92,7 @@ void main() {
try { try {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
), ),
...@@ -107,7 +107,7 @@ void main() { ...@@ -107,7 +107,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
), ),
...@@ -128,7 +128,7 @@ void main() { ...@@ -128,7 +128,7 @@ void main() {
try { try {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
groupValue: 2, groupValue: 2,
...@@ -147,7 +147,7 @@ void main() { ...@@ -147,7 +147,7 @@ void main() {
try { try {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: null, children: null,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
), ),
...@@ -165,7 +165,7 @@ void main() { ...@@ -165,7 +165,7 @@ void main() {
try { try {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: null, onValueChanged: null,
), ),
...@@ -179,7 +179,7 @@ void main() { ...@@ -179,7 +179,7 @@ void main() {
try { try {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
unselectedColor: null, unselectedColor: null,
...@@ -204,7 +204,7 @@ void main() { ...@@ -204,7 +204,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -218,6 +218,8 @@ void main() { ...@@ -218,6 +218,8 @@ void main() {
), ),
); );
await tester.pumpAndSettle();
DefaultTextStyle textStyle = tester.widget(find.widgetWithText(DefaultTextStyle, 'Child 1')); DefaultTextStyle textStyle = tester.widget(find.widgetWithText(DefaultTextStyle, 'Child 1'));
IconTheme iconTheme = tester.widget(find.widgetWithIcon(IconTheme, const IconData(1))); IconTheme iconTheme = tester.widget(find.widgetWithIcon(IconTheme, const IconData(1)));
...@@ -246,7 +248,7 @@ void main() { ...@@ -246,7 +248,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -260,7 +262,7 @@ void main() { ...@@ -260,7 +262,7 @@ void main() {
pressedColor: const Color(0x638CFC7B), pressedColor: const Color(0x638CFC7B),
), ),
); );
}, },
), ),
); );
...@@ -305,7 +307,7 @@ void main() { ...@@ -305,7 +307,7 @@ void main() {
child: new SizedBox( child: new SizedBox(
width: 200.0, width: 200.0,
height: 200.0, height: 200.0,
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
), ),
...@@ -330,7 +332,7 @@ void main() { ...@@ -330,7 +332,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
value = true; value = true;
...@@ -360,7 +362,7 @@ void main() { ...@@ -360,7 +362,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
groupValue: sharedValue, groupValue: sharedValue,
...@@ -415,7 +417,7 @@ void main() { ...@@ -415,7 +417,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -453,7 +455,7 @@ void main() { ...@@ -453,7 +455,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -520,7 +522,7 @@ void main() { ...@@ -520,7 +522,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
...@@ -553,7 +555,7 @@ void main() { ...@@ -553,7 +555,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
...@@ -591,7 +593,7 @@ void main() { ...@@ -591,7 +593,7 @@ void main() {
return boilerplate( return boilerplate(
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
new SegmentedControl<int>( new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
...@@ -619,7 +621,7 @@ void main() { ...@@ -619,7 +621,7 @@ void main() {
Directionality( Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
child: new Center( child: new Center(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
), ),
...@@ -645,7 +647,7 @@ void main() { ...@@ -645,7 +647,7 @@ void main() {
return Directionality( return Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
child: new Center( child: new Center(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -689,7 +691,7 @@ void main() { ...@@ -689,7 +691,7 @@ void main() {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new Center( child: new Center(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -705,7 +707,7 @@ void main() { ...@@ -705,7 +707,7 @@ void main() {
); );
expect( expect(
semantics, semantics,
hasSemantics( hasSemantics(
new TestSemantics.root( new TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
...@@ -735,7 +737,8 @@ void main() { ...@@ -735,7 +737,8 @@ void main() {
ignoreId: true, ignoreId: true,
ignoreRect: true, ignoreRect: true,
ignoreTransform: true, ignoreTransform: true,
)); ),
);
await tester.tap(find.text('Child 2')); await tester.tap(find.text('Child 2'));
await tester.pump(); await tester.pump();
...@@ -787,7 +790,7 @@ void main() { ...@@ -787,7 +790,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
...@@ -859,7 +862,7 @@ void main() { ...@@ -859,7 +862,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -879,7 +882,7 @@ void main() { ...@@ -879,7 +882,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -899,7 +902,7 @@ void main() { ...@@ -899,7 +902,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -920,7 +923,7 @@ void main() { ...@@ -920,7 +923,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -941,7 +944,7 @@ void main() { ...@@ -941,7 +944,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -962,7 +965,7 @@ void main() { ...@@ -962,7 +965,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -983,7 +986,7 @@ void main() { ...@@ -983,7 +986,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
setState(() { setState(() {
...@@ -1012,7 +1015,7 @@ void main() { ...@@ -1012,7 +1015,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
...@@ -1055,7 +1058,7 @@ void main() { ...@@ -1055,7 +1058,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
...@@ -1146,7 +1149,7 @@ void main() { ...@@ -1146,7 +1149,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
...@@ -1194,7 +1197,7 @@ void main() { ...@@ -1194,7 +1197,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
...@@ -1239,7 +1242,7 @@ void main() { ...@@ -1239,7 +1242,7 @@ void main() {
new StatefulBuilder( new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
return boilerplate( return boilerplate(
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) { onValueChanged: (int newValue) {
...@@ -1294,7 +1297,7 @@ void main() { ...@@ -1294,7 +1297,7 @@ void main() {
return boilerplate( return boilerplate(
child: new SizedBox( child: new SizedBox(
width: 800.0, width: 800.0,
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
...@@ -1328,7 +1331,7 @@ void main() { ...@@ -1328,7 +1331,7 @@ void main() {
return boilerplate( return boilerplate(
child: new SizedBox( child: new SizedBox(
width: 800.0, width: 800.0,
child: new SegmentedControl<int>( child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'), key: const ValueKey<String>('Segmented Control'),
children: children, children: children,
onValueChanged: (int newValue) {}, onValueChanged: (int newValue) {},
......
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