Polish PSE

This commit is contained in:
BuildTools
2024-05-16 19:20:28 +02:00
parent 7941081b90
commit c54a79e218
5 changed files with 137 additions and 21 deletions

View File

@@ -57,17 +57,14 @@ dependencies {
implementation("androidx.compose.ui:ui-graphics") implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3") implementation("androidx.compose.material3:material3")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.datastore:datastore-preferences:1.0.0") implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("com.google.code.gson:gson:2.9.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"))
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
testImplementation("junit:junit:4.13.2") testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation("androidx.compose.ui:ui-test-junit4") 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"))
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
debugImplementation("androidx.compose.ui:ui-tooling") debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest") debugImplementation("androidx.compose.ui:ui-test-manifest")
} }

View File

@@ -5,8 +5,10 @@ import android.os.Bundle
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row 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.size
import androidx.compose.foundation.layout.wrapContentWidth import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack 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.TopAppBar
import androidx.compose.material3.TopAppBarDefaults import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
@@ -39,7 +43,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.schoolapp.cleverclass.ui.theme.CleverClassTheme import com.schoolapp.cleverclass.ui.theme.CleverClassTheme
import org.json.JSONObject import org.json.JSONObject
import java.io.InputStreamReader import java.io.InputStreamReader
@@ -49,8 +52,10 @@ class PSEActivity : ComponentActivity() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContent { setContent {
CleverClassTheme { CleverClassTheme {
Surface(modifier = Modifier.fillMaxSize(), Surface(
color = MaterialTheme.colorScheme.background) { modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background)
{
PSEContent(activity = this) 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 // Content of PSE
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun PSEContent(activity: ComponentActivity){ fun PSEMainContent(activity: ComponentActivity) {
var showInfo by remember { var showInfo by remember {
mutableStateOf(false) 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, 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 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 { Column {
TopAppBar( TopAppBar(
colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer), colors = TopAppBarDefaults.centerAlignedTopAppBarColors(MaterialTheme.colorScheme.primaryContainer),
@@ -131,6 +166,7 @@ fun PSEContent(activity: ComponentActivity){
) )
Column( Column(
verticalArrangement = Arrangement.Center,
modifier = Modifier modifier = Modifier
.fillMaxHeight() .fillMaxHeight()
.padding(3.dp) .padding(3.dp)
@@ -138,23 +174,34 @@ fun PSEContent(activity: ComponentActivity){
.horizontalScroll(rememberScrollState()) .horizontalScroll(rememberScrollState())
) { ) {
var dialogCounter = 0 var dialogCounter = 0
Row {
groups.forEach { element ->
InformationBox(text = element, color = MaterialTheme.colorScheme.onBackground, false)
}
}
for (row in 0..6) { for (row in 0..6) {
Row { Row {
InformationBox(text = (row + 1).toString(), color = MaterialTheme.colorScheme.onBackground, true)
for (element in 0..31) { for (element in 0..31) {
val index = row * 32 + element val index = row * 32 + element
if (elementNameList[index] != "") { if (elementNameList[index] != "") {
Box(modifier = Modifier Box(modifier = Modifier
.padding(3.dp) .padding(3.dp)
.size(60.dp) .size(60.dp)
.background(color = colors[elementButtonColors[index]]) .background(
color = colors[elementButtonColors[index]],
shape = RoundedCornerShape(5)
)
.clickable { dialogChooser = ++dialogCounter } .clickable { dialogChooser = ++dialogCounter }
) { ) {
Text( Text(
modifier = Modifier modifier = Modifier.align(Alignment.Center),
.align(Alignment.Center),
text = elementNameList[index], text = elementNameList[index],
color = com.schoolapp.cleverclass.ui.theme.TextOnColouredButton, color = com.schoolapp.cleverclass.ui.theme.TextOnColouredButton,
fontSize = 24.sp style = MaterialTheme.typography.labelLarge
) )
} }
} else { } 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) .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 { fun readElementData(context: Context, int: Int): String {

View File

@@ -1,11 +1,22 @@
package com.schoolapp.cleverclass package com.schoolapp.cleverclass
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box 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.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier 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 const val NO_INTERNET_CONNECTION_CODE = -1
@@ -27,6 +38,29 @@ fun LoadingScreen(){
modifier = Modifier.fillMaxSize(), modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center 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
)
}
} }
} }

View File

@@ -17,6 +17,13 @@ val Typography = Typography(
lineHeight = 24.sp, lineHeight = 24.sp,
letterSpacing = 0.5.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( headlineMedium = TextStyle(
fontFamily = FontFamily(Font(R.font.arlrdbd, FontWeight.Normal)), fontFamily = FontFamily(Font(R.font.arlrdbd, FontWeight.Normal)),
fontWeight = FontWeight.Normal, fontWeight = FontWeight.Normal,

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M480,880q-83,0 -156,-31.5T197,763q-54,-54 -85.5,-127T80,480q0,-83 31.5,-156T197,197q54,-54 127,-85.5T480,80q83,0 156,31.5T763,197q54,54 85.5,127T880,480q0,83 -31.5,156T763,763q-54,54 -127,85.5T480,880ZM480,800q64,0 123,-24t104,-69L480,480v-320q-134,0 -227,93t-93,227q0,134 93,227t227,93Z"
android:fillColor="#e8eaed"/>
</vector>