Skip to content

Commit

Permalink
mod MatchDetailScreen & SummaryScreen
Browse files Browse the repository at this point in the history
  • Loading branch information
eshc123 committed May 31, 2024
1 parent a9067b7 commit 8b9544a
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import com.eshc.goonersapp.core.designsystem.theme.ColorFFF5F5F5
import com.eshc.goonersapp.core.designsystem.theme.ColorFFFFFFFF
import com.eshc.goonersapp.core.designsystem.theme.GnrTypography
import com.eshc.goonersapp.core.domain.model.match.MatchDetail
import com.eshc.goonersapp.core.domain.model.match.MatchInformation
import com.eshc.goonersapp.core.domain.model.match.MatchLineup
import com.eshc.goonersapp.core.domain.model.match.getScoreHistoryList
import com.eshc.goonersapp.feature.match.model.MatchUiModel
import com.eshc.goonersapp.feature.match.state.MatchDetailUiState
Expand All @@ -67,6 +69,8 @@ fun MatchDetailRootScreen(
viewModel: MatchDetailViewModel = hiltViewModel(),
) {
val matchData by viewModel.matchDetailUiState.collectAsStateWithLifecycle()
val lineup by viewModel.lineupUiState.collectAsStateWithLifecycle()
val matchInformation by viewModel.matchInformationState.collectAsStateWithLifecycle()

Scaffold(
topBar = {
Expand All @@ -79,6 +83,8 @@ fun MatchDetailRootScreen(
) { paddingValues ->
MatchDetailScreen(
matchDetailUiState = matchData,
lineupUiState = lineup,
matchInformationState = matchInformation,
onClickChat = onClickChat,
modifier = Modifier
.fillMaxSize()
Expand All @@ -90,6 +96,8 @@ fun MatchDetailRootScreen(
@Composable
fun MatchDetailScreen(
matchDetailUiState: MatchDetailUiState,
lineupUiState: UiState<MatchLineup>,
matchInformationState : UiState<MatchInformation>,
onClickChat: (MatchUiModel) -> Unit,
modifier: Modifier = Modifier
) {
Expand Down Expand Up @@ -247,7 +255,12 @@ fun MatchDetailScreen(

item {
when (selectedTab) {
DetailTab.SUMMARY -> { SummaryScreen() }
DetailTab.SUMMARY -> {
SummaryScreen(
lineupUiState = lineupUiState,
matchInformationState = matchInformationState
)
}
DetailTab.COMMENT -> { /* TODO("Not yet implemented") */ }
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,117 @@
package com.eshc.goonersapp.feature.match.detail

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.eshc.goonersapp.core.common.state.UiState
import com.eshc.goonersapp.core.designsystem.theme.Color88FFFFFF
import com.eshc.goonersapp.core.designsystem.theme.ColorFF10358A
import com.eshc.goonersapp.core.designsystem.theme.ColorFF181818
import com.eshc.goonersapp.core.designsystem.theme.ColorFF889AC4
import com.eshc.goonersapp.core.designsystem.theme.ColorFFE6EDFC
import com.eshc.goonersapp.core.designsystem.theme.GnrTypography
import com.eshc.goonersapp.core.domain.model.DataResult
import com.eshc.goonersapp.core.domain.model.match.MatchInformation
import com.eshc.goonersapp.core.domain.model.match.MatchLineup
import com.eshc.goonersapp.core.domain.model.match.NotablePlayer
import com.eshc.goonersapp.core.domain.model.player.Player
import com.eshc.goonersapp.feature.match.component.formation.FootballFieldBox
import com.eshc.goonersapp.feature.match.component.formation.LineUpPlayerCard

@Composable
fun SummaryScreen(
startingPlayers: List<List<Player>> = emptyList(),
playerToWatchFor : Player = Player(0)
lineupUiState: UiState<MatchLineup>,
matchInformationState : UiState<MatchInformation>,
) {
Column(
modifier = Modifier
.padding(start = 14.dp,end = 14.dp ,top = 22.dp, bottom = 80.dp)
) {
when(lineupUiState){
is UiState.Success -> {
Text(
text = "Line-Ups",
modifier = Modifier.padding(bottom = 16.dp),
style = GnrTypography.subtitleMedium,
color = ColorFF181818
)

LineUpBox(
matchLineup = lineupUiState.data
)
}
is UiState.Loading -> {
Box(
modifier = Modifier
.fillMaxWidth()
.height(360.dp),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator()
}
}
else -> {

}
}
when(matchInformationState){
is UiState.Success -> {
matchInformationState.data.notablePlayer?.let {
Text(
text = "Player To Watch For",
modifier = Modifier.padding(top = 70.dp, bottom = 16.dp),
style = GnrTypography.subtitleMedium,
color = ColorFF181818
)
PlayerToWatchForBox(
player = it,
modifier = Modifier.fillMaxWidth()
)
}
}
is UiState.Loading -> {
Box(
modifier = Modifier
.fillMaxWidth()
.height(40.dp),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator()
}
}
else -> {

}
}


Text(
text = "Line-Ups",
modifier = Modifier.padding(bottom = 16.dp),
style = GnrTypography.subtitleMedium,
color = ColorFF181818
)

LineUpBox(
startingPlayers = startingPlayers
)

Text(
text = "Player To Watch For",
modifier = Modifier.padding(top = 70.dp, bottom = 16.dp),
style = GnrTypography.subtitleMedium,
color = ColorFF181818
)
PlayerToWatchForBox(
player = playerToWatchFor,
games = 0,
goals = 0,
modifier = Modifier.fillMaxWidth()
)
}

}

@Composable
fun LineUpBox(
startingPlayers : List<List<Player>>
matchLineup: MatchLineup
){
Box(
modifier = Modifier
Expand All @@ -71,17 +123,15 @@ fun LineUpBox(
rotateDegree = 180f
)
PlayerLineUpBox(
startingPlayers = startingPlayers
matchLineup = matchLineup
)
}
}


@Composable
fun PlayerToWatchForBox(
player: Player,
games : Int,
goals : Int,
player: NotablePlayer,
modifier: Modifier = Modifier
){
Box(
Expand All @@ -102,7 +152,7 @@ fun PlayerToWatchForBox(
.wrapContentHeight()
.weight(0.45f)
.padding(end = 18.dp),
text = "${player.backNumber}",
text = "",
style = GnrTypography.heading2SemiBold,
color = ColorFF889AC4,
textAlign = TextAlign.End
Expand All @@ -113,34 +163,40 @@ fun PlayerToWatchForBox(
.weight(0.55f)
) {
Text(
text = player.displayName,
text = player.playerName,
style = GnrTypography.body1Medium,
color = ColorFF10358A
)
Text(
text = player.position,
text = player.playerPosition,
style = GnrTypography.descriptionRegular,
color = ColorFF10358A
)
}
}
PlayerStatToWatchForRow(
title = "Games",
stat = "$games",
stat = "${player.playerParticipationCount}",
modifier = Modifier.padding(bottom = 3.dp)
)
PlayerStatToWatchForRow(
title = "Goals",
stat = "$goals",
stat = "${player.playerGoalCount}",
modifier = Modifier
)
}

AsyncImage(
modifier = Modifier.fillMaxWidth(0.35f),
model = "",
contentDescription = ""
)
Box(
modifier = Modifier.fillMaxWidth(0.4f),
contentAlignment = Alignment.BottomCenter
){
AsyncImage(
modifier = Modifier
.fillMaxWidth(0.85f),
model = player.playerImageUrl,
contentDescription = "player"
)
}

}
}

Expand All @@ -161,13 +217,17 @@ fun PlayerStatToWatchForRow(
.weight(0.45f)
)
Text(
modifier = Modifier.wrapContentHeight().weight(0.45f),
modifier = Modifier
.wrapContentHeight()
.weight(0.45f),
text = title,
style = GnrTypography.body1Medium,
color = ColorFF181818
)
Text(
modifier = Modifier.wrapContentHeight().weight(0.1f),
modifier = Modifier
.wrapContentHeight()
.weight(0.1f),
text = stat,
maxLines = 1,
textAlign = TextAlign.Center,
Expand All @@ -179,15 +239,15 @@ fun PlayerStatToWatchForRow(

@Composable
fun PlayerLineUpBox(
startingPlayers : List<List<Player>>
matchLineup: MatchLineup
){
Column(
modifier = Modifier
.fillMaxSize()
.padding(start = 12.dp, end = 12.dp, top = 16.dp, bottom = 16.dp),
verticalArrangement = Arrangement.spacedBy(26.dp)
) {
startingPlayers.forEach { players ->
matchLineup.getMyTeamLineup(19).groupStartingPlayersByPosition().forEach { players ->
Row(
modifier = Modifier
.fillMaxWidth()
Expand All @@ -203,10 +263,4 @@ fun PlayerLineUpBox(
}
}
}
}

@Preview
@Composable
fun PreviewSummaryScreen(){
SummaryScreen()
}

0 comments on commit 8b9544a

Please sign in to comment.