package de.trainingstagebuch.app.viewmodel

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import de.trainingstagebuch.app.utils.UiText
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update

data class LegalUiState(
    val loading: Boolean = false,
    val errorMessage: UiText? = null
)

class ImpressumViewModel(application: Application) : AndroidViewModel(application) {
    private val _state = MutableStateFlow(LegalUiState())
    val state: StateFlow<LegalUiState> = _state.asStateFlow()

    fun retry() {
        _state.update { it.copy(loading = false, errorMessage = null) }
    }
}

class DatenschutzViewModel(application: Application) : AndroidViewModel(application) {
    private val _state = MutableStateFlow(LegalUiState())
    val state: StateFlow<LegalUiState> = _state.asStateFlow()

    fun retry() {
        _state.update { it.copy(loading = false, errorMessage = null) }
    }
}
