1
0

tui_components.rs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. fn main() {
  4. dioxus::tui::launch(app);
  5. }
  6. #[derive(Props, PartialEq)]
  7. struct QuadrentProps {
  8. color: String,
  9. text: String,
  10. }
  11. fn Quadrant(cx: Scope<QuadrentProps>) -> Element {
  12. cx.render(rsx! {
  13. div {
  14. border_width: "1px",
  15. width: "50%",
  16. height: "100%",
  17. background_color: "{cx.props.color}",
  18. justify_content: "center",
  19. align_items: "center",
  20. "{cx.props.text}"
  21. }
  22. })
  23. }
  24. fn app(cx: Scope) -> Element {
  25. cx.render(rsx! {
  26. div {
  27. width: "100%",
  28. height: "100%",
  29. flex_direction: "column",
  30. div {
  31. width: "100%",
  32. height: "50%",
  33. flex_direction: "row",
  34. Quadrant{
  35. color: "red".to_string(),
  36. text: "[A]".to_string()
  37. },
  38. Quadrant{
  39. color: "black".to_string(),
  40. text: "[B]".to_string()
  41. }
  42. }
  43. div {
  44. width: "100%",
  45. height: "50%",
  46. flex_direction: "row",
  47. Quadrant{
  48. color: "green".to_string(),
  49. text: "[C]".to_string()
  50. },
  51. Quadrant{
  52. color: "blue".to_string(),
  53. text: "[D]".to_string()
  54. }
  55. }
  56. }
  57. })
  58. }