diff --git a/README.md b/README.md
index 9e9c594..4b4870b 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@
-🎨 Jetpack Compose color picker library that allows you to get colors from any images like gallery pictures by tapping on the desired color.
+🎨 Kotlin Multiplatform color picker library that allows you to get colors from any images like gallery pictures by tapping on the desired color.
Also, it supports brightness and alpha slider, which can adjust your ARGB factors.
@@ -185,7 +185,7 @@ You can select specific points with the functions below:
You can set the debounce duration, which decides to invoke the color listener from the last tapping. Debounce can be useful to reduce overhead. For example, communicating with IoT devices or relevant works that require heavy operations.
```kotlin
-.setDebounceDuration(300L)
+controller.debounceDuration = 200L
```
#### Enable and Disable
@@ -193,7 +193,7 @@ You can set the debounce duration, which decides to invoke the color listener fr
You can enable or disable your color picker with the below function:
```kotlin
-.setEnabled(false)
+controller.enabled = false
```
diff --git a/colorpicker-compose/api/android/colorpicker-compose.api b/colorpicker-compose/api/android/colorpicker-compose.api
index a760ff9..a8696b1 100644
--- a/colorpicker-compose/api/android/colorpicker-compose.api
+++ b/colorpicker-compose/api/android/colorpicker-compose.api
@@ -33,6 +33,7 @@ public final class com/github/skydoves/colorpicker/compose/ColorPickerController
public synthetic fun (Lkotlinx/coroutines/CoroutineScope;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getColorFlow (J)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun getColorFlow$default (Lcom/github/skydoves/colorpicker/compose/ColorPickerController;JILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
+ public final fun getDebounceDuration ()Ljava/lang/Long;
public final fun getEnabled ()Z
public final fun getPaletteBitmap ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getSelectedColor ()Landroidx/compose/runtime/State;
@@ -50,8 +51,7 @@ public final class com/github/skydoves/colorpicker/compose/ColorPickerController
public final fun selectCenter (Z)V
public final fun setAlpha (FZ)V
public final fun setBrightness (FZ)V
- public final fun setDebounceDuration (J)V
- public static synthetic fun setDebounceDuration$default (Lcom/github/skydoves/colorpicker/compose/ColorPickerController;JILjava/lang/Object;)V
+ public final fun setDebounceDuration (Ljava/lang/Long;)V
public final fun setEnabled (Z)V
public final fun setPaletteImageBitmap (Landroidx/compose/ui/graphics/ImageBitmap;)V
public final fun setWheelAlpha (F)V
diff --git a/colorpicker-compose/api/desktop/colorpicker-compose.api b/colorpicker-compose/api/desktop/colorpicker-compose.api
index a760ff9..a8696b1 100644
--- a/colorpicker-compose/api/desktop/colorpicker-compose.api
+++ b/colorpicker-compose/api/desktop/colorpicker-compose.api
@@ -33,6 +33,7 @@ public final class com/github/skydoves/colorpicker/compose/ColorPickerController
public synthetic fun (Lkotlinx/coroutines/CoroutineScope;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun getColorFlow (J)Lkotlinx/coroutines/flow/Flow;
public static synthetic fun getColorFlow$default (Lcom/github/skydoves/colorpicker/compose/ColorPickerController;JILjava/lang/Object;)Lkotlinx/coroutines/flow/Flow;
+ public final fun getDebounceDuration ()Ljava/lang/Long;
public final fun getEnabled ()Z
public final fun getPaletteBitmap ()Lkotlinx/coroutines/flow/StateFlow;
public final fun getSelectedColor ()Landroidx/compose/runtime/State;
@@ -50,8 +51,7 @@ public final class com/github/skydoves/colorpicker/compose/ColorPickerController
public final fun selectCenter (Z)V
public final fun setAlpha (FZ)V
public final fun setBrightness (FZ)V
- public final fun setDebounceDuration (J)V
- public static synthetic fun setDebounceDuration$default (Lcom/github/skydoves/colorpicker/compose/ColorPickerController;JILjava/lang/Object;)V
+ public final fun setDebounceDuration (Ljava/lang/Long;)V
public final fun setEnabled (Z)V
public final fun setPaletteImageBitmap (Landroidx/compose/ui/graphics/ImageBitmap;)V
public final fun setWheelAlpha (F)V
diff --git a/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/AlphaTile.kt b/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/AlphaTile.kt
index 91cc799..2579400 100644
--- a/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/AlphaTile.kt
+++ b/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/AlphaTile.kt
@@ -53,9 +53,9 @@ public fun AlphaTile(
color = controller?.selectedColor?.value ?: selectedColor
}
val paint = alphaTilePaint(
- with(density) { tileSize.toPx() },
- tileOddColor,
- tileEvenColor,
+ tileSize = with(density) { tileSize.toPx() },
+ tileOddColor = tileOddColor,
+ tileEvenColor = tileEvenColor,
)
Canvas(
diff --git a/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/ColorPicker.kt b/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/ColorPicker.kt
index 2ade58d..59fd0f4 100644
--- a/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/ColorPicker.kt
+++ b/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/ColorPicker.kt
@@ -64,9 +64,12 @@ internal fun ColorPicker(
) {
var initialized by remember { mutableStateOf(false) }
- DisposableEffect(key1 = controller) {
+ val debounceDuration = controller.debounceDuration
+ DisposableEffect(key1 = controller, key2 = debounceDuration) {
controller.coroutineScope.launch(Dispatchers.Main) {
- controller.getColorFlow().collect { onColorChanged(it) }
+ controller.getColorFlow(debounceDuration ?: 0).collect {
+ onColorChanged(it)
+ }
}
onDispose { controller.releaseBitmap() }
}
diff --git a/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt b/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt
index bf2a6fd..29bb18e 100644
--- a/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt
+++ b/colorpicker-compose/src/commonMain/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt
@@ -102,8 +102,14 @@ constructor(
/** An [ImageBitmap] to be drawn on the canvas as a wheel. */
public var wheelBitmap: ImageBitmap? = null
+ internal val _debounceDuration: MutableState = mutableStateOf(null)
+
/** A debounce duration for observing color changes. */
- private var debounceDuration: Long? = null
+ public var debounceDuration: Long?
+ get() = _debounceDuration.value
+ set(value) {
+ _debounceDuration.value = value
+ }
/** Radius to draw default wheel. */
public var wheelRadius: Dp = 12.dp
@@ -265,11 +271,6 @@ constructor(
}
}
- /** Sets the debounce duration that allows you to observe color changes with a given duration. */
- public fun setDebounceDuration(duration: Long = 0) {
- this.debounceDuration = duration
- }
-
/** Notify color changes to the color picker and other subcomponents. */
private fun notifyColorChanged(fromUser: Boolean) {
val color = _selectedColor.value