Skip to content

Commit

Permalink
docs(home-setup): add docs in Views and controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-borriello00 committed Sep 6, 2023
1 parent 0092a30 commit c467090
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/main/scala/scatan/controllers/home/HomeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,21 @@ import scatan.Pages
import scatan.mvc.lib.application.NavigableApplication
import scatan.mvc.lib.NavigableApplicationManager

/** This is the controller for the home page.
*/
trait HomeController extends Controller:
/** This method is called when the user clicks on the settings button.
*/
def goToSetup(): Unit

/** This method is called when the user clicks on the about button.
*/
def goToAbout(): Unit

/** This is the implementation of the controller for the home page.
* @param requirements,
* the requirements for the controller.
*/
class HomeControllerImpl(requirements: Controller.Requirements[HomeView, ?]) extends HomeController:
override def goToSetup(): Unit =
NavigableApplicationManager.navigateTo[Pages](Pages.Setup)
Expand Down
11 changes: 11 additions & 0 deletions src/main/scala/scatan/controllers/setup/SetUpController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,21 @@ import scatan.views.setup.SetUpView
import scatan.mvc.lib.NavigableApplicationManager
import scatan.Pages

/** This is the controller for the setup page.
*/
trait SetUpController extends Controller:
/** This method is called when the user clicks on the back button.
*/
def goToHome(): Unit

/** This method is called when the user clicks on the start button.
*/
def goToPlay(): Unit

/** This is the implementation of the controller for the setup page.
* @param dependencies,
* the dependencies for the controller.
*/
class SetUpControllerImpl(dependencies: Controller.Requirements[SetUpView, ?]) extends SetUpController:
override def goToHome(): Unit = NavigableApplicationManager.navigateTo(Pages.Home)
// TODO: implement goToPlay
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/scatan/views/home/HomeView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ package scatan.views.home

import scatan.mvc.lib.View

/** This is the view for the home page.
*/
trait HomeView extends View:
def start(): Unit
7 changes: 7 additions & 0 deletions src/main/scala/scatan/views/home/ScalaJsHomeView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import scatan.Pages

import scatan.mvc.lib.{NavigableApplicationManager, ScalaJSView, View}

/** This is the view for the home page.
*
* @param requirements,
* the requirements for the view
* @param container,
* the container for the view
*/
class ScalaJsHomeView(requirements: View.Requirements[HomeController], container: String)
extends HomeView
with View.Dependencies(requirements)
Expand Down
11 changes: 7 additions & 4 deletions src/main/scala/scatan/views/setup/ScalaJsSetUpView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import com.raquo.laminar.api.L.*
import scatan.mvc.lib.{NavigableApplicationManager, ScalaJSView, View}
import scatan.Pages

/** This is the view for the setup page.
*
* @param requirements,
* the requirements for the view
* @param container,
* the container for the view
*/
class ScalaJsSetUpView(requirements: View.Requirements[SetUpController], container: String)
extends SetUpView
with View.Dependencies(requirements)
Expand All @@ -16,17 +23,13 @@ class ScalaJsSetUpView(requirements: View.Requirements[SetUpController], contain
print("Hello, world!")

override def element: Element =
/*
in this div, there are 4 textbox, one for each user name, and one button to start the game
*/
div(
cls := "setup-view",
// Title
div(
cls := "setup-title",
"Setup your game"
),
// Menu view with 3 buttons, play, settings and about, dispose them vertically
div(
cls := "setup-menu",
for i <- 1 to numberOfUsers
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/scatan/views/setup/SetUpView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ import scatan.controllers.setup.SetUpController
import scatan.Pages
import scatan.mvc.lib.View

/** This is the view for the setup page.
*/
trait SetUpView extends View:
def start(): Unit

0 comments on commit c467090

Please sign in to comment.