pub struct CupertinoDynamicColor {
pub color: Color,
pub dark_color: Color,
pub high_contrast_color: Color,
pub dark_high_contrast_color: Color,
pub elevated_color: Color,
pub dark_elevated_color: Color,
pub high_contrast_elevated_color: Color,
pub dark_high_contrast_elevated_color: Color,
pub debug_label: Option<&'static str>,
}Expand description
A colour that adapts: up to eight values for one name, one for each combination of a light or dark interface, normal or high contrast, and the base or the elevated level.
resolve picks the one that applies where it is used;
resolve_with picks it for conditions given outright. Used as a
plain Color without being resolved (Color::from), it is its light, normal-contrast,
base value, as the reference’s is.
Most colours vary along fewer than three of the axes, and two constructors say so:
with_brightness and
with_brightness_and_contrast. The palette is
CupertinoColors.
use frus_widgets::{Brightness, Color, CupertinoDynamicColor, CupertinoUserInterfaceLevelData};
let ink = CupertinoDynamicColor::with_brightness(Color::rgb8(20, 20, 20), Color::rgb8(240, 240, 240));
let dark = ink.resolve_with(Brightness::Dark, CupertinoUserInterfaceLevelData::Base, false);
assert_eq!(dark, Color::rgb8(240, 240, 240));Fields§
§color: ColorLight, normal contrast, base level.
dark_color: ColorDark, normal contrast, base level.
high_contrast_color: ColorLight, high contrast, base level.
dark_high_contrast_color: ColorDark, high contrast, base level.
elevated_color: ColorLight, normal contrast, elevated.
dark_elevated_color: ColorDark, normal contrast, elevated.
high_contrast_elevated_color: ColorLight, high contrast, elevated.
dark_high_contrast_elevated_color: ColorDark, high contrast, elevated.
debug_label: Option<&'static str>A name to tell it by when it is printed; it takes no part in equality.
Implementations§
Source§impl CupertinoDynamicColor
impl CupertinoDynamicColor
Sourcepub const fn new(
color: Color,
dark_color: Color,
high_contrast_color: Color,
dark_high_contrast_color: Color,
elevated_color: Color,
dark_elevated_color: Color,
high_contrast_elevated_color: Color,
dark_high_contrast_elevated_color: Color,
) -> Self
pub const fn new( color: Color, dark_color: Color, high_contrast_color: Color, dark_high_contrast_color: Color, elevated_color: Color, dark_elevated_color: Color, high_contrast_elevated_color: Color, dark_high_contrast_elevated_color: Color, ) -> Self
A colour that varies along all three axes: all eight values, given outright.
Sourcepub const fn with_brightness_and_contrast(
color: Color,
dark_color: Color,
high_contrast_color: Color,
dark_high_contrast_color: Color,
) -> Self
pub const fn with_brightness_and_contrast( color: Color, dark_color: Color, high_contrast_color: Color, dark_high_contrast_color: Color, ) -> Self
A colour that varies with the brightness and the contrast, and is the same at either level.
Sourcepub const fn with_brightness(color: Color, dark_color: Color) -> Self
pub const fn with_brightness(color: Color, dark_color: Color) -> Self
A colour that varies with the brightness alone.
Sourcepub fn resolve_with(
&self,
brightness: Brightness,
level: CupertinoUserInterfaceLevelData,
high_contrast: bool,
) -> Color
pub fn resolve_with( &self, brightness: Brightness, level: CupertinoUserInterfaceLevelData, high_contrast: bool, ) -> Color
The value for these conditions: a brightness, a level, and whether the
reader has asked for high_contrast.
Sourcepub fn resolve(&self, theme: &Theme) -> Color
pub fn resolve(&self, theme: &Theme) -> Color
The value where it is used: in the brightness of the Apple-style theme under
theme (CupertinoTheme::brightness_of), at
the level theme says its subtree is at, and in high contrast if the reader has asked
for it (Accessibility::high_contrast, read
from the ambient MediaQuery).
That brightness is the theme’s, not the system’s, unless the theme says otherwise: an application that keeps a light theme on a dark system gets the light values, as the reference’s adaptive colours under its main theme do.
Trait Implementations§
Source§impl Clone for CupertinoDynamicColor
impl Clone for CupertinoDynamicColor
impl Copy for CupertinoDynamicColor
Source§impl Debug for CupertinoDynamicColor
impl Debug for CupertinoDynamicColor
Source§impl From<Color> for CupertinoDynamicColor
A plain colour as an adaptive one: the same in every condition, so that a theme takes
either where it takes a colour.
impl From<Color> for CupertinoDynamicColor
A plain colour as an adaptive one: the same in every condition, so that a theme takes either where it takes a colour.
Source§impl From<CupertinoDynamicColor> for Color
An adaptive colour used without being resolved: its light, normal-contrast, base value.
impl From<CupertinoDynamicColor> for Color
An adaptive colour used without being resolved: its light, normal-contrast, base value.