emojis in sessionrecap
This commit is contained in:
parent
d5fbb2adab
commit
d9f4170fbd
7 changed files with 122 additions and 3 deletions
|
|
@ -2,7 +2,6 @@ package be.ugent.sel.studeez.common.composable
|
|||
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.updateTransition
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.FloatingActionButton
|
||||
import androidx.compose.material.Icon
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
package be.ugent.sel.studeez.common.composable
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun ImageBackgroundButton(
|
||||
paint: Painter,
|
||||
str: String,
|
||||
background2: Color,
|
||||
setBackground1: (Color) -> Unit,
|
||||
setBackground2: (Color) -> Unit
|
||||
) {
|
||||
Image(
|
||||
painter = paint,
|
||||
str,
|
||||
modifier = Modifier
|
||||
.clickable {
|
||||
if (background2 == Color.Transparent) {
|
||||
setBackground1(Color.LightGray)
|
||||
setBackground2(Color.Transparent)
|
||||
} else {
|
||||
setBackground2(Color.Transparent)
|
||||
}
|
||||
}
|
||||
.border(
|
||||
width = 2.dp,
|
||||
color = background2,
|
||||
shape = RoundedCornerShape(16.dp)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
@ -1,13 +1,30 @@
|
|||
package be.ugent.sel.studeez.screens.session_recap
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.ButtonDefaults
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
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 androidx.hilt.navigation.compose.hiltViewModel
|
||||
import be.ugent.sel.studeez.R
|
||||
import be.ugent.sel.studeez.common.composable.BasicButton
|
||||
import be.ugent.sel.studeez.common.composable.ImageBackgroundButton
|
||||
import be.ugent.sel.studeez.common.ext.basicButton
|
||||
import be.ugent.sel.studeez.data.local.models.SessionReport
|
||||
import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds
|
||||
|
|
@ -47,10 +64,49 @@ fun SessionRecapScreen(modifier: Modifier, sessionRecapActions: SessionRecapActi
|
|||
val sessionReport: SessionReport = sessionRecapActions.getSessionReport()
|
||||
val studyTime: Int = sessionReport.studyTime
|
||||
val hms: HoursMinutesSeconds = Time(studyTime).getAsHMS()
|
||||
val (background1, setBackground1) = remember { mutableStateOf(Color.Transparent) }
|
||||
val (background2, setBackground2) = remember { mutableStateOf(Color.Transparent) }
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.fillMaxHeight()
|
||||
.padding(16.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Text(text = "You studied: $hms")
|
||||
Text(
|
||||
text = stringResource(R.string.congrats) + hms,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
textAlign = TextAlign.Center,
|
||||
fontWeight = FontWeight.Light,
|
||||
fontSize = 30.sp
|
||||
)
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.how_did_it_go),
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
textAlign = TextAlign.Center,
|
||||
fontWeight = FontWeight.Light,
|
||||
fontSize = 30.sp
|
||||
)
|
||||
|
||||
Row {
|
||||
ImageBackgroundButton(
|
||||
paint = painterResource(id = R.drawable.mood_1),
|
||||
str = stringResource(id = R.string.good),
|
||||
background2 = background2,
|
||||
setBackground1 = setBackground2,
|
||||
setBackground2 = setBackground1
|
||||
)
|
||||
|
||||
ImageBackgroundButton(
|
||||
paint = painterResource(id = R.drawable.mood_2),
|
||||
str = stringResource(id = R.string.bad),
|
||||
background2 = background1,
|
||||
setBackground1 = setBackground1,
|
||||
setBackground2 = setBackground2
|
||||
)
|
||||
}
|
||||
|
||||
BasicButton(
|
||||
R.string.save, Modifier.basicButton()
|
||||
|
|
@ -65,3 +121,12 @@ fun SessionRecapScreen(modifier: Modifier, sessionRecapActions: SessionRecapActi
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun SessionRecapScreenPreview() {
|
||||
SessionRecapScreen(
|
||||
modifier = Modifier,
|
||||
sessionRecapActions = SessionRecapActions(hiltViewModel(), {}, {})
|
||||
)
|
||||
}
|
||||
Reference in a new issue