package com.example.ui.settings import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.example.data.model.MealType import com.example.ui.journal.GoogleSheetsUiState import com.example.ui.settings.components.AccountAndSecuritySection import com.example.ui.settings.components.AppearanceThemeSection import com.example.ui.settings.components.DataExportImportSection import com.example.ui.settings.components.GoogleSheetsIntegrationSection import com.example.ui.settings.components.NotificationRemindersSection import com.example.ui.theme.AppThemeMode import com.google.firebase.Firebase import com.google.firebase.auth.auth @Composable fun SettingsScreen( currentThemeMode: AppThemeMode, totalMealsCount: Int, sheetsUiState: GoogleSheetsUiState, isAutoSyncSheets: Boolean, spreadsheetUrl: String?, onThemeModeChange: (AppThemeMode) -> Unit, onScheduleReminder: (MealType, Int, Int, Boolean) -> Unit, onTestNotification: (MealType) -> Unit, onSaveCsvClick: () -> Unit, onShareCsvClick: () -> Unit, onImportCsvClick: () -> Unit, onSyncSheetsClick: () -> Unit, onAutoSyncSheetsChange: (Boolean) -> Unit, onOpenSheetsClick: (String) -> Unit, onRestoreSheetsClick: () -> Unit = {}, onSignInClick: () -> Unit, onSignOut: () -> Unit, modifier: Modifier = Modifier ) { val currentUser = Firebase.auth.currentUser LazyColumn( modifier = modifier .fillMaxSize() .testTag("settings_screen_list"), contentPadding = PaddingValues(horizontal = 20.dp, vertical = 24.dp), verticalArrangement = Arrangement.spacedBy(20.dp) ) { item { Column( modifier = Modifier .fillMaxWidth() .padding(bottom = 4.dp) ) { Text( text = "Paramètres", style = MaterialTheme.typography.headlineMedium, color = MaterialTheme.colorScheme.onBackground, fontWeight = FontWeight.Bold ) Text( text = "Export CSV, rappels personnalisés, thème et compte", style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onBackground.copy(alpha = 0.7f) ) } } // 1. Local Database & CSV Management item { DataExportImportSection( totalMealsCount = totalMealsCount, onImportCsvClick = onImportCsvClick, onSaveCsvClick = onSaveCsvClick, onShareCsvClick = onShareCsvClick ) } // 2. Google Sheets & Drive Sync item { GoogleSheetsIntegrationSection( sheetsUiState = sheetsUiState, isAutoSyncSheets = isAutoSyncSheets, spreadsheetUrl = spreadsheetUrl, onSyncSheetsClick = onSyncSheetsClick, onAutoSyncSheetsChange = onAutoSyncSheetsChange, onOpenSheetsClick = onOpenSheetsClick, onRestoreSheetsClick = onRestoreSheetsClick ) } // 3. Reminders item { NotificationRemindersSection( onScheduleReminder = onScheduleReminder, onTestNotification = onTestNotification ) } // 4. Theme Selector item { AppearanceThemeSection( currentThemeMode = currentThemeMode, onThemeModeChange = onThemeModeChange ) } // 5. Account & Cloud Sync item { AccountAndSecuritySection( currentUser = currentUser, onSignInClick = onSignInClick, onSignOut = onSignOut ) } item { Spacer(modifier = Modifier.height(64.dp)) } } }