https://github.com/lapce/floem
- 布局系统使用 Taffy 实现 Flexbox
- 响应式设计启发自 leptos_reactive
响应性“信号”允许您以最小的努力保持UI最新,同时保持非常高的性能。
use floem::reactive::create_signal;
use floem::view::View;
use floem::views::{h_stack, label, v_stack, Decorators};
use floem::widgets::button;
fn app_view() -> impl View {
// 创建一个响应式信号,默认值为0
let (counter, set_counter) = create_signal(0);
// 创建一个垂直布局
v_stack((
// 标签控件上的计数文本将自动更新,得益于响应式信号
label(move || format!("Value: {}", counter.get())),
// 创建一个水平布局
h_stack((
button(|| "Increment").on_click_stop(move |_| {
// 按钮单击时更新计数
set_counter.update(|value| *value += 1);
}),
button(|| "Decrement").on_click_stop(move |_| {
// 按钮单击时更新计数
set_counter.update(|value| *value -= 1);
}),
)),
))
}
fn main() {
floem::launch(app_view);
}