Skip to content

Commit

Permalink
feat: #691 경매 상세 페이지 수정(마감기한 시간 정보 뷰 수정 및 최고 입찰자 표시) (#699)
Browse files Browse the repository at this point in the history
* refactor: 높이 계산 로직 수정

* refactor: 마감 시간 스트링 생성 로직 수정

* feat: 최고입찰자인지 표시하는 기능 추가

* feat: 경매 상세 조회 api 응답 DTO 수정

* feat: getRemainingHeight 로직 개선

* refactor: 액션바 높이 상수화

* refactor: 액션바 상수 수정

* refactor: 탭 레이아웃 너비 수정 및 액션바 로직 수정

* refactor: CoordinatorLayout을 사용하도록 수정

* refactor: 경매 상세 페이지 ui 가로모드 대응
  • Loading branch information
rhthrhrl0 authored Oct 17, 2023
1 parent 2b07087 commit ce2e5ab
Show file tree
Hide file tree
Showing 11 changed files with 468 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.ddangddangddang.android.feature.detail
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import androidx.viewpager2.widget.ViewPager2
import com.ddangddangddang.android.R
Expand Down Expand Up @@ -33,33 +32,9 @@ class AuctionDetailActivity :
binding.viewModel = viewModel
setupDetailView()
setupViewModel()
setDynamicHeight(binding.vpDetailInfo, this)
if (savedInstanceState == null) viewModel.loadAuctionDetail(auctionId)
}

// 액션바 높이를 반환하는 함수
private fun getActionBarHeight(context: Context): Int {
val styledAttributes =
context.theme.obtainStyledAttributes(intArrayOf(android.R.attr.actionBarSize))
val actionBarHeight = styledAttributes.getDimension(0, 0f).toInt()
styledAttributes.recycle()
return actionBarHeight
}

// 스크린 높이에서 액션바 높이를 뺀 높이를 계산하는 함수
private fun getRemainingHeight(context: Context): Int {
val screenHeight = context.resources.displayMetrics.heightPixels
val actionBarHeight = getActionBarHeight(context)
return screenHeight - actionBarHeight * 2
}

// 뷰의 높이를 동적으로 설정하는 함수
private fun setDynamicHeight(view: View, context: Context) {
val params = view.layoutParams
params.height = getRemainingHeight(context)
view.layoutParams = params
}

private fun setupDetailView() {
binding.vpDetailInfo.adapter = DetailFragmentAdapter(supportFragmentManager, lifecycle)
TabLayoutMediator(binding.tbDetailInfo, binding.vpDetailInfo) { tab, position ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ enum class AuctionDetailBottomButtonStatus(
EnterAuctionChatRoom(R.string.detail_auction_chat_room_entrance, true),

MyAuction(R.string.detail_auction_my_auction, false),

AlreadyLastBidder(R.string.detail_auction_already_last_bidder, false),
;

companion object {
Expand All @@ -26,10 +28,18 @@ enum class AuctionDetailBottomButtonStatus(
val isOwner = auctionDetailModel.isOwner
val auctionStatus = auctionDetailModel.auctionDetailStatusModel
val chatStatus = auctionDetailModel.chatAuctionDetailModel
val isLastBidder = auctionDetailModel.isLastBidder

return when {
canEnterMessageRoom(chatStatus) -> EnterAuctionChatRoom
canBidAuction(auctionStatus, isOwner) -> BidAuction
canBidAuction(auctionStatus, isOwner) -> {
if (isLastBidder) {
AlreadyLastBidder
} else {
BidAuction
}
}

isOwner -> MyAuction
else -> FinishAuction
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ object AuctionDetailFormatter {
val minutes = (differenceInMills / (60 * 1000L)) % 60

return buildString {
if (days > 0L) append("${days}")
if (hours > 0L) append(" ${hours}시간")
if (minutes > 0L) append(" ${minutes}")
if (days > 0L) append("${days}")
append(" ${String.format("%02d:%02d", hours, minutes)}")
}.trim()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ class AuctionDetailViewModel @Inject constructor(
when (it) {
AuctionDetailBottomButtonStatus.BidAuction -> popupAuctionBidEvent()
AuctionDetailBottomButtonStatus.EnterAuctionChatRoom -> enterChatRoomEvent()
AuctionDetailBottomButtonStatus.FinishAuction -> {}
AuctionDetailBottomButtonStatus.AlreadyLastBidder -> {}
AuctionDetailBottomButtonStatus.MyAuction -> {}
AuctionDetailBottomButtonStatus.FinishAuction -> {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ data class AuctionDetailModel(
val sellerModel: SellerModel,
val chatAuctionDetailModel: ChatAuctionDetailModel,
val isOwner: Boolean,
val isLastBidder: Boolean,
)
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ object AuctionDetailModelMapper : Mapper<AuctionDetailModel, AuctionDetailRespon
SellerModel(seller.id, seller.image ?: "", seller.nickname, seller.reliability),
ChatAuctionDetailModel(chat.id, chat.isChatParticipant),
isOwner,
isLastBidder,
)
}
}
314 changes: 314 additions & 0 deletions android/app/src/main/res/layout-land/activity_auction_detail.xml

Large diffs are not rendered by default.

Loading

0 comments on commit ce2e5ab

Please sign in to comment.