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
967 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. trait UiModule {
  12. def fxAppResource(
  13. logger: Logger[Task],
  14. backend: AppTypes.HttpBackend,
  15. actorSystem: akka.actor.ActorSystem,
  16. requesters: Requesters,
  17. schedulers: Schedulers
  18. ): Resource[Task, JFXApp] =
  19. Resource.make(logger.info("Creating FX Application") >> Task {
  20. val app: JFXApp = wire[MyFxApp]
  21. app
  22. })(app => logger.info("Stopping FX Application") >> Task(app.stopApp()))
  23. }
  24. object UiModule {
  25. def makePrimaryStage(
  26. backend: AppTypes.HttpBackend,
  27. actorSystem: akka.actor.ActorSystem
  28. ) = {
  29. new PrimaryStage {
  30. scene = new DefaultUI().scene
  31. }
  32. }
  33. }