diff --git a/presentation/src/main/java/com/nexters/boolti/presentation/extension/LocalDateTime.kt b/presentation/src/main/java/com/nexters/boolti/presentation/extension/LocalDateTime.kt index d456d776..652f1f45 100644 --- a/presentation/src/main/java/com/nexters/boolti/presentation/extension/LocalDateTime.kt +++ b/presentation/src/main/java/com/nexters/boolti/presentation/extension/LocalDateTime.kt @@ -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 @@ -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')}" } \ No newline at end of file diff --git a/presentation/src/main/java/com/nexters/boolti/presentation/screen/showdetail/ShowDetailButtons.kt b/presentation/src/main/java/com/nexters/boolti/presentation/screen/showdetail/ShowDetailButtons.kt index 66cbe223..aba65ba2 100644 --- a/presentation/src/main/java/com/nexters/boolti/presentation/screen/showdetail/ShowDetailButtons.kt +++ b/presentation/src/main/java/com/nexters/boolti/presentation/screen/showdetail/ShowDetailButtons.kt @@ -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 @@ -137,4 +137,19 @@ fun ShowDetailButtonsBeforeTicketingPreview() { onGiftClicked = {} ) } -} \ No newline at end of file +} + +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')}" + } \ No newline at end of file diff --git a/presentation/src/main/java/com/nexters/boolti/presentation/screen/showdetail/ShowDetailScreen.kt b/presentation/src/main/java/com/nexters/boolti/presentation/screen/showdetail/ShowDetailScreen.kt index 19963fb1..587e0f53 100644 --- a/presentation/src/main/java/com/nexters/boolti/presentation/screen/showdetail/ShowDetailScreen.kt +++ b/presentation/src/main/java/com/nexters/boolti/presentation/screen/showdetail/ShowDetailScreen.kt @@ -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 @@ -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 @@ -172,6 +178,12 @@ fun ShowDetailScreen( LazyColumn( modifier = Modifier, ) { + item { + CountDownBanner( + uiState.showDetail.salesEndDate.plusDays(1).atStartOfDay().minusMinutes(1) + ) + } + item { Poster( modifier = modifier.fillMaxWidth(), @@ -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) + ) + } +} \ No newline at end of file diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 42c5e0c1..a5f24514 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -221,6 +221,7 @@ 공연 정보 출연진 %d매 판매 완료 + 🔥 판매 종료까지 COMING SOON 조금만 기다려주세요!