@@ -51,6 +51,7 @@ import androidx.compose.ui.res.stringResource
5151import androidx.compose.ui.semantics.clearAndSetSemantics
5252import androidx.compose.ui.semantics.contentDescription
5353import androidx.compose.ui.semantics.semantics
54+ import androidx.compose.ui.text.AnnotatedString
5455import androidx.compose.ui.text.TextStyle
5556import androidx.compose.ui.text.style.TextAlign
5657import androidx.compose.ui.tooling.preview.Preview
@@ -60,6 +61,7 @@ import androidx.compose.ui.unit.LayoutDirection
6061import androidx.compose.ui.unit.dp
6162import com.orange.ouds.core.R
6263import com.orange.ouds.core.component.OudsBulletListUnorderedAsset.Bullet.extraParameters
64+ import com.orange.ouds.core.component.common.text.OudsAnnotatedBulletListLabel
6365import com.orange.ouds.core.component.content.OudsComponentContent
6466import com.orange.ouds.core.component.content.OudsComponentIcon
6567import com.orange.ouds.core.component.content.OudsPolymorphicComponentContent
@@ -149,6 +151,36 @@ class OudsBulletListBuilder internal constructor() {
149151 subListType : OudsBulletListType ? = null,
150152 subListTextStyle : OudsBulletListTextStyle ? = null,
151153 builder : (OudsBulletListBuilder .() -> Unit )? = null
154+ ) {
155+ item(label as CharSequence , subListType, subListTextStyle, builder)
156+ }
157+
158+ /* *
159+ * Adds an item to the bullet list.
160+ *
161+ * This function can also define a nested sub-list by providing a `builder` lambda.
162+ *
163+ * @param label The annotated text content of the list item.
164+ * @param subListType The specific [OudsBulletListType] for the nested sub-list, if any.
165+ * If `null`, the type is inherited from the parent list.
166+ * @param subListTextStyle The specific [OudsBulletListTextStyle] for the nested sub-list, if any.
167+ * If `null`, the text style is inherited from the parent list.
168+ * @param builder A lambda scope for defining nested list items.
169+ */
170+ fun item (
171+ label : OudsAnnotatedBulletListLabel ,
172+ subListType : OudsBulletListType ? = null,
173+ subListTextStyle : OudsBulletListTextStyle ? = null,
174+ builder : (OudsBulletListBuilder .() -> Unit )? = null
175+ ) {
176+ item(label.annotatedString, subListType, subListTextStyle, builder)
177+ }
178+
179+ private fun item (
180+ label : CharSequence ,
181+ subListType : OudsBulletListType ? = null,
182+ subListTextStyle : OudsBulletListTextStyle ? = null,
183+ builder : (OudsBulletListBuilder .() -> Unit )? = null
152184 ) {
153185 val subListItems = builder?.let { OudsBulletListBuilder ().apply (it).build() }.orEmpty()
154186 items.add(BulletListItem (label, subListType, subListTextStyle, subListItems))
@@ -247,16 +279,18 @@ private fun OudsBulletListItem(
247279 OudsBulletListFontSize .BodyLarge -> OudsTheme .sizes.maxWidth.type.body.large
248280 OudsBulletListFontSize .BodyMedium -> OudsTheme .sizes.maxWidth.type.body.medium
249281 }
250- Text (
251- modifier = Modifier
252- .fillMaxHeight()
253- .wrapContentHeight() // Allows to center the text vertically when its height is smaller than the row height
254- .widthIn(max = textMaxWidth)
255- .clearAndSetSemantics {},
256- text = item.label,
257- style = currentTextStyle.toTextStyle(),
258- color = OudsTheme .colorScheme.content.default
259- )
282+ val textModifier = Modifier
283+ .fillMaxHeight()
284+ .wrapContentHeight() // Allows to center the text vertically when its height is smaller than the row height
285+ .widthIn(max = textMaxWidth)
286+ .clearAndSetSemantics {}
287+ val text = item.label
288+ val textStyle = currentTextStyle.toTextStyle()
289+ val textColor = OudsTheme .colorScheme.content.default
290+ when (text) {
291+ is AnnotatedString -> Text (modifier = textModifier, text = text, style = textStyle, color = textColor)
292+ is String -> Text (modifier = textModifier, text = text, style = textStyle, color = textColor)
293+ }
260294 }
261295
262296 if (item.subListItems.isNotEmpty()) {
@@ -284,7 +318,7 @@ private fun OudsBulletListItem(
284318}
285319
286320internal data class BulletListItem (
287- val label : String ,
321+ val label : CharSequence ,
288322 val subListType : OudsBulletListType ? ,
289323 val subListTextStyle : OudsBulletListTextStyle ? ,
290324 val subListItems : List <BulletListItem > = emptyList()
0 commit comments