Bläddra i källkod

Move darkenColor method to Util.kt

Aidan Follestad 5 år sedan
förälder
incheckning
ccd6521de0

+ 0 - 10
bottomsheets/src/main/java/com/afollestad/materialdialogs/bottomsheets/BottomSheet.kt

@@ -18,7 +18,6 @@ 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
@@ -26,7 +25,6 @@ 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
@@ -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 {

+ 10 - 0
bottomsheets/src/main/java/com/afollestad/materialdialogs/bottomsheets/Util.kt

@@ -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
@@ -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
+  })
+}