From b35ec3145037ef8893a8dcf47b3a7d16dcf55306 Mon Sep 17 00:00:00 2001 From: luigi-borriello00 Date: Wed, 6 Sep 2023 21:21:02 +0200 Subject: [PATCH] refactor(aboutPage): move page switch in the controller --- .../scala/scatan/controllers/home/AboutController.scala | 8 +++++--- src/main/scala/scatan/views/home/AboutView.scala | 4 ++-- src/main/scala/scatan/views/home/HomeView.scala | 2 +- src/main/scala/scatan/views/setup/SetUpView.scala | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/scala/scatan/controllers/home/AboutController.scala b/src/main/scala/scatan/controllers/home/AboutController.scala index ec63e295..588980c9 100644 --- a/src/main/scala/scatan/controllers/home/AboutController.scala +++ b/src/main/scala/scatan/controllers/home/AboutController.scala @@ -2,12 +2,14 @@ package scatan.controllers.home import scatan.mvc.lib.Controller import scatan.model.ApplicationState import scatan.views.home.AboutView +import scatan.mvc.lib.NavigableApplicationManager +import scatan.Pages trait AboutController extends Controller: - def about(): Unit + def goToHome(): Unit class AboutControllerImpl(requirements: Controller.Requirements[AboutView, ApplicationState]) extends AboutController with Controller.Dependencies(requirements): - override def about(): Unit = - println("About") + override def goToHome(): Unit = + NavigableApplicationManager.navigateTo(Pages.Home) diff --git a/src/main/scala/scatan/views/home/AboutView.scala b/src/main/scala/scatan/views/home/AboutView.scala index 5b457fc6..a0dba97d 100644 --- a/src/main/scala/scatan/views/home/AboutView.scala +++ b/src/main/scala/scatan/views/home/AboutView.scala @@ -1,7 +1,7 @@ package scatan.views.home import com.raquo.laminar.api.L.* -import scatan.mvc.lib.{NavigableApplicationManager, ScalaJSView, View} +import scatan.mvc.lib.{ScalaJSView, View} import scatan.controllers.home.AboutController trait AboutView extends View @@ -16,6 +16,6 @@ class ScalaJSAboutView(requirements: View.Requirements[AboutController], contain p("This is a ScalaJS view"), button( "Back", - onClick --> (_ => NavigableApplicationManager.navigateBack()) + onClick --> (_ => controller.goToHome()) ) ) diff --git a/src/main/scala/scatan/views/home/HomeView.scala b/src/main/scala/scatan/views/home/HomeView.scala index a7b0142e..78498aea 100644 --- a/src/main/scala/scatan/views/home/HomeView.scala +++ b/src/main/scala/scatan/views/home/HomeView.scala @@ -5,7 +5,7 @@ import scatan.controllers.home.HomeController import com.raquo.laminar.api.L.* import scatan.Pages -import scatan.mvc.lib.{NavigableApplicationManager, ScalaJSView, View} +import scatan.mvc.lib.{ScalaJSView, View} /** This is the view for the home page. */ diff --git a/src/main/scala/scatan/views/setup/SetUpView.scala b/src/main/scala/scatan/views/setup/SetUpView.scala index ea7e9753..33dd6d57 100644 --- a/src/main/scala/scatan/views/setup/SetUpView.scala +++ b/src/main/scala/scatan/views/setup/SetUpView.scala @@ -6,7 +6,7 @@ import scatan.Pages import scatan.mvc.lib.View import scatan.controllers.setup.SetUpController import com.raquo.laminar.api.L.* -import scatan.mvc.lib.{NavigableApplicationManager, ScalaJSView, View} +import scatan.mvc.lib.{ScalaJSView, View} import scatan.Pages /** This is the view for the setup page.