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
5c8d7e34
Unverified
Commit
5c8d7e34
authored
Jul 09, 2018
by
xster
Committed by
GitHub
Jul 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust Cupertino controls's APIs to match Material (#19127)
parent
d3ad0729
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
6 deletions
+47
-6
button.dart
packages/flutter/lib/src/cupertino/button.dart
+10
-1
slider.dart
packages/flutter/lib/src/cupertino/slider.dart
+5
-3
switch.dart
packages/flutter/lib/src/cupertino/switch.dart
+4
-2
button_test.dart
packages/flutter/test/cupertino/button_test.dart
+28
-0
No files found.
packages/flutter/lib/src/cupertino/button.dart
View file @
5c8d7e34
...
@@ -50,6 +50,7 @@ class CupertinoButton extends StatefulWidget {
...
@@ -50,6 +50,7 @@ class CupertinoButton extends StatefulWidget {
@required
this
.
child
,
@required
this
.
child
,
this
.
padding
,
this
.
padding
,
this
.
color
,
this
.
color
,
this
.
disabledColor
,
this
.
minSize
=
44.0
,
this
.
minSize
=
44.0
,
this
.
pressedOpacity
=
0.1
,
this
.
pressedOpacity
=
0.1
,
this
.
borderRadius
=
const
BorderRadius
.
all
(
const
Radius
.
circular
(
8.0
)),
this
.
borderRadius
=
const
BorderRadius
.
all
(
const
Radius
.
circular
(
8.0
)),
...
@@ -71,6 +72,14 @@ class CupertinoButton extends StatefulWidget {
...
@@ -71,6 +72,14 @@ class CupertinoButton extends StatefulWidget {
/// Defaults to null which produces a button with no background or border.
/// Defaults to null which produces a button with no background or border.
final
Color
color
;
final
Color
color
;
/// The color of the button's background when the button is disabled.
///
/// Ignored if the [CupertinoButton] doesn't also have a [color].
///
/// Defaults to a standard iOS disabled color when [color] is specified and
/// [disabledColor] is null.
final
Color
disabledColor
;
/// The callback that is called when the button is tapped or otherwise activated.
/// The callback that is called when the button is tapped or otherwise activated.
///
///
/// If this is set to null, the button will be disabled.
/// If this is set to null, the button will be disabled.
...
@@ -216,7 +225,7 @@ class _CupertinoButtonState extends State<CupertinoButton> with SingleTickerProv
...
@@ -216,7 +225,7 @@ class _CupertinoButtonState extends State<CupertinoButton> with SingleTickerProv
decoration:
new
BoxDecoration
(
decoration:
new
BoxDecoration
(
borderRadius:
widget
.
borderRadius
,
borderRadius:
widget
.
borderRadius
,
color:
backgroundColor
!=
null
&&
!
enabled
color:
backgroundColor
!=
null
&&
!
enabled
?
_kDisabledBackground
?
widget
.
disabledColor
??
_kDisabledBackground
:
backgroundColor
,
:
backgroundColor
,
),
),
child:
new
Padding
(
child:
new
Padding
(
...
...
packages/flutter/lib/src/cupertino/slider.dart
View file @
5c8d7e34
...
@@ -57,7 +57,7 @@ class CupertinoSlider extends StatefulWidget {
...
@@ -57,7 +57,7 @@ class CupertinoSlider extends StatefulWidget {
this
.
min
=
0.0
,
this
.
min
=
0.0
,
this
.
max
=
1.0
,
this
.
max
=
1.0
,
this
.
divisions
,
this
.
divisions
,
this
.
activeColor
=
CupertinoColors
.
activeBlue
,
this
.
activeColor
,
})
:
assert
(
value
!=
null
),
})
:
assert
(
value
!=
null
),
assert
(
min
!=
null
),
assert
(
min
!=
null
),
assert
(
max
!=
null
),
assert
(
max
!=
null
),
...
@@ -95,7 +95,7 @@ class CupertinoSlider extends StatefulWidget {
...
@@ -95,7 +95,7 @@ class CupertinoSlider extends StatefulWidget {
/// },
/// },
/// )
/// )
/// ```
/// ```
///
///
/// See also:
/// See also:
///
///
/// * [onChangeStart] for a callback that is called when the user starts
/// * [onChangeStart] for a callback that is called when the user starts
...
@@ -185,6 +185,8 @@ class CupertinoSlider extends StatefulWidget {
...
@@ -185,6 +185,8 @@ class CupertinoSlider extends StatefulWidget {
final
int
divisions
;
final
int
divisions
;
/// The color to use for the portion of the slider that has been selected.
/// The color to use for the portion of the slider that has been selected.
///
/// Defaults to [CupertinoColors.activeBlue].
final
Color
activeColor
;
final
Color
activeColor
;
@override
@override
...
@@ -223,7 +225,7 @@ class _CupertinoSliderState extends State<CupertinoSlider> with TickerProviderSt
...
@@ -223,7 +225,7 @@ class _CupertinoSliderState extends State<CupertinoSlider> with TickerProviderSt
return
new
_CupertinoSliderRenderObjectWidget
(
return
new
_CupertinoSliderRenderObjectWidget
(
value:
(
widget
.
value
-
widget
.
min
)
/
(
widget
.
max
-
widget
.
min
),
value:
(
widget
.
value
-
widget
.
min
)
/
(
widget
.
max
-
widget
.
min
),
divisions:
widget
.
divisions
,
divisions:
widget
.
divisions
,
activeColor:
widget
.
activeColor
,
activeColor:
widget
.
activeColor
??
CupertinoColors
.
activeBlue
,
onChanged:
widget
.
onChanged
!=
null
?
_handleChanged
:
null
,
onChanged:
widget
.
onChanged
!=
null
?
_handleChanged
:
null
,
onChangeStart:
widget
.
onChangeStart
!=
null
?
_handleDragStart
:
null
,
onChangeStart:
widget
.
onChangeStart
!=
null
?
_handleDragStart
:
null
,
onChangeEnd:
widget
.
onChangeEnd
!=
null
?
_handleDragEnd
:
null
,
onChangeEnd:
widget
.
onChangeEnd
!=
null
?
_handleDragEnd
:
null
,
...
...
packages/flutter/lib/src/cupertino/switch.dart
View file @
5c8d7e34
...
@@ -51,7 +51,7 @@ class CupertinoSwitch extends StatefulWidget {
...
@@ -51,7 +51,7 @@ class CupertinoSwitch extends StatefulWidget {
Key
key
,
Key
key
,
@required
this
.
value
,
@required
this
.
value
,
@required
this
.
onChanged
,
@required
this
.
onChanged
,
this
.
activeColor
=
CupertinoColors
.
activeGreen
,
this
.
activeColor
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
/// Whether this switch is on or off.
/// Whether this switch is on or off.
...
@@ -82,6 +82,8 @@ class CupertinoSwitch extends StatefulWidget {
...
@@ -82,6 +82,8 @@ class CupertinoSwitch extends StatefulWidget {
final
ValueChanged
<
bool
>
onChanged
;
final
ValueChanged
<
bool
>
onChanged
;
/// The color to use when this switch is on.
/// The color to use when this switch is on.
///
/// Defaults to [CupertinoColors.activeGreen].
final
Color
activeColor
;
final
Color
activeColor
;
@override
@override
...
@@ -100,7 +102,7 @@ class _CupertinoSwitchState extends State<CupertinoSwitch> with TickerProviderSt
...
@@ -100,7 +102,7 @@ class _CupertinoSwitchState extends State<CupertinoSwitch> with TickerProviderSt
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
_CupertinoSwitchRenderObjectWidget
(
return
new
_CupertinoSwitchRenderObjectWidget
(
value:
widget
.
value
,
value:
widget
.
value
,
activeColor:
widget
.
activeColor
,
activeColor:
widget
.
activeColor
??
CupertinoColors
.
activeGreen
,
onChanged:
widget
.
onChanged
,
onChanged:
widget
.
onChanged
,
vsync:
this
,
vsync:
this
,
);
);
...
...
packages/flutter/test/cupertino/button_test.dart
View file @
5c8d7e34
...
@@ -198,6 +198,34 @@ void main() {
...
@@ -198,6 +198,34 @@ void main() {
semantics
.
dispose
();
semantics
.
dispose
();
});
});
testWidgets
(
'Can specify colors'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
new
CupertinoButton
(
child:
const
Text
(
'Skeuomorph me'
),
color:
const
Color
(
0x0000FF
),
disabledColor:
const
Color
(
0x00FF00
),
onPressed:
()
{
},
)));
BoxDecoration
boxDecoration
=
tester
.
widget
<
DecoratedBox
>(
find
.
widgetWithText
(
DecoratedBox
,
'Skeuomorph me'
)
).
decoration
;
expect
(
boxDecoration
.
color
,
const
Color
(
0x0000FF
));
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
CupertinoButton
(
child:
const
Text
(
'Skeuomorph me'
),
color:
const
Color
(
0x0000FF
),
disabledColor:
const
Color
(
0x00FF00
),
onPressed:
null
,
)));
boxDecoration
=
tester
.
widget
<
DecoratedBox
>(
find
.
widgetWithText
(
DecoratedBox
,
'Skeuomorph me'
)
).
decoration
;
expect
(
boxDecoration
.
color
,
const
Color
(
0x00FF00
));
});
}
}
Widget
boilerplate
(
{
Widget
child
})
{
Widget
boilerplate
(
{
Widget
child
})
{
...
...
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