diff --git a/colorpicker-compose/api/colorpicker-compose.api b/colorpicker-compose/api/colorpicker-compose.api index e8e9381..775cf0f 100644 --- a/colorpicker-compose/api/colorpicker-compose.api +++ b/colorpicker-compose/api/colorpicker-compose.api @@ -43,6 +43,7 @@ public final class com/github/skydoves/colorpicker/compose/ColorPickerController public final fun selectByColor-DxMtmZc (JZ)V public final fun selectByCoordinate (FFZ)V public final fun selectCenter (Z)V + public final fun setBrightness (FZ)V public final fun setDebounceDuration (J)V public final fun setEnabled (Z)V public final fun setPaletteContentScale (Lcom/github/skydoves/colorpicker/compose/PaletteContentScale;)V diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt index 007d474..1373b58 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ColorPickerController.kt @@ -24,6 +24,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.Stable import androidx.compose.runtime.State +import androidx.compose.runtime.mutableFloatStateOf +import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.graphics.Color @@ -76,10 +78,10 @@ public class ColorPickerController { internal var pureSelectedColor: MutableState = mutableStateOf(Color.Transparent) /** Alpha value to be applied with the selected color. */ - internal var alpha: MutableState = mutableStateOf(1.0f) + internal var alpha: MutableState = mutableFloatStateOf(1.0f) /** Brightness value to be applied with the selected color. */ - internal var brightness: MutableState = mutableStateOf(1.0f) + internal var brightness: MutableState = mutableFloatStateOf(1.0f) /** Radius to draw default wheel. */ internal var wheelRadius: Dp = 12.dp @@ -110,7 +112,7 @@ public class ColorPickerController { /** Indicates if the brightness slider has been attached. */ internal var isAttachedBrightnessSlider: Boolean = false - internal var reviseTick = mutableStateOf(0) + internal var reviseTick = mutableIntStateOf(0) internal var colorChangedTick = MutableStateFlow(null) @@ -133,7 +135,7 @@ public class ColorPickerController { paletteBitmap = resized.asImageBitmap() copiedBitmap.recycle() selectCenter(fromUser = false) - reviseTick.value++ + reviseTick.intValue++ } /** Set a [PaletteContentScale] to the palette bitmap. */ @@ -149,25 +151,25 @@ public class ColorPickerController { /** Set a radius to draw default wheel. */ public fun setWheelRadius(radius: Dp) { wheelRadius = radius - reviseTick.value++ + reviseTick.intValue++ } /** Set a paint to draw default wheel. */ public fun setWheelPaint(paint: Paint) { wheelPaint = paint - reviseTick.value++ + reviseTick.intValue++ } /** Set a color for the wheel. */ public fun setWheelColor(color: Color) { wheelPaint.color = color - reviseTick.value++ + reviseTick.intValue++ } /** Set an alpha for the wheel. */ public fun setWheelAlpha(alpha: Float) { wheelPaint.alpha = alpha - reviseTick.value++ + reviseTick.intValue++ } /** Enable or unable color selection. */ @@ -271,7 +273,7 @@ public class ColorPickerController { } /** Combine the brightness value to the selected pure color. */ - internal fun setBrightness(brightness: Float, fromUser: Boolean) { + public fun setBrightness(brightness: Float, fromUser: Boolean) { this.brightness.value = brightness val hsv = FloatArray(3) android.graphics.Color.colorToHSV(pureSelectedColor.value.toArgb(), hsv) diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvColorPicker.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvColorPicker.kt index 44094e5..3a35c23 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvColorPicker.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/HsvColorPicker.kt @@ -198,6 +198,6 @@ public fun HsvColorPicker( } } } - controller.reviseTick.value + controller.reviseTick.intValue } } diff --git a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ImageColorPicker.kt b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ImageColorPicker.kt index 7373925..3976964 100644 --- a/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ImageColorPicker.kt +++ b/colorpicker-compose/src/main/kotlin/com/github/skydoves/colorpicker/compose/ImageColorPicker.kt @@ -181,7 +181,7 @@ public fun ImageColorPicker( this.drawOnPosSelected() } } - controller.reviseTick.value + controller.reviseTick.intValue } }