fix: wire contacts quick actions to form fields
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package ru.daemonlord.messenger.ui.contacts
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -43,6 +44,8 @@ import androidx.compose.runtime.snapshotFlow
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@@ -85,6 +88,8 @@ private fun ContactsScreen(
|
||||
) {
|
||||
val listState = rememberLazyListState()
|
||||
val isTabletLayout = LocalConfiguration.current.screenWidthDp >= 840
|
||||
val searchFocusRequester = remember { FocusRequester() }
|
||||
val emailFocusRequester = remember { FocusRequester() }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
onMainBarVisibilityChanged(true)
|
||||
@@ -141,7 +146,9 @@ private fun ContactsScreen(
|
||||
OutlinedTextField(
|
||||
value = state.query,
|
||||
onValueChange = onQueryChanged,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.focusRequester(searchFocusRequester),
|
||||
singleLine = true,
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
@@ -185,12 +192,14 @@ private fun ContactsScreen(
|
||||
icon = Icons.Filled.PersonAdd,
|
||||
title = stringResource(id = R.string.contacts_action_find_people),
|
||||
subtitle = stringResource(id = R.string.contacts_action_find_people_subtitle),
|
||||
onClick = { searchFocusRequester.requestFocus() },
|
||||
)
|
||||
ContactActionCard(
|
||||
modifier = Modifier.weight(1f),
|
||||
icon = Icons.Filled.Email,
|
||||
title = stringResource(id = R.string.contacts_action_add_email),
|
||||
subtitle = stringResource(id = R.string.contacts_action_add_email_subtitle),
|
||||
onClick = { emailFocusRequester.requestFocus() },
|
||||
)
|
||||
}
|
||||
Row(
|
||||
@@ -201,7 +210,9 @@ private fun ContactsScreen(
|
||||
OutlinedTextField(
|
||||
value = state.addByEmail,
|
||||
onValueChange = onAddByEmailChanged,
|
||||
modifier = Modifier.weight(1f),
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.focusRequester(emailFocusRequester),
|
||||
singleLine = true,
|
||||
label = { Text(stringResource(id = R.string.contacts_add_by_email_label)) },
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
@@ -307,9 +318,10 @@ private fun ContactActionCard(
|
||||
icon: androidx.compose.ui.graphics.vector.ImageVector,
|
||||
title: String,
|
||||
subtitle: String,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Surface(
|
||||
modifier = modifier,
|
||||
modifier = modifier.clickable(onClick = onClick),
|
||||
shape = RoundedCornerShape(20.dp),
|
||||
color = MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.34f),
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user