generated from luke-else/egui-template
	Refactored some small logic. Blank ICAO ready by default
This commit is contained in:
		
							
								
								
									
										1
									
								
								src/app/metar/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/app/metar/mod.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
 | 
			
		||||
@@ -1,3 +1,5 @@
 | 
			
		||||
mod metar;
 | 
			
		||||
mod req;
 | 
			
		||||
mod ui;
 | 
			
		||||
 | 
			
		||||
/// Stuct to store the state of the running application
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								src/app/req/mod.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/app/req/mod.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
 | 
			
		||||
@@ -6,7 +6,6 @@ pub mod tabs;
 | 
			
		||||
impl<'a> eframe::App for App<'a> {
 | 
			
		||||
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
 | 
			
		||||
        let frame = egui::Frame::default().fill(ONE_DARK.bg);
 | 
			
		||||
 | 
			
		||||
        // Display the top bar of tabs
 | 
			
		||||
        tabs::display_tabs(&mut self.tab_state, ctx, &frame);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,19 +1,33 @@
 | 
			
		||||
use egui::Key;
 | 
			
		||||
 | 
			
		||||
use super::Tab;
 | 
			
		||||
 | 
			
		||||
#[derive(Debug, Default, PartialEq, Eq)]
 | 
			
		||||
#[derive(Debug, PartialEq, Eq)]
 | 
			
		||||
pub struct MetarTab {
 | 
			
		||||
    pub icaos: Vec<String>,
 | 
			
		||||
    pub metars: Vec<String>,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Default for MetarTab {
 | 
			
		||||
    fn default() -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
            icaos: vec!["".to_string()],
 | 
			
		||||
            metars: vec![],
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Tab for MetarTab {
 | 
			
		||||
    fn display_tab(&mut self, ctx: &egui::Context, frame: &egui::Frame) {
 | 
			
		||||
        egui::CentralPanel::default().frame(*frame).show(ctx, |ui| {
 | 
			
		||||
            // Given Key pressed, place focus on next item
 | 
			
		||||
            let new_icao_focus: bool = ui.input(|i| i.key_pressed(Key::Space));
 | 
			
		||||
 | 
			
		||||
            for icao in self.icaos.iter_mut() {
 | 
			
		||||
                ui.text_edit_singleline(icao);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if ui.button("Add More").clicked() || ui.input(|i| i.key_pressed(egui::Key::Tab)) {
 | 
			
		||||
            if ui.button("Add More").clicked() || new_icao_focus {
 | 
			
		||||
                self.icaos.push("".to_string());
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
pub mod metar_tab;
 | 
			
		||||
mod metar_tab;
 | 
			
		||||
 | 
			
		||||
use std::collections::HashMap;
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user