Skip to content

Commit 23f88bd

Browse files
authored
Merge pull request #1 from KvColorPalette/feature/change-ui-in-color-picker
Feature/change UI in color picker
2 parents d3422ec + c733a40 commit 23f88bd

File tree

7 files changed

+393
-211
lines changed

7 files changed

+393
-211
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Kavimal Wijewardana ([email protected])
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# KvColorPicker - Android
2+
3+
This is a lightweight Android library that provides Jetpack Compose `@Composable` UI to select colors. This open as a bottom sheet in default.
4+
But developers can use individual peaces available in the library as per their requirements.
5+
6+
# Features
7+
* Color Picker BottomSheet
8+
* Picker from RGB-A values
9+
10+
# Installation
11+
Add following in your root `build.gradle`/`build.gradle.kts` at the end of repositories:
12+
````
13+
dependencyResolutionManagement {
14+
repositories {
15+
mavenCentral()
16+
maven { url 'https://jitpack.io' } // jitpack.io repository configured.
17+
}
18+
}
19+
````
20+
21+
Add the following dependency to your `build.gradle` / `build.gradle.kts` file:
22+
For Groovy - `build.gradle`:
23+
````
24+
dependencies {
25+
implementation 'com.github.KvColorPalette:KvColorPicker-Android:0.0.1'
26+
}
27+
````
28+
For Kotlin DSL - `build.gradle.kts`:
29+
````
30+
dependencies {
31+
implementation("com.github.KvColorPalette:KvColorPicker-Android:0.0.1")
32+
}
33+
````
34+
35+
# Usage
36+
After you integrated the `KvColorPicker-Android` library, you can consume it as follows.
37+
38+
### Open up BottomSheet
39+
As a main functionality, consumer can use color picker bottom sheet in there application as follows.
40+
```
41+
// Create state variable to show and hide bottom sheet
42+
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
43+
44+
// Button click to open bottom-sheet
45+
Button(
46+
onClick = {
47+
sheetState.value = true
48+
}
49+
) {
50+
Text("Open Color Picker")
51+
}
52+
53+
// Color Picker bottom sheet UI
54+
KvColorPickerBottomSheet(
55+
showSheet = showSheet,
56+
sheetState = sheetState,
57+
onColorSelected = { selectedColor ->
58+
// Do anything when you have selected color
59+
}
60+
)
61+
```
62+
63+
# Contribution
64+
We welcome contributions! Please fork the repository, make your changes, and submit a pull request. Ensure your code adheres to the established guidelines.
65+
66+
# License
67+
`KvColorPicker-Android` is licensed under the [MIT License](https://github.com/KvColorPalette/KvColorPicker-Android/blob/main/LICENSE).
68+
69+
# Feedback
70+
For questions, suggestions, or issues, please open an issue on GitHub or contact us at [email protected].
71+
72+

kv-color-picker/src/main/kotlin/com/kavi/droid/color/picker/KvColorPicker.kt

Lines changed: 0 additions & 196 deletions
This file was deleted.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.kavi.droid.color.palette.app.extension
1+
package com.kavi.droid.color.picker.extension
22

33
/**
44
* Converts a float value in the range [0, 1] to an integer color component in the range [0, 255].
55
*
66
* @return The integer representation of the color component.
77
*/
8-
fun Float.toColorInt(): Int = (this * 255 + 0.5f).toInt()
8+
internal fun Float.toColorInt(): Int = (this * 255 + 0.5f).toInt()

kv-color-picker/src/main/kotlin/com/kavi/droid/color/picker/KvColorPickerBottomSheet.kt renamed to kv-color-picker/src/main/kotlin/com/kavi/droid/color/picker/ui/KvColorPickerBottomSheet.kt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.kavi.droid.color.picker
1+
package com.kavi.droid.color.picker.ui
22

33
import androidx.compose.foundation.layout.Column
44
import androidx.compose.foundation.layout.Row
@@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.padding
77
import androidx.compose.foundation.shape.RoundedCornerShape
88
import androidx.compose.material3.Button
99
import androidx.compose.material3.ExperimentalMaterial3Api
10-
import androidx.compose.material3.MaterialTheme
1110
import androidx.compose.material3.ModalBottomSheet
1211
import androidx.compose.material3.OutlinedButton
1312
import androidx.compose.material3.SheetState
@@ -23,6 +22,7 @@ import androidx.compose.ui.graphics.Color
2322
import androidx.compose.ui.text.style.TextAlign
2423
import androidx.compose.ui.unit.dp
2524
import androidx.compose.ui.unit.sp
25+
import com.kavi.droid.color.picker.ui.pickers.KvColorPicker
2626

2727
@OptIn(ExperimentalMaterial3Api::class)
2828
@Composable
@@ -44,17 +44,6 @@ fun KvColorPickerBottomSheet(showSheet: MutableState<Boolean>, sheetState: Sheet
4444
fontSize = 32.sp
4545
)
4646

47-
Text(
48-
text ="By dragging \'RED\', \'GREEN\', and \'BLUE\' bars below, you can select " +
49-
"or generate your color you want exactly, or type your color\'s hex and set it.",
50-
textAlign = TextAlign.Start,
51-
modifier = Modifier
52-
.fillMaxWidth().padding(top = 4.dp, start = 16.dp, end = 16.dp),
53-
color = Color.Gray,
54-
style = MaterialTheme.typography.bodySmall,
55-
fontSize = 10.sp
56-
)
57-
5847
KvColorPicker(
5948
modifier = Modifier.padding(16.dp),
6049
onColorSelected = {

0 commit comments

Comments
 (0)