
A versatile color picker library offers multiple picker types including Classic, Circle, Ring, and Simple Ring, alongside a customizable dialog and useful color manipulation extensions.
🎨 Color Picker for Kotlin multiplatform inspired from compose-color-picker by mhssn95
implementation 'io.github.mohammedalaamorsi:colorpicker:1.0.2'ColorPicker {
color = it
}You can provide a type for the color picker as the following.
ColorPicker(
type = ColorPickerType.Classic()
) {
color = it
}Classic
ColorPickerType.Classic(
showAlphaBar = true
)Circle
ColorPickerType.Circle(
showBrightnessBar = true,
showAlphaBar = true,
lightCenter = true
)Ring
ColorPickerType.Ring(
ringWidth = 10.dp,
previewRadius = 80.dp,
showLightColorBar = true,
showDarkColorBar = true,
showAlphaBar = true,
showColorPreview = true
)Simple Ring
ColorPickerType.SimpleRing(
colorWidth = 20.dp,
tracksCount = 5,
sectorsCount = 24
)ColorPickerDialog(
show = showDialog,
type = colorPickerType,
properties = DialogProperties(),
onDismissRequest = {
showDialog = false
},
onPickedColor = {
color = it
},
)val color = Color(0xffe1a1c1)
val alpha = color.alpha() //return alpha value as integer => 255
val red = color.red() //return red value as integer => 225
val green = color.green() //return green value as integer => 161
val blue = color.blue() //return blue value as integer => 193
val hex = color.toHex() //return argb color as hex string
val (alpha, red, green, blue) = color.argb() //return an array for all color channels valueadd Modifier.transparentBackground to draw behind your composable element a transparent effect background
Box(
modifier = Modifier
.width(205.dp)
.height(300.dp)
.clip(RoundedCornerShape(32.dp))
.transparentBackground(verticalBoxesCount = 16)
.background(Color.Cyan.copy(alpha = 0.2f))
)local.properties file to the project root and set a path to Android SDK thereTo run the application on android device/emulator:
To build the application bundle:
./gradlew :sample:composeApp:assembleDebug
.apk file in sample/composeApp/build/outputs/apk/debug/composeApp-debug.apk
Run the desktop application: ./gradlew :sample:composeApp:run
To run the application on iPhone device/simulator:
sample/iosApp/iosApp.xcproject in Xcode and run standard configurationCopyright 2024 Mohammed Alaa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
🎨 Color Picker for Kotlin multiplatform inspired from compose-color-picker by mhssn95
implementation 'io.github.mohammedalaamorsi:colorpicker:1.0.2'ColorPicker {
color = it
}You can provide a type for the color picker as the following.
ColorPicker(
type = ColorPickerType.Classic()
) {
color = it
}Classic
ColorPickerType.Classic(
showAlphaBar = true
)Circle
ColorPickerType.Circle(
showBrightnessBar = true,
showAlphaBar = true,
lightCenter = true
)Ring
ColorPickerType.Ring(
ringWidth = 10.dp,
previewRadius = 80.dp,
showLightColorBar = true,
showDarkColorBar = true,
showAlphaBar = true,
showColorPreview = true
)Simple Ring
ColorPickerType.SimpleRing(
colorWidth = 20.dp,
tracksCount = 5,
sectorsCount = 24
)ColorPickerDialog(
show = showDialog,
type = colorPickerType,
properties = DialogProperties(),
onDismissRequest = {
showDialog = false
},
onPickedColor = {
color = it
},
)val color = Color(0xffe1a1c1)
val alpha = color.alpha() //return alpha value as integer => 255
val red = color.red() //return red value as integer => 225
val green = color.green() //return green value as integer => 161
val blue = color.blue() //return blue value as integer => 193
val hex = color.toHex() //return argb color as hex string
val (alpha, red, green, blue) = color.argb() //return an array for all color channels valueadd Modifier.transparentBackground to draw behind your composable element a transparent effect background
Box(
modifier = Modifier
.width(205.dp)
.height(300.dp)
.clip(RoundedCornerShape(32.dp))
.transparentBackground(verticalBoxesCount = 16)
.background(Color.Cyan.copy(alpha = 0.2f))
)local.properties file to the project root and set a path to Android SDK thereTo run the application on android device/emulator:
To build the application bundle:
./gradlew :sample:composeApp:assembleDebug
.apk file in sample/composeApp/build/outputs/apk/debug/composeApp-debug.apk
Run the desktop application: ./gradlew :sample:composeApp:run
To run the application on iPhone device/simulator:
sample/iosApp/iosApp.xcproject in Xcode and run standard configurationCopyright 2024 Mohammed Alaa
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.