added prepending free subjects to timetable when the day does not start with subject number 1

This commit is contained in:
Odweta
2024-11-26 18:52:03 +01:00
parent ed981f89de
commit 26317052cc
3 changed files with 33 additions and 7 deletions
@@ -269,6 +269,24 @@ class Parsing {
auxSubjects.add(Subject.empty())
}
// prepend free subjects when day does not start with subject number 1
val newSubjects: MutableList<Subject> = mutableListOf()
var n = auxSubjects[0].number.toInt()
while (n > 1) {
newSubjects.add(
Subject.freeSubject(
number = (n - 1).toString(),
start = "00:00",
end = "00:00"
)
)
n -= 1
}
val finalSubjects: MutableList<Subject> = mutableListOf()
finalSubjects.addAll(newSubjects.reversed())
finalSubjects.addAll(auxSubjects)
for ((i, s) in auxSubjects.withIndex()) {
if (s.free) {
s.start = auxSubjects[i-1].end
@@ -279,7 +297,7 @@ class Parsing {
val day = Day()
day.name = name
day.date = date
day.subjects = auxSubjects
day.subjects = finalSubjects
// get rid of duplicates
val nextSubjects: MutableList<Subject> = mutableListOf()
@@ -1,6 +1,7 @@
package com.odweta.solon
import android.annotation.SuppressLint
import android.graphics.drawable.Drawable
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
@@ -220,8 +221,12 @@ private fun DayScreen(day: Day) {
if (day.subjects.indexOf(subject) > 0) {
Box(modifier = Modifier.height(10.dp)) {
if (subject.name == day.subjects[day.subjects.indexOf(subject) - 1].name) {
val drawable =
if (subject.free) { R.drawable.squiggly_line_green }
else { R.drawable.squiggly_line_yellow }
Image(
painter = painterResource(R.drawable.squiggly_line_yellow),
painter = painterResource(drawable),
contentDescription = "Spojovač stejných předmětů",
modifier = Modifier.fillMaxSize()
)
@@ -324,11 +329,14 @@ private fun DayScreen(day: Day) {
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.End
) {
Text(
text = "${subject.start}${subject.end}",
color = Color.White,
fontSize = 21.sp
)
// show only for non prepended free lectures
if ((subject.free && subject.start != "00:00" && subject.end != "00:00") || !subject.free) {
Text(
text = "${subject.start}${subject.end}",
color = Color.White,
fontSize = 21.sp
)
}
if (!subject.free) {
Box (
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB