created studystate for functional timer to improve localisation

This commit is contained in:
reyniersbram 2023-04-18 14:58:16 +02:00
parent 86bc8d9e1a
commit 826acc1186
8 changed files with 45 additions and 22 deletions

View file

@ -4,7 +4,7 @@ class FunctionalCustomTimer(studyTime: Int) : FunctionalTimer(studyTime) {
override fun tick() {
if (time.time == 0) {
view = DONE
view = StudyState.DONE
} else {
time.minOne()
}

View file

@ -10,17 +10,17 @@ class FunctionalPomodoroTimer(
override fun tick() {
if (time.time == 0 && breaksRemaining == 0) {
view = DONE
view = StudyState.DONE
return
}
if (time.time == 0) {
if (isInBreak) {
breaksRemaining--
view = FOCUS_REMAINING(breaksRemaining)
view = StudyState.FOCUS_REMAINING
time.time = studyTime
} else {
view = BREAK
view = StudyState.BREAK
time.time = breakTime
}
isInBreak = !isInBreak

View file

@ -2,7 +2,7 @@ package be.ugent.sel.studeez.data.local.models.timer_functional
abstract class FunctionalTimer(initialValue: Int) {
val time: Time = Time(initialValue)
var view: String = FOCUS
var view: StudyState = StudyState.FOCUS
fun getHoursMinutesSeconds(): HoursMinutesSeconds {
return time.getAsHMS()
@ -12,11 +12,8 @@ abstract class FunctionalTimer(initialValue: Int) {
abstract fun hasEnded(): Boolean
companion object {
const val FOCUS: String = "Focus"
const val DONE: String = "Done!"
const val BREAK: String = "Take a break!"
val FOCUS_REMAINING: (Int) -> String = { n -> "Focus! ($n breaks remaining)" }
enum class StudyState {
FOCUS, DONE, BREAK, FOCUS_REMAINING
}
}