/* * Copyright (C) 2025 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.screencapture.common.ui.compose import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.size import androidx.compose.material3.ButtonColors import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import com.android.compose.PlatformButton import com.android.systemui.common.shared.model.Icon as IconModel import com.android.systemui.common.ui.compose.Icon private val ButtonPaddings = PaddingValues(horizontal = 16.dp, vertical = 8.dp) /** Component for a primary button containing text and an optional leading icon. */ @Composable fun PrimaryButton( text: String, onClick: () -> Unit, modifier: Modifier = Modifier, enabled: Boolean = true, icon: IconModel? = null, contentPadding: PaddingValues = ButtonPaddings, iconPadding: Dp = 5.dp, colors: ButtonColors = ButtonDefaults.buttonColors( containerColor = MaterialTheme.colorScheme.primary, contentColor = MaterialTheme.colorScheme.onPrimary, ), ) { PlatformButton( onClick = onClick, modifier = modifier, enabled = enabled, colors = colors, contentPadding = contentPadding, ) { if (icon != null) { Icon(icon = icon, modifier = Modifier.size(20.dp).align(Alignment.CenterVertically)) Spacer(Modifier.size(iconPadding)) } Text(text = text, maxLines = 1, modifier = Modifier.align(Alignment.CenterVertically)) } }