Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c458fa84 authored by Wes Okuhara's avatar Wes Okuhara
Browse files

Screen Capture: Create primary icon button in Compose

Creates a primary button with text and an optional leading icon in
Compose. The button text and icon are both parameterized. This is
suitable to be used as an action button for capturing the screen.

Screenshot: http://screen/9nSbxzgkenvGEnk.png

Bug: 412723048
Test: Manual
Flag: com.android.systemui.desktop_screen_capture
Change-Id: I229f59dda06249040ae7c22f4615a52a842839a7
parent 092bb913
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
/*
 * 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.ui.compose

import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
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

/** Component for a primary button containing text and an optional leading icon. */
@Composable
fun PrimaryButton(
    text: String,
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    icon: IconModel? = null,
) {
    PlatformButton(modifier = modifier, onClick = onClick) {
        if (icon != null) {
            Icon(icon = icon, modifier = Modifier.size(20.dp))
            Spacer(Modifier.size(5.dp))
        }
        Text(text = text, maxLines = 1)
    }
}