Skip to main content

CupertinoDynamicColor

Struct CupertinoDynamicColor 

Source
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: Color

Light, normal contrast, base level.

§dark_color: Color

Dark, normal contrast, base level.

§high_contrast_color: Color

Light, high contrast, base level.

§dark_high_contrast_color: Color

Dark, high contrast, base level.

§elevated_color: Color

Light, normal contrast, elevated.

§dark_elevated_color: Color

Dark, normal contrast, elevated.

§high_contrast_elevated_color: Color

Light, high contrast, elevated.

§dark_high_contrast_elevated_color: Color

Dark, 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

Source

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.

Source

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.

Source

pub const fn with_brightness(color: Color, dark_color: Color) -> Self

A colour that varies with the brightness alone.

Source

pub const fn labelled(self, label: &'static str) -> Self

The same colour, printed as label.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CupertinoDynamicColor

Source§

impl Debug for CupertinoDynamicColor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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.

Source§

fn from(c: Color) -> Self

Converts to this type from the input type.
Source§

impl From<CupertinoDynamicColor> for Color

An adaptive colour used without being resolved: its light, normal-contrast, base value.

Source§

fn from(c: CupertinoDynamicColor) -> Color

Converts to this type from the input type.
Source§

impl PartialEq for CupertinoDynamicColor

Equal when all eight values are: the label is only a name.

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.