Skip to content

Commit

Permalink
[MERGE] #34 -> develop
Browse files Browse the repository at this point in the history
[FEAT/#34] 판매뷰 / 데이트피커 구현
  • Loading branch information
Marchbreeze authored Sep 1, 2024
2 parents c17131f + 61f5151 commit dea1292
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package co.orange.presentation.sell.progress

import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import co.orange.core.base.BaseBottomSheet
import co.orange.core.extension.setOnSingleClickListener
import kr.genti.presentation.R
import kr.genti.presentation.databinding.BottomSheetSellDateBinding
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.Locale

class SellDateBottomSheet :
BaseBottomSheet<BottomSheetSellDateBinding>(R.layout.bottom_sheet_sell_date) {
private val viewModel by activityViewModels<SellProgressViewModel>()

override fun onStart() {
super.onStart()
dialog?.window?.setBackgroundDrawableResource(R.color.transparent)
}

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)

initSubmitBtnListener()
setDatePicker()
}

private fun initSubmitBtnListener() {
binding.btnSubmit.setOnSingleClickListener {
viewModel.sellDate = getDateFromDatePicker()
dismiss()
}
}

private fun getDateFromDatePicker(): String =
with(binding.dpSell) {
SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(
Calendar.getInstance().apply {
set(year, month, dayOfMonth)
}.time,
)
}

private fun setDatePicker() {
binding.dpSell.apply {
val calendar = Calendar.getInstance()
calendar.add(Calendar.DAY_OF_YEAR, -7)
minDate = calendar.timeInMillis
calendar.add(Calendar.DAY_OF_YEAR, 14)
maxDate = calendar.timeInMillis
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SellProgressViewModel
var productId = ""
var isAccountExist = false

var sellDate = ""

private val _getProductState = MutableStateFlow<UiState<SellProductModel>>(UiState.Empty)
val getProductState: StateFlow<UiState<SellProductModel>> = _getProductState

Expand Down
6 changes: 3 additions & 3 deletions presentation/src/main/res/layout/activity_sell_progress.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,18 +185,18 @@

<TextView
android:id="@+id/tv_sell_date"
style="@style/TextAppearance.DDanzi.Body1"
style="@style/TextAppearance.DDanzi.Body3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/shape_gray3_line_5_rect"
android:gravity="center"
android:paddingVertical="8dp"
android:text="@string/confirm_tv_date_hint"
android:textColor="@color/gray_4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_sell_date_subtitle"
tools:text="2024.06.24" />
app:layout_constraintTop_toBottomOf="@id/tv_sell_date_subtitle" />

<View
android:id="@+id/border_sell_date"
Expand Down
59 changes: 59 additions & 0 deletions presentation/src/main/res/layout/bottom_sheet_sell_date.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_white_fill_top20_rect"
android:paddingBottom="30dp">

<View
android:id="@+id/iv_handler"
android:layout_width="82dp"
android:layout_height="4dp"
android:layout_marginTop="8dp"
android:background="@drawable/shape_gray4_fill_100_rect"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<DatePicker
android:id="@+id/dp_sell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:calendarTextColor="@color/gray_4"
android:calendarViewShown="false"
android:datePickerMode="spinner"
android:headerDayOfMonthTextAppearance="@style/TextAppearance.DDanzi.Body3"
android:headerMonthTextAppearance="@style/TextAppearance.DDanzi.Body3"
android:headerYearTextAppearance="@style/TextAppearance.DDanzi.Body3"
android:spinnersShown="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/btn_submit"
style="@style/TextAppearance.DDanzi.Body3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="30dp"
android:background="@drawable/shape_black_fill_10_rect"
android:gravity="center"
android:paddingVertical="16dp"
android:text="@string/okay"
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/dp_sell" />

</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

1 change: 1 addition & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<string name="confirm_tv_price">판매 가격</string>
<string name="confirm_tv_sell_date">받은 날짜</string>
<string name="confirm_tv_sell_date_subtitle">배송지 입력 기간 이내의 상품만 등록 가능합니다.</string>
<string name="confirm_tv_date_hint">클릭해서 날짜를 선택하세요</string>

<string name="sell_product_tv_subtitle">해당 상품이 맞나요?</string>
<string name="sell_product_btn_submit">네 맞아요</string>
Expand Down

0 comments on commit dea1292

Please sign in to comment.