package de.trainingstagebuch.app

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import de.trainingstagebuch.app.core.StandardErrorMapper
import de.trainingstagebuch.app.network.NetworkModule
import de.trainingstagebuch.app.network.SocketManager
import de.trainingstagebuch.app.services.AppServices
import de.trainingstagebuch.app.ui.theme.TrainingstagebuchTheme

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        StandardErrorMapper.initialize(applicationContext)
        NetworkModule.initialize(applicationContext)
        SocketManager.initialize(applicationContext)
        AppServices.initialize(applicationContext)
        AppServices.personalSettingsService.applyPersistedLanguage()
        setContent {
            TrainingstagebuchTheme {
                Surface(color = MaterialTheme.colorScheme.background) {
                    TrainingstagebuchApp()
                }
            }
        }
    }

    override fun onStart() {
        super.onStart()
        SocketManager.setAppInForeground(true)
    }

    override fun onStop() {
        SocketManager.setAppInForeground(false)
        super.onStop()
    }
}
