refactor: make functions private and extract constant
This commit is contained in:
parent
a1382d0ee4
commit
ff112ce890
2 changed files with 5 additions and 3 deletions
|
@ -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
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Add table
Reference in a new issue