diff --git a/src/iced.rs b/src/iced.rs index 669f2b0..f37e192 100644 --- a/src/iced.rs +++ b/src/iced.rs @@ -1,9 +1,26 @@ -//use iced::{Application, Command, executor, Clipboard, Element, Text, Settings}; +use iced::{ + widget::{button, text}, + Element, +}; pub fn iced_main() -> iced::Result { - println!("Iced"); - Ok(()) - //Gamarjoba::run(Settings::default()) + println!("Iced"); + iced::run("A counter", update, view) +} + +#[derive(Debug, Clone)] +enum Message { + Increment, +} + +fn update(counter: &mut u64, message: Message) { + match message { + Message::Increment => *counter += 1, + } +} + +fn view(counter: &u64) -> Element { + button(text(counter)).on_press(Message::Increment).into() } /* diff --git a/src/main.rs b/src/main.rs index 4f1ec97..2b43026 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,37 +1,31 @@ mod iced; -use anyhow::{Result, anyhow}; +use anyhow::{anyhow, Result}; fn main() -> Result<()> { + let args: Vec = std::env::args().collect(); - let args: Vec = std::env::args().collect(); + let framework = match args.get(1) { + Some(s) => s, + None => return Err(anyhow!("Specify a framework to use")), + }; - let framework = match args.get(1) { - Some(s) => s, - None => return Err(anyhow!("Specify a framework to use")) - }; - - match framework.as_str() { - "iced" => { - iced::iced_main().map_err(|err| anyhow!(err)) - }, - "druid" => druid_main(), - "egui" => egui_main(), - other => { - Err(anyhow!(r#"You specified {other}, allowed values: "iced", "egui""#)) + match framework.as_str() { + "iced" => iced::iced_main().map_err(|err| anyhow!(err)), + "druid" => druid_main(), + "egui" => egui_main(), + other => Err(anyhow!( + r#"You specified {other}, allowed values: "iced", "egui""# + )), } - } } - fn druid_main() -> Result<()> { - println!("druid"); - Ok(()) + println!("druid"); + Ok(()) } fn egui_main() -> Result<()> { - println!("egui - not implemented yet"); - Ok(()) + println!("egui - not implemented yet"); + Ok(()) } - -