Skip to content
Ghimpu Lucian Eduard edited this page May 25, 2022 · 3 revisions

🎨 Everli Colors

Standalone colors, plain constants that be used anywhere.

Screenshot 2022-05-25 at 23 44 57

Compose

All colors are Compose Color accessible via the EverliColors object:

@Composable
fun SomeText() {
  Text(
    text = "Hello",
    color = EverliColors.Black100,
  )
}

XML

All colors are normal resources stored in colors.xml

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello"
    android:textColor="@color/black_100" />

EverliColor Enum

EverliColor is a utility class supposed to be used in your data layer if needed. It can be helpful when your backend provides it in data objects.

🔧 Utilities

EverliColor.fromString() -> used to handle deserialization.

EverliColor.toColor() -> used to convert to Compose Color.

EverliColor.toResourceId() -> used to convert to XML resource id.

➕ Adding a new color

It mainly involves following the usages mentioned above:

  1. First a new constant in EverliCollors
  2. Then a new resource in colors.xml
  3. Then a new enum value in EverliColor
  4. Finally make sure you also converted EverliColor.toColor() and EverliColor.toResourceId() and unit tests.

Implementation notes

Why not use colorResource(R.color.green_100) in EverliColors to use xml resource as single source of truth?

Because colorResource can only be used from a @Composable scope, limiting the usage of EverliColors

Clone this wiki locally