diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5dd62a3..fbcd7cc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -57,17 +57,14 @@ dependencies { implementation("androidx.compose.ui:ui-graphics") implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.material3:material3") - implementation(platform("androidx.compose:compose-bom:2023.03.00")) implementation("androidx.datastore:datastore-preferences:1.0.0") implementation("com.google.code.gson:gson:2.9.0") implementation(platform("androidx.compose:compose-bom:2023.03.00")) - implementation(platform("androidx.compose:compose-bom:2023.03.00")) testImplementation("junit:junit:4.13.2") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") androidTestImplementation("androidx.compose.ui:ui-test-junit4") androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) - androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-test-manifest") } \ No newline at end of file diff --git a/app/src/main/java/com/schoolapp/cleverclass/PSEActivity.kt b/app/src/main/java/com/schoolapp/cleverclass/PSEActivity.kt index 44b6281..ec3390a 100644 --- a/app/src/main/java/com/schoolapp/cleverclass/PSEActivity.kt +++ b/app/src/main/java/com/schoolapp/cleverclass/PSEActivity.kt @@ -5,8 +5,10 @@ import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.horizontalScroll +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -17,6 +19,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.wrapContentWidth 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.ArrowBack @@ -31,6 +34,7 @@ import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar import androidx.compose.material3.TopAppBarDefaults import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember @@ -39,7 +43,6 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import com.schoolapp.cleverclass.ui.theme.CleverClassTheme import org.json.JSONObject import java.io.InputStreamReader @@ -49,8 +52,10 @@ class PSEActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { CleverClassTheme { - Surface(modifier = Modifier.fillMaxSize(), - color = MaterialTheme.colorScheme.background) { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background) + { PSEContent(activity = this) } } @@ -58,10 +63,49 @@ class PSEActivity : ComponentActivity() { } } +@Composable +fun PSEContent(activity: ComponentActivity){ + var loading by remember { + mutableStateOf(true) + } + + LaunchedEffect(key1 = true) { + loading = false + } + + if (loading) { + StaticLoadingScreen() + } else { + PSEMainContent(activity) + } +} + + +private val colors = listOf( + Color(0xFFBCA76D), + Color(0xFFC65253), + Color(0xFF337733), + Color(0xFFDC2222), + Color(0xFF129DC3), + Color(0xFFDDCC69), + Color(0xFF7044DD) +) +private val shells = listOf( + "K", "L", "M", "N", "O", "P", "Q" +) +private val groups = listOf( + "", + "I", "II", + "", "", "", "", "", "", "", "", "", "", "", "", "", "", + "IIIb", "IVb", "Vb", "VIb", "VIIb", "VIIIb", "VIIIb", "VIIIb", "Ib", "IIb", + "III", "IV", "V", "VI", "VII", "VIII", + "" +) + // Content of PSE @OptIn(ExperimentalMaterial3Api::class) @Composable -fun PSEContent(activity: ComponentActivity){ +fun PSEMainContent(activity: ComponentActivity) { var showInfo by remember { mutableStateOf(false) } @@ -86,15 +130,6 @@ fun PSEContent(activity: ComponentActivity){ 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 ) - val colors = listOf( - Color(0xFFBCA76D), - Color(0xFFC65253), - Color(0xFF337733), - Color(0xFFDC2222), - Color(0xFF129DC3), - Color(0xFFDDCC69), - Color(0xFF7044DD) - ) Column { TopAppBar( colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer), @@ -131,6 +166,7 @@ fun PSEContent(activity: ComponentActivity){ ) Column( + verticalArrangement = Arrangement.Center, modifier = Modifier .fillMaxHeight() .padding(3.dp) @@ -138,23 +174,34 @@ fun PSEContent(activity: ComponentActivity){ .horizontalScroll(rememberScrollState()) ) { var dialogCounter = 0 + + Row { + groups.forEach { element -> + InformationBox(text = element, color = MaterialTheme.colorScheme.onBackground, false) + } + } + for (row in 0..6) { Row { + InformationBox(text = (row + 1).toString(), color = MaterialTheme.colorScheme.onBackground, true) + for (element in 0..31) { val index = row * 32 + element if (elementNameList[index] != "") { Box(modifier = Modifier .padding(3.dp) .size(60.dp) - .background(color = colors[elementButtonColors[index]]) + .background( + color = colors[elementButtonColors[index]], + shape = RoundedCornerShape(5) + ) .clickable { dialogChooser = ++dialogCounter } ) { Text( - modifier = Modifier - .align(Alignment.Center), + modifier = Modifier.align(Alignment.Center), text = elementNameList[index], color = com.schoolapp.cleverclass.ui.theme.TextOnColouredButton, - fontSize = 24.sp + style = MaterialTheme.typography.labelLarge ) } } else { @@ -165,6 +212,8 @@ fun PSEContent(activity: ComponentActivity){ ) } } + + InformationBox(text = shells[row], color = colors[row], true) } } } @@ -226,6 +275,26 @@ fun PSEContent(activity: ComponentActivity){ .padding(5.dp) ) } + +} + +@Composable +fun InformationBox(text: String, color: Color, outline: Boolean){ + Box(modifier = Modifier + .padding(3.dp) + .size(60.dp) + .border( + width = 1.dp, + color = if (outline) MaterialTheme.colorScheme.primaryContainer else Color.Transparent + ) + ) { + Text( + modifier = Modifier.align(Alignment.Center), + text = text, + color = color, + style = MaterialTheme.typography.labelLarge + ) + } } fun readElementData(context: Context, int: Int): String { diff --git a/app/src/main/java/com/schoolapp/cleverclass/Utilities.kt b/app/src/main/java/com/schoolapp/cleverclass/Utilities.kt index f191763..c4c8549 100644 --- a/app/src/main/java/com/schoolapp/cleverclass/Utilities.kt +++ b/app/src/main/java/com/schoolapp/cleverclass/Utilities.kt @@ -1,11 +1,22 @@ package com.schoolapp.cleverclass +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp const val NO_INTERNET_CONNECTION_CODE = -1 @@ -27,6 +38,29 @@ fun LoadingScreen(){ modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center ){ - CircularProgressIndicator() + CircularProgressIndicator(color = MaterialTheme.colorScheme.secondary) + } +} +@Composable +fun StaticLoadingScreen(){ + Box( + modifier = Modifier.fillMaxSize(), + contentAlignment = Alignment.Center + ){ + Column(horizontalAlignment = Alignment.CenterHorizontally) { + Text( + text = "Loading...", + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(start = 16.dp, end = 16.dp), + color = MaterialTheme.colorScheme.onBackground + ) + Spacer(modifier = Modifier.height(8.dp)) + Image( + painter = painterResource(id = R.drawable.static_loading_icon), + contentDescription = null, + colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onBackground), + contentScale = ContentScale.FillBounds + ) + } } } \ No newline at end of file diff --git a/app/src/main/java/com/schoolapp/cleverclass/ui/theme/Type.kt b/app/src/main/java/com/schoolapp/cleverclass/ui/theme/Type.kt index 199e06c..35ec0b0 100644 --- a/app/src/main/java/com/schoolapp/cleverclass/ui/theme/Type.kt +++ b/app/src/main/java/com/schoolapp/cleverclass/ui/theme/Type.kt @@ -17,6 +17,13 @@ val Typography = Typography( lineHeight = 24.sp, letterSpacing = 0.5.sp ), + labelLarge = TextStyle( + fontFamily = FontFamily(Font(R.font.arlrdbd, FontWeight.Normal)), + fontWeight = FontWeight.Normal, + fontSize = 24.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ), headlineMedium = TextStyle( fontFamily = FontFamily(Font(R.font.arlrdbd, FontWeight.Normal)), fontWeight = FontWeight.Normal, diff --git a/app/src/main/res/drawable/static_loading_icon.xml b/app/src/main/res/drawable/static_loading_icon.xml new file mode 100644 index 0000000..b08e379 --- /dev/null +++ b/app/src/main/res/drawable/static_loading_icon.xml @@ -0,0 +1,9 @@ + + +