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,6 +3,7 @@ package com.ddangddangddang.android.feature.detail
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.TypedValue
import android.view.View
import androidx.activity.viewModels
import androidx.viewpager2.widget.ViewPager2
Expand All @@ -18,6 +19,7 @@ import com.ddangddangddang.android.notification.NotificationType
import com.ddangddangddang.android.notification.cancelActiveNotification
import com.ddangddangddang.android.util.binding.BindingActivity
import com.ddangddangddang.android.util.view.Toaster
import com.ddangddangddang.android.util.view.convertDpToPx
import com.ddangddangddang.android.util.view.observeLoadingWithDialog
import com.ddangddangddang.android.util.view.showDialog
import com.google.android.material.tabs.TabLayoutMediator
Expand All @@ -40,18 +42,18 @@ class AuctionDetailActivity :

// 액션바 높이를 반환하는 함수
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
val typedValue = TypedValue()
context.theme.resolveAttribute(androidx.appcompat.R.attr.actionBarSize, typedValue, true)
return TypedValue.complexToDimensionPixelSize(typedValue.data, resources.displayMetrics)
}

// 스크린 높이에서 액션바 높이를 뺀 높이를 계산하는 함수
private fun getRemainingHeight(context: Context): Int {
val screenHeight = context.resources.displayMetrics.heightPixels
val statusBarHeight = convertDpToPx(STATUS_BAR_HEIGHT) // 탭 레이아웃의 톱 마진과도 같은 값임.
val actionBarHeight = getActionBarHeight(context)
return screenHeight - actionBarHeight * 2
val tabLayoutHeight = resources.getDimensionPixelOffset(R.dimen.height_submit_button)
val bottomButtonHeight = resources.getDimensionPixelOffset(R.dimen.height_submit_button)
return screenHeight - statusBarHeight - actionBarHeight - tabLayoutHeight - bottomButtonHeight
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private fun getRemainingHeight(context: Context): Int {
    val screenHeight = convertDpToPx(resources.configuration.screenHeightDp.toFloat())
    val actionBarHeight = getActionBarHeight(context)
    val tabLayoutHeight = resources.getDimensionPixelOffset(R.dimen.height_submit_button)
    val bottomButtonHeight = resources.getDimensionPixelOffset(R.dimen.height_submit_button)
    return screenHeight - actionBarHeight - tabLayoutHeight - bottomButtonHeight 
}
  • resources.configuration.screenHeightDp 를 사용하면 화면 orientation, cutout 사이즈를 고려하지 않아도 될 것 같아요!
  • screenHeightDp

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

찾아주셔서 감사합니다! 테스트 중에 픽셀2 api33 버전에서 상태바가 같이 나오고 있는 것 같아서 확인이 필요할 것 같아요!


// 뷰의 높이를 동적으로 설정하는 함수
Expand Down Expand Up @@ -184,6 +186,7 @@ class AuctionDetailActivity :

companion object {
private const val AUCTION_ID_KEY = "auction_id_key"
private const val STATUS_BAR_HEIGHT = 24f

fun getIntent(context: Context, auctionId: Long): Intent {
return Intent(context, AuctionDetailActivity::class.java).apply {
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,
)
}
}
13 changes: 9 additions & 4 deletions android/app/src/main/res/layout/activity_auction_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/height_submit_button">

<androidx.appcompat.widget.Toolbar
android:id="@+id/tb_detail_auction"
Expand Down Expand Up @@ -260,13 +261,16 @@
<com.google.android.material.tabs.TabLayout
android:id="@+id/tb_detail_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_height="48dp"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dimen/height_submit_button 으로 하는게 좋을 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그걸 사용할까 하다가 안했던 이유는, 버튼이 아니라 탭 레이아웃에 대한 높이인데 이걸 적용하면, 나중에 리팩토링하다가 예기치 못하게 같이 바뀔 수 있을 것 같아요.

android:layout_marginTop="24dp"
android:backgroundTint="@color/grey_50"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_auctioneer_count"
app:tabIndicatorFullWidth="true" />
app:tabGravity="fill"
app:tabIndicatorFullWidth="true"
app:tabMaxWidth="0dp"
app:tabMode="fixed" />

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/vp_detail_info"
Expand All @@ -282,7 +286,7 @@
android:id="@+id/btn_auction_detail_bottom_button"
style="@style/BigButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="@dimen/height_submit_button"
android:layout_gravity="bottom"
android:layout_marginHorizontal="@dimen/margin_side_layout"
android:enabled="@{viewModel.auctionDetailBottomButtonStatus.enabled}"
Expand All @@ -292,6 +296,7 @@
android:padding="0dp"
android:text="@{AuctionDetailFormatter.INSTANCE.getAuctionBottomButtonText(context,viewModel.auctionDetailBottomButtonStatus)}"
android:textColor="@color/text_active_fixed"
android:textSize="18dp"
tools:text="입찰하기" />
</FrameLayout>
</layout>
3 changes: 2 additions & 1 deletion android/app/src/main/res/layout/fragment_auction_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@
<TextView
android:id="@+id/tv_seller_nickname"
style="@style/Body"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@{activityViewModel.auctionDetailModel.sellerModel.nickname}"
app:layout_constraintBottom_toTopOf="@id/iv_reliability_icon"
app:layout_constraintEnd_toStartOf="@id/gl_end"
app:layout_constraintStart_toEndOf="@id/cv_profile"
app:layout_constraintTop_toTopOf="@id/cv_profile"
app:layout_constraintVertical_chainStyle="packed"
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<string name="detail_auction_chat_room_create">쪽지방 생성</string>
<string name="detail_auction_chat_room_entrance">쪽지방 입장</string>
<string name="detail_auction_my_auction">내꺼 입찰금지</string>
<string name="detail_auction_already_last_bidder">현재까지 최고입찰자</string>
<string name="detail_auction_category">%s > %s</string>
<string name="detail_auction_price_status">%s %,d원</string>
<string name="detail_auction_start_price">시작가 %,d원</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ data class AuctionDetailResponse(
val seller: SellerResponse,
val chat: ChatAuctionDetailResponse,
val isOwner: Boolean,
val isLastBidder: Boolean,
)