use fission::prelude::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum ShippingMethod { Standard, Express }
fission_component! {
pub ShippingChoice<()> {
state { selected: ShippingMethod = ShippingMethod::Standard }
}
view(choice, _state, cx) =>
Column(
children: [
Radio(
checked: choice.selected == ShippingMethod::Standard,
label: Some(cx.tr("shipping.standard")),
on_select: reduce { choice.selected = ShippingMethod::Standard; },
),
Radio(
checked: choice.selected == ShippingMethod::Express,
label: Some(cx.tr("shipping.express")),
on_select: reduce { choice.selected = ShippingMethod::Express; },
),
],
)
}
Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
id | Option<WidgetId> | Stable widget identity. | Defaults to None. |
checked | bool | Whether this option is the selected one. | Defaults to false. |
on_select | Option<ActionEnvelope> | Action fired when the radio is chosen. | Defaults to None. |
label | Option<String> | Visible text shown next to the radio indicator. | Defaults to None. |