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/255 선물 등록하기 #268

Merged
merged 17 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
HamBP marked this conversation as resolved.
Show resolved Hide resolved
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
Loading