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
bbb2a0f8
Unverified
Commit
bbb2a0f8
authored
Nov 05, 2019
by
LongCatIsLooong
Committed by
GitHub
Nov 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update cupertino demos in gallery (#43841)
parent
76957c9d
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
377 additions
and
294 deletions
+377
-294
cupertino_navigation_demo.dart
...gallery/lib/demo/cupertino/cupertino_navigation_demo.dart
+120
-108
cupertino_picker_demo.dart
...ter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart
+92
-75
cupertino_refresh_demo.dart
...er_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart
+46
-52
cupertino_segmented_control_demo.dart
.../lib/demo/cupertino/cupertino_segmented_control_demo.dart
+58
-40
button.dart
packages/flutter/lib/src/cupertino/button.dart
+3
-3
colors.dart
packages/flutter/lib/src/cupertino/colors.dart
+10
-10
route.dart
packages/flutter/lib/src/cupertino/route.dart
+5
-1
button_test.dart
packages/flutter/test/cupertino/button_test.dart
+39
-1
dialog_test.dart
packages/flutter/test/cupertino/dialog_test.dart
+4
-4
No files found.
examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart
View file @
bbb2a0f8
...
...
@@ -143,6 +143,7 @@ class CupertinoDemoTab1 extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
CupertinoPageScaffold
(
backgroundColor:
CupertinoColors
.
systemGroupedBackground
,
child:
CustomScrollView
(
semanticChildCount:
_kChildCount
,
slivers:
<
Widget
>[
...
...
@@ -199,6 +200,8 @@ class Tab1RowItem extends StatelessWidget {
),
));
},
child:
Container
(
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
systemBackground
,
context
),
child:
SafeArea
(
top:
false
,
bottom:
false
,
...
...
@@ -222,10 +225,10 @@ class Tab1RowItem extends StatelessWidget {
children:
<
Widget
>[
Text
(
colorName
),
const
Padding
(
padding:
EdgeInsets
.
only
(
top:
8.0
)),
const
Text
(
Text
(
'Buy this cool color'
,
style:
TextStyle
(
color:
Color
(
0xFF8E8E93
),
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
secondaryLabel
,
context
),
fontSize:
13.0
,
fontWeight:
FontWeight
.
w300
,
),
...
...
@@ -252,6 +255,7 @@ class Tab1RowItem extends StatelessWidget {
),
),
),
),
);
if
(
lastItem
)
{
...
...
@@ -263,7 +267,7 @@ class Tab1RowItem extends StatelessWidget {
row
,
Container
(
height:
1.0
,
color:
const
Color
(
0xFFD9D9D9
),
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
separator
,
context
),
),
],
);
...
...
@@ -336,8 +340,8 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
const
Padding
(
padding:
EdgeInsets
.
only
(
top:
6.0
)),
Text
(
'Item number
${widget.index}
'
,
style:
const
TextStyle
(
color:
C
olor
(
0xFF8E8E93
),
style:
TextStyle
(
color:
C
upertinoDynamicColor
.
resolve
(
CupertinoColors
.
secondaryLabel
,
context
),
fontSize:
16.0
,
fontWeight:
FontWeight
.
w100
,
),
...
...
@@ -433,7 +437,10 @@ class CupertinoDemoTab2 extends StatelessWidget {
child:
CupertinoScrollbar
(
child:
ListView
(
children:
<
Widget
>[
Tab2Header
(),
CupertinoUserInterfaceLevel
(
data:
CupertinoUserInterfaceLevelData
.
elevated
,
child:
Tab2Header
(),
),
...
buildTab2Conversation
(),
],
),
...
...
@@ -456,18 +463,18 @@ class Tab2Header extends StatelessWidget {
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
Container
(
decoration:
const
BoxDecoration
(
color:
C
olor
(
0xFFE5E5E5
),
decoration:
BoxDecoration
(
color:
C
upertinoDynamicColor
.
resolve
(
CupertinoColors
.
systemFill
,
context
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
18.0
,
vertical:
12.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
const
<
Widget
>[
children:
<
Widget
>[
Text
(
'SUPPORT TICKET'
,
style:
TextStyle
(
color:
C
olor
(
0xFF646464
),
color:
C
upertinoDynamicColor
.
resolve
(
CupertinoColors
.
secondaryLabel
,
context
),
letterSpacing:
-
0.9
,
fontSize:
14.0
,
fontWeight:
FontWeight
.
w500
,
...
...
@@ -476,7 +483,7 @@ class Tab2Header extends StatelessWidget {
Text
(
'Show More'
,
style:
TextStyle
(
color:
C
olor
(
0xFF646464
),
color:
C
upertinoDynamicColor
.
resolve
(
CupertinoColors
.
secondaryLabel
,
context
),
letterSpacing:
-
0.6
,
fontSize:
12.0
,
fontWeight:
FontWeight
.
w500
,
...
...
@@ -487,8 +494,8 @@ class Tab2Header extends StatelessWidget {
),
),
Container
(
decoration:
const
BoxDecoration
(
color:
C
olor
(
0xFFF3F3F3
),
decoration:
BoxDecoration
(
color:
C
upertinoDynamicColor
.
resolve
(
CupertinoColors
.
quaternarySystemFill
,
context
),
),
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
18.0
,
vertical:
12.0
),
...
...
@@ -576,21 +583,31 @@ class Tab2ConversationBubble extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
Color
backgroundColor
;
Color
foregroundColor
;
switch
(
color
)
{
case
Tab2ConversationBubbleColor
.
gray
:
backgroundColor
=
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
systemFill
,
context
);
foregroundColor
=
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
label
,
context
);
break
;
case
Tab2ConversationBubbleColor
.
blue
:
backgroundColor
=
CupertinoTheme
.
of
(
context
).
primaryColor
;
foregroundColor
=
CupertinoColors
.
white
;
break
;
}
return
Container
(
decoration:
BoxDecoration
(
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
18.0
)),
color:
color
==
Tab2ConversationBubbleColor
.
blue
?
CupertinoColors
.
activeBlue
:
CupertinoColors
.
lightBackgroundGray
,
color:
backgroundColor
,
),
margin:
const
EdgeInsets
.
symmetric
(
horizontal:
8.0
,
vertical:
8.0
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
14.0
,
vertical:
10.0
),
child:
Text
(
text
,
style:
TextStyle
(
color:
color
==
Tab2ConversationBubbleColor
.
blue
?
CupertinoColors
.
white
:
CupertinoColors
.
black
,
color:
foregroundColor
,
letterSpacing:
-
0.4
,
fontSize:
15.0
,
fontWeight:
FontWeight
.
w400
,
...
...
@@ -655,12 +672,15 @@ class Tab2ConversationRow extends StatelessWidget {
crossAxisAlignment:
isSelf
?
CrossAxisAlignment
.
center
:
CrossAxisAlignment
.
end
,
children:
<
Widget
>[
if
(
avatar
!=
null
)
avatar
,
Tab2ConversationBubble
(
CupertinoUserInterfaceLevel
(
data:
CupertinoUserInterfaceLevelData
.
elevated
,
child:
Tab2ConversationBubble
(
text:
text
,
color:
isSelf
?
Tab2ConversationBubbleColor
.
blue
:
Tab2ConversationBubbleColor
.
gray
,
),
),
],
),
);
...
...
@@ -709,15 +729,8 @@ class CupertinoDemoTab3 extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
CupertinoPageScaffold
(
navigationBar:
CupertinoNavigationBar
(
trailing:
trailingButtons
,
),
child:
DecoratedBox
(
decoration:
BoxDecoration
(
color:
CupertinoTheme
.
of
(
context
).
brightness
==
Brightness
.
light
?
CupertinoColors
.
extraLightBackgroundGray
:
CupertinoColors
.
darkBackgroundGray
,
),
navigationBar:
CupertinoNavigationBar
(
trailing:
trailingButtons
),
backgroundColor:
CupertinoColors
.
systemBackground
,
child:
ListView
(
children:
<
Widget
>[
const
Padding
(
padding:
EdgeInsets
.
only
(
top:
32.0
)),
...
...
@@ -758,7 +771,6 @@ class CupertinoDemoTab3 extends StatelessWidget {
),
],
),
),
);
}
}
...
...
examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart
View file @
bbb2a0f8
...
...
@@ -17,21 +17,50 @@ class CupertinoPickerDemo extends StatefulWidget {
_CupertinoPickerDemoState
createState
()
=>
_CupertinoPickerDemoState
();
}
class
_CupertinoPickerDemoState
extends
State
<
CupertinoPickerDemo
>
{
int
_selectedColorIndex
=
0
;
class
_BottomPicker
extends
StatelessWidget
{
const
_BottomPicker
({
Key
key
,
@required
this
.
child
,
})
:
assert
(
child
!=
null
),
super
(
key:
key
);
Duration
timer
=
const
Duration
()
;
final
Widget
child
;
// Value that is shown in the date picker in date mode.
DateTime
date
=
DateTime
.
now
();
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
height:
_kPickerSheetHeight
,
padding:
const
EdgeInsets
.
only
(
top:
6.0
),
color:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
),
child:
DefaultTextStyle
(
style:
TextStyle
(
color:
CupertinoColors
.
label
.
resolveFrom
(
context
),
fontSize:
22.0
,
),
child:
GestureDetector
(
// Blocks taps from propagating to the modal sheet and popping.
onTap:
()
{
},
child:
SafeArea
(
top:
false
,
child:
child
,
),
),
),
);
}
}
// Value that is shown in the date picker in time mode.
DateTime
time
=
DateTime
.
now
();
class
_Menu
extends
StatelessWidget
{
const
_Menu
({
Key
key
,
@required
this
.
children
,
})
:
assert
(
children
!=
null
),
super
(
key:
key
);
// Value that is shown in the date picker in dateAndTime mode.
DateTime
dateTime
=
DateTime
.
now
();
final
List
<
Widget
>
children
;
Widget
_buildMenu
(
List
<
Widget
>
children
)
{
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
decoration:
BoxDecoration
(
color:
CupertinoTheme
.
of
(
context
).
scaffoldBackgroundColor
,
...
...
@@ -54,28 +83,21 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
),
);
}
}
Widget
_buildBottomPicker
(
Widget
picker
)
{
return
Container
(
height:
_kPickerSheetHeight
,
padding:
const
EdgeInsets
.
only
(
top:
6.0
),
color:
CupertinoColors
.
white
,
child:
DefaultTextStyle
(
style:
const
TextStyle
(
color:
CupertinoColors
.
black
,
fontSize:
22.0
,
),
child:
GestureDetector
(
// Blocks taps from propagating to the modal sheet and popping.
onTap:
()
{
},
child:
SafeArea
(
top:
false
,
child:
picker
,
),
),
),
);
}
class
_CupertinoPickerDemoState
extends
State
<
CupertinoPickerDemo
>
{
int
_selectedColorIndex
=
0
;
Duration
timer
=
const
Duration
();
// Value that is shown in the date picker in date mode.
DateTime
date
=
DateTime
.
now
();
// Value that is shown in the date picker in time mode.
DateTime
time
=
DateTime
.
now
();
// Value that is shown in the date picker in dateAndTime mode.
DateTime
dateTime
=
DateTime
.
now
();
Widget
_buildColorPicker
(
BuildContext
context
)
{
final
FixedExtentScrollController
scrollController
=
...
...
@@ -86,11 +108,11 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
await
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
_
build
BottomPicker
(
CupertinoPicker
(
return
_BottomPicker
(
child:
CupertinoPicker
(
scrollController:
scrollController
,
itemExtent:
_kPickerItemHeight
,
backgroundColor:
CupertinoColors
.
white
,
backgroundColor:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
)
,
onSelectedItemChanged:
(
int
index
)
{
setState
(()
=>
_selectedColorIndex
=
index
);
},
...
...
@@ -104,14 +126,12 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
},
);
},
child:
_
build
Menu
(
<
Widget
>[
child:
_Menu
(
children:
<
Widget
>[
const
Text
(
'Favorite Color'
),
Text
(
coolColorNames
[
_selectedColorIndex
],
style:
const
TextStyle
(
color:
CupertinoColors
.
inactiveGray
),
style:
TextStyle
(
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
inactiveGray
,
context
)),
),
],
),
...
...
@@ -124,8 +144,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
_buildBottomPicker
(
CupertinoTimerPicker
(
return
_BottomPicker
(
child:
CupertinoTimerPicker
(
backgroundColor:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
),
initialTimerDuration:
timer
,
onTimerDurationChanged:
(
Duration
newTimer
)
{
setState
(()
=>
timer
=
newTimer
);
...
...
@@ -135,14 +156,14 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
},
);
},
child:
_
build
Menu
(
<
Widget
>[
child:
_Menu
(
children:
<
Widget
>[
const
Text
(
'Countdown Timer'
),
Text
(
'
${timer.inHours}
:'
'
${(timer.inMinutes % 60).toString().padLeft(2,'0')}
:'
'
${(timer.inSeconds % 60).toString().padLeft(2,'0')}
'
,
style:
const
TextStyle
(
color:
CupertinoColors
.
inactiveGray
),
style:
TextStyle
(
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
inactiveGray
,
context
)
),
),
],
),
...
...
@@ -155,8 +176,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
_buildBottomPicker
(
CupertinoDatePicker
(
return
_BottomPicker
(
child:
CupertinoDatePicker
(
backgroundColor:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
),
mode:
CupertinoDatePickerMode
.
date
,
initialDateTime:
date
,
onDateTimeChanged:
(
DateTime
newDateTime
)
{
...
...
@@ -167,12 +189,12 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
},
);
},
child:
_
build
Menu
(
<
Widget
>[
child:
_Menu
(
children:
<
Widget
>[
const
Text
(
'Date'
),
Text
(
DateFormat
.
yMMMMd
().
format
(
date
),
style:
const
TextStyle
(
color:
CupertinoColors
.
inactiveGray
),
style:
TextStyle
(
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
inactiveGray
,
context
)
),
),
]
),
...
...
@@ -185,8 +207,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
_buildBottomPicker
(
CupertinoDatePicker
(
return
_BottomPicker
(
child:
CupertinoDatePicker
(
backgroundColor:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
),
mode:
CupertinoDatePickerMode
.
time
,
initialDateTime:
time
,
onDateTimeChanged:
(
DateTime
newDateTime
)
{
...
...
@@ -197,12 +220,12 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
},
);
},
child:
_
build
Menu
(
<
Widget
>[
child:
_Menu
(
children:
<
Widget
>[
const
Text
(
'Time'
),
Text
(
DateFormat
.
jm
().
format
(
time
),
style:
const
TextStyle
(
color:
CupertinoColors
.
inactiveGray
),
style:
TextStyle
(
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
inactiveGray
,
context
)
),
),
],
),
...
...
@@ -215,8 +238,9 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
showCupertinoModalPopup
<
void
>(
context:
context
,
builder:
(
BuildContext
context
)
{
return
_buildBottomPicker
(
CupertinoDatePicker
(
return
_BottomPicker
(
child:
CupertinoDatePicker
(
backgroundColor:
CupertinoColors
.
systemBackground
.
resolveFrom
(
context
),
mode:
CupertinoDatePickerMode
.
dateAndTime
,
initialDateTime:
dateTime
,
onDateTimeChanged:
(
DateTime
newDateTime
)
{
...
...
@@ -227,12 +251,12 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
},
);
},
child:
_
build
Menu
(
<
Widget
>[
child:
_Menu
(
children:
<
Widget
>[
const
Text
(
'Date and Time'
),
Text
(
DateFormat
.
yMMMd
().
add_jm
().
format
(
dateTime
),
style:
const
TextStyle
(
color:
CupertinoColors
.
inactiveGray
),
style:
TextStyle
(
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
inactiveGray
,
context
)
),
),
],
),
...
...
@@ -252,12 +276,6 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
),
child:
DefaultTextStyle
(
style:
CupertinoTheme
.
of
(
context
).
textTheme
.
textStyle
,
child:
DecoratedBox
(
decoration:
BoxDecoration
(
color:
CupertinoTheme
.
of
(
context
).
brightness
==
Brightness
.
light
?
CupertinoColors
.
extraLightBackgroundGray
:
CupertinoColors
.
darkBackgroundGray
,
),
child:
ListView
(
children:
<
Widget
>[
const
Padding
(
padding:
EdgeInsets
.
only
(
top:
32.0
)),
...
...
@@ -269,7 +287,6 @@ class _CupertinoPickerDemoState extends State<CupertinoPickerDemo> {
],
),
),
),
);
}
}
examples/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart
View file @
bbb2a0f8
...
...
@@ -41,12 +41,7 @@ class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDem
return
DefaultTextStyle
(
style:
CupertinoTheme
.
of
(
context
).
textTheme
.
textStyle
,
child:
CupertinoPageScaffold
(
child:
DecoratedBox
(
decoration:
BoxDecoration
(
color:
CupertinoTheme
.
of
(
context
).
brightness
==
Brightness
.
light
?
CupertinoColors
.
extraLightBackgroundGray
:
CupertinoColors
.
darkBackgroundGray
,
),
backgroundColor:
CupertinoColors
.
systemGroupedBackground
,
child:
CustomScrollView
(
// If left unspecified, the [CustomScrollView] appends an
// [AlwaysScrollableScrollPhysics]. Behind the scene, the ScrollableState
...
...
@@ -95,7 +90,6 @@ class _CupertinoRefreshControlDemoState extends State<CupertinoRefreshControlDem
],
),
),
),
);
}
}
...
...
@@ -163,7 +157,7 @@ class _ListItem extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
color:
Cupertino
Theme
.
of
(
context
).
scaffoldBackgroundColor
,
color:
Cupertino
DynamicColor
.
resolve
(
CupertinoColors
.
systemBackground
,
context
)
,
height:
60.0
,
padding:
const
EdgeInsets
.
only
(
top:
9.0
),
child:
Row
(
...
...
examples/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart
View file @
bbb2a0f8
...
...
@@ -46,7 +46,13 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
),
};
int
sharedValue
=
0
;
int
currentSegment
=
0
;
void
onValueChanged
(
int
newValue
)
{
setState
(()
{
currentSegment
=
newValue
;
});
}
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -60,23 +66,28 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
trailing:
CupertinoDemoDocumentationButton
(
CupertinoSegmentedControlDemo
.
routeName
),
),
child:
DefaultTextStyle
(
style:
CupertinoTheme
.
of
(
context
).
textTheme
.
textStyle
,
style:
CupertinoTheme
.
of
(
context
).
textTheme
.
textStyle
.
copyWith
(
fontSize:
13
)
,
child:
SafeArea
(
child:
Column
(
children:
<
Widget
>[
const
Padding
(
padding:
EdgeInsets
.
all
(
16.0
),
),
const
Padding
(
padding:
EdgeInsets
.
all
(
16.0
)),
SizedBox
(
width:
500.0
,
child:
CupertinoSegmentedControl
<
int
>(
children:
children
,
onValueChanged:
(
int
newValue
)
{
setState
(()
{
sharedValue
=
newValue
;
});
},
groupValue:
sharedValue
,
onValueChanged:
onValueChanged
,
groupValue:
currentSegment
,
),
),
SizedBox
(
width:
500
,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
16.0
),
child:
CupertinoSlidingSegmentedControl
<
int
>(
children:
children
,
onValueChanged:
onValueChanged
,
groupValue:
currentSegment
,
),
),
),
Expanded
(
...
...
@@ -85,7 +96,11 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
vertical:
32.0
,
horizontal:
16.0
,
),
child:
Container
(
child:
CupertinoUserInterfaceLevel
(
data:
CupertinoUserInterfaceLevelData
.
elevated
,
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
Container
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
64.0
,
horizontal:
16.0
,
...
...
@@ -114,7 +129,10 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
),
],
),
child:
icons
[
sharedValue
],
child:
icons
[
currentSegment
],
);
},
),
),
),
),
...
...
packages/flutter/lib/src/cupertino/button.dart
View file @
bbb2a0f8
...
...
@@ -33,7 +33,7 @@ class CupertinoButton extends StatefulWidget {
this
.
color
,
this
.
disabledColor
=
CupertinoColors
.
quaternarySystemFill
,
this
.
minSize
=
kMinInteractiveDimensionCupertino
,
this
.
pressedOpacity
=
0.
1
,
this
.
pressedOpacity
=
0.
4
,
this
.
borderRadius
=
const
BorderRadius
.
all
(
Radius
.
circular
(
8.0
)),
@required
this
.
onPressed
,
})
:
assert
(
pressedOpacity
==
null
||
(
pressedOpacity
>=
0.0
&&
pressedOpacity
<=
1.0
)),
...
...
@@ -53,7 +53,7 @@ class CupertinoButton extends StatefulWidget {
this
.
padding
,
this
.
disabledColor
=
CupertinoColors
.
quaternarySystemFill
,
this
.
minSize
=
kMinInteractiveDimensionCupertino
,
this
.
pressedOpacity
=
0.
1
,
this
.
pressedOpacity
=
0.
4
,
this
.
borderRadius
=
const
BorderRadius
.
all
(
Radius
.
circular
(
8.0
)),
@required
this
.
onPressed
,
})
:
assert
(
pressedOpacity
==
null
||
(
pressedOpacity
>=
0.0
&&
pressedOpacity
<=
1.0
)),
...
...
@@ -102,7 +102,7 @@ class CupertinoButton extends StatefulWidget {
/// The opacity that the button will fade to when it is pressed.
/// The button will have an opacity of 1.0 when it is not pressed.
///
/// This defaults to 0.
1
. If null, opacity will not change on pressed if using
/// This defaults to 0.
4
. If null, opacity will not change on pressed if using
/// your own custom effects is desired.
final
double
pressedOpacity
;
...
...
packages/flutter/lib/src/cupertino/colors.dart
View file @
bbb2a0f8
...
...
@@ -304,15 +304,15 @@ class CupertinoColors {
/// The color for text labels containing secondary content, equivalent to
/// [UIColor.secondaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173136-secondarylabel).
static
const
CupertinoDynamicColor
secondaryLabel
=
CupertinoDynamicColor
(
color:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
darkColor:
Color
.
fromARGB
(
255
,
255
,
255
,
25
5
),
highContrastColor:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
darkHighContrastColor:
Color
.
fromARGB
(
255
,
255
,
255
,
25
5
),
elevatedColor:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
darkElevatedColor:
Color
.
fromARGB
(
255
,
255
,
255
,
25
5
),
highContrastElevatedColor:
Color
.
fromARGB
(
255
,
0
,
0
,
0
),
darkHighContrastElevatedColor:
Color
.
fromARGB
(
255
,
255
,
255
,
25
5
),
);
color:
Color
.
fromARGB
(
153
,
60
,
60
,
67
),
darkColor:
Color
.
fromARGB
(
153
,
235
,
235
,
24
5
),
highContrastColor:
Color
.
fromARGB
(
173
,
60
,
60
,
67
),
darkHighContrastColor:
Color
.
fromARGB
(
173
,
235
,
235
,
24
5
),
elevatedColor:
Color
.
fromARGB
(
153
,
60
,
60
,
67
),
darkElevatedColor:
Color
.
fromARGB
(
153
,
235
,
235
,
24
5
),
highContrastElevatedColor:
Color
.
fromARGB
(
173
,
60
,
60
,
67
),
darkHighContrastElevatedColor:
Color
.
fromARGB
(
173
,
235
,
235
,
24
5
),
);
/// The color for text labels containing tertiary content, equivalent to
/// [UIColor.tertiaryLabel](https://developer.apple.com/documentation/uikit/uicolor/3173153-tertiarylabel).
...
...
@@ -889,7 +889,7 @@ class CupertinoDynamicColor extends Color {
/// brightness, normal contrast, [CupertinoUserInterfaceLevelData.base] elevation
/// level), unless [nullOk] is set to false, in which case an exception will be
/// thrown.
CupertinoDynamicColor
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
fals
e
})
{
CupertinoDynamicColor
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
tru
e
})
{
final
Brightness
brightness
=
_isPlatformBrightnessDependent
?
CupertinoTheme
.
brightnessOf
(
context
,
nullOk:
nullOk
)
??
Brightness
.
light
:
Brightness
.
light
;
...
...
packages/flutter/lib/src/cupertino/route.dart
View file @
bbb2a0f8
...
...
@@ -13,6 +13,7 @@ import 'package:flutter/widgets.dart';
import
'package:flutter/animation.dart'
show
Curves
;
import
'colors.dart'
;
import
'interface_level.dart'
;
const
double
_kBackGestureWidth
=
20.0
;
const
double
_kMinFlingVelocity
=
1.0
;
// Screen widths per second.
...
...
@@ -840,7 +841,10 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> {
@override
Widget
buildPage
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
)
{
return
builder
(
context
);
return
CupertinoUserInterfaceLevel
(
data:
CupertinoUserInterfaceLevelData
.
elevated
,
child:
Builder
(
builder:
builder
),
);
}
@override
...
...
packages/flutter/test/cupertino/button_test.dart
View file @
bbb2a0f8
...
...
@@ -63,6 +63,44 @@ void main() {
);
});
// TODO(LongCatIsLoong): Uncomment once https://github.com/flutter/flutter/issues/44115
// is fixed.
/*
testWidgets(
'CupertinoButton.filled default color contrast meets guideline',
(WidgetTester tester) async {
// The native color combination systemBlue text over white background fails
// to pass the color contrast guideline.
//await tester.pumpWidget(
// CupertinoTheme(
// data: const CupertinoThemeData(),
// child: Directionality(
// textDirection: TextDirection.ltr,
// child: CupertinoButton.filled(
// child: const Text('Button'),
// onPressed: () {},
// ),
// ),
// ),
//);
//await expectLater(tester, meetsGuideline(textContrastGuideline));
await tester.pumpWidget(
CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
home: CupertinoPageScaffold(
child: CupertinoButton.filled(
child: const Text('Button'),
onPressed: () {},
),
),
),
);
await expectLater(tester, meetsGuideline(textContrastGuideline));
});
*/
testWidgets
(
'Button with background is wider'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
boilerplate
(
child:
const
CupertinoButton
(
child:
Text
(
'X'
,
style:
testStyle
),
...
...
@@ -145,7 +183,7 @@ void main() {
of:
find
.
byType
(
CupertinoButton
),
matching:
find
.
byType
(
FadeTransition
),
));
expect
(
opacity
.
opacity
.
value
,
0.
1
);
expect
(
opacity
.
opacity
.
value
,
0.
4
);
});
testWidgets
(
'pressedOpacity parameter'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/cupertino/dialog_test.dart
View file @
bbb2a0f8
...
...
@@ -978,19 +978,19 @@ void main() {
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
closeTo
(
0.
1
0
,
0.001
));
expect
(
transition
.
opacity
.
value
,
closeTo
(
0.
4
0
,
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
closeTo
(
0.
156
,
0.001
));
expect
(
transition
.
opacity
.
value
,
closeTo
(
0.
437
,
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
closeTo
(
0.
324
,
0.001
));
expect
(
transition
.
opacity
.
value
,
closeTo
(
0.
55
,
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
expect
(
transition
.
opacity
.
value
,
closeTo
(
0.
606
,
0.001
));
expect
(
transition
.
opacity
.
value
,
closeTo
(
0.
737
,
0.001
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
25
));
transition
=
tester
.
firstWidget
(
find
.
byType
(
FadeTransition
));
...
...
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