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
//! Loading indicator view for the showcase application.
use bevy::prelude::*;
use bevy_material_ui::{
loading_indicator::{LoadingIndicatorBuilder, ShapeMorphMaterial, SpawnLoadingIndicatorChild},
prelude::*,
};
use crate::showcase::common::*;
/// Spawn the loading indicator section content
pub fn spawn_loading_indicator_section(
parent: &mut ChildSpawnerCommands,
theme: &MaterialTheme,
materials: &mut Assets<ShapeMorphMaterial>,
) {
parent
.spawn(Node {
flex_direction: FlexDirection::Column,
row_gap: Val::Px(16.0),
..default()
})
.with_children(|section| {
spawn_section_header(
section,
theme,
"showcase.section.loading_indicator.title",
"Loading Indicator",
"showcase.section.loading_indicator.description",
"Material Design 3 loading indicators with morphing shapes",
);
section
.spawn(Node {
flex_direction: FlexDirection::Column,
row_gap: Val::Px(16.0),
width: Val::Percent(100.0),
max_width: Val::Px(420.0),
margin: UiRect::vertical(Val::Px(8.0)),
..default()
})
.with_children(|col| {
// Default
col.spawn((
Text::new(""),
LocalizedText::new("showcase.loading.default")
.with_default("Loading indicator"),
TextFont {
font_size: 14.0,
..default()
},
TextColor(theme.on_surface_variant),
NeedsInternationalFont,
));
col.spawn((Node::default(), TestId::new("loading_indicator_default")))
.with_children(|node| {
node.spawn_loading_indicator(theme, materials);
});
// Contained (with container background)
col.spawn((
Text::new(""),
LocalizedText::new("showcase.loading.with_container")
.with_default("Loading indicator with container"),
TextFont {
font_size: 14.0,
..default()
},
TextColor(theme.on_surface_variant),
NeedsInternationalFont,
));
col.spawn_loading_indicator_with(
theme,
materials,
LoadingIndicatorBuilder::new().contained(),
);
// Multiple colors
col.spawn((
Text::new(""),
LocalizedText::new("showcase.loading.multi_color")
.with_default("Loading indicator with multiple colors"),
TextFont {
font_size: 14.0,
..default()
},
TextColor(theme.on_surface_variant),
NeedsInternationalFont,
));
col.spawn_loading_indicator_with(
theme,
materials,
LoadingIndicatorBuilder::new().multi_color(),
);
// Small size
col.spawn((
Text::new(""),
LocalizedText::new("showcase.loading.small")
.with_default("Small loading indicator"),
TextFont {
font_size: 14.0,
..default()
},
TextColor(theme.on_surface_variant),
NeedsInternationalFont,
));
col.spawn_loading_indicator_with(
theme,
materials,
LoadingIndicatorBuilder::new().size(36.0),
);
// Large and fast
col.spawn((
Text::new(""),
LocalizedText::new("showcase.loading.large_fast")
.with_default("Large loading indicator (fast)"),
TextFont {
font_size: 14.0,
..default()
},
TextColor(theme.on_surface_variant),
NeedsInternationalFont,
));
col.spawn_loading_indicator_with(
theme,
materials,
LoadingIndicatorBuilder::new().size(64.0).speed(2.0),
);
});
spawn_code_block(
section,
theme,
include_str!("../../loading_indicator_demo.rs"),
);
});
}