Floem basic example

This commit is contained in:
Greg Shuflin 2024-10-20 20:16:34 -07:00
parent 04f4af5f79
commit 5fd5300bd2
5 changed files with 31 additions and 13 deletions

10
justfile Normal file
View File

@ -0,0 +1,10 @@
_default:
@just --list
run *args:
cargo run -- {{args}}
floem:
cargo run --bin floem

20
src/bin/floem.rs Normal file
View File

@ -0,0 +1,20 @@
use anyhow::Result;
use floem::{reactive::create_signal, views::{button, label}, IntoView};
pub fn main() -> Result<()> {
floem::launch(app_view);
Ok(())
}
fn app_view() -> impl IntoView {
let (counter, mut set_counter) = create_signal(0);
(
label(move || format!("Value: {counter}")),
(
button("Increment").action(move || set_counter +=1),
button("Decrement").action(move || set_counter -=1),
)
)
}

View File

@ -1,7 +0,0 @@
use anyhow::Result;
pub(crate) fn main() -> Result<()> {
Ok(())
}

View File

@ -1,7 +1,5 @@
use anyhow::Result;
pub(crate) fn main() -> Result<()> {
pub fn main() -> Result<()> {
Ok(())
}

View File

@ -1,4 +1,3 @@
mod floem;
mod gpui;
mod iced;
@ -18,7 +17,6 @@ enum Command {
Egui,
Druid,
Gpui,
Floem
}
fn main() -> Result<()> {
@ -30,7 +28,6 @@ fn main() -> Result<()> {
Command::Egui => egui_main(),
Command::Druid => druid_main(),
Command::Gpui => gpui::main(),
Command::Floem => floem::main(),
}
}