From ce12dd57b1b2ed6d02b13817f3677b066a5cd141 Mon Sep 17 00:00:00 2001 From: Benign X <1341398182@qq.com> Date: Fri, 22 Nov 2024 00:44:22 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=BB(App):=20load=20code=20based=20on?= =?UTF-8?q?=20selected=20sample?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- src/app.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/app.rs b/src/app.rs index 4925df0..eff03d0 100644 --- a/src/app.rs +++ b/src/app.rs @@ -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); });