From 79f65166b0c2f49e14508b7c867a2310f856c83a Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sat, 13 Jan 2024 03:36:44 +0900 Subject: [PATCH 1/9] =?UTF-8?q?[DEL/#96]=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=8C=8C=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/drawable/sel_button_text_color_preference.xml | 4 ---- .../src/main/res/layout/activity_finish_preference.xml | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 presentation/src/main/res/drawable/sel_button_text_color_preference.xml diff --git a/presentation/src/main/res/drawable/sel_button_text_color_preference.xml b/presentation/src/main/res/drawable/sel_button_text_color_preference.xml deleted file mode 100644 index 5aa981d7..00000000 --- a/presentation/src/main/res/drawable/sel_button_text_color_preference.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/presentation/src/main/res/layout/activity_finish_preference.xml b/presentation/src/main/res/layout/activity_finish_preference.xml index 6340fee5..2c0ea077 100644 --- a/presentation/src/main/res/layout/activity_finish_preference.xml +++ b/presentation/src/main/res/layout/activity_finish_preference.xml @@ -77,9 +77,9 @@ android:layout_marginHorizontal="24dp" android:layout_marginBottom="22dp" android:background="@drawable/sel_rounded_corner_button_preference" - android:text="@string/preference_btn_finish" android:outlineProvider="none" - android:textColor="@drawable/sel_button_text_color_preference" + android:text="@string/preference_btn_finish" + android:textColor="@color/gray_200" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" /> From dc234b973a3a3b56e01991c821fddf0696956cf2 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sun, 14 Jan 2024 17:25:01 +0900 Subject: [PATCH 2/9] =?UTF-8?q?[FEAT/#96]=20=EC=97=AC=ED=96=89=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=84=9C=EB=B2=84=ED=86=B5=EC=8B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 +- .../com/going/doorip/di/DataSourceModule.kt | 7 ++++ .../com/going/doorip/di/RepositoryModule.kt | 7 ++++ .../java/com/going/doorip/di/ServiceModule.kt | 7 +++- .../datasource/EnterPreferenceDataSource.kt | 11 +++++ .../EnterPreferenceDataSourceImpl.kt | 18 ++++++++ .../dto/request/EnterPreferenceRequestDto.kt | 28 +++++++++++++ .../data/dto/request/EnterTripRequestDto.kt | 1 - .../response/EnterPreferenceResponseDto.kt | 21 ++++++++++ .../EnterPreferenceRepositoryImpl.kt | 20 +++++++++ .../data/service/EnterPreferenceService.kt | 15 +++++++ .../request/EnterPreferenceRequestModel.kt | 12 ++++++ .../response/EnterPreferenceResponseModel.kt | 10 +++++ .../repository/EnterPreferenceRepository.kt | 11 +++++ .../preferencetag/PreferenceTagViewModel.kt | 1 + .../entertrip/EnterPreferenceActivity.kt | 8 ++-- .../entertrip/EnterPreferenceViewModel.kt | 41 +++++++++++++++++++ .../res/layout/activity_enter_preference.xml | 5 --- 18 files changed, 213 insertions(+), 12 deletions(-) create mode 100644 data/src/main/java/com/going/data/datasource/EnterPreferenceDataSource.kt create mode 100644 data/src/main/java/com/going/data/datasourceImpl/EnterPreferenceDataSourceImpl.kt create mode 100644 data/src/main/java/com/going/data/dto/request/EnterPreferenceRequestDto.kt create mode 100644 data/src/main/java/com/going/data/dto/response/EnterPreferenceResponseDto.kt create mode 100644 data/src/main/java/com/going/data/repositoryImpl/EnterPreferenceRepositoryImpl.kt create mode 100644 data/src/main/java/com/going/data/service/EnterPreferenceService.kt create mode 100644 domain/src/main/kotlin/com/going/domain/entity/request/EnterPreferenceRequestModel.kt create mode 100644 domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceResponseModel.kt create mode 100644 domain/src/main/kotlin/com/going/domain/repository/EnterPreferenceRepository.kt create mode 100644 presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a2311acb..b03dedc0 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -75,7 +75,7 @@ = + runCatching { + enterPreferenceDataSource.postTripInfo(request.toEnterPreferenceRequestDto()) + } + +} diff --git a/data/src/main/java/com/going/data/service/EnterPreferenceService.kt b/data/src/main/java/com/going/data/service/EnterPreferenceService.kt new file mode 100644 index 00000000..a3e7330a --- /dev/null +++ b/data/src/main/java/com/going/data/service/EnterPreferenceService.kt @@ -0,0 +1,15 @@ +package com.going.data.service + +import com.going.data.dto.request.EnterPreferenceRequestDto +import com.going.data.dto.response.EnterPreferenceResponseDto +import retrofit2.http.Body +import retrofit2.http.POST + +interface EnterPreferenceService { + + @POST("api/trips") + suspend fun postTripInfoFromServer( + @Body request: EnterPreferenceRequestDto, + ): EnterPreferenceResponseDto + +} \ No newline at end of file diff --git a/domain/src/main/kotlin/com/going/domain/entity/request/EnterPreferenceRequestModel.kt b/domain/src/main/kotlin/com/going/domain/entity/request/EnterPreferenceRequestModel.kt new file mode 100644 index 00000000..83d5ccf1 --- /dev/null +++ b/domain/src/main/kotlin/com/going/domain/entity/request/EnterPreferenceRequestModel.kt @@ -0,0 +1,12 @@ +package com.going.domain.entity.request + +data class EnterPreferenceRequestModel( + val title: String, + val startDate: String, + val endDate: String, + val styleA: Int, + val styleB: Int, + val styleC: Int, + val styleD: Int, + val styleE: Int +) \ No newline at end of file diff --git a/domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceResponseModel.kt b/domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceResponseModel.kt new file mode 100644 index 00000000..56a73476 --- /dev/null +++ b/domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceResponseModel.kt @@ -0,0 +1,10 @@ +package com.going.domain.entity.response + +data class EnterPreferenceResponseModel( + val tripId : Long, + val title : String, + val startDate : String, + val endDate : String, + val code : String, + val day : Int +) \ No newline at end of file diff --git a/domain/src/main/kotlin/com/going/domain/repository/EnterPreferenceRepository.kt b/domain/src/main/kotlin/com/going/domain/repository/EnterPreferenceRepository.kt new file mode 100644 index 00000000..989177aa --- /dev/null +++ b/domain/src/main/kotlin/com/going/domain/repository/EnterPreferenceRepository.kt @@ -0,0 +1,11 @@ +package com.going.domain.repository + +import com.going.domain.entity.request.EnterPreferenceRequestModel + +interface EnterPreferenceRepository { + + suspend fun postTipInfo( + request: EnterPreferenceRequestModel + ): Result + +} \ No newline at end of file diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt b/presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt index 158dab8e..f6a785ec 100644 --- a/presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt @@ -5,6 +5,7 @@ import com.going.domain.entity.PreferenceData class PreferenceTagViewModel : ViewModel() { + // 추후 삭제할 예정 val preferenceTagList = listOf( PreferenceData( number = "01", diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt index b212d458..aa6728ab 100644 --- a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt +++ b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt @@ -8,7 +8,6 @@ import com.going.presentation.R import com.going.presentation.databinding.ActivityEnterPreferenceBinding import com.going.presentation.preferencetag.PreferenceTagAdapter import com.going.presentation.preferencetag.PreferenceTagDecoration -import com.going.presentation.preferencetag.PreferenceTagViewModel import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.END_DAY import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.END_MONTH import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.END_YEAR @@ -26,13 +25,14 @@ class EnterPreferenceActivity : private var _adapter: PreferenceTagAdapter? = null private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) } - private val viewModel by viewModels() + private val viewModel by viewModels() private val preferenceAnswers = MutableList(5) { Int.MAX_VALUE } private var title: String? = "" private var startDate: String? = "" private var endDate: String? = "" + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -73,9 +73,9 @@ class EnterPreferenceActivity : } private fun getCreateTripInfo() { - val serverList = getIntent() + val infoList = getIntent() - if (serverList != null) { + if (infoList != null) { title = intent.getStringExtra(NAME) val startYear = intent.getIntExtra(START_YEAR, 0) val startMonth = intent.getIntExtra(START_MONTH, 0) diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt new file mode 100644 index 00000000..8ee9b37c --- /dev/null +++ b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt @@ -0,0 +1,41 @@ +package com.going.presentation.preferencetag.entertrip + +import androidx.lifecycle.ViewModel +import com.going.domain.entity.PreferenceData + +class EnterPreferenceViewModel : ViewModel() { + + val preferenceTagList = listOf( + PreferenceData( + number = "01", + question = "계획은 어느정도로 세울까요?", + leftPrefer = "철저하게", + rightPrefer = "즉흥으로" + ), + PreferenceData( + number = "02", + question = "장소선택의 기준은 무엇인가요?", + leftPrefer = "관광지", + rightPrefer = "로컬장소" + ), + PreferenceData( + number = "03", + question = "어느 식당을 갈까요?", + leftPrefer = "유명 맛집", + rightPrefer = "가까운 곳" + ), + PreferenceData( + number = "04", + question = "기억하고 싶은 순간에!", + leftPrefer = "사진 필수", + rightPrefer = "눈에 담기" + ), + PreferenceData( + number = "05", + question = "하루 일정을 어떻게 채우나요?", + leftPrefer = "알차게", + rightPrefer = "여유롭게" + ), + ) + +} \ No newline at end of file diff --git a/presentation/src/main/res/layout/activity_enter_preference.xml b/presentation/src/main/res/layout/activity_enter_preference.xml index 6e00cf38..db5c71ef 100644 --- a/presentation/src/main/res/layout/activity_enter_preference.xml +++ b/presentation/src/main/res/layout/activity_enter_preference.xml @@ -5,11 +5,6 @@ - - - From b51536a8382ebc5c155aa40f567dc7e939200200 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sun, 14 Jan 2024 21:40:05 +0900 Subject: [PATCH 3/9] =?UTF-8?q?[FEAT/#96]=20=EC=97=AC=ED=96=89=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=84=9C=EB=B2=84=ED=86=B5=EC=8B=A0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 +- .../datasource/EnterPreferenceDataSource.kt | 4 +- .../datasourceImpl/DashBoardDataSourceImpl.kt | 4 +- .../EnterPreferenceDataSourceImpl.kt | 3 +- .../response/EnterPreferenceResponseDto.kt | 5 +- .../going/data/interceptor/AuthInterceptor.kt | 25 +++++--- .../EnterPreferenceRepositoryImpl.kt | 10 ++- .../data/service/EnterPreferenceService.kt | 3 +- ...sponseModel.kt => EnterPreferenceModel.kt} | 2 +- .../repository/EnterPreferenceRepository.kt | 5 +- .../preferencetag/PreferenceTagViewModel.kt | 1 - .../entertrip/EnterPreferenceActivity.kt | 61 +++++++++++++++++-- .../entertrip/EnterPreferenceViewModel.kt | 57 ++++++++++++++++- 13 files changed, 157 insertions(+), 27 deletions(-) rename domain/src/main/kotlin/com/going/domain/entity/response/{EnterPreferenceResponseModel.kt => EnterPreferenceModel.kt} (81%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b03dedc0..db3def69 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -65,7 +65,7 @@ + } \ No newline at end of file diff --git a/data/src/main/java/com/going/data/datasourceImpl/DashBoardDataSourceImpl.kt b/data/src/main/java/com/going/data/datasourceImpl/DashBoardDataSourceImpl.kt index 6bafedb2..757c1fc8 100644 --- a/data/src/main/java/com/going/data/datasourceImpl/DashBoardDataSourceImpl.kt +++ b/data/src/main/java/com/going/data/datasourceImpl/DashBoardDataSourceImpl.kt @@ -10,7 +10,9 @@ class DashBoardDataSourceImpl @Inject constructor( private val dashBoardService: DashBoardService ) : DashBoardDataSource { - override suspend fun getTripList(progress: String): BaseResponse = + override suspend fun getTripList( + progress: String + ): BaseResponse = dashBoardService.getTripList(progress) } diff --git a/data/src/main/java/com/going/data/datasourceImpl/EnterPreferenceDataSourceImpl.kt b/data/src/main/java/com/going/data/datasourceImpl/EnterPreferenceDataSourceImpl.kt index cf75c341..e733520d 100644 --- a/data/src/main/java/com/going/data/datasourceImpl/EnterPreferenceDataSourceImpl.kt +++ b/data/src/main/java/com/going/data/datasourceImpl/EnterPreferenceDataSourceImpl.kt @@ -1,6 +1,7 @@ package com.going.data.datasourceImpl import com.going.data.datasource.EnterPreferenceDataSource +import com.going.data.dto.BaseResponse import com.going.data.dto.request.EnterPreferenceRequestDto import com.going.data.dto.response.EnterPreferenceResponseDto import com.going.data.service.EnterPreferenceService @@ -12,7 +13,7 @@ class EnterPreferenceDataSourceImpl @Inject constructor( override suspend fun postTripInfo( request: EnterPreferenceRequestDto - ): EnterPreferenceResponseDto = + ): BaseResponse = enterPreferenceService.postTripInfoFromServer(request) } \ No newline at end of file diff --git a/data/src/main/java/com/going/data/dto/response/EnterPreferenceResponseDto.kt b/data/src/main/java/com/going/data/dto/response/EnterPreferenceResponseDto.kt index bd1f3374..4bf4b10c 100644 --- a/data/src/main/java/com/going/data/dto/response/EnterPreferenceResponseDto.kt +++ b/data/src/main/java/com/going/data/dto/response/EnterPreferenceResponseDto.kt @@ -1,7 +1,10 @@ package com.going.data.dto.response +import com.going.domain.entity.response.EnterPreferenceModel import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +@Serializable data class EnterPreferenceResponseDto( @SerialName("tripId") val tripId: Long, @@ -17,5 +20,5 @@ data class EnterPreferenceResponseDto( val day: Int, ) { fun toEnterPreferenceModel() = - EnterPreferenceResponseDto(tripId, title, startDate, endDate, code, day) + EnterPreferenceModel(tripId, title, startDate, endDate, code, day) } diff --git a/data/src/main/java/com/going/data/interceptor/AuthInterceptor.kt b/data/src/main/java/com/going/data/interceptor/AuthInterceptor.kt index da83d5e7..aafb3df3 100644 --- a/data/src/main/java/com/going/data/interceptor/AuthInterceptor.kt +++ b/data/src/main/java/com/going/data/interceptor/AuthInterceptor.kt @@ -22,11 +22,14 @@ class AuthInterceptor @Inject constructor( Timber.d("GET ACCESS TOKEN : ${dataStore.accessToken}") - val authRequest = if (dataStore.accessToken.isNotBlank()) { - originalRequest.newAuthBuilder().build() - } else { - originalRequest - } + + // val authRequest = if (dataStore.accessToken.isNotBlank()) { +// originalRequest.newAuthBuilder().build() +// } else { +// originalRequest +// } + + val authRequest = originalRequest.newAuthBuilder().build() val response = chain.proceed(authRequest) @@ -84,12 +87,18 @@ class AuthInterceptor @Inject constructor( return response } - private fun Request.newAuthBuilder() = - this.newBuilder().addHeader(AUTHORIZATION, "$BEARER ${dataStore.accessToken}") +// private fun Request.newAuthBuilder() = +// this.newBuilder().addHeader(AUTHORIZATION, "$BEARER ${dataStore.accessToken}") + // +// private fun Request.newAuthBuilder() = +// this.newBuilder().addHeader(AUTHORIZATION, "$BEARER ${dataStore.accessToken}") + + private fun Request.newAuthBuilder() = + this.newBuilder().addHeader(AUTHORIZATION, "$BEARER eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2IiwiaWF0IjoxNzA0ODk1NDE4LCJleHAiOjE3MDU1MDAyMTh9.FWPJhGl9amOs1Aog1snD2O1ayVm6lRYBJgHOndyWdMQ") companion object { private const val CODE_TOKEN_EXPIRED = 401 private const val BEARER = "Bearer" private const val AUTHORIZATION = "Authorization" } -} +} \ No newline at end of file diff --git a/data/src/main/java/com/going/data/repositoryImpl/EnterPreferenceRepositoryImpl.kt b/data/src/main/java/com/going/data/repositoryImpl/EnterPreferenceRepositoryImpl.kt index 9390c5aa..db5c482f 100644 --- a/data/src/main/java/com/going/data/repositoryImpl/EnterPreferenceRepositoryImpl.kt +++ b/data/src/main/java/com/going/data/repositoryImpl/EnterPreferenceRepositoryImpl.kt @@ -3,6 +3,7 @@ package com.going.data.repositoryImpl import com.going.data.datasource.EnterPreferenceDataSource import com.going.data.dto.request.toEnterPreferenceRequestDto import com.going.domain.entity.request.EnterPreferenceRequestModel +import com.going.domain.entity.response.EnterPreferenceModel import com.going.domain.repository.EnterPreferenceRepository import javax.inject.Inject @@ -10,11 +11,14 @@ class EnterPreferenceRepositoryImpl @Inject constructor( private val enterPreferenceDataSource: EnterPreferenceDataSource ) : EnterPreferenceRepository { - override suspend fun postTipInfo( + override suspend fun postTripInfo( request: EnterPreferenceRequestModel - ): Result = + ): Result = runCatching { - enterPreferenceDataSource.postTripInfo(request.toEnterPreferenceRequestDto()) + enterPreferenceDataSource.postTripInfo( + request.toEnterPreferenceRequestDto(), + ).data.toEnterPreferenceModel() } + } diff --git a/data/src/main/java/com/going/data/service/EnterPreferenceService.kt b/data/src/main/java/com/going/data/service/EnterPreferenceService.kt index a3e7330a..0f547484 100644 --- a/data/src/main/java/com/going/data/service/EnterPreferenceService.kt +++ b/data/src/main/java/com/going/data/service/EnterPreferenceService.kt @@ -1,5 +1,6 @@ package com.going.data.service +import com.going.data.dto.BaseResponse import com.going.data.dto.request.EnterPreferenceRequestDto import com.going.data.dto.response.EnterPreferenceResponseDto import retrofit2.http.Body @@ -10,6 +11,6 @@ interface EnterPreferenceService { @POST("api/trips") suspend fun postTripInfoFromServer( @Body request: EnterPreferenceRequestDto, - ): EnterPreferenceResponseDto + ): BaseResponse } \ No newline at end of file diff --git a/domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceResponseModel.kt b/domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceModel.kt similarity index 81% rename from domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceResponseModel.kt rename to domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceModel.kt index 56a73476..35efbcbb 100644 --- a/domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceResponseModel.kt +++ b/domain/src/main/kotlin/com/going/domain/entity/response/EnterPreferenceModel.kt @@ -1,6 +1,6 @@ package com.going.domain.entity.response -data class EnterPreferenceResponseModel( +data class EnterPreferenceModel( val tripId : Long, val title : String, val startDate : String, diff --git a/domain/src/main/kotlin/com/going/domain/repository/EnterPreferenceRepository.kt b/domain/src/main/kotlin/com/going/domain/repository/EnterPreferenceRepository.kt index 989177aa..ff9c984f 100644 --- a/domain/src/main/kotlin/com/going/domain/repository/EnterPreferenceRepository.kt +++ b/domain/src/main/kotlin/com/going/domain/repository/EnterPreferenceRepository.kt @@ -1,11 +1,12 @@ package com.going.domain.repository import com.going.domain.entity.request.EnterPreferenceRequestModel +import com.going.domain.entity.response.EnterPreferenceModel interface EnterPreferenceRepository { - suspend fun postTipInfo( + suspend fun postTripInfo( request: EnterPreferenceRequestModel - ): Result + ): Result } \ No newline at end of file diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt b/presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt index f6a785ec..158dab8e 100644 --- a/presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/preferencetag/PreferenceTagViewModel.kt @@ -5,7 +5,6 @@ import com.going.domain.entity.PreferenceData class PreferenceTagViewModel : ViewModel() { - // 추후 삭제할 예정 val preferenceTagList = listOf( PreferenceData( number = "01", diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt index aa6728ab..c8132c53 100644 --- a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt +++ b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt @@ -1,11 +1,19 @@ package com.going.presentation.preferencetag.entertrip +import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.activity.viewModels import androidx.core.content.ContextCompat +import androidx.lifecycle.flowWithLifecycle import com.going.domain.entity.PreferenceData import com.going.presentation.R import com.going.presentation.databinding.ActivityEnterPreferenceBinding +import com.going.presentation.enter.entertrip.EnterTripActivity.Companion.DAY +import com.going.presentation.enter.entertrip.EnterTripActivity.Companion.END +import com.going.presentation.enter.entertrip.EnterTripActivity.Companion.START +import com.going.presentation.enter.entertrip.EnterTripActivity.Companion.TITLE +import com.going.presentation.enter.invitefinish.InviteFinishActivity import com.going.presentation.preferencetag.PreferenceTagAdapter import com.going.presentation.preferencetag.PreferenceTagDecoration import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.END_DAY @@ -16,8 +24,13 @@ import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion. import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.START_MONTH import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.START_YEAR import com.going.ui.base.BaseActivity +import com.going.ui.extension.UiState import com.going.ui.extension.setOnSingleClickListener +import com.going.ui.extension.toast +import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.onEach +@AndroidEntryPoint class EnterPreferenceActivity : BaseActivity(R.layout.activity_enter_preference), PreferenceTagAdapter.OnPreferenceSelectedListener { @@ -40,7 +53,8 @@ class EnterPreferenceActivity : initItemDecoration() initBackClickListener() getCreateTripInfo() - sendStyleInfo() + initStartBtnClickListener() + observeEnterPreferenceListState() } @@ -57,7 +71,7 @@ class EnterPreferenceActivity : private fun initBackClickListener() { binding.btnPreferenceStart.setOnSingleClickListener { - sendStyleInfo() + finish() } } @@ -90,13 +104,52 @@ class EnterPreferenceActivity : } - private fun sendStyleInfo() { - var styleA = preferenceAnswers[0] + private fun initStartBtnClickListener() { + binding.btnPreferenceStart.setOnSingleClickListener { + viewModel.getTripInfoFromServer() + toast("버튼 눌림") + } + } + + private fun observeEnterPreferenceListState() { + viewModel.enterPreferenceListState.flowWithLifecycle(lifecycle).onEach { state -> + when (state) { + is UiState.Success -> { + Log.d("LYB", "성공힘") + Intent(this, InviteFinishActivity::class.java).apply { + putExtra(TITLE, state.data.title) + putExtra(START, state.data.startDate) + putExtra(END, state.data.endDate) + putExtra(DAY, state.data.day) + startActivity(this) + } + } + + is UiState.Failure -> toast(getString(R.string.server_error)) + + is UiState.Loading -> return@onEach + + is UiState.Empty -> return@onEach + + } + } + } + + private fun sendTripInfo() { + viewModel.title.value = title + viewModel.startDate.value = startDate + viewModel.endDate.value = endDate + viewModel.styleA.value = preferenceAnswers[0] + viewModel.styleB.value = preferenceAnswers[1] + viewModel.styleC.value = preferenceAnswers[2] + viewModel.styleD.value = preferenceAnswers[3] + viewModel.styleE.value = preferenceAnswers[4] } override fun onPreferenceSelected(item: PreferenceData, checkList: Int) { preferenceAnswers[item.number.toInt() - 1] = checkList isButtonValid() + sendTripInfo() } override fun onDestroy() { diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt index 8ee9b37c..59a54bf1 100644 --- a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt @@ -1,9 +1,64 @@ package com.going.presentation.preferencetag.entertrip +import android.util.Log +import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope import com.going.domain.entity.PreferenceData +import com.going.domain.entity.request.EnterPreferenceRequestModel +import com.going.domain.entity.response.EnterPreferenceModel +import com.going.domain.repository.EnterPreferenceRepository +import com.going.ui.extension.UiState +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.launch +import javax.inject.Inject -class EnterPreferenceViewModel : ViewModel() { +@HiltViewModel +class EnterPreferenceViewModel @Inject constructor( + private val enterPreferenceRepository: EnterPreferenceRepository +) : ViewModel() { + + private val _enterPreferenceListState = + MutableStateFlow>(UiState.Empty) + val enterPreferenceListState: StateFlow> get() = _enterPreferenceListState + + val title = MutableLiveData("") + val startDate = MutableLiveData("") + val endDate = MutableLiveData("") + val styleA = MutableLiveData(0) + val styleB = MutableLiveData(0) + val styleC = MutableLiveData(0) + val styleD = MutableLiveData(0) + val styleE = MutableLiveData(0) + + fun getTripInfoFromServer() { + _enterPreferenceListState.value = UiState.Loading + viewModelScope.launch { + enterPreferenceRepository.postTripInfo( + EnterPreferenceRequestModel( + title.value ?: "", + startDate.value ?: "", + endDate.value ?: "", + styleA.value ?: 0, + styleB.value ?: 0, + styleC.value ?: 0, + styleD.value ?: 0, + styleE.value ?: 0 + ) + ) + .onSuccess { + Log.d("LYB", "뷰모델에서 성공힘") + _enterPreferenceListState.value = UiState.Success(it) + } + .onFailure { + Log.d("LYB", "뷰모델에서 실패함") + Log.d("LYB", it.message.orEmpty()) + _enterPreferenceListState.value = UiState.Failure(it.message.orEmpty()) + } + } + } val preferenceTagList = listOf( PreferenceData( From 15aef1ff87643307928778f5dca7e30c10385d5e Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sun, 14 Jan 2024 22:54:55 +0900 Subject: [PATCH 4/9] =?UTF-8?q?[FEAT/#96]=20=EC=97=AC=ED=96=89=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=84=9C=EB=B2=84=ED=86=B5=EC=8B=A0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 4 ++-- .../com/going/doorip/di/RetrofitModule.kt | 2 +- .../{ => dto}/interceptor/AuthInterceptor.kt | 2 +- .../EnterPreferenceRepositoryImpl.kt | 1 - .../preferencetag/PreferenceTagViewModel.kt | 1 + .../entertrip/EnterPreferenceActivity.kt | 19 ++++++++++--------- .../entertrip/EnterPreferenceViewModel.kt | 3 --- 7 files changed, 15 insertions(+), 17 deletions(-) rename data/src/main/java/com/going/data/{ => dto}/interceptor/AuthInterceptor.kt (99%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 92d1f955..f262d76a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -67,7 +67,7 @@ ( PreferenceData( number = "01", diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt index c8132c53..97ca8acb 100644 --- a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt +++ b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt @@ -2,10 +2,10 @@ package com.going.presentation.preferencetag.entertrip import android.content.Intent import android.os.Bundle -import android.util.Log import androidx.activity.viewModels import androidx.core.content.ContextCompat import androidx.lifecycle.flowWithLifecycle +import androidx.lifecycle.lifecycleScope import com.going.domain.entity.PreferenceData import com.going.presentation.R import com.going.presentation.databinding.ActivityEnterPreferenceBinding @@ -28,6 +28,7 @@ import com.going.ui.extension.UiState 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 @@ -92,13 +93,14 @@ class EnterPreferenceActivity : if (infoList != null) { title = intent.getStringExtra(NAME) val startYear = intent.getIntExtra(START_YEAR, 0) - val startMonth = intent.getIntExtra(START_MONTH, 0) - val startDay = intent.getIntExtra(START_DAY, 0) + val startMonth = String.format(TWO_DIGIT_FORMAT, intent.getIntExtra(START_MONTH, 0)) + val startDay = String.format(TWO_DIGIT_FORMAT, intent.getIntExtra(START_DAY, 0)) val endYear = intent.getIntExtra(END_YEAR, 0) - val endMonth = intent.getIntExtra(END_MONTH, 0) - val endDay = intent.getIntExtra(END_DAY, 0) + val endMonth = String.format(TWO_DIGIT_FORMAT, intent.getIntExtra(END_MONTH, 0)) + val endDay = String.format(TWO_DIGIT_FORMAT, intent.getIntExtra(END_DAY, 0)) - startDate = String.format(SERVER_DATE, startYear, startMonth, startDay) + startDate = + String.format(SERVER_DATE, startYear, startMonth, startDay) endDate = String.format(SERVER_DATE, endYear, endMonth, endDay) } @@ -107,7 +109,6 @@ class EnterPreferenceActivity : private fun initStartBtnClickListener() { binding.btnPreferenceStart.setOnSingleClickListener { viewModel.getTripInfoFromServer() - toast("버튼 눌림") } } @@ -115,7 +116,6 @@ class EnterPreferenceActivity : viewModel.enterPreferenceListState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { is UiState.Success -> { - Log.d("LYB", "성공힘") Intent(this, InviteFinishActivity::class.java).apply { putExtra(TITLE, state.data.title) putExtra(START, state.data.startDate) @@ -132,7 +132,7 @@ class EnterPreferenceActivity : is UiState.Empty -> return@onEach } - } + }.launchIn(lifecycleScope) } private fun sendTripInfo() { @@ -159,5 +159,6 @@ class EnterPreferenceActivity : companion object { const val SERVER_DATE = "%s.%s.%s" + const val TWO_DIGIT_FORMAT = "%02d" } } \ No newline at end of file diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt index 59a54bf1..318625ce 100644 --- a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceViewModel.kt @@ -49,12 +49,9 @@ class EnterPreferenceViewModel @Inject constructor( ) ) .onSuccess { - Log.d("LYB", "뷰모델에서 성공힘") _enterPreferenceListState.value = UiState.Success(it) } .onFailure { - Log.d("LYB", "뷰모델에서 실패함") - Log.d("LYB", it.message.orEmpty()) _enterPreferenceListState.value = UiState.Failure(it.message.orEmpty()) } } From 7356d672547e4ca836cdf1a1f729327a5806a091 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sun, 14 Jan 2024 22:56:34 +0900 Subject: [PATCH 5/9] =?UTF-8?q?[FEAT/#96]=20=ED=99=94=EB=A9=B4=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../preferencetag/entertrip/EnterPreferenceActivity.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt index 97ca8acb..516be281 100644 --- a/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt +++ b/presentation/src/main/java/com/going/presentation/preferencetag/entertrip/EnterPreferenceActivity.kt @@ -23,6 +23,7 @@ import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion. import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.START_DAY import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.START_MONTH import com.going.presentation.starttrip.createtrip.CreateTripActivity.Companion.START_YEAR +import com.going.presentation.starttrip.finishtrip.FinishTripActivity import com.going.ui.base.BaseActivity import com.going.ui.extension.UiState import com.going.ui.extension.setOnSingleClickListener @@ -116,7 +117,7 @@ class EnterPreferenceActivity : viewModel.enterPreferenceListState.flowWithLifecycle(lifecycle).onEach { state -> when (state) { is UiState.Success -> { - Intent(this, InviteFinishActivity::class.java).apply { + Intent(this, FinishTripActivity::class.java).apply { putExtra(TITLE, state.data.title) putExtra(START, state.data.startDate) putExtra(END, state.data.endDate) From ebf2824f9ed1769e47b01c3e46452479b9287b40 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Sun, 14 Jan 2024 22:58:07 +0900 Subject: [PATCH 6/9] =?UTF-8?q?[FIX/#96]=20=EC=BD=94=EB=93=9C=20=EC=B5=9C?= =?UTF-8?q?=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 2 +- .../domain/entity/response/EnterPreferenceModel.kt | 12 ++++++------ .../preferencetag/PreferenceTagAdapter.kt | 6 ++---- .../preferencetag/PreferenceTagDecoration.kt | 2 +- .../entertrip/EnterPreferenceViewModel.kt | 1 - 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f262d76a..c2ef3504 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -102,7 +102,7 @@ Date: Sun, 14 Jan 2024 23:51:58 +0900 Subject: [PATCH 7/9] =?UTF-8?q?[FIX/#96]=20=EC=BB=A8=ED=94=8C=EB=A6=AD=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../starttrip/createtrip/BottomSheetDateContentFragment.kt | 2 +- .../starttrip/createtrip/EnterPreferenceActivity.kt | 2 +- .../starttrip/createtrip/EnterPreferenceViewModel.kt | 2 +- .../entertrip/starttrip/createtrip/EnterTripActivity.kt | 2 +- .../entertrip/starttrip/createtrip/FinishTripActivity.kt | 7 +++---- .../entertrip/starttrip/createtrip/FinishTripViewModel.kt | 2 +- .../entertrip/starttrip/invitetrip/CreateTripActivity.kt | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/BottomSheetDateContentFragment.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/BottomSheetDateContentFragment.kt index 2383950f..06c36a79 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/BottomSheetDateContentFragment.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/BottomSheetDateContentFragment.kt @@ -53,7 +53,7 @@ class BottomSheetDateContentFragment(val viewModel: CreateTripViewModel, val isS calendar.set(Calendar.DAY_OF_MONTH, viewModel.endDay.value ?: 0) val endDate = calendar.time - if(startDate.before(endDate)) { + if (startDate.before(endDate)) { dismiss() } else { toast(getString(R.string.create_trip_toast_error)) diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceActivity.kt index 7a23ccaa..34abcc1c 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceActivity.kt @@ -1,4 +1,4 @@ -package com.going.presentation.preferencetag.entertrip +package com.going.presentation.entertrip.starttrip.createtrip import android.content.Intent import android.os.Bundle diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceViewModel.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceViewModel.kt index 552729de..23eb4b92 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceViewModel.kt @@ -1,4 +1,4 @@ -package com.going.presentation.preferencetag.entertrip +package com.going.presentation.entertrip.starttrip.createtrip import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterTripActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterTripActivity.kt index 6f2c7ac4..58ee2cf2 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterTripActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterTripActivity.kt @@ -10,8 +10,8 @@ import androidx.lifecycle.lifecycleScope import com.going.domain.entity.CodeState import com.going.presentation.R import com.going.presentation.databinding.ActivityEnterTripBinding -import com.going.presentation.entertrip.starttrip.invitetrip.InviteFinishActivity import com.going.presentation.entertrip.starttrip.StartTripSplashActivity +import com.going.presentation.entertrip.starttrip.invitetrip.InviteFinishActivity import com.going.ui.base.BaseActivity import com.going.ui.extension.UiState import com.going.ui.extension.setOnSingleClickListener diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripActivity.kt index 62b062fb..dda54271 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripActivity.kt @@ -7,8 +7,8 @@ import android.content.Intent import android.os.Bundle import androidx.activity.viewModels import com.going.presentation.R +import com.going.presentation.dashboard.DashBoardActivity import com.going.presentation.databinding.ActivityFinishTripBinding -import com.going.presentation.preferencetag.entertrip.EnterPreferenceActivity import com.going.ui.base.BaseActivity import com.going.ui.extension.setOnSingleClickListener @@ -42,15 +42,14 @@ class FinishTripActivity : private fun initEnterTripBtnClickListener() { binding.btnFinishTripEnterTrip.setOnSingleClickListener { - Intent(this, EnterPreferenceActivity::class.java).apply { + Intent(this, DashBoardActivity::class.java).apply { startActivity(this) - //입장 코드 받아서 보내기 } finish() } } -// private fun checkDayLeft(){ + // private fun checkDayLeft(){ // 그 전 뷰에서 서버 붙여서 보내주는 day 값 알게 되면 맞게 로직 구현하겠습니다 // if(dayLeft > 0) { // binding.tvFinishTripDayLeft.text = dayLeft diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripViewModel.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripViewModel.kt index 77c77819..a6a1982c 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripViewModel.kt @@ -2,7 +2,7 @@ package com.going.presentation.entertrip.starttrip.createtrip import androidx.lifecycle.ViewModel -class FinishTripViewModel : ViewModel(){ +class FinishTripViewModel : ViewModel() { val INVITE_CODE = "a1b2c3" } diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/invitetrip/CreateTripActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/invitetrip/CreateTripActivity.kt index e24a94ff..e213ef53 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/invitetrip/CreateTripActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/invitetrip/CreateTripActivity.kt @@ -10,7 +10,7 @@ import com.going.presentation.R import com.going.presentation.databinding.ActivityCreateTripBinding import com.going.presentation.entertrip.starttrip.StartTripSplashActivity import com.going.presentation.entertrip.starttrip.createtrip.BottomSheetDateContentFragment -import com.going.presentation.preferencetag.entertrip.EnterPreferenceActivity +import com.going.presentation.entertrip.starttrip.createtrip.EnterPreferenceActivity import com.going.ui.base.BaseActivity import com.going.ui.extension.setOnSingleClickListener From b6f079bb201f6ad40c23db05723a09c60428d400 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Mon, 15 Jan 2024 01:11:34 +0900 Subject: [PATCH 8/9] =?UTF-8?q?[FEAT/#96]=20=EC=95=A1=ED=8B=B0=EB=B9=84?= =?UTF-8?q?=ED=8B=B0=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/DashBoardActivity.kt | 12 +++++ .../createtrip/EnterPreferenceActivity.kt | 3 +- .../starttrip/createtrip/EnterTripActivity.kt | 1 + .../createtrip/FinishTripActivity.kt | 48 +++++++++++++------ .../createtrip/FinishTripViewModel.kt | 8 ---- .../main/res/layout/activity_finish_trip.xml | 3 -- presentation/src/main/res/values/strings.xml | 2 +- 7 files changed, 50 insertions(+), 27 deletions(-) delete mode 100644 presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripViewModel.kt diff --git a/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt b/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt index 6b4d73bd..6897a075 100644 --- a/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt +++ b/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt @@ -1,10 +1,13 @@ package com.going.presentation.dashboard +import android.content.Intent import android.os.Bundle import androidx.activity.viewModels import com.going.presentation.R import com.going.presentation.databinding.ActivityTripDashBoardBinding +import com.going.presentation.entertrip.starttrip.invitetrip.CreateTripActivity import com.going.ui.base.BaseActivity +import com.going.ui.extension.setOnSingleClickListener import com.google.android.material.tabs.TabLayoutMediator import dagger.hilt.android.AndroidEntryPoint @@ -22,6 +25,7 @@ class DashBoardActivity : setTabLayout() setViewPager() setTravelerName() + initCreateTripBtnClickListener() } @@ -51,6 +55,14 @@ class DashBoardActivity : } } + private fun initCreateTripBtnClickListener() { + binding.btnDashboardCreateTrip.setOnSingleClickListener { + Intent(this, CreateTripActivity::class.java).apply { + startActivity(this) + } + } + } + companion object { const val TAB_ONGOING = "진행중인 여행" const val TAB_COMPLETED = "지나간 여행" diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceActivity.kt index 34abcc1c..4b88f291 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterPreferenceActivity.kt @@ -9,11 +9,11 @@ import androidx.lifecycle.lifecycleScope import com.going.domain.entity.PreferenceData import com.going.presentation.R import com.going.presentation.databinding.ActivityEnterPreferenceBinding +import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.CODE import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.DAY import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.END import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.START import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.TITLE -import com.going.presentation.entertrip.starttrip.createtrip.FinishTripActivity import com.going.presentation.entertrip.starttrip.invitetrip.CreateTripActivity.Companion.END_DAY import com.going.presentation.entertrip.starttrip.invitetrip.CreateTripActivity.Companion.END_MONTH import com.going.presentation.entertrip.starttrip.invitetrip.CreateTripActivity.Companion.END_YEAR @@ -120,6 +120,7 @@ class EnterPreferenceActivity : putExtra(TITLE, state.data.title) putExtra(START, state.data.startDate) putExtra(END, state.data.endDate) + putExtra(CODE, state.data.code) putExtra(DAY, state.data.day) startActivity(this) } diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterTripActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterTripActivity.kt index 58ee2cf2..56b4e273 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterTripActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/EnterTripActivity.kt @@ -123,6 +123,7 @@ class EnterTripActivity : BaseActivity(R.layout.activi const val TITLE = "title" const val START = "start" const val END = "end" + const val CODE = "code" const val DAY = "day" } diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripActivity.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripActivity.kt index dda54271..d89fa2b3 100644 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripActivity.kt +++ b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripActivity.kt @@ -5,31 +5,40 @@ import android.content.ClipboardManager import android.content.Context import android.content.Intent import android.os.Bundle -import androidx.activity.viewModels import com.going.presentation.R import com.going.presentation.dashboard.DashBoardActivity import com.going.presentation.databinding.ActivityFinishTripBinding +import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.DAY +import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.END +import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.START +import com.going.presentation.entertrip.starttrip.createtrip.EnterTripActivity.Companion.TITLE +import com.going.presentation.entertrip.starttrip.invitetrip.InviteFinishActivity.Companion.DATE_FORMAT +import com.going.presentation.entertrip.starttrip.invitetrip.InviteFinishActivity.Companion.D_DAY_FORMAT +import com.going.presentation.entertrip.starttrip.invitetrip.InviteFinishActivity.Companion.TRIP_FORMAT import com.going.ui.base.BaseActivity import com.going.ui.extension.setOnSingleClickListener +import com.kakao.sdk.auth.Constants.CODE class FinishTripActivity : BaseActivity(R.layout.activity_finish_trip) { - private val viewModel by viewModels() + + private var inviteCode: String? = "" override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + getTripInfo() initCopyCodetvClickListener() initSendCodeBtnClickListener() initEnterTripBtnClickListener() - //checkDayLeft() + } private fun initCopyCodetvClickListener() { binding.tvFinishTripTermsText.setOnSingleClickListener { val clipboardManager = this.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - val clipData = ClipData.newPlainText("INVITE_CODE_LABEL", viewModel.INVITE_CODE) + val clipData = ClipData.newPlainText("INVITE_CODE_LABEL", inviteCode) clipboardManager.setPrimaryClip(clipData) } } @@ -49,16 +58,27 @@ class FinishTripActivity : } } - // private fun checkDayLeft(){ -// 그 전 뷰에서 서버 붙여서 보내주는 day 값 알게 되면 맞게 로직 구현하겠습니다 -// if(dayLeft > 0) { -// binding.tvFinishTripDayLeft.text = dayLeft -// }else{ -// binding.tvFinishTripDayLeft.text = -// } -// } - companion object { - const val INVITE_CODE_LABEL = "Invite Code" + private fun getTripInfo() { + val intent = getIntent() + + if (intent != null) { + val title = intent.getStringExtra(TITLE) + val start = intent.getStringExtra(START) + val end = intent.getStringExtra(END) + val code = intent.getStringExtra(CODE) + val day = intent.getIntExtra(DAY, 0) + + binding.tvFinishTripName.text = title + binding.tvFinishTripDay.text = String.format(DATE_FORMAT, start, end) + binding.tvInviteCode.text = code + + if (day > 0) { + binding.tvFinishTripDayLeft.text = String.format(D_DAY_FORMAT, day) + } else { + binding.tvFinishTripDayLeft.text = TRIP_FORMAT + } + } } + } diff --git a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripViewModel.kt b/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripViewModel.kt deleted file mode 100644 index a6a1982c..00000000 --- a/presentation/src/main/java/com/going/presentation/entertrip/starttrip/createtrip/FinishTripViewModel.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.going.presentation.entertrip.starttrip.createtrip - -import androidx.lifecycle.ViewModel - -class FinishTripViewModel : ViewModel() { - val INVITE_CODE = "a1b2c3" -} - diff --git a/presentation/src/main/res/layout/activity_finish_trip.xml b/presentation/src/main/res/layout/activity_finish_trip.xml index 659dcd7b..2cbf0494 100644 --- a/presentation/src/main/res/layout/activity_finish_trip.xml +++ b/presentation/src/main/res/layout/activity_finish_trip.xml @@ -5,9 +5,6 @@ - %s님의 여행 새로운 여행을 시작해 보세요 - 여행 생성하기 + 여행 추가하기 여행종료 - D - %d From 3fb074692aef73ffd5b1fd2ecb927bc008b59e61 Mon Sep 17 00:00:00 2001 From: LEE YOU BIN Date: Mon, 15 Jan 2024 01:18:10 +0900 Subject: [PATCH 9/9] =?UTF-8?q?[FIX/#96]=20=EC=BD=94=EB=93=9C=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../going/presentation/dashboard/DashBoardActivity.kt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt b/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt index 6897a075..6ede4803 100644 --- a/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt +++ b/presentation/src/main/java/com/going/presentation/dashboard/DashBoardActivity.kt @@ -57,9 +57,13 @@ class DashBoardActivity : private fun initCreateTripBtnClickListener() { binding.btnDashboardCreateTrip.setOnSingleClickListener { - Intent(this, CreateTripActivity::class.java).apply { - startActivity(this) - } + navigateToDashboard() + } + } + + private fun navigateToDashboard() { + Intent(this, CreateTripActivity::class.java).apply { + startActivity(this) } }