Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
Move darkenColor method to Util.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed May 20, 2019
1 parent df57e68 commit ccd6521
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ package com.afollestad.materialdialogs.bottomsheets
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.os.Build.VERSION.SDK_INT
import android.view.LayoutInflater
import android.view.View.GONE
import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager.LayoutParams
import androidx.annotation.ColorInt
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.afollestad.materialdialogs.DialogBehavior
import com.afollestad.materialdialogs.LayoutMode
Expand Down Expand Up @@ -111,14 +109,6 @@ class BottomSheet(
}
}

@ColorInt fun Int.darkenColor(factor: Float = 0.5f): Int {
val color = this
return Color.HSVToColor(FloatArray(3).apply {
Color.colorToHSV(color, this)
this[2] *= factor
})
}

private fun setupBottomSheetBehavior() {
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetView)
.apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ package com.afollestad.materialdialogs.bottomsheets
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ValueAnimator
import android.graphics.Color
import android.view.View
import android.view.View.OnAttachStateChangeListener
import android.view.animation.DecelerateInterpolator
import androidx.annotation.CheckResult
import androidx.annotation.ColorInt
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
import com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED
Expand Down Expand Up @@ -116,3 +118,11 @@ internal fun <T : View> T.onDetach(onAttached: T.() -> Unit) {
override fun onViewAttachedToWindow(v: View) = Unit
})
}

@ColorInt internal fun Int.darkenColor(factor: Float = 0.5f): Int {
val color = this
return Color.HSVToColor(FloatArray(3).apply {
Color.colorToHSV(color, this)
this[2] *= factor
})
}

0 comments on commit ccd6521

Please sign in to comment.