Thread
#compose
    s

    Slackbot

    1 year ago
    This message was deleted.
    d

    Denis

    1 year ago
    do you try to
    remember
    on the top level?
    m

    Mjahangiry75

    1 year ago
    it bundled in
    InputDialog
    d

    Denis

    1 year ago
    I was talking about
    val showRenameDocumentDialog = remember,
    but I suppose it's not full code, though. Otherwise it shouldn't even compile, right? btw, could you put code in the thread? it takes a lot of space in the channel
    m

    Mjahangiry75

    1 year ago
    no I don't get compile errors when the error occurs when I tap on the confirm button
    val showRenameDocumentDialog = remember { mutableStateOf<Document?>(null) }
    
    showRenameDocumentDialog.value?.let { document ->
        InputDialog(
            inputLabel = stringResource(id = R.string.rename_document_dialog_placeholder),
            onConfirm = {
                documentsBaseViewModel.renameDocument(document.id, it)
                showRenameDocumentDialog.value = null
            },
            onDismissRequest = {
                showRenameDocumentDialog.value = null
            }
        )
    }
    
    @Composable
    fun InputDialog(
        modifier: Modifier = Modifier,
        inputLabel: String,
        onConfirm: (String) -> Unit,
        onDismissRequest: () -> Unit = {}
    ) {
    
        val (input, setInput) = remember { mutableStateOf("") }
    
        Dialog(
            onDismissRequest = onDismissRequest,
            properties = DialogProperties(dismissOnBackPress = true, dismissOnClickOutside = true),
            content = {
                Column(
                    modifier = modifier
                        .background(color = Color(0xFFFFFFFF), shape = alertDialogShape)
                        .padding(horizontal = 16.dp, vertical = 32.dp),
                ) {
    
                    OutlinedTextField(
                        label = { Text(text = inputLabel) },
                        value = input,
                        onValueChange = setInput
                    )
    
                    Spacer(modifier = Modifier.height(16.dp))
    
                    ActionButton(
                        modifier = Modifier.fillMaxWidth(),
                        onClick = {
                            onConfirm(input)
                            setInput("")
                        }
                    ) {
                        Text(text = stringResource(id = R.string.confirm))
                    }
                }
            }
        )
    }