Repository: Automattic/pocket-casts-android
File: modules/services/compose/src/main/java/au/com/shiftyjelly/pocketcasts/compose/components/Tooltip2.kt (Kotlin)

Code before:
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import au.com.shiftyjelly.pocketcasts.compose.AppThemeWithBackground
import au.com.shiftyjelly.pocketcasts.compose.preview.ThemePreviewParameterProvider
import au.com.shiftyjelly.pocketcasts.compose.theme
import au.com.shiftyjelly.pocketcasts.ui.theme.Theme

@Composable
fun Tooltip2(
    title: String,
    body: String?,
    anchorPosition: AnchorPosition,
    modifier: Modifier = Modifier,
    elevation: Dp = 16.dp,
) {
    val tooltipShape = Tooltip2Shape(anchorPosition)
    val backgroundColor = when (MaterialTheme.theme.type) {
        Theme.ThemeType.DARK_CONTRAST -> MaterialTheme.theme.colors.primaryUi05
        else -> MaterialTheme.theme.colors.primaryUi01
    }

    Box(
        modifier = Modifier
            .then(if (elevation > 0.dp) Modifier.shadow(elevation, tooltipShape) else Modifier)
            .clip(tooltipShape)
            .background(backgroundColor)
            .then(modifier),
    ) {
        Column(
            modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
        ) {
            if (anchorPosition.isTopAligned()) {
                Spacer(
                    modifier = Modifier.height(AnchorHeight),
                )
            }
            TextH40(
                text = title,
            )
            if (body != null) {
                Spacer(
                    modifier = Modifier.height(4.dp),
                )
                TextP50(
                    text = body,
                    color = MaterialTheme.theme.colors.primaryText02,
                )
            }
            if (anchorPosition.isBottomAligned()) {

Review comment (suggestion):
💡 you could just start the expression with `(if (elevation > 0.dp) Modifier.shadow(elevation, tooltipShape) else Modifier).clip(...)`

Code after:
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import au.com.shiftyjelly.pocketcasts.compose.AppThemeWithBackground
import au.com.shiftyjelly.pocketcasts.compose.preview.ThemePreviewParameterProvider
import au.com.shiftyjelly.pocketcasts.compose.theme
import au.com.shiftyjelly.pocketcasts.ui.theme.Theme

@Composable
fun Tooltip2(
    title: String,
    tipPosition: TipPosition,
    modifier: Modifier = Modifier,
    body: String? = null,
    elevation: Dp = 16.dp,
) {
    val tooltipShape = Tooltip2Shape(tipPosition)
    val backgroundColor = when (MaterialTheme.theme.type) {
        Theme.ThemeType.DARK_CONTRAST -> MaterialTheme.theme.colors.primaryUi05
        else -> MaterialTheme.theme.colors.primaryUi01
    }

    Box(
        modifier = (if (elevation > 0.dp) Modifier.shadow(elevation, tooltipShape) else Modifier)
            .clip(tooltipShape)
            .background(backgroundColor)
            .then(modifier),
    ) {
        Column(
            modifier = Modifier.padding(horizontal = 16.dp, vertical = 14.dp),
        ) {
            if (tipPosition.isTopAligned()) {
                Spacer(
                    modifier = Modifier.height(TipHeight),
                )
            }
            TextH40(
                text = title,
            )
            if (body != null) {
                Spacer(
                    modifier = Modifier.height(4.dp),
                )
                TextP50(
                    text = body,
                    color = MaterialTheme.theme.colors.primaryText02,
                )
            }
            if (tipPosition.isBottomAligned()) {
                Spacer(