Floem basic example
This commit is contained in:
parent
04f4af5f79
commit
5fd5300bd2
10
justfile
Normal file
10
justfile
Normal 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
20
src/bin/floem.rs
Normal 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),
|
||||
)
|
||||
)
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
use anyhow::Result;
|
||||
|
||||
|
||||
pub(crate) fn main() -> Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
pub(crate) fn main() -> Result<()> {
|
||||
|
||||
pub fn main() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user