teogor / ceres

🪐 Ceres is a comprehensive Android development framework designed to streamline your app development process. Powered by the latest technologies like Jetpack Compose, Hilt, Coroutines, and Flow, Ceres empowers developers to build modern and efficient Android applications.

Home Page:https://source.teogor.dev/ceres

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FR]: Add Support for Custom Light/Dark Tones in Color Composables

teogor opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Describe the problem

Currently, there are no color composable functions that allow users to set custom light and dark tones or colors for their applications. This issue proposes the addition of two new composable functions to address this gap.

Describe the solution

  1. Add a Color.tone composable function that accepts custom light and dark tone values, allowing users to dynamically set the tones for their app's color scheme.

  2. Add a lightDarkColor composable function that accepts custom light and dark colors as parameters, enabling users to define custom colors for light and dark modes.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Usefulness of Color.tone Function:
The Color.tone function is useful because it allows developers to create a more personalized color scheme for their apps. It provides flexibility by accepting custom light and dark tone values, making it easier to adapt the app's appearance to different preferences and design requirements.

@Composable
fun Color.tone(
  @IntRange(from = 0, to = 100) lightTone: Int,
  @IntRange(from = 0, to = 100) darkTone: Int,
): Color {
  val isDarkMode = MaterialTheme.isDarkMode
  return if (isDarkMode) {
    // Apply the custom dark tone to the color
    // ...
  } else {
    // Apply the custom light tone to the color
    // ...
  }
}

Usefulness of lightDarkColor Function:
The lightDarkColor function is valuable because it allows developers to define custom light and dark colors for their app's theme. It grants the ability to create unique and visually appealing designs that can adapt to different lighting conditions.

@Composable
fun lightDarkColor(
  lightColor: Color,
  darkColor: Color,
): Color {
  val isDarkMode = MaterialTheme.isDarkMode
  return if (isDarkMode) {
    // Use the custom dark color in dark mode
    darkColor
  } else {
    // Use the custom light color in light mode
    lightColor
  }
}