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

Commit 682aa757 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Shortcut Helper - Add "no search results" UI" into main

parents b3624fe4 96534dc1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -3651,6 +3651,8 @@
         hasn't typed in anything in the search box yet. The helper is a  component that shows the
         user which keyboard shortcuts they can use. [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_search_placeholder">Search shortcuts</string>
    <!-- Text shown when a search query didn't produce any results. [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_no_search_results">No search results</string>
    <!-- Content description of the icon that allows to collapse a keyboard shortcut helper category
         panel. The helper is a  component that shows the  user which keyboard shortcuts they can
         use. The helper shows shortcuts in categories, which can be collapsed or expanded.
+45 −8
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.FlowRowScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
@@ -208,9 +209,24 @@ private fun ShortcutHelperSinglePane(
        Spacer(modifier = Modifier.height(6.dp))
        ShortcutsSearchBar(onSearchQueryChanged)
        Spacer(modifier = Modifier.height(16.dp))
        CategoriesPanelSinglePane(searchQuery, categories, selectedCategoryType, onCategorySelected)
        if (categories.isEmpty()) {
            Box(modifier = Modifier.weight(1f)) {
                NoSearchResultsText(horizontalPadding = 16.dp, fillHeight = true)
            }
        } else {
            CategoriesPanelSinglePane(
                searchQuery,
                categories,
                selectedCategoryType,
                onCategorySelected
            )
            Spacer(modifier = Modifier.weight(1f))
        KeyboardSettings(onClick = onKeyboardSettingsClicked)
        }
        KeyboardSettings(
            horizontalPadding = 16.dp,
            verticalPadding = 32.dp,
            onClick = onKeyboardSettingsClicked
        )
    }
}

@@ -429,7 +445,7 @@ private fun ShortcutHelperTwoPane(
@Composable
private fun EndSidePanel(searchQuery: String, modifier: Modifier, category: ShortcutCategory?) {
    if (category == null) {
        // TODO(b/353953351) - Show a "no results" UI?
        NoSearchResultsText(horizontalPadding = 24.dp, fillHeight = false)
        return
    }
    LazyColumn(modifier.nestedScroll(rememberNestedScrollInteropConnection())) {
@@ -440,6 +456,24 @@ private fun EndSidePanel(searchQuery: String, modifier: Modifier, category: Shor
    }
}

@Composable
private fun NoSearchResultsText(horizontalPadding: Dp, fillHeight: Boolean) {
    var modifier = Modifier.fillMaxWidth()
    if (fillHeight) {
        modifier = modifier.fillMaxHeight()
    }
    Text(
        stringResource(R.string.shortcut_helper_no_search_results),
        style = MaterialTheme.typography.bodyMedium,
        color = MaterialTheme.colorScheme.onSurface,
        modifier =
            modifier
                .padding(vertical = 8.dp)
                .background(MaterialTheme.colorScheme.surfaceBright, RoundedCornerShape(28.dp))
                .padding(horizontal = horizontalPadding, vertical = 24.dp)
    )
}

@Composable
private fun SubCategoryContainerDualPane(searchQuery: String, subCategory: ShortcutSubCategory) {
    Surface(
@@ -659,7 +693,11 @@ private fun StartSidePanel(
        Spacer(modifier = Modifier.heightIn(8.dp))
        CategoriesPanelTwoPane(categories, selectedCategory, onCategoryClicked)
        Spacer(modifier = Modifier.weight(1f))
        KeyboardSettings(onKeyboardSettingsClicked)
        KeyboardSettings(
            horizontalPadding = 24.dp,
            verticalPadding = 24.dp,
            onKeyboardSettingsClicked
        )
    }
}

@@ -805,10 +843,9 @@ private fun ShortcutsSearchBar(onQueryChange: (String) -> Unit) {
}

@Composable
private fun KeyboardSettings(onClick: () -> Unit) {
private fun KeyboardSettings(horizontalPadding: Dp, verticalPadding: Dp, onClick: () -> Unit) {
    val interactionSource = remember { MutableInteractionSource() }
    val isFocused by interactionSource.collectIsFocusedAsState()

    Surface(
        onClick = onClick,
        shape = RoundedCornerShape(24.dp),
@@ -834,7 +871,7 @@ private fun KeyboardSettings(onClick: () -> Unit) {
                color = MaterialTheme.colorScheme.onSurfaceVariant,
                fontSize = 16.sp
            )
            Spacer(modifier = Modifier.width(8.dp))
            Spacer(modifier = Modifier.weight(1f))
            Icon(
                imageVector = Icons.AutoMirrored.Default.OpenInNew,
                contentDescription = null,