Skip to content

Commit

Permalink
Dark gray flash feedback in night mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Hafizzle committed Sep 25, 2023
1 parent d1b2923 commit e1fcc7e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.graphics.drawable.ColorDrawable
import android.view.View
import android.view.ViewTreeObserver
import com.habitrpg.common.habitica.extensions.dpToPx
import com.habitrpg.common.habitica.extensions.isUsingNightModeResources

fun View.setScaledPadding(context: Context?, left: Int, top: Int, right: Int, bottom: Int) {
this.setPadding(left.dpToPx(context), top.dpToPx(context), right.dpToPx(context), bottom.dpToPx(context))
Expand Down Expand Up @@ -43,7 +44,12 @@ fun View.fadeInAnimation(duration: Long = 500) {

fun View.flash() {
val originalColor = (background as? ColorDrawable)?.color
setBackgroundColor(Color.LTGRAY)
if (this.context.isUsingNightModeResources()) {
setBackgroundColor(Color.DKGRAY)
} else {
setBackgroundColor(Color.LTGRAY)
}

postDelayed({
originalColor?.let { setBackgroundColor(it) } ?: setBackgroundResource(0)
}, 100)
Expand Down

0 comments on commit e1fcc7e

Please sign in to comment.