package com.ys.bdtp.adm.mvvm.ui.screen.task

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.ys.bdtp.adm.mvvm.ui.screen.main.LocalNavHostController
import com.ys.bdtp.adm.mvvm.ui.screen.main.Route

/**
 * 近期任务组件
 */
@Composable
fun TaskContent(title: String) {
    val nav = LocalNavHostController.current!!
    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(Color.White),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Text(
            text = "近期负责的项目任务",
            fontSize = 16.sp,
            fontWeight = FontWeight.Bold,
            color = Color(0xFF1F2429),
            modifier = Modifier.height(20.dp)
        )
        Spacer(modifier = Modifier.fillMaxWidth().height(20.dp))

        TaskTitle()

        LazyColumn(modifier = Modifier.fillMaxWidth().height(380.dp)) {
            items(20) {
                Box {
                    TaskItem()
                    Spacer(
                        modifier = Modifier
                            .align(Alignment.BottomCenter)
                            .fillMaxWidth().height(1.dp)
                            .background(Color(0xFFE4E6E7))
                    )
                }
            }
        }
        Spacer(modifier = Modifier.fillMaxWidth().height(40.dp))
        TextButton(
            onClick = {
                nav.navigate(Route.Tasks)
            },
            modifier = Modifier.wrapContentWidth()
        ) {
            Text(
                text = title,
                fontSize = 14.sp,
                color = Color(0xFF0091FF),
                textAlign = TextAlign.Center,
            )
        }
    }
}


@Preview(widthDp = 1489, heightDp = 930)
@Composable
fun PreviewProjectTask() {
    TaskContent("查看全部项目任务")
}