-
Notifications
You must be signed in to change notification settings - Fork 117
Changed trailingIcon type from val to var #811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,7 +133,7 @@ data class SnackBarItemModel( | |
| val id: String = java.util.UUID.randomUUID().toString(), | ||
| val style: SnackbarStyle = SnackbarStyle.Neutral, | ||
| val leadingIcon: FluentIcon? = null, | ||
| val trailingIcon: FluentIcon? = null, | ||
| var trailingIcon: FluentIcon? = null, | ||
| val subTitle: String? = null, | ||
| val actionText: String? = null, | ||
| val snackBarToken: StackableSnackBarTokens = DEFAULT_SNACKBAR_TOKENS, | ||
|
|
@@ -606,6 +606,7 @@ private fun SnackBarStackItem( | |
| } | ||
| } | ||
|
|
||
|
|
||
| val textPaddingValues = | ||
| if (model.actionText == null && model.trailingIcon != null) PaddingValues( | ||
| start = 16.dp, | ||
|
|
@@ -786,24 +787,24 @@ private fun SnackBarStackItem( | |
| ) | ||
| } | ||
|
|
||
| if (model.trailingIcon != null && model.trailingIcon.isIconAvailable()) { | ||
| if (model.trailingIcon != null && model.trailingIcon!!.isIconAvailable()) { | ||
|
||
| Box( | ||
| modifier = Modifier | ||
| .testTag(SnackBarTestTags.SNACK_BAR_ICON) | ||
| .then( | ||
| if (model.trailingIcon.onClick != null) { | ||
| if (model.trailingIcon!!.onClick != null) { | ||
| Modifier.clickable( | ||
| interactionSource = remember { MutableInteractionSource() }, | ||
| indication = rememberRipple(), | ||
| enabled = true, | ||
| role = Role.Image, | ||
| onClick = model.trailingIcon.onClick!! | ||
| onClick = model.trailingIcon!!.onClick!! | ||
| ) | ||
| } else Modifier | ||
| ) | ||
| ) { | ||
| Icon( | ||
| model.trailingIcon, | ||
| model.trailingIcon!!, | ||
|
Comment on lines
+795
to
+807
|
||
| modifier = Modifier | ||
| .padding(top = 12.dp, bottom = 12.dp, end = 16.dp) | ||
| .size(token.leftIconSize(snackBarInfo)), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing
trailingIconfromvaltovarin a data class marked with@Stableis problematic. The@Stableannotation tells Compose that the object is immutable, but introducing a mutable property violates this contract. This can lead to recomposition issues where changes to the trailingIcon won't trigger proper UI updates. Consider creating a new instance of the model with the updated trailingIcon using the data class copy() method instead of mutating the property.