quality of life fixes

made the toolbar font size adaptively large relative to the user's name length, shrunk down the height of subjects and marks and made back gestures work properly - not close the app but show the previous screen
This commit is contained in:
Odweta
2024-11-08 18:09:55 +01:00
parent 8a4956e6c6
commit d3197111c3
9 changed files with 324 additions and 259 deletions
@@ -1,5 +1,6 @@
package com.odweta.solon package com.odweta.solon
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.border import androidx.compose.foundation.border
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
@@ -36,6 +37,11 @@ import java.time.format.TextStyle
@Composable @Composable
fun AboutScreen(modifier: Modifier = Modifier) { fun AboutScreen(modifier: Modifier = Modifier) {
// handle the back gesture (back swipe form side or back button on bottom android navbar)
BackHandler {
isShowing.value = IsShowing.Menu
}
Column( Column(
modifier = Modifier modifier = Modifier
.fillMaxSize(), .fillMaxSize(),
@@ -60,13 +66,13 @@ fun AboutScreen(modifier: Modifier = Modifier) {
shape = RoundedCornerShape(roundedCornerDimen), shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow color = PastelYellow
) )
.width(100.dp) .width(70.dp)
.height(100.dp) .height(70.dp)
) { ) {
Icon( Icon(
imageVector = Icons.Default.ArrowBackIosNew, // Replace with your desired icon imageVector = Icons.Default.ArrowBackIosNew,
contentDescription = "Back icon", contentDescription = "Back icon",
modifier = Modifier.size(35.dp) // Adjust size if needed modifier = Modifier.size(40.dp)
) )
} }
} }
@@ -15,6 +15,7 @@ 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.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.core.view.WindowCompat
import com.odweta.solon.ui.theme.SolonTheme import com.odweta.solon.ui.theme.SolonTheme
import kotlin.math.sign import kotlin.math.sign
+152 -124
View File
@@ -1,5 +1,6 @@
package com.odweta.solon package com.odweta.solon
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border import androidx.compose.foundation.border
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
@@ -37,6 +38,8 @@ import androidx.compose.ui.unit.sp
import com.odweta.solon.ui.theme.PastelGreen import com.odweta.solon.ui.theme.PastelGreen
import com.odweta.solon.ui.theme.PastelGreenTransparent import com.odweta.solon.ui.theme.PastelGreenTransparent
import com.odweta.solon.ui.theme.PastelOrange import com.odweta.solon.ui.theme.PastelOrange
import com.odweta.solon.ui.theme.PastelOrangeDark
import com.odweta.solon.ui.theme.PastelOrangeDarkTransparent
import com.odweta.solon.ui.theme.PastelOrangeTransparent import com.odweta.solon.ui.theme.PastelOrangeTransparent
import com.odweta.solon.ui.theme.PastelRed import com.odweta.solon.ui.theme.PastelRed
import com.odweta.solon.ui.theme.PastelRedTransparent import com.odweta.solon.ui.theme.PastelRedTransparent
@@ -63,25 +66,31 @@ fun MarksScreen() {
} }
private fun getAvgColor(avg: String, isBorder: Boolean = false): Color { private fun getAvgColor(avg: String, isBorder: Boolean = false): Color {
val aux = avg.replace(",", ".").toFloat().toInt() val aux = avg.replace(",", ".").toFloat()
return if (aux in 1..<2) { return if (aux in 1f..<1.5f) {
if (isBorder) { if (isBorder) {
PastelGreen PastelGreen
} else { } else {
PastelGreenTransparent PastelGreenTransparent
} }
} else if (aux in 2..<3) { } else if (aux in 1.5f..<2.5f) {
if (isBorder) { if (isBorder) {
PastelYellow PastelYellow
} else { } else {
PastelYellowTransparent PastelYellowTransparent
} }
} else if (aux in 3..<4) { } else if (aux in 2.5f..<3.5f) {
if (isBorder) { if (isBorder) {
PastelOrange PastelOrange
} else { } else {
PastelOrangeTransparent PastelOrangeTransparent
} }
} else if (aux in 3.5f..<4.5f) {
if (isBorder) {
PastelOrangeDark
} else {
PastelOrangeDarkTransparent
}
} else { } else {
if (isBorder) { if (isBorder) {
PastelRed PastelRed
@@ -119,7 +128,7 @@ fun MarksAll() {
Row( Row(
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.height(100.dp) .height(70.dp)
.background( .background(
color = getAvgColor(Util.avg(markList)), // decide on the color (transparent) color = getAvgColor(Util.avg(markList)), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen) shape = RoundedCornerShape(roundedCornerDimen)
@@ -131,7 +140,7 @@ fun MarksAll() {
) { ) {
Row( Row(
modifier = Modifier modifier = Modifier
.width(210.dp) .width(150.dp)
.fillMaxHeight() .fillMaxHeight()
.background( .background(
color = getAvgColor(Util.avg(markList)), // decide on the color (not transparent) color = getAvgColor(Util.avg(markList)), // decide on the color (not transparent)
@@ -142,12 +151,12 @@ fun MarksAll() {
) { ) {
Text( Text(
text = subject.uppercase(), text = subject.uppercase(),
fontSize = 35.sp, fontSize = 30.sp,
color = Color.White, color = Color.White,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
modifier = Modifier modifier = Modifier
.width(100.dp) .width(70.dp)
) )
Box( Box(
@@ -159,18 +168,19 @@ fun MarksAll() {
Text( Text(
text = Util.avg(markList).replace(".", ","), text = Util.avg(markList).replace(".", ","),
fontSize = 30.sp, fontSize = 28.sp,
color = Color.White, color = Color.White,
textAlign = TextAlign.Center, textAlign = TextAlign.Center,
modifier = Modifier modifier = Modifier
.width(100.dp) .width(70.dp)
) )
} }
Box( Box(
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
.fillMaxHeight(), .fillMaxHeight()
.padding(horizontal = 10.dp),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
Text( Text(
@@ -186,6 +196,11 @@ fun MarksAll() {
@Composable @Composable
fun MarksSubject() { fun MarksSubject() {
// handle the back gesture (back swipe form side or back button on bottom android navbar)
BackHandler {
marksShow.value = MarksShow.All
}
val scrollState = rememberScrollState() val scrollState = rememberScrollState()
Column( Column(
@@ -195,33 +210,67 @@ fun MarksSubject() {
.fillMaxWidth() .fillMaxWidth()
.padding(horizontal = 5.dp) .padding(horizontal = 5.dp)
) { ) {
Button( Row(
onClick = { modifier = Modifier.fillMaxWidth()
marksShow.value = MarksShow.All
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(100.dp)
.height(100.dp)
) { ) {
Icon( Button(
imageVector = Icons.Default.ArrowBackIosNew, // Replace with your desired icon onClick = {
contentDescription = "Back icon", marksShow.value = MarksShow.All
modifier = Modifier.size(35.dp) // Adjust size if needed },
) colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(70.dp)
.height(70.dp)
) {
Icon(
imageVector = Icons.Default.ArrowBackIosNew,
contentDescription = "Back icon",
modifier = Modifier.size(40.dp)
)
}
Box(modifier = Modifier.weight(1f))
Box(
modifier = Modifier
.width(70.dp)
.height(70.dp)
.border(
width = 5.dp,
color = getAvgColor(
Util.avg(marks[subjectToShow]!!),
true
),
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(
getAvgColor(
Util.avg(marks[subjectToShow]!!)
)
)
.padding(vertical = 15.dp),
contentAlignment = Alignment.Center
) {
Text(
text = Util.avg(marks[subjectToShow]!!).replace(".", ","),
color = Color.White,
textAlign = TextAlign.Center,
fontSize = 25.sp
) // average
}
} }
Spacer(modifier = Modifier.height(20.dp)) Spacer(modifier = Modifier.height(20.dp))
Box(modifier = Modifier.height(100.dp)) { //Box(modifier = Modifier.height(100.dp)) {
Text( Text(
text = subjectNameMap[subjectToShow]!!, text = subjectNameMap[subjectToShow]!!,
color = Color.White, color = Color.White,
@@ -237,36 +286,7 @@ fun MarksSubject() {
.background(PastelYellowTransparent) .background(PastelYellowTransparent)
.padding(vertical = 20.dp) .padding(vertical = 20.dp)
) // subject ) // subject
} //}
Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.Center
) {
Text(
text = Util.avg(marks[subjectToShow]!!).replace(".", ","),
color = Color.White,
textAlign = TextAlign.Center,
fontSize = 30.sp,
modifier = Modifier
.width(100.dp)
.height(100.dp)
.border(
width = 5.dp,
color = getAvgColor(
Util.avg(marks[subjectToShow]!!),
true
),
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(
getAvgColor(
Util.avg(marks[subjectToShow]!!)
)
)
.padding(vertical = 32.5.dp)
) // average
}
Spacer(modifier = Modifier.height(20.dp)) Spacer(modifier = Modifier.height(20.dp))
@@ -284,7 +304,7 @@ fun MarksSubject() {
color = getAvgColor(mark.grade), color = getAvgColor(mark.grade),
shape = RoundedCornerShape(roundedCornerDimen) shape = RoundedCornerShape(roundedCornerDimen)
) )
.padding(vertical = 20.dp) .padding(vertical = 10.dp)
.clickable { .clickable {
markToShow = mark markToShow = mark
marksShow.value = MarksShow.Detail marksShow.value = MarksShow.Detail
@@ -292,7 +312,7 @@ fun MarksSubject() {
) { ) {
Box( Box(
modifier = Modifier modifier = Modifier
.width(100.dp) .width(70.dp)
.align(Alignment.CenterVertically), .align(Alignment.CenterVertically),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
@@ -312,7 +332,7 @@ fun MarksSubject() {
Text( Text(
text = mark.theme, text = mark.theme,
color = Color.White, color = Color.White,
fontSize = 23.sp fontSize = 20.sp
) // theme ) // theme
} }
} }
@@ -323,6 +343,11 @@ fun MarksSubject() {
@Composable @Composable
fun MarksDetail() { fun MarksDetail() {
// handle the back gesture (back swipe form side or back button on bottom android navbar)
BackHandler {
marksShow.value = MarksShow.Subject
}
val scrollState = rememberScrollState() val scrollState = rememberScrollState()
Column( Column(
@@ -333,34 +358,68 @@ fun MarksDetail() {
.padding(horizontal = 5.dp) .padding(horizontal = 5.dp)
.verticalScroll(scrollState) .verticalScroll(scrollState)
) { ) {
Button( Row(
onClick = { modifier = Modifier.fillMaxWidth()
marksShow.value = MarksShow.Subject
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(100.dp)
.height(100.dp)
) { ) {
Icon( Button(
imageVector = Icons.Default.ArrowBackIosNew, // Replace with your desired icon onClick = {
contentDescription = "Back icon", marksShow.value = MarksShow.Subject
modifier = Modifier.size(35.dp) // Adjust size if needed },
) colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(70.dp)
.height(70.dp)
) {
Icon(
imageVector = Icons.Default.ArrowBackIosNew,
contentDescription = "Back icon",
modifier = Modifier.size(40.dp)
)
}
Box(modifier = Modifier.weight(1f))
Box(
modifier = Modifier
.width(70.dp)
.height(70.dp)
.border(
width = 5.dp,
color = getAvgColor(
Util.avg(marks[subjectToShow]!!),
true
),
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(
getAvgColor(
Util.avg(marks[subjectToShow]!!)
)
)
.padding(vertical = 15.dp),
contentAlignment = Alignment.Center
) {
Text(
text = markToShow.grade,
color = Color.White,
textAlign = TextAlign.Center,
fontSize = 25.sp
) // average
}
} }
Spacer(modifier = Modifier.height(20.dp)) Spacer(modifier = Modifier.height(20.dp))
Row { Row {
Box(modifier = Modifier.height(100.dp)) { //Box(modifier = Modifier.height(70.dp)) {
Text( Text(
text = markToShow.theme, text = markToShow.theme,
color = Color.White, color = Color.White,
@@ -376,40 +435,9 @@ fun MarksDetail() {
.background(PastelYellowTransparent) .background(PastelYellowTransparent)
.padding(vertical = 20.dp) .padding(vertical = 20.dp)
) // description ) // description
} //}
} // description } // description
Row {
Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.Center
) {
Text(
text = markToShow.grade,
color = Color.White,
textAlign = TextAlign.Center,
fontSize = 35.sp,
modifier = Modifier
.width(100.dp)
.height(100.dp)
.border(
width = 5.dp,
color = getAvgColor(
Util.avg(mutableListOf(markToShow)),
true
),
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(
getAvgColor(
Util.avg(mutableListOf(markToShow))
)
)
.padding(vertical = 32.5.dp)
) // average
}
} // grade
Spacer(modifier = Modifier.height(20.dp)) Spacer(modifier = Modifier.height(20.dp))
Row( Row(
@@ -431,7 +459,7 @@ fun MarksDetail() {
Text( Text(
text = "Váha:", text = "Váha:",
color = Color.White, color = Color.White,
fontSize = 30.sp fontSize = 20.sp
) )
} }
@@ -444,7 +472,7 @@ fun MarksDetail() {
Text( Text(
text = markToShow.weight.replace(".", ","), text = markToShow.weight.replace(".", ","),
color = Color.White, color = Color.White,
fontSize = 23.sp fontSize = 20.sp
) )
} }
} // weight } // weight
@@ -470,7 +498,7 @@ fun MarksDetail() {
Text( Text(
text = "Datum:", text = "Datum:",
color = Color.White, color = Color.White,
fontSize = 30.sp fontSize = 20.sp
) )
} }
@@ -489,7 +517,7 @@ fun MarksDetail() {
Text( Text(
text = date, text = date,
color = Color.White, color = Color.White,
fontSize = 23.sp fontSize = 20.sp
) )
} }
} // date } // date
@@ -112,7 +112,7 @@ fun MenuScreen(modifier: Modifier = Modifier) {
Text("Ne") Text("Ne")
} }
} }
) // TODO: THEME DIALOG )
} }
Button(onClick = { Button(onClick = {
@@ -2,20 +2,20 @@ package com.odweta.solon
import android.content.Context import android.content.Context
import android.widget.Toast import android.widget.Toast
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.border import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Visibility import androidx.compose.material.icons.filled.Visibility
import androidx.compose.material.icons.filled.VisibilityOff import androidx.compose.material.icons.filled.VisibilityOff
@@ -106,112 +106,112 @@ fun signInButtonCallback(ctx: Context, coscope: CoroutineScope, buttonText: Stri
} }
} }
@OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun SignInScreen() { fun SignInScreen() {
// handle the back gesture (back swipe form side or back button on bottom android navbar)
BackHandler {
screenToShow.value = Screen.Main
}
var usernameText by remember { mutableStateOf("") } var usernameText by remember { mutableStateOf("") }
var passwordText by remember { mutableStateOf("") } var passwordText by remember { mutableStateOf("") }
val ctx = LocalContext.current val ctx = LocalContext.current
val coscope = rememberCoroutineScope() val coscope = rememberCoroutineScope()
var isPasswordVisible by remember { mutableStateOf(false) } // State for visibility toggle var isPasswordVisible by remember { mutableStateOf(false) } // State for visibility toggle
val visualTransformation = if (isPasswordVisible) VisualTransformation.None else PasswordVisualTransformation() val visualTransformation = if (isPasswordVisible) VisualTransformation.None else PasswordVisualTransformation()
val scrollState = rememberScrollState()
Box( Column(
modifier = Modifier.fillMaxSize(), modifier = Modifier
contentAlignment = Alignment.Center .fillMaxWidth()
.background(Color.Black)
.imePadding(),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) { ) {
Column( // TODO: squishable sign in layout
Image(
painter = painterResource(R.drawable.solon_just_yellow),
contentDescription = "Solon logo",
modifier = Modifier.size(200.dp)
)
TextField(
value = usernameText,
onValueChange = { input -> usernameText = input },
modifier = Modifier modifier = Modifier
.fillMaxSize() .border(width = 5.dp, color = PastelYellow, shape = RoundedCornerShape(
.background(Color.Black) roundedCornerDimen))
.verticalScroll(scrollState), .width(230.dp),
horizontalAlignment = Alignment.CenterHorizontally, colors = TextFieldDefaults.colors(
verticalArrangement = Arrangement.Center focusedTextColor = Color.White, // White text
) { unfocusedTextColor = Color.White, // White text when not focused
Image( focusedContainerColor = Color.Black, // Black background when focused
painter = painterResource(R.drawable.solon_just_yellow), unfocusedContainerColor = Color.Black, // Black background when not focused
contentDescription = "Solon logo", cursorColor = PastelYellow, // Yellow cursor
modifier = Modifier.size(230.dp) focusedIndicatorColor = Color.Black, // Yellow border when focused
) unfocusedIndicatorColor = Color.Black // Yellow border when not focused
),
)
TextField( Spacer(modifier = Modifier.height(20.dp))
value = usernameText,
onValueChange = { input -> usernameText = input },
modifier = Modifier
.border(width = 5.dp, color = PastelYellow, shape = RoundedCornerShape(
roundedCornerDimen))
.width(230.dp),
colors = TextFieldDefaults.colors(
focusedTextColor = Color.White, // White text
unfocusedTextColor = Color.White, // White text when not focused
focusedContainerColor = Color.Black, // Black background when focused
unfocusedContainerColor = Color.Black, // Black background when not focused
cursorColor = PastelYellow, // Yellow cursor
focusedIndicatorColor = Color.Black, // Yellow border when focused
unfocusedIndicatorColor = Color.Black // Yellow border when not focused
),
)
Spacer(modifier = Modifier.height(20.dp)) TextField(
value = passwordText,
TextField( onValueChange = { input -> passwordText = input },
value = passwordText, visualTransformation = visualTransformation,
onValueChange = { input -> passwordText = input }, modifier = Modifier
visualTransformation = visualTransformation, .width(230.dp)
modifier = Modifier .border(
.width(230.dp) width = 5.dp,
.border( color = PastelYellow,
width = 5.dp, shape = RoundedCornerShape(
color = PastelYellow, roundedCornerDimen
shape = RoundedCornerShape(
roundedCornerDimen
)
),
colors = TextFieldDefaults.colors(
focusedTextColor = Color.White, // White text
unfocusedTextColor = Color.White, // White text when not focused
focusedContainerColor = Color.Black, // Black background when focused
unfocusedContainerColor = Color.Black, // Black background when not focused
cursorColor = PastelYellow, // Yellow cursor
focusedIndicatorColor = Color.Black, // Yellow border when focused
unfocusedIndicatorColor = Color.Black // Yellow border when not focused
),
trailingIcon = {
// Toggle button for showing/hiding password
IconButton(onClick = { isPasswordVisible = !isPasswordVisible }) {
Icon(
imageVector = if (isPasswordVisible) Icons.Filled.Visibility else Icons.Filled.VisibilityOff,
contentDescription = if (isPasswordVisible) "Hide password" else "Show password",
tint = Color.Gray // You can customize the icon color
)
}
}
)
Spacer(modifier = Modifier.height(20.dp))
Button(
onClick = {
signInButtonCallback(ctx, coscope, buttonText.value, usernameText, passwordText)
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
) )
.width(230.dp) ),
) { colors = TextFieldDefaults.colors(
Text( focusedTextColor = Color.White, // White text
text = buttonText.value, unfocusedTextColor = Color.White, // White text when not focused
fontSize = 23.sp focusedContainerColor = Color.Black, // Black background when focused
) unfocusedContainerColor = Color.Black, // Black background when not focused
cursorColor = PastelYellow, // Yellow cursor
focusedIndicatorColor = Color.Black, // Yellow border when focused
unfocusedIndicatorColor = Color.Black // Yellow border when not focused
),
trailingIcon = {
// Toggle button for showing/hiding password
IconButton(onClick = { isPasswordVisible = !isPasswordVisible }) {
Icon(
imageVector = if (isPasswordVisible) Icons.Filled.Visibility else Icons.Filled.VisibilityOff,
contentDescription = if (isPasswordVisible) "Hide password" else "Show password",
tint = Color.Gray // You can customize the icon color
)
}
} }
)
Spacer(modifier = Modifier.height(20.dp))
Button(
onClick = {
signInButtonCallback(ctx, coscope, buttonText.value, usernameText, passwordText)
},
colors = ButtonDefaults.buttonColors(
contentColor = Color.White,
containerColor = Color.Black
),
modifier = Modifier
.border(
width = 5.dp,
shape = RoundedCornerShape(roundedCornerDimen),
color = PastelYellow
)
.width(230.dp)
) {
Text(
text = buttonText.value,
fontSize = 23.sp
)
} }
} }
} }
@@ -29,6 +29,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontStyle import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import com.odweta.solon.ui.theme.PastelGreen import com.odweta.solon.ui.theme.PastelGreen
@@ -95,11 +96,9 @@ fun subjectModifier(d: Day, s: Subject, lectureNumber: Int): Modifier {
month = "0$month" month = "0$month"
} }
d.date = "$day. $month."
val dayFormatter = DateTimeFormatter.ofPattern("dd. MM. yyyy") val dayFormatter = DateTimeFormatter.ofPattern("dd. MM. yyyy")
val hourFormatter = DateTimeFormatter.ofPattern("HH:mm:ss") val hourFormatter = DateTimeFormatter.ofPattern("HH:mm:ss")
val dateParsed = LocalDate.parse(d.date + " " + LocalDate.now().year, dayFormatter) val dateParsed = LocalDate.parse("$day. $month." + " " + LocalDate.now().year, dayFormatter)
val startTimeParsed = LocalTime.parse(s.start + ":00", hourFormatter) val startTimeParsed = LocalTime.parse(s.start + ":00", hourFormatter)
val endTimeParsed = LocalTime.parse(s.end + ":00", hourFormatter) val endTimeParsed = LocalTime.parse(s.end + ":00", hourFormatter)
@@ -110,27 +109,22 @@ fun subjectModifier(d: Day, s: Subject, lectureNumber: Int): Modifier {
currentLectureNumber = lectureNumber currentLectureNumber = lectureNumber
} }
val m = Modifier
.fillMaxWidth()
.height(70.dp)
.background(
color = getSubjectColor(s, true), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
return if (lectureNumber == currentLectureNumber && dateParsed == todayDate) { return if (lectureNumber == currentLectureNumber && dateParsed == todayDate) {
Modifier m.border(
.fillMaxWidth() width = 5.dp,
.height(100.dp) color = getSubjectColor(s, false),
.background( shape = RoundedCornerShape(roundedCornerDimen)
color = getSubjectColor(s, true), // decide on the color (transparent) )
shape = RoundedCornerShape(roundedCornerDimen)
)
.border(
width = 5.dp,
color = getSubjectColor(s, false),
shape = RoundedCornerShape(roundedCornerDimen)
)
} else { } else {
Modifier m
.fillMaxWidth()
.height(100.dp)
.background(
color = getSubjectColor(s, true), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
} }
} }
@@ -150,7 +144,7 @@ private fun DayScreen(day: Day) {
Text( Text(
text = "${day.name} ${day.date}", text = "${day.name} ${day.date}",
color = Color.White, color = Color.White,
fontSize = 30.sp, fontSize = 26.sp,
fontWeight = FontWeight.Bold, fontWeight = FontWeight.Bold,
fontStyle = FontStyle.Italic fontStyle = FontStyle.Italic
) )
@@ -249,7 +243,8 @@ private fun DayScreen(day: Day) {
.padding(vertical = 5.dp), .padding(vertical = 5.dp),
contentAlignment = Alignment.Center contentAlignment = Alignment.Center
) { ) {
if (!Parsing.userIsParent()) { // add this to the 'Svoboda' mode maybe later; for now, it is left out
/*if (!Parsing.userIsParent()) {
if ( if (
subject.teacher == "Jindřich Svoboda" && subject.teacher == "Jindřich Svoboda" &&
studentClass == "5. G" studentClass == "5. G"
@@ -260,7 +255,7 @@ private fun DayScreen(day: Day) {
modifier = Modifier.fillMaxSize() modifier = Modifier.fillMaxSize()
) )
} }
} }*/
} }
if (subject.substitute != "2") { if (subject.substitute != "2") {
@@ -278,11 +273,15 @@ private fun DayScreen(day: Day) {
) )
if (!subject.free) { if (!subject.free) {
Text( Box (
text = subject.teacher, contentAlignment = Alignment.BottomEnd
color = Color.White, ) {
fontSize = 12.sp Text(
) text = subject.teacher,
color = Color.White,
fontSize = 12.sp
)
}
} }
} }
} }
@@ -1,15 +1,44 @@
package com.odweta.solon package com.odweta.solon
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
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.sp import androidx.compose.ui.unit.sp
@Composable @Composable
fun ToolbarScreen() { fun ToolbarScreen() {
Text( // make the font size adaptive relative to the length of the user's name
text = toolbarText.value, var toolbarTextSizeAdaptive by remember { mutableStateOf(25.sp) }
fontSize = 25.sp,
color = Color.White if (toolbarText.value.length > 28) {
) toolbarTextSizeAdaptive = 20.sp
}
if (toolbarText.value.length > 32) {
toolbarTextSizeAdaptive = 16.sp
}
if (toolbarText.value.length > 40) {
toolbarTextSizeAdaptive = 12.sp
}
if (toolbarText.value.length > 45) {
toolbarTextSizeAdaptive = 10.sp
}
Box(modifier = Modifier.padding(10.dp)) {
Text(
text = toolbarText.value,
fontSize = toolbarTextSizeAdaptive,
color = Color.White
)
}
} }
@@ -19,11 +19,13 @@ val White = Color(0xFFFFFFFF)
val Transparent = Color(0x00000000) val Transparent = Color(0x00000000)
val PastelRed = Color(0xFFFF6666) val PastelRed = Color(0xFFFF6666)
val PastelOrangeDark = Color(0xFFDC6421)
val PastelGreen = Color(0xFF00CC99) val PastelGreen = Color(0xFF00CC99)
val PastelOrange = Color(0xFFFF9933) val PastelOrange = Color(0xFFFF9933)
val PastelYellow = Color(0xFFFFCC33) val PastelYellow = Color(0xFFFFCC33)
val PastelRedTransparent = Color(0x50FF6666) val PastelRedTransparent = Color(0x50FF6666)
val PastelOrangeDarkTransparent = Color(0x50DC6421)
val PastelGreenTransparent = Color(0x5000CC99) val PastelGreenTransparent = Color(0x5000CC99)
val PastelOrangeTransparent = Color(0x50FF9933) val PastelOrangeTransparent = Color(0x50FF9933)
val PastelYellowTransparent = Color(0x50FFCC33) val PastelYellowTransparent = Color(0x50FFCC33)
+1 -1
View File
@@ -1,6 +1,6 @@
[versions] [versions]
accompanistCoil = "0.30.1" accompanistCoil = "0.30.1"
agp = "8.7.1" agp = "8.7.2"
coilCompose = "2.4.0" coilCompose = "2.4.0"
glide = "4.16.0" glide = "4.16.0"
kotlin = "2.0.0" kotlin = "2.0.0"