intigrate focus system with tui
This commit is contained in:
1 parent
7a17683447
commit
35ee243d0d
5 files changed
+132
-20
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn main() {
|
||||
dioxus::tui::launch(app);
|
||||
}
|
||||
|
||||
fn Button(cx: Scope) -> Element {
|
||||
let state = use_state(&cx, || false);
|
||||
let color = if *state.get() { "red" } else { "blue" };
|
||||
let text = if *state.get() { "☐" } else { "☒" };
|
||||
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
border_width: "1px",
|
||||
width: "50%",
|
||||
height: "100%",
|
||||
background_color: "{color}",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
onkeydown: |_| state.modify(|s| !s),
|
||||
|
||||
"{text}"
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
flex_direction: "column",
|
||||
|
||||
div {
|
||||
width: "100%",
|
||||
height: "50%",
|
||||
flex_direction: "row",
|
||||
|
||||
Button{},
|
||||
Button{},
|
||||
Button{},
|
||||
Button{},
|
||||
}
|
||||
|
||||
div {
|
||||
width: "100%",
|
||||
height: "50%",
|
||||
flex_direction: "row",
|
||||
|
||||
Button{},
|
||||
Button{},
|
||||
Button{},
|
||||
Button{},
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user