commit
666502e19f
3 changed files with 62 additions and 6 deletions
|
@ -2,7 +2,8 @@ package be.ugent.sel.studeez.data.local.models.timer_functional
|
|||
|
||||
class FunctionalPomodoroTimer(
|
||||
private var studyTime: Int,
|
||||
private var breakTime: Int, repeats: Int
|
||||
private var breakTime: Int,
|
||||
val repeats: Int
|
||||
) : FunctionalTimer(studyTime) {
|
||||
|
||||
var breaksRemaining = repeats
|
||||
|
|
|
@ -100,6 +100,8 @@ abstract class AbstractSessionScreen {
|
|||
fontSize = 30.sp
|
||||
)
|
||||
|
||||
MidSection()
|
||||
|
||||
Box(
|
||||
contentAlignment = Alignment.Center, modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
@ -126,6 +128,11 @@ abstract class AbstractSessionScreen {
|
|||
@Composable
|
||||
abstract fun motivationString(): String
|
||||
|
||||
@Composable
|
||||
open fun MidSection() {
|
||||
// Default has no midsection, unless overwritten.
|
||||
}
|
||||
|
||||
abstract fun callMediaPlayer()
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,20 @@
|
|||
package be.ugent.sel.studeez.screens.session.sessionScreens
|
||||
|
||||
import android.media.MediaPlayer
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import be.ugent.sel.studeez.R
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalPomodoroTimer
|
||||
import be.ugent.sel.studeez.resources
|
||||
|
@ -12,6 +25,37 @@ class BreakSessionScreen(
|
|||
private var mediaplayer: MediaPlayer?
|
||||
): AbstractSessionScreen() {
|
||||
|
||||
@Composable
|
||||
override fun MidSection() {
|
||||
Dots()
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Dots() {
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.Center,
|
||||
) {
|
||||
repeat(funPomoDoroTimer.repeats - funPomoDoroTimer.breaksRemaining) {
|
||||
Dot(color = Color.DarkGray)
|
||||
}
|
||||
if (!funPomoDoroTimer.isInBreak) Dot(Color.Green) else Dot(Color.DarkGray)
|
||||
repeat(funPomoDoroTimer.breaksRemaining - 1) {
|
||||
Dot(color = Color.Gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Dot(color: Color) {
|
||||
Box(modifier = Modifier
|
||||
.padding(5.dp)
|
||||
.size(10.dp)
|
||||
.clip(CircleShape)
|
||||
.background(color))
|
||||
}
|
||||
|
||||
@Composable
|
||||
override fun motivationString(): String {
|
||||
if (funPomoDoroTimer.isInBreak) {
|
||||
|
@ -22,11 +66,7 @@ class BreakSessionScreen(
|
|||
return resources().getString(AppText.state_done)
|
||||
}
|
||||
|
||||
return resources().getQuantityString(
|
||||
R.plurals.state_focus_remaining,
|
||||
funPomoDoroTimer.breaksRemaining,
|
||||
funPomoDoroTimer.breaksRemaining
|
||||
)
|
||||
return resources().getString(AppText.state_focus)
|
||||
}
|
||||
|
||||
override fun callMediaPlayer() {
|
||||
|
@ -42,4 +82,12 @@ class BreakSessionScreen(
|
|||
mediaplayer?.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun MidsectionPreview() {
|
||||
val funPomoDoroTimer = FunctionalPomodoroTimer(15, 60, 5)
|
||||
val breakSessionScreen = BreakSessionScreen(funPomoDoroTimer, MediaPlayer())
|
||||
breakSessionScreen.MidSection()
|
||||
}
|
Reference in a new issue