Skip to content

Commit

Permalink
refactor(aboutPage): move page switch in the controller
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-borriello00 committed Sep 6, 2023
1 parent ddf5dfb commit b35ec31
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/main/scala/scatan/controllers/home/AboutController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions src/main/scala/scatan/views/home/AboutView.scala
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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())
)
)
2 changes: 1 addition & 1 deletion src/main/scala/scatan/views/home/HomeView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scatan/views/setup/SetUpView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b35ec31

Please sign in to comment.