<commit_before>/*
 * Copyright (c) 2022 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package jp.toastkid.ui.dialog

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.material.AlertDialog
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Clear
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import jp.toastkid.ui.R

@Composable
fun InputFileNameDialogUi(
    openDialog: MutableState<Boolean>,
    defaultInput: String = "",
    onCommit: (String) -> Unit
) {
    if (openDialog.value.not()) {
        return
    }

    val input = remember { mutableStateOf(defaultInput) }
    AlertDialog(
        onDismissRequest = { openDialog.value = false },
        title = {
            Text(
                stringResource(id = R.string.title_dialog_input_file_name),
                style = MaterialTheme.typography.h5
            )
        },
        text = {
            TextField(
                value = input.value,
                onValueChange = { text ->
                    input.value = text
                },
                singleLine = true,
                trailingIcon = {
                    Icon(
                        Icons.Filled.Clear,
                        contentDescription = "clear text",
                        modifier = Modifier
                            .offset(x = 8.dp)
                            .clickable {
                                input.value = ""
                            }
                    )<commit_msg>feature #511 Set appropriate cursor color.<commit_after>/*
 * Copyright (c) 2022 toastkidjp.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompany this distribution.
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html.
 */

package jp.toastkid.ui.dialog

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
import androidx.compose.material.AlertDialog
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TextFieldDefaults
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Clear
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import jp.toastkid.ui.R

@Composable
fun InputFileNameDialogUi(
    openDialog: MutableState<Boolean>,
    defaultInput: String = "",
    onCommit: (String) -> Unit
) {
    if (openDialog.value.not()) {
        return
    }

    val input = remember { mutableStateOf(defaultInput) }
    AlertDialog(
        onDismissRequest = { openDialog.value = false },
        title = {
            Text(
                stringResource(id = R.string.title_dialog_input_file_name),
                style = MaterialTheme.typography.h5
            )
        },
        text = {
            TextField(
                value = input.value,
                onValueChange = { text ->
                    input.value = text
                },
                singleLine = true,
                colors = TextFieldDefaults.textFieldColors(
                    textColor = MaterialTheme.colors.onSurface,
                    backgroundColor = Color.Transparent,
                    cursorColor = MaterialTheme.colors.onSurface
                ),
                trailingIcon = {
                    Icon(
                        Icons.Filled.Clear,
                        contentDescription = "clear text",
                        modifier = Modifier
                            .offset(x = 8.dp)
                            .clickable {
                                input.value = ""
                            }
                    )
{'fraction_non_alphanumeric': 0.08016276703967447, 'fraction_numerical': 0.0046795523906408955, 'mean_word_length': 2.059116365899191, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6613957', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1257, 'n_words': 267}