euv_example/pages/shell/
impl.rs1use super::*;
2
3impl ShowcasePage {
5 #[must_use]
17 pub fn new(route: &'static str, state: ShowcaseState, tokens: ThemeTokens) -> Self {
18 Self {
19 route,
20 state,
21 tokens,
22 }
23 }
24}
25
26#[component(retention = Freeze)]
28impl ShowcasePage {
30 fn on_mount(&self, _node: NodeId) {
37 let route: &str = self.get_route();
38 let node_style: &ShowcaseState = self.get_state();
39 let _: bool = {
40 if let Some(mut updated_value) = (node_style.get_lifecycle_mounts()).try_get_untracked()
41 {
42 {
43 let char_item: &mut u32 = &mut updated_value;
44 *char_item += 1;
45 }
46 (node_style.get_lifecycle_mounts()).set(updated_value)
47 } else {
48 false
49 }
50 };
51 let _: bool = node_style
52 .get_lifecycle_last_event()
53 .set_if_changed(format!("MOUNT {route} (PageRetention::Freeze)"));
54 if !node_style.get_bg_frozen().get_untracked() {
55 if route == ROUTE_GAME {
56 node_style.get_game_host().set_paused(false);
57 } else if route == ROUTE_GAME_3D {
58 node_style.get_game3d_host().set_paused(false);
59 } else if route == ROUTE_WATER {
60 node_style.get_water_host().set_paused(false);
61 }
62 }
63 }
64
65 fn on_activate(&self, _node: NodeId) {
72 let route: &str = self.get_route();
73 let node_style: &ShowcaseState = self.get_state();
74 if !node_style.get_bg_frozen().get_untracked() {
75 if route == ROUTE_GAME {
76 node_style.get_game_host().set_paused(false);
77 } else if route == ROUTE_GAME_3D {
78 node_style.get_game3d_host().set_paused(false);
79 } else if route == ROUTE_WATER {
80 node_style.get_water_host().set_paused(false);
81 }
82 }
83 }
84
85 fn on_freeze(&self, _node: NodeId) {
92 let route: &str = self.get_route();
93 let node_style: &ShowcaseState = self.get_state();
94 let _: bool = {
95 if let Some(mut updated_value) =
96 (node_style.get_lifecycle_freezes()).try_get_untracked()
97 {
98 {
99 let char_item: &mut u32 = &mut updated_value;
100 *char_item += 1;
101 }
102 (node_style.get_lifecycle_freezes()).set(updated_value)
103 } else {
104 false
105 }
106 };
107 let _: bool = node_style
108 .get_lifecycle_last_event()
109 .set_if_changed(format!("FREEZE {route} (effects & engines suspended)"));
110 if route == ROUTE_GAME {
111 node_style.get_game_host().set_paused(true);
112 } else if route == ROUTE_GAME_3D {
113 node_style.get_game3d_host().set_paused(true);
114 } else if route == ROUTE_WATER {
115 node_style.get_water_host().set_paused(true);
116 }
117 }
118
119 fn on_resume(&self, _node: NodeId) {
126 let route: &str = self.get_route();
127 let node_style: &ShowcaseState = self.get_state();
128 let _: bool = {
129 if let Some(mut updated_value) =
130 (node_style.get_lifecycle_resumes()).try_get_untracked()
131 {
132 {
133 let char_item: &mut u32 = &mut updated_value;
134 *char_item += 1;
135 }
136 (node_style.get_lifecycle_resumes()).set(updated_value)
137 } else {
138 false
139 }
140 };
141 let _: bool = node_style
142 .get_lifecycle_last_event()
143 .set_if_changed(format!("RESUME {route} (coalesced state synced)"));
144 if !node_style.get_bg_frozen().get_untracked() {
145 if route == ROUTE_GAME {
146 node_style.get_game_host().set_paused(false);
147 } else if route == ROUTE_GAME_3D {
148 node_style.get_game3d_host().set_paused(false);
149 } else if route == ROUTE_WATER {
150 node_style.get_water_host().set_paused(false);
151 }
152 }
153 }
154
155 fn on_destroy(&self) {
161 let route: &str = self.get_route();
162 let node_style: &ShowcaseState = self.get_state();
163 let _: bool = {
164 if let Some(mut updated_value) =
165 (node_style.get_lifecycle_destroys()).try_get_untracked()
166 {
167 {
168 let char_item: &mut u32 = &mut updated_value;
169 *char_item += 1;
170 }
171 (node_style.get_lifecycle_destroys()).set(updated_value)
172 } else {
173 false
174 }
175 };
176 if route == ROUTE_GAME {
177 node_style.get_game_host().set_paused(true);
178 } else if route == ROUTE_GAME_3D {
179 node_style.get_game3d_host().set_paused(true);
180 } else if route == ROUTE_WATER {
181 node_style.get_water_host().set_paused(true);
182 }
183 }
184
185 fn render(&self) -> NodeId {
195 mount_route_by_name(self.get_route(), self.get_state(), self.get_tokens())
196 }
197}