package com.pixelized.biblib.ui.screen.authentication.composable

import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.width
import androidx.compose.material.Checkbox
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.pixelized.biblib.R

@Composable
fun CredentialRemember(
    modifier: Modifier = Modifier,
    value: Boolean,
    onValueChange: (Boolean) -> Unit,
) {
    Row(
        modifier = modifier.clickable(
            interactionSource = remember { MutableInteractionSource() },
            indication = null,
            onClick = { onValueChange(value.not()) }
        )
    ) {
        Checkbox(
            modifier = Modifier.align(Alignment.CenterVertically),
            checked = value,
            onCheckedChange = null
        )

        Spacer(modifier = Modifier.width(8.dp))

        Text(
            modifier = Modifier.align(Alignment.CenterVertically),
            style = MaterialTheme.typography.caption,
            color = MaterialTheme.colors.onBackground,
            text = stringResource(id = R.string.authentication_credential_remember)
        )
    }
}