@@ -36,7 +36,6 @@ import androidx.compose.ui.graphics.StrokeCap
3636import androidx.compose.ui.graphics.painter.Painter
3737import androidx.compose.ui.graphics.vector.ImageVector
3838import androidx.compose.ui.platform.LocalConfiguration
39- import androidx.compose.ui.res.painterResource
4039import androidx.compose.ui.res.stringResource
4140import androidx.compose.ui.semantics.hideFromAccessibility
4241import androidx.compose.ui.semantics.semantics
@@ -55,7 +54,6 @@ import com.orange.ouds.core.extensions.iconSize
5554import com.orange.ouds.core.theme.OudsTheme
5655import com.orange.ouds.core.theme.value
5756import com.orange.ouds.core.utilities.CheckedContent
58- import com.orange.ouds.core.utilities.LayeredTintedPainter
5957import com.orange.ouds.core.utilities.OudsPreview
6058import com.orange.ouds.core.utilities.OudsPreviewLightDark
6159import com.orange.ouds.core.utilities.PreviewGrid
@@ -565,10 +563,15 @@ enum class OudsTagSize {
565563 *
566564 * @property asset The asset to be displayed in the tag, or `null` if there is no asset.
567565 */
568- sealed class OudsTagStatus (val asset : OudsTagAsset ? = null ) {
566+ sealed class OudsTagStatus (private val alertStatus : OudsAlertStatus , val asset : OudsTagAsset ? = null ) {
569567
570568 @Composable
571- internal open fun getDefaultIconPainter (appearance : OudsTagAppearance , enabled : Boolean ): Painter ? = null
569+ internal fun getDefaultIconPainter (appearance : OudsTagAppearance , enabled : Boolean ): Painter ? {
570+ return OudsAlertStatus .getDefaultIconPainter(
571+ status = alertStatus,
572+ layeredTintedWarningPainter = appearance != OudsTagAppearance .Emphasized && enabled
573+ )
574+ }
572575
573576 internal open val defaultIconContentDescription: String
574577 @Composable
@@ -578,7 +581,7 @@ sealed class OudsTagStatus(val asset: OudsTagAsset? = null) {
578581 * Default or inactive status. Used for standard labels, categories, or when no specific status needs to be communicated.
579582 * Its [asset] can be an [OudsTagAsset.Bullet], an [OudsTagAsset.Icon] or `null` if no asset is needed.
580583 */
581- class Neutral internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(asset) {
584+ class Neutral internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(OudsAlertStatus . Neutral (), asset) {
582585 /* *
583586 * Creates an instance of [OudsTagStatus.Neutral] with a bullet.
584587 */
@@ -600,7 +603,7 @@ sealed class OudsTagStatus(val asset: OudsTagAsset? = null) {
600603 * Invites users to explore and engage with new offerings, creating an exciting and engaging experience.
601604 * Its [asset] can be an [OudsTagAsset.Bullet], an [OudsTagAsset.Icon] or `null` if no asset is needed.
602605 */
603- class Accent internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(asset) {
606+ class Accent internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(OudsAlertStatus . Accent (), asset) {
604607 /* *
605608 * Creates an instance of [OudsTagStatus.Accent] with a bullet.
606609 */
@@ -621,7 +624,7 @@ sealed class OudsTagStatus(val asset: OudsTagAsset? = null) {
621624 * Indicates success, confirmation, or a positive status. This functional status is commonly used to highlight completed actions or approved items.
622625 * Its [asset] can be an [OudsTagAsset.Bullet], an [OudsTagAsset.Icon.Default] or `null` if no asset is needed.
623626 */
624- class Positive internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(asset) {
627+ class Positive internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(OudsAlertStatus . Positive (), asset) {
625628 /* *
626629 * Creates an instance of [OudsTagStatus.Positive] with a bullet.
627630 */
@@ -636,17 +639,13 @@ sealed class OudsTagStatus(val asset: OudsTagAsset? = null) {
636639 * Creates an instance of [OudsTagStatus.Positive] with no asset.
637640 */
638641 constructor () : this (null )
639-
640- @Composable
641- override fun getDefaultIconPainter (appearance : OudsTagAppearance , enabled : Boolean ) =
642- painterResource(OudsTheme .drawableResources.component.alert.tickConfirmationFill)
643642 }
644643
645644 /* *
646645 * Conveys informational messages or supplementary details. This functional status is used for neutral, helpful, or contextual information.
647646 * Its [asset] can be an [OudsTagAsset.Bullet], an [OudsTagAsset.Icon.Default] or `null` if no asset is needed.
648647 */
649- class Info internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(asset) {
648+ class Info internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(OudsAlertStatus . Info (), asset) {
650649 /* *
651650 * Creates an instance of [OudsTagStatus.Info] with a bullet.
652651 */
@@ -661,17 +660,13 @@ sealed class OudsTagStatus(val asset: OudsTagAsset? = null) {
661660 * Creates an instance of [OudsTagStatus.Info] with no asset.
662661 */
663662 constructor () : this (null )
664-
665- @Composable
666- override fun getDefaultIconPainter (appearance : OudsTagAppearance , enabled : Boolean ) =
667- painterResource(OudsTheme .drawableResources.component.alert.infoFill)
668663 }
669664
670665 /* *
671666 * Signals caution or a potentially risky situation. This functional status is used to draw attention to items requiring user awareness or intervention.
672667 * Its [asset] can be an [OudsTagAsset.Bullet], an [OudsTagAsset.Icon.Default] or `null` if no asset is needed.
673668 */
674- class Warning internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(asset) {
669+ class Warning internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(OudsAlertStatus . Warning (), asset) {
675670 /* *
676671 * Creates an instance of [OudsTagStatus.Warning] with a bullet.
677672 */
@@ -687,20 +682,6 @@ sealed class OudsTagStatus(val asset: OudsTagAsset? = null) {
687682 */
688683 constructor () : this (null )
689684
690- @Composable
691- override fun getDefaultIconPainter (appearance : OudsTagAppearance , enabled : Boolean ): Painter {
692- val iconTokens = OudsTheme .componentsTokens.icon
693- return when {
694- appearance == OudsTagAppearance .Emphasized || ! enabled -> painterResource(id = OudsTheme .drawableResources.component.alert.warningExternalShape)
695- else -> LayeredTintedPainter (
696- backPainter = painterResource(id = OudsTheme .drawableResources.component.alert.warningExternalShape),
697- backPainterColor = iconTokens.colorContentStatusWarningExternalShape.value,
698- frontPainter = painterResource(id = OudsTheme .drawableResources.component.alert.warningInternalShape),
699- frontPainterColor = iconTokens.colorContentStatusWarningInternalShape.value
700- )
701- }
702- }
703-
704685 override val defaultIconContentDescription
705686 @Composable
706687 get() = stringResource(id = R .string.core_common_warning_a11y)
@@ -710,7 +691,7 @@ sealed class OudsTagStatus(val asset: OudsTagAsset? = null) {
710691 * Represents errors, critical issues, or urgent attention needed. This functional status is used to highlight problems or failed actions.
711692 * Its [asset] can be an [OudsTagAsset.Bullet], an [OudsTagAsset.Icon.Default] or `null` if no asset is needed.
712693 */
713- class Negative internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(asset) {
694+ class Negative internal constructor(asset : OudsTagAsset ? ) : OudsTagStatus(OudsAlertStatus . Negative (), asset) {
714695 /* *
715696 * Creates an instance of [OudsTagStatus.Negative] with a bullet.
716697 */
@@ -726,10 +707,6 @@ sealed class OudsTagStatus(val asset: OudsTagAsset? = null) {
726707 */
727708 constructor () : this (null )
728709
729- @Composable
730- override fun getDefaultIconPainter (appearance : OudsTagAppearance , enabled : Boolean ) =
731- painterResource(OudsTheme .drawableResources.component.alert.importantFill)
732-
733710 override val defaultIconContentDescription
734711 @Composable
735712 get() = stringResource(id = R .string.core_common_error_a11y)
0 commit comments