pub struct WidgetConfig {Show 15 fields
pub version: u32,
pub small: Option<WidgetElement>,
pub medium: Option<WidgetElement>,
pub large: Option<WidgetElement>,
pub accessory: Option<WidgetElement>,
pub entries: Vec<WidgetEntry>,
pub strings: BTreeMap<String, BTreeMap<String, String>>,
pub default_locale: Option<String>,
pub source: Option<DataSource>,
pub data: Option<Value>,
pub state: Option<Map<String, Value>>,
pub transition: Option<Transition>,
pub templates: BTreeMap<String, WidgetElement>,
pub requires: Option<Requires>,
pub fallback: Option<FallbackLayouts>,
}Expand description
Top-level widget config with layouts per size family.
Fields§
§version: u32Schema version. Defaults to 1.
small: Option<WidgetElement>Layout for the small size family.
medium: Option<WidgetElement>Layout for the medium size family.
large: Option<WidgetElement>Layout for the large size family.
accessory: Option<WidgetElement>iOS / watchOS Lock Screen accessory families (circular, rectangular, inline).
Falls back to small. Ignored elsewhere. Not a resolve family: {{…}}, when,
repeat and entries do not apply to it.
entries: Vec<WidgetEntry>Scheduled states: from at on, an entry’s layouts replace the base ones.
The OS switches them while the app is closed (WidgetKit timeline, Android alarm,
desktop timer). See crate::resolve.
strings: BTreeMap<String, BTreeMap<String, String>>Localized strings per locale ("en", "pt-BR"), used as {{t.key}} in any text.
default_locale: Option<String>Locale used when the device locale has no strings table. Default: first table.
source: Option<DataSource>JSON the widget fetches by itself on a schedule; its fields are {{data.path}}.
data: Option<Value>Default values for {{data.path}} (overridden by setWidgetData and source).
state: Option<Map<String, Value>>Defaults of the widget’s local state, read as {{state.key}} / when /
bind / repeat.each: "state.list". Taps on elements with set change it
in-process (no app needed); setWidgetState changes it from the app. The stored
state (state:{widgetId}, state:{widgetId}#{instance}) is merged over these per
top-level key.
transition: Option<Transition>How content changes between timeline entries / redraws (a hint):
numeric animates digits, opacity cross-fades, slide pushes from the bottom.
Apple and desktop animate; Android and Adaptive Cards ignore it.
templates: BTreeMap<String, WidgetElement>Reusable elements expanded by {"type": "use", "template": "<key>"}.
requires: Option<Requires>Minimum renderer contract; older renderers show fallback instead.
fallback: Option<FallbackLayouts>Layouts shown by renderers that do not meet requires.
Implementations§
Source§impl WidgetConfig
impl WidgetConfig
Sourcepub fn small(el: impl Into<WidgetElement>) -> Self
pub fn small(el: impl Into<WidgetElement>) -> Self
Config with only the small size family set.
Sourcepub fn layouts_mut(&mut self) -> impl Iterator<Item = &mut WidgetElement>
pub fn layouts_mut(&mut self) -> impl Iterator<Item = &mut WidgetElement>
Every layout root, scheduled entries included (for host-side passes such as normalization and image prefetch).
Sourcepub fn with_medium(self, el: impl Into<WidgetElement>) -> Self
pub fn with_medium(self, el: impl Into<WidgetElement>) -> Self
Set the medium size family.
Sourcepub fn with_large(self, el: impl Into<WidgetElement>) -> Self
pub fn with_large(self, el: impl Into<WidgetElement>) -> Self
Set the large size family.
Trait Implementations§
Source§impl Clone for WidgetConfig
impl Clone for WidgetConfig
Source§impl Debug for WidgetConfig
impl Debug for WidgetConfig
Source§impl Default for WidgetConfig
impl Default for WidgetConfig
Source§impl<'de> Deserialize<'de> for WidgetConfig
impl<'de> Deserialize<'de> for WidgetConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for WidgetConfig
Available on crate feature schema only.
impl JsonSchema for WidgetConfig
schema only.Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read more