added prepending free subjects to timetable when the day does not start with subject number 1
This commit is contained in:
@@ -269,6 +269,24 @@ class Parsing {
|
|||||||
auxSubjects.add(Subject.empty())
|
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()) {
|
for ((i, s) in auxSubjects.withIndex()) {
|
||||||
if (s.free) {
|
if (s.free) {
|
||||||
s.start = auxSubjects[i-1].end
|
s.start = auxSubjects[i-1].end
|
||||||
@@ -279,7 +297,7 @@ class Parsing {
|
|||||||
val day = Day()
|
val day = Day()
|
||||||
day.name = name
|
day.name = name
|
||||||
day.date = date
|
day.date = date
|
||||||
day.subjects = auxSubjects
|
day.subjects = finalSubjects
|
||||||
|
|
||||||
// get rid of duplicates
|
// get rid of duplicates
|
||||||
val nextSubjects: MutableList<Subject> = mutableListOf()
|
val nextSubjects: MutableList<Subject> = mutableListOf()
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.odweta.solon
|
package com.odweta.solon
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@@ -220,8 +221,12 @@ private fun DayScreen(day: Day) {
|
|||||||
if (day.subjects.indexOf(subject) > 0) {
|
if (day.subjects.indexOf(subject) > 0) {
|
||||||
Box(modifier = Modifier.height(10.dp)) {
|
Box(modifier = Modifier.height(10.dp)) {
|
||||||
if (subject.name == day.subjects[day.subjects.indexOf(subject) - 1].name) {
|
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(
|
Image(
|
||||||
painter = painterResource(R.drawable.squiggly_line_yellow),
|
painter = painterResource(drawable),
|
||||||
contentDescription = "Spojovač stejných předmětů",
|
contentDescription = "Spojovač stejných předmětů",
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
)
|
)
|
||||||
@@ -324,11 +329,14 @@ private fun DayScreen(day: Day) {
|
|||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
horizontalAlignment = Alignment.End
|
horizontalAlignment = Alignment.End
|
||||||
) {
|
) {
|
||||||
Text(
|
// show only for non prepended free lectures
|
||||||
text = "${subject.start}–${subject.end}",
|
if ((subject.free && subject.start != "00:00" && subject.end != "00:00") || !subject.free) {
|
||||||
color = Color.White,
|
Text(
|
||||||
fontSize = 21.sp
|
text = "${subject.start}–${subject.end}",
|
||||||
)
|
color = Color.White,
|
||||||
|
fontSize = 21.sp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (!subject.free) {
|
if (!subject.free) {
|
||||||
Box (
|
Box (
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
Reference in New Issue
Block a user