Create your own's text boxes follow the remote's rules
Found testing RC1's first-run fallback on the emulator: the channel name box kept Up and Down, so Next couldn't be reached. OrbitField now uses textFieldKeys, as the sign-in boxes do (OK opens the keyboard, Up and Down move). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
@@ -217,9 +218,13 @@ internal fun ChoiceCard(title: String, lines: List<String>, modifier: Modifier,
|
||||
@Composable
|
||||
internal fun OrbitField(value: String, onChange: (String) -> Unit, hint: String, modifier: Modifier) {
|
||||
var focused by remember { mutableStateOf(false) }
|
||||
// The remote's rules for a text box (1.0 RC1, found on the emulator: Create your own's name box kept Up and Down, so its
|
||||
// Next button couldn't be reached): OK opens the keyboard, Up and Down move on, as on the sign-in boxes.
|
||||
val keyboard = androidx.compose.ui.platform.LocalSoftwareKeyboardController.current
|
||||
val focus = androidx.compose.ui.platform.LocalFocusManager.current
|
||||
Box(modifier.onFocusChanged { focused = it.isFocused }.background(Panel, RoundedCornerShape(8.dp)).border(2.dp, if (focused) Yellow else Blue, RoundedCornerShape(8.dp)).padding(10.dp)) {
|
||||
if (value.isEmpty()) Text(hint, color = Muted, fontSize = 15.sp)
|
||||
BasicTextField(value, { onChange(it.replace("\n", "")) }, Modifier.fillMaxWidth(), singleLine = true, textStyle = TextStyle(color = Ink, fontSize = 15.sp),
|
||||
BasicTextField(value, { onChange(it.replace("\n", "")) }, Modifier.fillMaxWidth().onPreviewKeyEvent { event -> textFieldKeys(event.nativeKeyEvent, keyboard, focus) }, singleLine = true, textStyle = TextStyle(color = Ink, fontSize = 15.sp),
|
||||
cursorBrush = SolidColor(Yellow), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user