Skip to content

Commit

Permalink
Merge pull request #258 from Nexters/feature/254
Browse files Browse the repository at this point in the history
Feature/254 선물하기 flow
  • Loading branch information
HamBP authored Jul 15, 2024
2 parents 6630b56 + 747adba commit 70bea32
Show file tree
Hide file tree
Showing 40 changed files with 1,862 additions and 132 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.nexters.boolti.data.datasource

import com.nexters.boolti.data.network.api.GiftService
import com.nexters.boolti.data.network.request.GiftReceiveRequest
import com.nexters.boolti.data.network.response.ApproveGiftPaymentResponse
import com.nexters.boolti.data.network.response.GiftResponse
import com.nexters.boolti.data.network.response.ImageResponse
import com.nexters.boolti.domain.request.GiftApproveRequest
import javax.inject.Inject

internal class GiftDataSource @Inject constructor(
private val service: GiftService
) {
suspend fun receiveGift(request: GiftReceiveRequest): Boolean = service.receiveGift(request)

suspend fun approveGiftPayment(request: GiftApproveRequest): ApproveGiftPaymentResponse =
service.approveGiftPayment(request)

suspend fun getGift(giftId: String): GiftResponse = service.getGift(giftId)

suspend fun getGiftImages(): List<ImageResponse> = service.getGiftImages()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.nexters.boolti.data.network.AuthAuthenticator
import com.nexters.boolti.data.datasource.AuthDataSource
import com.nexters.boolti.data.network.AuthInterceptor
import com.nexters.boolti.data.network.api.DeviceTokenService
import com.nexters.boolti.data.network.api.GiftService
import com.nexters.boolti.data.network.api.HostService
import com.nexters.boolti.data.network.api.ReservationService
import com.nexters.boolti.data.network.api.ShowService
Expand Down Expand Up @@ -95,6 +96,10 @@ internal object NetworkModule {
@Provides
fun provideTicketingService(@Named("auth") retrofit: Retrofit): TicketingService = retrofit.create()

@Singleton
@Provides
fun provideGiftService(@Named("auth") retrofit: Retrofit): GiftService = retrofit.create()

@Singleton
@Provides
fun provideTicketService(@Named("auth") retrofit: Retrofit): TicketService = retrofit.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package com.nexters.boolti.data.di
import com.nexters.boolti.data.repository.TicketingRepositoryImpl
import com.nexters.boolti.data.repository.AuthRepositoryImpl
import com.nexters.boolti.data.repository.ConfigRepositoryImpl
import com.nexters.boolti.data.repository.GiftRepositoryImpl
import com.nexters.boolti.data.repository.ReservationRepositoryImpl
import com.nexters.boolti.data.repository.HostRepositoryImpl
import com.nexters.boolti.data.repository.ShowRepositoryImpl
import com.nexters.boolti.data.repository.TicketRepositoryImpl
import com.nexters.boolti.domain.repository.AuthRepository
import com.nexters.boolti.domain.repository.ConfigRepository
import com.nexters.boolti.domain.repository.GiftRepository
import com.nexters.boolti.domain.repository.ReservationRepository
import com.nexters.boolti.domain.repository.HostRepository
import com.nexters.boolti.domain.repository.ShowRepository
Expand All @@ -34,6 +36,9 @@ internal abstract class RepositoryModule {
@Binds
abstract fun bindTicketingRepository(repository: TicketingRepositoryImpl): TicketingRepository

@Binds
abstract fun bindGiftRepository(repository: GiftRepositoryImpl): GiftRepository

@Binds
abstract fun bindTicketRepository(repository: TicketRepositoryImpl): TicketRepository

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.nexters.boolti.data.network.api

import com.nexters.boolti.data.network.request.GiftReceiveRequest
import com.nexters.boolti.data.network.response.ApproveGiftPaymentResponse
import com.nexters.boolti.data.network.response.GiftResponse
import com.nexters.boolti.data.network.response.ImageResponse
import com.nexters.boolti.domain.request.GiftApproveRequest
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

internal interface GiftService {
@POST("/app/api/v1/order/receive-gift")
suspend fun receiveGift(@Body request: GiftReceiveRequest): Boolean

@POST("/app/api/v1/order/gift-approve-payment")
suspend fun approveGiftPayment(@Body request: GiftApproveRequest): ApproveGiftPaymentResponse

@GET("/app/api/v1/gift/{giftId}")
suspend fun getGift(@Path("giftId") giftId: String): GiftResponse

@GET("/app/api/v1/gift/img-list")
suspend fun getGiftImages(): List<ImageResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.nexters.boolti.data.network.request

data class GiftReceiveRequest(
val giftId: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.nexters.boolti.data.network.response

import com.nexters.boolti.domain.model.ApproveGiftPayment
import kotlinx.serialization.Serializable

@Serializable
data class ApproveGiftPaymentResponse(
val orderId: String,
val reservationId: String,
val giftId: String,
) {
fun toDomain(): ApproveGiftPayment {
return ApproveGiftPayment(
orderId = orderId,
reservationId = reservationId,
giftId = giftId
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.nexters.boolti.data.network.response

import com.nexters.boolti.domain.model.Gift
import kotlinx.serialization.Serializable

@Serializable
data class GiftResponse(
val id: String,
val orderId: String,
val reservationId: String,
val giftImgId: String,
val message: String,
val senderName: String,
val senderPhoneNumber: String,
val recipientName: String,
val recipientPhoneNumber: String,
val isDone: Boolean,
) {
fun toDomain(): Gift {
return Gift(
id = id,
orderId = orderId,
reservationId = reservationId,
giftImgId = giftImgId,
message = message,
senderName = senderName,
senderPhoneNumber = senderPhoneNumber,
recipientName = recipientName,
recipientPhoneNumber = recipientPhoneNumber,
isDone = isDone,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.nexters.boolti.data.repository

import com.nexters.boolti.data.datasource.GiftDataSource
import com.nexters.boolti.data.network.request.GiftReceiveRequest
import com.nexters.boolti.data.network.response.toDomains
import com.nexters.boolti.domain.model.ApproveGiftPayment
import com.nexters.boolti.domain.model.Gift
import com.nexters.boolti.domain.model.ImagePair
import com.nexters.boolti.domain.repository.GiftRepository
import com.nexters.boolti.domain.request.GiftApproveRequest
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

internal class GiftRepositoryImpl @Inject constructor(
private val dataSource: GiftDataSource
) : GiftRepository {
override fun receiveGift(giftId: String): Flow<Boolean> = flow {
emit(dataSource.receiveGift(GiftReceiveRequest(giftId)))
}

override fun approveGiftPayment(request: GiftApproveRequest): Flow<ApproveGiftPayment> = flow {
emit(dataSource.approveGiftPayment(request).toDomain())
}

override fun getGift(giftId: String): Flow<Gift> = flow {
emit(dataSource.getGift(giftId).toDomain())
}

override fun getGiftImages(): Flow<List<ImagePair>> = flow {
emit(dataSource.getGiftImages().toDomains())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal class TicketingRepositoryImpl @Inject constructor(
emit(reservationDataSource.findReservationById(reservationId).toDomain())
}

override fun getOrderId(request: OrderIdRequest): Flow<String> = flow {
override fun requestOrderId(request: OrderIdRequest): Flow<String> = flow {
emit(dataSource.requestOrderId(request))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.nexters.boolti.domain.model

data class ApproveGiftPayment(
val orderId: String,
val reservationId: String,
val giftId: String,
)
14 changes: 14 additions & 0 deletions domain/src/main/java/com/nexters/boolti/domain/model/Gift.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nexters.boolti.domain.model

data class Gift(
val id: String,
val orderId: String,
val reservationId: String,
val giftImgId: String,
val message: String,
val senderName: String,
val senderPhoneNumber: String,
val recipientName: String,
val recipientPhoneNumber: String,
val isDone: Boolean,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.nexters.boolti.domain.repository

import com.nexters.boolti.domain.model.ApproveGiftPayment
import com.nexters.boolti.domain.model.Gift
import com.nexters.boolti.domain.model.ImagePair
import com.nexters.boolti.domain.request.GiftApproveRequest
import kotlinx.coroutines.flow.Flow

interface GiftRepository {
fun receiveGift(giftId: String): Flow<Boolean>

fun approveGiftPayment(request: GiftApproveRequest): Flow<ApproveGiftPayment>

fun getGift(giftId: String): Flow<Gift>

fun getGiftImages(): Flow<List<ImagePair>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface TicketingRepository {
fun requestReservation(request: TicketingRequest): Flow<String>
fun checkInviteCode(request: CheckInviteCodeRequest): Flow<InviteCodeStatus>
fun getPaymentInfo(reservationId: String): Flow<ReservationDetail>
fun getOrderId(request: OrderIdRequest): Flow<String>
fun requestOrderId(request: OrderIdRequest): Flow<String>
fun approvePayment(request: PaymentApproveRequest): Flow<ApprovePaymentResponse>
fun cancelPayment(request: PaymentCancelRequest): Flow<Boolean>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.nexters.boolti.domain.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class GiftApproveRequest(
val orderId: String,
val amount: Int,
val paymentKey: String,
val showId: String,
val salesTicketTypeId: String,
val ticketCount: Int,
@SerialName("giftImgId") val giftImageId: String,
val message: String,
val senderName: String,
val senderPhoneNumber: String,
val recipientName: String,
val recipientPhoneNumber: String,
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.nexters.boolti.presentation.component

import android.util.Log
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
Expand All @@ -25,6 +24,7 @@ import com.kakao.sdk.auth.model.OAuthToken
import com.kakao.sdk.user.UserApiClient
import com.nexters.boolti.presentation.R
import com.nexters.boolti.presentation.theme.Grey95
import com.nexters.boolti.presentation.theme.KakaoYellow
import timber.log.Timber

@Composable
Expand Down Expand Up @@ -57,15 +57,15 @@ fun KakaoLoginButton(
.fillMaxWidth()
.height(48.dp),
shape = RoundedCornerShape(4.dp),
colors = ButtonDefaults.outlinedButtonColors(containerColor = Color(0XFFFFE833)),
colors = ButtonDefaults.outlinedButtonColors(containerColor = KakaoYellow),
contentPadding = PaddingValues(horizontal = 20.dp)
) {
Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.CenterStart,
) {
Icon(
painter = painterResource(R.drawable.ic_kakaotalk), contentDescription = "카카오톡 아이콘",
painter = painterResource(R.drawable.ic_kakaotalk), contentDescription = null,
modifier = Modifier.size(width = 20.dp, height = 20.dp),
tint = Color.Black,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package com.nexters.boolti.presentation.component

import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
Expand All @@ -27,19 +29,14 @@ fun MainButton(
modifier: Modifier = Modifier,
label: String = stringResource(id = R.string.btn_ok),
enabled: Boolean = true,
disabledContentColor: Color = Grey50,
colors: ButtonColors = MainButtonDefaults.buttonColors(),
onClick: () -> Unit,
) {
Button(
modifier = modifier.height(48.dp),
onClick = onClick,
enabled = enabled,
colors = ButtonDefaults.buttonColors(
containerColor = MaterialTheme.colorScheme.primary,
contentColor = MaterialTheme.colorScheme.onPrimary,
disabledContainerColor = Grey80,
disabledContentColor = disabledContentColor,
),
colors = colors,
shape = RoundedCornerShape(4.dp),
contentPadding = PaddingValues(horizontal = marginHorizontal),
interactionSource = remember { MutableInteractionSource() },
Expand All @@ -48,6 +45,22 @@ fun MainButton(
}
}

object MainButtonDefaults {

@Composable
fun buttonColors(
containerColor: Color = MaterialTheme.colorScheme.primary,
contentColor: Color = MaterialTheme.colorScheme.onPrimary,
disabledContainerColor: Color = Grey80,
disabledContentColor: Color = Grey50,
): ButtonColors = ButtonDefaults.buttonColors(
containerColor = containerColor,
contentColor = contentColor,
disabledContainerColor = disabledContainerColor,
disabledContentColor = disabledContentColor
)
}

@Composable
fun SecondaryButton(
modifier: Modifier = Modifier,
Expand Down Expand Up @@ -79,7 +92,26 @@ fun SecondaryButton(
fun MainButtonPreview() {
BooltiTheme {
Surface {
MainButton(label = "확인") {}
MainButton(
modifier = Modifier.fillMaxWidth(),
label = "확인",
) {}
}
}
}

@Preview
@Composable
fun AnotherMainButtonPreview() {
BooltiTheme {
Surface {
MainButton(
modifier = Modifier.fillMaxWidth(),
label = "선물하기",
colors = MainButtonDefaults.buttonColors(
containerColor = Grey80
)
) {}
}
}
}
Loading

0 comments on commit 70bea32

Please sign in to comment.