Merge "Add onClick for CardPreference" into main

This commit is contained in:
YK Hung
2024-02-23 16:01:05 +00:00
committed by Android (Google) Code Review

View File

@@ -61,6 +61,9 @@ constructor(
/** The visibility of secondary button on tips card. The default value is `false`. */ /** The visibility of secondary button on tips card. The default value is `false`. */
var secondaryButtonVisibility: Boolean = false var secondaryButtonVisibility: Boolean = false
var onClick: (() -> Unit)? = null
/** The callback for click on card preference itself. */
private var onDismiss: (() -> Unit)? = null private var onDismiss: (() -> Unit)? = null
/** Enable the dismiss button on tips card. */ /** Enable the dismiss button on tips card. */
@@ -84,9 +87,10 @@ constructor(
buttons = listOfNotNull(configPrimaryButton(), configSecondaryButton()), buttons = listOfNotNull(configPrimaryButton(), configSecondaryButton()),
onDismiss = onDismiss, onDismiss = onDismiss,
imageVector = imageVector =
iconResId iconResId
?.takeIf { it != Resources.ID_NULL } ?.takeIf { it != Resources.ID_NULL }
?.let { ImageVector.vectorResource(it) }, ?.let { ImageVector.vectorResource(it) },
onClick = onClick,
) )
) )
} }