Added color pickers

This commit is contained in:
Hemanth S 2020-05-21 01:58:38 +05:30
parent b42303f33a
commit 5ae53c2dc1
19 changed files with 70 additions and 72 deletions

View file

@ -14,10 +14,13 @@
package code.name.monkey.retromusic.extensions
import android.app.Dialog
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.Color
import androidx.annotation.AttrRes
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
@ -27,28 +30,38 @@ fun Int.ripAlpha(): Int {
return ColorUtil.stripAlpha(this)
}
fun Context.accentColor(): Int {
return ThemeStore.accentColor(this)
}
fun Context.surfaceColor(): Int {
return ATHUtil.resolveColor(this, R.attr.colorSurface, Color.WHITE)
}
fun Dialog.colorControlNormal() = resolveColor(android.R.attr.colorControlNormal)
fun Toolbar.backgroundTintList() {
val surfaceColor = ATHUtil.resolveColor(context, R.attr.colorSurface, Color.BLACK)
val colorStateList = ColorStateList.valueOf(surfaceColor)
backgroundTintList = colorStateList
}
fun Context.textColorSecondary(): Int {
return ATHUtil.resolveColor(this, android.R.attr.textColorSecondary)
}
fun Context.accentColor() = ThemeStore.accentColor(this)
fun Context.colorControlNormal(): Int {
return ATHUtil.resolveColor(this, android.R.attr.colorControlNormal)
}
fun Fragment.accentColor() = ThemeStore.accentColor(requireContext())
fun Context.textColorPrimary(): Int {
return ATHUtil.resolveColor(this, android.R.attr.textColorPrimary)
}
fun Context.surfaceColor() = resolveColor(R.attr.colorSurface, Color.WHITE)
fun Fragment.surfaceColor() = resolveColor(R.attr.colorSurface, Color.WHITE)
fun Context.textColorSecondary() = resolveColor(android.R.attr.textColorSecondary)
fun Fragment.textColorSecondary() = resolveColor(android.R.attr.textColorSecondary)
fun Context.colorControlNormal() = resolveColor(android.R.attr.colorControlNormal)
fun Fragment.colorControlNormal() = resolveColor(android.R.attr.colorControlNormal)
fun Context.textColorPrimary() = resolveColor(android.R.attr.textColorPrimary)
fun Fragment.textColorPrimary() = resolveColor(android.R.attr.textColorPrimary)
fun Context.resolveColor(@AttrRes attr: Int, fallBackColor: Int = 0) =
ATHUtil.resolveColor(this, attr, fallBackColor)
fun Fragment.resolveColor(@AttrRes attr: Int, fallBackColor: Int = 0) =
ATHUtil.resolveColor(requireContext(), attr, fallBackColor)
fun Dialog.resolveColor(@AttrRes attr: Int, fallBackColor: Int = 0) =
ATHUtil.resolveColor(context, attr, fallBackColor)