Skip to content

Commit

Permalink
Merge pull request #268 from Nexters/feature/255
Browse files Browse the repository at this point in the history
Feature/255 선물 등록하기
  • Loading branch information
HamBP authored Jul 28, 2024
2 parents 2fd431c + a01afd1 commit 9427654
Show file tree
Hide file tree
Showing 12 changed files with 337 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.nexters.boolti.data.network.request

import kotlinx.serialization.Serializable

@Serializable
data class GiftReceiveRequest(
val giftUuid: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package com.nexters.boolti.data.network.response

import com.nexters.boolti.data.util.toLocalDate
import com.nexters.boolti.domain.model.Gift
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class GiftResponse(
val id: String,
@SerialName("userId") val senderUserId: String,
val giftUuid: String,
val orderId: String?,
val reservationId: String,
Expand All @@ -23,6 +25,7 @@ data class GiftResponse(
fun toDomain(): Gift {
return Gift(
id = id,
senderUserId = senderUserId,
uuid = giftUuid,
orderId = orderId,
reservationId = reservationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.nexters.boolti.domain.request.LoginRequest
import com.nexters.boolti.domain.request.SignUpRequest
import com.nexters.boolti.domain.request.SignoutRequest
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject
Expand All @@ -34,6 +35,7 @@ internal class AuthRepositoryImpl @Inject constructor(
return authDataSource.login(request).onSuccess { response ->
tokenDataSource.saveTokens(response.accessToken ?: "", response.refreshToken ?: "")
deviceTokenDataSource.sendFcmToken()
getUserAndCache().first()
}.mapCatching(LoginResponse::toDomain)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import java.time.LocalDate

data class Gift(
val id: String,
val senderUserId: String,
val uuid: String,
val orderId: String?,
val reservationId: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.nexters.boolti.presentation.component

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
Expand All @@ -27,14 +29,18 @@ import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.nexters.boolti.presentation.R
import com.nexters.boolti.presentation.theme.BooltiTheme
import com.nexters.boolti.presentation.theme.Grey05
import com.nexters.boolti.presentation.theme.Grey50
import com.nexters.boolti.presentation.theme.Grey80

@Composable
fun BTDialog(
modifier: Modifier = Modifier,
enableDismiss: Boolean = true,
showCloseButton: Boolean = true,
onDismiss: () -> Unit = {},
negativeButtonLabel: String = stringResource(R.string.cancel),
onClickNegativeButton: (() -> Unit)? = null,
positiveButtonLabel: String = stringResource(R.string.btn_ok),
positiveButtonEnabled: Boolean = true,
horizontalAlignment: Alignment.Horizontal = Alignment.CenterHorizontally,
Expand Down Expand Up @@ -79,12 +85,27 @@ fun BTDialog(
}
content()
Spacer(modifier = Modifier.size(28.dp))
MainButton(
modifier = Modifier.fillMaxWidth(),
label = positiveButtonLabel,
enabled = positiveButtonEnabled,
onClick = onClickPositiveButton,
)
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
if (onClickNegativeButton != null) {
MainButton(
modifier = Modifier.weight(1f),
label = negativeButtonLabel,
onClick = onClickNegativeButton,
colors = MainButtonDefaults.buttonColors(
containerColor = Grey80,
contentColor = Grey05,
)
)
}
MainButton(
modifier = Modifier.weight(1f),
label = positiveButtonLabel,
enabled = positiveButtonEnabled,
onClick = onClickPositiveButton,
)
}
}
}
}
Expand All @@ -101,3 +122,17 @@ fun BTDialogPreview() {
}
}
}

@Preview
@Composable
fun BTDialogHavingNegativeButtonPreview() {
BooltiTheme {
Surface {
BTDialog(
onClickNegativeButton = {}
) {
Text(text = "관리자 코드로 입장 확인")
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.nexters.boolti.presentation.screen.home

import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.nexters.boolti.presentation.R
import com.nexters.boolti.presentation.component.BTDialog
import com.nexters.boolti.presentation.theme.Grey15
import com.nexters.boolti.presentation.theme.Grey50

@Composable
fun GiftDialog(
status: GiftStatus,
onDismiss: () -> Unit,
receiveGift: () -> Unit,
requireLogin: () -> Unit,
onFailed: () -> Unit,
) {
val buttonTextRes = when (status) {
GiftStatus.SELF, GiftStatus.CAN_REGISTER -> R.string.gift_register
GiftStatus.NEED_LOGIN -> R.string.gift_login
GiftStatus.FAILED -> R.string.description_close_button
}

val textRes = when (status) {
GiftStatus.SELF -> R.string.gift_self_dialog
GiftStatus.NEED_LOGIN -> R.string.gift_need_login
GiftStatus.CAN_REGISTER -> R.string.gift_register_dialog
GiftStatus.FAILED -> R.string.gift_registration_failed
}

val action: () -> Unit = when (status) {
GiftStatus.SELF -> {
{
receiveGift()
onDismiss()
}
}

GiftStatus.NEED_LOGIN -> requireLogin
GiftStatus.CAN_REGISTER -> {
{
receiveGift()
onDismiss()
}
}

GiftStatus.FAILED -> onDismiss
}

val hasNegativeButton = status in listOf(GiftStatus.SELF, GiftStatus.CAN_REGISTER)

BTDialog(
onDismiss = onDismiss,
onClickPositiveButton = action,
positiveButtonLabel = stringResource(id = buttonTextRes),
onClickNegativeButton = if(hasNegativeButton) onFailed else null
) {
Text(
text = stringResource(id = textRes),
style = MaterialTheme.typography.titleLarge.copy(
color = Grey15,
textAlign = TextAlign.Center
),
)
if (status == GiftStatus.FAILED) {
Text(
modifier = Modifier.padding(top = 4.dp),
text = stringResource(id = R.string.gift_registration_failed_dialog),
style = MaterialTheme.typography.bodySmall.copy(
color = Grey50,
textAlign = TextAlign.Center
),
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.nexters.boolti.presentation.screen.home

enum class GiftStatus {
NEED_LOGIN,
FAILED,
SELF,
CAN_REGISTER,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.nexters.boolti.presentation.screen.home

sealed interface HomeEvent {
data class DeepLinkEvent(
val deepLink: String,
) : HomeEvent

data class ShowMessage(
val status: GiftStatus
) : HomeEvent
}
Loading

0 comments on commit 9427654

Please sign in to comment.