@@ -22,6 +22,7 @@ import androidx.compose.ui.res.stringResource
2222import androidx.compose.ui.tooling.preview.PreviewLightDark
2323import com.orange.ouds.app.R
2424import com.orange.ouds.app.ui.components.Component
25+ import com.orange.ouds.app.ui.components.annotatedStringArgument
2526import com.orange.ouds.app.ui.components.bulletlist.BulletListDemoState.Companion.MaxLevelCount
2627import com.orange.ouds.app.ui.components.bulletlist.BulletListDemoState.Companion.MinLevelCount
2728import com.orange.ouds.app.ui.components.iconArgument
@@ -44,6 +45,11 @@ import com.orange.ouds.core.component.OudsBulletListFontWeight
4445import com.orange.ouds.core.component.OudsBulletListTextStyle
4546import com.orange.ouds.core.component.OudsBulletListType
4647import com.orange.ouds.core.component.OudsBulletListUnorderedAsset
48+ import com.orange.ouds.core.component.common.text.OudsAnnotatedBulletListLabel
49+ import com.orange.ouds.core.component.common.text.OudsLinkAnnotation
50+ import com.orange.ouds.core.component.common.text.buildOudsAnnotatedBulletListLabel
51+ import com.orange.ouds.core.component.common.text.withLink
52+ import com.orange.ouds.core.component.common.text.withStrong
4753import com.orange.ouds.foundation.extensions.toSentenceCase
4854import com.orange.ouds.foundation.extensions.tryOrNull
4955import com.orange.ouds.theme.OudsVersion
@@ -113,32 +119,37 @@ private fun BulletListDemoBottomSheetContent(state: BulletListDemoState) {
113119 applyTopPadding = true ,
114120 label = stringResource(R .string.app_components_common_label_tech),
115121 value = label,
116- onValueChange = { value -> label = value }
122+ onValueChange = { value -> label = value },
123+ enabled = labelTextInputEnabled,
124+ helperText = stringResource(id = R .string.app_components_common_annotatedTextHelperText_tech)
125+ )
126+ CustomizationSwitchItem (
127+ label = stringResource(R .string.app_components_common_annotatedText_tech),
128+ checked = annotatedText,
129+ onCheckedChange = { annotatedText = it },
117130 )
118131 }
119132}
120133
121134@Composable
122135private fun BulletListDemoContent (state : BulletListDemoState ) {
123136 with (state) {
124- val builder: OudsBulletListBuilder .() -> Unit = remember(levelCount, label) {
137+ val builder: OudsBulletListBuilder .() -> Unit = remember(levelCount, label, annotatedText ) {
125138 {
126139 when (levelCount) {
127- 1 -> {
128- item(label = label)
129- item(label = label)
130- item(label = label)
140+ 1 -> repeat(3 ) { index ->
141+ bulletListDemoItem(index, this @with)
131142 }
132143 2 -> {
133- item(label = label ) {
134- item(label = label )
135- item(label = label )
144+ bulletListDemoItem( 0 , this @with ) {
145+ bulletListDemoItem( 1 , this @with )
146+ bulletListDemoItem( 2 , this @with )
136147 }
137148 }
138149 else -> {
139- item(label = label ) {
140- item(label = label ) {
141- item(label = label )
150+ bulletListDemoItem( 0 , this @with ) {
151+ bulletListDemoItem( 1 , this @with ) {
152+ bulletListDemoItem( 2 , this @with )
142153 }
143154 }
144155 }
@@ -155,10 +166,9 @@ private fun BulletListDemoContent(state: BulletListDemoState) {
155166 } else {
156167 type
157168 },
158- textStyle = OudsBulletListTextStyle (fontSize, fontWeight)
159- ) {
160- builder()
161- }
169+ textStyle = OudsBulletListTextStyle (fontSize, fontWeight),
170+ builder = builder
171+ )
162172 }
163173}
164174
@@ -190,19 +200,19 @@ private fun Code.Builder.bulletListDemoCodeSnippet(state: BulletListDemoState, t
190200 when (levelCount) {
191201 1 -> {
192202 repeat(3 ) {
193- itemFunctionCall(label )
203+ itemFunctionCall(state )
194204 }
195205 }
196206 2 -> {
197- itemFunctionCall(label ) {
198- itemFunctionCall(label )
199- itemFunctionCall(label )
207+ itemFunctionCall(state ) {
208+ itemFunctionCall(state )
209+ itemFunctionCall(state )
200210 }
201211 }
202212 else -> {
203- itemFunctionCall(label ) {
204- itemFunctionCall(label ) {
205- itemFunctionCall(label )
213+ itemFunctionCall(state ) {
214+ itemFunctionCall(state ) {
215+ itemFunctionCall(state )
206216 }
207217 }
208218 }
@@ -212,10 +222,16 @@ private fun Code.Builder.bulletListDemoCodeSnippet(state: BulletListDemoState, t
212222 }
213223}
214224
215- private fun Code.Builder.itemFunctionCall (label : String , content : (Code .Builder .() -> Unit )? = null) = functionCall(" item" ) {
225+ private fun Code.Builder.itemFunctionCall (state : BulletListDemoState , content : (Code .Builder .() -> Unit )? = null) = functionCall(" item" ) {
216226 trailingLambda = true
217227 isMultiline = false
218- labelArgument(label)
228+ with (state) {
229+ if (annotatedText) {
230+ annotatedStringArgument<OudsAnnotatedBulletListLabel >(" label" )
231+ } else {
232+ labelArgument(label)
233+ }
234+ }
219235 content?.let {
220236 lambdaArgument(" builder" ) {
221237 content()
@@ -263,6 +279,36 @@ private fun getUnorderedAssetClasses() = if (LocalInspectionMode.current) {
263279 OudsBulletListUnorderedAsset ::class .sealedSubclasses
264280}
265281
282+ private fun OudsBulletListBuilder.bulletListDemoItem (index : Int , state : BulletListDemoState , builder : (OudsBulletListBuilder .() -> Unit )? = null) {
283+ with (state) {
284+ if (annotatedText) {
285+ val annotatedLabel = buildOudsAnnotatedBulletListLabel {
286+ when (index) {
287+ 0 -> {
288+ append(" Your payment was " )
289+ withStrong { append(" declined" ) }
290+ append(" ." )
291+ }
292+ 1 -> {
293+ append(" Check your " )
294+ withStrong { append(" available balance" ) }
295+ append(" before retrying." )
296+ }
297+ 2 -> {
298+ append(" Update your " )
299+ withLink(OudsLinkAnnotation .Url (" https://unified-design-system.orange.com" )) { append(" declined" ) }
300+ append(" if needed." )
301+ }
302+ else -> {}
303+ }
304+ }
305+ item(label = annotatedLabel, builder = builder)
306+ } else {
307+ item(label = label, builder = builder)
308+ }
309+ }
310+ }
311+
266312@PreviewLightDark
267313@Composable
268314private fun PreviewBulletListDemoScreen () = AppPreview {
0 commit comments