SettingsViewModel

class SettingsViewModel(val scope: CoroutineScope, val appState: AppStateImpl, val globalError: ReversiException? = null, val setTheme: (AppTheme) -> Unit, val setPlayerName: suspend (String?) -> Unit, val saveGame: suspend () -> Unit, val setGame: (Game) -> Unit, val setGlobalError: (Exception?, ErrorType?) -> Unit) : ViewModel<SettingsUiState>

ViewModel for the settings page screen. Manages settings changes, audio volume, theme selection, and persistence.

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope, appState: AppStateImpl, globalError: ReversiException? = null, setTheme: (AppTheme) -> Unit, setPlayerName: suspend (String?) -> Unit, saveGame: suspend () -> Unit, setGame: (Game) -> Unit, setGlobalError: (Exception?, ErrorType?) -> Unit)

Properties

Link copied to clipboard
protected open override val _uiState: MutableState<SettingsUiState>

The mutable internal UI state.

Link copied to clipboard
private val appState: AppStateImpl

The global application state.

Link copied to clipboard
open override val globalError: ReversiException?

Optional global error to display on initial load.

Link copied to clipboard
private val saveGame: suspend () -> Unit
Link copied to clipboard
private val scope: CoroutineScope

Coroutine scope for background operations.

Link copied to clipboard
private val setGame: (Game) -> Unit
Link copied to clipboard
open override val setGlobalError: (Exception?, ErrorType?) -> Unit

Callback function to update global error state.

Link copied to clipboard
private val setPlayerName: suspend (String?) -> Unit

Callback function to update the player name.

Link copied to clipboard
private val setTheme: (AppTheme) -> Unit

Callback function to update the theme.

Functions

Link copied to clipboard
fun applySettings(oldTheme: AppTheme, newName: String?, newTheme: AppTheme, draftCoreConfig: CoreConfig, volume: Float, endAction: () -> Unit)
Link copied to clipboard
private fun parseVolume(volume: Float, current: AudioPool)
Link copied to clipboard
fun setCurrentVol(volume: Float)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard