Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c94fdb1b authored by Charlotte Lu's avatar Charlotte Lu Committed by Android (Google) Code Review
Browse files

Merge "Change apn type into ExposedDropdownMenuCheckBox" into main

parents 52789931 c9cfcbe0
Loading
Loading
Loading
Loading
+23 −6
Original line number Diff line number Diff line
@@ -54,16 +54,18 @@ fun SettingsExposedDropdownMenuCheckBox(
    selectedOptionsState: SnapshotStateList<Int>,
    emptyVal: String = "",
    enabled: Boolean,
    errorMessage: String? = null,
    onSelectedOptionStateChange: () -> Unit,
) {
    var dropDownWidth by remember { mutableIntStateOf(0) }
    var expanded by remember { mutableStateOf(false) }
    val allIndex = options.indexOf("*")
    ExposedDropdownMenuBox(
        expanded = expanded,
        onExpandedChange = { expanded = it },
        modifier = Modifier
            .width(350.dp)
            .padding(SettingsDimension.menuFieldPadding)
            .padding(SettingsDimension.textFieldPadding)
            .onSizeChanged { dropDownWidth = it.width },
    ) {
        OutlinedTextField(
@@ -72,6 +74,7 @@ fun SettingsExposedDropdownMenuCheckBox(
                .menuAnchor()
                .fillMaxWidth(),
            value = if (selectedOptionsState.size == 0) emptyVal
            else if (selectedOptionsState.contains(allIndex)) "*"
            else selectedOptionsState.joinToString { options[it] },
            onValueChange = {},
            label = { Text(text = label) },
@@ -81,7 +84,13 @@ fun SettingsExposedDropdownMenuCheckBox(
                )
            },
            readOnly = true,
            enabled = enabled
            enabled = enabled,
            isError = errorMessage != null,
            supportingText = {
                if (errorMessage != null) {
                    Text(text = errorMessage)
                }
            }
        )
        if (options.isNotEmpty()) {
            ExposedDropdownMenu(
@@ -98,9 +107,17 @@ fun SettingsExposedDropdownMenuCheckBox(
                            .fillMaxWidth(),
                        onClick = {
                            if (selectedOptionsState.contains(index)) {
                                if (index == allIndex)
                                    selectedOptionsState.clear()
                                else {
                                    selectedOptionsState.remove(
                                        index
                                    )
                                    if (selectedOptionsState.contains(allIndex))
                                        selectedOptionsState.remove(
                                            allIndex
                                        )
                                }
                            } else {
                                selectedOptionsState.add(
                                    index