|
@@ -4,12 +4,17 @@ import androidx.compose.material3.AlertDialog
|
|
|
import androidx.compose.material3.OutlinedTextField
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.focus.FocusRequester
|
|
|
+import androidx.compose.ui.focus.focusRequester
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
import eu.kanade.domain.category.model.Category
|
|
|
import eu.kanade.presentation.components.TextButton
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
+import kotlinx.coroutines.delay
|
|
|
|
|
|
@Composable
|
|
|
fun CategoryCreateDialog(
|
|
@@ -17,6 +22,8 @@ fun CategoryCreateDialog(
|
|
|
onCreate: (String) -> Unit,
|
|
|
) {
|
|
|
val (name, onNameChange) = remember { mutableStateOf("") }
|
|
|
+ val focusRequester = remember { FocusRequester() }
|
|
|
+
|
|
|
AlertDialog(
|
|
|
onDismissRequest = onDismissRequest,
|
|
|
confirmButton = {
|
|
@@ -24,27 +31,35 @@ fun CategoryCreateDialog(
|
|
|
onCreate(name)
|
|
|
onDismissRequest()
|
|
|
},) {
|
|
|
- Text(text = stringResource(id = R.string.action_add))
|
|
|
+ Text(text = stringResource(R.string.action_add))
|
|
|
}
|
|
|
},
|
|
|
dismissButton = {
|
|
|
TextButton(onClick = onDismissRequest) {
|
|
|
- Text(text = stringResource(id = R.string.action_cancel))
|
|
|
+ Text(text = stringResource(R.string.action_cancel))
|
|
|
}
|
|
|
},
|
|
|
title = {
|
|
|
- Text(text = stringResource(id = R.string.action_add_category))
|
|
|
+ Text(text = stringResource(R.string.action_add_category))
|
|
|
},
|
|
|
text = {
|
|
|
OutlinedTextField(
|
|
|
+ modifier = Modifier
|
|
|
+ .focusRequester(focusRequester),
|
|
|
value = name,
|
|
|
onValueChange = onNameChange,
|
|
|
label = {
|
|
|
- Text(text = stringResource(id = R.string.name))
|
|
|
+ Text(text = stringResource(R.string.name))
|
|
|
},
|
|
|
)
|
|
|
},
|
|
|
)
|
|
|
+
|
|
|
+ LaunchedEffect(focusRequester) {
|
|
|
+ // TODO: https://issuetracker.google.com/issues/204502668
|
|
|
+ delay(100)
|
|
|
+ focusRequester.requestFocus()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
@@ -54,6 +69,8 @@ fun CategoryRenameDialog(
|
|
|
category: Category,
|
|
|
) {
|
|
|
val (name, onNameChange) = remember { mutableStateOf(category.name) }
|
|
|
+ val focusRequester = remember { FocusRequester.Default }
|
|
|
+
|
|
|
AlertDialog(
|
|
|
onDismissRequest = onDismissRequest,
|
|
|
confirmButton = {
|
|
@@ -61,27 +78,35 @@ fun CategoryRenameDialog(
|
|
|
onRename(name)
|
|
|
onDismissRequest()
|
|
|
},) {
|
|
|
- Text(text = stringResource(id = android.R.string.ok))
|
|
|
+ Text(text = stringResource(android.R.string.ok))
|
|
|
}
|
|
|
},
|
|
|
dismissButton = {
|
|
|
TextButton(onClick = onDismissRequest) {
|
|
|
- Text(text = stringResource(id = R.string.action_cancel))
|
|
|
+ Text(text = stringResource(R.string.action_cancel))
|
|
|
}
|
|
|
},
|
|
|
title = {
|
|
|
- Text(text = stringResource(id = R.string.action_rename_category))
|
|
|
+ Text(text = stringResource(R.string.action_rename_category))
|
|
|
},
|
|
|
text = {
|
|
|
OutlinedTextField(
|
|
|
+ modifier = Modifier
|
|
|
+ .focusRequester(focusRequester),
|
|
|
value = name,
|
|
|
onValueChange = onNameChange,
|
|
|
label = {
|
|
|
- Text(text = stringResource(id = R.string.name))
|
|
|
+ Text(text = stringResource(R.string.name))
|
|
|
},
|
|
|
)
|
|
|
},
|
|
|
)
|
|
|
+
|
|
|
+ LaunchedEffect(focusRequester) {
|
|
|
+ // TODO: https://issuetracker.google.com/issues/204502668
|
|
|
+ delay(100)
|
|
|
+ focusRequester.requestFocus()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Composable
|