Skip to content

Commit

Permalink
Boolti-238 feat: 결제 관련 약관 노션 연결 및 동의 로직 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
mangbaam committed Apr 29, 2024
1 parent 618eb6c commit d148c08
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
Expand Down Expand Up @@ -106,6 +107,7 @@ fun TicketingScreen(
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
var showConfirmDialog by remember { mutableStateOf(false) }
val context = LocalContext.current
val uriHandler = LocalUriHandler.current

val paymentLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
Expand Down Expand Up @@ -221,10 +223,16 @@ fun TicketingScreen(
OrderAgreementSection(
totalAgreed = uiState.orderAgreed,
agreement = uiState.orderAgreement,
agreementLabels = uiState.orderAgreementInfos,
onClickTotalAgree = viewModel::toggleAgreement,
onClickAgree = viewModel::toggleAgreement,
onClickShow = {}, // TODO 기획 확정되면 구현
onClickShow = {
val url = when (it) {
0 -> "https://boolti.notion.site/00259d85983c4ba8a987a374e2615396?pvs=4"
1 -> "https://boolti.notion.site/3-354880c7d75e424486b7974e5cc8bcad?pvs=4"
else -> return@OrderAgreementSection
}
uriHandler.openUri(url)
},
)

Text(
Expand Down Expand Up @@ -599,8 +607,7 @@ private fun TicketHolderSection(
@Composable
private fun OrderAgreementSection(
totalAgreed: Boolean,
agreementLabels: List<Int>,
agreement: List<Boolean>,
agreement: List<Pair<Int, Boolean>>,
onClickTotalAgree: () -> Unit,
onClickAgree: (index: Int) -> Unit,
onClickShow: (index: Int) -> Unit,
Expand Down Expand Up @@ -640,11 +647,11 @@ private fun OrderAgreementSection(
}

Spacer(modifier = Modifier.size(16.dp))
agreementLabels.forEachIndexed { index, labelRes ->
agreement.forEachIndexed { index, (labelRes, agreed) ->
OrderAgreementItem(
modifier = Modifier.padding(top = 4.dp),
index = index,
agreed = agreement[index],
agreed = agreed,
label = stringResource(labelRes),
onClickAgree = onClickAgree,
onClickShow = onClickShow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ data class TicketingState(
val depositorContact: String = "",
val inviteCode: String = "",
val refundPolicy: List<String> = emptyList(),
val orderAgreement: List<Boolean> = listOf(false, false, false),
val orderAgreement: List<Pair<Int, Boolean>> = listOf(
Pair(R.string.order_agreement_privacy_collection, false),
Pair(R.string.order_agreement_privacy_offer, false),
),
) {
val orderAgreementInfos = listOf(
R.string.order_agreement_privacy_collection,
R.string.order_agreement_privacy_offer,
R.string.order_agreement_payment_agency,
)

val orderAgreed: Boolean
get() = orderAgreement.none { !it }
get() = orderAgreement.none { !it.second }

val reservationButtonEnabled: Boolean
get() = when {
Expand All @@ -48,16 +45,16 @@ data class TicketingState(

fun toggleAgreement(index: Int): TicketingState {
val updated = orderAgreement.toMutableList().apply {
set(index, !orderAgreement[index])
set(index, orderAgreement[index].copy(second = !orderAgreement[index].second))
}
return copy(orderAgreement = updated)
}

fun toggleAgreement(): TicketingState {
return if (orderAgreed) {
copy(orderAgreement = orderAgreement.map { false })
copy(orderAgreement = orderAgreement.map { it.copy(second = false) })
} else {
copy(orderAgreement = orderAgreement.map { true })
copy(orderAgreement = orderAgreement.map { it.copy(second = true) })
}
}
}

0 comments on commit d148c08

Please sign in to comment.