-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
123 additions
and
3 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
presentation/src/main/java/co/orange/presentation/sell/progress/SellDateBottomSheet.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
presentation/src/main/res/layout/bottom_sheet_sell_date.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters