Assigned
Status Update
Comments
ad...@google.com <ad...@google.com> #2
Hello, can you please attach a sample that reproduces your error?
No update yet.
Hello, can you please attach a sample that reproduces your error?
Description
Description:
Text
could support receiving both aString
andStringRes
in a single constructor parameter. Currently,Text
has an overloaded constructor to support both of these types in isolation but developers must handle this mapping themselves. This results in requiring twoText
elements to be present in the composition and hiding them/showing them depending on the string approach. For example:Although this simple wrapper has helped rectify the issue in my personal project, it feels as though this should be something that is built into Compose! Its
Use Cases:
The following use cases should benefit from a feature such as this:
Wanting to surface and use a single string-like value when fetching an object from an API; but needing to default some of it's properties to a
StringRes
if they are null or empty. e.g. imagine an app where you can name a dog, or default to the word dog if the user hasn't named it yet -> "{Custom name} ?: R.string.dog_default_name"Building custom reusable Jetpack Compose components that take either a
String
or aStringRes
such that their API is as flexible as possible.