pub struct SheetSpec {
pub content: SheetContent,
pub detents: Vec<Detent>,
pub selected: Option<Detent>,
pub grabber: bool,
pub scrolling_expands: bool,
pub largest_undimmed: Option<Detent>,
pub corner_radius: Option<f64>,
pub dismissible: bool,
pub tint: Option<u32>,
pub dark: Option<bool>,
/* private fields */
}Expand description
What a sheet asks: its SheetContent, the detents it rests at and how
its sheet chrome behaves.
Validated when submitted (show_sheet), before any platform API is
touched — see Self::validate.
Fields§
§content: SheetContentWhat the sheet shows.
detents: Vec<Detent>The heights the sheet may rest at, smallest first by convention;
non-empty, no duplicates. Default [Medium, Large].
selected: Option<Detent>The detent the sheet opens at; None lets the platform choose (the
smallest). Must be one of Self::detents.
grabber: boolShow the grabber bar at the top edge (default true).
scrolling_expands: boolWhether scrolling to a scroll view’s edge grows the sheet to its next
detent instead of scrolling (UIKit’s
prefersScrollingExpandsWhenScrolledToEdge; default true).
largest_undimmed: Option<Detent>The largest detent at which the content behind the sheet stays
undimmed and interactive; None dims at every detent. Must be one of
Self::detents.
corner_radius: Option<f64>The sheet’s corner radius in points; None keeps the system radius.
dismissible: boolWhether the user may swipe the sheet away — answered as
SheetOutcome::Dismissed(DismissReason::User). false
leaves only an action or a programmatic dismissal (default true).
tint: Option<u32>A packed ARGB tint the Default-role action rows (and any other
tint-following chrome) wear; None keeps the system tint. With the
frust-api feature, SheetSpec::with_theme fills it (and
Self::dark) from the active theme.
dark: Option<bool>Pin the sheet’s light/dark appearance; None follows the system.
Implementations§
Source§impl SheetSpec
impl SheetSpec
Sourcepub fn with_theme(self, theme: &Theme) -> Self
pub fn with_theme(self, theme: &Theme) -> Self
Fold the active theme into the sheet — the theme ladder’s
representative subset, as for every control: SheetSpec::tint
from scheme().primary (the accent ink the Default-role rows wear)
and SheetSpec::dark from the theme’s brightness (L1).
Source§impl SheetSpec
impl SheetSpec
Sourcepub fn new(content: SheetContent) -> Self
pub fn new(content: SheetContent) -> Self
A dismissible [Medium, Large] sheet with a grabber, showing
content.
Sourcepub fn with_detents(self, detents: impl IntoIterator<Item = Detent>) -> Self
pub fn with_detents(self, detents: impl IntoIterator<Item = Detent>) -> Self
Replace the detents.
Sourcepub fn with_selected(self, detent: Detent) -> Self
pub fn with_selected(self, detent: Detent) -> Self
Open at detent (one of Self::detents).
Sourcepub fn with_dismissible(self, dismissible: bool) -> Self
pub fn with_dismissible(self, dismissible: bool) -> Self
Set Self::dismissible.
Sourcepub fn on_detent(
self,
listener: impl Fn(Detent) + Send + Sync + 'static,
) -> Self
pub fn on_detent( self, listener: impl Fn(Detent) + Send + Sync + 'static, ) -> Self
Stream the user’s detent changes into listener — intermediate
events while the sheet stays live, never terminal outcomes. Called on
the platform’s main thread (frust’s UI thread), once per change the
user makes (a drag, a grabber tap); a programmatic
SheetHandle::select_detent is not echoed back, following UIKit.
Sourcepub fn validate(&self) -> Result<(), PresentError>
pub fn validate(&self) -> Result<(), PresentError>
The submit-time validation: the content is not empty (a non-empty
title or message, an image or an action) and any image is non-empty
bytes; at most MAX_SHEET_ACTIONS actions, every action id
non-empty and unique; at least one detent, no duplicates, every
Detent::Custom fraction finite with 0 < f <= 1; selected and
largest_undimmed, when given, among detents; a corner_radius,
when given, finite and non-negative.
§Errors
PresentError::InvalidSpec naming the first rule broken.
Trait Implementations§
impl StructuralPartialEq for SheetSpec
Auto Trait Implementations§
impl !RefUnwindSafe for SheetSpec
impl !UnwindSafe for SheetSpec
impl Freeze for SheetSpec
impl Send for SheetSpec
impl Sync for SheetSpec
impl Unpin for SheetSpec
impl UnsafeUnpin for SheetSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.