Add add and remove function to grades
This commit is contained in:
@@ -14,7 +14,9 @@ import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
@@ -42,7 +44,6 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment.Companion.CenterVertically
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
|
||||
import com.schoolapp.cleverclass.ui.theme.TextOnColouredButton
|
||||
@@ -63,7 +64,7 @@ class FachActivity : ComponentActivity() {
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
color = MaterialTheme.colorScheme.background
|
||||
) {
|
||||
FachContent(activity = this, name = name)
|
||||
GradeContent(activity = this, name = name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +73,19 @@ class FachActivity : ComponentActivity() {
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun FachContent(activity: ComponentActivity, name : String){
|
||||
fun GradeContent(activity: ComponentActivity, name : String){
|
||||
val colors = listOf(
|
||||
Color(0xFF536DFE),
|
||||
Color(0xFF448AFF),
|
||||
Color(0xFF40C4FF),
|
||||
Color(0xFF18FFFF),
|
||||
Color(0xFF64FFDA),
|
||||
Color(0xFF69F0AE)
|
||||
)
|
||||
var grades by remember {
|
||||
mutableStateOf(emptyList<GradeData>())
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
@@ -114,8 +127,9 @@ fun FachContent(activity: ComponentActivity, name : String){
|
||||
}
|
||||
},
|
||||
floatingActionButton = {
|
||||
FloatingActionButton(onClick = { /*TODO*/ },
|
||||
shape = RoundedCornerShape(40)
|
||||
FloatingActionButton(
|
||||
onClick = { grades = grades + GradeData(grades.size, colors.random()) },
|
||||
shape = RoundedCornerShape(40)
|
||||
) {
|
||||
Icon(imageVector = Icons.Filled.Add,
|
||||
contentDescription = null,
|
||||
@@ -124,18 +138,18 @@ fun FachContent(activity: ComponentActivity, name : String){
|
||||
) {innerPadding ->
|
||||
Column(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(innerPadding))
|
||||
.padding(innerPadding)
|
||||
.verticalScroll(rememberScrollState()))
|
||||
{
|
||||
NotenPrefab()
|
||||
NotenPrefab()
|
||||
grades.forEach{ gradeData ->
|
||||
GradePrefab(onClose = { grades = grades.filter { it != gradeData } }, color = gradeData.color)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun NotenPrefab(){
|
||||
val color = Color(0xFFB2FF59)
|
||||
fun GradePrefab(onClose: () -> Unit, color: Color){
|
||||
var typeExpanded by remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
@@ -187,7 +201,7 @@ fun NotenPrefab(){
|
||||
tint = TextOnColouredButton,
|
||||
modifier = Modifier
|
||||
.size(28.dp)
|
||||
.clickable { /*TODO*/ }
|
||||
.clickable { onClose() }
|
||||
)
|
||||
}
|
||||
|
||||
@@ -242,3 +256,5 @@ fun NotenPrefab(){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data class GradeData(val id: Int, val color: Color)
|
||||
|
||||
Reference in New Issue
Block a user