Skip to content

Commit bb35a33

Browse files
committed
💻(App): load code based on selected sample
Adds a check to load the `code` field from `SAMPLE_CODES_LIST` if `selected_sample` is not empty, ensuring the correct sample code is displayed. Signed-off-by: Benign X <1341398182@qq.com>
1 parent 11f0476 commit bb35a33

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

‎Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "vegravis"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
edition = "2021"
55
homepage = "https://w-mai.github.io/vegravis"
66
repository = "https://github.com/W-Mai/vegravis"

‎src/app.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,17 @@ impl eframe::App for MainApp {
128128
self.is_loaded_from_url = true;
129129
}
130130

131+
if !self.selected_sample.is_empty() {
132+
self.code = AnyData::new(
133+
SAMPLE_CODES_LIST
134+
.iter()
135+
.find(|x| x.0 == self.selected_sample)
136+
.unwrap()
137+
.1
138+
.to_owned(),
139+
)
140+
}
141+
131142
egui::TopBottomPanel::top("top").show(ctx, |ui| {
132143
self.ui_about(ui);
133144
});

0 commit comments

Comments
 (0)