package com.zaojiao.app.feat.settings

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.hilt.navigation.compose.hiltViewModel
import com.zaojiao.app.feat.design.AppBar
import com.zaojiao.app.feat.design.Colors

@Composable
internal fun SettingsIndexRoute(
    viewModel: SettingsViewModel = hiltViewModel()
) {
    SettingsPage(
        logout = viewModel::logout
    )
}

@Composable
fun SettingsPage(
    logout: () -> Unit,
) {
    LazyColumn(
        modifier = Modifier
            .background(color = Color(0xFFF9F7F8))
            .fillMaxHeight()
            .fillMaxWidth()
    ) {
        item {
            AppBar(title = "设置")
        }

        item {
            Box(modifier = Modifier.height(11.dp))
        }

        item {
            SettingsVideo()
        }

        item {
            Box(modifier = Modifier.height(14.dp))
        }

        item {
            SettingsCommon()
        }

        item {
            Box(modifier = Modifier.height(14.dp))
        }

        item {
            Text(
                text = "退出登录",
                modifier = Modifier
                    .navigationBarsPadding()
                    .padding(horizontal = 16.dp)
                    .clickable { logout() }
                    .background(
                        color = Color.White,
                        shape = RoundedCornerShape(10.dp),
                    )
                    .padding(vertical = 12.dp)
                    .fillMaxWidth(),
                style = TextStyle(
                    color = Colors.FF333333,
                    fontSize = 16.sp,
                    lineHeight = 22.sp,
                    fontWeight = FontWeight.Medium,
                ),
                textAlign = TextAlign.Center,
            )
        }
    }
}