made the AMOLED mode work

This commit is contained in:
Odweta
2024-11-30 12:06:51 +01:00
parent 80e5581f45
commit 5a98379d3f
2 changed files with 167 additions and 69 deletions
@@ -46,6 +46,7 @@ import com.odweta.solon.ui.theme.PastelRed
import com.odweta.solon.ui.theme.PastelRedTransparent
import com.odweta.solon.ui.theme.PastelYellow
import com.odweta.solon.ui.theme.PastelYellowTransparent
import kotlin.math.round
enum class MarksShow {
All,
@@ -114,6 +115,64 @@ fun MarksAll() {
.verticalScroll(scrollState)
) {
for ((subject, markList) in marks) {
val amoledModifier = if (settingsData.useAmoledMode.checked.value) {
Modifier
.width(150.dp)
.fillMaxHeight()
.border(
width = borderWidthDimen,
color = getAvgColor(Util.avg(markList), true), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
} else {
Modifier
.width(150.dp)
.fillMaxHeight()
.background(
color = getAvgColor(Util.avg(markList)), // decide on the color (not transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
}
val amoledModifierBackground = if (settingsData.useAmoledMode.checked.value) {
Modifier
.fillMaxWidth()
.height(70.dp)
.border(
width = borderWidthDimen,
color = getAvgColor(Util.avg(markList), true), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
.clickable {
marksShow.value = MarksShow.Subject
subjectToShow = subject
}
} else {
Modifier
.fillMaxWidth()
.height(70.dp)
.background(
color = getAvgColor(Util.avg(markList)), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
.clickable {
marksShow.value = MarksShow.Subject
subjectToShow = subject
}
}
val amoledSpacerModifier = if (settingsData.useAmoledMode.checked.value) {
Modifier
.width(10.dp)
.fillMaxHeight()
.background(getAvgColor(Util.avg(markList)))
} else {
Modifier
.width(10.dp)
.fillMaxHeight()
.background(Color.Black)
}
var marksString = ""
for (m in 0 until markList.size-1) {
if (markList[m].grade in "0123456789") {
@@ -127,26 +186,10 @@ fun MarksAll() {
}
Row(
modifier = Modifier
.fillMaxWidth()
.height(70.dp)
.background(
color = getAvgColor(Util.avg(markList)), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
.clickable {
marksShow.value = MarksShow.Subject
subjectToShow = subject
}
modifier = amoledModifierBackground
) {
Row(
modifier = Modifier
.width(150.dp)
.fillMaxHeight()
.background(
color = getAvgColor(Util.avg(markList)), // decide on the color (not transparent)
shape = RoundedCornerShape(roundedCornerDimen)
),
modifier = amoledModifier,
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
@@ -161,10 +204,7 @@ fun MarksAll() {
)
Box(
modifier = Modifier
.width(10.dp)
.fillMaxHeight()
.background(Color.Black)
modifier = amoledSpacerModifier
)
val currAvg = Util.avg(markList).replace(".", ",")
@@ -257,10 +297,14 @@ fun MarksSubject() {
),
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(
getAvgColor(
Util.avg(marks[subjectToShow]!!)
)
.background(color = if (settingsData.useAmoledMode.checked.value) {
Color.Black
} else {
getAvgColor(
Util.avg(marks[subjectToShow]!!)
)
},
shape = RoundedCornerShape(roundedCornerDimen)
)
.padding(vertical = 15.dp),
contentAlignment = Alignment.Center
@@ -281,23 +325,27 @@ fun MarksSubject() {
Spacer(modifier = Modifier.height(20.dp))
//Box(modifier = Modifier.height(100.dp)) {
Text(
text = subjectNameMap[subjectToShow]!!,
color = Color.White,
textAlign = TextAlign.Center,
fontSize = 30.sp,
modifier = Modifier
.fillMaxWidth()
.border(
width = 5.dp,
color = PastelYellow,
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(PastelYellowTransparent)
.padding(vertical = 20.dp)
) // subject
//}
Text(
text = subjectNameMap[subjectToShow]!!,
color = Color.White,
textAlign = TextAlign.Center,
fontSize = 30.sp,
modifier = Modifier
.fillMaxWidth()
.border(
width = 5.dp,
color = PastelYellow,
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(color = if (settingsData.useAmoledMode.checked.value) {
Color.Black
} else {
PastelYellowTransparent
},
shape = RoundedCornerShape(roundedCornerDimen)
)
.padding(vertical = 20.dp)
) // subject
Spacer(modifier = Modifier.height(20.dp))
@@ -311,8 +359,14 @@ fun MarksSubject() {
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 5.dp)
.background(
color = getAvgColor(mark.grade),
.background(color = if (settingsData.useAmoledMode.checked.value) {
Color.Black
} else {
getAvgColor(
Util.avg(marks[subjectToShow]!!)
)
},
shape = RoundedCornerShape(roundedCornerDimen)
)
.padding(vertical = 10.dp)
@@ -411,9 +465,13 @@ fun MarksDetail() {
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(
getAvgColor(
Util.avg(marks[subjectToShow]!!)
)
if (settingsData.useAmoledMode.checked.value) {
Color.Black
} else {
getAvgColor(
Util.avg(marks[subjectToShow]!!)
)
}
)
.padding(vertical = 15.dp),
contentAlignment = Alignment.Center
@@ -443,7 +501,12 @@ fun MarksDetail() {
color = PastelYellow,
shape = RoundedCornerShape(roundedCornerDimen)
)
.background(PastelYellowTransparent)
.background(if (settingsData.useAmoledMode.checked.value) {
Color.Black
} else {
PastelYellowTransparent
}
)
.padding(vertical = 20.dp)
) // description
//}
@@ -456,7 +519,11 @@ fun MarksDetail() {
.fillMaxWidth()
.padding(horizontal = 5.dp)
.background(
color = PastelYellowTransparent,
color = if (settingsData.useAmoledMode.checked.value) {
Color.Black
} else {
PastelYellowTransparent
},
shape = RoundedCornerShape(roundedCornerDimen)
)
.padding(vertical = 20.dp, horizontal = 10.dp)
@@ -495,7 +562,11 @@ fun MarksDetail() {
.fillMaxWidth()
.padding(horizontal = 5.dp)
.background(
color = PastelYellowTransparent,
color = if (settingsData.useAmoledMode.checked.value) {
Color.Black
} else {
PastelYellowTransparent
},
shape = RoundedCornerShape(roundedCornerDimen)
)
.padding(vertical = 20.dp, horizontal = 10.dp)
@@ -170,17 +170,28 @@ fun subjectModifier(d: Day, s: Subject, lectureNumber: Int): Modifier {
currentLectureNumber = lectureNumber
}
val m = Modifier
.fillMaxWidth()
.height(70.dp)
.background(
color = getSubjectColor(s, true), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
val m = if (settingsData.useAmoledMode.checked.value) {
Modifier
.fillMaxWidth()
.height(70.dp)
.border(
width = borderWidthDimen,
color = getSubjectColor(s, false), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
} else {
Modifier
.fillMaxWidth()
.height(70.dp)
.background(
color = getSubjectColor(s, true), // decide on the color (transparent)
shape = RoundedCornerShape(roundedCornerDimen)
)
}
return if (lectureNumber == currentLectureNumber && dateParsed == todayDate) {
m.border(
width = 5.dp,
width = borderWidthDimen,
color = getSubjectColor(s, false),
shape = RoundedCornerShape(roundedCornerDimen)
)
@@ -220,6 +231,31 @@ private fun DayScreen(day: Day) {
.verticalScroll(scrollState)
) {
for (subject in day.subjects) {
val amoledModifier = if (settingsData.useAmoledMode.checked.value) {
Modifier
.width(50.dp)
.fillMaxHeight()
.border(
width = borderWidthDimen,
color = getSubjectColor(
subject,
false
),
shape = RoundedCornerShape(roundedCornerDimen)
)
} else {
Modifier
.width(50.dp)
.fillMaxHeight()
.background(
color = getSubjectColor(
subject,
true
),
shape = RoundedCornerShape(roundedCornerDimen)
)
}
if (day.subjects.indexOf(subject) > 0) {
Box(modifier = Modifier.height(10.dp)) {
if (subject.name == day.subjects[day.subjects.indexOf(subject) - 1].name) {
@@ -241,16 +277,7 @@ private fun DayScreen(day: Day) {
) {
if (subject.substitute != "2") {
Box(
modifier = Modifier
.width(50.dp)
.fillMaxHeight()
.background(
color = getSubjectColor(
subject,
true
), // decide on the color (not transparent)
shape = RoundedCornerShape(roundedCornerDimen)
),
modifier = amoledModifier,
contentAlignment = Alignment.Center
) {
Text(