mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-31 15:28:20 +01:00
Update grade colors (#231)
This commit is contained in:
parent
66bd566526
commit
514d1e11aa
@ -5,12 +5,13 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Grade
|
||||
import io.github.wulkanowy.utils.colorStringId
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import io.github.wulkanowy.utils.valueColor
|
||||
import io.github.wulkanowy.utils.valueBgColor
|
||||
import kotlinx.android.synthetic.main.dialog_grade.*
|
||||
|
||||
|
||||
@ -57,7 +58,7 @@ class GradeDetailsDialog : DialogFragment() {
|
||||
|
||||
gradeDialogValue.run {
|
||||
text = grade.entry
|
||||
setBackgroundResource(grade.valueColor)
|
||||
setBackgroundResource(grade.valueBgColor)
|
||||
}
|
||||
|
||||
gradeDialogTeacherValue.text = if (grade.teacher.isBlank()) {
|
||||
|
@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
||||
import android.view.View
|
||||
import android.view.View.GONE
|
||||
import android.view.View.VISIBLE
|
||||
import androidx.core.content.ContextCompat
|
||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||
import eu.davidea.flexibleadapter.items.IFlexible
|
||||
@ -14,7 +15,7 @@ import io.github.wulkanowy.utils.toFormattedString
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
import kotlinx.android.synthetic.main.item_grade_details.*
|
||||
|
||||
class GradeDetailsItem(val grade: Grade, private val weightString: String, private val valueColor: Int) :
|
||||
class GradeDetailsItem(val grade: Grade, private val weightString: String, private val valueBgColor: Int) :
|
||||
AbstractFlexibleItem<GradeDetailsItem.ViewHolder>() {
|
||||
|
||||
override fun getLayoutRes() = R.layout.item_grade_details
|
||||
@ -31,7 +32,7 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva
|
||||
holder.run {
|
||||
gradeItemValue.run {
|
||||
text = grade.entry
|
||||
setBackgroundResource(valueColor)
|
||||
setBackgroundResource(valueBgColor)
|
||||
}
|
||||
gradeItemDescription.text = if (grade.description.isNotBlank()) grade.description else grade.gradeSymbol
|
||||
gradeItemDate.text = grade.date.toFormattedString()
|
||||
@ -49,7 +50,7 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva
|
||||
if (grade != other.grade) return false
|
||||
if (grade.id != other.grade.id) return false
|
||||
if (weightString != other.weightString) return false
|
||||
if (valueColor != other.valueColor) return false
|
||||
if (valueBgColor != other.valueBgColor) return false
|
||||
|
||||
return true
|
||||
}
|
||||
@ -58,7 +59,7 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva
|
||||
var result = grade.hashCode()
|
||||
result = 31 * result + grade.id.toInt()
|
||||
result = 31 * result + weightString.hashCode()
|
||||
result = 31 * result + valueColor
|
||||
result = 31 * result + valueBgColor
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import io.github.wulkanowy.utils.FirebaseAnalyticsHelper
|
||||
import io.github.wulkanowy.utils.SchedulersProvider
|
||||
import io.github.wulkanowy.utils.calcAverage
|
||||
import io.github.wulkanowy.utils.changeModifier
|
||||
import io.github.wulkanowy.utils.valueColor
|
||||
import io.github.wulkanowy.utils.valueBgColor
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -151,7 +151,7 @@ class GradeDetailsPresenter @Inject constructor(
|
||||
GradeDetailsItem(
|
||||
grade = item,
|
||||
weightString = view?.weightString.orEmpty(),
|
||||
valueColor = item.valueColor
|
||||
valueBgColor = item.valueBgColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ fun List<GradeSummary>.calcAverage(): Double {
|
||||
}.average().let { if (it.isNaN()) 0.0 else it }
|
||||
}
|
||||
|
||||
inline val Grade.valueColor: Int
|
||||
inline val Grade.valueBgColor: Int
|
||||
get() {
|
||||
return when (value) {
|
||||
6 -> R.color.grade_six
|
||||
|
@ -5,14 +5,15 @@
|
||||
<color name="colorPrimaryLight">#ff6659</color>
|
||||
<color name="colorBackgroundBottomNav">#f0f0f0</color>
|
||||
|
||||
<color name="grade_six">#03a9f4</color>
|
||||
<color name="grade_five">#4caf50</color>
|
||||
<color name="grade_four">#92c400</color>
|
||||
<color name="grade_three">#ffa000</color>
|
||||
<color name="grade_two">#ff5722</color>
|
||||
<color name="grade_one">#d32f2f</color>
|
||||
<color name="grade_default">#607d8b</color>
|
||||
|
||||
<color name="grade_text">#ffffff</color>
|
||||
<color name="grade_six">#91b43c</color>
|
||||
<color name="grade_five">#2cbd92</color>
|
||||
<color name="grade_four">#50b6d6</color>
|
||||
<color name="grade_three">#d2ab24</color>
|
||||
<color name="grade_two">#9071b3</color>
|
||||
<color name="grade_one">#d65757</color>
|
||||
<color name="grade_default">#3d5f9c</color>
|
||||
|
||||
<color name="bottom_nav_background">#303030</color>
|
||||
<color name="bottom_nav_background_inverse">#ffffff</color>
|
||||
|
Loading…
x
Reference in New Issue
Block a user