#21 begin styling subject
This commit is contained in:
parent
4bbc3af4b2
commit
c33aad5496
5 changed files with 65 additions and 8 deletions
|
@ -1,19 +1,60 @@
|
|||
package be.ugent.sel.studeez.common.composable
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
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.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.Card
|
||||
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.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import be.ugent.sel.studeez.R
|
||||
import be.ugent.sel.studeez.data.local.models.task.Subject
|
||||
|
||||
@Composable
|
||||
fun SubjectEntry(
|
||||
subject: Subject,
|
||||
) {
|
||||
Text(text = subject.name)
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(10.dp),
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.Top,
|
||||
) {
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp),
|
||||
verticalAlignment = Alignment.Top,
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(20.dp)
|
||||
.clip(CircleShape)
|
||||
.background(Color(subject.argb_color))
|
||||
.padding(4.dp),
|
||||
)
|
||||
Text(text = subject.name)
|
||||
}
|
||||
StealthButton(text = R.string.view_task) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun SubjectEntryPreview() {
|
||||
SubjectEntry(subject = Subject(name = "Test Subject"))
|
||||
SubjectEntry(subject = Subject(name = "Test Subject", argb_color = 0xFFF44336))
|
||||
}
|
|
@ -7,5 +7,7 @@ data class Subject(
|
|||
val name: String = "",
|
||||
val tasks: List<Task> = mutableListOf(),
|
||||
val time: Int = 0,
|
||||
val color: Int = 0,
|
||||
)
|
||||
val argb_color: Long = 0,
|
||||
) {
|
||||
// fun getColor(): Color = Color(ARGB_color)
|
||||
}
|
|
@ -1,11 +1,15 @@
|
|||
package be.ugent.sel.studeez.screens.tasks
|
||||
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.Divider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.ui.Modifier
|
||||
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.NewTaskSubjectButton
|
||||
import be.ugent.sel.studeez.common.composable.PrimaryScreenTemplate
|
||||
|
@ -47,8 +51,18 @@ fun TaskScreen(
|
|||
val subjects = getSubjects().collectAsState(initial = emptyList())
|
||||
Column {
|
||||
LazyColumn {
|
||||
items(subjects.value) {
|
||||
SubjectEntry(subject = it)
|
||||
if (subjects.value.isNotEmpty()) {
|
||||
item {
|
||||
SubjectEntry(subject = subjects.value[0])
|
||||
}
|
||||
}
|
||||
if (subjects.value.size > 1) {
|
||||
items(subjects.value.subList(1, subjects.value.lastIndex + 1)) {
|
||||
Column {
|
||||
Divider(modifier = Modifier.padding(10.dp, 0.dp))
|
||||
SubjectEntry(subject = it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NewTaskSubjectButton(onClick = addSubject, R.string.new_subject)
|
||||
|
@ -56,7 +70,6 @@ fun TaskScreen(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun TaskScreenPreview() {
|
||||
|
|
|
@ -19,7 +19,7 @@ class TaskViewModel @Inject constructor(
|
|||
name = "Test Subject",
|
||||
tasks = listOf(),
|
||||
time = 0,
|
||||
color = 0,
|
||||
argb_color = 0xFFF44336,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
<string name="tasks">Tasks</string>
|
||||
<string name="new_subject">New Subject</string>
|
||||
<string name="new_task">New Task</string>
|
||||
<string name="view_task">View</string>
|
||||
|
||||
<!-- Sessions -->
|
||||
<string name="sessions">Sessions</string>
|
||||
|
|
Reference in a new issue