val category: String,
val state: String,
)
@Composable
fun GridView(dataList:MutableList) {
//对数据按类别和id排序
dataList.sortWith(compareBy({it.category},{it.id}))
/**
- 区间宽度,随窗口尺寸变化更新
*/
var districtWidth by remember { mutableStateOf(0f) }
/**
- 每个方框的尺寸
*/
val gridBoxWidth:Float=200f
/**
- 每列方框的数量
*/
var everyRowBoxQuantity:Int
Column (
modifier = Modifier
//可滚动
.verticalScroll(rememberScrollState())
){
BoxWithConstraints {
//获取Column最大宽度
districtWidth=maxWidth.value
//计算每列方框的数量
everyRowBoxQuantity=floor(districtWidth/gridBoxWidth).toInt()
//类别表
val categoryList:MutableList = mutableListOf()
//显示列表,类别-数据列表
val gridList:MutableMap<String,List>