Skip to main content

ElevationOverlay

Struct ElevationOverlay 

Source
pub struct ElevationOverlay;
Expand description

A utility class for dealing with the overlay color needed to indicate elevation of surfaces.

Dart’s abstract final class ElevationOverlay: it is never constructed, its members are associated functions.

Implementations§

Source§

impl ElevationOverlay

Source

pub fn apply_surface_tint( color: Color, surface_tint: Option<Color>, elevation: f64, ) -> Color

Applies a surface tint color to a given container color to indicate the level of its elevation.

With Material Design 3, some components will use a “surface tint” color overlay with an opacity applied to their base color to indicate they are elevated. The amount of opacity will vary with the elevation as described in: https://m3.material.io/styles/color/the-color-system/color-roles.

If surface_tint is not null and not completely transparent (Color::alpha is 0), then the returned color will be the given color with the surface_tint of the appropriate opacity applied to it. Otherwise it will just return color unmodified.

Source

pub fn apply_overlay( app: &mut App, context: BuildContext, color: Color, elevation: f64, ) -> Color

Applies an overlay color to a surface color to indicate the level of its elevation in a dark theme.

If using Material Design 3, this type of color overlay is no longer used. Instead a “surface tint” overlay is used instead. See apply_surface_tint, ThemeData::use_material3 for more information.

Material drop shadows can be difficult to see in a dark theme, so the 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. This function computes and applies this overlay to a given color as needed.

If the ambient theme is dark (ThemeData::brightness is Brightness::Dark), and ThemeData::apply_elevation_overlay_color is true, and the given color is ColorScheme::surface then this will return a version of the color with a semi-transparent ColorScheme::on_surface overlaid on top of it. The opacity of the overlay is computed based on the elevation.

Otherwise it will just return the color unmodified.

See also:

  • ThemeData::apply_elevation_overlay_color which controls the whether an overlay color will be applied to indicate elevation.
  • overlay_color which computes the needed overlay color.
  • Material which uses this to apply an elevation overlay to its surface.
  • https://material.io/design/color/dark-theme.html, which specifies how the overlay should be applied.
Source

pub fn overlay_color( app: &mut App, context: BuildContext, elevation: f64, ) -> Color

Computes the appropriate overlay color used to indicate elevation in dark themes.

If using Material Design 3, this type of color overlay is no longer used. Instead a “surface tint” overlay is used instead. See apply_surface_tint, ThemeData::use_material3 for more information.

See also:

Source

pub fn color_with_overlay( surface: Color, overlay: Color, elevation: f64, ) -> Color

Returns a color blended by laying a semi-transparent overlay (using the overlay color) on top of a surface (using the surface color).

If using Material Design 3, this type of color overlay is no longer used. Instead a “surface tint” overlay is used instead. See apply_surface_tint, ThemeData::use_material3 for more information.

The opacity of the overlay depends on elevation. As elevation increases, the opacity will also increase.

See https://material.io/design/color/dark-theme.html#properties.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,