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

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Search
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

@Composable
fun ProjectTaskAll() {
    Column(
        modifier = Modifier
            .fillMaxHeight()
            .background(Color.White)
            .padding(horizontal = 50.dp, vertical = 50.dp)
    ) {
        Spacer(modifier = Modifier.height(50.dp))
        Row(
            modifier = Modifier.fillMaxWidth(),
            horizontalArrangement = Arrangement.SpaceBetween,
            verticalAlignment = Alignment.CenterVertically
        ) {
            Text(
                text = "全部项目任务",
                fontSize = 16.sp,
                fontWeight = FontWeight.Bold,
                color = Color(0xFF1F2429),
                modifier = Modifier.height(20.dp)
            )

            OutlinedTextField(
                value = "",
                onValueChange = {},
                modifier = Modifier.height(48.dp),
                placeholder = {
                    Text(text = "Search", fontSize = 14.sp, color = Color(0xFFC3C7CB))
                },
                leadingIcon = {
                    Icon(
                        imageVector = Icons.Default.Search,
                        contentDescription = ""
                    )
                }
            )
        }
        Spacer(modifier = Modifier.height(20.dp))
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .height(40.dp)
                .background(Color(0xFFF8F9FA)),
            verticalAlignment = Alignment.CenterVertically,
            horizontalArrangement = Arrangement.SpaceAround

        ) {
            Text(
                text = "项目名称",
                fontSize = 16.sp,
                color = Color(0xFF646C73),
                textAlign = TextAlign.Center,
                modifier = Modifier.weight(3f)
            )
            Text(
                text = "楼层",
                fontSize = 16.sp,
                color = Color(0xFF646C73),
                textAlign = TextAlign.Center,
                modifier = Modifier.weight(2f)
            )
            Text(
                text = "起始时间",
                fontSize = 16.sp,
                color = Color(0xFF646C73),
                textAlign = TextAlign.Center,
                modifier = Modifier.weight(2f)
            )
            Text(
                text = "项目完成进度",
                fontSize = 16.sp,
                color = Color(0xFF646C73),
                textAlign = TextAlign.Center,
                modifier = Modifier.weight(3f)
            )

            Text(
                text = "",
                fontSize = 16.sp,
                color = Color(0xFF646C73),
                textAlign = TextAlign.Center,
                modifier = Modifier.weight(2f)
            )
        }

        LazyColumn(modifier = Modifier.fillMaxWidth().height(436.dp)) {
            items(20) {
                Box {
                    Row(
                        modifier = Modifier
                            .fillMaxWidth()
                            .height(48.dp)
                            .background(Color.White),
                        verticalAlignment = Alignment.CenterVertically,
                        horizontalArrangement = Arrangement.SpaceEvenly
                    ) {
                        Text(
                            text = "项目名称",
                            fontSize = 16.sp,
                            color = Color(0xFF1F2429),
                            textAlign = TextAlign.Center,
                            modifier = Modifier.weight(3f)
                        )
                        Text(
                            text = "楼层",
                            fontSize = 16.sp,
                            color = Color(0xFF1F2429),
                            textAlign = TextAlign.Center,
                            modifier = Modifier.weight(2f)
                        )
                        Text(
                            text = "起始时间",
                            fontSize = 16.sp,
                            color = Color(0xFF1F2429),
                            textAlign = TextAlign.Center,
                            modifier = Modifier.weight(2f)
                        )

                        Surface(
                            elevation = 0.dp,
                            shape = RoundedCornerShape(10.dp),
                            modifier = Modifier.weight(3f).height(10.dp),
                        ) {
                            LinearProgressIndicator(
                                progress = 0.8f,
                                color = Color(0xFF0091FF),
                                backgroundColor = Color(0xFFF9F9F9),
                            )
                        }

                        Text(
                            text = "40%",
                            fontSize = 16.sp,
                            color = Color(0xFF1F2429),
                            textAlign = TextAlign.Center,
                            modifier = Modifier.weight(2f)
                        )
                    }
                    Spacer(
                        modifier = Modifier
                            .align(Alignment.BottomCenter)
                            .fillMaxWidth().height(1.dp)
                            .background(Color(0xFFE4E6E7))
                    )
                }

            }
        }
    }
}

@Preview(widthDp = 1280, heightDp = 800)
@Composable
fun PreviewProjectTaskAll() {
    ProjectTaskAll()
}
