Package edu.ntnu.idi.idatt.navigation
Class ViewNavigator
java.lang.Object
edu.ntnu.idi.idatt.navigation.ViewNavigator
- All Implemented Interfaces:
ButtonClickObserver
ViewNavigator.
Handles navigation between different views/screens within the application.
It acts as a central point for view switching, responding to button clicks (as a
ButtonClickObserver
) or direct calls to navigate to specific ViewType
s. It
creates the necessary views and their controllers, setting up dependencies and event handlers
(like onStartGame
, onQuitGame
) to link them together.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
navigateTo
(ViewType viewType) Navigates to the specifiedViewType
without any parameters.void
navigateTo
(ViewType viewType, Map<String, Object> params) Navigates to the specifiedViewType
, creating and displaying the corresponding view in theappView
.void
onButtonClicked
(String buttonId) Handles button click events without parameters.void
onButtonClickedWithParams
(String buttonId, Map<String, Object> params) Handles button click events with parameters.
-
Constructor Details
-
ViewNavigator
Constructs a ViewNavigator.- Parameters:
appView
- The mainAppView
container where different views will be displayed.
-
-
Method Details
-
onButtonClicked
Handles button click events without parameters. Attempts to navigate to aViewType
matching the button ID.- Specified by:
onButtonClicked
in interfaceButtonClickObserver
- Parameters:
buttonId
- The ID of the button, expected to match aViewType
enum name.
-
onButtonClickedWithParams
Handles button click events with parameters. Attempts to navigate to aViewType
matching the button ID, passing along the parameters.- Specified by:
onButtonClickedWithParams
in interfaceButtonClickObserver
- Parameters:
buttonId
- The ID of the button, expected to match aViewType
enum name.params
- A map of parameters to be passed to the new view/controller.
-