Fix background color

This commit is contained in:
Lucas Lima 2020-08-08 15:40:11 -03:00
parent 10de9f9f32
commit eb9cc87f2a
No known key found for this signature in database
GPG key ID: 049CCC5A365B00D2
8 changed files with 17 additions and 13 deletions

View file

@ -1,6 +1,7 @@
package dev.lucasnlm.antimine.theme.view
import android.content.Context
import android.graphics.Color
import android.graphics.Paint
import android.graphics.RectF
import android.graphics.Typeface
@ -32,7 +33,7 @@ class ThemeAdapter(
Area(4, 1, 1, 3, hasMine = false, mistake = false, mark = Mark.None, isCovered = false),
Area(5, 2, 1, 3, hasMine = true, mistake = false, mark = Mark.Flag, isCovered = true),
Area(6, 0, 2, 0, hasMine = true, mistake = false, mark = Mark.Question, isCovered = true),
Area(7, 1, 2, 0, hasMine = false, mistake = false, mark = Mark.None, isCovered = true),
Area(7, 1, 2, 4, hasMine = false, mistake = false, mark = Mark.None, isCovered = false),
Area(8, 2, 2, 0, hasMine = false, mistake = false, mark = Mark.None, isCovered = true)
)
@ -56,15 +57,13 @@ class ThemeAdapter(
val theme = themes[position]
val paintSettings = createAreaPaintSettings(holder.itemView.context, areaSize)
holder.itemView.run {
area0.bindTheme(minefield[0], theme, paintSettings)
area1.bindTheme(minefield[1], theme, paintSettings)
area2.bindTheme(minefield[2], theme, paintSettings)
area3.bindTheme(minefield[3], theme, paintSettings)
area4.bindTheme(minefield[4], theme, paintSettings)
area5.bindTheme(minefield[5], theme, paintSettings)
area6.bindTheme(minefield[6], theme, paintSettings)
area7.bindTheme(minefield[7], theme, paintSettings)
area8.bindTheme(minefield[8], theme, paintSettings)
arrayOf(area0, area1, area2, area3, area4, area5, area6, area7, area8)
.forEachIndexed { index, areaView -> areaView.bindTheme(minefield[index], theme, paintSettings) }
val color = with (theme.palette.background) {
Color.rgb(Color.red(this), Color.green(this), Color.blue(this))
}
parentGrid.setBackgroundColor(color)
clickTheme.setOnClickListener {
themeViewModel.setTheme(theme)

View file

@ -11,6 +11,7 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:columnCount="3"
android:background="#FFFF0000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"

View file

@ -4,6 +4,7 @@ import androidx.annotation.ColorInt
data class AreaPalette(
@ColorInt val border: Int,
@ColorInt val background: Int,
@ColorInt val covered: Int,
@ColorInt val uncovered: Int,
@ColorInt val minesAround1: Int,

View file

@ -48,6 +48,7 @@ class ThemeRepository(
private fun fromDefaultPalette(context: Context) =
AreaPalette(
border = ContextCompat.getColor(context, R.color.view_cover),
background = ContextCompat.getColor(context, R.color.background),
covered = ContextCompat.getColor(context, R.color.view_cover),
uncovered = ContextCompat.getColor(context, R.color.view_clean),
minesAround1 = ContextCompat.getColor(context, R.color.mines_around_1),

View file

@ -11,6 +11,7 @@ object Themes {
themeNoActionBar = R.style.CustomLightTheme_NoActionBar,
palette = AreaPalette(
border = 0x424242,
background = 0xFFFFFF,
covered = 0x424242,
uncovered = 0xd5d2cc,
minesAround1 = 0x527F8D,
@ -32,6 +33,7 @@ object Themes {
themeNoActionBar = R.style.CustomDarkTheme_NoActionBar,
palette = AreaPalette(
border = 0x171717,
background = 0x212121,
covered = 0x171717,
uncovered = 0x424242,
minesAround1 = 0xd5d2cc,

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#546E7A</color>
<color name="white">#FFFFFF</color>
<color name="primary">#212121</color>
<color name="primary_dark">#212121</color>
<color name="background">#212121</color>
<color name="mines_around_1">#d5d2cc</color>
<color name="mines_around_2">#d5d2cc</color>

View file

@ -4,7 +4,7 @@
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:background">@color/primary</item>
<item name="android:background">@color/background</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
<color name="primary">#FFFFFF</color>
<color name="primary_dark">#9E9E9E</color>
<color name="background">#FFFFFF</color>
<color name="mines_around_1">#527F8D</color>
<color name="mines_around_2">#2B8D43</color>