@@ -22,7 +22,7 @@ import androidx.compose.ui.res.painterResource
2222import androidx.compose.ui.res.stringResource
2323import androidx.compose.ui.tooling.preview.PreviewLightDark
2424import com.orange.ouds.app.R
25- import com.orange.ouds.app.ui.components.alert.AlertMessageDemoState.Companion.MaxBulletCount
25+ import com.orange.ouds.app.ui.components.annotatedStringArgument
2626import com.orange.ouds.app.ui.components.iconArgument
2727import com.orange.ouds.app.ui.components.labelArgument
2828import com.orange.ouds.app.ui.components.onClickArgument
@@ -44,6 +44,13 @@ import com.orange.ouds.core.component.OudsAlertMessage
4444import com.orange.ouds.core.component.OudsAlertMessageActionLink
4545import com.orange.ouds.core.component.OudsAlertMessageActionLinkPosition
4646import com.orange.ouds.core.component.OudsAlertMessageStatus
47+ import com.orange.ouds.core.component.common.text.OudsAnnotatedAlertMessageBulletListLabel
48+ import com.orange.ouds.core.component.common.text.OudsAnnotatedAlertMessageDescription
49+ import com.orange.ouds.core.component.common.text.OudsLinkAnnotation
50+ import com.orange.ouds.core.component.common.text.buildOudsAnnotatedAlertMessageBulletListLabel
51+ import com.orange.ouds.core.component.common.text.buildOudsAnnotatedAlertMessageDescription
52+ import com.orange.ouds.core.component.common.text.withLink
53+ import com.orange.ouds.core.component.common.text.withStrong
4754import com.orange.ouds.foundation.extensions.toSentenceCase
4855import com.orange.ouds.foundation.extensions.tryOrNull
4956import com.orange.ouds.theme.OudsVersion
@@ -123,7 +130,9 @@ private fun AlertMessageDemoBottomSheetContent(state: AlertMessageDemoState) {
123130 applyTopPadding = true ,
124131 label = stringResource(R .string.app_components_common_description_tech),
125132 value = description.orEmpty(),
126- onValueChange = { value -> description = value }
133+ onValueChange = { value -> description = value },
134+ enabled = descriptionTextInputEnabled,
135+ helperText = stringResource(id = R .string.app_components_common_annotatedTextHelperText_tech)
127136 )
128137 CustomizationTextInput (
129138 applyTopPadding = true ,
@@ -143,16 +152,23 @@ private fun AlertMessageDemoBottomSheetContent(state: AlertMessageDemoState) {
143152 selectedChipIndex = OudsAlertMessageActionLinkPosition .entries.indexOf(actionLinkPosition),
144153 onSelectionChange = { id -> actionLinkPosition = OudsAlertMessageActionLinkPosition .entries[id] }
145154 )
146- for (id in 1 . .MaxBulletCount ) {
155+ for (index in 0 .. < AlertMessageDemoState .MaxBulletCount ) {
147156 CustomizationTextInput (
148157 applyTopPadding = true,
149- label = stringResource(R .string.app_components_alert_alertMessage_bullet_tech, id ),
150- value = bulletList?.get(id).orEmpty() ,
158+ label = stringResource(R .string.app_components_alert_alertMessage_bullet_tech, index + 1 ),
159+ value = bulletList[index] ,
151160 onValueChange = { value - >
152- bulletList = bulletList.orEmpty().toMutableMap().apply { put(id, value) }
153- }
161+ bulletList = bulletList.toMutableList().apply { set(index, value) }.toList()
162+ },
163+ enabled = bulletListTextInputsEnabled,
164+ helperText = stringResource(id = R .string.app_components_common_annotatedTextHelperText_tech)
154165 )
155166 }
167+ CustomizationSwitchItem (
168+ label = stringResource(R .string.app_components_common_annotatedText_tech),
169+ checked = annotatedText,
170+ onCheckedChange = { annotatedText = it },
171+ )
156172 }
157173}
158174
@@ -164,27 +180,67 @@ private fun AlertMessageDemoContent(state: AlertMessageDemoState) {
164180 AlertMessageDemoState .Icon .Tinted -> OudsAlertIcon (painter = painterResource(LocalThemeDrawableResources .current.tipsAndTricks), tinted = true )
165181 AlertMessageDemoState .Icon .Untinted -> OudsAlertIcon (painter = rememberUntintedIconPainter(), tinted = false )
166182 }
167- OudsAlertMessage (
168- label = label,
169- description = description,
170- status = when (status) {
171- is OudsAlertMessageStatus .Accent -> OudsAlertMessageStatus .Accent (alertIcon)
172- is OudsAlertMessageStatus .Neutral -> OudsAlertMessageStatus .Neutral (alertIcon)
173- is OudsAlertMessageStatus .Info -> OudsAlertMessageStatus .Info
174- is OudsAlertMessageStatus .Negative -> OudsAlertMessageStatus .Negative
175- is OudsAlertMessageStatus .Positive -> OudsAlertMessageStatus .Positive
176- is OudsAlertMessageStatus .Warning -> OudsAlertMessageStatus .Warning
177- },
178- onClose = if (hasCloseButton) {
179- {}
180- } else {
181- null
182- },
183- actionLink = actionLink?.let { actionLinkLabel ->
184- OudsAlertMessageActionLink (label = actionLinkLabel, onClick = {}, position = actionLinkPosition)
185- },
186- bulletList = bulletList?.toSortedMap()?.values?.toList()
187- )
183+ val status = when (status) {
184+ is OudsAlertMessageStatus .Accent -> OudsAlertMessageStatus .Accent (alertIcon)
185+ is OudsAlertMessageStatus .Neutral -> OudsAlertMessageStatus .Neutral (alertIcon)
186+ is OudsAlertMessageStatus .Info -> OudsAlertMessageStatus .Info
187+ is OudsAlertMessageStatus .Negative -> OudsAlertMessageStatus .Negative
188+ is OudsAlertMessageStatus .Positive -> OudsAlertMessageStatus .Positive
189+ is OudsAlertMessageStatus .Warning -> OudsAlertMessageStatus .Warning
190+ }
191+ val onClose = if (hasCloseButton) {
192+ {}
193+ } else {
194+ null
195+ }
196+ val actionLink = actionLink?.let { actionLinkLabel ->
197+ OudsAlertMessageActionLink (label = actionLinkLabel, onClick = {}, position = actionLinkPosition)
198+ }
199+ if (annotatedText) {
200+ val annotatedDescription = buildOudsAnnotatedAlertMessageDescription {
201+ append(" Your last payment attempt was " )
202+ withStrong { append(" declined" ) }
203+ append(" . Please check your payment details or " )
204+ withStrong { append(" available balance" ) }
205+ append(" and try again, or " )
206+ withLink(OudsLinkAnnotation .Url (" https://unified-design-system.orange.com" )) { append(" update your payment details" ) }
207+ append(" ." )
208+ }
209+ val annotatedBulletList = listOf (
210+ buildOudsAnnotatedAlertMessageBulletListLabel {
211+ append(" Your payment was " )
212+ withStrong { append(" declined" ) }
213+ append(" ." )
214+ },
215+ buildOudsAnnotatedAlertMessageBulletListLabel {
216+ append(" Check your " )
217+ withStrong { append(" available balance" ) }
218+ append(" before retrying." )
219+ },
220+ buildOudsAnnotatedAlertMessageBulletListLabel {
221+ append(" Update your " )
222+ withStrong { append(" payment details" ) }
223+ append(" if needed." )
224+ }
225+ )
226+ OudsAlertMessage (
227+ label = label,
228+ description = annotatedDescription,
229+ status = status,
230+ onClose = onClose,
231+ actionLink = actionLink,
232+ bulletList = annotatedBulletList
233+ )
234+ } else {
235+ OudsAlertMessage (
236+ label = label,
237+ description = description,
238+ status = status,
239+ onClose = onClose,
240+ actionLink = actionLink,
241+ bulletList = bulletList
242+ )
243+ }
188244 }
189245}
190246
@@ -209,7 +265,11 @@ private fun Code.Builder.alertMessageDemoCodeSnippet(state: AlertMessageDemoStat
209265 }
210266 }
211267 labelArgument(label)
212- description?.let { typedArgument(" description" , description) }
268+ if (annotatedText) {
269+ annotatedStringArgument<OudsAnnotatedAlertMessageDescription >(name = " description" )
270+ } else {
271+ description?.let { typedArgument(" description" , description) }
272+ }
213273 if (hasCloseButton) {
214274 lambdaArgument(" onClose" ) {
215275 comment(" Close alert message" )
@@ -224,10 +284,18 @@ private fun Code.Builder.alertMessageDemoCodeSnippet(state: AlertMessageDemoStat
224284 typedArgument(" position" , actionLinkPosition)
225285 }
226286 }
227- bulletList?. let { bulletLabelById ->
287+ if ( bulletList.any { it.isNotBlank() } || annotatedText) {
228288 functionCallArgument(" bulletList" , " listOf" ) {
229- bulletLabelById.toSortedMap().values.forEach { label ->
230- typedArgument(null , label)
289+ if (annotatedText) {
290+ repeat(AlertMessageDemoState .MaxBulletCount ) {
291+ annotatedStringArgument<OudsAnnotatedAlertMessageBulletListLabel >(null )
292+ }
293+ } else {
294+ bulletList.forEach { label ->
295+ if (label.isNotBlank()) {
296+ typedArgument(null , label)
297+ }
298+ }
231299 }
232300 }
233301 }
0 commit comments