|
1 | | -# KV Android Color Pallet |
| 1 | +# KV Android Color Pallet |
| 2 | + |
| 3 | +This is a lightweight Android library that generates a color palette from a given color and creates a theme color set for Android applications. |
| 4 | +This library simplifies the process of building consistent and visually appealing color themes. |
| 5 | + |
| 6 | +# Features |
| 7 | +* Generate a color palette based on a single input color. Using color alpha/mat-colors |
| 8 | +* Create a complete theme color set, including primary, secondary, background, and surface colors. |
| 9 | +* Support for Material Design color guidelines. |
| 10 | +* Easy integration with Android projects. |
| 11 | + |
| 12 | +# Installation |
| 13 | +Add following in your root `build.gradle`/`build.gradle.kts` at the end of repositories: |
| 14 | +```` |
| 15 | +dependencyResolutionManagement { |
| 16 | + repositories { |
| 17 | + mavenCentral() |
| 18 | + maven { url 'https://jitpack.io' } // jitpack.io repository configured. |
| 19 | + } |
| 20 | +} |
| 21 | +```` |
| 22 | + |
| 23 | +Add the following dependency to your `build.gradle` / `build.gradle.kts` file: |
| 24 | +For Groovy - `build.gradle`: |
| 25 | +```` |
| 26 | +dependencies { |
| 27 | + implementation 'com.github.kavi707:kv-android-color-pallet:0.0.2' |
| 28 | +} |
| 29 | +```` |
| 30 | +For Kotlin DSL - `build.gradle.kts`: |
| 31 | +```` |
| 32 | +dependencies { |
| 33 | + implementation("com.github.kavi707:kv-android-color-pallet:0.0.2") |
| 34 | +} |
| 35 | +```` |
| 36 | + |
| 37 | +# Usage |
| 38 | +### Initiate |
| 39 | +On usage of the kv-android-color-pallet, from your application class, Initiate it using following code. |
| 40 | +While initiating, you have to parse a color (androidx.compose.ui.graphics.Color) that you prefer to use as your primary color in your application. |
| 41 | +```` |
| 42 | +override fun onCreate() { |
| 43 | + super.onCreate() |
| 44 | + // Initialize the kv-android-color-pallet |
| 45 | + KvColorPallet.init(MatPackage.MatDGreen.color) |
| 46 | +} |
| 47 | +```` |
| 48 | +This initiation create a color set for a theme using the given color at the initiation. |
| 49 | +This generated color set available for light and dark theme variants. |
| 50 | + |
| 51 | +### Use generated theme |
| 52 | +As mentioned above, according to the initiation color, that generate the color set for light and dark them. |
| 53 | +In your Jetpack Compose project, you can assign generate color set the your application theme. |
| 54 | +```` |
| 55 | + // Access the generated theme color set from kv-android-color-pallet library |
| 56 | + val theme = KvColorPallet.appThemePallet |
| 57 | +
|
| 58 | + // Generate application light theme using kv-android-color-pallet light colors |
| 59 | + val themeLight = lightColorScheme( |
| 60 | + primary = theme.light.primary, |
| 61 | + secondary = theme.light.secondary, |
| 62 | + tertiary = theme.light.tertiary, |
| 63 | + background = theme.light.background, |
| 64 | + onPrimary = theme.light.onPrimary, |
| 65 | + onSecondary = theme.light.onSecondary |
| 66 | + ) |
| 67 | +
|
| 68 | + // Generate application dark theme using kv-android-color-pallet dark colors |
| 69 | + val themeDark = darkColorScheme( |
| 70 | + primary = theme.dark.primary, |
| 71 | + secondary = theme.dark.secondary, |
| 72 | + tertiary = theme.dark.tertiary, |
| 73 | + background = theme.dark.background, |
| 74 | + onPrimary = theme.dark.onPrimary, |
| 75 | + onSecondary = theme.dark.onSecondary |
| 76 | + ) |
| 77 | + |
| 78 | + // Generate the color schema |
| 79 | + val appColorScheme = when { |
| 80 | + darkTheme -> themeDark |
| 81 | + else -> themeLight |
| 82 | + } |
| 83 | +
|
| 84 | + // Assign the color schema to the team. |
| 85 | + MaterialTheme( |
| 86 | + colorScheme = appColorScheme, |
| 87 | + typography = AppTypography, |
| 88 | + content = content |
| 89 | + ) |
| 90 | +```` |
| 91 | + |
| 92 | +# Contribution |
| 93 | +We welcome contributions! Please fork the repository, make your changes, and submit a pull request. Ensure your code adheres to the established guidelines. |
| 94 | + |
| 95 | +# License |
| 96 | +kv-android-color-pallet is licensed under the [MIT License](https://github.com/kavi707/kv-android-color-pallet/blob/main/LICENSE). |
| 97 | + |
| 98 | +# Feedback |
| 99 | +For questions, suggestions, or issues, please open an issue on GitHub or contact us at kavimalw@gmail.com. |
| 100 | + |
| 101 | + |
0 commit comments