refactor: rename Details to MatchDetails
This commit is contained in:
parent
07d20aba86
commit
e36defeec1
7 changed files with 24 additions and 29 deletions
|
@ -33,7 +33,7 @@ import xyz.leomurca.csgomatches.domain.model.League
|
|||
import xyz.leomurca.csgomatches.domain.model.Match
|
||||
import xyz.leomurca.csgomatches.domain.model.MatchStatus
|
||||
import xyz.leomurca.csgomatches.domain.model.Opponent
|
||||
import xyz.leomurca.csgomatches.ui.navigation.DetailsRoute
|
||||
import xyz.leomurca.csgomatches.ui.navigation.MatchDetailsRoute
|
||||
import xyz.leomurca.csgomatches.ui.theme.LiveRed
|
||||
import xyz.leomurca.csgomatches.ui.theme.White_20
|
||||
import xyz.leomurca.csgomatches.ui.theme.White_50
|
||||
|
@ -43,7 +43,7 @@ import java.time.ZonedDateTime
|
|||
@Composable
|
||||
fun MatchCard(
|
||||
match: Match,
|
||||
onTapCard: (DetailsRoute) -> Unit,
|
||||
onTapCard: (MatchDetailsRoute) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Box(modifier = modifier.fillMaxWidth()) {
|
||||
|
@ -54,7 +54,7 @@ fun MatchCard(
|
|||
Card(
|
||||
modifier = Modifier.fillMaxWidth(), shape = RoundedCornerShape(16.dp), onClick = {
|
||||
onTapCard(
|
||||
DetailsRoute(
|
||||
MatchDetailsRoute(
|
||||
leftOpponentId = leftOpponent.id,
|
||||
rightOpponentId = rightOpponent.id,
|
||||
leagueAndSerieName = leagueAndSerieName,
|
||||
|
|
|
@ -4,19 +4,19 @@ import androidx.navigation.NavGraphBuilder
|
|||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.toRoute
|
||||
import kotlinx.serialization.Serializable
|
||||
import xyz.leomurca.csgomatches.ui.screens.details.DetailsScreen
|
||||
import xyz.leomurca.csgomatches.ui.screens.matchdetails.MatchDetailsScreen
|
||||
|
||||
@Serializable
|
||||
data class DetailsRoute(
|
||||
data class MatchDetailsRoute(
|
||||
val leftOpponentId: Long,
|
||||
val rightOpponentId: Long,
|
||||
val leagueAndSerieName: String,
|
||||
val scheduleString: String
|
||||
)
|
||||
|
||||
fun NavGraphBuilder.detailsScreen(onBackClick: () -> Unit) {
|
||||
composable<DetailsRoute> {
|
||||
val details: DetailsRoute = it.toRoute()
|
||||
DetailsScreen(details = details, onBackClick = onBackClick)
|
||||
fun NavGraphBuilder.matchDetailsScreen(onBackClick: () -> Unit) {
|
||||
composable<MatchDetailsRoute> {
|
||||
val matchDetails: MatchDetailsRoute = it.toRoute()
|
||||
MatchDetailsScreen(matchDetails = matchDetails, onBackClick = onBackClick)
|
||||
}
|
||||
}
|
|
@ -2,15 +2,13 @@ package xyz.leomurca.csgomatches.ui.navigation
|
|||
|
||||
import androidx.navigation.NavGraphBuilder
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.toRoute
|
||||
import kotlinx.serialization.Serializable
|
||||
import xyz.leomurca.csgomatches.domain.model.Match
|
||||
import xyz.leomurca.csgomatches.ui.screens.matches.MatchesScreen
|
||||
|
||||
@Serializable
|
||||
object MatchesRoute
|
||||
|
||||
fun NavGraphBuilder.matchesScreen(onTapCard: (DetailsRoute) -> Unit) {
|
||||
fun NavGraphBuilder.matchesScreen(onTapCard: (MatchDetailsRoute) -> Unit) {
|
||||
composable<MatchesRoute> {
|
||||
MatchesScreen(onTapCard = onTapCard)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ fun RootNavHost() {
|
|||
matchesScreen {
|
||||
navController.navigate(it)
|
||||
}
|
||||
detailsScreen {
|
||||
matchDetailsScreen {
|
||||
navController.popBackStack()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.leomurca.csgomatches.ui.screens.details
|
||||
package xyz.leomurca.csgomatches.ui.screens.matchdetails
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
|
@ -10,7 +10,6 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
|
@ -24,21 +23,20 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import xyz.leomurca.csgomatches.ui.components.LoadingIndicator
|
||||
import xyz.leomurca.csgomatches.ui.navigation.DetailsRoute
|
||||
import xyz.leomurca.csgomatches.ui.navigation.MatchDetailsRoute
|
||||
import xyz.leomurca.csgomatches.ui.theme.White
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
fun DetailsScreen(
|
||||
viewModel: DetailsViewModel = hiltViewModel(),
|
||||
details: DetailsRoute,
|
||||
fun MatchDetailsScreen(
|
||||
viewModel: MatchDetailsViewModel = hiltViewModel(),
|
||||
matchDetails: MatchDetailsRoute,
|
||||
onBackClick: () -> Unit
|
||||
) {
|
||||
val uiState = viewModel.uiState.collectAsState()
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.loadTeam(details.leftOpponentId.toString(), isLeft = true)
|
||||
viewModel.loadTeam(details.rightOpponentId.toString(), isLeft = false)
|
||||
viewModel.loadTeam(matchDetails.leftOpponentId.toString(), isLeft = true)
|
||||
viewModel.loadTeam(matchDetails.rightOpponentId.toString(), isLeft = false)
|
||||
}
|
||||
|
||||
Box(
|
||||
|
@ -47,7 +45,7 @@ fun DetailsScreen(
|
|||
.background(MaterialTheme.colorScheme.background),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
TopBar(details.leagueAndSerieName, onBackClick)
|
||||
TopBar(matchDetails.leagueAndSerieName, onBackClick)
|
||||
|
||||
val value = uiState.value
|
||||
when {
|
|
@ -1,6 +1,5 @@
|
|||
package xyz.leomurca.csgomatches.ui.screens.details
|
||||
package xyz.leomurca.csgomatches.ui.screens.matchdetails
|
||||
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
|
@ -15,7 +14,7 @@ import xyz.leomurca.csgomatches.domain.repository.MatchRepository
|
|||
import javax.inject.Inject
|
||||
|
||||
@HiltViewModel
|
||||
class DetailsViewModel @Inject constructor(
|
||||
class MatchDetailsViewModel @Inject constructor(
|
||||
private val matchRepository: MatchRepository,
|
||||
) : ViewModel() {
|
||||
|
|
@ -24,7 +24,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
|
|||
import xyz.leomurca.csgomatches.domain.model.Match
|
||||
import xyz.leomurca.csgomatches.ui.components.LoadingIndicator
|
||||
import xyz.leomurca.csgomatches.ui.components.MatchCard
|
||||
import xyz.leomurca.csgomatches.ui.navigation.DetailsRoute
|
||||
import xyz.leomurca.csgomatches.ui.navigation.MatchDetailsRoute
|
||||
import xyz.leomurca.csgomatches.ui.screens.matches.MatchesViewModel.MatchesUiState
|
||||
import xyz.leomurca.csgomatches.ui.theme.White
|
||||
|
||||
|
@ -32,7 +32,7 @@ import xyz.leomurca.csgomatches.ui.theme.White
|
|||
@Composable
|
||||
fun MatchesScreen(
|
||||
viewModel: MatchesViewModel = hiltViewModel(),
|
||||
onTapCard: (DetailsRoute) -> Unit
|
||||
onTapCard: (MatchDetailsRoute) -> Unit
|
||||
) {
|
||||
val uiState = viewModel.uiState.collectAsState()
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior()
|
||||
|
@ -72,7 +72,7 @@ fun MatchesScreen(
|
|||
}
|
||||
|
||||
@Composable
|
||||
private fun MatchesList(matches: List<Match>, onTapCard: (DetailsRoute) -> Unit) {
|
||||
private fun MatchesList(matches: List<Match>, onTapCard: (MatchDetailsRoute) -> Unit) {
|
||||
LazyColumn(
|
||||
Modifier
|
||||
.padding(horizontal = 24.dp),
|
||||
|
|
Loading…
Add table
Reference in a new issue