From ce2e5ab25bb7f97b1200efd82127efdc14f9b740 Mon Sep 17 00:00:00 2001 From: Mendel <67176829+rhthrhrl0@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:21:18 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20#691=20=EA=B2=BD=EB=A7=A4=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=88=98=EC=A0=95(?= =?UTF-8?q?=EB=A7=88=EA=B0=90=EA=B8=B0=ED=95=9C=20=EC=8B=9C=EA=B0=84=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EB=B7=B0=20=EC=88=98=EC=A0=95=20=EB=B0=8F?= =?UTF-8?q?=20=EC=B5=9C=EA=B3=A0=20=EC=9E=85=EC=B0=B0=EC=9E=90=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C)=20(#699)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 높이 계산 로직 수정 * refactor: 마감 시간 스트링 생성 로직 수정 * feat: 최고입찰자인지 표시하는 기능 추가 * feat: 경매 상세 조회 api 응답 DTO 수정 * feat: getRemainingHeight 로직 개선 * refactor: 액션바 높이 상수화 * refactor: 액션바 상수 수정 * refactor: 탭 레이아웃 너비 수정 및 액션바 로직 수정 * refactor: CoordinatorLayout을 사용하도록 수정 * refactor: 경매 상세 페이지 ui 가로모드 대응 --- .../feature/detail/AuctionDetailActivity.kt | 25 -- .../detail/AuctionDetailBottomButtonStatus.kt | 12 +- .../feature/detail/AuctionDetailFormatter.kt | 5 +- .../feature/detail/AuctionDetailViewModel.kt | 3 +- .../android/model/AuctionDetailModel.kt | 1 + .../model/mapper/AuctionDetailModelMapper.kt | 1 + .../layout-land/activity_auction_detail.xml | 314 ++++++++++++++++++ .../res/layout/activity_auction_detail.xml | 242 ++++++++------ .../main/res/layout/fragment_auction_info.xml | 3 +- android/app/src/main/res/values/strings.xml | 1 + .../model/response/AuctionDetailResponse.kt | 1 + 11 files changed, 468 insertions(+), 140 deletions(-) create mode 100644 android/app/src/main/res/layout-land/activity_auction_detail.xml diff --git a/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailActivity.kt b/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailActivity.kt index 9ee7b2c40..033f47314 100644 --- a/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailActivity.kt +++ b/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailActivity.kt @@ -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 @@ -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 -> diff --git a/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailBottomButtonStatus.kt b/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailBottomButtonStatus.kt index 4922cb72f..3eeafb305 100644 --- a/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailBottomButtonStatus.kt +++ b/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailBottomButtonStatus.kt @@ -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 { @@ -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 } diff --git a/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailFormatter.kt b/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailFormatter.kt index 4a29086cc..cb9eff13c 100644 --- a/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailFormatter.kt +++ b/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailFormatter.kt @@ -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() } diff --git a/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailViewModel.kt b/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailViewModel.kt index dba80674e..c656beed9 100644 --- a/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailViewModel.kt +++ b/android/app/src/main/java/com/ddangddangddang/android/feature/detail/AuctionDetailViewModel.kt @@ -80,8 +80,9 @@ class AuctionDetailViewModel @Inject constructor( when (it) { AuctionDetailBottomButtonStatus.BidAuction -> popupAuctionBidEvent() AuctionDetailBottomButtonStatus.EnterAuctionChatRoom -> enterChatRoomEvent() - AuctionDetailBottomButtonStatus.FinishAuction -> {} + AuctionDetailBottomButtonStatus.AlreadyLastBidder -> {} AuctionDetailBottomButtonStatus.MyAuction -> {} + AuctionDetailBottomButtonStatus.FinishAuction -> {} } } } diff --git a/android/app/src/main/java/com/ddangddangddang/android/model/AuctionDetailModel.kt b/android/app/src/main/java/com/ddangddangddang/android/model/AuctionDetailModel.kt index b81b95378..bc7ba7876 100644 --- a/android/app/src/main/java/com/ddangddangddang/android/model/AuctionDetailModel.kt +++ b/android/app/src/main/java/com/ddangddangddang/android/model/AuctionDetailModel.kt @@ -20,4 +20,5 @@ data class AuctionDetailModel( val sellerModel: SellerModel, val chatAuctionDetailModel: ChatAuctionDetailModel, val isOwner: Boolean, + val isLastBidder: Boolean, ) diff --git a/android/app/src/main/java/com/ddangddangddang/android/model/mapper/AuctionDetailModelMapper.kt b/android/app/src/main/java/com/ddangddangddang/android/model/mapper/AuctionDetailModelMapper.kt index 86867f38d..d84fc8075 100644 --- a/android/app/src/main/java/com/ddangddangddang/android/model/mapper/AuctionDetailModelMapper.kt +++ b/android/app/src/main/java/com/ddangddangddang/android/model/mapper/AuctionDetailModelMapper.kt @@ -34,6 +34,7 @@ object AuctionDetailModelMapper : Mapper + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +