navbar working
This commit is contained in:
@@ -66,8 +66,8 @@ object BackButtonFactory: BackButtonFactoryInterface {
|
||||
override fun get(type: BackButtonType): @Composable () -> Unit {
|
||||
return when (type) {
|
||||
BackButtonType.Menu -> { { BackButton({ isShowing = IsShowing.Menu }) } }
|
||||
BackButtonType.MarksAll -> { { BackButton({ marksShow = MarksShow.All }) } }
|
||||
BackButtonType.MarksSubject -> { { BackButton({ marksShow = MarksShow.Subject }) } }
|
||||
BackButtonType.MarksAll -> { { BackButton({ global.marksDepthLevel = MarksDepthLevel.All }) } }
|
||||
BackButtonType.MarksSubject -> { { BackButton({ global.marksDepthLevel = MarksDepthLevel.Subject }) } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,6 +296,10 @@ class Global {
|
||||
var isAPISetUp by mutableStateOf(false)
|
||||
var launched by mutableStateOf(false)
|
||||
var refreshed by mutableStateOf(false)
|
||||
var marksDepthLevel by mutableStateOf(MarksDepthLevel.All)
|
||||
|
||||
var subjectToShow by mutableStateOf("")
|
||||
var markToShow by mutableStateOf(Mark())
|
||||
|
||||
inner class FilePaths {
|
||||
val accountData: String = "account_data.txt"
|
||||
|
||||
@@ -46,22 +46,18 @@ import com.odweta.solon.ui.theme.PastelYellowTransparent
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
enum class MarksShow {
|
||||
enum class MarksDepthLevel {
|
||||
All,
|
||||
Subject,
|
||||
Detail
|
||||
}
|
||||
|
||||
var marksShow by mutableStateOf(MarksShow.All)
|
||||
private var subjectToShow: String = ""
|
||||
private var markToShow: Mark = Mark()
|
||||
|
||||
@Composable
|
||||
fun MarksScreen() {
|
||||
when (marksShow) {
|
||||
MarksShow.All -> MarksAll()
|
||||
MarksShow.Subject -> MarksSubject()
|
||||
MarksShow.Detail -> MarksDetail()
|
||||
when (global.marksDepthLevel) {
|
||||
MarksDepthLevel.All -> MarksAll()
|
||||
MarksDepthLevel.Subject -> MarksSubject()
|
||||
MarksDepthLevel.Detail -> MarksDetail()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,8 +138,8 @@ fun MarksAll() {
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
)
|
||||
.clickable {
|
||||
marksShow = MarksShow.Subject
|
||||
subjectToShow = subject
|
||||
global.marksDepthLevel = MarksDepthLevel.Subject
|
||||
global.subjectToShow = subject
|
||||
}
|
||||
} else {
|
||||
Modifier
|
||||
@@ -154,8 +150,8 @@ fun MarksAll() {
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
)
|
||||
.clickable {
|
||||
marksShow = MarksShow.Subject
|
||||
subjectToShow = subject
|
||||
global.marksDepthLevel = MarksDepthLevel.Subject
|
||||
global.subjectToShow = subject
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +261,7 @@ fun MarksAll() {
|
||||
fun MarksSubject() {
|
||||
// handle the back gesture (back swipe form side or back button on bottom android navbar)
|
||||
BackHandler {
|
||||
marksShow = MarksShow.All
|
||||
global.marksDepthLevel = MarksDepthLevel.All
|
||||
}
|
||||
|
||||
val scrollState = rememberScrollState()
|
||||
@@ -291,7 +287,7 @@ fun MarksSubject() {
|
||||
.border(
|
||||
width = 5.dp,
|
||||
color = getAvgColor(
|
||||
Util.avg(marks[subjectToShow]!!),
|
||||
Util.avg(marks[global.subjectToShow]!!),
|
||||
true
|
||||
),
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
@@ -300,7 +296,7 @@ fun MarksSubject() {
|
||||
Color.Black
|
||||
} else {
|
||||
getAvgColor(
|
||||
Util.avg(marks[subjectToShow]!!)
|
||||
Util.avg(marks[global.subjectToShow]!!)
|
||||
)
|
||||
},
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
@@ -308,7 +304,7 @@ fun MarksSubject() {
|
||||
.padding(vertical = 15.dp),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
val currAvg = Util.avg(marks[subjectToShow]!!).replace(".", ",")
|
||||
val currAvg = Util.avg(marks[global.subjectToShow]!!).replace(".", ",")
|
||||
var textToShow = currAvg
|
||||
if (currAvg.length == 3 && currAvg[2] == '0') {
|
||||
textToShow = currAvg[0].toString()
|
||||
@@ -325,7 +321,7 @@ fun MarksSubject() {
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
|
||||
Text(
|
||||
text = subjectNameMap[subjectToShow]!!,
|
||||
text = subjectNameMap[global.subjectToShow]!!,
|
||||
color = Color.White,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 30.sp,
|
||||
@@ -349,7 +345,7 @@ fun MarksSubject() {
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
|
||||
Column(modifier = Modifier.verticalScroll(scrollState)) {
|
||||
for ((i, mark) in marks[subjectToShow]!!.withIndex()) {
|
||||
for ((i, mark) in marks[global.subjectToShow]!!.withIndex()) {
|
||||
if (i > 0) {
|
||||
Spacer(modifier = Modifier.height(10.dp))
|
||||
}
|
||||
@@ -371,8 +367,8 @@ fun MarksSubject() {
|
||||
)
|
||||
.padding(vertical = 10.dp)
|
||||
.clickable {
|
||||
markToShow = mark
|
||||
marksShow = MarksShow.Detail
|
||||
global.markToShow = mark
|
||||
global.marksDepthLevel = MarksDepthLevel.Detail
|
||||
}
|
||||
) {
|
||||
Box(
|
||||
@@ -424,9 +420,7 @@ fun MarksSubject() {
|
||||
@Composable
|
||||
fun MarksDetail() {
|
||||
// handle the back gesture (back swipe form side or back button on bottom android navbar)
|
||||
BackHandler {
|
||||
marksShow = MarksShow.Subject
|
||||
}
|
||||
BackHandler { global.marksDepthLevel = MarksDepthLevel.Subject }
|
||||
|
||||
val scrollState = rememberScrollState()
|
||||
|
||||
@@ -452,7 +446,7 @@ fun MarksDetail() {
|
||||
.border(
|
||||
width = borderWidthDimen,
|
||||
color = getAvgColor(
|
||||
Util.avg(mutableListOf(markToShow)),
|
||||
Util.avg(mutableListOf(global.markToShow)),
|
||||
true
|
||||
),
|
||||
shape = RoundedCornerShape(roundedCornerDimen)
|
||||
@@ -462,7 +456,7 @@ fun MarksDetail() {
|
||||
Color.Black
|
||||
} else {
|
||||
getAvgColor(
|
||||
Util.avg(mutableListOf(markToShow))
|
||||
Util.avg(mutableListOf(global.markToShow))
|
||||
)
|
||||
}
|
||||
)
|
||||
@@ -470,7 +464,7 @@ fun MarksDetail() {
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = markToShow.grade,
|
||||
text = global.markToShow.grade,
|
||||
color = Color.White,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 25.sp
|
||||
@@ -482,7 +476,7 @@ fun MarksDetail() {
|
||||
|
||||
Row {
|
||||
Text(
|
||||
text = markToShow.theme,
|
||||
text = global.markToShow.theme,
|
||||
color = Color.White,
|
||||
textAlign = TextAlign.Center,
|
||||
fontSize = 30.sp,
|
||||
@@ -540,7 +534,7 @@ fun MarksDetail() {
|
||||
contentAlignment = Alignment.CenterEnd
|
||||
) {
|
||||
Text(
|
||||
text = markToShow.weight.replace(".", ","),
|
||||
text = global.markToShow.weight.replace(".", ","),
|
||||
color = Color.White,
|
||||
fontSize = 20.sp
|
||||
)
|
||||
@@ -582,7 +576,7 @@ fun MarksDetail() {
|
||||
.weight(1f),
|
||||
contentAlignment = Alignment.CenterEnd
|
||||
) {
|
||||
val rawDate: String = markToShow.date.split("T")[0]
|
||||
val rawDate: String = global.markToShow.date.split("T")[0]
|
||||
val year = rawDate.split("-")[0]
|
||||
val month = rawDate.split("-")[1]
|
||||
val day = rawDate.split("-")[2]
|
||||
|
||||
@@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material.icons.Icons
|
||||
@@ -17,8 +16,6 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -26,9 +23,6 @@ import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.odweta.solon.ui.theme.PastelYellow
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
private var timetableColor: MutableState<Color> = mutableStateOf(PastelYellow)
|
||||
private var marksColor: MutableState<Color> = mutableStateOf(Color.White)
|
||||
@@ -73,6 +67,7 @@ fun NavbarScreen() {
|
||||
timetableColor.value = PastelYellow
|
||||
marksColor.value = Color.White
|
||||
menuColor.value = Color.White
|
||||
global.currentScreenElement = ScreenElement.Timetable
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
contentColor = timetableColor.value,
|
||||
@@ -94,7 +89,8 @@ fun NavbarScreen() {
|
||||
timetableColor.value = Color.White
|
||||
marksColor.value = PastelYellow
|
||||
menuColor.value = Color.White
|
||||
marksShow = MarksShow.All
|
||||
global.currentScreenElement = ScreenElement.Marks
|
||||
global.marksDepthLevel = MarksDepthLevel.All
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
contentColor = marksColor.value,
|
||||
@@ -116,6 +112,7 @@ fun NavbarScreen() {
|
||||
timetableColor.value = Color.White
|
||||
marksColor.value = Color.White
|
||||
menuColor.value = PastelYellow
|
||||
global.currentScreenElement = ScreenElement.Menu
|
||||
},
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
contentColor = menuColor.value,
|
||||
|
||||
@@ -531,9 +531,15 @@ private fun DayScreen(day: Day) {
|
||||
})
|
||||
|
||||
if (
|
||||
(global.lectureNotes[lectureId] != null && global.lectureNotes[lectureId]?.note?.value != "") ||
|
||||
(global.lectureNotes[lectureId] != null && global.lectureNotes[lectureId]?.type?.value != LectureNoteType.Normal) &&
|
||||
(global.lectureNotes[lectureId] != null && global.lectureNotes[lectureId]?.type?.value != LectureNoteType.Other)
|
||||
(global.lectureNotes[global.selectedLecture] != null &&
|
||||
global.lectureNotes[global.selectedLecture]
|
||||
?.note?.value != "") ||
|
||||
(global.lectureNotes[global.selectedLecture] != null &&
|
||||
global.lectureNotes[global.selectedLecture]
|
||||
?.type?.value != LectureNoteType.Normal) &&
|
||||
(global.lectureNotes[global.selectedLecture] != null &&
|
||||
global.lectureNotes[global.selectedLecture]
|
||||
?.type?.value != LectureNoteType.Other)
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier.padding(start = 3.dp, top = 1.dp),
|
||||
|
||||
@@ -80,12 +80,12 @@ object StatusFactory: StatusFactoryInterface {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
global.refreshed = false
|
||||
val anim = listOf(
|
||||
"Přihlašování",
|
||||
"Přihlašování.",
|
||||
"Přihlašování..",
|
||||
"Přihlašování...",
|
||||
"Přihlašování..",
|
||||
"Přihlašování."
|
||||
"Načítání nových dat",
|
||||
"Načítání nových dat.",
|
||||
"Načítání nových dat..",
|
||||
"Načítání nových dat...",
|
||||
"Načítání nových dat..",
|
||||
"Načítání nových dat."
|
||||
)
|
||||
var i = 0
|
||||
while (!global.refreshed) {
|
||||
|
||||
Reference in New Issue
Block a user