mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 15:28:20 +01:00
Follow current grade scheme in stats chart (#277)
This commit is contained in:
parent
2621e5680d
commit
35f1fe8d61
@ -40,7 +40,18 @@ class GradeStatisticsFragment : BaseSessionFragment(), GradeStatisticsView, Grad
|
|||||||
override val isViewEmpty
|
override val isViewEmpty
|
||||||
get() = gradeStatisticsChart.isEmpty
|
get() = gradeStatisticsChart.isEmpty
|
||||||
|
|
||||||
private val gradeColors = listOf(
|
private lateinit var gradeColors: List<Pair<Int, Int>>
|
||||||
|
|
||||||
|
private val vulcanGradeColors = listOf(
|
||||||
|
6 to R.color.grade_vulcan_six,
|
||||||
|
5 to R.color.grade_vulcan_five,
|
||||||
|
4 to R.color.grade_vulcan_four,
|
||||||
|
3 to R.color.grade_vulcan_three,
|
||||||
|
2 to R.color.grade_vulcan_two,
|
||||||
|
1 to R.color.grade_vulcan_one
|
||||||
|
)
|
||||||
|
|
||||||
|
private val materialGradeColors = listOf(
|
||||||
6 to R.color.grade_material_six,
|
6 to R.color.grade_material_six,
|
||||||
5 to R.color.grade_material_five,
|
5 to R.color.grade_material_five,
|
||||||
4 to R.color.grade_material_four,
|
4 to R.color.grade_material_four,
|
||||||
@ -72,13 +83,6 @@ class GradeStatisticsFragment : BaseSessionFragment(), GradeStatisticsView, Grad
|
|||||||
minAngleForSlices = 25f
|
minAngleForSlices = 25f
|
||||||
legend.apply {
|
legend.apply {
|
||||||
textColor = context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
textColor = context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||||
setCustom(gradeLabels.mapIndexed { i, it ->
|
|
||||||
LegendEntry().apply {
|
|
||||||
label = it
|
|
||||||
formColor = ContextCompat.getColor(context, gradeColors[i].second)
|
|
||||||
form = Legend.LegendForm.SQUARE
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +107,12 @@ class GradeStatisticsFragment : BaseSessionFragment(), GradeStatisticsView, Grad
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateData(items: List<GradeStatistics>) {
|
override fun updateData(items: List<GradeStatistics>, theme: String) {
|
||||||
|
gradeColors = when (theme) {
|
||||||
|
"vulcan" -> vulcanGradeColors
|
||||||
|
else -> materialGradeColors
|
||||||
|
}
|
||||||
|
|
||||||
gradeStatisticsChart.run {
|
gradeStatisticsChart.run {
|
||||||
data = PieData(PieDataSet(items.map {
|
data = PieData(PieDataSet(items.map {
|
||||||
PieEntry(it.amount.toFloat(), it.grade.toString())
|
PieEntry(it.amount.toFloat(), it.grade.toString())
|
||||||
@ -124,6 +133,15 @@ class GradeStatisticsFragment : BaseSessionFragment(), GradeStatisticsView, Grad
|
|||||||
centerText = items.fold(0) { acc, it -> acc + it.amount }
|
centerText = items.fold(0) { acc, it -> acc + it.amount }
|
||||||
.let { resources.getQuantityString(R.plurals.grade_number_item, it, it) }
|
.let { resources.getQuantityString(R.plurals.grade_number_item, it, it) }
|
||||||
}
|
}
|
||||||
|
legend.apply {
|
||||||
|
setCustom(gradeLabels.mapIndexed { i, it ->
|
||||||
|
LegendEntry().apply {
|
||||||
|
label = it
|
||||||
|
formColor = ContextCompat.getColor(context, gradeColors[i].second)
|
||||||
|
form = Legend.LegendForm.SQUARE
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package io.github.wulkanowy.ui.modules.grade.statistics
|
|||||||
|
|
||||||
import io.github.wulkanowy.data.db.entities.Subject
|
import io.github.wulkanowy.data.db.entities.Subject
|
||||||
import io.github.wulkanowy.data.repositories.gradestatistics.GradeStatisticsRepository
|
import io.github.wulkanowy.data.repositories.gradestatistics.GradeStatisticsRepository
|
||||||
|
import io.github.wulkanowy.data.repositories.preferences.PreferencesRepository
|
||||||
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
import io.github.wulkanowy.data.repositories.semester.SemesterRepository
|
||||||
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
import io.github.wulkanowy.data.repositories.student.StudentRepository
|
||||||
import io.github.wulkanowy.data.repositories.subject.SubjectRepository
|
import io.github.wulkanowy.data.repositories.subject.SubjectRepository
|
||||||
@ -18,6 +19,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
|||||||
private val subjectRepository: SubjectRepository,
|
private val subjectRepository: SubjectRepository,
|
||||||
private val studentRepository: StudentRepository,
|
private val studentRepository: StudentRepository,
|
||||||
private val semesterRepository: SemesterRepository,
|
private val semesterRepository: SemesterRepository,
|
||||||
|
private val preferencesRepository: PreferencesRepository,
|
||||||
private val schedulers: SchedulersProvider,
|
private val schedulers: SchedulersProvider,
|
||||||
private val analytics: FirebaseAnalyticsHelper
|
private val analytics: FirebaseAnalyticsHelper
|
||||||
) : BaseSessionPresenter<GradeStatisticsView>(errorHandler) {
|
) : BaseSessionPresenter<GradeStatisticsView>(errorHandler) {
|
||||||
@ -133,7 +135,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
|||||||
view?.run {
|
view?.run {
|
||||||
showEmpty(it.isEmpty())
|
showEmpty(it.isEmpty())
|
||||||
showContent(it.isNotEmpty())
|
showContent(it.isNotEmpty())
|
||||||
updateData(it)
|
updateData(it, preferencesRepository.gradeColorTheme)
|
||||||
}
|
}
|
||||||
analytics.logEvent("load_grade_statistics", "items" to it.size, "force_refresh" to forceRefresh)
|
analytics.logEvent("load_grade_statistics", "items" to it.size, "force_refresh" to forceRefresh)
|
||||||
}) {
|
}) {
|
||||||
|
@ -11,7 +11,7 @@ interface GradeStatisticsView : BaseSessionView {
|
|||||||
|
|
||||||
fun updateSubjects(data: ArrayList<String>)
|
fun updateSubjects(data: ArrayList<String>)
|
||||||
|
|
||||||
fun updateData(items: List<GradeStatistics>)
|
fun updateData(items: List<GradeStatistics>, theme: String)
|
||||||
|
|
||||||
fun showSubjects(show: Boolean)
|
fun showSubjects(show: Boolean)
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ fun Grade.getBackgroundColor(theme: String): Int {
|
|||||||
"20A4F7" -> R.color.grade_blue
|
"20A4F7" -> R.color.grade_blue
|
||||||
"6ECD07" -> R.color.grade_green
|
"6ECD07" -> R.color.grade_green
|
||||||
"B16CF1" -> R.color.grade_purple
|
"B16CF1" -> R.color.grade_purple
|
||||||
else -> R.color.grade_default
|
else -> R.color.grade_material_default
|
||||||
}
|
}
|
||||||
"material" -> when (value) {
|
"material" -> when (value) {
|
||||||
6 -> R.color.grade_material_six
|
6 -> R.color.grade_material_six
|
||||||
@ -39,7 +39,7 @@ fun Grade.getBackgroundColor(theme: String): Int {
|
|||||||
3 -> R.color.grade_material_three
|
3 -> R.color.grade_material_three
|
||||||
2 -> R.color.grade_material_two
|
2 -> R.color.grade_material_two
|
||||||
1 -> R.color.grade_material_one
|
1 -> R.color.grade_material_one
|
||||||
else -> R.color.grade_default
|
else -> R.color.grade_material_default
|
||||||
}
|
}
|
||||||
else -> when (value) {
|
else -> when (value) {
|
||||||
6 -> R.color.grade_vulcan_six
|
6 -> R.color.grade_vulcan_six
|
||||||
@ -48,7 +48,7 @@ fun Grade.getBackgroundColor(theme: String): Int {
|
|||||||
3 -> R.color.grade_vulcan_three
|
3 -> R.color.grade_vulcan_three
|
||||||
2 -> R.color.grade_vulcan_two
|
2 -> R.color.grade_vulcan_two
|
||||||
1 -> R.color.grade_vulcan_one
|
1 -> R.color.grade_vulcan_one
|
||||||
else -> R.color.grade_default
|
else -> R.color.grade_vulcan_default
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:background="@color/grade_default"
|
android:background="@color/grade_material_default"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:textColor="@color/grade_text"
|
android:textColor="@color/grade_text"
|
||||||
android:textSize="30sp"
|
android:textSize="30sp"
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
android:layout_width="45dp"
|
android:layout_width="45dp"
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:background="@color/grade_default"
|
android:background="@color/grade_material_default"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:maxLength="5"
|
android:maxLength="5"
|
||||||
android:textColor="@color/grade_text"
|
android:textColor="@color/grade_text"
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
<color name="colorPrimaryLight">#ff6659</color>
|
<color name="colorPrimaryLight">#ff6659</color>
|
||||||
<color name="colorBackgroundBottomNav">#f0f0f0</color>
|
<color name="colorBackgroundBottomNav">#f0f0f0</color>
|
||||||
|
|
||||||
<color name="grade_default">#607d8b</color>
|
|
||||||
<color name="grade_text">#ffffff</color>
|
<color name="grade_text">#ffffff</color>
|
||||||
|
|
||||||
<color name="grade_black">#424242</color>
|
<color name="grade_black">#424242</color>
|
||||||
@ -20,6 +19,7 @@
|
|||||||
<color name="grade_material_three">#ffa000</color>
|
<color name="grade_material_three">#ffa000</color>
|
||||||
<color name="grade_material_two">#ff5722</color>
|
<color name="grade_material_two">#ff5722</color>
|
||||||
<color name="grade_material_one">#d32f2f</color>
|
<color name="grade_material_one">#d32f2f</color>
|
||||||
|
<color name="grade_material_default">#607d8b</color>
|
||||||
|
|
||||||
<color name="grade_vulcan_six">#91b43c</color>
|
<color name="grade_vulcan_six">#91b43c</color>
|
||||||
<color name="grade_vulcan_five">#2cbd92</color>
|
<color name="grade_vulcan_five">#2cbd92</color>
|
||||||
@ -27,6 +27,7 @@
|
|||||||
<color name="grade_vulcan_three">#d2ab24</color>
|
<color name="grade_vulcan_three">#d2ab24</color>
|
||||||
<color name="grade_vulcan_two">#9071b3</color>
|
<color name="grade_vulcan_two">#9071b3</color>
|
||||||
<color name="grade_vulcan_one">#d65757</color>
|
<color name="grade_vulcan_one">#d65757</color>
|
||||||
|
<color name="grade_vulcan_default">#3d5f9c</color>
|
||||||
|
|
||||||
<color name="bottom_nav_background">#303030</color>
|
<color name="bottom_nav_background">#303030</color>
|
||||||
<color name="bottom_nav_background_inverse">#ffffff</color>
|
<color name="bottom_nav_background_inverse">#ffffff</color>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user