Merge "[flexiglass] Add a `PlatformIconButton` to `PlatformButtons`." into main
diff --git a/packages/SystemUI/compose/core/src/com/android/compose/PlatformButtons.kt b/packages/SystemUI/compose/core/src/com/android/compose/PlatformButtons.kt
index bb2fbf7..a18b460 100644
--- a/packages/SystemUI/compose/core/src/com/android/compose/PlatformButtons.kt
+++ b/packages/SystemUI/compose/core/src/com/android/compose/PlatformButtons.kt
@@ -17,6 +17,7 @@
package com.android.compose
+import androidx.annotation.DrawableRes
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.RowScope
@@ -24,8 +25,13 @@
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
+import androidx.compose.material3.Icon
+import androidx.compose.material3.IconButton
+import androidx.compose.material3.IconButtonColors
+import androidx.compose.material3.IconButtonDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
+import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.android.compose.theme.LocalAndroidColorScheme
@@ -89,6 +95,29 @@
)
}
+@Composable
+fun PlatformIconButton(
+ onClick: () -> Unit,
+ modifier: Modifier = Modifier,
+ enabled: Boolean = true,
+ colors: IconButtonColors = iconButtonColors(),
+ @DrawableRes iconResource: Int,
+ contentDescription: String?,
+) {
+ IconButton(
+ modifier = modifier,
+ onClick = onClick,
+ enabled = enabled,
+ colors = colors,
+ ) {
+ Icon(
+ painter = painterResource(id = iconResource),
+ contentDescription = contentDescription,
+ tint = colors.contentColor,
+ )
+ }
+}
+
private val DefaultPlatformButtonVerticalPadding = 6.dp
private val ButtonPaddings = PaddingValues(horizontal = 16.dp, vertical = 8.dp)
@@ -109,6 +138,13 @@
}
@Composable
+private fun iconButtonColors(): IconButtonColors {
+ return IconButtonDefaults.filledIconButtonColors(
+ contentColor = LocalAndroidColorScheme.current.onSurface,
+ )
+}
+
+@Composable
private fun outlineButtonBorder(): BorderStroke {
return BorderStroke(
width = 1.dp,