Skip to content

Commit

Permalink
feat : [선물하기] 메시지, 송&수신자 정보 입력
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Jun 17, 2024
1 parent 3faf24f commit b7fc472
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
Expand Down Expand Up @@ -82,30 +83,28 @@ fun GiftScreen(
.verticalScroll(rememberScrollState())
) {
Column {
// TODO : 메서드 연결
CardSelection(
message = uiState.message,
onMessageChanged = {}
onMessageChanged = viewModel::updateMessage
)

// TODO : 받는 분, 보내는 분 데이터 연결
// TODO : 결제 후 카카오톡 친구 목록에서 받는... 어쩌구 문구 추가
// 받는 분
ContactInfo(
sectionName = stringResource(id = R.string.gift_receiver_info),
name = "",
phoneNumber = "",
onNameChanged = {},
onPhoneNumberChanged = {},
name = uiState.receiverName,
phoneNumber = uiState.receiverContact,
onNameChanged = viewModel::updateReceiverName,
onPhoneNumberChanged = viewModel::updateReceiverContact,
)

// 보내는 분
ContactInfo(
sectionName = stringResource(id = R.string.gift_sender_info),
name = "",
phoneNumber = "",
onNameChanged = {},
onPhoneNumberChanged = {},
name = uiState.senderName,
phoneNumber = uiState.senderContact,
onNameChanged = viewModel::updateSenderName,
onPhoneNumberChanged = viewModel::updateSenderContact,
)

// TODO : 섹션 제목 추가
Expand Down Expand Up @@ -224,6 +223,7 @@ private fun CardSelection(
value = message,
onValueChange = onMessageChanged,
textStyle = MaterialTheme.typography.titleLarge.copy(color = Color.White),
cursorBrush = SolidColor(Color.White)
)
Text(
modifier = Modifier.padding(top = 12.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ import java.time.LocalDateTime
@Stable
data class GiftUiState(
val loading: Boolean = true,
val message: String = "",
val poster: String = "",
val showDate: LocalDateTime = LocalDateTime.now(),
val showName: String = "",
val ticketName: String = "", // TODO : 티켓 정보 업데이트하기
val ticketName: String = "",
val ticketCount: Int = 1,
val totalPrice: Int = 0,
val refundPolicy: List<String> = emptyList(),
val orderAgreement: List<Pair<Int, Boolean>> = listOf(
Pair(R.string.order_agreement_privacy_collection, false),
Pair(R.string.order_agreement_privacy_offer, false),
),
val message: String = "공연에 초대합니다.",
val senderName: String = "",
val senderContact: String = "",
val receiverName: String = "",
val receiverContact: String = "",
) {
val orderAgreed: Boolean
get() = orderAgreement.none { !it.second }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.onStart
import kotlinx.coroutines.flow.update
Expand Down Expand Up @@ -52,7 +53,6 @@ class GiftViewModel @Inject constructor(
}.onEach { info ->
_uiState.update {
it.copy(
loading = false,
poster = info.showImg,
showDate = info.showDate,
showName = info.showName,
Expand All @@ -61,6 +61,30 @@ class GiftViewModel @Inject constructor(
totalPrice = info.totalPrice,
)
}
}.onCompletion {
_uiState.update {
it.copy(loading = false)
}
}.launchIn(viewModelScope + recordExceptionHandler)
}

fun updateMessage(message: String) {
_uiState.update { it.copy(message = message) }
}

fun updateSenderName(name: String) {
_uiState.update { it.copy(senderName = name) }
}

fun updateSenderContact(contact: String) {
_uiState.update { it.copy(senderContact = contact) }
}

fun updateReceiverName(name: String) {
_uiState.update { it.copy(receiverName = name) }
}

fun updateReceiverContact(contact: String) {
_uiState.update { it.copy(receiverContact = contact) }
}
}

0 comments on commit b7fc472

Please sign in to comment.