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.

37 lines
1000 B

  1. package nova.monadic_sfx.ui
  2. import scalafx.application.JFXApp
  3. import monix.eval.Task
  4. import nova.monadic_sfx.AppTypes
  5. import scalafx.application.JFXApp.PrimaryStage
  6. import io.odin.Logger
  7. import cats.effect.Resource
  8. import com.softwaremill.macwire._
  9. import nova.monadic_sfx.http.Requesters
  10. import nova.monadic_sfx.executors.Schedulers
  11. import akka.actor.typed._
  12. trait UiModule {
  13. def fxAppResource(
  14. logger: Logger[Task],
  15. backend: AppTypes.HttpBackend,
  16. actorSystem: ActorSystem[SpawnProtocol.Command],
  17. requesters: Requesters,
  18. schedulers: Schedulers
  19. ): Resource[Task, JFXApp] =
  20. Resource.make(for {
  21. _ <- logger.info("Creating FX Application")
  22. app <- Task { wire[MyFxApp] }
  23. } yield (app))(app => logger.info("Stopping FX Application"))
  24. }
  25. object UiModule {
  26. def makePrimaryStage(
  27. backend: AppTypes.HttpBackend,
  28. actorSystem: ActorSystem[SpawnProtocol.Command]
  29. ) = {
  30. new PrimaryStage {
  31. scene = new DefaultUI().scene
  32. }
  33. }
  34. }