Class ViewNavigator

java.lang.Object
edu.ntnu.idi.idatt.navigation.ViewNavigator
All Implemented Interfaces:
ButtonClickObserver

public class ViewNavigator extends Object implements 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 ViewTypes. It creates the necessary views and their controllers, setting up dependencies and event handlers (like onStartGame, onQuitGame) to link them together.

See Also:
  • Constructor Details

    • ViewNavigator

      public ViewNavigator(AppView appView)
      Constructs a ViewNavigator.
      Parameters:
      appView - The main AppView container where different views will be displayed.
  • Method Details

    • onButtonClicked

      public void onButtonClicked(String buttonId)
      Handles button click events without parameters. Attempts to navigate to a ViewType matching the button ID.
      Specified by:
      onButtonClicked in interface ButtonClickObserver
      Parameters:
      buttonId - The ID of the button, expected to match a ViewType enum name.
    • onButtonClickedWithParams

      public void onButtonClickedWithParams(String buttonId, Map<String,Object> params)
      Handles button click events with parameters. Attempts to navigate to a ViewType matching the button ID, passing along the parameters.
      Specified by:
      onButtonClickedWithParams in interface ButtonClickObserver
      Parameters:
      buttonId - The ID of the button, expected to match a ViewType enum name.
      params - A map of parameters to be passed to the new view/controller.