Added ip param to app. Some really basic code just testing a new dev environment

This commit is contained in:
Luke Else 2023-07-05 22:53:40 +01:00
parent 0a5061d787
commit 2170c7872e
4 changed files with 15 additions and 5 deletions

View File

@ -9,3 +9,4 @@ edition = "2021"
egui = "0.22.0" egui = "0.22.0"
eframe = "0.22.0" eframe = "0.22.0"
tracing-subscriber = "0.3.16" tracing-subscriber = "0.3.16"
subnet_calculator = "0.1.0"

View File

@ -2,14 +2,16 @@ mod ui;
/// Stuct to store the state of the running application /// Stuct to store the state of the running application
pub struct App { pub struct App {
name: String name: String,
ip: String
} }
impl Default for App { impl Default for App {
/// Creates the default startup state for the app; /// Creates the default startup state for the app;
fn default() -> Self { fn default() -> Self {
Self { Self {
name: String::from("Hello, World!") name: String::from("Hello, World!"),
ip: String::from("127.0.0.1")
} }
} }
} }

View File

@ -1,6 +1,10 @@
use std::str::FromStr;
use crate::app::App; use crate::app::App;
use crate::theme::onedark::ONE_DARK; use crate::theme::onedark::ONE_DARK;
use subnet_calculator::{Network, ip::IpAddr};
impl eframe::App for App { impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let background_frame = egui::Frame::default().fill(ONE_DARK.bg); let background_frame = egui::Frame::default().fill(ONE_DARK.bg);
@ -16,6 +20,9 @@ impl eframe::App for App {
.auto_sized() .auto_sized()
.show(ctx, |ui| { .show(ctx, |ui| {
ui.heading(&self.name); ui.heading(&self.name);
ui.text_edit_singleline(&mut self.ip);
Network::create_subnet(&IpAddr::from_str(self.ip.as_str()).unwrap(), 24).unwrap();
for _ in 0..10 { for _ in 0..10 {
ui.add(egui::Button::new(&self.name)); ui.add(egui::Button::new(&self.name));
@ -23,4 +30,4 @@ impl eframe::App for App {
} }
); );
} }
} }

View File

@ -20,4 +20,4 @@ fn main() -> Result<(), eframe::Error> {
options, options,
Box::new(|_cc| Box::new(App::default())), Box::new(|_cc| Box::new(App::default())),
) )
} }