task.rs 731 B

12345678910111213141516171819202122232425262728
  1. use dioxus::prelude::*;
  2. fn main() {
  3. dioxus_tui::launch(app);
  4. }
  5. fn app() -> Element {
  6. let mut count = use_signal(|| 0);
  7. use_future(move || async move {
  8. loop {
  9. count += 1;
  10. tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
  11. schedule_update();
  12. }
  13. });
  14. rsx! {
  15. div { width: "100%",
  16. div { width: "50%", height: "5px", background_color: "blue", justify_content: "center", align_items: "center",
  17. "Hello {count}!"
  18. }
  19. div { width: "50%", height: "10px", background_color: "red", justify_content: "center", align_items: "center",
  20. "Hello {count}!"
  21. }
  22. }
  23. }
  24. }