package com.aiosman.ravenow.ui.about

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
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.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.aiosman.ravenow.LocalAppTheme
import com.aiosman.ravenow.R
import com.aiosman.ravenow.ui.comment.NoticeScreenHeader
import com.aiosman.ravenow.ui.composables.StatusBarSpacer

@Composable
fun AboutScreen() {
    val appColors = LocalAppTheme.current
    val context = LocalContext.current
    val versionText = context.packageManager.getPackageInfo(context.packageName, 0).versionName
    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(appColors.background),
    ) {
        StatusBarSpacer()
        Box(
            modifier = Modifier.padding(horizontal = 24.dp, vertical = 16.dp)
        ) {
            NoticeScreenHeader(
                title = stringResource(R.string.about_paipai),
                moreIcon = false
            )
        }
        Column(
            modifier = Modifier
                .weight(1f)
                .fillMaxWidth(),
            horizontalAlignment = Alignment.CenterHorizontally,
            verticalArrangement = Arrangement.Center
        ) {
            // app icondww
            Box {
                Image(
                    painter = painterResource(id = R.mipmap.invalid_name),
                    contentDescription = "app icon",
                    modifier = Modifier.size(80.dp)
                )
            }
            Spacer(modifier = Modifier.height(24.dp))
            // app name
            Text(
                text = stringResource(R.string.paipai),
                fontSize = 24.sp,
                color = appColors.text,
                fontWeight = FontWeight.ExtraBold
            )
            Spacer(modifier = Modifier.height(16.dp))
            // app version
            Text(
                text = stringResource(R.string.version_text, versionText ?: ""),
                fontSize = 16.sp,
                color = appColors.secondaryText,
                fontWeight = FontWeight.Normal
            )

        }
    }
}