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

경매 상세 페이지 수정(마감기한 시간 정보 뷰 수정 및 최고 입찰자 표시) #699

Merged
merged 10 commits into from
Oct 17, 2023
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 @@ -34,33 +33,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