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
12b72919
Unverified
Commit
12b72919
authored
Nov 07, 2021
by
Taha Tesser
Committed by
GitHub
Nov 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Cupertino] fix dark mode for `ContextMenuAction` (#92480)
parent
6ea0b2c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
27 deletions
+54
-27
context_menu_action.dart
packages/flutter/lib/src/cupertino/context_menu_action.dart
+14
-5
context_menu_action_test.dart
...ages/flutter/test/cupertino/context_menu_action_test.dart
+40
-22
No files found.
packages/flutter/lib/src/cupertino/context_menu_action.dart
View file @
12b72919
...
...
@@ -49,8 +49,14 @@ class CupertinoContextMenuAction extends StatefulWidget {
}
class
_CupertinoContextMenuActionState
extends
State
<
CupertinoContextMenuAction
>
{
static
const
Color
_kBackgroundColor
=
Color
(
0xFFEEEEEE
);
static
const
Color
_kBackgroundColorPressed
=
Color
(
0xFFDDDDDD
);
static
const
Color
_kBackgroundColor
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0xFFEEEEEE
),
darkColor:
Color
(
0xFF212122
),
);
static
const
Color
_kBackgroundColorPressed
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0xFFDDDDDD
),
darkColor:
Color
(
0xFF3F3F40
),
);
static
const
double
_kButtonHeight
=
56.0
;
static
const
TextStyle
_kActionSheetActionStyle
=
TextStyle
(
fontFamily:
'.SF UI Text'
,
...
...
@@ -93,10 +99,11 @@ class _CupertinoContextMenuActionState extends State<CupertinoContextMenuAction>
color:
CupertinoColors
.
destructiveRed
,
);
}
return
_kActionSheetActionStyle
;
return
_kActionSheetActionStyle
.
copyWith
(
color:
CupertinoDynamicColor
.
resolve
(
CupertinoColors
.
label
,
context
)
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
GestureDetector
(
...
...
@@ -114,7 +121,9 @@ class _CupertinoContextMenuActionState extends State<CupertinoContextMenuAction>
button:
true
,
child:
Container
(
decoration:
BoxDecoration
(
color:
_isPressed
?
_kBackgroundColorPressed
:
_kBackgroundColor
,
color:
_isPressed
?
CupertinoDynamicColor
.
resolve
(
_kBackgroundColorPressed
,
context
)
:
CupertinoDynamicColor
.
resolve
(
_kBackgroundColor
,
context
),
),
padding:
const
EdgeInsets
.
symmetric
(
vertical:
16.0
,
...
...
packages/flutter/test/cupertino/context_menu_action_test.dart
View file @
12b72919
...
...
@@ -5,15 +5,28 @@
import
'package:flutter/cupertino.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../rendering/mock_canvas.dart'
;
void
main
(
)
{
// Constants taken from _ContextMenuActionState.
const
Color
_kBackgroundColor
=
Color
(
0xFFEEEEEE
);
const
Color
_kBackgroundColorPressed
=
Color
(
0xFFDDDDDD
);
const
Color
_kRegularActionColor
=
CupertinoColors
.
black
;
const
CupertinoDynamicColor
_kBackgroundColor
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0xFFEEEEEE
),
darkColor:
Color
(
0xFF212122
),
);
// static const Color _kBackgroundColorPressed = Color(0xFFDDDDDD);
const
CupertinoDynamicColor
_kBackgroundColorPressed
=
CupertinoDynamicColor
.
withBrightness
(
color:
Color
(
0xFFDDDDDD
),
darkColor:
Color
(
0xFF3F3F40
),
);
const
Color
_kDestructiveActionColor
=
CupertinoColors
.
destructiveRed
;
const
FontWeight
_kDefaultActionWeight
=
FontWeight
.
w600
;
Widget
_getApp
({
VoidCallback
?
onPressed
,
bool
isDestructiveAction
=
false
,
bool
isDefaultAction
=
false
})
{
Widget
_getApp
({
VoidCallback
?
onPressed
,
bool
isDestructiveAction
=
false
,
bool
isDefaultAction
=
false
,
Brightness
?
brightness
,
})
{
final
UniqueKey
actionKey
=
UniqueKey
();
final
CupertinoContextMenuAction
action
=
CupertinoContextMenuAction
(
key:
actionKey
,
...
...
@@ -25,6 +38,9 @@ void main() {
);
return
CupertinoApp
(
theme:
CupertinoThemeData
(
brightness:
brightness
??
Brightness
.
light
,
),
home:
CupertinoPageScaffold
(
child:
Center
(
child:
action
,
...
...
@@ -33,16 +49,6 @@ void main() {
);
}
BoxDecoration
_getDecoration
(
WidgetTester
tester
)
{
final
Finder
finder
=
find
.
descendant
(
of:
find
.
byType
(
CupertinoContextMenuAction
),
matching:
find
.
byType
(
Container
),
);
expect
(
finder
,
findsOneWidget
);
final
Container
container
=
tester
.
widget
(
finder
);
return
container
.
decoration
!
as
BoxDecoration
;
}
TextStyle
_getTextStyle
(
WidgetTester
tester
)
{
final
Finder
finder
=
find
.
descendant
(
of:
find
.
byType
(
CupertinoContextMenuAction
),
...
...
@@ -76,22 +82,34 @@ void main() {
testWidgets
(
'turns grey when pressed and held'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_getApp
());
expect
(
_getDecoration
(
tester
).
color
,
_kBackgroundColor
);
expect
(
find
.
byType
(
CupertinoContextMenuAction
),
paints
..
rect
(
color:
_kBackgroundColor
.
color
));
final
Offset
actionCenterLight
=
tester
.
getCenter
(
find
.
byType
(
CupertinoContextMenuAction
));
final
TestGesture
gestureLight
=
await
tester
.
startGesture
(
actionCenterLight
);
await
tester
.
pump
();
expect
(
find
.
byType
(
CupertinoContextMenuAction
),
paints
..
rect
(
color:
_kBackgroundColorPressed
.
color
));
await
gestureLight
.
up
();
await
tester
.
pump
();
expect
(
find
.
byType
(
CupertinoContextMenuAction
),
paints
..
rect
(
color:
_kBackgroundColor
.
color
));
await
tester
.
pumpWidget
(
_getApp
(
brightness:
Brightness
.
dark
));
expect
(
find
.
byType
(
CupertinoContextMenuAction
),
paints
..
rect
(
color:
_kBackgroundColor
.
darkColor
));
final
Offset
actionCenter
=
tester
.
getCenter
(
find
.
byType
(
CupertinoContextMenuAction
));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
actionCenter
);
final
Offset
actionCenter
Dark
=
tester
.
getCenter
(
find
.
byType
(
CupertinoContextMenuAction
));
final
TestGesture
gesture
Dark
=
await
tester
.
startGesture
(
actionCenterDark
);
await
tester
.
pump
();
expect
(
_getDecoration
(
tester
).
color
,
_kBackgroundColorPressed
);
expect
(
find
.
byType
(
CupertinoContextMenuAction
),
paints
..
rect
(
color:
_kBackgroundColorPressed
.
darkColor
)
);
await
gesture
.
up
();
await
gesture
Dark
.
up
();
await
tester
.
pump
();
expect
(
_getDecoration
(
tester
).
color
,
_kBackgroundColor
);
expect
(
find
.
byType
(
CupertinoContextMenuAction
),
paints
..
rect
(
color:
_kBackgroundColor
.
darkColor
)
);
});
testWidgets
(
'icon and textStyle colors are correct out of the box'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
_getApp
());
expect
(
_getTextStyle
(
tester
).
color
,
_kRegularActionColor
);
expect
(
_getIcon
(
tester
).
color
,
_kRegularActionColor
);
expect
(
_getTextStyle
(
tester
).
color
,
CupertinoColors
.
label
);
expect
(
_getIcon
(
tester
).
color
,
CupertinoColors
.
label
);
});
testWidgets
(
'icon and textStyle colors are correct for destructive actions'
,
(
WidgetTester
tester
)
async
{
...
...
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