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"
eframe = "0.22.0"
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
pub struct App {
name: String
name: String,
ip: String
}
impl Default for App {
/// Creates the default startup state for the app;
fn default() -> 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::theme::onedark::ONE_DARK;
use subnet_calculator::{Network, ip::IpAddr};
impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let background_frame = egui::Frame::default().fill(ONE_DARK.bg);
@ -17,6 +21,9 @@ impl eframe::App for App {
.show(ctx, |ui| {
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 {
ui.add(egui::Button::new(&self.name));
}