Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
b2cf1a24
Unverified
Commit
b2cf1a24
authored
Aug 09, 2018
by
Natalie Sampsell
Committed by
GitHub
Aug 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SegmentedControl -> CupertinoSegmentedControl (#20267)
parent
a49bffa5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
45 deletions
+48
-45
segmented_control.dart
packages/flutter/lib/src/cupertino/segmented_control.dart
+6
-6
segmented_control_test.dart
packages/flutter/test/cupertino/segmented_control_test.dart
+42
-39
No files found.
packages/flutter/lib/src/cupertino/segmented_control.dart
View file @
b2cf1a24
...
...
@@ -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
Cupertino
SegmentedControl
<
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
({
Cupertino
SegmentedControl
({
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
Cupertino
SegmentedControl<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
<
Cupertino
SegmentedControl
<
T
>>
with
TickerProviderStateMixin
<
Cupertino
SegmentedControl
<
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
(
Cupertino
SegmentedControl
<
T
>
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
if
(
oldWidget
.
children
.
length
!=
widget
.
children
.
length
)
{
...
...
packages/flutter/test/cupertino/segmented_control_test.dart
View file @
b2cf1a24
...
...
@@ -27,7 +27,7 @@ StatefulBuilder setupSimpleSegmentedControl() {
return
new
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
boilerplate
(
child:
new
SegmentedControl
<
int
>(
child:
new
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
int
>(
children:
children
,
onValueChanged:
(
int
newValue
)
{},
),
...
...
@@ -107,7 +107,7 @@ void main() {
await
tester
.
pumpWidget
(
boilerplate
(
child:
new
SegmentedControl
<
int
>(
child:
new
Cupertino
SegmentedControl
<
int
>(
children:
children
,
onValueChanged:
(
int
newValue
)
{},
),
...
...
@@ -128,7 +128,7 @@ void main() {
try
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
new
SegmentedControl
<
int
>(
child:
new
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
int
>(
children:
null
,
onValueChanged:
(
int
newValue
)
{},
),
...
...
@@ -165,7 +165,7 @@ void main() {
try
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
new
SegmentedControl
<
int
>(
child:
new
Cupertino
SegmentedControl
<
int
>(
children:
children
,
onValueChanged:
null
,
),
...
...
@@ -179,7 +179,7 @@ void main() {
try
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
new
SegmentedControl
<
int
>(
child:
new
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
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
Cupertino
SegmentedControl
<
int
>(
key:
const
ValueKey
<
String
>(
'Segmented Control'
),
children:
children
,
onValueChanged:
(
int
newValue
)
{},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment