Add select functionality to grades
This commit is contained in:
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@@ -4,6 +4,7 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ import androidx.compose.foundation.verticalScroll
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
import androidx.compose.material.icons.filled.ArrowBack
|
import androidx.compose.material.icons.filled.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Check
|
||||||
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
||||||
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
||||||
|
import androidx.compose.material.icons.outlined.Delete
|
||||||
|
import androidx.compose.material.icons.outlined.Edit
|
||||||
import androidx.compose.material3.BottomAppBar
|
import androidx.compose.material3.BottomAppBar
|
||||||
import androidx.compose.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
@@ -103,6 +105,16 @@ fun GradeContent(activity: ComponentActivity, name : String){
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// TODO: add confirmation to delete all
|
||||||
|
actions = {
|
||||||
|
IconButton(onClick = { grades = emptyList() }) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.Delete,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(28.dp)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@@ -148,8 +160,16 @@ fun GradeContent(activity: ComponentActivity, name : String){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val types = listOf("Schulaufgabe", "Test", "Ex", "Referat", "Mündlich", "Sonstiges")
|
||||||
|
val grades = listOf(1, 2, 3, 4, 5, 6)
|
||||||
|
val weights = listOf(0.5f, 1f, 1.5f, 2f)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun GradePrefab(onClose: () -> Unit, color: Color){
|
fun GradePrefab(onClose: () -> Unit, color: Color){
|
||||||
|
var editing by remember {
|
||||||
|
mutableStateOf(true)
|
||||||
|
}
|
||||||
|
|
||||||
var typeExpanded by remember {
|
var typeExpanded by remember {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
@@ -160,53 +180,105 @@ fun GradePrefab(onClose: () -> Unit, color: Color){
|
|||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var selectedType by remember {
|
||||||
|
mutableStateOf("Typ")
|
||||||
|
}
|
||||||
|
var selectedGrade by remember {
|
||||||
|
mutableStateOf(1)
|
||||||
|
}
|
||||||
|
var selectedWeight by remember {
|
||||||
|
mutableStateOf(1f)
|
||||||
|
}
|
||||||
|
|
||||||
// Background
|
// Background
|
||||||
Surface(
|
Surface(
|
||||||
shape = RoundedCornerShape(20),
|
shape = RoundedCornerShape(20),
|
||||||
color = color,
|
color = color,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.height(128.dp)
|
.height(120.dp)
|
||||||
.padding(start = 16.dp, end = 16.dp, top = 16.dp)
|
.padding(start = 16.dp, end = 16.dp, top = 16.dp)
|
||||||
) {
|
) {
|
||||||
// Content
|
// Content
|
||||||
Column(modifier = Modifier.padding(16.dp)) {
|
Column(modifier = Modifier.padding(16.dp)) {
|
||||||
|
// Top Row
|
||||||
Row {
|
Row {
|
||||||
// Type
|
// Type
|
||||||
Surface(
|
Surface(
|
||||||
shape = RoundedCornerShape(10),
|
shape = RoundedCornerShape(10),
|
||||||
color = color,
|
color = color,
|
||||||
border = BorderStroke(2.dp, TextOnColouredButton),
|
border = if(editing) BorderStroke(2.dp, TextOnColouredButton) else null,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(width = 128.dp, height = 32.dp)
|
.size(width = 170.dp, height = 32.dp)
|
||||||
.clickable { typeExpanded = !typeExpanded }
|
.let { if (editing) it.clickable { typeExpanded = !typeExpanded } else it }
|
||||||
) {
|
) {
|
||||||
Row(verticalAlignment = CenterVertically,
|
Row(verticalAlignment = CenterVertically,
|
||||||
modifier = Modifier.padding(4.dp)) {
|
modifier = Modifier.padding(4.dp)) {
|
||||||
Text(text = "Typ", color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
Text(text = selectedType, color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
||||||
DropdownMenu(expanded = typeExpanded, onDismissRequest = { typeExpanded = false }) {
|
|
||||||
DropdownMenuItem(text = { Text(text = "Test") }, onClick = { /*TODO*/ })
|
if(editing) {
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = typeExpanded,
|
||||||
|
onDismissRequest = { typeExpanded = false }
|
||||||
|
){
|
||||||
|
types.forEach { type ->
|
||||||
|
Item(
|
||||||
|
name = type,
|
||||||
|
onItemClick = {
|
||||||
|
selectedType = type
|
||||||
|
typeExpanded = !typeExpanded
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
Icon(
|
||||||
|
imageVector = if (typeExpanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = TextOnColouredButton
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
Icon(imageVector = if (typeExpanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
|
|
||||||
contentDescription = null,
|
|
||||||
tint = TextOnColouredButton)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Delete
|
|
||||||
|
// Buttons
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
Icon(
|
if (editing) {
|
||||||
imageVector = Icons.Filled.Close,
|
// Delete
|
||||||
contentDescription = null,
|
Icon(
|
||||||
tint = TextOnColouredButton,
|
imageVector = Icons.Outlined.Delete,
|
||||||
modifier = Modifier
|
contentDescription = null,
|
||||||
.size(28.dp)
|
tint = TextOnColouredButton,
|
||||||
.clickable { onClose() }
|
modifier = Modifier
|
||||||
)
|
.size(28.dp)
|
||||||
|
.clickable { onClose() }
|
||||||
|
)
|
||||||
|
Spacer(modifier = Modifier.width(4.dp))
|
||||||
|
// Confirm
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Filled.Check,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = TextOnColouredButton,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(28.dp)
|
||||||
|
.clickable { editing = !editing }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
// Edit
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Outlined.Edit,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = TextOnColouredButton,
|
||||||
|
modifier = Modifier
|
||||||
|
.size(28.dp)
|
||||||
|
.clickable { editing = !editing }
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
// Bottom Row
|
||||||
Row (verticalAlignment = CenterVertically) {
|
Row (verticalAlignment = CenterVertically) {
|
||||||
// Grade
|
// Grade
|
||||||
Text(text = "Note:", color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
Text(text = "Note:", color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
||||||
@@ -214,41 +286,76 @@ fun GradePrefab(onClose: () -> Unit, color: Color){
|
|||||||
Surface(
|
Surface(
|
||||||
shape = RoundedCornerShape(10),
|
shape = RoundedCornerShape(10),
|
||||||
color = color,
|
color = color,
|
||||||
border = BorderStroke(2.dp, TextOnColouredButton),
|
border = if(editing) BorderStroke(2.dp, TextOnColouredButton) else null,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(width = 48.dp, height = 32.dp)
|
.size(width = 48.dp, height = 32.dp)
|
||||||
.clickable { gradeExpanded = !gradeExpanded }
|
.let { if (editing) it.clickable { gradeExpanded = !gradeExpanded } else it }
|
||||||
) {
|
) {
|
||||||
Row(verticalAlignment = CenterVertically,
|
Row(verticalAlignment = CenterVertically,
|
||||||
modifier = Modifier.padding(4.dp)) {
|
modifier = Modifier.padding(4.dp)) {
|
||||||
Text(text = "1", color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
Text(text = selectedGrade.toString(), color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
||||||
DropdownMenu(expanded = gradeExpanded, onDismissRequest = { gradeExpanded = false }) {
|
|
||||||
DropdownMenuItem(text = { Text(text = "Test") }, onClick = { /*TODO*/ })
|
if(editing) {
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = gradeExpanded,
|
||||||
|
onDismissRequest = { gradeExpanded = false }) {
|
||||||
|
grades.forEach { grade ->
|
||||||
|
Item(
|
||||||
|
name = grade.toString(),
|
||||||
|
onItemClick = {
|
||||||
|
selectedGrade = grade
|
||||||
|
gradeExpanded = !gradeExpanded
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
Icon(
|
||||||
|
imageVector = if (gradeExpanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = TextOnColouredButton
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
Icon(imageVector = if (gradeExpanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown, contentDescription = null, tint = TextOnColouredButton)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Weight
|
// Weight
|
||||||
Spacer(modifier = Modifier.width(16.dp))
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
Text(text = "Gewichtung:", color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
Text(text = "Gewichtung:", color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
||||||
Spacer(modifier = Modifier.width(8.dp))
|
Spacer(modifier = Modifier.width(8.dp))
|
||||||
Surface(
|
Surface(
|
||||||
shape = RoundedCornerShape(10),
|
shape = RoundedCornerShape(10),
|
||||||
color = color,
|
color = color,
|
||||||
border = BorderStroke(2.dp, TextOnColouredButton),
|
border = if(editing) BorderStroke(2.dp, TextOnColouredButton) else null,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(width = 64.dp, height = 32.dp)
|
.size(width = 80.dp, height = 32.dp)
|
||||||
.clickable { weightExpanded = !weightExpanded }
|
.let { if (editing) it.clickable { weightExpanded = !weightExpanded } else it }
|
||||||
) {
|
) {
|
||||||
Row(verticalAlignment = CenterVertically,
|
Row(verticalAlignment = CenterVertically,
|
||||||
modifier = Modifier.padding(4.dp)) {
|
modifier = Modifier.padding(4.dp)) {
|
||||||
Text(text = "1x", color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
Text(text = "$selectedWeight" + "x", color = TextOnColouredButton, style = MaterialTheme.typography.labelMedium)
|
||||||
DropdownMenu(expanded = weightExpanded, onDismissRequest = { weightExpanded = false }) {
|
|
||||||
DropdownMenuItem(text = { Text(text = "Test") }, onClick = { /*TODO*/ })
|
if (editing) {
|
||||||
|
DropdownMenu(
|
||||||
|
expanded = weightExpanded,
|
||||||
|
onDismissRequest = { weightExpanded = false }) {
|
||||||
|
weights.forEach { weight ->
|
||||||
|
Item(
|
||||||
|
name = weight.toString(),
|
||||||
|
onItemClick = {
|
||||||
|
selectedWeight = weight
|
||||||
|
weightExpanded = !weightExpanded
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
Icon(
|
||||||
|
imageVector = if (weightExpanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown,
|
||||||
|
contentDescription = null,
|
||||||
|
tint = TextOnColouredButton
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
Icon(imageVector = if (weightExpanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown, contentDescription = null, tint = TextOnColouredButton)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,5 +363,13 @@ fun GradePrefab(onClose: () -> Unit, color: Color){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun Item(name : String, onItemClick: (String) -> Unit){
|
||||||
|
DropdownMenuItem(
|
||||||
|
text = { Text(text = name) },
|
||||||
|
onClick = { onItemClick(name) }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
data class GradeData(val id: Int, val color: Color)
|
data class GradeData(val id: Int, val color: Color)
|
||||||
|
|||||||
Reference in New Issue
Block a user