Timer geeft nu correcte UI + timer kan manueel gestopt worden
This commit is contained in:
parent
7c0e15cb9d
commit
2071b31f72
2 changed files with 102 additions and 13 deletions
|
@ -1,19 +1,23 @@
|
||||||
package be.ugent.sel.studeez.screens.session
|
package be.ugent.sel.studeez.screens.session
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.border
|
||||||
|
import androidx.compose.foundation.layout.*
|
||||||
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
|
import androidx.compose.material.TextButton
|
||||||
import androidx.compose.runtime.*
|
import androidx.compose.runtime.*
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.TextUnit
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.hilt.navigation.compose.hiltViewModel
|
import androidx.hilt.navigation.compose.hiltViewModel
|
||||||
import be.ugent.sel.studeez.R
|
import be.ugent.sel.studeez.domain.implementation.LogServiceImpl
|
||||||
import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate
|
import be.ugent.sel.studeez.navigation.StudeezDestinations
|
||||||
import be.ugent.sel.studeez.resources
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -22,12 +26,33 @@ fun SessionScreen(
|
||||||
openAndPopUp: (String, String) -> Unit,
|
openAndPopUp: (String, String) -> Unit,
|
||||||
viewModel: SessionViewModel = hiltViewModel()
|
viewModel: SessionViewModel = hiltViewModel()
|
||||||
) {
|
) {
|
||||||
PrimaryScreenTemplate(
|
Column(
|
||||||
title = resources().getString(R.string.start_session),
|
modifier = Modifier.padding(10.dp)
|
||||||
open = open,
|
) {
|
||||||
openAndPopUp = openAndPopUp
|
|
||||||
) {
|
|
||||||
Timer(viewModel)
|
Timer(viewModel)
|
||||||
|
|
||||||
|
Box(
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(50.dp)
|
||||||
|
) {
|
||||||
|
TextButton(
|
||||||
|
onClick = { open(StudeezDestinations.HOME_SCREEN) },
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 20.dp)
|
||||||
|
.border(1.dp, Color.Red, RoundedCornerShape(32.dp))
|
||||||
|
.background(Color.Transparent)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "End session",
|
||||||
|
color = Color.Red,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
modifier = Modifier.padding(1.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +69,12 @@ private fun Timer(viewModel: SessionViewModel = hiltViewModel()) {
|
||||||
Column {
|
Column {
|
||||||
Text(
|
Text(
|
||||||
text = "${hms.hours} : ${hms.minutes} : ${hms.seconds}",
|
text = "${hms.hours} : ${hms.minutes} : ${hms.seconds}",
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(50.dp),
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
fontSize = 80.sp
|
fontSize = 40.sp,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = viewModel.getTimer().getViewString(),
|
text = viewModel.getTimer().getViewString(),
|
||||||
|
@ -56,5 +83,62 @@ private fun Timer(viewModel: SessionViewModel = hiltViewModel()) {
|
||||||
fontWeight = FontWeight.Light,
|
fontWeight = FontWeight.Light,
|
||||||
fontSize = 30.sp
|
fontSize = 30.sp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Box(
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(50.dp)
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(16.dp)
|
||||||
|
.background(Color.Blue, RoundedCornerShape(32.dp))
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = viewModel.getTask(),
|
||||||
|
color = Color.White,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(vertical = 4.dp, horizontal = 20.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
fun Screen() {
|
||||||
|
val viewModel = SessionViewModel(LogServiceImpl())
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(10.dp)
|
||||||
|
) {
|
||||||
|
Timer(viewModel)
|
||||||
|
|
||||||
|
Box(
|
||||||
|
contentAlignment = Alignment.Center,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(50.dp)
|
||||||
|
) {
|
||||||
|
TextButton(
|
||||||
|
onClick = {},
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(vertical = 1.dp, horizontal = 20.dp)
|
||||||
|
.border(1.dp, Color.Red, RoundedCornerShape(32.dp))
|
||||||
|
.background(Color.Transparent)
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "End session",
|
||||||
|
color = Color.Red,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 18.sp,
|
||||||
|
modifier = Modifier.padding(1.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,8 +13,13 @@ class SessionViewModel @Inject constructor(
|
||||||
) : StudeezViewModel(logService) {
|
) : StudeezViewModel(logService) {
|
||||||
|
|
||||||
private val timer: FunctionalTimer = FunctionalPomodoroTimer(15, 5, 3)
|
private val timer: FunctionalTimer = FunctionalPomodoroTimer(15, 5, 3)
|
||||||
|
private val task : String = "No task selected" // placeholder for tasks implementation
|
||||||
|
|
||||||
fun getTimer() : FunctionalTimer {
|
fun getTimer() : FunctionalTimer {
|
||||||
return timer
|
return timer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getTask(): String {
|
||||||
|
return task
|
||||||
|
}
|
||||||
}
|
}
|
Reference in a new issue