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

Verified Commit 506d08c5 authored by Saalim Quadri's avatar Saalim Quadri
Browse files

feat: Sync SearchTopBar and Empty State with mocks

parent 93d74105
Loading
Loading
Loading
Loading
Loading
+8 −11
Original line number Original line Diff line number Diff line
@@ -18,11 +18,9 @@


package foundation.e.apps.ui.compose.components
package foundation.e.apps.ui.compose.components


import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.size
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material.icons.outlined.Search
@@ -33,34 +31,33 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import foundation.e.apps.R
import foundation.e.apps.R
import foundation.e.apps.ui.compose.theme.AppTheme
import foundation.e.apps.ui.compose.theme.AppTheme


@Composable
@Composable
fun SearchEmptyState(modifier: Modifier = Modifier) {
fun SearchEmptyState(modifier: Modifier = Modifier) {
    Box(
    Box(
        modifier = modifier
        modifier = modifier.fillMaxSize(),
            .fillMaxSize(),
        contentAlignment = Alignment.Center,
        contentAlignment = Alignment.Center,
    ) {
    ) {
        Column(
        Column(
            horizontalAlignment = Alignment.CenterHorizontally,
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.spacedBy(12.dp),
        ) {
        ) {
            Icon(
            Icon(
                imageVector = Icons.Outlined.Search,
                imageVector = Icons.Outlined.Search,
                contentDescription = null,
                contentDescription = null,
                tint = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.45f),
                tint = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.5f),
                modifier = Modifier
                modifier = Modifier.size(64.dp),
                    .padding(bottom = 4.dp)
                    .size(72.dp),
            )
            )
            Text(
            Text(
                text = stringResource(id = R.string.search_hint),
                text = stringResource(id = R.string.search_hint),
                style = MaterialTheme.typography.bodyMedium,
                fontSize = 18.sp,
                color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.72f),
                color = MaterialTheme.colorScheme.onBackground,
                textAlign = TextAlign.Center,
            )
            )
        }
        }
    }
    }
+77 −66
Original line number Original line Diff line number Diff line
@@ -19,18 +19,20 @@
package foundation.e.apps.ui.compose.components
package foundation.e.apps.ui.compose.components


import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Cancel
import androidx.compose.material.icons.filled.Cancel
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material.icons.outlined.Search
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Composable
@@ -69,8 +71,7 @@ fun SearchTopBar(
    }
    }


    Row(
    Row(
        modifier = modifier
        modifier = modifier.fillMaxWidth(),
            .fillMaxWidth(),
        verticalAlignment = Alignment.CenterVertically,
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.SpaceEvenly
        horizontalArrangement = Arrangement.SpaceEvenly
    ) {
    ) {
@@ -82,14 +83,17 @@ fun SearchTopBar(
            )
            )
        }
        }


        TextField(
        Column(
            modifier = Modifier
            modifier = Modifier
                .padding(end = 16.dp)
                .padding(end = 16.dp)
                .weight(1f)
                .weight(1f)
        ) {
            TextField(
                modifier = Modifier
                    .fillMaxWidth()
                    .focusRequester(focusRequester),
                    .focusRequester(focusRequester),
                value = query,
                value = query,
                onValueChange = onQueryChange,
                onValueChange = onQueryChange,
            placeholder = { Text(text = stringResource(id = R.string.search_hint)) },
                singleLine = true,
                singleLine = true,
                textStyle = MaterialTheme.typography.bodyLarge,
                textStyle = MaterialTheme.typography.bodyLarge,
                leadingIcon = {
                leadingIcon = {
@@ -124,7 +128,7 @@ fun SearchTopBar(
                    capitalization = KeyboardCapitalization.Sentences,
                    capitalization = KeyboardCapitalization.Sentences,
                    imeAction = ImeAction.Search,
                    imeAction = ImeAction.Search,
                ),
                ),
            keyboardActions = androidx.compose.foundation.text.KeyboardActions(
                keyboardActions = KeyboardActions(
                    onSearch = {
                    onSearch = {
                        val trimmedQuery = query.trim()
                        val trimmedQuery = query.trim()
                        if (trimmedQuery.isEmpty()) {
                        if (trimmedQuery.isEmpty()) {
@@ -136,10 +140,10 @@ fun SearchTopBar(
                    },
                    },
                ),
                ),
                colors = TextFieldDefaults.colors(
                colors = TextFieldDefaults.colors(
                focusedIndicatorColor = MaterialTheme.colorScheme.primary,
                    focusedIndicatorColor = Color.Transparent,
                unfocusedIndicatorColor = MaterialTheme.colorScheme.primary,
                    unfocusedIndicatorColor = Color.Transparent,
                disabledIndicatorColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.5f),
                    disabledIndicatorColor = Color.Transparent,
                cursorColor = MaterialTheme.colorScheme.primary,
                    cursorColor = MaterialTheme.colorScheme.tertiary,
                    focusedTextColor = MaterialTheme.colorScheme.onBackground,
                    focusedTextColor = MaterialTheme.colorScheme.onBackground,
                    unfocusedTextColor = MaterialTheme.colorScheme.onBackground,
                    unfocusedTextColor = MaterialTheme.colorScheme.onBackground,
                    disabledTextColor = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.5f),
                    disabledTextColor = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.5f),
@@ -154,6 +158,13 @@ fun SearchTopBar(
                    disabledContainerColor = Color.Transparent,
                    disabledContainerColor = Color.Transparent,
                ),
                ),
            )
            )

            HorizontalDivider(
                modifier = Modifier.padding(start = 12.dp),
                thickness = 2.dp,
                color = MaterialTheme.colorScheme.tertiary
            )
        }
    }
    }
}
}