mirror of
https://github.com/Myzel394/NumberHub.git
synced 2025-06-19 08:45:27 +02:00
Don't remember toolbar
This commit is contained in:
parent
6b47aeaaae
commit
be78dd2347
@ -85,8 +85,7 @@ fun ExpressionTextField(
|
||||
onCursorChange(TextRange(value.selection.end))
|
||||
}
|
||||
|
||||
val textToolbar: UnittoTextToolbar = remember(readOnly) {
|
||||
if (readOnly) {
|
||||
val textToolbar: UnittoTextToolbar = if (readOnly) {
|
||||
UnittoTextToolbar(
|
||||
view = localView,
|
||||
copyCallback = ::copyCallback,
|
||||
@ -104,7 +103,6 @@ fun ExpressionTextField(
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
AutoSizableTextField(
|
||||
modifier = modifier,
|
||||
@ -114,8 +112,6 @@ fun ExpressionTextField(
|
||||
minRatio = minRatio,
|
||||
onValueChange = { onCursorChange(it.selection) },
|
||||
readOnly = readOnly,
|
||||
showToolbar = textToolbar::showMenu,
|
||||
hideToolbar = textToolbar::hide,
|
||||
visualTransformation = expressionTransformer,
|
||||
placeholder = placeholder,
|
||||
textToolbar = textToolbar,
|
||||
@ -169,8 +165,6 @@ fun UnformattedTextField(
|
||||
minRatio = minRatio,
|
||||
onValueChange = { onCursorChange(it.selection) },
|
||||
readOnly = readOnly,
|
||||
showToolbar = textToolbar::showMenu,
|
||||
hideToolbar = textToolbar::hide,
|
||||
placeholder = placeholder,
|
||||
textToolbar = textToolbar
|
||||
)
|
||||
@ -186,8 +180,6 @@ private fun AutoSizableTextField(
|
||||
minRatio: Float = 1f,
|
||||
onValueChange: (TextFieldValue) -> Unit,
|
||||
readOnly: Boolean = false,
|
||||
showToolbar: (rect: Rect) -> Unit = {},
|
||||
hideToolbar: () -> Unit = {},
|
||||
visualTransformation: VisualTransformation = VisualTransformation.None,
|
||||
placeholder: String? = null,
|
||||
textToolbar: UnittoTextToolbar
|
||||
@ -199,6 +191,12 @@ private fun AutoSizableTextField(
|
||||
var nFontSize: TextUnit by remember { mutableStateOf(0.sp) }
|
||||
var minFontSize: TextUnit
|
||||
|
||||
CompositionLocalProvider(
|
||||
LocalTextInputService provides null,
|
||||
LocalTextToolbar provides textToolbar
|
||||
) {
|
||||
val localTextToolbar = LocalTextToolbar.current
|
||||
|
||||
BoxWithConstraints(
|
||||
modifier = modifier,
|
||||
contentAlignment = Alignment.BottomStart
|
||||
@ -241,15 +239,11 @@ private fun AutoSizableTextField(
|
||||
)
|
||||
var offset = Offset.Zero
|
||||
|
||||
CompositionLocalProvider(
|
||||
LocalTextInputService provides null,
|
||||
LocalTextToolbar provides textToolbar
|
||||
) {
|
||||
BasicTextField(
|
||||
value = textValue,
|
||||
onValueChange = {
|
||||
showToolbar(Rect(offset, 0f))
|
||||
hideToolbar()
|
||||
localTextToolbar.showMenu(Rect(offset, 0f))
|
||||
localTextToolbar.hide()
|
||||
onValueChange(it)
|
||||
},
|
||||
modifier = Modifier
|
||||
@ -258,10 +252,10 @@ private fun AutoSizableTextField(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null,
|
||||
onClick = {
|
||||
hideToolbar()
|
||||
localTextToolbar.hide()
|
||||
focusRequester.requestFocus()
|
||||
onValueChange(value.copy(selection = TextRange.Zero))
|
||||
showToolbar(Rect(offset, 0f))
|
||||
localTextToolbar.showMenu(Rect(offset, 0f))
|
||||
}
|
||||
)
|
||||
.widthIn(max = with(density) { intrinsics.width.toDp() })
|
||||
|
Loading…
x
Reference in New Issue
Block a user