Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Modified Match Detail Screen (4) #87

Merged
merged 14 commits into from
Jun 2, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,56 @@ package com.eshc.goonersapp.core.common.util
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import java.util.Locale

const val DefaultDatePattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"

object DateUtil {
private val defaultDateFormat = DateTimeFormatter.ofPattern(DefaultDatePattern)

fun getYearAndMonthString(date : String ) : String {
if(date.isBlank()) return date
return LocalDate.parse(date, defaultDateFormat).format(DateTimeFormatter.ofPattern("yyyy.MM"))
fun getYearAndMonthString(date: String): String {
if (date.isBlank()) return date
return LocalDate.parse(date, defaultDateFormat)
.format(DateTimeFormatter.ofPattern("yyyy.MM"))
}

fun getYearAndMonthAndDateString(date: String): String {
if (date.isBlank()) return date
return LocalDate.parse(date, defaultDateFormat)
.format(DateTimeFormatter.ofPattern("yyyy.MM.dd"))
}

fun getYearAndMonthAndDateString(date : String ) : String {
if(date.isBlank()) return date
return LocalDate.parse(date, defaultDateFormat).format(DateTimeFormatter.ofPattern("yyyy.MM.dd"))
fun getYearAndMonthAndDateAndTimeString(date: String): String {
if (date.isBlank()) return date
return LocalDateTime.parse(date, defaultDateFormat)
.format(DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm"))
}

fun getYearAndMonthAndDateAndTimeString(date : String ) : String {
if(date.isBlank()) return date
return LocalDateTime.parse(date, defaultDateFormat).format(DateTimeFormatter.ofPattern("yyyy.MM.dd HH:mm"))
fun getYearAndMonthAndDateAndDayAndTimeString(date: String): String {
if (date.isBlank()) return date
return LocalDateTime.parse(date, defaultDateFormat).format(
DateTimeFormatter.ofPattern(
"yyyy.MM.dd E HH:mm",
Locale.US
)
).uppercase()
}

fun getYearAndMonthAndDateAndDayAndTimeString(date : String ) : String {
if(date.isBlank()) return date
return LocalDateTime.parse(date, defaultDateFormat).format(DateTimeFormatter.ofPattern("yyyy.MM.dd E HH:mm")).uppercase()
fun getMonthAndDateAndDayString(date: String): String {
if (date.isBlank()) return date
return LocalDateTime.parse(date, defaultDateFormat)
.format(DateTimeFormatter.ofPattern("MM.dd E", Locale.US)).uppercase()
}

fun getYearAndMonthAndDateLocalDate(date : String ) : LocalDate {
if(date.isBlank()) return LocalDate.now()
fun getYearAndMonthAndDateLocalDate(date: String): LocalDate {
if (date.isBlank()) return LocalDate.now()
return LocalDate.parse(date, defaultDateFormat)
}

fun getTimeString(date: String) : String {
if(date.isBlank()) return date
fun getTimeString(date: String): String {
if (date.isBlank()) return date
return LocalDateTime.parse(date, defaultDateFormat).let {
"${it.hour}:" + "${it.minute}".padStart(2,'0')
"${it.hour}:" + "${it.minute}".padStart(2, '0')
}
}
}
Binary file added core/designsystem/src/main/res/drawable/ic_ball.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,31 @@ import androidx.compose.foundation.background
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.RowScope
import androidx.compose.foundation.layout.fillMaxHeight
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.size
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.VerticalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import coil.compose.AsyncImage
import com.eshc.goonersapp.core.common.state.UiState
import com.eshc.goonersapp.core.common.util.DateUtil
import com.eshc.goonersapp.core.designsystem.IconPack
Expand All @@ -50,9 +38,6 @@ import com.eshc.goonersapp.core.designsystem.component.MatchLeagueInfo
import com.eshc.goonersapp.core.designsystem.iconpack.IcTalk
import com.eshc.goonersapp.core.designsystem.theme.ColorFF10358A
import com.eshc.goonersapp.core.designsystem.theme.ColorFF777777
import com.eshc.goonersapp.core.designsystem.theme.ColorFFC3CDE2
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
Expand All @@ -77,7 +62,11 @@ fun MatchDetailRootScreen(
GnrTopBar(
title = "",
onBackIconClick = onBackIconClick,
content = { }
content = {
MatchDetailTopBar(
match = matchData.match
)
}
)
}
) { paddingValues ->
Expand Down Expand Up @@ -115,115 +104,37 @@ fun MatchDetailScreen(
.fillMaxSize()
) {
item {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 20.dp),
verticalAlignment = Alignment.CenterVertically
) {
MatchLeagueInfo(
logoSize = 25.dp,
logoPadding = 4.dp,
competitionUrl = match.leagueImageUrl,
competitionName = "Premier league",
verticalAlignment = Alignment.CenterVertically,
)

Column(
modifier = Modifier
.wrapContentHeight()
.weight(1f),
horizontalAlignment = Alignment.End
) {
Text(
text = DateUtil.getYearAndMonthAndDateAndDayAndTimeString(match.matchDate),
style = GnrTypography.body1SemiBold,
color = ColorFF10358A,
)
Text(
modifier = Modifier.padding(top = 4.dp),
text = match.stadiumName,
style = GnrTypography.body2Regular,
color = ColorFF777777,
)
}
}

val annotatedScore = if (match.isFinished) buildAnnotatedString {
withStyle(style = SpanStyle(ColorFF10358A)) { append("${match.homeScore} ") }
withStyle(style = SpanStyle(ColorFFC3CDE2)) { append(":") }
withStyle(style = SpanStyle(ColorFF10358A)) { append(" ${match.awayScore}") }
} else buildAnnotatedString {
withStyle(style = SpanStyle(ColorFF10358A)) { append(" vs ") }
}
Row(
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
.padding(horizontal = 24.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceAround
) {
TeamLogoImageBox(
teamLogoImageUrl = match.homeTeamImageUrl
)

Text(
modifier = Modifier.padding(horizontal = 8.dp),
text = annotatedScore,
style = GnrTypography.heading1Bold,
)

TeamLogoImageBox(
teamLogoImageUrl = match.awayTeamImageUrl
)
}

MatchInfoBoard(
match
)
}


item {
when(matchDetail){
is UiState.Success -> {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(
top = 20.dp
)
.height(IntrinsicSize.Min),
horizontalArrangement = Arrangement.Center,
content = {
MatchScoredHistory(
modifier = Modifier.weight(1f),
horizontalAlignment = Alignment.End,
matchScoreHistoryList = matchDetail.data.getScoreHistoryList(match.homeTeamId)
)
VerticalDivider(
modifier = Modifier
.fillMaxHeight()
.padding(horizontal = 12.dp)
)
MatchScoredHistory(
modifier = Modifier.weight(1f),
horizontalAlignment = Alignment.Start,
matchScoreHistoryList = matchDetail.data.getScoreHistoryList(match.awayTeamId)
)
}
)
}
is UiState.Loading -> {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp),
contentAlignment = Alignment.Center
){
CircularProgressIndicator()
if(match.isFinished){
when (matchDetail) {
is UiState.Success -> {
MatchScoreBoard(
match = match,
matchDetailList = matchDetail.data
)
}

}
else -> {
is UiState.Loading -> {
Box(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator()
}

}

else -> {
//TODOx
}
}
}

Expand Down Expand Up @@ -257,6 +168,7 @@ fun MatchDetailScreen(
when (selectedTab) {
DetailTab.SUMMARY -> {
SummaryScreen(
match = match,
lineupUiState = lineupUiState,
matchInformationState = matchInformationState
)
Expand Down Expand Up @@ -299,49 +211,13 @@ fun RowScope.MatchScoredHistory(
matchScoreHistoryList.forEach { history ->
Text(
text = history.scoringRecordText,
color = ColorFF10358A,
color = if(history.teamId == 19) ColorFF10358A else ColorFF777777,
style = GnrTypography.descriptionMedium
)
}
}
}

@Composable
fun TeamLogoImageBox(
teamLogoImageUrl: String,
modifier: Modifier = Modifier
) {
Box(
modifier = modifier
.size(88.dp)
.clip(CircleShape)
.background(
ColorFFF5F5F5
),
contentAlignment = Alignment.Center
) {
Box(
modifier = Modifier
.shadow(
elevation = 3.dp,
shape = CircleShape
)
.size(72.dp)
.clip(CircleShape)
.background(
ColorFFFFFFFF
),
contentAlignment = Alignment.Center
) {
AsyncImage(
modifier = Modifier.fillMaxWidth(0.65f),
model = teamLogoImageUrl,
contentDescription = null,
contentScale = ContentScale.FillWidth
)
}
}
}

enum class DetailTab {
SUMMARY, COMMENT
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.eshc.goonersapp.feature.match.detail

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.eshc.goonersapp.core.designsystem.theme.ColorFF181818
import com.eshc.goonersapp.core.designsystem.theme.GnrTypography
import com.eshc.goonersapp.feature.match.model.MatchUiModel

@Composable
fun MatchDetailTopBar(
match : MatchUiModel
){
Row(
modifier = Modifier
.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(7.dp, alignment = Alignment.Start)
) {
AsyncImage(
modifier = Modifier.size(25.dp),
model = match.leagueImageUrl,
contentDescription = "League Logo"
)
Text(
text = match.getMatchTitle(),
style = GnrTypography.subtitleSemiBold,
color = ColorFF181818,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
}
}
Loading
Loading