diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index a130ded6..753b97e1 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -171,7 +171,12 @@
android:screenOrientation="portrait" />
+
+
diff --git a/app/src/main/java/com/going/doorip/di/DataSourceModule.kt b/app/src/main/java/com/going/doorip/di/DataSourceModule.kt
index d336e600..5a28cb28 100644
--- a/app/src/main/java/com/going/doorip/di/DataSourceModule.kt
+++ b/app/src/main/java/com/going/doorip/di/DataSourceModule.kt
@@ -2,6 +2,7 @@ package com.going.doorip.di
import com.going.data.datasource.AuthDataSource
import com.going.data.datasource.DashBoardDataSource
+import com.going.data.datasource.EditTripDataSource
import com.going.data.datasource.EnterTripDataSource
import com.going.data.datasource.ProfileDataSource
import com.going.data.datasource.SettingDataSource
@@ -10,6 +11,7 @@ import com.going.data.datasource.TodoDataSource
import com.going.data.datasource.TokenReissueDataSource
import com.going.data.datasourceImpl.AuthDataSourceImpl
import com.going.data.datasourceImpl.DashBoardDataSourceImpl
+import com.going.data.datasourceImpl.EditTripDataSourceImpl
import com.going.data.datasourceImpl.EnterTripDataSourceImpl
import com.going.data.datasourceImpl.ProfileDataSourceImpl
import com.going.data.datasourceImpl.SettingDataSourceImpl
@@ -65,4 +67,9 @@ object DataSourceModule {
@Singleton
fun provideTokenReissueDataSource(tokenReissueDataSourceImpl: TokenReissueDataSourceImpl): TokenReissueDataSource =
tokenReissueDataSourceImpl
+
+ @Provides
+ @Singleton
+ fun provideEditTripDataSource(editTripDataSourceImpl: EditTripDataSourceImpl): EditTripDataSource =
+ editTripDataSourceImpl
}
diff --git a/app/src/main/java/com/going/doorip/di/RepositoryModule.kt b/app/src/main/java/com/going/doorip/di/RepositoryModule.kt
index 4d7a671e..67542210 100644
--- a/app/src/main/java/com/going/doorip/di/RepositoryModule.kt
+++ b/app/src/main/java/com/going/doorip/di/RepositoryModule.kt
@@ -2,6 +2,7 @@ package com.going.doorip.di
import com.going.data.repositoryImpl.AuthRepositoryImpl
import com.going.data.repositoryImpl.DashBoardRepositoryImpl
+import com.going.data.repositoryImpl.EditTripRepositoryImpl
import com.going.data.repositoryImpl.EnterTripRepositoryImpl
import com.going.data.repositoryImpl.ProfileRepositoryImpl
import com.going.data.repositoryImpl.SettingRepositoryImpl
@@ -11,6 +12,7 @@ import com.going.data.repositoryImpl.TokenReissueRepositoryImpl
import com.going.data.repositoryImpl.TokenRepositoryImpl
import com.going.domain.repository.AuthRepository
import com.going.domain.repository.DashBoardRepository
+import com.going.domain.repository.EditTripRepository
import com.going.domain.repository.EnterTripRepository
import com.going.domain.repository.ProfileRepository
import com.going.domain.repository.SettingRepository
@@ -72,4 +74,9 @@ object RepositoryModule {
@Singleton
fun provideTokenReissueRepository(tokenReissueRepositoryImpl: TokenReissueRepositoryImpl): TokenReissueRepository =
tokenReissueRepositoryImpl
+
+ @Provides
+ @Singleton
+ fun provideEditTripRepository(editTripRepositoryImpl: EditTripRepositoryImpl): EditTripRepository =
+ editTripRepositoryImpl
}
diff --git a/app/src/main/java/com/going/doorip/di/ServiceModule.kt b/app/src/main/java/com/going/doorip/di/ServiceModule.kt
index 82056816..c0c8299e 100644
--- a/app/src/main/java/com/going/doorip/di/ServiceModule.kt
+++ b/app/src/main/java/com/going/doorip/di/ServiceModule.kt
@@ -2,6 +2,7 @@ package com.going.doorip.di
import com.going.data.service.AuthService
import com.going.data.service.DashBoardService
+import com.going.data.service.EditTripService
import com.going.data.service.EnterTripService
import com.going.data.service.ProfileService
import com.going.data.service.SettingService
@@ -60,4 +61,9 @@ object ServiceModule {
@Singleton
fun provideTokenReissueService(@REISSUE retrofit: Retrofit): TokenReissueService =
retrofit.create(TokenReissueService::class.java)
+
+ @Provides
+ @Singleton
+ fun provideEditTripService(@JWT retrofit: Retrofit): EditTripService =
+ retrofit.create(EditTripService::class.java)
}
diff --git a/data/src/main/java/com/going/data/datasource/EditTripDataSource.kt b/data/src/main/java/com/going/data/datasource/EditTripDataSource.kt
new file mode 100644
index 00000000..7e80a6b6
--- /dev/null
+++ b/data/src/main/java/com/going/data/datasource/EditTripDataSource.kt
@@ -0,0 +1,22 @@
+package com.going.data.datasource
+
+import com.going.data.dto.BaseResponse
+import com.going.data.dto.NonDataBaseResponse
+import com.going.data.dto.request.EditTripInfoRequestDto
+import com.going.data.dto.response.TripInfoResponseDto
+
+interface EditTripDataSource {
+ suspend fun getTripInfo(
+ tripId: Long
+ ): BaseResponse
+
+ suspend fun patchEditTripInfo(
+ tripId: Long,
+ request: EditTripInfoRequestDto
+ ): NonDataBaseResponse
+
+ suspend fun patchQuitTrip(
+ tripId: Long
+ ): NonDataBaseResponse
+
+}
\ No newline at end of file
diff --git a/data/src/main/java/com/going/data/datasourceImpl/EditTripDataSourceImpl.kt b/data/src/main/java/com/going/data/datasourceImpl/EditTripDataSourceImpl.kt
new file mode 100644
index 00000000..9bec20fe
--- /dev/null
+++ b/data/src/main/java/com/going/data/datasourceImpl/EditTripDataSourceImpl.kt
@@ -0,0 +1,32 @@
+package com.going.data.datasourceImpl
+
+import com.going.data.datasource.EditTripDataSource
+import com.going.data.dto.BaseResponse
+import com.going.data.dto.NonDataBaseResponse
+import com.going.data.dto.request.EditTripInfoRequestDto
+import com.going.data.dto.response.TripInfoResponseDto
+import com.going.data.service.EditTripService
+import javax.inject.Inject
+
+class EditTripDataSourceImpl @Inject constructor(
+ private val editTripService: EditTripService,
+) : EditTripDataSource {
+
+ override suspend fun getTripInfo(
+ tripId: Long
+ ): BaseResponse =
+ editTripService.getTripInfo(tripId)
+
+ override suspend fun patchEditTripInfo(
+ tripId: Long,
+ request: EditTripInfoRequestDto
+ ): NonDataBaseResponse = editTripService.patchEditTripInfo(
+ tripId, request
+ )
+
+ override suspend fun patchQuitTrip(
+ tripId: Long
+ ): NonDataBaseResponse = editTripService.patchQuitTrip(
+ tripId
+ )
+}
\ No newline at end of file
diff --git a/data/src/main/java/com/going/data/dto/request/EditTripInfoRequestDto.kt b/data/src/main/java/com/going/data/dto/request/EditTripInfoRequestDto.kt
new file mode 100644
index 00000000..ad89e96b
--- /dev/null
+++ b/data/src/main/java/com/going/data/dto/request/EditTripInfoRequestDto.kt
@@ -0,0 +1,19 @@
+package com.going.data.dto.request
+
+import com.going.domain.entity.request.EditTripRequestModel
+import kotlinx.serialization.SerialName
+import kotlinx.serialization.Serializable
+
+@Serializable
+class EditTripInfoRequestDto(
+ @SerialName("title")
+ val title: String,
+ @SerialName("startDate")
+ val startDate: String,
+ @SerialName("endDate")
+ val endDate: String,
+)
+
+fun EditTripRequestModel.toEditTrioRequestDto(): EditTripInfoRequestDto =
+ EditTripInfoRequestDto(title, startDate, endDate)
+
diff --git a/data/src/main/java/com/going/data/dto/response/TripInfoResponseDto.kt b/data/src/main/java/com/going/data/dto/response/TripInfoResponseDto.kt
new file mode 100644
index 00000000..f45d2f71
--- /dev/null
+++ b/data/src/main/java/com/going/data/dto/response/TripInfoResponseDto.kt
@@ -0,0 +1,20 @@
+package com.going.data.dto.response
+
+import com.going.domain.entity.response.TripInfoModel
+import kotlinx.serialization.SerialName
+import kotlinx.serialization.Serializable
+
+@Serializable
+data class TripInfoResponseDto(
+ @SerialName("tripId")
+ val tripId: Long,
+ @SerialName("title")
+ val title: String,
+ @SerialName("startDate")
+ val startDate: String,
+ @SerialName("endDate")
+ val endDate: String,
+) {
+ fun toTripInfoModel(): TripInfoModel
+ = TripInfoModel(tripId, title, startDate, endDate)
+}
diff --git a/data/src/main/java/com/going/data/repositoryImpl/EditTripRepositoryImpl.kt b/data/src/main/java/com/going/data/repositoryImpl/EditTripRepositoryImpl.kt
new file mode 100644
index 00000000..944fd63c
--- /dev/null
+++ b/data/src/main/java/com/going/data/repositoryImpl/EditTripRepositoryImpl.kt
@@ -0,0 +1,37 @@
+package com.going.data.repositoryImpl
+
+import com.going.data.datasource.EditTripDataSource
+import com.going.data.dto.request.toEditTrioRequestDto
+import com.going.domain.entity.request.EditTripRequestModel
+import com.going.domain.entity.response.TripInfoModel
+import com.going.domain.repository.EditTripRepository
+import javax.inject.Inject
+
+class EditTripRepositoryImpl @Inject constructor(
+ private val editTripDataSource: EditTripDataSource,
+) : EditTripRepository {
+ override suspend fun getTripInfo(
+ tripId: Long
+ ): Result =
+ runCatching {
+ editTripDataSource.getTripInfo(tripId).data.toTripInfoModel()
+ }
+
+ override suspend fun patchEditTripInfo(
+ tripId: Long, request: EditTripRequestModel
+ ): Result =
+ runCatching {
+ editTripDataSource.patchEditTripInfo(
+ tripId, request.toEditTrioRequestDto()
+ )
+ }
+
+ override suspend fun patchQuitTrip(
+ tripId: Long
+ ): Result =
+ runCatching {
+ editTripDataSource.patchQuitTrip(
+ tripId
+ )
+ }
+}
diff --git a/data/src/main/java/com/going/data/service/EditTripService.kt b/data/src/main/java/com/going/data/service/EditTripService.kt
new file mode 100644
index 00000000..61965143
--- /dev/null
+++ b/data/src/main/java/com/going/data/service/EditTripService.kt
@@ -0,0 +1,30 @@
+package com.going.data.service
+
+import com.going.data.dto.BaseResponse
+import com.going.data.dto.NonDataBaseResponse
+import com.going.data.dto.request.EditTripInfoRequestDto
+import com.going.data.dto.response.TripInfoResponseDto
+import retrofit2.http.Body
+import retrofit2.http.GET
+import retrofit2.http.PATCH
+import retrofit2.http.Path
+
+interface EditTripService {
+
+ @GET("api/trips/{tripId}")
+ suspend fun getTripInfo(
+ @Path("tripId") tripId: Long
+ ): BaseResponse
+
+ @PATCH("api/trips/{tripId}")
+ suspend fun patchEditTripInfo(
+ @Path("tripId") tripId: Long,
+ @Body request: EditTripInfoRequestDto,
+ ): NonDataBaseResponse
+
+ @PATCH("api/trips/{tripId}/leave")
+ suspend fun patchQuitTrip(
+ @Path("tripId") tripId: Long,
+ ): NonDataBaseResponse
+
+}
\ No newline at end of file
diff --git a/domain/src/main/kotlin/com/going/domain/entity/request/EditTripRequestModel.kt b/domain/src/main/kotlin/com/going/domain/entity/request/EditTripRequestModel.kt
new file mode 100644
index 00000000..f2615184
--- /dev/null
+++ b/domain/src/main/kotlin/com/going/domain/entity/request/EditTripRequestModel.kt
@@ -0,0 +1,7 @@
+package com.going.domain.entity.request
+
+data class EditTripRequestModel(
+ val title: String,
+ val startDate: String,
+ val endDate: String,
+)
diff --git a/domain/src/main/kotlin/com/going/domain/entity/request/TripInfoRequestModel.kt b/domain/src/main/kotlin/com/going/domain/entity/request/TripInfoRequestModel.kt
new file mode 100644
index 00000000..346a2f06
--- /dev/null
+++ b/domain/src/main/kotlin/com/going/domain/entity/request/TripInfoRequestModel.kt
@@ -0,0 +1,8 @@
+package com.going.domain.entity.request
+
+data class TripInfoRequestModel(
+ val tripId: Long,
+ val title: String,
+ val startDate : String,
+ val endDate : String,
+)
diff --git a/domain/src/main/kotlin/com/going/domain/entity/response/QuitTripModel.kt b/domain/src/main/kotlin/com/going/domain/entity/response/QuitTripModel.kt
new file mode 100644
index 00000000..e9231f6c
--- /dev/null
+++ b/domain/src/main/kotlin/com/going/domain/entity/response/QuitTripModel.kt
@@ -0,0 +1,5 @@
+package com.going.domain.entity.response
+
+data class QuitTripModel(
+ val tripId: Long,
+)
diff --git a/domain/src/main/kotlin/com/going/domain/entity/response/TripInfoModel.kt b/domain/src/main/kotlin/com/going/domain/entity/response/TripInfoModel.kt
new file mode 100644
index 00000000..5a1da384
--- /dev/null
+++ b/domain/src/main/kotlin/com/going/domain/entity/response/TripInfoModel.kt
@@ -0,0 +1,8 @@
+package com.going.domain.entity.response
+
+data class TripInfoModel(
+ val tripId: Long,
+ val title: String,
+ val startDate: String,
+ val endDate: String,
+)
diff --git a/domain/src/main/kotlin/com/going/domain/repository/EditTripRepository.kt b/domain/src/main/kotlin/com/going/domain/repository/EditTripRepository.kt
new file mode 100644
index 00000000..57cf023f
--- /dev/null
+++ b/domain/src/main/kotlin/com/going/domain/repository/EditTripRepository.kt
@@ -0,0 +1,18 @@
+package com.going.domain.repository
+
+import com.going.domain.entity.request.EditTripRequestModel
+import com.going.domain.entity.response.TripInfoModel
+
+interface EditTripRepository {
+
+ suspend fun getTripInfo(
+ tripId: Long
+ ): Result
+ suspend fun patchEditTripInfo(
+ tripId: Long,
+ request: EditTripRequestModel
+ ): Result
+ suspend fun patchQuitTrip(
+ tripId: Long
+ ): Result
+}
\ No newline at end of file
diff --git a/presentation/src/main/java/com/going/presentation/entertrip/invitetrip/finish/InviteFinishActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/invitetrip/finish/InviteFinishActivity.kt
index ac2c1a69..6a7f1f53 100644
--- a/presentation/src/main/java/com/going/presentation/entertrip/invitetrip/finish/InviteFinishActivity.kt
+++ b/presentation/src/main/java/com/going/presentation/entertrip/invitetrip/finish/InviteFinishActivity.kt
@@ -80,7 +80,7 @@ class InviteFinishActivity :
startDate: String,
endDate: String,
day: Int,
- ): Intent = Intent(context, EnterTripActivity::class.java).apply {
+ ): Intent = Intent(context, InviteFinishActivity::class.java).apply {
putExtra(TRIP_ID, tripId)
putExtra(TITLE, title)
putExtra(START, startDate)
diff --git a/presentation/src/main/java/com/going/presentation/todo/change/TodoChangeActivity.kt b/presentation/src/main/java/com/going/presentation/todo/change/TodoChangeActivity.kt
index 644f43f9..85c68f07 100644
--- a/presentation/src/main/java/com/going/presentation/todo/change/TodoChangeActivity.kt
+++ b/presentation/src/main/java/com/going/presentation/todo/change/TodoChangeActivity.kt
@@ -5,7 +5,6 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
-import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import androidx.core.view.isVisible
import androidx.core.widget.doAfterTextChanged
@@ -15,7 +14,6 @@ import com.going.presentation.R
import com.going.presentation.databinding.ActivityTodoChangeBinding
import com.going.presentation.todo.create.TodoCreateActivity.Companion.MAX_MEMO_LEN
import com.going.presentation.todo.create.TodoCreateActivity.Companion.MAX_TODO_LEN
-import com.going.presentation.todo.detail.TodoDetailActivity
import com.going.ui.base.BaseActivity
import com.going.ui.extension.setOnSingleClickListener
import com.going.ui.extension.toast
diff --git a/presentation/src/main/java/com/going/presentation/todo/editinfo/EditTripInfoActivity.kt b/presentation/src/main/java/com/going/presentation/todo/editinfo/EditTripInfoActivity.kt
deleted file mode 100644
index 136b94a0..00000000
--- a/presentation/src/main/java/com/going/presentation/todo/editinfo/EditTripInfoActivity.kt
+++ /dev/null
@@ -1,124 +0,0 @@
-package com.going.presentation.todo.editinfo
-
-import android.content.Intent
-import android.os.Bundle
-import androidx.activity.viewModels
-import androidx.core.widget.doAfterTextChanged
-import com.going.presentation.R
-import com.going.presentation.dashboard.DashBoardActivity
-import com.going.presentation.databinding.ActivityEditTripInfoBinding
-import com.going.ui.base.BaseActivity
-import com.going.ui.extension.setOnSingleClickListener
-import com.going.ui.extension.toast
-
-class EditTripInfoActivity :
- BaseActivity(R.layout.activity_edit_trip_info) {
- private val viewModel by viewModels()
-
- private var startBottomSheetDialog: EditDateBottomSheet? = null
- private var endBottomSheetDialog: EditDateBottomSheet? = null
- private var quitDialog: TripQuitDialogFragment? = null
-
- override fun onCreate(savedInstanceState: Bundle?) {
- super.onCreate(savedInstanceState)
-
- initBindingViewModel()
- setEtInfoNameArguments()
- observeInfoNameTextChanged()
- initStartDateClickListener()
- initEndDateClickListener()
- initEditBtnClickListener()
- initQuitBtnClickListener()
- initBackBtnClickListener()
- }
-
- private fun initBindingViewModel() {
- binding.viewModel = viewModel
- }
-
- private fun setEtInfoNameArguments() {
- with(binding.etEditTripInfoName) {
- setMaxLen(viewModel.getMaxTripLen())
- overWarning = getString(R.string.trip_over_error)
- blankWarning = getString(R.string.trip_blank_error)
- }
- }
-
- private fun observeInfoNameTextChanged() {
- binding.etEditTripInfoName.editText.doAfterTextChanged { text ->
- viewModel.setNameState(text.toString(), binding.etEditTripInfoName.state)
- }
- }
-
-
- private fun initStartDateClickListener() {
- binding.tvEditTripInfoStartDate.setOnSingleClickListener {
- startBottomSheetDialog = EditDateBottomSheet(true)
- startBottomSheetDialog?.show(supportFragmentManager, startBottomSheetDialog?.tag)
- }
- }
-
- private fun initEndDateClickListener() {
- binding.tvEditTripInfoEndDate.setOnSingleClickListener {
- if (viewModel.startYear.value != null && viewModel.startMonth.value != null && viewModel.startDay.value != null) {
- endBottomSheetDialog = EditDateBottomSheet(false)
- endBottomSheetDialog?.show(supportFragmentManager, endBottomSheetDialog?.tag)
- } else {
- toast(getString(R.string.create_trip_toast_error))
- }
- }
- }
-
- private fun initEditBtnClickListener() {
- binding.btnEditTripInfoEdit.setOnSingleClickListener {
- Intent(this, DashBoardActivity::class.java).apply {
- putExtra(NAME, viewModel.name.value)
- putExtra(START_YEAR, viewModel.startYear.value)
- putExtra(START_MONTH, viewModel.startMonth.value)
- putExtra(START_DAY, viewModel.startDay.value)
- putExtra(END_YEAR, viewModel.endYear.value)
- putExtra(END_MONTH, viewModel.endMonth.value)
- putExtra(END_DAY, viewModel.endDay.value)
- addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
- startActivity(this)
- }
- }
- }
-
- private fun initQuitBtnClickListener() {
- binding.btnEditTripInfoQuit.setOnSingleClickListener {
- showQuitDialog()
- }
- }
-
- private fun showQuitDialog() {
- quitDialog = TripQuitDialogFragment()
- quitDialog?.show(supportFragmentManager, quitDialog?.tag)
- Intent(this, DashBoardActivity::class.java).apply {
- //정보 지워지게 구성
- startActivity(this)
- }
- }
-
- private fun initBackBtnClickListener() {
- binding.btnEditTripInfoBack.setOnSingleClickListener {
- finish()
- }
- }
-
- override fun onDestroy() {
- super.onDestroy()
- if (quitDialog?.isAdded == true) quitDialog?.dismiss()
- }
-
- companion object {
- const val NAME = "name"
- const val START_YEAR = "startYear"
- const val START_MONTH = "startMonth"
- const val START_DAY = "startDay"
- const val END_YEAR = "endYear"
- const val END_MONTH = "endMonth"
- const val END_DAY = "endDay"
- }
-}
-
diff --git a/presentation/src/main/java/com/going/presentation/todo/editinfo/EditTripInfoViewModel.kt b/presentation/src/main/java/com/going/presentation/todo/editinfo/EditTripInfoViewModel.kt
deleted file mode 100644
index 446c6a43..00000000
--- a/presentation/src/main/java/com/going/presentation/todo/editinfo/EditTripInfoViewModel.kt
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.going.presentation.todo.editinfo
-
-import androidx.lifecycle.MutableLiveData
-import androidx.lifecycle.ViewModel
-import com.going.presentation.designsystem.edittext.EditTextState
-import kotlinx.coroutines.flow.MutableStateFlow
-
-class EditTripInfoViewModel : ViewModel() {
- val name = MutableLiveData()
-
- val startYear = MutableLiveData()
- val startMonth = MutableLiveData()
- val startDay = MutableLiveData()
-
- val endYear = MutableLiveData()
- val endMonth = MutableLiveData()
- val endDay = MutableLiveData()
-
- val isStartDateAvailable = MutableLiveData(false)
- val isEndDateAvailable = MutableLiveData(false)
-
- val isNameAvailable = MutableStateFlow(false)
- private val isTripAvailable = MutableLiveData(false)
- var isCheckTripAvailable = MutableLiveData(false)
-
- fun getMaxTripLen() = MAX_TRIP_LEN
-
- fun setNameState(newName: String, state: EditTextState) {
- name.value = newName
- isNameAvailable.value = state == EditTextState.SUCCESS
- }
-
- fun setStartDate(year: Int, month: Int, day: Int) {
- startYear.value = year
- startMonth.value = month
- startDay.value = day
- checkStartDateAvailable()
- }
-
- fun setEndDate(year: Int, month: Int, day: Int) {
- endYear.value = year
- endMonth.value = month
- endDay.value = day
- checkEndDateAvailable()
- }
-
-
- fun checkStartDateAvailable() {
- if (startYear.value != null && startMonth.value != null && startDay.value != null) {
- isStartDateAvailable.value = true
- checkTripAvailable()
- } else {
- isStartDateAvailable.value = false
- }
- }
-
-
- fun checkEndDateAvailable() {
- if (endYear.value != null && endMonth.value != null && endDay.value != null) {
- isEndDateAvailable.value = true
- checkTripAvailable()
- } else {
- isEndDateAvailable.value = false
- }
- }
-
- fun checkTripAvailable() {
- isCheckTripAvailable.value =
- (isTripAvailable.value == true && isStartDateAvailable.value == true && isEndDateAvailable.value == true)
- }
-
- companion object {
- const val MAX_TRIP_LEN = 15
- }
-}
-
diff --git a/presentation/src/main/java/com/going/presentation/todo/editinfo/TripQuitDialogFragment.kt b/presentation/src/main/java/com/going/presentation/todo/edittrip/QuitTripDialogFragment.kt
similarity index 57%
rename from presentation/src/main/java/com/going/presentation/todo/editinfo/TripQuitDialogFragment.kt
rename to presentation/src/main/java/com/going/presentation/todo/edittrip/QuitTripDialogFragment.kt
index 11271e94..329576ed 100644
--- a/presentation/src/main/java/com/going/presentation/todo/editinfo/TripQuitDialogFragment.kt
+++ b/presentation/src/main/java/com/going/presentation/todo/edittrip/QuitTripDialogFragment.kt
@@ -1,16 +1,21 @@
-package com.going.presentation.todo.editinfo
+package com.going.presentation.todo.edittrip
+import android.content.Intent
import android.os.Bundle
import android.view.View
import android.view.WindowManager
+import androidx.fragment.app.activityViewModels
import com.going.presentation.R
-import com.going.presentation.databinding.FragmentTripQuitDialogBinding
+import com.going.presentation.dashboard.DashBoardActivity
+import com.going.presentation.databinding.FragmentQuitTripDialogBinding
+import com.going.presentation.todo.edittrip.edit.EditTripViewModel
import com.going.ui.base.BaseDialog
import com.going.ui.extension.setOnSingleClickListener
-class TripQuitDialogFragment :
- BaseDialog(R.layout.fragment_trip_quit_dialog) {
+class QuitTripDialogFragment :
+ BaseDialog(R.layout.fragment_quit_trip_dialog) {
+ private val viewModel by activityViewModels()
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@@ -37,7 +42,10 @@ class TripQuitDialogFragment :
private fun initNegativeClickListener() {
binding.tvDialogNegative.setOnSingleClickListener {
- //대시보드 뷰로 이동
+ viewModel.patchQuitTripFromServer()
+ Intent(requireActivity(), DashBoardActivity::class.java).apply {
+ requireActivity().startActivity(this)
+ }
}
}
}
diff --git a/presentation/src/main/java/com/going/presentation/todo/edittrip/edit/EditTripActivity.kt b/presentation/src/main/java/com/going/presentation/todo/edittrip/edit/EditTripActivity.kt
new file mode 100644
index 00000000..ab33a6ba
--- /dev/null
+++ b/presentation/src/main/java/com/going/presentation/todo/edittrip/edit/EditTripActivity.kt
@@ -0,0 +1,118 @@
+package com.going.presentation.todo.edittrip.edit
+
+import android.app.Activity
+import android.os.Bundle
+import androidx.activity.viewModels
+import androidx.lifecycle.flowWithLifecycle
+import androidx.lifecycle.lifecycleScope
+import com.going.presentation.R
+import com.going.presentation.databinding.ActivityEditTripBinding
+import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.TRIP_ID
+import com.going.presentation.todo.edittrip.QuitTripDialogFragment
+import com.going.presentation.todo.edittrip.info.EditTripInfoActivity
+import com.going.ui.base.BaseActivity
+import com.going.ui.extension.setOnSingleClickListener
+import com.going.ui.extension.toast
+import com.going.ui.state.UiState
+import dagger.hilt.android.AndroidEntryPoint
+import kotlinx.coroutines.flow.launchIn
+import kotlinx.coroutines.flow.onEach
+
+@AndroidEntryPoint
+class EditTripActivity :
+ BaseActivity(R.layout.activity_edit_trip) {
+ private val viewModel by viewModels()
+ private var quitDialog: QuitTripDialogFragment? = null
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ initBindingViewModel()
+ getIntentData()
+ observeTripinfoState()
+ observePatchQuitState()
+ initEditBtnClickListener()
+ initQuitBtnClickListener()
+ initBackBtnClickListener()
+ }
+
+ private fun initBindingViewModel() {
+ binding.viewModel = viewModel
+ }
+
+ private fun getIntentData() {
+ viewModel.tripId = intent.getLongExtra(TRIP_ID, -1L)
+ viewModel.getTripInfoFromServer(viewModel.tripId)
+ }
+
+ private fun observeTripinfoState() {
+ viewModel.tripInfoState.flowWithLifecycle(lifecycle).onEach { state ->
+ when (state) {
+ is UiState.Success -> {
+ with(binding) {
+ tvEditTripName.text = viewModel?.title
+ tvEditTripInfoStartDate.text = viewModel?.startDate
+ tvEditTripInfoEndDate.text = viewModel?.endDate
+ viewModel?.gettitleLength()
+ }
+ }
+
+ is UiState.Failure -> {
+ toast(getString(R.string.server_error))
+ }
+
+ is UiState.Loading -> return@onEach
+ is UiState.Empty -> return@onEach
+ }
+ }.launchIn(lifecycleScope)
+ }
+
+ private fun observePatchQuitState() {
+ viewModel.quittripState.flowWithLifecycle(lifecycle).onEach { result ->
+ if (result) {
+ toast(getString(R.string.quit_trip_toast_success))
+ setResult(Activity.RESULT_OK)
+ finish()
+ return@onEach
+ }
+ toast(getString(R.string.quit_trip_toast_failure))
+ }.launchIn(lifecycleScope)
+ }
+
+ private fun initQuitBtnClickListener() {
+ binding.btnEditTripQuit.setOnSingleClickListener {
+ showQuitDialog()
+ }
+ }
+
+
+ private fun initEditBtnClickListener() {
+ binding.btnEditTripEdit.setOnSingleClickListener {
+ EditTripInfoActivity.createIntent(
+ this,
+ viewModel.tripId,
+ viewModel.title,
+ viewModel.startDate,
+ viewModel.endDate
+ ).apply { startActivity(this) }
+
+ }
+ }
+
+ private fun showQuitDialog() {
+ quitDialog = QuitTripDialogFragment()
+ quitDialog?.show(supportFragmentManager, quitDialog?.tag)
+ }
+
+ private fun initBackBtnClickListener() {
+ binding.btnEditTripInfoBack.setOnSingleClickListener {
+ finish()
+ }
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ if (quitDialog?.isAdded == true) quitDialog?.dismiss()
+ }
+
+}
\ No newline at end of file
diff --git a/presentation/src/main/java/com/going/presentation/todo/edittrip/edit/EditTripViewModel.kt b/presentation/src/main/java/com/going/presentation/todo/edittrip/edit/EditTripViewModel.kt
new file mode 100644
index 00000000..7e3fd8e9
--- /dev/null
+++ b/presentation/src/main/java/com/going/presentation/todo/edittrip/edit/EditTripViewModel.kt
@@ -0,0 +1,82 @@
+package com.going.presentation.todo.edittrip.edit
+
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.going.domain.entity.response.TripInfoModel
+import com.going.domain.repository.EditTripRepository
+import com.going.ui.extension.getGraphemeLength
+import com.going.ui.state.UiState
+import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.SharedFlow
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.launch
+import javax.inject.Inject
+
+@HiltViewModel
+class EditTripViewModel @Inject constructor(
+ private val editTripRepository: EditTripRepository
+) : ViewModel() {
+ val titleLength = MutableLiveData(0)
+
+ val startYear = MutableLiveData()
+ val startMonth = MutableLiveData()
+ val startDay = MutableLiveData()
+
+ val endYear = MutableLiveData()
+ val endMonth = MutableLiveData()
+ val endDay = MutableLiveData()
+
+ var tripId: Long = 0
+ var title: String = ""
+ var startDate: String = ""
+ var endDate: String = ""
+
+
+ private val _tripInfoState = MutableStateFlow>(UiState.Empty)
+ val tripInfoState: StateFlow> get() = _tripInfoState
+
+ private val _quittripState = MutableSharedFlow()
+ val quittripState: SharedFlow = _quittripState
+
+ fun gettitleLength(){
+ titleLength.value = title.getGraphemeLength()
+ }
+
+ fun getTripInfoFromServer(tripId: Long) {
+ _tripInfoState.value = UiState.Loading
+ viewModelScope.launch {
+ editTripRepository.getTripInfo(tripId)
+ .onSuccess {
+ title = it.title
+ startDate = it.startDate
+ endDate = it.endDate
+ _tripInfoState.value = UiState.Success(it)
+ }
+ .onFailure {
+ _tripInfoState.value = UiState.Failure(it.message.orEmpty())
+ }
+ }
+ }
+
+ fun patchQuitTripFromServer() {
+ viewModelScope.launch {
+ editTripRepository.patchQuitTrip(
+ tripId
+ )
+ .onSuccess {
+ _quittripState.emit(true)
+ }
+ .onFailure {
+ _quittripState.emit(false)
+ }
+ }
+ }
+
+ companion object {
+ const val MAX_TRIP_LEN = 15
+ }
+
+}
diff --git a/presentation/src/main/java/com/going/presentation/todo/editinfo/EditDateBottomSheet.kt b/presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditDateBottomSheet.kt
similarity index 56%
rename from presentation/src/main/java/com/going/presentation/todo/editinfo/EditDateBottomSheet.kt
rename to presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditDateBottomSheet.kt
index d94d2482..e63b53e6 100644
--- a/presentation/src/main/java/com/going/presentation/todo/editinfo/EditDateBottomSheet.kt
+++ b/presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditDateBottomSheet.kt
@@ -1,4 +1,4 @@
-package com.going.presentation.todo.editinfo
+package com.going.presentation.todo.edittrip.info
import android.os.Bundle
import android.view.View
@@ -30,19 +30,16 @@ class EditDateBottomSheet(val isStart: Boolean) :
val calendar = Calendar.getInstance()
val datePicker = binding.dpEditTripDate.apply {
updateDate(
- calendar.get(Calendar.YEAR),
- calendar.get(Calendar.MONTH),
- 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)
)
}
- calendar.set(2000, 0, 1)
- datePicker.minDate = calendar.timeInMillis
-
- if (viewModel.endYear.value != null && viewModel.endMonth.value != null && viewModel.endDay.value != null) {
+ 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 {
@@ -52,17 +49,24 @@ class EditDateBottomSheet(val isStart: Boolean) :
}
private fun customEndDate() {
- binding.dpEditTripDate.apply {
- minDate = Calendar.getInstance().apply {
- set(
- viewModel.startYear.value ?: 0,
- (viewModel.startMonth.value ?: 0) - 1,
- viewModel.startDay.value ?: 0
- )
- }.timeInMillis
- maxDate = Calendar.getInstance().apply {
- set(2100, 0, 1)
- }.timeInMillis
+ val calendar = Calendar.getInstance()
+ val datePicker = binding.dpEditTripDate.apply {
+ updateDate(
+ viewModel.currentEndYear ?: calendar.get(Calendar.YEAR),
+ (viewModel.currentEndMonth ?: calendar.get(Calendar.MONTH)) - 1,
+ viewModel.currentEndDay ?: calendar.get(Calendar.DAY_OF_MONTH)
+ )
+ }
+ if (viewModel.startYear != viewModel.currentStartYear || viewModel.startMonth != viewModel.currentStartMonth || viewModel.startDay != viewModel.currentStartDay) {
+ calendar.set(
+ viewModel.startYear ?: 0,
+ (viewModel.startMonth ?: 0) - 1,
+ viewModel.startDay ?: 0
+ )
+ datePicker.minDate = calendar.timeInMillis
+ } else {
+ calendar.set(2000, 0, 1)
+ datePicker.minDate = calendar.timeInMillis
}
}
@@ -71,7 +75,6 @@ class EditDateBottomSheet(val isStart: Boolean) :
if (isStart) {
viewModel.setStartDate(year, month + 1, dayOfMonth)
} else {
- customEndDate()
viewModel.setEndDate(year, month + 1, dayOfMonth)
}
}
diff --git a/presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditTripInfoActivity.kt b/presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditTripInfoActivity.kt
new file mode 100644
index 00000000..fefae519
--- /dev/null
+++ b/presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditTripInfoActivity.kt
@@ -0,0 +1,143 @@
+package com.going.presentation.todo.edittrip.info
+
+import android.app.Activity
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import androidx.activity.viewModels
+import androidx.core.widget.doAfterTextChanged
+import androidx.lifecycle.flowWithLifecycle
+import androidx.lifecycle.lifecycleScope
+import com.going.presentation.R
+import com.going.presentation.dashboard.DashBoardActivity
+import com.going.presentation.databinding.ActivityEditTripInfoBinding
+import com.going.ui.base.BaseActivity
+import com.going.ui.extension.setOnSingleClickListener
+import com.going.ui.extension.toast
+import dagger.hilt.android.AndroidEntryPoint
+import kotlinx.coroutines.flow.launchIn
+import kotlinx.coroutines.flow.onEach
+
+@AndroidEntryPoint
+class EditTripInfoActivity :
+ BaseActivity(R.layout.activity_edit_trip_info) {
+ private val viewModel by viewModels()
+
+ private var startBottomSheetDialog: EditDateBottomSheet? = null
+ private var endBottomSheetDialog: EditDateBottomSheet? = null
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ initBindingViewModel()
+ observePatchEditState()
+ setEtInfoNameArguments()
+ observeInfoNameTextChanged()
+ getTripInfoData()
+ initStartDateClickListener()
+ initEndDateClickListener()
+ initEditBtnClickListener()
+ initBackBtnClickListener()
+ }
+
+ private fun initBindingViewModel() {
+ binding.viewModel = viewModel
+ }
+
+ private fun getTripInfoData() {
+ viewModel.tripId = intent.getLongExtra(TRIP_ID, -1L)
+ viewModel.currentTitle = intent.getStringExtra(TITLE) ?: ""
+ viewModel.currentStartDate = intent.getStringExtra(START_DATE) ?: ""
+ viewModel.currentEndDate = intent.getStringExtra(END_DATE) ?: ""
+
+ binding.etEditTripInfoName.editText.setText(viewModel.currentTitle)
+ viewModel.splitStartDate()
+ viewModel.splitEndDate()
+ }
+
+ private fun observePatchEditState() {
+ viewModel.tripEditState.flowWithLifecycle(lifecycle).onEach { result ->
+ if (result) {
+ toast(getString(R.string.edit_trip_toast_success))
+ setResult(Activity.RESULT_OK)
+ finish()
+ return@onEach
+ }
+ toast(getString(R.string.edit_trip_toast_failure))
+ }.launchIn(lifecycleScope)
+ }
+
+ private fun setEtInfoNameArguments() {
+ with(binding.etEditTripInfoName) {
+ setMaxLen(viewModel.getMaxTripLen())
+ overWarning = getString(R.string.trip_over_error)
+ blankWarning = getString(R.string.trip_blank_error)
+ }
+ }
+
+
+ private fun observeInfoNameTextChanged() {
+ binding.etEditTripInfoName.editText.doAfterTextChanged { text ->
+ viewModel.setTitleState(text.toString(), binding.etEditTripInfoName.state)
+ }
+ viewModel.checkTripAvailable()
+ }
+
+
+ private fun initStartDateClickListener() {
+ binding.tvEditTripInfoStartDate.setOnSingleClickListener {
+ startBottomSheetDialog = EditDateBottomSheet(true)
+ startBottomSheetDialog?.show(supportFragmentManager, startBottomSheetDialog?.tag)
+ }
+ viewModel.checkStartDateAvailable()
+ viewModel.checkTripAvailable()
+
+ }
+
+ private fun initEndDateClickListener() {
+ binding.tvEditTripInfoEndDate.setOnSingleClickListener {
+ endBottomSheetDialog = EditDateBottomSheet(false)
+ endBottomSheetDialog?.show(supportFragmentManager, endBottomSheetDialog?.tag)
+ }
+ viewModel.checkEndDateAvailable()
+ viewModel.checkTripAvailable()
+
+ }
+
+ private fun initEditBtnClickListener() {
+ binding.btnEditTripSave.setOnSingleClickListener {
+ viewModel.patchTripInfoFromServer()
+ Intent(this, DashBoardActivity::class.java).apply {
+ startActivity(this)
+ }
+ }
+ }
+
+ private fun initBackBtnClickListener() {
+ binding.btnEditTripInfoBack.setOnSingleClickListener {
+ finish()
+ }
+ }
+
+ companion object {
+ 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(
+ context: Context,
+ tripId: Long,
+ title: String,
+ startDate: String,
+ endDate: String
+ ): Intent = Intent(context, EditTripInfoActivity::class.java).apply {
+ putExtra(TRIP_ID, tripId)
+ putExtra(TITLE, title)
+ putExtra(START_DATE, startDate)
+ putExtra(END_DATE, endDate)
+ }
+ }
+}
+
diff --git a/presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditTripInfoViewModel.kt b/presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditTripInfoViewModel.kt
new file mode 100644
index 00000000..2dce5af1
--- /dev/null
+++ b/presentation/src/main/java/com/going/presentation/todo/edittrip/info/EditTripInfoViewModel.kt
@@ -0,0 +1,159 @@
+package com.going.presentation.todo.edittrip.info
+
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.viewModelScope
+import com.going.domain.entity.request.EditTripRequestModel
+import com.going.domain.repository.EditTripRepository
+import com.going.presentation.designsystem.edittext.EditTextState
+import dagger.hilt.android.lifecycle.HiltViewModel
+import kotlinx.coroutines.flow.MutableSharedFlow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.SharedFlow
+import kotlinx.coroutines.launch
+import javax.inject.Inject
+
+@HiltViewModel
+class EditTripInfoViewModel @Inject constructor(
+ private val editTripRepository: EditTripRepository,
+) : ViewModel() {
+
+ private val _tripEditState = MutableSharedFlow()
+ val tripEditState: SharedFlow = _tripEditState
+
+ var tripId: Long = 0
+
+ var currentTitle: String = ""
+ var currentStartDate: String = ""
+ var currentEndDate: String = ""
+
+ 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()
+
+ var endYear: Int? = null
+ var endMonth: Int? = null
+ var endDay: Int? = null
+ var endDate = MutableLiveData()
+
+ val isStartDateAvailable = MutableLiveData(false)
+ val isEndDateAvailable = MutableLiveData(false)
+
+ val isTitleAvailable = MutableStateFlow(false)
+ var isCheckTripAvailable = MutableLiveData(false)
+
+ fun getMaxTripLen() = MAX_TRIP_LEN
+
+ fun patchTripInfoFromServer() {
+ viewModelScope.launch {
+ editTripRepository.patchEditTripInfo(
+ tripId,
+ EditTripRequestModel(
+ title = title.orEmpty(),
+ startDate = startDate.value.orEmpty(),
+ endDate = endDate.value.orEmpty()
+ )
+ )
+ .onSuccess {
+ _tripEditState.emit(true)
+ }
+ .onFailure {
+ _tripEditState.emit(false)
+ }
+ }
+ }
+
+ 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 {
+ 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 = newTitle
+ isTitleAvailable.value = state == EditTextState.SUCCESS
+ checkTripAvailable()
+ }
+
+ fun setStartDate(year: Int, month: Int, day: Int) {
+ 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 = year
+ endMonth = month
+ endDay = day
+ checkEndDateAvailable()
+ endDate.value = String.format("%04d.%02d.%02d", year, month, day)
+ }
+
+ fun checkStartDateAvailable() {
+ if (startYear != null && startMonth != null && startDay != null) {
+ isStartDateAvailable.value = true
+ checkTripAvailable()
+ } else {
+ isStartDateAvailable.value = false
+ }
+ }
+
+ fun checkEndDateAvailable() {
+ if (endYear != null && endMonth != null && endDay != null) {
+ isEndDateAvailable.value = true
+ checkTripAvailable()
+ } else {
+ isEndDateAvailable.value = false
+ }
+ }
+
+ fun checkTripAvailable() {
+ isCheckTripAvailable.value = !title.isNullOrEmpty() && (
+ (title != null && currentTitle != title) ||
+ currentStartDate != startDate.value ||
+ currentEndDate != endDate.value
+ )
+ }
+
+ companion object {
+ const val MAX_TRIP_LEN = 15
+ }
+}
+
diff --git a/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt b/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt
index 546a3f28..0e29b0a8 100644
--- a/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt
+++ b/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoFragment.kt
@@ -16,10 +16,12 @@ import androidx.viewpager2.widget.ViewPager2
import com.going.domain.entity.response.TripParticipantModel
import com.going.presentation.R
import com.going.presentation.databinding.FragmentOurTodoBinding
+import com.going.presentation.entertrip.invitetrip.invitecode.EnterTripActivity.Companion.TRIP_ID
import com.going.presentation.profile.participant.ParticipantProfileActivity
import com.going.presentation.todo.TodoActivity.Companion.EXTRA_TRIP_ID
import com.going.presentation.todo.create.TodoCreateActivity
import com.going.presentation.todo.ourtodo.checkfriends.CheckFriendsActivity
+import com.going.presentation.todo.edittrip.edit.EditTripActivity
import com.going.presentation.todo.ourtodo.friendlist.OurTodoFriendAdapter
import com.going.presentation.todo.ourtodo.invite.FriendInviteDialog
import com.going.presentation.todo.ourtodo.todolist.OurTodoViewPagerAdapter
@@ -60,12 +62,12 @@ class OurTodoFragment() : BaseFragment(R.layout.fragment
super.onViewCreated(view, savedInstanceState)
initAdapter()
- initTripInfoBtnClickListener()
initAddTodoBtnListener()
initItemDecoration()
initInviteBtnListener()
initBackBtnClickListener()
initTripFriendBtnClickListener()
+ initTripInfoBtnClickListener()
setTabLayout()
setViewPager()
setViewPagerChangeListener()
@@ -94,12 +96,6 @@ class OurTodoFragment() : BaseFragment(R.layout.fragment
).apply { startActivity(this) }
}
- private fun initTripInfoBtnClickListener() {
- binding.btnOurTodoTripInfo.setOnSingleClickListener {
- // TODO : 여행정보 화면 이동
- }
- }
-
private fun initAddTodoBtnListener() {
binding.btnOurTodoAddTodo.setOnSingleClickListener {
TodoCreateActivity.createIntent(
@@ -144,6 +140,15 @@ class OurTodoFragment() : BaseFragment(R.layout.fragment
}
}
+ private fun initTripInfoBtnClickListener() {
+ binding.btnOurTodoTripInfo.setOnSingleClickListener {
+ Intent(requireActivity(), EditTripActivity::class.java).apply {
+ putExtra(TRIP_ID, viewModel.tripId)
+ startActivity(this)
+ }
+ }
+ }
+
private fun setOurTripInfo() {
arguments?.let {
viewModel.tripId = it.getLong(EXTRA_TRIP_ID)
diff --git a/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoViewModel.kt b/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoViewModel.kt
index 1d314bea..19877253 100644
--- a/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoViewModel.kt
+++ b/presentation/src/main/java/com/going/presentation/todo/ourtodo/OurTodoViewModel.kt
@@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.going.domain.entity.response.OurTripInfoModel
import com.going.domain.entity.response.TodoModel
+import com.going.domain.repository.EditTripRepository
import com.going.domain.repository.TodoRepository
import com.going.ui.state.UiState
import dagger.hilt.android.lifecycle.HiltViewModel
@@ -26,8 +27,8 @@ class OurTodoViewModel @Inject constructor(
private val _todoCompleteListState = MutableStateFlow>>(UiState.Empty)
val todoCompleteListState: StateFlow>> = _todoCompleteListState
- var inviteCode : String = ""
- var tripId : Long = 0
+ var inviteCode: String = ""
+ var tripId: Long = 0
fun getOurTripInfoFromServer() {
_ourTripInfoState.value = UiState.Loading
diff --git a/presentation/src/main/res/layout/activity_edit_trip.xml b/presentation/src/main/res/layout/activity_edit_trip.xml
new file mode 100644
index 00000000..ffc67fff
--- /dev/null
+++ b/presentation/src/main/res/layout/activity_edit_trip.xml
@@ -0,0 +1,183 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/presentation/src/main/res/layout/activity_edit_trip_info.xml b/presentation/src/main/res/layout/activity_edit_trip_info.xml
index f4d640cc..fa832ce5 100644
--- a/presentation/src/main/res/layout/activity_edit_trip_info.xml
+++ b/presentation/src/main/res/layout/activity_edit_trip_info.xml
@@ -7,14 +7,14 @@
+ type="com.going.presentation.todo.edittrip.info.EditTripInfoViewModel" />
+ tools:context=".todo.edittrip.info.EditTripInfoActivity">
+
-
-
-
-
+ app:layout_constraintStart_toStartOf="parent" />
diff --git a/presentation/src/main/res/layout/fragment_trip_quit_dialog.xml b/presentation/src/main/res/layout/fragment_quit_trip_dialog.xml
similarity index 100%
rename from presentation/src/main/res/layout/fragment_trip_quit_dialog.xml
rename to presentation/src/main/res/layout/fragment_quit_trip_dialog.xml
diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml
index 47975ed2..b0986460 100644
--- a/presentation/src/main/res/values/strings.xml
+++ b/presentation/src/main/res/values/strings.xml
@@ -233,7 +233,7 @@
브라우저 오류
- 여행 정보
+ 여행 정보 수정
어떤 여행인가요?
여행 일정을 알려주세요
이번 여행 이름을 입력해 주세요
@@ -241,6 +241,7 @@
나가기
수정하기
프로필을 수정했어요
+ 저장하기
선택하기
%1$d.%2$d.%3$d
시작일을 먼저 입력해 주세요
@@ -254,4 +255,20 @@
취향태그 수정하기
취향태그를 수정했어요
취향태그 수정에 실패했어요
+
+
+ 여행 정보
+ 어떤 여행인가요?
+ 여행 일정을 알려주세요
+ -
+ 나가기
+ 수정하기
+ 선택하기
+ %1$d.%2$d.%3$d
+ 여행 정보 수정되었어요
+ 여행 정보 수정에 실패했어요
+
+
+ 여행방에서 나왔어요
+ 여행방에서 나오지 못했어요