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
Expand all
Hide 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
This diff is collapsed.
Click to expand it.
examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart
View file @
bbb2a0f8
This diff is collapsed.
Click to expand it.
examples/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart
View file @
bbb2a0f8
...
...
@@ -41,59 +41,53 @@ 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
,
),
child:
CustomScrollView
(
// If left unspecified, the [CustomScrollView] appends an
// [AlwaysScrollableScrollPhysics]. Behind the scene, the ScrollableState
// will attach that [AlwaysScrollableScrollPhysics] to the output of
// [ScrollConfiguration.of] which will be a [ClampingScrollPhysics]
// on Android.
// To demonstrate the iOS behavior in this demo and to ensure that the list
// always scrolls, we specifically use a [BouncingScrollPhysics] combined
// with a [AlwaysScrollableScrollPhysics]
physics:
const
BouncingScrollPhysics
(
parent:
AlwaysScrollableScrollPhysics
()),
slivers:
<
Widget
>[
CupertinoSliverNavigationBar
(
largeTitle:
const
Text
(
'Refresh'
),
// We're specifying a back label here because the previous page
// is a Material page. CupertinoPageRoutes could auto-populate
// these back labels.
previousPageTitle:
'Cupertino'
,
trailing:
CupertinoDemoDocumentationButton
(
CupertinoRefreshControlDemo
.
routeName
),
),
CupertinoSliverRefreshControl
(
onRefresh:
()
{
return
Future
<
void
>.
delayed
(
const
Duration
(
seconds:
2
))
..
then
<
void
>((
_
)
{
if
(
mounted
)
{
setState
(()
=>
repopulateList
());
}
});
},
),
SliverSafeArea
(
top:
false
,
// Top safe area is consumed by the navigation bar.
sliver:
SliverList
(
delegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
_ListItem
(
name:
randomizedContacts
[
index
][
0
],
place:
randomizedContacts
[
index
][
1
],
date:
randomizedContacts
[
index
][
2
],
called:
randomizedContacts
[
index
][
3
]
==
'true'
,
);
},
childCount:
20
,
),
backgroundColor:
CupertinoColors
.
systemGroupedBackground
,
child:
CustomScrollView
(
// If left unspecified, the [CustomScrollView] appends an
// [AlwaysScrollableScrollPhysics]. Behind the scene, the ScrollableState
// will attach that [AlwaysScrollableScrollPhysics] to the output of
// [ScrollConfiguration.of] which will be a [ClampingScrollPhysics]
// on Android.
// To demonstrate the iOS behavior in this demo and to ensure that the list
// always scrolls, we specifically use a [BouncingScrollPhysics] combined
// with a [AlwaysScrollableScrollPhysics]
physics:
const
BouncingScrollPhysics
(
parent:
AlwaysScrollableScrollPhysics
()),
slivers:
<
Widget
>[
CupertinoSliverNavigationBar
(
largeTitle:
const
Text
(
'Refresh'
),
// We're specifying a back label here because the previous page
// is a Material page. CupertinoPageRoutes could auto-populate
// these back labels.
previousPageTitle:
'Cupertino'
,
trailing:
CupertinoDemoDocumentationButton
(
CupertinoRefreshControlDemo
.
routeName
),
),
CupertinoSliverRefreshControl
(
onRefresh:
()
{
return
Future
<
void
>.
delayed
(
const
Duration
(
seconds:
2
))
..
then
<
void
>((
_
)
{
if
(
mounted
)
{
setState
(()
=>
repopulateList
());
}
});
},
),
SliverSafeArea
(
top:
false
,
// Top safe area is consumed by the navigation bar.
sliver:
SliverList
(
delegate:
SliverChildBuilderDelegate
(
(
BuildContext
context
,
int
index
)
{
return
_ListItem
(
name:
randomizedContacts
[
index
][
0
],
place:
randomizedContacts
[
index
][
1
],
date:
randomizedContacts
[
index
][
2
],
called:
randomizedContacts
[
index
][
3
]
==
'true'
,
);
},
childCount:
20
,
),
),
]
,
)
,
)
,
]
,
),
),
);
...
...
@@ -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,36 +96,43 @@ class _CupertinoSegmentedControlDemoState extends State<CupertinoSegmentedContro
vertical:
32.0
,
horizontal:
16.0
,
),
child:
Container
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
64.0
,
horizontal:
16.0
,
),
decoration:
BoxDecoration
(
color:
CupertinoTheme
.
of
(
context
).
scaffoldBackgroundColor
,
borderRadius:
BorderRadius
.
circular
(
3.0
),
boxShadow:
const
<
BoxShadow
>[
BoxShadow
(
offset:
Offset
(
0.0
,
3.0
),
blurRadius:
5.0
,
spreadRadius:
-
1.0
,
color:
_kKeyUmbraOpacity
,
),
BoxShadow
(
offset:
Offset
(
0.0
,
6.0
),
blurRadius:
10.0
,
spreadRadius:
0.0
,
color:
_kKeyPenumbraOpacity
,
),
BoxShadow
(
offset:
Offset
(
0.0
,
1.0
),
blurRadius:
18.0
,
spreadRadius:
0.0
,
color:
_kAmbientShadowOpacity
,
),
],
child:
CupertinoUserInterfaceLevel
(
data:
CupertinoUserInterfaceLevelData
.
elevated
,
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
Container
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
64.0
,
horizontal:
16.0
,
),
decoration:
BoxDecoration
(
color:
CupertinoTheme
.
of
(
context
).
scaffoldBackgroundColor
,
borderRadius:
BorderRadius
.
circular
(
3.0
),
boxShadow:
const
<
BoxShadow
>[
BoxShadow
(
offset:
Offset
(
0.0
,
3.0
),
blurRadius:
5.0
,
spreadRadius:
-
1.0
,
color:
_kKeyUmbraOpacity
,
),
BoxShadow
(
offset:
Offset
(
0.0
,
6.0
),
blurRadius:
10.0
,
spreadRadius:
0.0
,
color:
_kKeyPenumbraOpacity
,
),
BoxShadow
(
offset:
Offset
(
0.0
,
1.0
),
blurRadius:
18.0
,
spreadRadius:
0.0
,
color:
_kAmbientShadowOpacity
,
),
],
),
child:
icons
[
currentSegment
],
);
},
),
child:
icons
[
sharedValue
],
),
),
),
...
...
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