Skip to content

Commit

Permalink
feat : 티켓 판매 종료 카운트 다운 배너 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Nov 12, 2024
1 parent c604706 commit 81602a1
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package com.nexters.boolti.presentation.extension

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import com.nexters.boolti.presentation.R
import java.time.Duration
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
Expand Down Expand Up @@ -38,19 +36,4 @@ val LocalDateTime.dDay: Long
get() = run {
val today = LocalDate.now()
ChronoUnit.DAYS.between(today, toLocalDate())
}

val LocalDateTime.countDownString: String
@Composable
get() = run {
val now = LocalDateTime.now()

val duration = Duration.between(now, this)

val days = duration.toDays()
val hours = duration.toHours() % 24
val minutes = duration.toMinutes() % 60

stringResource(id = R.string.ticketing_button_ticket_countdown, days) +
" ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import com.nexters.boolti.domain.model.ShowState
import com.nexters.boolti.presentation.R
import com.nexters.boolti.presentation.component.MainButton
import com.nexters.boolti.presentation.component.MainButtonDefaults
import com.nexters.boolti.presentation.extension.countDownString
import com.nexters.boolti.presentation.theme.BooltiTheme
import com.nexters.boolti.presentation.theme.Grey50
import com.nexters.boolti.presentation.theme.Grey80
import com.nexters.boolti.presentation.theme.marginHorizontal
import java.time.Duration
import java.time.LocalDateTime

@Composable
Expand Down Expand Up @@ -137,4 +137,19 @@ fun ShowDetailButtonsBeforeTicketingPreview() {
onGiftClicked = {}
)
}
}
}

private val LocalDateTime.countDownString: String
@Composable
get() = run {
val now = LocalDateTime.now()

val duration = Duration.between(now, this)

val days = duration.toDays()
val hours = duration.toHours() % 24
val minutes = duration.toMinutes() % 60

stringResource(id = R.string.ticketing_button_ticket_countdown, days) +
" ${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -81,18 +82,23 @@ import com.nexters.boolti.presentation.extension.showDateTimeString
import com.nexters.boolti.presentation.screen.LocalSnackbarController
import com.nexters.boolti.presentation.screen.ticketing.ChooseTicketBottomSheet
import com.nexters.boolti.presentation.screen.ticketing.TicketBottomSheetType
import com.nexters.boolti.presentation.theme.BooltiTheme
import com.nexters.boolti.presentation.theme.Grey05
import com.nexters.boolti.presentation.theme.Grey20
import com.nexters.boolti.presentation.theme.Grey30
import com.nexters.boolti.presentation.theme.Grey50
import com.nexters.boolti.presentation.theme.Grey70
import com.nexters.boolti.presentation.theme.Grey80
import com.nexters.boolti.presentation.theme.Grey85
import com.nexters.boolti.presentation.theme.Grey90
import com.nexters.boolti.presentation.theme.marginHorizontal
import com.nexters.boolti.presentation.theme.point2
import com.nexters.boolti.presentation.theme.point3
import com.nexters.boolti.presentation.util.UrlParser
import kotlinx.coroutines.launch
import timber.log.Timber
import java.time.Duration
import java.time.LocalDateTime
import kotlin.math.ceil

@Composable
Expand Down Expand Up @@ -172,6 +178,12 @@ fun ShowDetailScreen(
LazyColumn(
modifier = Modifier,
) {
item {
CountDownBanner(
uiState.showDetail.salesEndDate.plusDays(1).atStartOfDay().minusMinutes(1)
)
}

item {
Poster(
modifier = modifier.fillMaxWidth(),
Expand Down Expand Up @@ -771,3 +783,48 @@ private fun Cast(
private fun Divider(modifier: Modifier = Modifier) {
HorizontalDivider(modifier = modifier, color = Grey85)
}

@Composable
private fun CountDownBanner(deadlineDateTime: LocalDateTime) {
Box(
modifier = Modifier
.height(40.dp)
.fillMaxWidth()
.background(Grey05),
contentAlignment = Alignment.Center
) {
Text(
text = deadlineDateTime.countDownString,
style = MaterialTheme.typography.titleLarge.copy(color = Grey90)
)
}
}

private val LocalDateTime.countDownString: String
@Composable
get() = run {
val now = LocalDateTime.now()

val duration = Duration.between(now, this)
val hours = duration.toHours() % 24
val minutes = duration.toMinutes() % 60
val seconds = duration.seconds % 60

stringResource(id = R.string.show_ticketing_deadline_countdown) + " " +
"${hours.toString().padStart(2, '0')}:" +
"${minutes.toString().padStart(2, '0')}:" +
seconds.toString().padStart(2, '0')
}

@Preview
@Composable
private fun CountDownBannerPreview() {
BooltiTheme {
CountDownBanner(
deadlineDateTime = LocalDateTime.now()
.plusHours(0)
.plusMinutes(5)
.plusSeconds(12)
)
}
}
1 change: 1 addition & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
<string name="show_tab_info">공연 정보</string>
<string name="show_tab_cast">출연진</string>
<string name="show_sold_ticket_count">%d매 판매 완료</string>
<string name="show_ticketing_deadline_countdown">🔥 판매 종료까지</string>
<string name="empty_cast_title">COMING SOON</string>
<string name="empty_cast_desc">조금만 기다려주세요!</string>
<string name="show_share_format">
Expand Down

0 comments on commit 81602a1

Please sign in to comment.