You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.1 KiB

  1. package nova.monadic_sfx.screens
  2. import akka.actor.typed._
  3. import monix.eval.Task
  4. import nova.monadic_sfx.AppTypes
  5. import nova.monadic_sfx.implicits._
  6. import scalafx.scene.Parent
  7. import scalafx.scene.control._
  8. import scalafx.scene.layout.HBox
  9. import scalafx.scene.text.Text
  10. class HomeScreen(
  11. backend: AppTypes.HttpBackend,
  12. system: ActorSystem[SpawnProtocol.Command],
  13. onLogout: () => Task[Unit]
  14. ) {
  15. val myButton = new Button {
  16. id = "LogoutButton"
  17. text = "logout"
  18. // onAction = () => Action.asyncT(onLogout())
  19. }
  20. val myObs = myButton.observableAction()
  21. // myObs.foreachL(_ => ())
  22. private lazy val root = Task.deferAction { implicit s =>
  23. Task {
  24. new HBox {
  25. children = List(
  26. new Text {
  27. text = "hello"
  28. },
  29. myButton
  30. )
  31. }
  32. }
  33. }
  34. def render = root
  35. }
  36. object HomeScreen {
  37. def apply(
  38. backend: AppTypes.HttpBackend,
  39. system: ActorSystem[SpawnProtocol.Command],
  40. onLogout: () => Task[Unit]
  41. ): Task[Parent] =
  42. new HomeScreen(backend, system, onLogout).render
  43. }