/*
 * Book's Story — free and open-source Material You eBook reader.
 * Copyright (C) 2024-2026 Acclorite
 * SPDX-License-Identifier: GPL-3.0-only
 */

package org.dueattendant149.bookshelf.ui.settings.reader.font.components

import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontStyle
import org.dueattendant149.bookshelf.R
import org.dueattendant149.bookshelf.ui.common.components.settings.SegmentedButtonWithTitle
import org.dueattendant149.bookshelf.ui.common.helpers.LocalSettings
import org.dueattendant149.bookshelf.ui.common.model.ListItem

@Composable
fun FontStyleOption() {
    val settings = LocalSettings.current

    SegmentedButtonWithTitle(
        title = stringResource(id = R.string.font_style_option),
        buttons = listOf(
            ListItem(
                item = false,
                title = stringResource(id = R.string.font_style_normal),
                textStyle = {
                    MaterialTheme.typography.labelLarge.copy(
                        fontFamily = settings.fontFamily.value.font,
                        fontStyle = FontStyle.Normal
                    )
                },
                selected = !settings.italic.value
            ),
            ListItem(
                item = true,
                title = stringResource(id = R.string.font_style_italic),
                textStyle = {
                    MaterialTheme.typography.labelLarge.copy(
                        fontFamily = settings.fontFamily.value.font,
                        fontStyle = FontStyle.Italic
                    )
                },
                selected = settings.italic.value
            )
        ),
        onClick = { item ->
            settings.italic.update(item)
        }
    )
}