Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 1.02 KB

File metadata and controls

38 lines (28 loc) · 1.02 KB

Usage

Overview

  • Component package: app.theme.provide
  • DI integration: app.theme.ThemeConfig

The current theme state is managed by an instance of shared.presentation.theme.ThemeState. This class provides a currentState property representing the currently selected theme configuration.

The feature utilizes app.theme.provide.presentation.ThemeProvider to control the value of this property:

  • Persist its state whenever it changes.
  • Restore the last state when the app is reopened.

The logic is handled by app.theme.provide.presentation.ThemeStatefulViewModel.

Thus, whenever you update the current active application theme, it is automatically saved across app restarts.

class ToggleThemeViewModel(
    private val themeState: ThemeState
) : BaseViewModel() {

    fun onSetLightTheme() {
        themeState.setLight()
    }

    fun onSetDarkTheme() {
        themeState.setDark()
    }

    fun onSetCustomTheme() {
        themeState.currentConfig = ThemeConfig(
            ...
        )
    }
    ...
}