Skip to content

Commit

Permalink
adding dismissicon token for card nudge (#532)
Browse files Browse the repository at this point in the history
* adding icon drawable support to card Nudge

* seperatring tokens from leading icon and dismiss icon

* reverting drawable changes

* removing unnecessary strings

* accentIcon tint update

---------

Co-authored-by: PraveenKumar <[email protected]>
  • Loading branch information
praveen970 and PraveenKumar authored Oct 16, 2023
1 parent e7e6667 commit 5821943
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ open class CardNudgeTokens : IControlToken, Parcelable {
return aliasTokens.brandForegroundColor[FluentAliasTokens.BrandForegroundColorTokens.BrandForegroundTint].value()
}

@Composable
open fun dismissIconColor(cardNudgeInfo: CardNudgeInfo): Color {
return aliasTokens.brandForegroundColor[FluentAliasTokens.BrandForegroundColorTokens.BrandForegroundTint].value()
}

@Composable
open fun accentColor(cardNudgeInfo: CardNudgeInfo): Color {
return aliasTokens.brandForegroundColor[FluentAliasTokens.BrandForegroundColorTokens.BrandForeground1].value()
Expand Down Expand Up @@ -77,10 +82,10 @@ open class CardNudgeTokens : IControlToken, Parcelable {
FluentGlobalTokens.strokeWidth(FluentGlobalTokens.StrokeWidthTokens.StrokeWidth10)

@Composable
open fun leftIconSize(cardNudgeInfo: CardNudgeInfo): Dp = 24.dp
open fun iconSize(cardNudgeInfo: CardNudgeInfo): Dp = 24.dp

@Composable
open fun leftIconBackgroundSize(cardNudgeInfo: CardNudgeInfo): Dp = 40.dp
open fun iconBackgroundSize(cardNudgeInfo: CardNudgeInfo): Dp = 40.dp

@Composable
open fun dismissIconSize(cardNudgeInfo: CardNudgeInfo): Dp = 20.dp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fun CardNudge(
if (metadata.icon != null && metadata.icon.isIconAvailable()) {
Box(
modifier = Modifier
.size(token.leftIconBackgroundSize(cardNudgeInfo))
.size(token.iconBackgroundSize(cardNudgeInfo))
.background(
token.iconBackgroundBrush(cardNudgeInfo),
CircleShape
Expand All @@ -170,8 +170,8 @@ fun CardNudge(
Icon(
metadata.icon,
modifier = Modifier
.size(token.leftIconSize(cardNudgeInfo)),
tint = token.iconColor(cardNudgeInfo)
.size(token.iconSize(cardNudgeInfo)),
tint = metadata.icon.tint ?: token.iconColor(cardNudgeInfo)
)
}
}
Expand Down Expand Up @@ -199,7 +199,7 @@ fun CardNudge(
) {
Icon(
metadata.accentIcon,
tint = token.accentColor(cardNudgeInfo)
tint = metadata.accentIcon.tint ?: token.accentColor(cardNudgeInfo)
)
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ fun CardNudge(
.padding(10.dp)
.size(token.dismissIconSize(cardNudgeInfo))
.testTag(CARD_NUDGE_DISMISS_BUTTON),
tint = token.iconColor(cardNudgeInfo),
tint = token.dismissIconColor(cardNudgeInfo),
onClick = metadata.dismissOnClick
)
}
Expand Down

0 comments on commit 5821943

Please sign in to comment.