package com.jishisongfu.duobibi.ui.mine

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
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.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.jishisongfu.duobibi.BuildConfig
import com.jishisongfu.duobibi.R
import com.jishisongfu.duobibi.ui.theme.DbbColors

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AboutScreen(onBack: () -> Unit, onOpenPrivacy: () -> Unit) {
    Scaffold(
        topBar = {
            TopAppBar(
                title = { Text("关于多比比", fontWeight = FontWeight.Bold, color = DbbColors.Ink) },
                navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.AutoMirrored.Filled.ArrowBack, "返回", tint = DbbColors.Ink) } },
                colors = TopAppBarDefaults.topAppBarColors(containerColor = DbbColors.Card),
            )
        },
    ) { padding ->
        Column(
            Modifier.padding(padding).fillMaxSize().background(MaterialTheme.colorScheme.background).padding(20.dp),
            horizontalAlignment = Alignment.CenterHorizontally,
        ) {
            Spacer(Modifier.height(20.dp))
            Box(Modifier.size(72.dp).clip(RoundedCornerShape(18.dp)).background(DbbColors.Teal), contentAlignment = Alignment.Center) {
                Icon(painterResource(R.drawable.ic_launcher_foreground), null, tint = androidx.compose.ui.graphics.Color.White, modifier = Modifier.size(64.dp))
            }
            Spacer(Modifier.height(12.dp))
            Text("多比比", fontWeight = FontWeight.ExtraBold, fontSize = 20.sp, color = DbbColors.Ink)
            Text("v${BuildConfig.VERSION_NAME}", color = DbbColors.InkTer, fontSize = 12.sp)
            Spacer(Modifier.height(24.dp))
            Card(
                Modifier.fillMaxWidth(), colors = CardDefaults.cardColors(containerColor = DbbColors.Card),
                elevation = CardDefaults.cardElevation(defaultElevation = 2.dp), shape = RoundedCornerShape(16.dp),
            ) {
                Column(Modifier.padding(16.dp)) {
                    Text("多比比是一款跨平台比价工具:一个商品多平台到手价同台对比,降价雷达盯价提醒,AI 帮你判断值不值得买。价格记录默认只存本机。",
                        color = DbbColors.InkSec, fontSize = 13.sp, lineHeight = 20.sp)
                }
            }
            Spacer(Modifier.height(12.dp))
            Card(
                Modifier.fillMaxWidth().clickable(onClick = onOpenPrivacy),
                colors = CardDefaults.cardColors(containerColor = DbbColors.Card),
                elevation = CardDefaults.cardElevation(defaultElevation = 2.dp), shape = RoundedCornerShape(16.dp),
            ) {
                Text("隐私政策 ›", Modifier.padding(16.dp), color = DbbColors.Teal, fontWeight = FontWeight.Medium)
            }
        }
    }
}
