https://kotlinlang.org logo
#compose-android
Title
# compose-android
a

Arilson José de Oliveira Júnior

03/29/2023, 2:47 PM
Good morning guys! I have a question about compose migration that was raised here in the terms of a single source of truth. If you have a design system (XML) with colors tokens and typography already consolidated and you would initiate a Compose DS, what is the best strategy to maintain the single source of truth pattern in this case? How to access color tokens and how to access typography? Thanks!
t

Thomas Urbanitsch

03/29/2023, 2:58 PM
Some links, assuming “Theming” is what you are looking for: • General: https://developer.android.com/jetpack/compose/designsystems • Example: https://developer.android.com/codelabs/jetpack-compose-theming#3 There is also an additional resource for covering “Migration” (staying on xml for the theming): https://developer.android.com/jetpack/compose/designsystems/views-to-compose
a

Arilson José de Oliveira Júnior

03/29/2023, 3:06 PM
Thanks, @Thomas Urbanitsch! But my question is more about having only one source of color tokens and typography (in XML, as we already have this) for both libraries: XML-based DS and Compose-based DS
t

Thomas Urbanitsch

03/29/2023, 3:16 PM
You want to use definitions for colors and typography written once (preferably using the xml you already have) in both XML Layouts and Compose Layouts, correct?
a

Arilson José de Oliveira Júnior

03/29/2023, 3:22 PM
Yes! Actually, use these definitions in both design systems (XML and Compose)
t

Thomas Urbanitsch

03/29/2023, 3:25 PM
isn’t the last link i shared explaining exactly that? (the accompanist libraries enabling you to use your xml definitions in Compose) 🤔
a

Arilson José de Oliveira Júnior

03/29/2023, 3:28 PM
Yeah, I saw and the AppCompat Theme Adapter appears to work fine, but I don't know in the case of typography 🤔
b

brandonmcansh

03/29/2023, 5:05 PM
There is a parameter to bring over/respect typography in MaterialThemeAdapter
a

Arilson José de Oliveira Júnior

03/30/2023, 11:02 AM
Huuum ok! Thanks guys
m

maiatoday

04/02/2023, 1:26 PM
when last I looked it was possible to convert from xml to compose but only the standard theme elements. If you added custom attributes in your xml theme they wouldn’t convert
5 Views