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

[FEAT/#66] 설정뷰 / 배송지 등록 진입 API 구현 #67

Merged
merged 5 commits into from
Aug 12, 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
Expand Up @@ -84,6 +84,6 @@ class AuthInterceptor
private const val CODE_TOKEN_EXPIRED = 401
private const val TOKEN_EXPIRED_ERROR = "토큰이 만료되었어요\n다시 로그인 해주세요"
private const val BEARER = "Bearer"
private const val AUTHORIZATION = "Authorization"
private const val AUTHORIZATION = "accesstoken"
}
}
9 changes: 3 additions & 6 deletions app/src/main/java/co/orange/ddanzi/di/module/ServiceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,22 @@ object ServiceModule {
@RetrofitQualifier.NOTOKEN retrofit: Retrofit,
): SearchService = retrofit.create(SearchService::class.java)

// TODO
@Provides
@Singleton
fun provideProfileService(
@RetrofitQualifier.NOTOKEN retrofit: Retrofit,
@RetrofitQualifier.JWT retrofit: Retrofit,
): ProfileService = retrofit.create(ProfileService::class.java)

// TODO
@Provides
@Singleton
fun provideSettingService(
@RetrofitQualifier.NOTOKEN retrofit: Retrofit,
@RetrofitQualifier.JWT retrofit: Retrofit,
): SettingService = retrofit.create(SettingService::class.java)

// TODO
@Provides
@Singleton
fun provideInterestService(
@RetrofitQualifier.NOTOKEN retrofit: Retrofit,
@RetrofitQualifier.JWT retrofit: Retrofit,
): InterestService = retrofit.create(InterestService::class.java)

@Provides
Expand Down
10 changes: 5 additions & 5 deletions data/src/main/java/co/orange/data/dto/response/AddressDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import kotlinx.serialization.Serializable
data class AddressDto(
@SerialName("addressId")
val addressId: Long?,
@SerialName("name")
val name: String?,
@SerialName("recipient")
val recipient: String?,
@SerialName("zipCode")
val zipCode: String?,
@SerialName("type")
Expand All @@ -18,8 +18,8 @@ data class AddressDto(
val address: String,
@SerialName("detailAddress")
val detailAddress: String,
@SerialName("phone")
val phone: String?,
@SerialName("recipientPhone")
val recipientPhone: String?,
) {
fun toModel() = AddressModel(addressId, name, zipCode, type, address, detailAddress, phone)
fun toModel() = AddressModel(addressId, recipient, zipCode, type, address, detailAddress, recipientPhone)
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ data class ProductDetailDto(
val stockCount: Int,
@SerialName("infoUrl")
val infoUrl: String,
@SerialName("isInterested")
val isInterested: Boolean,
@SerialName("interestCount")
val interestCount: Int,
@SerialName("optionList")
Expand All @@ -43,6 +45,7 @@ data class ProductDetailDto(
salePrice,
stockCount,
infoUrl,
isInterested,
interestCount,
optionList.map { it.toModel() },
)
Expand Down
14 changes: 13 additions & 1 deletion data/src/main/java/co/orange/data/dto/response/ProductDto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@ data class ProductDto(
val originPrice: Int,
@SerialName("salePrice")
val salePrice: Int,
@SerialName("isInterested")
val isInterested: Boolean,
@SerialName("interestCount")
val interestCount: Int,
) {
fun toModel() = ProductModel(productId, kakaoProductId, name, imgUrl, originPrice, salePrice, interestCount)
fun toModel() =
ProductModel(
productId,
kakaoProductId,
name,
imgUrl,
originPrice,
salePrice,
isInterested,
interestCount,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package co.orange.domain.entity.response

data class AddressModel(
val addressId: Long?,
val name: String?,
val recipient: String?,
val zipCode: String?,
val type: String?,
val address: String?,
val detailAddress: String?,
val phone: String?,
val recipientPhone: String?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ data class ProductDetailModel(
val salePrice: Int,
val stockCount: Int,
val infoUrl: String,
val isInterested: Boolean,
val interestCount: Int,
val optionList: List<ProductOptionModel>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ data class ProductModel(
val imgUrl: String,
val originPrice: Int,
val salePrice: Int,
val isInterested: Boolean,
val interestCount: Int,
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class AddressViewModel
init {
getUserName()
getUserPhone()
getUserInfoFromServer()
}

private fun getUserName() {
Expand All @@ -54,6 +55,17 @@ class AddressViewModel
)
}

private fun getUserInfoFromServer() {
viewModelScope.launch {
settingRepository.getSettingInfo()
.onSuccess {
name.value = it.name
phone.value = it.phone
userRepository.setUserInfo(it.name, it.phone)
}
}
}

fun postToAddAddressToServer() {
viewModelScope.launch {
settingRepository.postToAddAddress(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@ class DetailActivity : BaseActivity<ActivityDetailBinding>(R.layout.activity_det

private fun observeLikeState() {
viewModel.likeState.flowWithLifecycle(lifecycle).distinctUntilChanged().onEach { isLiked ->
if (isLiked) {
binding.btnLike.setImageResource(R.drawable.ic_like_yellow)
} else {
binding.btnLike.setImageResource(R.drawable.ic_like_black_unselected)
with(binding) {
btnLike.isEnabled = isLiked
tvDetailLike.text = viewModel.interestCount.setOverThousand()
}
binding.tvDetailLike.text = viewModel.interestCount.setOverThousand()
}.launchIn(lifecycleScope)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DetailViewModel
infoUrl = it.infoUrl
interestCount = it.interestCount
optionList = it.optionList
_likeState.value = it.isInterested
_getProductDetailState.value = UiState.Success(it)
}
.onFailure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class HomeProductViewHolder(
}
tvHomeItemNowPrice.text = item.salePrice.setNumberForm()
tvHomeItemLike.text = item.interestCount.setOverThousand()
ivHomeItemLike.isEnabled = item.isInterested
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SearchItemViewHolder(
}
tvSearchItemNowPrice.text = item.salePrice.setNumberForm()
tvSearchItemLike.text = item.interestCount.setOverThousand()
ivSearchItemLike.isEnabled = item.isInterested

root.setOnSingleClickListener {
itemClick(item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ class DeliveryActivity : BaseActivity<ActivityDeliveryBinding>(R.layout.activity
if (state.data.addressId != null) {
btnDeliveryAdd.isVisible = false
layoutDeliveryItem.isVisible = true
tvDeliveryName.text = state.data.name
tvDeliveryName.text = state.data.recipient
tvDeliveryAddress.text =
getString(
R.string.address_format,
state.data.zipCode,
state.data.address,
state.data.detailAddress,
).breakLines()
tvDeliveryPhone.text = state.data.phone
tvDeliveryPhone.text = state.data.recipientPhone
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class HistoryViewHolder(
}
tvHomeItemNowPrice.text = item.salePrice.setNumberForm()
tvHomeItemLike.text = item.interestCount.setOverThousand()
btnItemLike.isEnabled = item.isInterested

root.setOnSingleClickListener {
itemClick(item)
Expand Down
5 changes: 5 additions & 0 deletions presentation/src/main/res/drawable/sel_item_like_yellow.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_like_yellow" android:state_enabled="true" />
<item android:drawable="@drawable/ic_like_black_unselected" android:state_enabled="false" />
</selector>
2 changes: 1 addition & 1 deletion presentation/src/main/res/layout/activity_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="@drawable/ic_like_black_unselected"
android:src="@drawable/sel_item_like_yellow"
app:layout_constraintBottom_toTopOf="@id/tv_detail_like"
app:layout_constraintEnd_toEndOf="@id/tv_detail_like"
app:layout_constraintStart_toStartOf="@id/tv_detail_like"
Expand Down
3 changes: 2 additions & 1 deletion presentation/src/main/res/layout/item_search_product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@
app:layout_constraintTop_toTopOf="@id/cv_search_item">

<ImageView
android:id="@+id/iv_search_item_like"
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:src="@drawable/ic_like_white_unselected" />
android:src="@drawable/sel_item_like_yellow" />

<TextView
android:id="@+id/tv_search_item_like"
Expand Down
Loading