refactor: make functions private and extract constant

This commit is contained in:
Leonardo Murça 2025-07-19 17:51:49 -03:00
parent a1382d0ee4
commit ff112ce890
2 changed files with 5 additions and 3 deletions

View file

@ -90,7 +90,7 @@ fun MatchDetailsScreen(
} }
@Composable @Composable
fun DualPlayerLists( private fun DualPlayerLists(
leftPlayers: List<Player>, leftPlayers: List<Player>,
rightPlayers: List<Player>, rightPlayers: List<Player>,
modifier: Modifier = Modifier modifier: Modifier = Modifier

View file

@ -35,6 +35,8 @@ import xyz.leomurca.csgomatches.ui.navigation.MatchDetailsRoute
import xyz.leomurca.csgomatches.ui.screens.matches.MatchesViewModel.MatchesUiState import xyz.leomurca.csgomatches.ui.screens.matches.MatchesViewModel.MatchesUiState
import xyz.leomurca.csgomatches.ui.theme.White import xyz.leomurca.csgomatches.ui.theme.White
private const val ITEMS_PAGINATION_THRESHOLD = 3
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun MatchesScreen( fun MatchesScreen(
@ -49,7 +51,7 @@ fun MatchesScreen(
snapshotFlow { listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index } snapshotFlow { listState.layoutInfo.visibleItemsInfo.lastOrNull()?.index }
.collect { lastVisibleIndex -> .collect { lastVisibleIndex ->
val totalItems = listState.layoutInfo.totalItemsCount val totalItems = listState.layoutInfo.totalItemsCount
if (lastVisibleIndex != null && lastVisibleIndex >= totalItems - 3) { if (lastVisibleIndex != null && lastVisibleIndex >= totalItems - ITEMS_PAGINATION_THRESHOLD) {
viewModel.loadNextPage() viewModel.loadNextPage()
} }
} }
@ -103,7 +105,7 @@ fun MatchesScreen(
} }
@Composable @Composable
fun MatchesList( private fun MatchesList(
matches: List<Match>, matches: List<Match>,
onTapCard: (MatchDetailsRoute) -> Unit, onTapCard: (MatchDetailsRoute) -> Unit,
listState: LazyListState, listState: LazyListState,