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.

46 lines
1.1 KiB

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