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

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.ys.bdtp.adm.app.theme.textBlackColor
import com.ys.bdtp.adm.app.theme.trDivColor
import com.ys.bdtp.adm.app.theme.whiteColor
import com.ys.bdtp.adm.mvvm.ui.compose.SelectState
import com.ys.bdtp.adm.mvvm.ui.compose.Table

@Composable
fun CadContent(selectState: SelectState) {
    Column(
        modifier = Modifier
            .fillMaxSize()
            .background(whiteColor)
            .padding(horizontal = 50.dp, vertical = 50.dp)
    ) {
        if (selectState == SelectState.Left) {
            Table(
                name = {
                    Text(text = "土建图纸核查", color = textBlackColor, fontSize = 16.sp)
                },
                th = {
                    CadDrawingTitle()
                },
                tr = {
                    LazyColumn(modifier = Modifier.fillMaxSize()) {
                        items(20) {
                            Box {
                                CadDrawingItem()
                                Spacer(
                                    modifier = Modifier
                                        .align(Alignment.BottomCenter)
                                        .fillMaxWidth().height(1.dp)
                                        .background(trDivColor)
                                )
                            }
                        }
                    }
                }
            )
        } else {
            Table(
                name = {
                    Text(text = "机电图纸核查", color = textBlackColor, fontSize = 16.sp)
                },
                th = {
                    CadDrawingTitle()
                },
                tr = {
                    LazyColumn(modifier = Modifier.fillMaxSize()) {
                        items(20) {
                            Box {
                                CadDrawingItem()
                                Spacer(
                                    modifier = Modifier
                                        .align(Alignment.BottomCenter)
                                        .fillMaxWidth().height(1.dp)
                                        .background(trDivColor)
                                )
                            }
                        }
                    }
                }
            )
        }

    }
}

@Preview(widthDp = 910, heightDp = 711)
@Composable
fun PreviewCadContent() {
    CadContent(SelectState.Left)
}