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
4c21fb90
Unverified
Commit
4c21fb90
authored
May 20, 2020
by
Darren Austin
Committed by
GitHub
May 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the requirements for applying the elevation overlay. (#57526)
parent
a6357651
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
23 deletions
+25
-23
elevation_overlay.dart
packages/flutter/lib/src/material/elevation_overlay.dart
+8
-8
material.dart
packages/flutter/lib/src/material/material.dart
+3
-3
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+9
-8
material_test.dart
packages/flutter/test/material/material_test.dart
+5
-4
No files found.
packages/flutter/lib/src/material/elevation_overlay.dart
View file @
4c21fb90
...
...
@@ -14,19 +14,19 @@ import 'theme.dart';
/// This is an internal implementation class and should not be exported by
/// the material package.
class
ElevationOverlay
{
// This class is not meant to be instatiated or extended; this constructor
// This class is not meant to be insta
n
tiated or extended; this constructor
// prevents instantiation and extension.
// ignore: unused_element
ElevationOverlay
.
_
();
/// Applies an elevation overlay color to a
surface
color to indicate
/// Applies an elevation overlay color to a
given
color to indicate
/// the level of elevation in a dark theme.
///
/// If the
surrounding [Theme.applyElevationOverlayColor] is true, and
///
[color] is [Theme.colorScheme.surface
] then this will return
/// a version of the given color with a semi-transparent
[Theme.colorScheme.onSurface]
///
overlaid on top of it. The opacity of the overlay is controlled by the
/// [elevation].
/// If the
ambient [ThemeData.applyElevationOverlayColor] is true,
///
and [ThemeData.brightness] is [Brightness.dark
] then this will return
/// a version of the given color with a semi-transparent
///
[ThemeData.colorScheme.onSurface] overlaid on top of it. The opacity
///
of the overlay is computed based on the
[elevation].
///
/// Otherwise it will just return the [color] unmodified.
///
...
...
@@ -39,7 +39,7 @@ class ElevationOverlay {
final
ThemeData
theme
=
Theme
.
of
(
context
);
if
(
elevation
>
0.0
&&
theme
.
applyElevationOverlayColor
&&
color
==
theme
.
colorScheme
.
surface
)
{
theme
.
brightness
==
Brightness
.
dark
)
{
return
Color
.
alphaBlend
(
overlayColor
(
context
,
elevation
),
color
);
}
...
...
packages/flutter/lib/src/material/material.dart
View file @
4c21fb90
...
...
@@ -227,9 +227,9 @@ class Material extends StatefulWidget {
/// [MaterialType.transparency].
///
/// To support dark themes, if the surrounding
/// [ThemeData.applyElevationOverlayColor] is true
then a semi-transparent
///
overlay color will be composited on top this color to indicat
e
/// the elevation.
/// [ThemeData.applyElevationOverlayColor] is true
and [ThemeData.brightness]
///
is [Brightness.dark] then a semi-transparent overlay color will b
e
///
composited on top of this color to indicate
the elevation.
///
/// By default, the color is derived from the [type] of material.
final
Color
color
;
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
4c21fb90
...
...
@@ -933,12 +933,13 @@ class ThemeData with Diagnosticable {
/// elevation of a surface should be portrayed with an "overlay" in addition
/// to the shadow. As the elevation of the component increases, the
/// overlay increases in opacity. [applyElevationOverlayColor] turns the
/// application of this overlay on or off.
/// application of this overlay on or off
for dark themes
.
///
/// If [true] a semi-transparent version of [colorScheme.onSurface] will be
/// applied on top of the color of [Material] widgets when their [Material.color]
/// is [colorScheme.surface]. The level of transparency is based on
/// [Material.elevation] as per the Material Dark theme specification.
/// If [true] and [brightness] is [Brightness.dark], a
/// semi-transparent version of [colorScheme.onSurface] will be
/// applied on top of the color of [Material] widgets. The level of
/// transparency is based on [Material.elevation] as per the
/// Material Dark theme specification.
///
/// If [false] the surface color will be used unmodified.
///
...
...
@@ -951,9 +952,9 @@ class ThemeData with Diagnosticable {
///
/// See also:
///
/// * [Material.elevation], which effects
how transparent the white overlay is.
///
* [Material.color], the white color overlay will only be applied of the
///
material's color is [colorScheme.surface]
.
/// * [Material.elevation], which effects
the level of transparency of the
///
overlay color.
///
* [Material.color], the elevation overlay will be applied to this color
.
/// * <https://material.io/design/color/dark-theme.html>, which specifies how
/// the overlay should be applied.
final
bool
applyElevationOverlayColor
;
...
...
packages/flutter/test/material/material_test.dart
View file @
4c21fb90
...
...
@@ -273,20 +273,21 @@ void main() {
}
});
testWidgets
(
'overlay will
only apply to materials using colorScheme.surfac
e'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'overlay will
not apply to materials using a light them
e'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Theme
(
data:
ThemeData
(
applyElevationOverlayColor:
true
,
colorScheme:
const
ColorScheme
.
dark
().
copyWith
(
surface:
const
Color
(
0xFF121212
)
),
colorScheme:
const
ColorScheme
.
light
(
),
),
child:
buildMaterial
(
color:
Colors
.
cyan
,
elevation:
8.0
,
color:
Colors
.
cyan
,
elevation:
8.0
,
),
),
);
final
RenderPhysicalShape
model
=
getModel
(
tester
);
// Shouldn't change, as it was under a light color scheme.
expect
(
model
.
color
,
equals
(
Colors
.
cyan
));
});
...
...
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