created studystate for functional timer to improve localisation
This commit is contained in:
parent
86bc8d9e1a
commit
826acc1186
8 changed files with 45 additions and 22 deletions
|
@ -3,15 +3,21 @@ package be.ugent.sel.studeez.screens.session
|
|||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import be.ugent.sel.studeez.R
|
||||
import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate
|
||||
import be.ugent.sel.studeez.common.composable.SecondaryScreenTemplate
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalTimer.StudyState
|
||||
import be.ugent.sel.studeez.resources
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
@ -44,12 +50,24 @@ fun Timer(viewModel: SessionViewModel = hiltViewModel()) {
|
|||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 80.sp
|
||||
)
|
||||
val stateString: String = when (viewModel.getTimer().view) {
|
||||
StudyState.DONE -> resources().getString(R.string.state_done)
|
||||
StudyState.FOCUS -> resources().getString(R.string.state_focus)
|
||||
StudyState.BREAK -> resources().getString(R.string.state_take_a_break)
|
||||
StudyState.FOCUS_REMAINING ->
|
||||
(viewModel.getTimer() as FunctionalPomodoroTimer?)?.breaksRemaining?.let {
|
||||
resources().getQuantityString(R.plurals.state_focus_remaining, it, it)
|
||||
}.toString()
|
||||
}
|
||||
|
||||
Text(
|
||||
text = viewModel.getTimer().view,
|
||||
text = stateString,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
textAlign = TextAlign.Center,
|
||||
fontWeight = FontWeight.Light,
|
||||
fontSize = 30.sp
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in a new issue