/*
 * 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.library.display.components

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import org.dueattendant149.bookshelf.R
import org.dueattendant149.bookshelf.presentation.library.model.LibraryLayout
import org.dueattendant149.bookshelf.presentation.library.model.LibraryTitlePosition
import org.dueattendant149.bookshelf.ui.common.components.settings.ChipsWithTitle
import org.dueattendant149.bookshelf.ui.common.helpers.LocalSettings
import org.dueattendant149.bookshelf.ui.common.model.ListItem
import org.dueattendant149.bookshelf.ui.theme.ExpandingTransition

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

    ExpandingTransition(visible = settings.libraryLayout.value == LibraryLayout.GRID) {
        ChipsWithTitle(
            title = stringResource(id = R.string.title_position_option),
            chips = LibraryTitlePosition.entries.map { item ->
                ListItem(
                    item = item,
                    title = stringResource(id = item.title),
                    selected = item == settings.libraryTitlePosition.value
                )
            },
            onClick = { item ->
                settings.libraryTitlePosition.update(item)
            }
        )
    }
}