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/270 1.6.X 버전 선물하기 디자인 QA #274

Merged
merged 10 commits into from
Jul 30, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,21 @@ internal data class GiftPaymentInfoResponse(
reservationState = reservationStatus.toReservationState(),
completedDateTime = null,
visitorName = recipientName,
visitorPhoneNumber = recipientPhoneNumber,
visitorPhoneNumber = recipientPhoneNumber.toDashedPhoneNumber(),
depositorName = senderName,
depositorPhoneNumber = senderPhoneNumber,
depositorPhoneNumber = senderPhoneNumber.toDashedPhoneNumber(),
csReservationId = csReservationId,
cardDetail = cardDetail?.toDomain(),
provider = easyPayDetail?.provider ?: ""
)
}

private fun String.toDashedPhoneNumber(): String {
if (!isPurePhoneNumber) return this

return slice(0..2) + "-" + slice(3..6) + "-" + slice(7..10)
}

private val String.isPurePhoneNumber
get() = "^\\d{11}$".toRegex().matches(this)
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ import com.nexters.boolti.presentation.screen.giftcomplete.GiftPolicy
import com.nexters.boolti.presentation.screen.giftcomplete.sendMessage
import com.nexters.boolti.presentation.theme.Grey10
import com.nexters.boolti.presentation.theme.Grey15
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.Grey80
import com.nexters.boolti.presentation.theme.Grey90
import com.nexters.boolti.presentation.theme.marginHorizontal
import com.nexters.boolti.presentation.theme.point2
import java.time.LocalDateTime

@Composable
fun ReservationDetailScreen(
Expand Down Expand Up @@ -124,7 +122,9 @@ fun ReservationDetailScreen(
}
Header(reservation = state.reservation)
TicketHolderInfo(reservation = state.reservation)
if (state.reservation.totalAmountPrice > 0) DepositorInfo(reservation = state.reservation)
if (state.reservation.totalAmountPrice > 0 || state.reservation.isGift) {
DepositorInfo(reservation = state.reservation)
}
TicketInfo(reservation = state.reservation)
PaymentInfo(reservation = state.reservation)
if (state.reservation.reservationState in listOf(
Expand All @@ -141,7 +141,7 @@ fun ReservationDetailScreen(
.padding(horizontal = marginHorizontal, vertical = 8.dp)
.fillMaxWidth(),
colors = MainButtonDefaults.buttonColors(
containerColor = Grey20,
containerColor = Grey15,
contentColor = Grey90,
),
label = stringResource(id = R.string.refund_button),
Expand Down Expand Up @@ -323,7 +323,7 @@ private fun TicketHolderInfo(
key = stringResource(id = R.string.contact_label),
value = reservation.visitorPhoneNumber
)
if (isGift) {
if (isGift && reservation.reservationState != ReservationState.CANCELED) {
val month = reservation.salesEndDateTime.month.value
val day = reservation.salesEndDateTime.dayOfMonth
val dateText = stringResource(id = R.string.gift_expiration_date, month, day)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ fun MainNavigation(modifier: Modifier, onClickQrScan: (showId: String, showName:
navigateToHome = navController::navigateToHome,
)
addGiftCompleteScreen(
navigateTo = navController::navigateTo,
navigateToHome = navController::navigateToHome,
popBackStack = { navController.popBackStack(MainDestination.Gift.route, true)}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ sealed class MainDestination(val route: String) {
)
}

data object GiftComplete : MainDestination(route = "giftComplete?reservationId={reservationId}&giftUuid={giftUuid}") {
data object GiftComplete : MainDestination(route = "giftComplete?giftId={giftId}") {
val arguments = listOf(
navArgument(reservationId) { type = NavType.StringType },
navArgument("giftId") { type = NavType.StringType },
)

fun createRoute(
reservationId: String,
giftUuid: String,
): String = "giftComplete?reservationId=$reservationId&giftUuid=$giftUuid"
giftId: String
): String = "giftComplete?giftId=${giftId}"
}

data object TicketDetail : MainDestination(route = "tickets") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ fun CardSelection(
color = Color(0xFFFFA883),
shape = RoundedCornerShape(8.dp)
)
.padding(horizontal = 20.dp, vertical = 32.dp)
.padding(top = 32.dp)
.padding(horizontal = 20.dp)
.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Expand Down Expand Up @@ -97,7 +98,6 @@ fun CardSelection(
modifier = Modifier
.padding(top = 28.dp)
.fillMaxWidth()
.aspectRatio(3 / 2f)
.background(Color.White),
contentScale = ContentScale.Crop,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.nexters.boolti.presentation.screen.gift

sealed interface GiftEvent {
data class GiftSuccess(val reservationId: String, val giftUuid: String) : GiftEvent
data class GiftSuccess(val giftId: String) : GiftEvent
data class ProgressPayment(val userId: String, val orderId: String) : GiftEvent
data object NoRemainingQuantity : GiftEvent
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fun NavGraphBuilder.addGiftScreen(
modifier = modifier,
popBackStack = popBackStack,
navigateToBusiness = { navigateTo(MainDestination.Business.route) },
navigateToComplete = { reservationId, giftUuid ->
navigateTo(MainDestination.GiftComplete.createRoute(reservationId, giftUuid))
navigateToComplete = { giftId ->
navigateTo(MainDestination.GiftComplete.createRoute(giftId))
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import com.nexters.boolti.tosspayments.TossPaymentWidgetActivity.Companion.RESUL
fun GiftScreen(
popBackStack: () -> Unit,
navigateToBusiness: () -> Unit,
navigateToComplete: (reservationId: String, giftUuid: String) -> Unit,
navigateToComplete: (giftId: String) -> Unit,
modifier: Modifier = Modifier,
viewModel: GiftViewModel = hiltViewModel(),
) {
Expand All @@ -78,13 +78,10 @@ fun GiftScreen(
when (result.resultCode) {
RESULT_SUCCESS -> {
val intent = result.data ?: return@rememberLauncherForActivityResult
val reservationId =
intent.getStringExtra("reservationId")
?: return@rememberLauncherForActivityResult
val giftUuid = intent.getStringExtra("giftUuid")
val giftId = intent.getStringExtra("giftId")
?: return@rememberLauncherForActivityResult

navigateToComplete(reservationId, giftUuid)
navigateToComplete(giftId)
}

RESULT_SOLD_OUT -> showTicketSoldOutDialog = true
Expand All @@ -97,7 +94,7 @@ fun GiftScreen(
.collect { event ->
when (event) {
is GiftEvent.GiftSuccess -> {
navigateToComplete(event.reservationId, event.giftUuid)
navigateToComplete(event.giftId)
}

is GiftEvent.ProgressPayment -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,7 @@ class GiftViewModel @Inject constructor(
)
.onStart { _uiState.update { it.copy(loading = true) } }
.onEach { giftPayment ->
sendEvent(
GiftEvent.GiftSuccess(
reservationId = giftPayment.reservationId,
giftUuid = giftPayment.giftUuid
)
)
sendEvent(GiftEvent.GiftSuccess(giftId = giftPayment.giftId))
}
.onCompletion { _uiState.update { it.copy(loading = false) } }
.launchIn(viewModelScope + recordExceptionHandler)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@ import androidx.navigation.compose.composable
import com.nexters.boolti.presentation.screen.MainDestination

fun NavGraphBuilder.addGiftCompleteScreen(
navigateTo: (String) -> Unit,
navigateToHome: () -> Unit,
popBackStack: () -> Unit,
) {
composable(
route = MainDestination.GiftComplete.route,
) {
GiftCompleteScreen(onClickClose = popBackStack, onClickHome = navigateToHome)
GiftCompleteScreen(
onClickClose = popBackStack,
onClickHome = navigateToHome,
navigateToReservation = { reservation ->
navigateTo(
MainDestination.ReservationDetail.createRoute(
id = reservation.id,
isGift = true,
)
)
},
)
}
}
Loading
Loading