Skip to content

Commit b4a3e72

Browse files
committed
Add helper button to initialize empty action category
1 parent 8a13804 commit b4a3e72

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

java/src/org/futo/inputmethod/latin/uix/actions/MoreActions.kt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.Box
88
import androidx.compose.foundation.layout.Column
99
import androidx.compose.foundation.layout.RowScope
1010
import androidx.compose.foundation.layout.Spacer
11-
import androidx.compose.foundation.layout.defaultMinSize
1211
import androidx.compose.foundation.layout.fillMaxHeight
1312
import androidx.compose.foundation.layout.fillMaxSize
1413
import androidx.compose.foundation.layout.fillMaxWidth
@@ -27,6 +26,7 @@ import androidx.compose.material3.MaterialTheme
2726
import androidx.compose.material3.OutlinedButton
2827
import androidx.compose.material3.Surface
2928
import androidx.compose.material3.Text
29+
import androidx.compose.material3.TextButton
3030
import androidx.compose.runtime.Composable
3131
import androidx.compose.runtime.DisposableEffect
3232
import androidx.compose.runtime.remember
@@ -211,7 +211,7 @@ fun ActionsEditor(header: @Composable () -> Unit) {
211211
}
212212
}
213213
is ActionEditorItem.Separator -> {
214-
ReorderableItem(reorderableLazyListState, key = it.toKey(), enabled = it.category != ActionCategory.entries[0]) { _ ->
214+
ReorderableItem(reorderableLazyListState, modifier = Modifier.fillMaxWidth(), key = it.toKey(), enabled = it.category != ActionCategory.entries[0]) { _ ->
215215
Column {
216216
if (it.category == ActionCategory.entries[0]) {
217217
header()
@@ -223,6 +223,24 @@ fun ActionsEditor(header: @Composable () -> Unit) {
223223
}
224224
}
225225
Text(it.category.name(context), modifier = Modifier.padding(top = 24.dp), style = CategoryTitleStyle, color = LocalContentColor.current.copy(alpha = 0.6f))
226+
227+
if(actionMap[it.category]?.isEmpty() == true && it.category != ActionCategory.entries.last()) {
228+
TextButton(onClick = {
229+
val selfIdx = list.indexOf(it)
230+
val itemToMove = list.subList(
231+
selfIdx,
232+
list.size
233+
).firstOrNull { v -> v is ActionEditorItem.Item }
234+
235+
if (itemToMove != null) {
236+
val idx = list.indexOf(itemToMove)
237+
238+
list.add(selfIdx + 1, list.removeAt(idx))
239+
}
240+
}) {
241+
Text("Add next")
242+
}
243+
}
226244
}
227245
}
228246
}

0 commit comments

Comments
 (0)