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.

45 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. class HomeScreen(
  15. backend: AppTypes.HttpBackend,
  16. system: akka.actor.ActorSystem,
  17. onLogout: () => Task[Unit]
  18. ) {
  19. private lazy val root = Task.deferAction { implicit s =>
  20. Task {
  21. new HBox {
  22. children = List(
  23. new Text {
  24. text = "hello"
  25. },
  26. new Button {
  27. text = "logout"
  28. onAction = () => Action.asyncT(onLogout())
  29. }
  30. )
  31. }
  32. }
  33. }
  34. def render = root
  35. }
  36. object HomeScreen {
  37. def apply(
  38. backend: AppTypes.HttpBackend,
  39. system: akka.actor.ActorSystem,
  40. onLogout: () => Task[Unit]
  41. ): Task[Parent] =
  42. new HomeScreen(backend, system, onLogout).render
  43. }