-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterialUtils.kt
57 lines (53 loc) · 2.36 KB
/
MaterialUtils.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.dzeio.chartsapp.utils
import android.view.View
import com.dzeio.charts.ChartViewInterface
import com.dzeio.charts.series.BarSerie
import com.dzeio.charts.series.LineSerie
import com.google.android.material.color.MaterialColors
object MaterialUtils {
fun materielTheme(chart: ChartViewInterface, view: View) {
chart.yAxis.apply {
textLabel.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorOnPrimaryContainer)
linePaint.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorOnPrimaryContainer)
goalLinePaint.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorError)
}
chart.xAxis.textPaint.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorOnPrimaryContainer)
chart.annotator.apply {
backgroundPaint.color = MaterialColors.getColor(
view,
com.google.android.material.R.attr.colorBackgroundFloating
)
titlePaint.color = MaterialColors.getColor(
view,
com.google.android.material.R.attr.colorOnPrimaryContainer
)
subTitlePaint.color = MaterialColors.getColor(
view,
com.google.android.material.R.attr.colorOnPrimaryContainer
)
}
for (serie in chart.series) {
if (serie is BarSerie) {
serie.apply {
barPaint.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorPrimary)
textPaint.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorOnPrimary)
textExternalPaint.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorPrimary)
}
} else if (serie is LineSerie) {
serie.apply {
linePaint.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorPrimary)
textPaint.color =
MaterialColors.getColor(view, com.google.android.material.R.attr.colorOnPrimary)
}
}
}
}
}