Added close button to files search popup

This commit is contained in:
Abdelilah El Aissaoui 2023-12-11 20:04:03 +01:00
parent f530e487c7
commit c0046d4086
No known key found for this signature in database
GPG Key ID: 7587FC860F594869

View File

@ -5,6 +5,9 @@ import androidx.compose.foundation.focusable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
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.layout.size
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
@ -13,8 +16,11 @@ import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.input.key.KeyEventType import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.onPreviewKeyEvent import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.key.type import androidx.compose.ui.input.key.type
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.jetpackduba.gitnuro.AppIcons
import com.jetpackduba.gitnuro.extensions.handOnHover
import com.jetpackduba.gitnuro.keybindings.KeybindingOption import com.jetpackduba.gitnuro.keybindings.KeybindingOption
import com.jetpackduba.gitnuro.keybindings.matchesBinding import com.jetpackduba.gitnuro.keybindings.matchesBinding
@ -45,7 +51,22 @@ fun SearchTextField(
hint = "Search files by name or path", hint = "Search files by name or path",
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()
.focusable() .focusable()
.focusRequester(searchFocusRequester) .focusRequester(searchFocusRequester),
trailingIcon = {
IconButton(
onClick = onClose,
modifier = Modifier
.padding(end = 8.dp)
.size(16.dp)
.handOnHover(),
) {
Icon(
painterResource(AppIcons.CLOSE),
contentDescription = null,
tint = MaterialTheme.colors.onBackground
)
}
}
) )
} }
} }