next step is to query for song id

main
aprzn 1 year ago
parent 41e4dd8a32
commit cd3078da9c

@ -1,6 +1,6 @@
#![allow(dead_code)]
use eframe::{
egui::{CentralPanel, Context, Layout, TextFormat},
egui::{CentralPanel, Context, Layout, TextFormat, Visuals},
emath::Align,
epaint::{text::LayoutJob, Color32, FontId},
Frame,
@ -38,18 +38,26 @@ struct SfhResponse {
songs: Vec<SfhSong>,
}
enum Event {
IdSubmit { id: String },
}
enum App {
IdSelect { search_string: String },
IdSelect { search_string: String, enabled: bool },
}
impl App {
fn new() -> Self {
Self::IdSelect {
search_string: String::new(),
enabled: true
}
}
fn update(&mut self, ctx: &Context, frame: &mut Frame) {
let mut events: Vec<Event> = vec![];
ctx.set_visuals(Visuals::light());
let mut title_text = LayoutJob::default();
title_text.append(
"NONG",
@ -61,7 +69,7 @@ impl App {
},
);
title_text.append(
"fisher",
"fisher\n",
0.0,
TextFormat {
color: Color32::from_rgb(0x60, 0x80, 0xd0),
@ -76,14 +84,30 @@ impl App {
ui.label(title_text);
match self {
Self::IdSelect { search_string } => {
ui.horizontal(|ui| {
ui.text_edit_singleline(search_string);
Self::IdSelect { search_string, enabled } => {
ui.label("Enter level ID:");
ui.add_enabled_ui(*enabled, |ui| {
ui.text_edit_singleline(search_string).request_focus();
});
if *enabled {
if ui.button("submit").clicked() {
events.push(Event::IdSubmit { id: search_string.clone() });
}
} else {
ui.label("loading...");
}
}
}
});
});
for event in events {
match event {
Event::IdSubmit { id } => {
*self = Self::IdSelect { search_string: id, enabled: false };
},
}
}
}
}

Loading…
Cancel
Save