Skip to content

Commit

Permalink
💻(App): load code based on selected sample
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
W-Mai committed Nov 21, 2024
1 parent 11f0476 commit ce12dd5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ impl eframe::App for MainApp {
self.is_loaded_from_url = true;
}

if !self.selected_sample.is_empty() {
self.code = AnyData::new(
SAMPLE_CODES_LIST
.iter()
.find(|x| x.0 == self.selected_sample)
.unwrap()
.1
.to_owned(),
)
}

egui::TopBottomPanel::top("top").show(ctx, |ui| {
self.ui_about(ui);
});
Expand Down

0 comments on commit ce12dd5

Please sign in to comment.