@Composable
fun TodayMatchesLazy(
matchesList: List
) {
val viewModel: MainViewModel = hiltViewModel()
viewModel.mainList.value = matchesList
val groupedList = viewModel.mainList.value.groupBy { it!!.league!!.id }
if (groupedList.isNotEmpty()) {
LazyColumn(
modifier = Modifier
.padding(20.dp)
.fillMaxSize()
) {
groupedList.forEach { (league, items) ->
item {
TodayMatchesHeader(leagueItem = items[0]!!, league = league!!)
}
itemsIndexed(items,
itemContent = { index, item ->
TodayMatchesRow(
teamHomeName = item!!.teams!!.home!!.name!!,
teamHomeLogo = item.teams!!.home!!.logo!!,
teamHomeR = item!!.goals!!.home!!.toString(),
teamAwayName = item.teams.away!!.name!!,
teamAwayLogo = item.teams.away.logo!!,
teamAwayR = item.goals!!.away!!.toString(),
time = item.fixture!!.date!!
)
}
)
}
}
}
}