mirror of
https://github.com/JetBrains/intellij-platform-plugin-template.git
synced 2025-12-05 14:21:55 +00:00
Remove unnecessary Column usage
This commit is contained in:
parent
5bae830655
commit
0657ead6a5
@ -51,63 +51,60 @@ internal fun <T> SearchBarWithAutoCompletion(
|
|||||||
.collect { searchTerm -> popupController.onQueryChanged(searchTerm) }
|
.collect { searchTerm -> popupController.onQueryChanged(searchTerm) }
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = modifier) {
|
Box(
|
||||||
Box(
|
modifier = modifier
|
||||||
|
.padding(8.dp)
|
||||||
|
) {
|
||||||
|
var textFieldWidth by remember { mutableIntStateOf(-1) }
|
||||||
|
TextField(
|
||||||
|
state = textFieldState,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
.onGloballyPositioned { coordinates -> textFieldWidth = coordinates.size.width }
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(8.dp)
|
.handlePopupCompletionKeyEvents(popupController) { item ->
|
||||||
) {
|
textFieldState.setTextAndPlaceCursorAtEnd(item.label)
|
||||||
var textFieldWidth by remember { mutableIntStateOf(-1) }
|
onSelectCompletion(item)
|
||||||
TextField(
|
}
|
||||||
state = textFieldState,
|
.focusRequester(focusRequester),
|
||||||
modifier = Modifier
|
placeholder = { Text(searchFieldPlaceholder) },
|
||||||
.onGloballyPositioned { coordinates -> textFieldWidth = coordinates.size.width }
|
leadingIcon = {
|
||||||
.fillMaxWidth()
|
Icon(AllIconsKeys.Actions.Find, contentDescription = "Find icon", Modifier.padding(end = 8.dp))
|
||||||
.handlePopupCompletionKeyEvents(popupController) { item ->
|
},
|
||||||
textFieldState.setTextAndPlaceCursorAtEnd(item.label)
|
trailingIcon = {
|
||||||
onSelectCompletion(item)
|
if (textFieldState.text.isNotBlank()) {
|
||||||
|
CloseIconButton {
|
||||||
|
onClear()
|
||||||
|
textFieldState.setTextAndPlaceCursorAtEnd("")
|
||||||
}
|
}
|
||||||
.focusRequester(focusRequester),
|
}
|
||||||
placeholder = { Text(searchFieldPlaceholder) },
|
},
|
||||||
leadingIcon = {
|
)
|
||||||
Icon(AllIconsKeys.Actions.Find, contentDescription = "Find icon", Modifier.padding(end = 8.dp))
|
|
||||||
},
|
|
||||||
trailingIcon = {
|
|
||||||
if (textFieldState.text.isNotBlank()) {
|
|
||||||
CloseIconButton {
|
|
||||||
onClear()
|
|
||||||
textFieldState.setTextAndPlaceCursorAtEnd("")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
if (popupController.isVisible) {
|
if (popupController.isVisible) {
|
||||||
PopupMenu(
|
PopupMenu(
|
||||||
onDismissRequest = {
|
onDismissRequest = {
|
||||||
popupController.reset()
|
popupController.reset()
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
horizontalAlignment = Alignment.Start,
|
horizontalAlignment = Alignment.Start,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
// Aligns PopupMenu with TextField
|
// Aligns PopupMenu with TextField
|
||||||
.width(with(LocalDensity.current) { textFieldWidth.toDp() })
|
.width(with(LocalDensity.current) { textFieldWidth.toDp() })
|
||||||
.wrapContentHeight()
|
.wrapContentHeight()
|
||||||
.padding(vertical = 4.dp, horizontal = 2.dp)
|
.padding(vertical = 4.dp, horizontal = 2.dp)
|
||||||
.zIndex(5f),
|
.zIndex(5f),
|
||||||
popupProperties = PopupProperties(focusable = false),
|
popupProperties = PopupProperties(focusable = false),
|
||||||
) {
|
) {
|
||||||
popupController.filteredItems.forEach { item ->
|
popupController.filteredItems.forEach { item ->
|
||||||
selectableItem(
|
selectableItem(
|
||||||
popupController. isItemSelected(item),
|
popupController.isItemSelected(item),
|
||||||
onClick = {
|
onClick = {
|
||||||
onSelectCompletion(item)
|
onSelectCompletion(item)
|
||||||
popupController.onItemAutocompleteConfirmed()
|
popupController.onItemAutocompleteConfirmed()
|
||||||
textFieldState.setTextAndPlaceCursorAtEnd(item.label)
|
textFieldState.setTextAndPlaceCursorAtEnd(item.label)
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
Text(item.label)
|
Text(item.label)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user