Skip to content

Commit

Permalink
wip(setUpView): implement setUpView
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-borriello00 authored and manuandru committed Sep 6, 2023
1 parent 734afc4 commit 3c1d73d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/scala/scatan/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package scatan
import com.raquo.laminar.api.L.{*, given}
import scatan.example.controller.{AboutController, AboutControllerImpl}
import scatan.controllers.home.{HomeController, HomeControllerImpl}
import scatan.controllers.setup.{SetUpController, SetUpControllerImpl}
import scatan.views.setup.{SetUpView, ScalaJsSetUpView}
import scatan.views.home.{HomeView, ScalaJsHomeView}
import scatan.example.model.CounterAppState
import scatan.example.view.{AboutView, ScalaJSAboutView}
Expand All @@ -20,6 +22,13 @@ enum Pages(val pageFactory: PageFactory[?, ?, CounterAppState]):
controllerFactory = new HomeControllerImpl(_)
)
)
case Setup
extends Pages(
PageFactory[SetUpController, SetUpView, CounterAppState](
viewFactory = new ScalaJsSetUpView(_, "root"),
controllerFactory = new SetUpControllerImpl(_)
)
)
case About
extends Pages(
PageFactory[AboutController, AboutView, CounterAppState](
Expand Down
5 changes: 5 additions & 0 deletions src/main/scala/scatan/controllers/setup/SetUpController.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package scatan.controllers.setup

import scatan.mvc.lib.Controller
import scatan.views.setup.SetUpView
import scatan.mvc.lib.Model
import scatan.example.model.CounterAppState

trait SetUpController extends Controller

class SetUpControllerImpl(dependencies: Controller.Requirements[SetUpView, CounterAppState]) extends SetUpController
2 changes: 1 addition & 1 deletion src/main/scala/scatan/views/home/ScalaJsHomeView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ScalaJsHomeView(requirements: View.Requirements[HomeController], container
cls := "home-menu",
button(
cls := "home-menu-button",
onClick.mapTo(Pages.Home) --> NavigableApplicationManager.navigateTo,
onClick.mapTo(Pages.Setup) --> NavigableApplicationManager.navigateTo,
"Play"
),
button(
Expand Down
39 changes: 39 additions & 0 deletions src/main/scala/scatan/views/setup/ScalaJsSetUpView.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package scatan.views.setup

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.Pages

class ScalaJsSetUpView(requirements: View.Requirements[SetUpController], container: String)
extends SetUpView
with View.Dependencies(requirements)
with ScalaJSView(container):

def start(): Unit =
print("Hello, world!")

override def element: Element =
// menu with 4 textbox for the players username and 4 dropdown for the players color and a button to start
div(
cls := "setup-view",
// Title
div(
cls := "setup-title"
),
// Menu view with 3 buttons, play, settings and about, dispose them vertically
div(
cls := "setup-menu",
button(
cls := "setup-menu-button",
onClick.mapTo(Pages.Home) --> NavigableApplicationManager.navigateTo,
"Play"
),
button(
cls := "setup-menu-button",
onClick.mapTo(Pages.About) --> NavigableApplicationManager.navigateTo,
"About"
)
)
)
9 changes: 9 additions & 0 deletions src/main/scala/scatan/views/setup/SetUpView.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package scatan.views.setup

import scatan.controllers.setup.SetUpController

import scatan.Pages
import scatan.mvc.lib.View

trait SetUpView extends View:
def start(): Unit

0 comments on commit 3c1d73d

Please sign in to comment.