SegmentedControl -> CupertinoSegmentedControl (#20267)

This commit is contained in:
Natalie Sampsell
2018-08-09 13:09:11 -07:00
committed by GitHub
parent a49bffa54e
commit b2cf1a2453
2 changed files with 48 additions and 45 deletions

View File

@@ -63,7 +63,7 @@ const Duration _kFadeDuration = Duration(milliseconds: 165);
/// See also:
///
/// * <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.
///
/// The [children], [onValueChanged], [unselectedColor], [selectedColor],
@@ -80,7 +80,7 @@ class SegmentedControl<T> 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<T> extends StatefulWidget {
/// @override
/// Widget build(BuildContext context) {
/// return new Container(
/// child: new SegmentedControl<int>(
/// child: new CupertinoSegmentedControl<int>(
/// children: children,
/// onValueChanged: (int newValue) {
/// setState(() {
@@ -198,8 +198,8 @@ class SegmentedControl<T> extends StatefulWidget {
_SegmentedControlState<T> createState() => _SegmentedControlState<T>();
}
class _SegmentedControlState<T> extends State<SegmentedControl<T>>
with TickerProviderStateMixin<SegmentedControl<T>> {
class _SegmentedControlState<T> extends State<CupertinoSegmentedControl<T>>
with TickerProviderStateMixin<CupertinoSegmentedControl<T>> {
T _pressedKey;
final List<AnimationController> _selectionControllers = <AnimationController>[];
@@ -308,7 +308,7 @@ class _SegmentedControlState<T> extends State<SegmentedControl<T>>
}
@override
void didUpdateWidget(SegmentedControl<T> oldWidget) {
void didUpdateWidget(CupertinoSegmentedControl<T> oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.children.length != widget.children.length) {

View File

@@ -27,7 +27,7 @@ StatefulBuilder setupSimpleSegmentedControl() {
return new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -65,7 +65,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'),
children: children,
onValueChanged: (int newValue) {
@@ -92,7 +92,7 @@ void main() {
try {
await tester.pumpWidget(
boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {},
),
@@ -107,7 +107,7 @@ void main() {
await tester.pumpWidget(
boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {},
),
@@ -128,7 +128,7 @@ void main() {
try {
await tester.pumpWidget(
boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {},
groupValue: 2,
@@ -147,7 +147,7 @@ void main() {
try {
await tester.pumpWidget(
boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: null,
onValueChanged: (int newValue) {},
),
@@ -165,7 +165,7 @@ void main() {
try {
await tester.pumpWidget(
boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: null,
),
@@ -179,7 +179,7 @@ void main() {
try {
await tester.pumpWidget(
boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
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<int>(
child: new CupertinoSegmentedControl<int>(
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<int>(
child: new CupertinoSegmentedControl<int>(
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<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {},
),
@@ -330,7 +332,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
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<int>(
child: new CupertinoSegmentedControl<int>(
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<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -453,7 +455,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -520,7 +522,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('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<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'),
children: children,
onValueChanged: (int newValue) {},
@@ -591,7 +593,7 @@ void main() {
return boilerplate(
child: Row(
children: <Widget>[
new SegmentedControl<int>(
new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'),
children: children,
onValueChanged: (int newValue) {},
@@ -619,7 +621,7 @@ void main() {
Directionality(
textDirection: TextDirection.rtl,
child: new Center(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {},
),
@@ -645,7 +647,7 @@ void main() {
return Directionality(
textDirection: TextDirection.rtl,
child: new Center(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -689,7 +691,7 @@ void main() {
return Directionality(
textDirection: TextDirection.ltr,
child: new Center(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -705,7 +707,7 @@ void main() {
);
expect(
semantics,
semantics,
hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
@@ -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<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('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<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -879,7 +882,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -899,7 +902,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -920,7 +923,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -941,7 +944,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -962,7 +965,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -983,7 +986,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
children: children,
onValueChanged: (int newValue) {
setState(() {
@@ -1012,7 +1015,7 @@ void main() {
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return boilerplate(
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('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<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('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<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('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<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('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<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'),
children: children,
onValueChanged: (int newValue) {
@@ -1294,7 +1297,7 @@ void main() {
return boilerplate(
child: new SizedBox(
width: 800.0,
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'),
children: children,
onValueChanged: (int newValue) {},
@@ -1328,7 +1331,7 @@ void main() {
return boilerplate(
child: new SizedBox(
width: 800.0,
child: new SegmentedControl<int>(
child: new CupertinoSegmentedControl<int>(
key: const ValueKey<String>('Segmented Control'),
children: children,
onValueChanged: (int newValue) {},