package com.hermes.app.feature.settings

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.hermes.app.R
import com.hermes.app.core.designsystem.HermesCard
import com.hermes.app.core.designsystem.HermesColors
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import com.hermes.app.core.localization.HermesLocalizationStore
import com.hermes.app.core.designsystem.HermesSectionHeader

@Composable
fun SettingsView(
    localizationStore: HermesLocalizationStore,
    localeCode: String,
    modifier: Modifier = Modifier,
) {
    HermesCard(modifier = modifier) {
        Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
            HermesSectionHeader(
                title = localizationStore.string(localeCode, R.string.settings_title),
                subtitle = localizationStore.string(localeCode, R.string.settings_subtitle),
            )

            SettingRow(
                label = localizationStore.string(localeCode, R.string.settings_language),
                value = localizationStore.localeName(localeCode),
            )
            SettingRow(
                label = localizationStore.string(localeCode, R.string.settings_haptics),
                value = localizationStore.string(localeCode, R.string.settings_enabled),
            )
            SettingRow(
                label = localizationStore.string(localeCode, R.string.settings_analytics),
                value = localizationStore.string(localeCode, R.string.settings_enabled),
            )
        }
    }
}

@Composable
private fun SettingRow(
    label: String,
    value: String,
) {
    Row(
        modifier = Modifier.fillMaxWidth(),
        verticalAlignment = Alignment.CenterVertically,
        horizontalArrangement = Arrangement.SpaceBetween,
    ) {
        Text(text = label, style = MaterialTheme.typography.bodyLarge, color = HermesColors.textPrimary)
        Text(text = value, style = MaterialTheme.typography.bodyMedium, color = HermesColors.textSecondary)
    }
}
