{"id":13428041,"url":"https://github.com/garretyoder/Colorful","last_synced_at":"2025-03-16T01:31:48.327Z","repository":{"id":39898240,"uuid":"70015242","full_name":"garretyoder/Colorful","owner":"garretyoder","description":"Android runtime theme library","archived":true,"fork":false,"pushed_at":"2023-10-10T15:44:56.000Z","size":699,"stargazers_count":2127,"open_issues_count":8,"forks_count":194,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-01-18T21:35:54.952Z","etag":null,"topics":["android","runtime","theme","themes"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/garretyoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-10-04T23:37:42.000Z","updated_at":"2024-12-26T10:24:00.000Z","dependencies_parsed_at":"2024-01-07T06:49:54.794Z","dependency_job_id":"ac612d8a-5d3e-4e22-8e51-18a4507a1530","html_url":"https://github.com/garretyoder/Colorful","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garretyoder%2FColorful","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garretyoder%2FColorful/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garretyoder%2FColorful/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garretyoder%2FColorful/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garretyoder","download_url":"https://codeload.github.com/garretyoder/Colorful/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243814900,"owners_count":20352037,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","runtime","theme","themes"],"created_at":"2024-07-31T01:00:44.756Z","updated_at":"2025-03-16T01:31:47.968Z","avatar_url":"https://github.com/garretyoder.png","language":"Kotlin","readme":"# Discontinued\nAndroid has had native theming for awhile now, so Colorful's purpose has been served and the library has been discontinued.\n\n\u003cimg src=\"screenshots/Colorful.png\" width=\"200\"\u003e\n\n# Colorful\n[![Release](https://jitpack.io/v/garretyoder/Colorful.svg)](https://jitpack.io/#garretyoder/Colorful) [![Build Status](https://travis-ci.org/garretyoder/Colorful.svg?branch=master)](https://travis-ci.org/garretyoder/Colorful)\n\n\nColorful is a dynamic theme library allowing you to change your apps' color schemes easily.\n\n*Colorful v2 is here! v2 has been rewritten from the ground up in Kotlin to be lighter, faster, and more feature-packed*\n\n## License\n\nColorful is licensed under the Apache 2.0 License\n\nCopyright 2018 Garret Yoder\n\n|                                    |                                    |                                    |\n| ---------------------------------- | ---------------------------------- | ---------------------------------- |\n| ![Image](screenshots/screen1.png)  | ![Image](screenshots/screen2.png)  | ![Image](screenshots/screen3.png)  |\n\n## Installation\nAdd jitpack to your maven sources\n```groovy\nallprojects {\n    repositories {\n        ...\n        maven { url \"https://jitpack.io\" }\n    }\n}\n```\nAdd Colorful as a dependency to your `build.gradle`\n```groovy\ndependencies {\n    implementation 'com.github.garretyoder:Colorful:2.3.4'\n}\n```\n\n## Usage\n\n### Initialization\n\nIn your `Application` class, you must initialize Colorful and set the default theme colors.\n```kotlin\nclass SampleApp:Application() {\n    override fun onCreate() {\n        super.onCreate()\n        val defaults:Defaults = Defaults(\n                primaryColor = ThemeColor.GREEN,\n                accentColor = ThemeColor.BLUE,\n                useDarkTheme = false,\n                translucent = false)\n        initColorful(this, defaults)\n    }\n}\n```\nThe following is a list of all theme colors available. \n```kotlin\nThemeColor.RED\nThemeColor.PINK\nThemeColor.PURPLE\nThemeColor.DEEP_PURPLE\nThemeColor.INDIGO\nThemeColor.BLUE\nThemeColor.LIGHT_BLUE\nThemeColor.CYAN\nThemeColor.TEAL\nThemeColor.GREEN\nThemeColor.LIGHT_GREEN\nThemeColor.LIME\nThemeColor.YELLOW\nThemeColor.AMBER\nThemeColor.ORANGE\nThemeColor.DEEP_ORANGE\nThemeColor.BROWN\nThemeColor.GREY\nThemeColor.BLUE_GREY\nThemeColor.WHITE\nThemeColor.BLACK\n```\n\n### Using Themes\n\nAny `Activity` you wish to be automatically themed must inherit from either `CActivity`, `CAppCompatActivity` if you wish to use AppCompat or `CMaterialActivity` if you wish to use the new Material Componets theme. *Note* The material componets theme is still beta and is available only in the testing android-p branch. To use the material-componets theme, please add the android-p colorful branch to your gradle build.\n```kotlin\nclass MainActivity : CActivity()\n```\n```kotlin\nclass MainActivity : CAppCompatActivity()\n```\n*Only available in the android-p branch*\n```kotlin\nclass MainActivity : CMaterialActivity()\n```\nIf you wish to use your own activity, you can manually apply Colorful's theme to any activity using `apply(activity:Activity)`\n```kotlin\nColorful().apply(this, override = true, baseTheme = BaseTheme.THEME_MATERIAL)\n```\nThe `override` value will control whether Colorful overrides your activitie's existing base theme, or merely sets primary and accent colors. **Note**: dark/light themeing will not work when override is disabled\nThe `baseTheme` value will control which base theme Colorful will use, Appcompat, Material, or Material Componets.\n\nAlternatively, as of Colorful 2.1, you can now have your activity inherit from the interface `CThemeInterface` which will provide the `handleOnCreate` and `handleOnResume` methods for automatic theme handling.\nSee both [CActivity](https://github.com/garretyoder/Colorful/blob/master/library/src/main/java/io/multimoon/colorful/CActivity.kt) and [CAppCompatActivity](https://github.com/garretyoder/Colorful/blob/master/library/src/main/java/io/multimoon/colorful/CAppCompatActivity.kt) for examples on how to implement the `CThemeInterface`\n\n### Setting The Theme\n\nYou can set the colors at any time using the `edit()` method\n```kotlin\nColorful().edit()\n        .setPrimaryColor(ThemeColor.RED)\n        .setAccentColor(ThemeColor.BLUE)\n        .setDarkTheme(true)\n        .setTranslucent(true)\n        .apply(context:Context)\n```\nYou must call `apply(context:Context)` to save your changes\n\n`primaryColor` the primary color of your theme. This affects componets such as toolbars, task descriptions, etc\n`accentColor` the accent color of your theme. This affects componets such as buttons, sliders, checkboxes, etc\n`darkTheme` the base theme of your style. This controls whether the theme is dark or light.\n`translucent` This controls whether translucency is enabled. This will turn the status bar translucent or solid\n\nColorful will handle saving and loading your theme preferences for you.\n\nThe `apply` method optionally takes a high-order function as a argument. This serves as a callback that will be triggered once Colorful has finished it's theme changes. A example usage would be to recreate the current activity after setting a new theme to immediately reflect changes.\n```kotlin\nColorful().edit()\n    .setPrimaryColor(ThemeColor.PURPLE)\n    .setAccentColor(ThemeColor.GREEN)\n    .apply(this) { \n        this.recreate() \n    }\n```\n\n### Getting the current theme values\n\nColorful can provide you with hex string, or android rgb int formatted values for the currently set colors. This is acheived through the `ColorPack` class, which is a pack that contains both dark and normal variants of the color. These are based off the Material Color Pallet 500 (normal) and 700 (dark) values. Examples are shown below.\n```kotlin\nColorful().getPrimaryColor().getColorPack().dark().asInt()\nColorful().getAccentColor().getColorPack().normal().asHex()\n```\n`Colorful().getDarkTheme()` will return a `boolean` value for whether the dark theme is enabled\n\n`Colorful().getTranslucent()` will return a `boolean` value for whether the current style has transluceny enabled.\n\n\n### Custom styles\n\nColorful has beta support for combining your own styles with it's own. This is not yet guaranteed to work reliably. \n```kotlin\nColorful().edit()\n                .setPrimaryColor(ThemeColor.RED)\n                .setAccentColor(ThemeColor.BLUE)\n                .setDarkTheme(true)\n                .setTranslucent(true)\n                .setCustomThemeOverride(R.style.AppTheme)\n                .apply(this)\n ```\n The `setCustomThemeOverride` method will allow Colorful to mix a provided theme with it's own. If you wish to set specific theme items yourself, such as coloring all text orange, you can do this within a style file and then have Colorful merge it with it's own theme.\n\n### Custom theme colors\n\nColorful allows you to define custom themes (e.g. light red primary color with dark yellow accents). If you want to use custom styles you have to do following 3 things:\n\n1. create styles for your custom themes:\n\n```kotlin\n\u003cstyle name=\"my_custom_primary_color\"\u003e\n\t\u003citem name=\"android:colorPrimary\"\u003e@color/md_red_200\u003c/item\u003e\n\t\u003citem name=\"colorPrimary\"\u003e@color/md_red_200\u003c/item\u003e\n\u003c/style\u003e\n\u003cstyle name=\"my_custom_primary_dark_color\"\u003e\n\t\u003citem name=\"android:colorPrimaryDark\"\u003e@color/md_red_400\u003c/item\u003e\n\t\u003citem name=\"colorPrimaryDark\"\u003e@color/md_red_400\u003c/item\u003e\n\u003c/style\u003e\n\u003cstyle name=\"my_custom_accent_color\"\u003e\n\t\u003citem name=\"android:colorAccent\"\u003e@color/md_yellow_700\u003c/item\u003e\n\t\u003citem name=\"colorAccent\"\u003e@color/md_yellow_700\u003c/item\u003e\n\u003c/style\u003e\n```\n \n 2. Create a custom theme color object, like following:\n \n```kotlin\nvar myCustomColor1 = CustomThemeColor(\n\tcontext,\n\tR.style.my_custom_primary_color,\n\tR.style.my_custom_primary_dark_color,\n\tR.color.md_red_200, // \u003c= use the color you defined in my_custom_primary_color\n\tR.color.md_red_400 // \u003c= use the color you defined in my_custom_primary_dark_color\n)\n// used as accent color, dark color is irrelevant...\nvar myCustomColor2 = CustomThemeColor(\n\tcontext,\n\tR.style.my_custom_accent_color,\n\tR.style.my_custom_accent_color,\n\tR.color.md_yellow_700, // \u003c= use the color you defined in my_custom_accent_color\n\tR.color.md_yellow_700 // \u003c= use the color you defined in my_custom_accent_color\n)\n```\n  \n3. use this custom theme color object like you would use any `ThemeColor.\u003cCOLOR\u003e` enum object, e.g.\n \n```kotlin\nvar defaults = Defaults(\n\tprimaryColor = myCustomColor1,\n\taccentColor = myCustomColor2,\n\tuseDarkTheme = true,\n\ttranslucent = false,\n\tcustomTheme = 0\n)\n```\n","funding_links":[],"categories":["Libraries","主题样式","Theme / Skin"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarretyoder%2FColorful","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarretyoder%2FColorful","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarretyoder%2FColorful/lists"}