1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
use super::*;
/// Fluent section builder for `EuvNavItem`.
impl EuvNavItem {
/// Assigns a sidebar category group label rendered above the first item in that group.
///
/// # Arguments
///
/// - `Self` - Source navigation item.
/// - `&str` - Category section title.
///
/// # Returns
///
/// - `Self` - Updated navigation item.
#[must_use]
pub fn section(mut self, group: &str) -> Self {
self.set_section(group.to_string());
self
}
}
/// Declarative `#[component]` implementation for `EuvSidebarNav`.
#[component]
/// Inherent implementation of [`EuvSidebarNav`].
impl EuvSidebarNav {
/// Renders `EuvSidebarNav` into the ambient framework-managed `Context`.
///
/// # Arguments
///
/// - `&Self` - Component descriptor reference.
///
/// # Returns
///
/// - `NodeId` - Mounted root scene node handle.
fn render(&self) -> NodeId {
let p: ThemePalette = self.get_tokens().get_palette();
let g: ThemeGeometry = self.get_tokens().get_geometry();
let active_route: Signal<String> = self.get_active_route();
let Self { items, .. } = self.clone();
let mut last_section: String = String::new();
let mut entries: Vec<SidebarNavEntry> = Vec::with_capacity(items.len());
for (idx, item) in items.into_iter().enumerate() {
let sec: &str = item.get_section().as_str();
let sec_header: Option<(String, f32)> =
if !sec.is_empty() && sec != last_section.as_str() {
last_section = sec.to_string();
Some((sec.to_string(), if idx == 0 { 2.0 } else { 12.0 }))
} else {
None
};
let target_path: String = item.get_path().clone();
let click_path: String = target_path.clone();
let indicator_path: String = target_path.clone();
let label: String = item.get_label().clone();
entries.push((sec_header, label, target_path, click_path, indicator_path));
}
view! {
column {
width: Length::Percent(100.0)
gap: 2.0
for (sec_header, label, target_path, click_path, indicator_path) in entries.into_iter() {
if let Some((sec_title, top_pad)) = sec_header {
row {
width: Length::Percent(100.0)
padding: Edges::new(top_pad, SPACE_SM, 4.0, SPACE_SM)
text {
font_size: 11.0
font_weight: FontWeight::SemiBold
color: p.get_muted_foreground()
{ sec_title }
}
}
}
row {
bind_style: move || {
let is_active: bool = active_route.get() == target_path;
Style::default()
.row()
.width(Length::Percent(100.0))
.height(Length::Px(g.get_control_sm().max(34.0)))
.align(AlignItems::Center)
.gap(SPACE_SM)
.padding(Edges::symmetric(0.0, SPACE_SM))
.radius(g.get_radius_md())
.background(if is_active {
p.get_primary().with_alpha(24)
} else {
COLOR_TRANSPARENT
})
.cursor(CursorIcon::Pointer)
}
on_click: move |_: &UiEvent| {
let _: bool = active_route.set_if_changed(click_path.clone());
}
view {
bind_style: move || {
let is_active: bool = active_route.get() == indicator_path;
Style::default()
.width(Length::Px(3.5))
.height(Length::Px(18.0))
.radius(99.0)
.background(if is_active {
p.get_primary()
} else {
COLOR_TRANSPARENT
})
}
}
text {
font_size: 13.5
font_weight: FontWeight::SemiBold
color: p.get_foreground()
text_overflow: TextOverflow::Clip
{ label }
}
}
}
}
}
}
}
/// Declarative `#[component]` implementation for `EuvTabs`.
#[component]
/// Inherent implementation of [`EuvTabs`].
impl EuvTabs {
/// Renders `EuvTabs` into the ambient framework-managed `Context`.
///
/// # Arguments
///
/// - `&Self` - Component descriptor reference.
///
/// # Returns
///
/// - `NodeId` - Mounted root scene node handle.
fn render(&self) -> NodeId {
let p: ThemePalette = self.get_tokens().get_palette();
let g: ThemeGeometry = self.get_tokens().get_geometry();
let active: Signal<usize> = self.get_active();
let Self { labels, .. } = self.clone();
view! {
row {
flex_wrap: FlexWrap::Wrap
width: Length::Percent(100.0)
gap: SPACE_XS
background: p.get_muted()
padding: Edges::all(SPACE_XS)
radius: g.get_radius_md()
for (idx, label) in labels.into_iter().enumerate() {
row {
bind_style: move || {
let selected: bool = active.get() == idx;
let mut st: Style = Style::default()
.row()
.height(Length::Px(g.get_control_sm()))
.justify(JustifyContent::Center)
.align(AlignItems::Center)
.padding(Edges::symmetric(0.0, SPACE_MD))
.overflow(Overflow::Hidden)
.radius(g.get_radius_sm())
.background(if selected {
p.get_card()
} else {
COLOR_TRANSPARENT
})
.border(
if selected { g.get_border_width() } else { 0.0 },
p.get_border(),
)
.cursor(CursorIcon::Pointer);
if selected {
st = st.shadow(g.get_shadow_xs());
}
st
}
on_click: move |_: &UiEvent| {
let _: bool = active.set_if_changed(idx);
}
text {
font_size: 13.0
font_weight: FontWeight::Medium
color: p.get_foreground()
text_align: TextAlign::Center
text_overflow: TextOverflow::Ellipsis
{ label }
}
}
}
}
}
}
}
/// Declarative `#[component]` implementation for `EuvBottomNav`.
#[component]
/// Inherent implementation of [`EuvBottomNav`].
impl EuvBottomNav {
/// Renders `EuvBottomNav` as a modern floating pill dock with crisp vector icons and high-contrast active capsule states.
///
/// # Arguments
///
/// - `&Self` - Component descriptor reference.
///
/// # Returns
///
/// - `NodeId` - Mounted bottom navigation bar container handle.
fn render(&self) -> NodeId {
let p: ThemePalette = self.get_tokens().get_palette();
let active_route: Signal<String> = self.get_active_route();
let Self { items, .. } = self.clone();
let tab_nodes: Vec<NodeId> = items
.into_iter()
.map(|item: EuvNavItem| {
let target_path: String = item.get_path().clone();
let click_path: String = target_path.clone();
let pill_path: String = target_path.clone();
let icon_path: String = target_path.clone();
let label_path: String = target_path;
let label: String = item.get_label().clone();
let icon_label: String = label.clone();
let on_tab_click = move |_: &UiEvent| {
let _: bool = active_route.set_if_changed(click_path.clone());
};
let tab_pill_style = move || -> Style {
let active: bool = active_route.get() == pill_path;
Style::default()
.column()
.flex_grow(1.0)
.flex_shrink(1.0)
.min_width(Length::Px(0.0))
.height(Length::Px(46.0))
.justify(JustifyContent::Center)
.align(AlignItems::Center)
.gap(2.0)
.padding(Edges::symmetric(3.0, 6.0))
.radius(23.0)
.overflow(Overflow::Hidden)
.background(if active {
p.get_primary()
} else {
COLOR_TRANSPARENT
})
.cursor(CursorIcon::Pointer)
};
let paint_icon = move |bounds: Rect, dl: &mut DisplayList| {
let active: bool = active_route.get_untracked() == icon_path;
let col: Color = if active {
p.get_primary_foreground()
} else {
p.get_muted_foreground()
};
draw_bottom_nav_icon(bounds, dl, &icon_path, &icon_label, col);
};
let label_style = move || -> Style {
let active: bool = active_route.get() == label_path;
Style::default()
.font_size(10.5)
.font_weight(if active {
FontWeight::Bold
} else {
FontWeight::Medium
})
.color(if active {
p.get_primary_foreground()
} else {
p.get_muted_foreground()
})
.text_align(TextAlign::Center)
.text_overflow(TextOverflow::Clip)
};
view! {
column {
bind_style: tab_pill_style
on_click: on_tab_click
canvas {
width: Length::Px(20.0)
height: Length::Px(18.0)
painter: paint_icon
}
text {
bind_style: label_style
{ label }
}
}
}
})
.collect();
view! {
row {
width: Length::Percent(100.0)
height: Length::Percent(100.0)
justify: JustifyContent::SpaceBetween
align: AlignItems::Center
gap: 4.0
..tab_nodes
}
}
}
}