#22 style task entry
This commit is contained in:
		
							parent
							
								
									ffb67cd1b2
								
							
						
					
					
						commit
						b7a74a13d7
					
				
					 6 changed files with 143 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -1,4 +1,4 @@
 | 
			
		|||
package be.ugent.sel.studeez.common.composable
 | 
			
		||||
package be.ugent.sel.studeez.common.composable.tasks
 | 
			
		||||
 | 
			
		||||
import androidx.compose.foundation.background
 | 
			
		||||
import androidx.compose.foundation.layout.Arrangement
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +24,7 @@ import androidx.compose.ui.text.style.TextOverflow
 | 
			
		|||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import be.ugent.sel.studeez.R
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.StealthButton
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.task.Subject
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -100,6 +101,7 @@ fun SubjectEntryPreview() {
 | 
			
		|||
    SubjectEntry(
 | 
			
		||||
        subject = Subject(
 | 
			
		||||
            name = "Test Subject",
 | 
			
		||||
//            name = "Testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt",
 | 
			
		||||
            argb_color = 0xFFF44336,
 | 
			
		||||
            time = 60
 | 
			
		||||
        ),
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,135 @@
 | 
			
		|||
package be.ugent.sel.studeez.common.composable.tasks
 | 
			
		||||
 | 
			
		||||
import androidx.compose.foundation.layout.Arrangement
 | 
			
		||||
import androidx.compose.foundation.layout.Box
 | 
			
		||||
import androidx.compose.foundation.layout.Row
 | 
			
		||||
import androidx.compose.foundation.layout.fillMaxWidth
 | 
			
		||||
import androidx.compose.foundation.layout.padding
 | 
			
		||||
import androidx.compose.material.Card
 | 
			
		||||
import androidx.compose.material.Checkbox
 | 
			
		||||
import androidx.compose.material.CheckboxDefaults
 | 
			
		||||
import androidx.compose.material.Icon
 | 
			
		||||
import androidx.compose.material.IconButton
 | 
			
		||||
import androidx.compose.material.MaterialTheme
 | 
			
		||||
import androidx.compose.material.Text
 | 
			
		||||
import androidx.compose.material.icons.Icons
 | 
			
		||||
import androidx.compose.material.icons.filled.Delete
 | 
			
		||||
import androidx.compose.runtime.Composable
 | 
			
		||||
import androidx.compose.ui.Alignment
 | 
			
		||||
import androidx.compose.ui.Modifier
 | 
			
		||||
import androidx.compose.ui.graphics.Color
 | 
			
		||||
import androidx.compose.ui.text.font.FontWeight
 | 
			
		||||
import androidx.compose.ui.text.style.TextOverflow
 | 
			
		||||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import be.ugent.sel.studeez.R
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.StealthButton
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.task.Task
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds
 | 
			
		||||
import be.ugent.sel.studeez.resources
 | 
			
		||||
 | 
			
		||||
@Composable
 | 
			
		||||
fun TaskEntry(
 | 
			
		||||
    task: Task,
 | 
			
		||||
) {
 | 
			
		||||
    Card(
 | 
			
		||||
        modifier = Modifier
 | 
			
		||||
            .fillMaxWidth()
 | 
			
		||||
            .padding(horizontal = 10.dp, vertical = 5.dp),
 | 
			
		||||
    ) {
 | 
			
		||||
        val color = if (task.completed) Color.Gray else Color.Black
 | 
			
		||||
        Row(
 | 
			
		||||
            horizontalArrangement = Arrangement.SpaceBetween,
 | 
			
		||||
            verticalAlignment = Alignment.CenterVertically,
 | 
			
		||||
        ) {
 | 
			
		||||
            Row(
 | 
			
		||||
                verticalAlignment = Alignment.CenterVertically,
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .padding(start = 10.dp)
 | 
			
		||||
                    .weight(22f),
 | 
			
		||||
            ) {
 | 
			
		||||
                Checkbox(
 | 
			
		||||
                    checked = task.completed,
 | 
			
		||||
                    onCheckedChange = {},
 | 
			
		||||
                    colors = CheckboxDefaults.colors(
 | 
			
		||||
                        checkedColor = Color.Gray,
 | 
			
		||||
                        uncheckedColor = MaterialTheme.colors.onSurface,
 | 
			
		||||
                    )
 | 
			
		||||
                )
 | 
			
		||||
                Row(
 | 
			
		||||
                    horizontalArrangement = Arrangement.SpaceBetween,
 | 
			
		||||
                    verticalAlignment = Alignment.CenterVertically,
 | 
			
		||||
                    modifier = Modifier.fillMaxWidth()
 | 
			
		||||
                ) {
 | 
			
		||||
                    Text(
 | 
			
		||||
                        text = task.name,
 | 
			
		||||
                        overflow = TextOverflow.Ellipsis,
 | 
			
		||||
                        maxLines = 1,
 | 
			
		||||
                        color = color,
 | 
			
		||||
                        modifier = Modifier.weight(13f),
 | 
			
		||||
                    )
 | 
			
		||||
                    Text(
 | 
			
		||||
                        text = "${HoursMinutesSeconds(task.time)}",
 | 
			
		||||
                        color = color,
 | 
			
		||||
                        modifier = Modifier.weight(5f)
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            Box(modifier = Modifier.weight(7f)) {
 | 
			
		||||
                if (task.completed) {
 | 
			
		||||
                    IconButton(
 | 
			
		||||
                        onClick = { /*TODO*/ },
 | 
			
		||||
                        modifier = Modifier
 | 
			
		||||
                            .padding(start = 20.dp)
 | 
			
		||||
                    ) {
 | 
			
		||||
                        Icon(
 | 
			
		||||
                            imageVector = Icons.Default.Delete,
 | 
			
		||||
                            contentDescription = resources().getString(R.string.delete_task),
 | 
			
		||||
                        )
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    StealthButton(
 | 
			
		||||
                        text = R.string.start,
 | 
			
		||||
                        modifier = Modifier
 | 
			
		||||
                            .padding(end = 5.dp),
 | 
			
		||||
                    ) {
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@Preview
 | 
			
		||||
@Composable
 | 
			
		||||
fun TaskEntryPreview() {
 | 
			
		||||
    TaskEntry(
 | 
			
		||||
        task = Task(
 | 
			
		||||
            name = "Test Task",
 | 
			
		||||
            completed = false,
 | 
			
		||||
        ),
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@Preview
 | 
			
		||||
@Composable
 | 
			
		||||
fun CompletedTaskEntryPreview() {
 | 
			
		||||
    TaskEntry(
 | 
			
		||||
        task = Task(
 | 
			
		||||
            name = "Test Task",
 | 
			
		||||
            completed = true,
 | 
			
		||||
        )
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@Preview
 | 
			
		||||
@Composable
 | 
			
		||||
fun OverflowTaskEntryPreview() {
 | 
			
		||||
    TaskEntry(
 | 
			
		||||
        task = Task(
 | 
			
		||||
            name = "Test Taskkkkkkkkkkkkkkkkkkkkkkkkkkk",
 | 
			
		||||
            completed = false,
 | 
			
		||||
        ),
 | 
			
		||||
    )
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -6,4 +6,5 @@ data class Task(
 | 
			
		|||
    @DocumentId val id: String = "",
 | 
			
		||||
    val name: String = "",
 | 
			
		||||
    val completed: Boolean = false,
 | 
			
		||||
    val time: Int = 0,
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ import androidx.compose.ui.tooling.preview.Preview
 | 
			
		|||
import androidx.compose.ui.unit.dp
 | 
			
		||||
import androidx.compose.ui.unit.sp
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.FunctionalEndlessTimer
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.timer_functional.HoursMinutesSeconds
 | 
			
		||||
import be.ugent.sel.studeez.navigation.StudeezDestinations
 | 
			
		||||
import be.ugent.sel.studeez.screens.session.SessionActions
 | 
			
		||||
import kotlinx.coroutines.delay
 | 
			
		||||
| 
						 | 
				
			
			@ -93,7 +94,7 @@ abstract class AbstractSessionScreen {
 | 
			
		|||
        val hms = sessionActions.getTimer().getHoursMinutesSeconds()
 | 
			
		||||
        Column {
 | 
			
		||||
            Text(
 | 
			
		||||
                text = "${hms.hours} : ${hms.minutes} : ${hms.seconds}",
 | 
			
		||||
                text = hms.toString(),
 | 
			
		||||
                modifier = Modifier
 | 
			
		||||
                    .fillMaxWidth()
 | 
			
		||||
                    .padding(50.dp),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,9 +12,9 @@ import androidx.compose.ui.unit.dp
 | 
			
		|||
import be.ugent.sel.studeez.R
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.NewTaskSubjectButton
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.SubjectEntry
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.drawer.DrawerActions
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.navbar.NavigationBarActions
 | 
			
		||||
import be.ugent.sel.studeez.common.composable.tasks.SubjectEntry
 | 
			
		||||
import be.ugent.sel.studeez.data.local.models.task.Subject
 | 
			
		||||
import be.ugent.sel.studeez.resources
 | 
			
		||||
import kotlinx.coroutines.flow.Flow
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue