1use material::widget::page;
2use material_ui_rs as material;
3
4use super::super::{Message, RadioChoice, SegmentChoice, Showcase};
5
6pub(super) fn view(state: &Showcase) -> material::Element<'_, Message> {
7 page::sections([
8 page::section("Counter", counter_controls(state)).into(),
9 page::section("Actions", action_buttons(state)).into(),
10 page::section("FABs", fabs(state)).into(),
11 page::section("Chips", chips(state)).into(),
12 page::section("Segmented buttons", segmented_buttons(state)).into(),
13 page::section("Selection controls", selection_controls(state)).into(),
14 ])
15 .into()
16}
17
18fn counter_controls(state: &Showcase) -> material::Element<'_, Message> {
19 page::row([
20 material::widget::button::outlined_action("Minus", Message::Decrement),
21 material::text::headline_medium(state.count.to_string()).into(),
22 material::widget::button::filled_action("Plus", Message::Increment),
23 ])
24 .into()
25}
26
27fn action_buttons(state: &Showcase) -> material::Element<'_, Message> {
28 use material::widget::button;
29
30 page::row(button::enabled_actions(
31 state.enabled,
32 Message::Increment,
33 [
34 button::filled("Filled"),
35 button::filled_tonal("Tonal"),
36 button::text("Text"),
37 ],
38 ))
39 .into()
40}
41
42fn fabs(state: &Showcase) -> material::Element<'_, Message> {
43 use material::widget::button;
44
45 page::stack([
46 page::row(button::enabled_actions(
47 state.enabled,
48 Message::Increment,
49 [
50 button::surface_small_fab("add"),
51 button::surface_fab("add"),
52 button::surface_large_fab("add"),
53 button::primary_fab("add"),
54 button::secondary_fab("add"),
55 button::tertiary_fab("add"),
56 ],
57 ))
58 .into(),
59 page::row(button::enabled_actions(
60 state.enabled,
61 Message::Increment,
62 [
63 button::primary_extended_fab_with_icon("add", "Create"),
64 button::secondary_extended_fab_with_icon("share", "Share"),
65 button::tertiary_extended_fab_with_icon("add", "Add"),
66 button::surface_extended_fab("Reroute"),
67 ],
68 ))
69 .into(),
70 ])
71 .into()
72}
73
74fn chips(state: &Showcase) -> material::Element<'_, Message> {
75 use material::widget::button;
76
77 page::compact_row(button::enabled_actions(
78 state.enabled,
79 Message::Increment,
80 [
81 button::assist_chip("Assist"),
82 button::suggestion_chip("Suggestion"),
83 button::filter_chip("Filter"),
84 button::selected_filter_chip("Selected"),
85 ],
86 ))
87 .into()
88}
89
90fn segmented_buttons(state: &Showcase) -> material::Element<'_, Message> {
91 use material::widget::segmented_button;
92
93 segmented_button::group(segmented_button::animated_selectable_label_actions(
94 &state.segment_state,
95 [
96 ("List", Message::SegmentSelected(SegmentChoice::List)),
97 ("Grid", Message::SegmentSelected(SegmentChoice::Grid)),
98 ("Map", Message::SegmentSelected(SegmentChoice::Map)),
99 ],
100 ))
101 .into()
102}
103
104fn selection_controls(state: &Showcase) -> material::Element<'_, Message> {
105 let switches = page::component_stack([
106 material::widget::checkbox::standard(
107 state.enabled,
108 "Enable actions",
109 Message::EnabledChanged,
110 )
111 .into(),
112 state
113 .theme_controller
114 .dark_mode_switch("Dark theme", Message::ThemeChanged)
115 .into(),
116 ]);
117
118 let radios = page::row([
119 material::widget::radio::standard(
120 "Standard",
121 RadioChoice::Standard,
122 state.radio_choice,
123 Message::ChoiceSelected,
124 )
125 .into(),
126 material::widget::radio::standard(
127 "Expressive",
128 RadioChoice::Expressive,
129 state.radio_choice,
130 Message::ChoiceSelected,
131 )
132 .into(),
133 material::widget::radio::standard(
134 "Dense",
135 RadioChoice::Dense,
136 state.radio_choice,
137 Message::ChoiceSelected,
138 )
139 .into(),
140 ]);
141
142 page::spacious_stack([switches.into(), radios.into()]).into()
143}