├── catalog
├── .gitignore
├── src
│ ├── androidMain
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ └── themes.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── AndroidManifest.xml
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── sergiobelda
│ │ │ └── pigment
│ │ │ └── catalog
│ │ │ └── main
│ │ │ └── MainActivity.kt
│ ├── commonMain
│ │ ├── composeResources
│ │ │ └── values
│ │ │ │ └── strings.xml
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── sergiobelda
│ │ │ └── pigment
│ │ │ └── catalog
│ │ │ ├── PigmentCatalogScreen.kt
│ │ │ ├── ui
│ │ │ └── Theme.kt
│ │ │ └── main
│ │ │ └── PigmentDemo.kt
│ ├── jsMain
│ │ ├── resources
│ │ │ └── index.html
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── sergiobelda
│ │ │ └── pigment
│ │ │ └── catalog
│ │ │ └── main
│ │ │ └── Main.js.kt
│ ├── iosMain
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── sergiobelda
│ │ │ └── pigment
│ │ │ └── catalog
│ │ │ └── Main.ios.kt
│ └── jvmMain
│ │ └── kotlin
│ │ └── dev
│ │ └── sergiobelda
│ │ └── pigment
│ │ └── catalog
│ │ └── Main.jvm.kt
├── README.md
└── build.gradle.kts
├── pigment
├── .gitignore
├── consumer-rules.pro
├── src
│ ├── commonMain
│ │ ├── composeResources
│ │ │ ├── values
│ │ │ │ └── strings.xml
│ │ │ └── drawable
│ │ │ │ ├── ic_check_24px.xml
│ │ │ │ ├── ic_format_color_reset_24px.xml
│ │ │ │ └── ic_color_off_24dp.xml
│ │ └── kotlin
│ │ │ └── dev
│ │ │ └── sergiobelda
│ │ │ └── pigment
│ │ │ └── colorpicker
│ │ │ ├── ColorPickerItem.kt
│ │ │ └── ColorPicker.kt
│ ├── test
│ │ └── snapshots
│ │ │ └── images
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Black].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Large].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Medium].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Small].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[White].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Large].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Medium].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Small].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[DarkColor].png
│ │ │ ├── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[LightColor].png
│ │ │ └── dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Unspecified].png
│ └── androidUnitTest
│ │ └── kotlin
│ │ └── dev
│ │ └── sergiobelda
│ │ └── pigment
│ │ ├── colorpicker
│ │ ├── ColorTestCase.kt
│ │ └── ColorPickerTest.kt
│ │ └── sample
│ │ └── SampleData.kt
├── proguard-rules.pro
├── samples
│ ├── src
│ │ ├── androidMain
│ │ │ └── kotlin
│ │ │ │ └── dev
│ │ │ │ └── sergiobelda
│ │ │ │ └── pigment
│ │ │ │ └── samples
│ │ │ │ └── colorpicker
│ │ │ │ ├── ColorPickerSizeProvider.kt
│ │ │ │ ├── ColorPickerLazyRowPreviews.kt
│ │ │ │ └── ColorPickerFlowRowPreviews.kt
│ │ └── commonMain
│ │ │ └── kotlin
│ │ │ └── dev
│ │ │ └── sergiobelda
│ │ │ └── pigment
│ │ │ └── samples
│ │ │ └── colorpicker
│ │ │ ├── SampleData.kt
│ │ │ ├── Utils.kt
│ │ │ ├── ColorPickerLazyRowSamples.kt
│ │ │ └── ColorPickerFlowRowSamples.kt
│ └── build.gradle.kts
└── build.gradle.kts
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── screenshots
├── ColorPicker_FlowRow.png
└── ColorPicker_LazyRow.png
├── catalog-ios
├── catalog-ios
│ ├── Assets.xcassets
│ │ ├── Contents.json
│ │ ├── AccentColor.colorset
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── Preview Content
│ │ └── Preview Assets.xcassets
│ │ │ └── Contents.json
│ ├── Info.plist
│ ├── catalog_iosApp.swift
│ └── ContentView.swift
├── catalog-ios.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── project.pbxproj
└── .gitignore
├── renovate.json
├── .gitignore
├── settings.gradle.kts
├── .github
└── workflows
│ ├── build.yml
│ └── deploy-docs.yml
├── gradle.properties
├── docs
└── index.md
├── mkdocs.yml
├── README.md
├── gradlew.bat
└── gradlew
/catalog/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/pigment/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/pigment/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/screenshots/ColorPicker_FlowRow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/screenshots/ColorPicker_FlowRow.png
--------------------------------------------------------------------------------
/screenshots/ColorPicker_LazyRow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/screenshots/ColorPicker_LazyRow.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Pigment Catalog
3 |
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:recommended"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios/Preview Content/Preview Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/catalog/README.md:
--------------------------------------------------------------------------------
1 | ## Run catalog
2 |
3 | ### Run on Desktop
4 |
5 | `./gradlew :catalog:run`
6 |
7 | ### Run on Web
8 |
9 | `./gradlew :catalog:jsBrowserRun`
10 |
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/catalog/src/androidMain/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/pigment/src/commonMain/composeResources/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Color Off
4 | Selected
5 |
6 |
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios/Assets.xcassets/AccentColor.colorset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "colors" : [
3 | {
4 | "idiom" : "universal"
5 | }
6 | ],
7 | "info" : {
8 | "author" : "xcode",
9 | "version" : 1
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Black].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Black].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Large].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Large].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Medium].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Medium].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Small].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Small].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[White].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[White].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Large].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Large].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Medium].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Medium].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Small].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_LazyRow[Small].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[DarkColor].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[DarkColor].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[LightColor].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[LightColor].png
--------------------------------------------------------------------------------
/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Unspecified].png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/serbelga/pigment/HEAD/pigment/src/test/snapshots/images/dev.sergiobelda.pigment.colorpicker_ColorPickerTest_FlowRow[Unspecified].png
--------------------------------------------------------------------------------
/catalog/src/commonMain/composeResources/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | OK
3 | Open BottomSheet
4 | Open Dialog
5 | Select color
6 |
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CADisableMinimumFrameDurationOnPhone
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 | /.idea/
17 | /pigment/samples/build/
18 | /.kotlin/
19 |
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios/catalog_iosApp.swift:
--------------------------------------------------------------------------------
1 | //
2 | // catalog_iosApp.swift
3 | // catalog-ios
4 | //
5 | // Created by Sergio Belda Galbis on 22/12/24.
6 | //
7 |
8 | import SwiftUI
9 |
10 | @main
11 | struct catalog_iosApp: App {
12 | var body: some Scene {
13 | WindowGroup {
14 | ContentView()
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/catalog/src/jsMain/resources/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Pigment Catalog Sample
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/pigment/src/commonMain/composeResources/drawable/ic_check_24px.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | includeBuild("build-logic")
3 | repositories {
4 | google()
5 | mavenCentral()
6 | gradlePluginPortal()
7 | }
8 | }
9 | dependencyResolutionManagement {
10 | repositoriesMode.set(RepositoriesMode.PREFER_PROJECT)
11 | repositories {
12 | google()
13 | mavenCentral()
14 | maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
15 | }
16 | }
17 |
18 | rootProject.name = "pigment-library"
19 |
20 | include(":catalog")
21 | include(":pigment")
22 | include(":pigment:samples")
23 |
24 | enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
25 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Build Project
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | - develop
8 | pull_request:
9 | branches:
10 | - main
11 | - develop
12 |
13 | jobs:
14 | build:
15 |
16 | runs-on: macos-latest
17 |
18 | steps:
19 | - name: Checkout the code
20 | uses: actions/checkout@v5
21 | - name: set up JDK 17
22 | uses: actions/setup-java@v5
23 | with:
24 | java-version: '17'
25 | distribution: 'temurin'
26 | cache: gradle
27 | - name: Run spotlessCheck
28 | run: ./gradlew spotlessCheck
29 | - name: Run build
30 | run: ./gradlew build
31 |
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios/ContentView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ContentView.swift
3 | // catalog-ios
4 | //
5 | // Created by Sergio Belda Galbis on 22/12/24.
6 | //
7 |
8 | import SwiftUI
9 | import catalog
10 |
11 | struct ContentView: View {
12 | var body: some View {
13 | ComposeView()
14 | .ignoresSafeArea(.keyboard) // Compose has own keyboard handler
15 | }
16 | }
17 |
18 | struct ComposeView: UIViewControllerRepresentable {
19 | func makeUIViewController(context: Context) -> UIViewController {
20 | Main_iosKt.MainViewController()
21 | }
22 |
23 | func updateUIViewController(_ uiViewController: UIViewController, context: Context) {
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
2 | android.useAndroidX=true
3 | kotlin.code.style=official
4 | org.jetbrains.compose.experimental.jscanvas.enabled=true
5 | org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
6 |
7 | POM_NAME=Pigment
8 | POM_DESCRIPTION=A color selector for Compose Multiplatform
9 | POM_URL=https://github.com/serbelga/pigment
10 | POM_SCM_URL=https://github.com/serbelga/pigment
11 | POM_SCM_CONNECTION=scm:git:git://github.com/serbelga/pigment.git
12 | POM_SCM_DEV_CONNECTION=scm:git:git://github.com/serbelga/pigment.git
13 | POM_LICENCE_NAME=The Apache Software License, Version 2.0
14 | POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
15 | POM_LICENCE_DIST=repo
16 | POM_DEVELOPER_ID=serbelga
17 | POM_DEVELOPER_NAME=Sergio Belda
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "platform" : "ios",
6 | "size" : "1024x1024"
7 | },
8 | {
9 | "appearances" : [
10 | {
11 | "appearance" : "luminosity",
12 | "value" : "dark"
13 | }
14 | ],
15 | "idiom" : "universal",
16 | "platform" : "ios",
17 | "size" : "1024x1024"
18 | },
19 | {
20 | "appearances" : [
21 | {
22 | "appearance" : "luminosity",
23 | "value" : "tinted"
24 | }
25 | ],
26 | "idiom" : "universal",
27 | "platform" : "ios",
28 | "size" : "1024x1024"
29 | }
30 | ],
31 | "info" : {
32 | "author" : "xcode",
33 | "version" : 1
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/pigment/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.kts.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/catalog/src/androidMain/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/catalog/src/iosMain/kotlin/dev/sergiobelda/pigment/catalog/Main.ios.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.catalog
18 |
19 | import androidx.compose.ui.window.ComposeUIViewController
20 | import platform.UIKit.UIViewController
21 |
22 | fun MainViewController(): UIViewController = ComposeUIViewController {
23 | PigmentCatalogScreen()
24 | }
25 |
--------------------------------------------------------------------------------
/pigment/src/commonMain/kotlin/dev/sergiobelda/pigment/colorpicker/ColorPickerItem.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.colorpicker
18 |
19 | import androidx.compose.runtime.Immutable
20 | import androidx.compose.ui.graphics.Color
21 |
22 | /**
23 | */
24 | @Immutable
25 | data class ColorPickerItem(
26 | val color: Color,
27 | val enabled: Boolean = true,
28 | )
29 |
--------------------------------------------------------------------------------
/pigment/src/androidUnitTest/kotlin/dev/sergiobelda/pigment/colorpicker/ColorTestCase.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.colorpicker
18 |
19 | import androidx.compose.ui.graphics.Color
20 |
21 | enum class ColorTestCase(val value: Color) {
22 | Unspecified(Color.Unspecified),
23 | White(Color.White),
24 | Black(Color.Black),
25 | LightColor(Color(0xFFFFEE58)),
26 | DarkColor(Color(0xFFEC407A)),
27 | }
28 |
--------------------------------------------------------------------------------
/pigment/src/commonMain/composeResources/drawable/ic_format_color_reset_24px.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/catalog/src/commonMain/kotlin/dev/sergiobelda/pigment/catalog/PigmentCatalogScreen.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.catalog
18 |
19 | import androidx.compose.runtime.Composable
20 | import dev.sergiobelda.pigment.catalog.main.PigmentDemo
21 | import dev.sergiobelda.pigment.catalog.ui.PigmentCatalogTheme
22 |
23 | @Composable
24 | fun PigmentCatalogScreen() {
25 | PigmentCatalogTheme {
26 | PigmentDemo()
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/catalog/src/jvmMain/kotlin/dev/sergiobelda/pigment/catalog/Main.jvm.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.catalog
18 |
19 | import androidx.compose.ui.window.Window
20 | import androidx.compose.ui.window.application
21 |
22 | fun main() = application {
23 | Window(
24 | resizable = false,
25 | onCloseRequest = ::exitApplication,
26 | title = "Pigment Demo Sample",
27 | ) {
28 | PigmentCatalogScreen()
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/pigment/samples/src/androidMain/kotlin/dev/sergiobelda/pigment/samples/colorpicker/ColorPickerSizeProvider.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.samples.colorpicker
18 |
19 | import androidx.compose.ui.tooling.preview.PreviewParameterProvider
20 | import dev.sergiobelda.pigment.colorpicker.ColorPickerSize
21 |
22 | internal class ColorPickerSizeProvider : PreviewParameterProvider {
23 | override val values: Sequence
24 | get() = ColorPickerSize.entries.asSequence()
25 | }
26 |
--------------------------------------------------------------------------------
/pigment/samples/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.androidLibrary)
3 | alias(libs.plugins.composeCompiler)
4 | alias(libs.plugins.composeMultiplatform)
5 | alias(libs.plugins.kotlinMultiplatform)
6 | id("dev.sergiobelda.pigment-spotless")
7 | }
8 |
9 | kotlin {
10 | androidTarget()
11 | jvm()
12 | iosX64()
13 | iosArm64()
14 | iosSimulatorArm64()
15 | js {
16 | browser()
17 | binaries.executable()
18 | }
19 |
20 | sourceSets {
21 |
22 | val commonMain by getting {
23 | dependencies {
24 | implementation(projects.pigment)
25 |
26 | implementation(compose.foundation)
27 | implementation(compose.ui)
28 | }
29 | }
30 | val androidMain by getting {
31 | dependencies {
32 | implementation(compose.preview)
33 | implementation(compose.uiTooling)
34 | }
35 | }
36 | }
37 | }
38 |
39 | android {
40 | namespace = "dev.sergiobelda.pigment.samples"
41 |
42 | compileSdk = 36
43 |
44 | defaultConfig {
45 | minSdk = 21
46 | }
47 |
48 | kotlin {
49 | jvmToolchain(17)
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/catalog/src/androidMain/kotlin/dev/sergiobelda/pigment/catalog/main/MainActivity.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.catalog.main
18 |
19 | import android.os.Bundle
20 | import androidx.activity.compose.setContent
21 | import androidx.activity.enableEdgeToEdge
22 | import androidx.appcompat.app.AppCompatActivity
23 | import dev.sergiobelda.pigment.catalog.PigmentCatalogScreen
24 |
25 | class MainActivity : AppCompatActivity() {
26 | override fun onCreate(savedInstanceState: Bundle?) {
27 | enableEdgeToEdge()
28 | super.onCreate(savedInstanceState)
29 | setContent {
30 | PigmentCatalogScreen()
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/catalog/src/jsMain/kotlin/dev/sergiobelda/pigment/catalog/main/Main.js.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.catalog.main
18 |
19 | import androidx.compose.ui.ExperimentalComposeUiApi
20 | import androidx.compose.ui.window.ComposeViewport
21 | import dev.sergiobelda.pigment.catalog.PigmentCatalogScreen
22 | import org.jetbrains.compose.resources.configureWebResources
23 | import org.jetbrains.skiko.wasm.onWasmReady
24 |
25 | @OptIn(ExperimentalComposeUiApi::class)
26 | fun main() {
27 | configureWebResources {
28 | resourcePathMapping { path -> "./$path" }
29 | }
30 | onWasmReady {
31 | ComposeViewport {
32 | PigmentCatalogScreen()
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | 🎨 A color selector for Compose Multiplatform.
4 |
5 | ## Download
6 |
7 | [](https://search.maven.org/search?q=g:dev.sergiobelda.pigment)
8 |
9 | ### Android
10 |
11 | ```kotlin
12 | dependencies {
13 | implementation("dev.sergiobelda.pigment:pigment:$VERSION")
14 | }
15 | ```
16 |
17 | ### Multiplatform
18 |
19 | ```kotlin
20 | kotlin {
21 | sourceSets {
22 | val commonMain by getting {
23 | dependencies {
24 | implementation("dev.sergiobelda.pigment:pigment:$VERSION")
25 | }
26 | }
27 | }
28 | }
29 | ```
30 |
31 | ## License
32 |
33 | ```
34 | Copyright 2024 Sergio Belda
35 |
36 | Licensed under the Apache License, Version 2.0 (the "License");
37 | you may not use this file except in compliance with the License.
38 | You may obtain a copy of the License at
39 |
40 | http://www.apache.org/licenses/LICENSE-2.0
41 |
42 | Unless required by applicable law or agreed to in writing, software
43 | distributed under the License is distributed on an "AS IS" BASIS,
44 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45 | See the License for the specific language governing permissions and
46 | limitations under the License.
47 | ```
48 |
--------------------------------------------------------------------------------
/catalog/src/commonMain/kotlin/dev/sergiobelda/pigment/catalog/ui/Theme.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.catalog.ui
18 |
19 | import androidx.compose.foundation.isSystemInDarkTheme
20 | import androidx.compose.material3.MaterialTheme
21 | import androidx.compose.material3.darkColorScheme
22 | import androidx.compose.material3.lightColorScheme
23 | import androidx.compose.runtime.Composable
24 |
25 | @Composable
26 | fun PigmentCatalogTheme(
27 | darkTheme: Boolean = isSystemInDarkTheme(),
28 | content: @Composable () -> Unit,
29 | ) {
30 | val colorScheme = if (darkTheme) {
31 | darkColorScheme()
32 | } else {
33 | lightColorScheme()
34 | }
35 | MaterialTheme(
36 | colorScheme = colorScheme,
37 | content = content,
38 | )
39 | }
40 |
--------------------------------------------------------------------------------
/mkdocs.yml:
--------------------------------------------------------------------------------
1 | site_name: Pigment
2 | site_description: A color selector for Compose Multiplatform
3 | site_author: 'Sergio Belda'
4 | site_url: 'https://github.com/serbelga/pigment'
5 | edit_uri: 'tree/main/docs/'
6 | remote_branch: gh-pages
7 |
8 | repo_name: 'pigment'
9 | repo_url: 'https://github.com/serbelga/pigment'
10 |
11 | docs_dir: docs
12 |
13 | nav:
14 | - 'Overview': 'index.md'
15 | - 'API Reference': api/
16 |
17 | theme:
18 | name: 'material'
19 | palette:
20 | - media: "(prefers-color-scheme: light)"
21 | scheme: default
22 | toggle:
23 | icon: material/brightness-4
24 | name: Switch to dark mode
25 | primary: white
26 | - media: "(prefers-color-scheme: dark)"
27 | scheme: slate
28 | toggle:
29 | icon: material/brightness-5
30 | name: Switch to light mode
31 | primary: black
32 | icon:
33 | logo: material/palette
34 | font:
35 | text: 'Manrope'
36 | code: 'JetBrains Mono'
37 | features:
38 | - content.code.annotate
39 | - content.code.copy
40 | - content.code.select
41 |
42 | markdown_extensions:
43 | - admonition
44 | - pymdownx.details
45 | - pymdownx.superfences
46 | - pymdownx.highlight:
47 | anchor_linenums: true
48 | line_spans: __span
49 | pygments_lang_class: true
50 | - pymdownx.inlinehilite
51 | - pymdownx.snippets
52 | - pymdownx.superfences
53 | - pymdownx.emoji:
54 | emoji_index: !!python/name:material.extensions.emoji.twemoji
55 | emoji_generator: !!python/name:material.extensions.emoji.to_svg
--------------------------------------------------------------------------------
/.github/workflows/deploy-docs.yml:
--------------------------------------------------------------------------------
1 | name: Deploy docs
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | permissions:
9 | contents: read
10 | pages: write
11 | id-token: write
12 |
13 | jobs:
14 | deploy_docs:
15 |
16 | runs-on: macos-15
17 |
18 | environment:
19 | name: github-pages
20 | url: ${{ steps.deployment.outputs.page_url }}
21 |
22 | steps:
23 | - uses: actions/checkout@v5
24 | with:
25 | lfs: 'true'
26 |
27 | - name: Setup JDK 17
28 | uses: actions/setup-java@v5
29 | with:
30 | java-version: '17'
31 | distribution: 'temurin'
32 |
33 | - name: Setup Python
34 | uses: actions/setup-python@v6
35 | with:
36 | python-version: '3.x'
37 |
38 | - name: Setup Pages
39 | uses: actions/configure-pages@v5
40 |
41 | - name: Install dependencies
42 | run: |
43 | python3 -m pip install --upgrade pip
44 | python3 -m pip install mkdocs mkdocs-material mkdocs-video "mkdocs-material[imaging]"
45 |
46 | - uses: gradle/gradle-build-action@v3
47 |
48 | - run: ./gradlew dokkaGenerate --no-configuration-cache
49 |
50 | - name: Build site
51 | run: mkdocs build
52 |
53 | - name: Copy Dokka output to site
54 | run: cp -r pigment/build/dokka/html site/api/
55 |
56 | - name: Upload artifact
57 | uses: actions/upload-pages-artifact@v4
58 | with:
59 | path: 'site'
60 |
61 | - name: Deploy to GitHub Pages
62 | id: deployment
63 | uses: actions/deploy-pages@v4
--------------------------------------------------------------------------------
/pigment/src/androidUnitTest/kotlin/dev/sergiobelda/pigment/sample/SampleData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.sample
18 |
19 | import androidx.compose.ui.graphics.Color
20 | import dev.sergiobelda.pigment.colorpicker.ColorPickerItem
21 |
22 | internal val colors: List = listOf(
23 | Color.Unspecified,
24 | Color.Black,
25 | Color.White,
26 | Color(0xFFFAFAFA),
27 | Color(0x80FF4444),
28 | Color(0xFFEF5350),
29 | Color(0xFFEC407A),
30 | Color(0xFFAB47BC),
31 | Color(0xFF7E57C2),
32 | Color(0xFF5C6BC0),
33 | Color(0xFF42A5F5),
34 | Color(0xFF29B6F6),
35 | Color(0xFF26C6DA),
36 | Color(0xFF26A69A),
37 | Color(0xFF66BB6A),
38 | Color(0xFF9CCC65),
39 | Color(0xFFD4E157),
40 | Color(0xFFFFEE58),
41 | Color(0xFFFFCA28),
42 | Color(0xFFFFA726),
43 | Color(0xFFFF7043),
44 | )
45 |
46 | val colorPickerItems = colors.map {
47 | ColorPickerItem(
48 | color = it,
49 | enabled = true,
50 | )
51 | }
52 |
--------------------------------------------------------------------------------
/pigment/samples/src/commonMain/kotlin/dev/sergiobelda/pigment/samples/colorpicker/SampleData.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.samples.colorpicker
18 |
19 | import androidx.compose.ui.graphics.Color
20 | import dev.sergiobelda.pigment.colorpicker.ColorPickerItem
21 |
22 | internal val colors: List = listOf(
23 | Color.Unspecified,
24 | Color.Black,
25 | Color.White,
26 | Color(0xFFFAFAFA),
27 | Color(0x80FF4444),
28 | Color(0xFFEF5350),
29 | Color(0xFFEC407A),
30 | Color(0xFFAB47BC),
31 | Color(0xFF7E57C2),
32 | Color(0xFF5C6BC0),
33 | Color(0xFF42A5F5),
34 | Color(0xFF29B6F6),
35 | Color(0xFF26C6DA),
36 | Color(0xFF26A69A),
37 | Color(0xFF66BB6A),
38 | Color(0xFF9CCC65),
39 | Color(0xFFD4E157),
40 | Color(0xFFFFEE58),
41 | Color(0xFFFFCA28),
42 | Color(0xFFFFA726),
43 | Color(0xFFFF7043),
44 | )
45 |
46 | val colorPickerItems = colors.map {
47 | ColorPickerItem(
48 | color = it,
49 | enabled = true,
50 | )
51 | }
52 |
--------------------------------------------------------------------------------
/pigment/src/commonMain/composeResources/drawable/ic_color_off_24dp.xml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
22 |
25 |
28 |
29 |
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/catalog-ios/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## User settings
6 | xcuserdata/
7 |
8 | ## Obj-C/Swift specific
9 | *.hmap
10 |
11 | ## App packaging
12 | *.ipa
13 | *.dSYM.zip
14 | *.dSYM
15 |
16 | ## Playgrounds
17 | timeline.xctimeline
18 | playground.xcworkspace
19 |
20 | # Swift Package Manager
21 | #
22 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
23 | # Packages/
24 | # Package.pins
25 | # Package.resolved
26 | # *.xcodeproj
27 | #
28 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
29 | # hence it is not needed unless you have added a package configuration file to your project
30 | # .swiftpm
31 |
32 | .build/
33 |
34 | # CocoaPods
35 | #
36 | # We recommend against adding the Pods directory to your .gitignore. However
37 | # you should judge for yourself, the pros and cons are mentioned at:
38 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
39 | #
40 | # Pods/
41 | #
42 | # Add this line if you want to avoid checking in source code from the Xcode workspace
43 | # *.xcworkspace
44 |
45 | # Carthage
46 | #
47 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
48 | # Carthage/Checkouts
49 |
50 | Carthage/Build/
51 |
52 | # fastlane
53 | #
54 | # It is recommended to not store the screenshots in the git repo.
55 | # Instead, use fastlane to re-generate the screenshots whenever they are needed.
56 | # For more information about the recommended setup visit:
57 | # https://docs.fastlane.tools/best-practices/source-control/#source-control
58 |
59 | fastlane/report.xml
60 | fastlane/Preview.html
61 | fastlane/screenshots/**/*.png
62 | fastlane/test_output
--------------------------------------------------------------------------------
/pigment/samples/src/commonMain/kotlin/dev/sergiobelda/pigment/samples/colorpicker/Utils.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.samples.colorpicker
18 |
19 | import androidx.compose.foundation.layout.Box
20 | import androidx.compose.foundation.layout.fillMaxWidth
21 | import androidx.compose.foundation.layout.height
22 | import androidx.compose.foundation.layout.padding
23 | import androidx.compose.foundation.shape.RoundedCornerShape
24 | import androidx.compose.runtime.Composable
25 | import androidx.compose.ui.Modifier
26 | import androidx.compose.ui.draw.drawBehind
27 | import androidx.compose.ui.graphics.Color
28 | import androidx.compose.ui.graphics.graphicsLayer
29 | import androidx.compose.ui.unit.dp
30 |
31 | @Composable
32 | internal fun ColorVisualizer(
33 | color: Color,
34 | ) {
35 | Box(
36 | modifier = Modifier
37 | .fillMaxWidth()
38 | .height(64.dp)
39 | .padding(top = 12.dp)
40 | .padding(horizontal = 12.dp)
41 | .graphicsLayer {
42 | shape = RoundedCornerShape(12.dp)
43 | clip = true
44 | }
45 | .drawBehind {
46 | drawRect(color)
47 | },
48 | )
49 | }
50 |
--------------------------------------------------------------------------------
/catalog/src/commonMain/kotlin/dev/sergiobelda/pigment/catalog/main/PigmentDemo.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.catalog.main
18 |
19 | import androidx.compose.foundation.layout.Arrangement
20 | import androidx.compose.foundation.layout.Column
21 | import androidx.compose.foundation.layout.padding
22 | import androidx.compose.material3.MaterialTheme
23 | import androidx.compose.material3.Scaffold
24 | import androidx.compose.material3.Text
25 | import androidx.compose.runtime.Composable
26 | import androidx.compose.ui.Modifier
27 | import androidx.compose.ui.unit.dp
28 | import dev.sergiobelda.pigment.samples.colorpicker.ColorPickerFlowRowSample
29 | import dev.sergiobelda.pigment.samples.colorpicker.ColorPickerLazyRowSample
30 |
31 | @Composable
32 | internal fun PigmentDemo() {
33 | Scaffold { paddingValues ->
34 | Column(
35 | verticalArrangement = Arrangement.spacedBy(16.dp),
36 | modifier = Modifier
37 | .padding(paddingValues),
38 | ) {
39 | ColorPickerFlowRowDemo()
40 | ColorPickerLazyRowDemo()
41 | }
42 | }
43 | }
44 |
45 | @Composable
46 | private fun ColorPickerFlowRowDemo() {
47 | Column {
48 | Text(
49 | "ColorPicker.FlowRow",
50 | style = MaterialTheme.typography.bodyLarge,
51 | modifier = Modifier.padding(horizontal = 12.dp),
52 | )
53 | ColorPickerFlowRowSample()
54 | }
55 | }
56 |
57 | @Composable
58 | private fun ColorPickerLazyRowDemo() {
59 | Column {
60 | Text(
61 | "ColorPicker.LazyRow",
62 | style = MaterialTheme.typography.bodyLarge,
63 | modifier = Modifier.padding(horizontal = 12.dp),
64 | )
65 | ColorPickerLazyRowSample()
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | activityCompose = "1.11.0"
3 | androidGradlePlugin = "8.13.0"
4 | appcompat = "1.7.1"
5 | composeMultiplatform = "1.9.3"
6 | coreKtx = "1.17.0"
7 | dokka = "2.0.0"
8 | kotlin = "2.2.21"
9 | kotlinCollectionsImmutable = "0.4.0"
10 | ktlint = "0.50.0"
11 | lifecycleRuntimeKtx = "2.9.4"
12 | paparazzi = "1.3.5"
13 | pigment = "0.6.0"
14 | spotless = "8.0.0"
15 | testParameterInjector = "1.19"
16 | vanniktechMavenPublishPlugin = "0.33.0"
17 |
18 | [libraries]
19 | android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
20 |
21 | androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
22 |
23 | androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appcompat" }
24 |
25 | androidx-coreKtx = { module = "androidx.core:core-ktx", version.ref = "coreKtx" }
26 |
27 | androidx-lifecycle-runtimeKtx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
28 |
29 | google-testParameterInjector = { module = "com.google.testparameterinjector:test-parameter-injector", version.ref = "testParameterInjector" }
30 |
31 | kotlin-collections-immutable = { module = "org.jetbrains.kotlinx:kotlinx-collections-immutable", version.ref = "kotlinCollectionsImmutable" }
32 | kotlin-gradlePlugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
33 |
34 | spotless-gradlePlugin = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }
35 |
36 | [plugins]
37 | androidApplication = { id = "com.android.application", version.ref = "androidGradlePlugin" }
38 | androidLibrary = { id = "com.android.library", version.ref = "androidGradlePlugin" }
39 | composeCompiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
40 | composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }
41 | dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
42 | kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
43 | kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
44 | paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
45 | spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
46 | vanniktechMavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechMavenPublishPlugin" }
47 |
--------------------------------------------------------------------------------
/pigment/samples/src/commonMain/kotlin/dev/sergiobelda/pigment/samples/colorpicker/ColorPickerLazyRowSamples.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.samples.colorpicker
18 |
19 | import androidx.compose.foundation.layout.Column
20 | import androidx.compose.foundation.text.BasicText
21 | import androidx.compose.runtime.Composable
22 | import androidx.compose.runtime.mutableStateMapOf
23 | import androidx.compose.runtime.mutableStateOf
24 | import androidx.compose.runtime.remember
25 | import androidx.compose.runtime.toMutableStateList
26 | import androidx.compose.ui.graphics.Color
27 | import dev.sergiobelda.pigment.colorpicker.ColorPicker
28 | import dev.sergiobelda.pigment.colorpicker.ColorPickerItem
29 |
30 | @Composable
31 | fun ColorPickerLazyRowSample() {
32 | val colorPickerItems = remember { colorPickerItems.toMutableStateList() }
33 | val (selectedColor, onColorSelected) = remember {
34 | mutableStateOf(Color.Unspecified)
35 | }
36 | Column {
37 | ColorPicker.LazyRow(
38 | colors = colorPickerItems,
39 | selectedColor = selectedColor,
40 | onColorSelected = onColorSelected,
41 | )
42 | ColorVisualizer(color = selectedColor)
43 | }
44 | }
45 |
46 | @Composable
47 | fun ColorPickerLazyRowMapSample() {
48 | val colorMap = remember {
49 | mutableStateMapOf(
50 | "Red" to ColorPickerItem(Color.Red),
51 | "Blue" to ColorPickerItem(Color.Blue),
52 | )
53 | }
54 | val (selectedItem, onItemSelected) = remember {
55 | mutableStateOf("Red")
56 | }
57 | Column {
58 | ColorPicker.LazyRow(
59 | colorsMap = colorMap,
60 | selectedItem = selectedItem,
61 | onItemSelected = onItemSelected,
62 | )
63 | BasicText(text = selectedItem)
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/pigment/samples/src/commonMain/kotlin/dev/sergiobelda/pigment/samples/colorpicker/ColorPickerFlowRowSamples.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.samples.colorpicker
18 |
19 | import androidx.compose.foundation.layout.Column
20 | import androidx.compose.foundation.layout.ExperimentalLayoutApi
21 | import androidx.compose.foundation.text.BasicText
22 | import androidx.compose.runtime.Composable
23 | import androidx.compose.runtime.mutableStateMapOf
24 | import androidx.compose.runtime.mutableStateOf
25 | import androidx.compose.runtime.remember
26 | import androidx.compose.runtime.toMutableStateList
27 | import androidx.compose.ui.graphics.Color
28 | import dev.sergiobelda.pigment.colorpicker.ColorPicker
29 | import dev.sergiobelda.pigment.colorpicker.ColorPickerItem
30 |
31 | @OptIn(ExperimentalLayoutApi::class)
32 | @Composable
33 | fun ColorPickerFlowRowSample() {
34 | val colorPickerItems = remember { colorPickerItems.toMutableStateList() }
35 | val (selectedColor, onColorSelected) = remember {
36 | mutableStateOf(Color.Unspecified)
37 | }
38 | Column {
39 | ColorPicker.FlowRow(
40 | colors = colorPickerItems,
41 | selectedColor = selectedColor,
42 | onColorSelected = onColorSelected,
43 | )
44 | ColorVisualizer(color = selectedColor)
45 | }
46 | }
47 |
48 | @OptIn(ExperimentalLayoutApi::class)
49 | @Composable
50 | fun ColorPickerFlowRowMapSample() {
51 | val colorMap = remember {
52 | mutableStateMapOf(
53 | "Red" to ColorPickerItem(Color.Red),
54 | "Blue" to ColorPickerItem(Color.Blue),
55 | )
56 | }
57 | val (selectedItem, onItemSelected) = remember {
58 | mutableStateOf("Red")
59 | }
60 | Column {
61 | ColorPicker.FlowRow(
62 | colorsMap = colorMap,
63 | selectedItem = selectedItem,
64 | onItemSelected = onItemSelected,
65 | )
66 | BasicText(text = selectedItem)
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Pigment
2 |
3 | 🎨 A color selector for Compose Multiplatform.
4 |
5 | ## Download
6 |
7 | [](https://search.maven.org/search?q=g:dev.sergiobelda.pigment)
8 |
9 | ### Android
10 |
11 | ```kotlin
12 | dependencies {
13 | implementation("dev.sergiobelda.pigment:pigment:$VERSION")
14 | }
15 | ```
16 |
17 | ### Multiplatform
18 |
19 | ```kotlin
20 | kotlin {
21 | sourceSets {
22 | val commonMain by getting {
23 | dependencies {
24 | implementation("dev.sergiobelda.pigment:pigment:$VERSION")
25 | }
26 | }
27 | }
28 | }
29 | ```
30 |
31 | ## Usage
32 |
33 | ### ColorPicker.FlowRow
34 |
35 |
36 |
37 | ```kotlin
38 | val colorPickerItems = remember {
39 | listOf(
40 | ColorPickerItem(color = Color.Unspecified),
41 | ColorPickerItem(color = Color.Black),
42 | ColorPickerItem(color = Color(0x80FF4444)),
43 | ColorPickerItem(color = Color(0xFFEF5350), enabled = false),
44 | ).toMutableStateList()
45 | }
46 | val (selectedColor, onColorSelected) = remember {
47 | mutableStateOf(Color.Unspecified)
48 | }
49 | ColorPicker.FlowRow(
50 | colors = colorPickerItems,
51 | selectedColor = selectedColor,
52 | onColorSelected = onColorSelected,
53 | )
54 | ```
55 |
56 | ### ColorPicker.LazyRow
57 |
58 |
59 |
60 | ```kotlin
61 | val colorPickerItems = remember {
62 | listOf(
63 | ColorPickerItem(color = Color.Unspecified),
64 | ColorPickerItem(color = Color.Black),
65 | ColorPickerItem(color = Color(0x80FF4444)),
66 | ColorPickerItem(color = Color(0xFFEF5350), enabled = false),
67 | ).toMutableStateList()
68 | }
69 | val (selectedColor, onColorSelected) = remember {
70 | mutableStateOf(Color.Unspecified)
71 | }
72 | ColorPicker.LazyRow(
73 | colors = colorPickerItems,
74 | selectedColor = selectedColor,
75 | onColorSelected = onColorSelected,
76 | )
77 | ```
78 |
79 | -------------------
80 |
81 | ## License
82 |
83 | ```
84 | Copyright 2024 Sergio Belda
85 |
86 | Licensed under the Apache License, Version 2.0 (the "License");
87 | you may not use this file except in compliance with the License.
88 | You may obtain a copy of the License at
89 |
90 | http://www.apache.org/licenses/LICENSE-2.0
91 |
92 | Unless required by applicable law or agreed to in writing, software
93 | distributed under the License is distributed on an "AS IS" BASIS,
94 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95 | See the License for the specific language governing permissions and
96 | limitations under the License.
97 | ```
98 |
--------------------------------------------------------------------------------
/pigment/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.gradle.jvm.tasks.Jar
2 |
3 | plugins {
4 | alias(libs.plugins.androidLibrary)
5 | alias(libs.plugins.kotlinMultiplatform)
6 | alias(libs.plugins.composeCompiler)
7 | alias(libs.plugins.composeMultiplatform)
8 | alias(libs.plugins.dokka)
9 | alias(libs.plugins.paparazzi)
10 | alias(libs.plugins.vanniktechMavenPublish)
11 | id("dev.sergiobelda.pigment-spotless")
12 | }
13 |
14 | group = "dev.sergiobelda.pigment"
15 | version = libs.versions.pigment.get()
16 |
17 | kotlin {
18 | androidTarget()
19 | jvm()
20 | iosX64()
21 | iosArm64()
22 | iosSimulatorArm64()
23 | js {
24 | browser()
25 | binaries.executable()
26 | }
27 |
28 | sourceSets {
29 | val commonMain by getting {
30 | dependencies {
31 | implementation(compose.components.resources)
32 | implementation(compose.material3)
33 | implementation(compose.ui)
34 | }
35 | }
36 | val androidMain by getting {
37 | dependencies {
38 | implementation(libs.androidx.appcompat)
39 | }
40 | }
41 | val androidUnitTest by getting {
42 | dependencies {
43 | implementation(libs.google.testParameterInjector)
44 | }
45 | }
46 | val jsMain by getting
47 | val jsTest by getting
48 | val jvmMain by getting
49 | val jvmTest by getting
50 | val iosX64Main by getting
51 | val iosArm64Main by getting
52 | val iosSimulatorArm64Main by getting
53 | val iosMain by creating
54 | val iosTest by creating
55 | }
56 | }
57 |
58 | android {
59 | namespace = "dev.sergiobelda.pigment"
60 |
61 | compileSdk = 36
62 |
63 | defaultConfig {
64 | minSdk = 21
65 |
66 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
67 | }
68 |
69 | buildTypes {
70 | release {
71 | isMinifyEnabled = false
72 | proguardFiles(
73 | getDefaultProguardFile("proguard-android-optimize.txt"),
74 | "proguard-rules.pro"
75 | )
76 | }
77 | }
78 |
79 | kotlin {
80 | jvmToolchain(17)
81 | }
82 | }
83 |
84 | mavenPublishing {
85 | publishToMavenCentral()
86 |
87 | signAllPublications()
88 | }
89 |
90 | tasks.withType {
91 | from(file("$rootDir/${projects.pigment.name}/samples/src/main/kotlin"))
92 | }
93 |
94 | compose.resources {
95 | packageOfResClass = "dev.sergiobelda.pigment.resources"
96 | }
97 |
98 | dokka {
99 | dokkaSourceSets.configureEach {
100 | samples.from( "$rootDir/${projects.pigment.name}/samples/src/commonMain/kotlin")
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/pigment/samples/src/androidMain/kotlin/dev/sergiobelda/pigment/samples/colorpicker/ColorPickerLazyRowPreviews.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.samples.colorpicker
18 |
19 | import androidx.compose.foundation.shape.RoundedCornerShape
20 | import androidx.compose.runtime.Composable
21 | import androidx.compose.runtime.mutableStateOf
22 | import androidx.compose.runtime.remember
23 | import androidx.compose.runtime.toMutableStateList
24 | import androidx.compose.ui.graphics.Color
25 | import androidx.compose.ui.tooling.preview.Preview
26 | import androidx.compose.ui.tooling.preview.PreviewParameter
27 | import androidx.compose.ui.unit.dp
28 | import dev.sergiobelda.pigment.colorpicker.ColorPicker
29 | import dev.sergiobelda.pigment.colorpicker.ColorPickerDefaults
30 | import dev.sergiobelda.pigment.colorpicker.ColorPickerSize
31 |
32 | @Preview
33 | @Composable
34 | private fun ColorPickerLazyRowPreview() {
35 | ColorPickerLazyRowSample()
36 | }
37 |
38 | @Preview
39 | @Composable
40 | private fun ColorPickerLazyRowMapPreview() {
41 | ColorPickerLazyRowMapSample()
42 | }
43 |
44 | @Preview
45 | @Composable
46 | private fun ColorPickerLazyRowSizePreview(
47 | @PreviewParameter(ColorPickerSizeProvider::class) size: ColorPickerSize,
48 | ) {
49 | val colorPickerItems = remember { colorPickerItems.toMutableStateList() }
50 | val (selectedColor, onColorSelected) = remember {
51 | mutableStateOf(Color.Unspecified)
52 | }
53 | ColorPicker.LazyRow(
54 | colors = colorPickerItems,
55 | selectedColor = selectedColor,
56 | onColorSelected = onColorSelected,
57 | size = size,
58 | )
59 | }
60 |
61 | @Preview
62 | @Composable
63 | private fun ColorPickerLazyRowCustomPreview() {
64 | val colorPickerItems = remember { colorPickerItems.toMutableStateList() }
65 | val (selectedColor, onColorSelected) = remember {
66 | mutableStateOf(Color.Unspecified)
67 | }
68 | ColorPicker.LazyRow(
69 | colors = colorPickerItems,
70 | selectedColor = selectedColor,
71 | onColorSelected = onColorSelected,
72 | shape = RoundedCornerShape(12.dp),
73 | size = ColorPickerSize.Small,
74 | colorIndicatorColors = ColorPickerDefaults.colorIndicatorColors(
75 | onDarkColor = Color.LightGray,
76 | onLightColor = Color.Blue,
77 | ),
78 | )
79 | }
80 |
--------------------------------------------------------------------------------
/pigment/src/androidUnitTest/kotlin/dev/sergiobelda/pigment/colorpicker/ColorPickerTest.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.colorpicker
18 |
19 | // Disabled for now until
20 | // https://youtrack.jetbrains.com/issue/CMP-7276/IllegalStateException-using-Compose-Components-Resources-and-Paparazzi
21 | // is resolved.
22 | /*
23 | import androidx.compose.foundation.layout.ExperimentalLayoutApi
24 | import androidx.compose.ui.graphics.Color
25 | import app.cash.paparazzi.DeviceConfig
26 | import app.cash.paparazzi.Paparazzi
27 | import com.android.ide.common.rendering.api.SessionParams
28 | import com.google.testing.junit.testparameterinjector.TestParameter
29 | import com.google.testing.junit.testparameterinjector.TestParameterInjector
30 | import dev.sergiobelda.pigment.sample.colorPickerItems
31 | import org.junit.Rule
32 | import org.junit.Test
33 | import org.junit.runner.RunWith
34 |
35 | @RunWith(TestParameterInjector::class)
36 | class ColorPickerTest {
37 |
38 | @get:Rule
39 | val paparazzi = Paparazzi(
40 | deviceConfig = DeviceConfig.PIXEL_5,
41 | renderingMode = SessionParams.RenderingMode.SHRINK,
42 | showSystemUi = false,
43 | )
44 |
45 | @OptIn(ExperimentalLayoutApi::class)
46 | @Test
47 | fun FlowRow(
48 | @TestParameter size: ColorPickerSize,
49 | ) {
50 | paparazzi.snapshot {
51 | ColorPicker.FlowRow(
52 | colors = colorPickerItems,
53 | selectedColor = Color.Unspecified,
54 | onColorSelected = {},
55 | size = size,
56 | )
57 | }
58 | }
59 |
60 | @OptIn(ExperimentalLayoutApi::class)
61 | @Test
62 | fun FlowRow(
63 | @TestParameter color: ColorTestCase,
64 | ) {
65 | paparazzi.snapshot {
66 | ColorPicker.FlowRow(
67 | colors = colorPickerItems,
68 | selectedColor = color.value,
69 | onColorSelected = {},
70 | )
71 | }
72 | }
73 |
74 | @Test
75 | fun LazyRow(
76 | @TestParameter size: ColorPickerSize,
77 | ) {
78 | paparazzi.snapshot {
79 | ColorPicker.LazyRow(
80 | colors = colorPickerItems,
81 | selectedColor = Color.Unspecified,
82 | onColorSelected = {},
83 | size = size,
84 | )
85 | }
86 | }
87 | }
88 | */
89 |
--------------------------------------------------------------------------------
/catalog/build.gradle.kts:
--------------------------------------------------------------------------------
1 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2 |
3 | plugins {
4 | kotlin("multiplatform")
5 | alias(libs.plugins.androidApplication)
6 | alias(libs.plugins.composeCompiler)
7 | alias(libs.plugins.composeMultiplatform)
8 | id("dev.sergiobelda.pigment-spotless")
9 | }
10 |
11 | group = "dev.sergiobelda.pigment.catalog"
12 |
13 | kotlin {
14 | androidTarget()
15 | jvm {
16 | compilations.all {
17 | kotlin {
18 | jvmToolchain(17)
19 | }
20 | }
21 | }
22 | listOf(
23 | iosX64(),
24 | iosArm64(),
25 | iosSimulatorArm64()
26 | ).forEach { iosTarget ->
27 | iosTarget.binaries.framework {
28 | baseName = "catalog"
29 | isStatic = true
30 | }
31 | }
32 | js {
33 | browser()
34 | binaries.executable()
35 | }
36 |
37 | sourceSets {
38 | val commonMain by getting {
39 | dependencies {
40 | implementation(projects.pigment)
41 | implementation(projects.pigment.samples)
42 |
43 | implementation(compose.components.resources)
44 | implementation(compose.material3)
45 | implementation(compose.ui)
46 |
47 | implementation(libs.kotlin.collections.immutable)
48 | }
49 | }
50 | val androidMain by getting {
51 | dependencies {
52 | implementation(libs.androidx.activity.compose)
53 | implementation(libs.androidx.appcompat)
54 | implementation(libs.androidx.coreKtx)
55 | implementation(libs.androidx.lifecycle.runtimeKtx)
56 | }
57 | }
58 | val jvmMain by getting {
59 | dependencies {
60 | implementation(compose.desktop.currentOs)
61 | }
62 | }
63 |
64 | all {
65 | languageSettings.optIn("kotlin.RequiresOptIn")
66 | }
67 | }
68 | }
69 |
70 | android {
71 | namespace = "dev.sergiobelda.pigment.catalog"
72 |
73 | compileSdk = 36
74 |
75 | defaultConfig {
76 | applicationId = "dev.sergiobelda.pigment.catalog"
77 | minSdk = 21
78 | targetSdk = 36
79 | versionCode = 1
80 | versionName = "1.0"
81 |
82 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
83 | }
84 |
85 | kotlin {
86 | jvmToolchain(17)
87 | }
88 | buildFeatures {
89 | compose = true
90 | }
91 | }
92 |
93 | dependencies {
94 | implementation(projects.pigment.samples)
95 | }
96 |
97 | compose.desktop {
98 | application {
99 | mainClass = "dev.sergiobelda.pigment.catalog.Main_jvmKt"
100 | nativeDistributions {
101 | targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
102 | }
103 | }
104 | }
105 |
106 | compose.resources {
107 | packageOfResClass = "dev.sergiobelda.pigment.catalog"
108 | }
109 |
--------------------------------------------------------------------------------
/pigment/samples/src/androidMain/kotlin/dev/sergiobelda/pigment/samples/colorpicker/ColorPickerFlowRowPreviews.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2025 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.samples.colorpicker
18 |
19 | import androidx.compose.foundation.layout.ExperimentalLayoutApi
20 | import androidx.compose.foundation.shape.RoundedCornerShape
21 | import androidx.compose.runtime.Composable
22 | import androidx.compose.runtime.mutableStateOf
23 | import androidx.compose.runtime.remember
24 | import androidx.compose.runtime.toMutableStateList
25 | import androidx.compose.ui.graphics.Color
26 | import androidx.compose.ui.tooling.preview.Preview
27 | import androidx.compose.ui.tooling.preview.PreviewParameter
28 | import androidx.compose.ui.unit.dp
29 | import dev.sergiobelda.pigment.colorpicker.ColorPicker
30 | import dev.sergiobelda.pigment.colorpicker.ColorPickerDefaults
31 | import dev.sergiobelda.pigment.colorpicker.ColorPickerSize
32 |
33 | @Preview
34 | @Composable
35 | private fun ColorPickerFlowRowPreview() {
36 | ColorPickerFlowRowSample()
37 | }
38 |
39 | @Preview
40 | @Composable
41 | private fun ColorPickerFlowRowMapPreview() {
42 | ColorPickerFlowRowMapSample()
43 | }
44 |
45 | @OptIn(ExperimentalLayoutApi::class)
46 | @Preview
47 | @Composable
48 | private fun ColorPickerFlowRowSizePreview(
49 | @PreviewParameter(ColorPickerSizeProvider::class) size: ColorPickerSize,
50 | ) {
51 | val colorPickerItems = remember { colorPickerItems.toMutableStateList() }
52 | val (selectedColor, onColorSelected) = remember {
53 | mutableStateOf(Color.Unspecified)
54 | }
55 | ColorPicker.FlowRow(
56 | colors = colorPickerItems,
57 | selectedColor = selectedColor,
58 | onColorSelected = onColorSelected,
59 | size = size,
60 | )
61 | }
62 |
63 | @OptIn(ExperimentalLayoutApi::class)
64 | @Preview
65 | @Composable
66 | private fun ColorPickerFlowRowCustomPreview() {
67 | val colorPickerItems = remember { colorPickerItems.toMutableStateList() }
68 | val (selectedColor, onColorSelected) = remember {
69 | mutableStateOf(Color.Unspecified)
70 | }
71 | ColorPicker.FlowRow(
72 | colors = colorPickerItems,
73 | selectedColor = selectedColor,
74 | onColorSelected = onColorSelected,
75 | shape = RoundedCornerShape(12.dp),
76 | size = ColorPickerSize.Small,
77 | colorIndicatorColors = ColorPickerDefaults.colorIndicatorColors(
78 | onDarkColor = Color.LightGray,
79 | onLightColor = Color.Blue,
80 | ),
81 | )
82 | }
83 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/catalog/src/androidMain/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH="\\\"\\\""
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/catalog-ios/catalog-ios.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 77;
7 | objects = {
8 |
9 | /* Begin PBXFileReference section */
10 | 4225D3F32D187DF80031AC3E /* catalog-ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "catalog-ios.app"; sourceTree = BUILT_PRODUCTS_DIR; };
11 | /* End PBXFileReference section */
12 |
13 | /* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
14 | 4225D40F2D187F820031AC3E /* Exceptions for "catalog-ios" folder in "catalog-ios" target */ = {
15 | isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
16 | membershipExceptions = (
17 | Info.plist,
18 | );
19 | target = 4225D3F22D187DF80031AC3E /* catalog-ios */;
20 | };
21 | /* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
22 |
23 | /* Begin PBXFileSystemSynchronizedRootGroup section */
24 | 4225D3F52D187DF80031AC3E /* catalog-ios */ = {
25 | isa = PBXFileSystemSynchronizedRootGroup;
26 | exceptions = (
27 | 4225D40F2D187F820031AC3E /* Exceptions for "catalog-ios" folder in "catalog-ios" target */,
28 | );
29 | path = "catalog-ios";
30 | sourceTree = "";
31 | };
32 | /* End PBXFileSystemSynchronizedRootGroup section */
33 |
34 | /* Begin PBXFrameworksBuildPhase section */
35 | 4225D3F02D187DF80031AC3E /* Frameworks */ = {
36 | isa = PBXFrameworksBuildPhase;
37 | buildActionMask = 2147483647;
38 | files = (
39 | );
40 | runOnlyForDeploymentPostprocessing = 0;
41 | };
42 | /* End PBXFrameworksBuildPhase section */
43 |
44 | /* Begin PBXGroup section */
45 | 4225D3EA2D187DF80031AC3E = {
46 | isa = PBXGroup;
47 | children = (
48 | 4225D3F52D187DF80031AC3E /* catalog-ios */,
49 | 4225D3F42D187DF80031AC3E /* Products */,
50 | );
51 | sourceTree = "";
52 | };
53 | 4225D3F42D187DF80031AC3E /* Products */ = {
54 | isa = PBXGroup;
55 | children = (
56 | 4225D3F32D187DF80031AC3E /* catalog-ios.app */,
57 | );
58 | name = Products;
59 | sourceTree = "";
60 | };
61 | /* End PBXGroup section */
62 |
63 | /* Begin PBXNativeTarget section */
64 | 4225D3F22D187DF80031AC3E /* catalog-ios */ = {
65 | isa = PBXNativeTarget;
66 | buildConfigurationList = 4225D4012D187DFA0031AC3E /* Build configuration list for PBXNativeTarget "catalog-ios" */;
67 | buildPhases = (
68 | 4225D40D2D187ECF0031AC3E /* ShellScript */,
69 | 4225D3EF2D187DF80031AC3E /* Sources */,
70 | 4225D3F02D187DF80031AC3E /* Frameworks */,
71 | 4225D3F12D187DF80031AC3E /* Resources */,
72 | );
73 | buildRules = (
74 | );
75 | dependencies = (
76 | );
77 | fileSystemSynchronizedGroups = (
78 | 4225D3F52D187DF80031AC3E /* catalog-ios */,
79 | );
80 | name = "catalog-ios";
81 | packageProductDependencies = (
82 | );
83 | productName = "catalog-ios";
84 | productReference = 4225D3F32D187DF80031AC3E /* catalog-ios.app */;
85 | productType = "com.apple.product-type.application";
86 | };
87 | /* End PBXNativeTarget section */
88 |
89 | /* Begin PBXProject section */
90 | 4225D3EB2D187DF80031AC3E /* Project object */ = {
91 | isa = PBXProject;
92 | attributes = {
93 | BuildIndependentTargetsInParallel = 1;
94 | LastSwiftUpdateCheck = 1620;
95 | LastUpgradeCheck = 1620;
96 | TargetAttributes = {
97 | 4225D3F22D187DF80031AC3E = {
98 | CreatedOnToolsVersion = 16.2;
99 | };
100 | };
101 | };
102 | buildConfigurationList = 4225D3EE2D187DF80031AC3E /* Build configuration list for PBXProject "catalog-ios" */;
103 | developmentRegion = en;
104 | hasScannedForEncodings = 0;
105 | knownRegions = (
106 | en,
107 | Base,
108 | );
109 | mainGroup = 4225D3EA2D187DF80031AC3E;
110 | minimizedProjectReferenceProxies = 1;
111 | preferredProjectObjectVersion = 77;
112 | productRefGroup = 4225D3F42D187DF80031AC3E /* Products */;
113 | projectDirPath = "";
114 | projectRoot = "";
115 | targets = (
116 | 4225D3F22D187DF80031AC3E /* catalog-ios */,
117 | );
118 | };
119 | /* End PBXProject section */
120 |
121 | /* Begin PBXResourcesBuildPhase section */
122 | 4225D3F12D187DF80031AC3E /* Resources */ = {
123 | isa = PBXResourcesBuildPhase;
124 | buildActionMask = 2147483647;
125 | files = (
126 | );
127 | runOnlyForDeploymentPostprocessing = 0;
128 | };
129 | /* End PBXResourcesBuildPhase section */
130 |
131 | /* Begin PBXShellScriptBuildPhase section */
132 | 4225D40D2D187ECF0031AC3E /* ShellScript */ = {
133 | isa = PBXShellScriptBuildPhase;
134 | buildActionMask = 2147483647;
135 | files = (
136 | );
137 | inputFileListPaths = (
138 | );
139 | inputPaths = (
140 | );
141 | outputFileListPaths = (
142 | );
143 | outputPaths = (
144 | );
145 | runOnlyForDeploymentPostprocessing = 0;
146 | shellPath = /bin/sh;
147 | shellScript = "cd \"$SRCROOT/..\"\n./gradlew :catalog:embedAndSignAppleFrameworkForXcode\n";
148 | };
149 | /* End PBXShellScriptBuildPhase section */
150 |
151 | /* Begin PBXSourcesBuildPhase section */
152 | 4225D3EF2D187DF80031AC3E /* Sources */ = {
153 | isa = PBXSourcesBuildPhase;
154 | buildActionMask = 2147483647;
155 | files = (
156 | );
157 | runOnlyForDeploymentPostprocessing = 0;
158 | };
159 | /* End PBXSourcesBuildPhase section */
160 |
161 | /* Begin XCBuildConfiguration section */
162 | 4225D3FF2D187DFA0031AC3E /* Debug */ = {
163 | isa = XCBuildConfiguration;
164 | buildSettings = {
165 | ALWAYS_SEARCH_USER_PATHS = NO;
166 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
167 | CLANG_ANALYZER_NONNULL = YES;
168 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
169 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
170 | CLANG_ENABLE_MODULES = YES;
171 | CLANG_ENABLE_OBJC_ARC = YES;
172 | CLANG_ENABLE_OBJC_WEAK = YES;
173 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
174 | CLANG_WARN_BOOL_CONVERSION = YES;
175 | CLANG_WARN_COMMA = YES;
176 | CLANG_WARN_CONSTANT_CONVERSION = YES;
177 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
178 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
179 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
180 | CLANG_WARN_EMPTY_BODY = YES;
181 | CLANG_WARN_ENUM_CONVERSION = YES;
182 | CLANG_WARN_INFINITE_RECURSION = YES;
183 | CLANG_WARN_INT_CONVERSION = YES;
184 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
185 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
186 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
187 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
188 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
189 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
190 | CLANG_WARN_STRICT_PROTOTYPES = YES;
191 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
192 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
193 | CLANG_WARN_UNREACHABLE_CODE = YES;
194 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
195 | COPY_PHASE_STRIP = NO;
196 | DEBUG_INFORMATION_FORMAT = dwarf;
197 | ENABLE_STRICT_OBJC_MSGSEND = YES;
198 | ENABLE_TESTABILITY = YES;
199 | ENABLE_USER_SCRIPT_SANDBOXING = YES;
200 | GCC_C_LANGUAGE_STANDARD = gnu17;
201 | GCC_DYNAMIC_NO_PIC = NO;
202 | GCC_NO_COMMON_BLOCKS = YES;
203 | GCC_OPTIMIZATION_LEVEL = 0;
204 | GCC_PREPROCESSOR_DEFINITIONS = (
205 | "DEBUG=1",
206 | "$(inherited)",
207 | );
208 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
209 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
210 | GCC_WARN_UNDECLARED_SELECTOR = YES;
211 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
212 | GCC_WARN_UNUSED_FUNCTION = YES;
213 | GCC_WARN_UNUSED_VARIABLE = YES;
214 | IPHONEOS_DEPLOYMENT_TARGET = 18.2;
215 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
216 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
217 | MTL_FAST_MATH = YES;
218 | ONLY_ACTIVE_ARCH = YES;
219 | SDKROOT = iphoneos;
220 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
221 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
222 | };
223 | name = Debug;
224 | };
225 | 4225D4002D187DFA0031AC3E /* Release */ = {
226 | isa = XCBuildConfiguration;
227 | buildSettings = {
228 | ALWAYS_SEARCH_USER_PATHS = NO;
229 | ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
230 | CLANG_ANALYZER_NONNULL = YES;
231 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
232 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
233 | CLANG_ENABLE_MODULES = YES;
234 | CLANG_ENABLE_OBJC_ARC = YES;
235 | CLANG_ENABLE_OBJC_WEAK = YES;
236 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
237 | CLANG_WARN_BOOL_CONVERSION = YES;
238 | CLANG_WARN_COMMA = YES;
239 | CLANG_WARN_CONSTANT_CONVERSION = YES;
240 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
241 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
242 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
243 | CLANG_WARN_EMPTY_BODY = YES;
244 | CLANG_WARN_ENUM_CONVERSION = YES;
245 | CLANG_WARN_INFINITE_RECURSION = YES;
246 | CLANG_WARN_INT_CONVERSION = YES;
247 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
248 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
249 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
250 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
251 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
252 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
253 | CLANG_WARN_STRICT_PROTOTYPES = YES;
254 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
255 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
256 | CLANG_WARN_UNREACHABLE_CODE = YES;
257 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
258 | COPY_PHASE_STRIP = NO;
259 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
260 | ENABLE_NS_ASSERTIONS = NO;
261 | ENABLE_STRICT_OBJC_MSGSEND = YES;
262 | ENABLE_USER_SCRIPT_SANDBOXING = YES;
263 | GCC_C_LANGUAGE_STANDARD = gnu17;
264 | GCC_NO_COMMON_BLOCKS = YES;
265 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
266 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
267 | GCC_WARN_UNDECLARED_SELECTOR = YES;
268 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
269 | GCC_WARN_UNUSED_FUNCTION = YES;
270 | GCC_WARN_UNUSED_VARIABLE = YES;
271 | IPHONEOS_DEPLOYMENT_TARGET = 18.2;
272 | LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
273 | MTL_ENABLE_DEBUG_INFO = NO;
274 | MTL_FAST_MATH = YES;
275 | SDKROOT = iphoneos;
276 | SWIFT_COMPILATION_MODE = wholemodule;
277 | VALIDATE_PRODUCT = YES;
278 | };
279 | name = Release;
280 | };
281 | 4225D4022D187DFA0031AC3E /* Debug */ = {
282 | isa = XCBuildConfiguration;
283 | buildSettings = {
284 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
285 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
286 | CODE_SIGN_STYLE = Automatic;
287 | CURRENT_PROJECT_VERSION = 1;
288 | DEVELOPMENT_ASSET_PATHS = "\"catalog-ios/Preview Content\"";
289 | ENABLE_PREVIEWS = YES;
290 | ENABLE_USER_SCRIPT_SANDBOXING = NO;
291 | GENERATE_INFOPLIST_FILE = YES;
292 | INFOPLIST_FILE = "catalog-ios/Info.plist";
293 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
294 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
295 | INFOPLIST_KEY_UILaunchScreen_Generation = YES;
296 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
297 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
298 | LD_RUNPATH_SEARCH_PATHS = (
299 | "$(inherited)",
300 | "@executable_path/Frameworks",
301 | );
302 | MARKETING_VERSION = 1.0;
303 | PRODUCT_BUNDLE_IDENTIFIER = "dev.sergiobelda.pigment.catalog.catalog-ios";
304 | PRODUCT_NAME = "$(TARGET_NAME)";
305 | SWIFT_EMIT_LOC_STRINGS = YES;
306 | SWIFT_VERSION = 5.0;
307 | TARGETED_DEVICE_FAMILY = "1,2";
308 | };
309 | name = Debug;
310 | };
311 | 4225D4032D187DFA0031AC3E /* Release */ = {
312 | isa = XCBuildConfiguration;
313 | buildSettings = {
314 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
315 | ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
316 | CODE_SIGN_STYLE = Automatic;
317 | CURRENT_PROJECT_VERSION = 1;
318 | DEVELOPMENT_ASSET_PATHS = "\"catalog-ios/Preview Content\"";
319 | ENABLE_PREVIEWS = YES;
320 | ENABLE_USER_SCRIPT_SANDBOXING = NO;
321 | GENERATE_INFOPLIST_FILE = YES;
322 | INFOPLIST_FILE = "catalog-ios/Info.plist";
323 | INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
324 | INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
325 | INFOPLIST_KEY_UILaunchScreen_Generation = YES;
326 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
327 | INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
328 | LD_RUNPATH_SEARCH_PATHS = (
329 | "$(inherited)",
330 | "@executable_path/Frameworks",
331 | );
332 | MARKETING_VERSION = 1.0;
333 | PRODUCT_BUNDLE_IDENTIFIER = "dev.sergiobelda.pigment.catalog.catalog-ios";
334 | PRODUCT_NAME = "$(TARGET_NAME)";
335 | SWIFT_EMIT_LOC_STRINGS = YES;
336 | SWIFT_VERSION = 5.0;
337 | TARGETED_DEVICE_FAMILY = "1,2";
338 | };
339 | name = Release;
340 | };
341 | /* End XCBuildConfiguration section */
342 |
343 | /* Begin XCConfigurationList section */
344 | 4225D3EE2D187DF80031AC3E /* Build configuration list for PBXProject "catalog-ios" */ = {
345 | isa = XCConfigurationList;
346 | buildConfigurations = (
347 | 4225D3FF2D187DFA0031AC3E /* Debug */,
348 | 4225D4002D187DFA0031AC3E /* Release */,
349 | );
350 | defaultConfigurationIsVisible = 0;
351 | defaultConfigurationName = Release;
352 | };
353 | 4225D4012D187DFA0031AC3E /* Build configuration list for PBXNativeTarget "catalog-ios" */ = {
354 | isa = XCConfigurationList;
355 | buildConfigurations = (
356 | 4225D4022D187DFA0031AC3E /* Debug */,
357 | 4225D4032D187DFA0031AC3E /* Release */,
358 | );
359 | defaultConfigurationIsVisible = 0;
360 | defaultConfigurationName = Release;
361 | };
362 | /* End XCConfigurationList section */
363 | };
364 | rootObject = 4225D3EB2D187DF80031AC3E /* Project object */;
365 | }
366 |
--------------------------------------------------------------------------------
/pigment/src/commonMain/kotlin/dev/sergiobelda/pigment/colorpicker/ColorPicker.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2024 Sergio Belda
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package dev.sergiobelda.pigment.colorpicker
18 |
19 | import androidx.compose.foundation.Image
20 | import androidx.compose.foundation.border
21 | import androidx.compose.foundation.clickable
22 | import androidx.compose.foundation.gestures.FlingBehavior
23 | import androidx.compose.foundation.gestures.ScrollableDefaults
24 | import androidx.compose.foundation.layout.Arrangement
25 | import androidx.compose.foundation.layout.Box
26 | import androidx.compose.foundation.layout.ExperimentalLayoutApi
27 | import androidx.compose.foundation.layout.FlowRow
28 | import androidx.compose.foundation.layout.FlowRowScope
29 | import androidx.compose.foundation.layout.PaddingValues
30 | import androidx.compose.foundation.layout.fillMaxHeight
31 | import androidx.compose.foundation.layout.fillMaxSize
32 | import androidx.compose.foundation.layout.padding
33 | import androidx.compose.foundation.layout.requiredSize
34 | import androidx.compose.foundation.layout.width
35 | import androidx.compose.foundation.lazy.LazyListScope
36 | import androidx.compose.foundation.lazy.LazyListState
37 | import androidx.compose.foundation.lazy.LazyRow
38 | import androidx.compose.foundation.lazy.items
39 | import androidx.compose.foundation.lazy.rememberLazyListState
40 | import androidx.compose.foundation.shape.CircleShape
41 | import androidx.compose.material3.ripple
42 | import androidx.compose.runtime.Composable
43 | import androidx.compose.runtime.Immutable
44 | import androidx.compose.runtime.Stable
45 | import androidx.compose.runtime.remember
46 | import androidx.compose.ui.Alignment
47 | import androidx.compose.ui.Modifier
48 | import androidx.compose.ui.draw.drawBehind
49 | import androidx.compose.ui.graphics.Color
50 | import androidx.compose.ui.graphics.ColorFilter
51 | import androidx.compose.ui.graphics.Shape
52 | import androidx.compose.ui.graphics.graphicsLayer
53 | import androidx.compose.ui.graphics.luminance
54 | import androidx.compose.ui.graphics.toArgb
55 | import androidx.compose.ui.semantics.CollectionInfo
56 | import androidx.compose.ui.semantics.collectionInfo
57 | import androidx.compose.ui.semantics.semantics
58 | import androidx.compose.ui.unit.Dp
59 | import androidx.compose.ui.unit.dp
60 | import dev.sergiobelda.pigment.colorpicker.ColorPicker.FlowRow
61 | import dev.sergiobelda.pigment.resources.Res
62 | import dev.sergiobelda.pigment.resources.color_off
63 | import dev.sergiobelda.pigment.resources.ic_check_24px
64 | import dev.sergiobelda.pigment.resources.ic_format_color_reset_24px
65 | import dev.sergiobelda.pigment.resources.selected
66 | import org.jetbrains.compose.resources.stringResource
67 | import org.jetbrains.compose.resources.vectorResource
68 |
69 | /**
70 | * A tool that allow user select a color item.
71 | */
72 | object ColorPicker {
73 |
74 | /**
75 | * A ColorPicker that follows the [FlowRow] layout that receives a list of [ColorPickerItem].
76 | *
77 | * @param colors The list of [ColorPickerItem] to be displayed.
78 | * @param selectedColor The selected [Color].
79 | * @param onColorSelected Launched when a color item has been selected.
80 | * @param modifier The modifier to be applied to the Row.
81 | * @param shape Shape of the color items.
82 | * @param size The [ColorPickerSize].
83 | * @param colorIndicatorColors The colors to be applied on the selected indicator for a Color item.
84 | * @param colorIndicatorBorderWidth The border width to be applied on the selected indicator for a Color item.
85 | * @param horizontalArrangement The horizontal arrangement of the layout's children.
86 | * @param verticalArrangement The vertical arrangement of the layout's virtual rows.
87 | * @param maxItemsInEachRow The maximum number of items per row.
88 | * @param maxLines The max number of rows.
89 | *
90 | * @sample dev.sergiobelda.pigment.samples.colorpicker.ColorPickerFlowRowSample
91 | *
92 | * @see FlowRow
93 | */
94 | @OptIn(ExperimentalLayoutApi::class)
95 | @Composable
96 | fun FlowRow(
97 | colors: List,
98 | selectedColor: Color,
99 | onColorSelected: (color: Color) -> Unit,
100 | modifier: Modifier = Modifier,
101 | shape: Shape = ColorPickerDefaults.Shape,
102 | size: ColorPickerSize = ColorPickerDefaults.Size,
103 | colorIndicatorColors: ColorIndicatorColors = ColorPickerDefaults.colorIndicatorColors(),
104 | colorIndicatorBorderWidth: ColorIndicatorBorderWidth = ColorPickerDefaults.colorIndicatorBorderWidth(),
105 | horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
106 | verticalArrangement: Arrangement.Vertical = Arrangement.Top,
107 | maxItemsInEachRow: Int = Int.MAX_VALUE,
108 | maxLines: Int = Int.MAX_VALUE,
109 | ) {
110 | ColorPickerFlowRow(
111 | itemsCount = colors.size,
112 | modifier = modifier,
113 | horizontalArrangement = horizontalArrangement,
114 | verticalArrangement = verticalArrangement,
115 | maxItemsInEachRow = maxItemsInEachRow,
116 | maxLines = maxLines,
117 | ) {
118 | colors.forEach { colorItem ->
119 | // TODO: Add Modifier.semantics { collectionItemInfo }
120 | ColorItem(
121 | colorItem = colorItem,
122 | selected = colorItem.color == selectedColor,
123 | onClick = { onColorSelected(colorItem.color) },
124 | shape = shape,
125 | size = size,
126 | colorIndicatorColors = colorIndicatorColors,
127 | colorIndicatorBorderWidth = colorIndicatorBorderWidth,
128 | )
129 | }
130 | }
131 | }
132 |
133 | /**
134 | * A ColorPicker that follows the [FlowRow] layout that receives a map of a key which
135 | * value is a [ColorPickerItem]. This component is useful when we need to relate a custom object
136 | * that needs to be selected with a [ColorPickerItem].
137 | *
138 | * @param colorsMap A map of [Any] and its [ColorPickerItem] value.
139 | * @param selectedItem The selected item.
140 | * @param onItemSelected Launched when an item has been selected.
141 | * @param modifier The modifier to be applied to the Row.
142 | * @param shape Shape of the color items.
143 | * @param size The [ColorPickerSize].
144 | * @param colorIndicatorColors The colors to be applied on the selected indicator for a Color item.
145 | * @param colorIndicatorBorderWidth The border width to be applied on the selected indicator for a Color item.
146 | * @param horizontalArrangement The horizontal arrangement of the layout's children.
147 | * @param verticalArrangement The vertical arrangement of the layout's virtual rows.
148 | * @param maxItemsInEachRow The maximum number of items per row.
149 | * @param maxLines The max number of rows.
150 | *
151 | * @sample dev.sergiobelda.pigment.samples.colorpicker.ColorPickerFlowRowMapSample
152 | *
153 | * @see FlowRow
154 | */
155 | @OptIn(ExperimentalLayoutApi::class)
156 | @Composable
157 | fun FlowRow(
158 | colorsMap: Map,
159 | selectedItem: T,
160 | onItemSelected: (item: T) -> Unit,
161 | modifier: Modifier = Modifier,
162 | shape: Shape = ColorPickerDefaults.Shape,
163 | size: ColorPickerSize = ColorPickerDefaults.Size,
164 | colorIndicatorColors: ColorIndicatorColors = ColorPickerDefaults.colorIndicatorColors(),
165 | colorIndicatorBorderWidth: ColorIndicatorBorderWidth = ColorPickerDefaults.colorIndicatorBorderWidth(),
166 | horizontalArrangement: Arrangement.Horizontal = Arrangement.Start,
167 | verticalArrangement: Arrangement.Vertical = Arrangement.Top,
168 | maxItemsInEachRow: Int = Int.MAX_VALUE,
169 | maxLines: Int = Int.MAX_VALUE,
170 | ) {
171 | ColorPickerFlowRow(
172 | itemsCount = colorsMap.size,
173 | modifier = modifier,
174 | horizontalArrangement = horizontalArrangement,
175 | verticalArrangement = verticalArrangement,
176 | maxItemsInEachRow = maxItemsInEachRow,
177 | maxLines = maxLines,
178 | ) {
179 | colorsMap.forEach { pair ->
180 | // TODO: Add Modifier.semantics { collectionItemInfo }
181 | ColorItem(
182 | colorItem = pair.value,
183 | selected = pair.key == selectedItem,
184 | onClick = { onItemSelected(pair.key) },
185 | shape = shape,
186 | size = size,
187 | colorIndicatorColors = colorIndicatorColors,
188 | colorIndicatorBorderWidth = colorIndicatorBorderWidth,
189 | )
190 | }
191 | }
192 | }
193 |
194 | /**
195 | * A ColorPicker that follows the [LazyRow] layout that receives a list of [ColorPickerItem].
196 | *
197 | * @param colors The list of [ColorPickerItem] to be displayed.
198 | * @param selectedColor The selected [Color].
199 | * @param onColorSelected Launched when a color item has been selected.
200 | * @param modifier the modifier to apply to this layout
201 | * @param shape Shape of the color items.
202 | * @param size The [ColorPickerSize].
203 | * @param colorIndicatorColors The colors to be applied on the selected indicator for a Color item.
204 | * @param colorIndicatorBorderWidth The border width to be applied on the selected indicator for a Color item.
205 | * @param state the state object to be used to control or observe the list's state
206 | * @param contentPadding a padding around the whole content. This will add padding for the
207 | * content after it has been clipped, which is not possible via [modifier] param. You can use it
208 | * to add a padding before the first item or after the last one. If you want to add a spacing
209 | * between each item use [horizontalArrangement].
210 | * @param reverseLayout reverse the direction of scrolling and layout. When `true`, items are
211 | * laid out in the reverse order and [LazyListState.firstVisibleItemIndex] == 0 means
212 | * that row is scrolled to the end. Note that [reverseLayout] does not change the behavior of
213 | * [horizontalArrangement], e.g. with [Arrangement.Start] [123###] becomes [321###].
214 | * @param horizontalArrangement The horizontal arrangement of the layout's children. This allows
215 | * to add a spacing between items and specify the arrangement of the items when we have not enough
216 | * of them to fill the whole minimum size.
217 | * @param verticalAlignment the vertical alignment applied to the items
218 | * @param flingBehavior logic describing fling behavior.
219 | * @param userScrollEnabled whether the scrolling via the user gestures or accessibility actions
220 | * is allowed. You can still scroll programmatically using the state even when it is disabled.
221 | *
222 | * @sample dev.sergiobelda.pigment.samples.colorpicker.ColorPickerLazyRowSample
223 | *
224 | * @see LazyRow
225 | */
226 | @Composable
227 | fun LazyRow(
228 | colors: List,
229 | selectedColor: Color,
230 | onColorSelected: (color: Color) -> Unit,
231 | modifier: Modifier = Modifier,
232 | shape: Shape = ColorPickerDefaults.Shape,
233 | size: ColorPickerSize = ColorPickerDefaults.Size,
234 | colorIndicatorColors: ColorIndicatorColors = ColorPickerDefaults.colorIndicatorColors(),
235 | colorIndicatorBorderWidth: ColorIndicatorBorderWidth = ColorPickerDefaults.colorIndicatorBorderWidth(),
236 | state: LazyListState = rememberLazyListState(),
237 | contentPadding: PaddingValues = PaddingValues(0.dp),
238 | reverseLayout: Boolean = false,
239 | horizontalArrangement: Arrangement.Horizontal =
240 | if (!reverseLayout) Arrangement.Start else Arrangement.End,
241 | verticalAlignment: Alignment.Vertical = Alignment.Top,
242 | flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
243 | userScrollEnabled: Boolean = true,
244 | ) {
245 | ColorPickerLazyRow(
246 | itemsCount = colors.size,
247 | modifier = modifier,
248 | state = state,
249 | contentPadding = contentPadding,
250 | reverseLayout = reverseLayout,
251 | horizontalArrangement = horizontalArrangement,
252 | verticalAlignment = verticalAlignment,
253 | flingBehavior = flingBehavior,
254 | userScrollEnabled = userScrollEnabled,
255 | ) {
256 | items(
257 | items = colors,
258 | key = { colorItem -> colorItem.color.toArgb() },
259 | contentType = { colorItem -> colorItem.color.toArgb() },
260 | ) { colorItem ->
261 | // TODO: Add Modifier.semantics { collectionItemInfo }
262 | ColorItem(
263 | colorItem = colorItem,
264 | selected = colorItem.color == selectedColor,
265 | onClick = { onColorSelected(colorItem.color) },
266 | shape = shape,
267 | size = size,
268 | colorIndicatorColors = colorIndicatorColors,
269 | colorIndicatorBorderWidth = colorIndicatorBorderWidth,
270 | )
271 | }
272 | }
273 | }
274 |
275 | /**
276 | * A ColorPicker that follows the [LazyRow] layout that receives a map of a key which
277 | * value is a [ColorPickerItem]. This component is useful when we need to relate a custom object
278 | * that needs to be selected with a [ColorPickerItem].
279 | *
280 | * @param colorsMap A map of [Any] and its [ColorPickerItem] value.
281 | * @param selectedItem The selected item.
282 | * @param onItemSelected Launched when an item has been selected.
283 | * @param modifier the modifier to apply to this layout
284 | * @param shape Shape of the color items.
285 | * @param size The [ColorPickerSize].
286 | * @param colorIndicatorColors The colors to be applied on the selected indicator for a Color item.
287 | * @param colorIndicatorBorderWidth The border width to be applied on the selected indicator for a Color item.
288 | * @param state the state object to be used to control or observe the list's state
289 | * @param contentPadding a padding around the whole content. This will add padding for the
290 | * content after it has been clipped, which is not possible via [modifier] param. You can use it
291 | * to add a padding before the first item or after the last one. If you want to add a spacing
292 | * between each item use [horizontalArrangement].
293 | * @param reverseLayout reverse the direction of scrolling and layout. When `true`, items are
294 | * laid out in the reverse order and [LazyListState.firstVisibleItemIndex] == 0 means
295 | * that row is scrolled to the end. Note that [reverseLayout] does not change the behavior of
296 | * [horizontalArrangement], e.g. with [Arrangement.Start] [123###] becomes [321###].
297 | * @param horizontalArrangement The horizontal arrangement of the layout's children. This allows
298 | * to add a spacing between items and specify the arrangement of the items when we have not enough
299 | * of them to fill the whole minimum size.
300 | * @param verticalAlignment the vertical alignment applied to the items
301 | * @param flingBehavior logic describing fling behavior.
302 | * @param userScrollEnabled whether the scrolling via the user gestures or accessibility actions
303 | * is allowed. You can still scroll programmatically using the state even when it is disabled.
304 | *
305 | * @sample dev.sergiobelda.pigment.samples.colorpicker.ColorPickerLazyRowMapSample
306 | *
307 | * @see LazyRow
308 | */
309 | @Composable
310 | fun LazyRow(
311 | colorsMap: Map,
312 | selectedItem: T,
313 | onItemSelected: (item: T) -> Unit,
314 | modifier: Modifier = Modifier,
315 | shape: Shape = ColorPickerDefaults.Shape,
316 | size: ColorPickerSize = ColorPickerDefaults.Size,
317 | colorIndicatorColors: ColorIndicatorColors = ColorPickerDefaults.colorIndicatorColors(),
318 | colorIndicatorBorderWidth: ColorIndicatorBorderWidth = ColorPickerDefaults.colorIndicatorBorderWidth(),
319 | state: LazyListState = rememberLazyListState(),
320 | contentPadding: PaddingValues = PaddingValues(0.dp),
321 | reverseLayout: Boolean = false,
322 | horizontalArrangement: Arrangement.Horizontal =
323 | if (!reverseLayout) Arrangement.Start else Arrangement.End,
324 | verticalAlignment: Alignment.Vertical = Alignment.Top,
325 | flingBehavior: FlingBehavior = ScrollableDefaults.flingBehavior(),
326 | userScrollEnabled: Boolean = true,
327 | ) {
328 | ColorPickerLazyRow(
329 | itemsCount = colorsMap.size,
330 | modifier = modifier,
331 | state = state,
332 | contentPadding = contentPadding,
333 | reverseLayout = reverseLayout,
334 | horizontalArrangement = horizontalArrangement,
335 | verticalAlignment = verticalAlignment,
336 | flingBehavior = flingBehavior,
337 | userScrollEnabled = userScrollEnabled,
338 | ) {
339 | colorsMap.forEach { pair ->
340 | item(
341 | key = pair.value.color.toArgb(),
342 | contentType = pair.value.color.toArgb(),
343 | ) {
344 | // TODO: Add Modifier.semantics { collectionItemInfo }
345 | ColorItem(
346 | colorItem = pair.value,
347 | selected = pair.key == selectedItem,
348 | onClick = { onItemSelected(pair.key) },
349 | shape = shape,
350 | size = size,
351 | colorIndicatorColors = colorIndicatorColors,
352 | colorIndicatorBorderWidth = colorIndicatorBorderWidth,
353 | )
354 | }
355 | }
356 | }
357 | }
358 | }
359 |
360 | @OptIn(ExperimentalLayoutApi::class)
361 | @Composable
362 | private fun ColorPickerFlowRow(
363 | itemsCount: Int,
364 | modifier: Modifier,
365 | horizontalArrangement: Arrangement.Horizontal,
366 | verticalArrangement: Arrangement.Vertical,
367 | maxItemsInEachRow: Int,
368 | maxLines: Int,
369 | content: @Composable FlowRowScope.() -> Unit,
370 | ) = FlowRow(
371 | modifier = modifier.semantics {
372 | collectionInfo = CollectionInfo(
373 | rowCount = maxLines,
374 | columnCount = itemsCount.coerceAtMost(maxItemsInEachRow),
375 | )
376 | },
377 | horizontalArrangement = horizontalArrangement,
378 | verticalArrangement = verticalArrangement,
379 | maxItemsInEachRow = maxItemsInEachRow,
380 | maxLines = maxLines,
381 | content = content,
382 | )
383 |
384 | @Composable
385 | private fun ColorPickerLazyRow(
386 | itemsCount: Int,
387 | modifier: Modifier,
388 | state: LazyListState,
389 | contentPadding: PaddingValues,
390 | reverseLayout: Boolean,
391 | horizontalArrangement: Arrangement.Horizontal,
392 | verticalAlignment: Alignment.Vertical,
393 | flingBehavior: FlingBehavior,
394 | userScrollEnabled: Boolean,
395 | content: LazyListScope.() -> Unit,
396 | ) = LazyRow(
397 | modifier = modifier.semantics {
398 | collectionInfo = CollectionInfo(
399 | rowCount = 1,
400 | columnCount = itemsCount,
401 | )
402 | },
403 | state = state,
404 | contentPadding = contentPadding,
405 | reverseLayout = reverseLayout,
406 | horizontalArrangement = horizontalArrangement,
407 | verticalAlignment = verticalAlignment,
408 | flingBehavior = flingBehavior,
409 | userScrollEnabled = userScrollEnabled,
410 | content = content,
411 | )
412 |
413 | @Composable
414 | internal inline fun ColorItem(
415 | colorItem: ColorPickerItem,
416 | selected: Boolean,
417 | crossinline onClick: () -> Unit,
418 | shape: Shape,
419 | size: ColorPickerSize,
420 | colorIndicatorColors: ColorIndicatorColors,
421 | colorIndicatorBorderWidth: ColorIndicatorBorderWidth,
422 | ) {
423 | Box(
424 | modifier = Modifier
425 | .padding(size.itemSpacing())
426 | .graphicsLayer {
427 | this.shape = shape
428 | clip = true
429 | }
430 | .clickable(
431 | enabled = colorItem.enabled,
432 | indication = ripple(),
433 | interactionSource = null,
434 | ) {
435 | onClick.invoke()
436 | },
437 | ) {
438 | val indicatorSize = size.indicatorSize()
439 | Box(
440 | modifier = Modifier
441 | .padding(ColorItemInnerPadding)
442 | .graphicsLayer {
443 | this.shape = shape
444 | clip = true
445 | }
446 | .requiredSize(indicatorSize),
447 | ) {
448 | when {
449 | colorItem.color != Color.Unspecified -> {
450 | ColorIndicator(
451 | color = colorItem.color,
452 | selected = selected,
453 | shape = shape,
454 | indicatorSize = indicatorSize,
455 | colorIndicatorColors = colorIndicatorColors,
456 | colorIndicatorBorderWidth = colorIndicatorBorderWidth,
457 | )
458 | }
459 |
460 | else -> {
461 | ColorUnspecifiedIndicator(
462 | selected = selected,
463 | )
464 | }
465 | }
466 | }
467 | }
468 | }
469 |
470 | @Composable
471 | internal fun ColorIndicator(
472 | color: Color,
473 | selected: Boolean,
474 | shape: Shape,
475 | indicatorSize: Dp,
476 | colorIndicatorColors: ColorIndicatorColors,
477 | colorIndicatorBorderWidth: ColorIndicatorBorderWidth,
478 | ) {
479 | val selectedColor = colorIndicatorColors.checkColor(color)
480 | val borderWidth = colorIndicatorBorderWidth.borderWidth(color, selected)
481 | val translucentColorWidth = remember(indicatorSize) { indicatorSize / 2 }
482 |
483 | // Translucent color background pattern
484 | Box(
485 | modifier = Modifier
486 | .width(translucentColorWidth)
487 | .fillMaxHeight()
488 | .drawBehind {
489 | drawRect(TranslucentContrastColor)
490 | },
491 | )
492 | // Color indicator
493 | Box(
494 | modifier = Modifier
495 | .fillMaxSize()
496 | .drawBehind {
497 | drawRect(color)
498 | }
499 | .border(
500 | width = borderWidth,
501 | color = selectedColor,
502 | shape = shape,
503 | ),
504 | ) {
505 | if (selected) {
506 | Image(
507 | imageVector = vectorResource(
508 | Res.drawable.ic_check_24px,
509 | ),
510 | contentDescription = stringResource(Res.string.selected),
511 | colorFilter = ColorFilter.tint(selectedColor),
512 | modifier = Modifier.align(Alignment.Center),
513 | )
514 | }
515 | }
516 | }
517 |
518 | @Composable
519 | internal fun ColorUnspecifiedIndicator(
520 | selected: Boolean,
521 | ) {
522 | Box(
523 | modifier = Modifier
524 | .fillMaxSize()
525 | .drawBehind {
526 | drawRect(ColorUnspecifiedIndicatorBackgroundColor)
527 | },
528 | ) {
529 | Image(
530 | imageVector = vectorResource(
531 | Res.drawable.ic_format_color_reset_24px,
532 | ),
533 | contentDescription = stringResource(Res.string.color_off),
534 | modifier = Modifier
535 | .align(Alignment.Center),
536 | colorFilter = ColorFilter.tint(
537 | color = if (selected) {
538 | ColorUnspecifiedIndicatorIconSelectedColor
539 | } else {
540 | ColorUnspecifiedIndicatorIconUnselectedColor
541 | },
542 | ),
543 | )
544 | if (selected) {
545 | Image(
546 | imageVector = vectorResource(Res.drawable.ic_check_24px),
547 | contentDescription = stringResource(Res.string.selected),
548 | modifier = Modifier.align(Alignment.Center),
549 | colorFilter = ColorFilter.tint(ColorUnspecifiedIndicatorSelectedColor),
550 | )
551 | }
552 | }
553 | }
554 |
555 | /**
556 | * Represents the size of items in Color Picker.
557 | */
558 | @Stable
559 | enum class ColorPickerSize {
560 | Small,
561 | Medium,
562 | Large,
563 | ;
564 |
565 | internal fun indicatorSize(): Dp =
566 | when (this) {
567 | Small -> ColorPickerSizeSmall
568 | Medium -> ColorPickerSizeMedium
569 | Large -> ColorPickerSizeLarge
570 | }
571 |
572 | internal fun itemSpacing(): Dp =
573 | when (this) {
574 | Small,
575 | Medium,
576 | Large,
577 | -> ColorItemSpacing
578 | }
579 | }
580 |
581 | /**
582 | * Color indicator border width on different states.
583 | */
584 | @Immutable
585 | data class ColorIndicatorBorderWidth internal constructor(
586 | private val neutralBorderWidth: Dp,
587 | private val selectedBorderWidth: Dp,
588 | private val unselectedBorderWidth: Dp,
589 | ) {
590 | @Stable
591 | internal fun borderWidth(color: Color, selected: Boolean): Dp =
592 | when {
593 | selected -> selectedBorderWidth
594 | color.luminance() !in 0.1..0.9 -> neutralBorderWidth
595 | else -> unselectedBorderWidth
596 | }
597 | }
598 |
599 | /**
600 | * Colors used on the UI elements of the color indicator that is on a specific state
601 | * (e.g. selected, ...).
602 | */
603 | @Immutable
604 | @ConsistentCopyVisibility
605 | data class ColorIndicatorColors internal constructor(
606 | private val onDarkColor: Color,
607 | private val onLightColor: Color,
608 | ) {
609 | @Stable
610 | internal fun checkColor(color: Color): Color =
611 | if (color.luminance() < 0.5) {
612 | onDarkColor
613 | } else {
614 | onLightColor
615 | }
616 | }
617 |
618 | /**
619 | * Defaults used in [ColorPicker].
620 | */
621 | object ColorPickerDefaults {
622 | val Shape: Shape = CircleShape
623 |
624 | val Size: ColorPickerSize = ColorPickerSize.Small
625 |
626 | @Stable
627 | fun colorIndicatorBorderWidth(
628 | neutralBorderWidth: Dp = NeutralBorderWidth,
629 | selectedBorderWidth: Dp = SelectedBorderWidth,
630 | unselectedBorderWidth: Dp = UnselectedBorderWidth,
631 | ): ColorIndicatorBorderWidth =
632 | ColorIndicatorBorderWidth(
633 | neutralBorderWidth = neutralBorderWidth,
634 | selectedBorderWidth = selectedBorderWidth,
635 | unselectedBorderWidth = unselectedBorderWidth,
636 | )
637 |
638 | @Stable
639 | fun colorIndicatorColors(
640 | onDarkColor: Color = Color.White,
641 | onLightColor: Color = Color.Black,
642 | ): ColorIndicatorColors =
643 | ColorIndicatorColors(
644 | onDarkColor = onDarkColor,
645 | onLightColor = onLightColor,
646 | )
647 |
648 | private val NeutralBorderWidth: Dp = 1.dp
649 |
650 | private val SelectedBorderWidth: Dp = 2.dp
651 |
652 | private val UnselectedBorderWidth: Dp = Dp.Unspecified
653 | }
654 |
655 | private const val ColorUnspecifiedIndicatorIconAlpha: Float = 0.2f
656 |
657 | private val ColorUnspecifiedIndicatorIconSelectedColor: Color = Color.Black.copy(
658 | alpha = ColorUnspecifiedIndicatorIconAlpha,
659 | )
660 |
661 | private val ColorUnspecifiedIndicatorIconUnselectedColor: Color = Color.Black
662 |
663 | private val ColorUnspecifiedIndicatorSelectedColor: Color = Color.Black
664 |
665 | private val ColorUnspecifiedIndicatorBackgroundColor: Color = Color.White
666 |
667 | private val ColorItemSpacing: Dp = 4.dp
668 |
669 | private val ColorItemInnerPadding: Dp = 2.dp
670 |
671 | private val ColorPickerSizeSmall: Dp = 36.dp
672 |
673 | private val ColorPickerSizeMedium: Dp = 48.dp
674 |
675 | private val ColorPickerSizeLarge: Dp = 56.dp
676 |
677 | private val TranslucentContrastColor: Color = Color(0xFFBDBDBD)
678 |
--------------------------------------------------------------------------------