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

[FEAT/#230] 여행 조회, 여행 수정, 여행 나가기 뷰 / 서버통신 구현 #241

Merged
merged 23 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
728690a
[FEAT/#230] 모듈 수정
crownjoe Mar 5, 2024
c794a44
[FEAT/#230] datasource 구현
crownjoe Mar 5, 2024
cf00a9b
[FEAT/#230] repository 구현
crownjoe Mar 5, 2024
1062ce9
[FEAT/#230] Dto, Model 구현
crownjoe Mar 5, 2024
f35e81d
[FEAT/#230] 여행 수정 초기 뷰, 여행 수정 뷰 ui 수정
crownjoe Mar 5, 2024
f237268
[FEAT/#230] 충돌 수정
crownjoe Mar 6, 2024
83962dc
[FEAT/#230] 머지 후 충돌 수정
crownjoe Mar 6, 2024
aa464bd
[FEAT/#230] 여행 디테일 조회 뷰 Model 구현
crownjoe Mar 7, 2024
4de23c3
[FEAT/#230] 여행 디테일 조회 뷰 DataSource 구
crownjoe Mar 7, 2024
1ae947b
[FEAT/#230] 여행 디테일 조회 뷰 Repository 구현
crownjoe Mar 7, 2024
ce5548a
[FEAT/#230] 여행 디테일 조회 뷰 서버통신 구현
crownjoe Mar 7, 2024
32a5776
[FEAT/#230] 여행 디테일 조회 뷰 서버통신 구현
crownjoe Mar 7, 2024
e40579a
[FEAT/#230] 여행 디테일 조회 뷰 서버통신 구현
crownjoe Mar 7, 2024
1adaa2f
[FEAT/#230] 여행 수정 뷰 서버통신 구현
crownjoe Mar 7, 2024
255a142
[FEAT/#230] 컨플릭 해결
crownjoe Mar 7, 2024
c7ae49c
[FEAT/#230] 여행 수정 뷰 서버통신 구현
crownjoe Mar 9, 2024
257cd3f
[FEAT/#230] 여행 수정 뷰 서버통신 로직 구현
crownjoe Mar 9, 2024
15fe072
[FEAT/#230] 여행 수정 뷰 로직 수정
crownjoe Mar 9, 2024
f0b6e81
[FEAT/#230] 여행 나가기 뷰 서버통신 구현
crownjoe Mar 9, 2024
e8e0314
[FEAT/#230] 컨플릭 해결
crownjoe Mar 9, 2024
b24abe3
[FEAT/#230] 오류 수정
crownjoe Mar 9, 2024
460c2b9
[CHORE/#230] 코리 반영 수정
crownjoe Mar 10, 2024
08862e3
[CHORE/#230] 컨플릭 해결
crownjoe Mar 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class QuitTripDialogFragment :
private fun initNegativeClickListener() {
binding.tvDialogNegative.setOnSingleClickListener {
viewModel.patchQuitTripFromServer()
val intent = Intent(requireActivity(), DashBoardActivity::class.java)
startActivity(intent)
Intent(requireActivity(), DashBoardActivity::class.java).apply {
requireActivity().startActivity(this)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ class EditDateBottomSheet(val isStart: Boolean) :
val calendar = Calendar.getInstance()
val datePicker = binding.dpEditTripDate.apply {
updateDate(
viewModel.currentStartYear.value ?: calendar.get(Calendar.YEAR),
(viewModel.currentStartMonth.value ?: calendar.get(Calendar.MONTH)) - 1,
viewModel.currentStartDay.value ?: calendar.get(Calendar.DAY_OF_MONTH)
viewModel.currentStartYear ?: calendar.get(Calendar.YEAR),
(viewModel.currentStartMonth ?: calendar.get(Calendar.MONTH)) - 1,
viewModel.currentStartDay ?: calendar.get(Calendar.DAY_OF_MONTH)
)
}
if (viewModel.endYear.value != viewModel.currentEndYear.value || viewModel.endMonth.value != viewModel.currentEndMonth.value || viewModel.endDay.value != viewModel.currentEndDay.value) {
if (viewModel.endYear != viewModel.currentEndYear || viewModel.endMonth != viewModel.currentEndMonth || viewModel.endDay != viewModel.currentEndDay) {
calendar.set(
viewModel.endYear.value ?: 0,
(viewModel.endMonth.value ?: 0) - 1,
viewModel.endDay.value ?: 0
viewModel.endYear ?: 0,
(viewModel.endMonth ?: 0) - 1,
viewModel.endDay ?: 0
)
datePicker.maxDate = calendar.timeInMillis
} else {
Expand All @@ -52,16 +52,16 @@ class EditDateBottomSheet(val isStart: Boolean) :
val calendar = Calendar.getInstance()
Copy link
Member

Choose a reason for hiding this comment

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

영상보니깐 바텀시트 값들이 2024 / 3 / 10 이 아니라 다른 형식이던데, 수정된 이유가 있었을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

바텀시트에 뜨는 날짜 말씀하시는 거라면 영어로 뜨는 이유는 아마두 애뮬이 영어로 되어 있어서 그런 것 같숩니다.. 실기기에서는 원래 바텀시트 데이트피커 나오는 것(2024 3 10) 처럼 나옵니다!!

val datePicker = binding.dpEditTripDate.apply {
updateDate(
viewModel.currentEndYear.value ?: calendar.get(Calendar.YEAR),
(viewModel.currentEndMonth.value ?: calendar.get(Calendar.MONTH)) - 1,
viewModel.currentEndDay.value ?: calendar.get(Calendar.DAY_OF_MONTH)
viewModel.currentEndYear ?: calendar.get(Calendar.YEAR),
(viewModel.currentEndMonth ?: calendar.get(Calendar.MONTH)) - 1,
viewModel.currentEndDay ?: calendar.get(Calendar.DAY_OF_MONTH)
)
}
if (viewModel.startYear.value != viewModel.currentStartYear.value || viewModel.startMonth.value != viewModel.currentStartMonth.value || viewModel.startDay.value != viewModel.currentStartDay.value) {
if (viewModel.startYear != viewModel.currentStartYear || viewModel.startMonth != viewModel.currentStartMonth || viewModel.startDay != viewModel.currentStartDay) {
calendar.set(
viewModel.startYear.value ?: 0,
(viewModel.startMonth.value ?: 0) - 1,
viewModel.startDay.value ?: 0
viewModel.startYear ?: 0,
(viewModel.startMonth ?: 0) - 1,
viewModel.startDay ?: 0
)
datePicker.minDate = calendar.timeInMillis
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,8 @@ class EditTripInfoActivity :
viewModel.currentEndDate = intent.getStringExtra(END_DATE) ?: ""

binding.etEditTripInfoName.editText.setText(viewModel.currentTitle)

val (startYear, startMonth, startDay) = splitDate(viewModel.currentStartDate)
viewModel.currentStartYear.value = startYear
viewModel.currentStartMonth.value = startMonth
viewModel.currentStartDay.value = startDay
viewModel.setStartDate(startYear, startMonth, startDay)

val (endYear, endMonth, endDay) = splitDate(viewModel.currentEndDate)
viewModel.currentEndYear.value = endYear
viewModel.currentEndMonth.value = endMonth
viewModel.currentEndDay.value = endDay
viewModel.setEndDate(endYear, endMonth, endDay)
}

fun splitDate(date: String): Triple<Int, Int, Int> {
val parts = date.split(".")
val year = parts[0].toInt()
val month = parts[1].toInt()
val day = parts[2].toInt()
return Triple(year, month, day)
viewModel.splitStartDate()
viewModel.splitEndDate()
Comment on lines +54 to +55
Copy link
Member

Choose a reason for hiding this comment

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

깔꼼쓰 ~~~~~

}

private fun observePatchEditState() {
Expand Down Expand Up @@ -125,8 +107,9 @@ class EditTripInfoActivity :
private fun initEditBtnClickListener() {
binding.btnEditTripSave.setOnSingleClickListener {
viewModel.patchTripInfoFromServer()
val intent = Intent(this, DashBoardActivity::class.java)
startActivity(intent)
Intent(this, DashBoardActivity::class.java).apply {
startActivity(this)
}
}
}

Expand All @@ -137,10 +120,10 @@ class EditTripInfoActivity :
}

companion object {
const val TRIP_ID = "TRIP_ID"
const val TITLE = "TITLE"
const val START_DATE = "START_DATE"
const val END_DATE = "END_DATE"
private const val TRIP_ID = "TRIP_ID"
private const val TITLE = "TITLE"
private const val START_DATE = "START_DATE"
private const val END_DATE = "END_DATE"

@JvmStatic
fun createIntent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ class EditTripInfoViewModel @Inject constructor(
var currentStartDate: String = ""
var currentEndDate: String = ""

val title = MutableLiveData<String>()

var currentStartYear = MutableLiveData<Int>()
var currentStartMonth = MutableLiveData<Int>()
var currentStartDay = MutableLiveData<Int>()
var currentEndYear = MutableLiveData<Int>()
var currentEndMonth = MutableLiveData<Int>()
var currentEndDay = MutableLiveData<Int>()

val startYear = MutableLiveData<Int>()
val startMonth = MutableLiveData<Int>()
val startDay = MutableLiveData<Int>()
var title: String? = null

var currentStartYear: Int? = null
var currentStartMonth: Int? = null
var currentStartDay: Int? = null
var currentEndYear: Int? = null
var currentEndMonth: Int? = null
var currentEndDay: Int? = null

var startYear: Int? = null
var startMonth: Int? = null
var startDay: Int? = null
var startDate = MutableLiveData<String>()

val endYear = MutableLiveData<Int>()
val endMonth = MutableLiveData<Int>()
val endDay = MutableLiveData<Int>()
var endYear: Int? = null
var endMonth: Int? = null
var endDay: Int? = null
var endDate = MutableLiveData<String>()

val isStartDateAvailable = MutableLiveData(false)
Expand All @@ -59,7 +59,7 @@ class EditTripInfoViewModel @Inject constructor(
editTripRepository.patchEditTripInfo(
tripId,
EditTripRequestModel(
title = title.value.orEmpty(),
title = title.orEmpty(),
startDate = startDate.value.orEmpty(),
endDate = endDate.value.orEmpty()
)
Expand All @@ -73,31 +73,61 @@ class EditTripInfoViewModel @Inject constructor(
}
}

fun splitStartDate() {
val (startYear, startMonth, startDay) = splitDate(currentStartDate)
currentStartYear = startYear
currentStartMonth = startMonth
currentStartDay = startDay
setStartDate(startYear, startMonth, startDay)

val (endYear, endMonth, endDay) = splitDate(currentEndDate)
currentEndYear = endYear
currentEndMonth = endMonth
currentEndDay = endDay
setEndDate(endYear, endMonth, endDay)
}

fun splitEndDate() {
val (endYear, endMonth, endDay) = splitDate(currentEndDate)
currentEndYear = endYear
currentEndMonth = endMonth
currentEndDay = endDay
setEndDate(endYear, endMonth, endDay)
}

fun splitDate(date: String): Triple<Int, Int, Int> {
val parts = date.split(".")
val year = parts[0].toInt()
val month = parts[1].toInt()
val day = parts[2].toInt()
return Triple(year, month, day)
}

fun setTitleState(newTitle: String, state: EditTextState) {
title.value = newTitle
title = newTitle
isTitleAvailable.value = state == EditTextState.SUCCESS
checkTripAvailable()
}

fun setStartDate(year: Int, month: Int, day: Int) {
startYear.value = year
startMonth.value = month
startDay.value = day
startYear = year
startMonth = month
startDay = day
checkStartDateAvailable()
startDate.value = String.format("%04d.%02d.%02d", year, month, day)
}


fun setEndDate(year: Int, month: Int, day: Int) {
endYear.value = year
endMonth.value = month
endDay.value = day
endYear = year
endMonth = month
endDay = day
checkEndDateAvailable()
endDate.value = String.format("%04d.%02d.%02d", year, month, day)
}

fun checkStartDateAvailable() {
if (startYear.value != null && startMonth.value != null && startDay.value != null) {
if (startYear != null && startMonth != null && startDay != null) {
isStartDateAvailable.value = true
checkTripAvailable()
} else {
Expand All @@ -106,7 +136,7 @@ class EditTripInfoViewModel @Inject constructor(
}

fun checkEndDateAvailable() {
if (endYear.value != null && endMonth.value != null && endDay.value != null) {
if (endYear != null && endMonth != null && endDay != null) {
isEndDateAvailable.value = true
checkTripAvailable()
} else {
Expand All @@ -115,8 +145,8 @@ class EditTripInfoViewModel @Inject constructor(
}

fun checkTripAvailable() {
isCheckTripAvailable.value = !title.value.isNullOrEmpty() && (
(title.value != null && currentTitle != title.value) ||
isCheckTripAvailable.value = !title.isNullOrEmpty() && (
(title != null && currentTitle != title) ||
currentStartDate != startDate.value ||
currentEndDate != endDate.value
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
app:canBlankError="true"
app:hint="@string/edit_trip_info_et_name_hint"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tb_edit_trip_info"
app:title="@string/edit_trip_info_tv_title" />
Expand Down