-
Notifications
You must be signed in to change notification settings - Fork 1
ThemeSwitcherController
Natalie L edited this page Dec 5, 2024
·
1 revision
The ThemeSwitcherController class is part of the controllers package
(package org.example.globalgoodsindex.controllers).
It is responsible for handling theme switching in the UI. The controller interacts with the ThemeManager to apply
the
selected theme and store the user's theme preferences. It provides a menu for selecting between different themes (light,
dark, nord)
using RadioMenuItems.
Initializes the theme switcher by setting up the UI components, applying the saved theme, and handling user selection.
- Binds the theme menu to a ToggleGroup and sets up the RadioMenuItem options for different themes.
- Adds a listener to the ToggleGroup to change the theme when the user selects a different option.
Sets the ToggleGroup for the theme menu items.
- Associates each
RadioMenuItemwith the sameToggleGroupto ensure that only one option can be selected at a time.
Selects the appropriate menu item based on the saved theme.
- Checks the saved theme and selects the corresponding
RadioMenuItem(e.g.,lightThemeMenuItemfor " PrimerLight").
Binds the text property of the theme switcher menu to a language resource.
- Uses
L10N.createStringBinding()to bind the text of the theme switcher to a language string, enabling internationalization.