Address search fab color issue
This commit is contained in:
committed by
Aayush Gupta
parent
8cfec71259
commit
c8d701feb4
@@ -81,7 +81,7 @@ fun lightenColor(@ColorInt color: Int, factor: Float = 0.5f, @Nullable alpha: In
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes a contrasting color from the given color.
|
||||
* Computes a contrasting color (B & W only) from the given color.
|
||||
* @param color The color to contrast.
|
||||
* @return The contrasting color.
|
||||
*/
|
||||
@@ -92,4 +92,4 @@ fun contrastingColor(@ColorInt color: Int): Int {
|
||||
val yiq = ((red * 299) + (green * 587) + (blue * 114)) / 1000
|
||||
|
||||
return if (yiq >= 128) Color.BLACK else Color.WHITE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,10 @@
|
||||
package com.aurora.extensions
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
|
||||
fun View.isVisible() = visibility == View.VISIBLE
|
||||
|
||||
@@ -83,3 +85,9 @@ fun View.getString(resourceId: Int): String {
|
||||
return context.getString(resourceId)
|
||||
}
|
||||
|
||||
fun FloatingActionButton.applyColors() {
|
||||
val accentColor = context.accentColor()
|
||||
backgroundTintList = ColorStateList.valueOf(accentColor)
|
||||
imageTintList = ColorStateList.valueOf(contrastingColor(accentColor))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user