diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 44a0a501..533d067a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -43,6 +43,14 @@ + + + + diff --git a/domain/src/main/kotlin/com/going/domain/entity/TendencyTestMock.kt b/domain/src/main/kotlin/com/going/domain/entity/TendencyTestMock.kt new file mode 100644 index 00000000..b7bd82da --- /dev/null +++ b/domain/src/main/kotlin/com/going/domain/entity/TendencyTestMock.kt @@ -0,0 +1,9 @@ +package com.going.domain.entity + +data class TendencyTestMock( + val question: String, + val firstAnswer: String, + val secondAnswer: String, + val thirdAnswer: String, + val fourthAnswer: String, +) diff --git a/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestActivity.kt b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestActivity.kt index 0686414d..ac79c066 100644 --- a/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestActivity.kt +++ b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestActivity.kt @@ -1,22 +1,121 @@ package com.going.presentation.tendencytest +import android.animation.Animator +import android.animation.ObjectAnimator import android.os.Bundle +import android.view.animation.DecelerateInterpolator +import android.widget.ProgressBar +import androidx.activity.viewModels import com.going.presentation.R -import com.going.presentation.databinding.ActivityTendencyTestSplashBinding +import com.going.presentation.databinding.ActivityTendencyTestBinding import com.going.ui.base.BaseActivity import com.going.ui.extension.setOnSingleClickListener class TendencyTestActivity : - BaseActivity(R.layout.activity_tendency_test_splash) { + BaseActivity(R.layout.activity_tendency_test) { + + private lateinit var fadeInList: List + private lateinit var fadeOutList: List + + private val viewModel by viewModels() + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - initStartBtnSingleClickListener() + initBindingViewModel() + initFadeAnimation() + initFadeListener() + initNextBtnClickListener() + } + + private fun initBindingViewModel() { + binding.viewModel = viewModel + } + + private fun initFadeAnimation() { + fadeOutList = listOf( + ObjectAnimator.ofFloat(binding.tvFirstAnswer, "alpha", 1f, 0f).apply { + duration = DURATION + }, + ObjectAnimator.ofFloat(binding.tvSecondAnswer, "alpha", 1f, 0f).apply { + duration = DURATION + }, + ObjectAnimator.ofFloat(binding.tvThirdAnswer, "alpha", 1f, 0f).apply { + duration = DURATION + }, + ObjectAnimator.ofFloat(binding.tvFourthAnswer, "alpha", 1f, 0f).apply { + duration = DURATION + }, + ) + + fadeInList = listOf( + ObjectAnimator.ofFloat(binding.tvFirstAnswer, "alpha", 0f, 1f).apply { + duration = DURATION + }, + ObjectAnimator.ofFloat(binding.tvSecondAnswer, "alpha", 0f, 1f).apply { + duration = DURATION + }, + ObjectAnimator.ofFloat(binding.tvThirdAnswer, "alpha", 0f, 1f).apply { + duration = DURATION + }, + ObjectAnimator.ofFloat(binding.tvFourthAnswer, "alpha", 0f, 1f).apply { + duration = DURATION + }, + ) + } + + private fun initFadeListener() { + fadeOutList[0].addListener( + object : Animator.AnimatorListener { + override fun onAnimationStart(animation: Animator) { + viewModel.clearAllChecked() + setProgressAnimate(binding.pbTendencyTest, viewModel.step.value + 1) + fadeOutList.map { + it.start() + } + } + + override fun onAnimationEnd(animation: Animator) { + viewModel.plusStepValue() + + fadeInList.map { + it.start() + } + } + + override fun onAnimationCancel(animation: Animator) { + // + } + + override fun onAnimationRepeat(animation: Animator) { + // + } + }, + ) } - private fun initStartBtnSingleClickListener() { - binding.btnTendencySplashStart.setOnSingleClickListener { - // 페이지 이동~ + private fun setProgressAnimate(pb: ProgressBar, progressTo: Int) = + ObjectAnimator.ofInt(pb, "progress", pb.progress, progressTo * 100).apply { + duration = DURATION + setAutoCancel(true) + interpolator = DecelerateInterpolator() + start() + } + + private fun initNextBtnClickListener() { + binding.btnTendencyNext.setOnSingleClickListener { + when (viewModel.step.value) { + 9 -> moveTendencyTestResultActivity() + else -> fadeOutList[0].start() + } } } + + private fun moveTendencyTestResultActivity() { + // 페이지 이동 기능 추가 예정 + } + + companion object { + const val DURATION = 500L + } } diff --git a/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestSplashActivity.kt b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestSplashActivity.kt new file mode 100644 index 00000000..8f6d7b38 --- /dev/null +++ b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestSplashActivity.kt @@ -0,0 +1,22 @@ +package com.going.presentation.tendencytest + +import android.os.Bundle +import com.going.presentation.R +import com.going.presentation.databinding.ActivityTendencyTestSplashBinding +import com.going.ui.base.BaseActivity +import com.going.ui.extension.setOnSingleClickListener + +class TendencyTestSplashActivity : + BaseActivity(R.layout.activity_tendency_test_splash) { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + initStartBtnSingleClickListener() + } + + private fun initStartBtnSingleClickListener() { + binding.btnTendencySplashStart.setOnSingleClickListener { + // 페이지 이동~ + } + } +} diff --git a/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestViewModel.kt b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestViewModel.kt new file mode 100644 index 00000000..52c07490 --- /dev/null +++ b/presentation/src/main/java/com/going/presentation/tendencytest/TendencyTestViewModel.kt @@ -0,0 +1,112 @@ +package com.going.presentation.tendencytest + +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import com.going.domain.entity.TendencyTestMock +import kotlinx.coroutines.flow.MutableStateFlow + +class TendencyTestViewModel : ViewModel() { + val step = MutableStateFlow(1) + val isChecked = MutableLiveData(false) + val isFirstChecked = MutableLiveData(false) + val isSecondChecked = MutableLiveData(false) + val isThirdChecked = MutableLiveData(false) + val isFourthChecked = MutableLiveData(false) + + val tendencyResultList: MutableList = MutableList(9) { 0 } + + val mockList: List = listOf( + TendencyTestMock( + "1번 문항", + "1-1", + "1-2", + "1-3", + "1-4", + ), + TendencyTestMock( + "2번 문항", + "2-1", + "2-2", + "2-3", + "2-4", + ), + TendencyTestMock( + "3번 문항", + "3-1", + "3-2", + "3-3", + "3-4", + ), + TendencyTestMock( + "4번 문항", + "4-1", + "4-2", + "4-3", + "4-4", + ), + TendencyTestMock( + "5번 문항", + "5-1", + "5-2", + "5-3", + "5-4", + ), + TendencyTestMock( + "6번 문항", + "6-1", + "6-2", + "6-3", + "6-4", + ), + TendencyTestMock( + "7번 문항", + "7-1", + "7-2", + "7-3", + "7-4", + ), + TendencyTestMock( + "8번 문항", + "8-1", + "8-2", + "8-3", + "8-4", + ), + TendencyTestMock( + "9번 문항", + "9-1", + "9-2", + "9-3", + "9-4", + ), + ) + + fun plusStepValue() { + step.value = step.value.plus(1) + } + + fun setCheckedValue(id: Int) { + clearAllChecked() + isChecked.value = true + tendencyResultList[step.value - 1] = id + + when (id) { + 1 -> isFirstChecked.value = true + 2 -> isSecondChecked.value = true + 3 -> isThirdChecked.value = true + 4 -> isFourthChecked.value = true + } + } + + fun clearAllChecked() { + isChecked.value = false + isFirstChecked.value = false + isSecondChecked.value = false + isThirdChecked.value = false + isFourthChecked.value = false + } + + companion object { + const val MAX_STEP = 9 + } +} diff --git a/presentation/src/main/res/drawable/ll_progressbar.xml b/presentation/src/main/res/drawable/ll_progressbar.xml new file mode 100644 index 00000000..ace40d42 --- /dev/null +++ b/presentation/src/main/res/drawable/ll_progressbar.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/drawable/sel_radiobutton.xml b/presentation/src/main/res/drawable/sel_radiobutton.xml new file mode 100644 index 00000000..0a7808a7 --- /dev/null +++ b/presentation/src/main/res/drawable/sel_radiobutton.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/drawable/sel_radiobutton_checked.xml b/presentation/src/main/res/drawable/sel_radiobutton_checked.xml new file mode 100644 index 00000000..18735f5f --- /dev/null +++ b/presentation/src/main/res/drawable/sel_radiobutton_checked.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/presentation/src/main/res/drawable/sel_radiobutton_unchecked.xml b/presentation/src/main/res/drawable/sel_radiobutton_unchecked.xml new file mode 100644 index 00000000..ea534d53 --- /dev/null +++ b/presentation/src/main/res/drawable/sel_radiobutton_unchecked.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/presentation/src/main/res/layout/activity_onboarding_profile_setting.xml b/presentation/src/main/res/layout/activity_onboarding_profile_setting.xml index 42a98600..f5174750 100644 --- a/presentation/src/main/res/layout/activity_onboarding_profile_setting.xml +++ b/presentation/src/main/res/layout/activity_onboarding_profile_setting.xml @@ -72,7 +72,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="4dp" - android:text="@{@string/text_count(viewModel.nowNameLength, viewModel.MAX_NAME_LEN)}" + android:text="@{@string/counter(viewModel.nowNameLength, viewModel.MAX_NAME_LEN)}" android:textColor="@color/gray_200" app:layout_constraintEnd_toEndOf="@id/et_onboarding_profile_setting_name" app:layout_constraintTop_toBottomOf="@id/et_onboarding_profile_setting_name" /> @@ -109,7 +109,7 @@ android:id="@+id/tv_info_counter" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@{@string/text_count(viewModel.nowInfoLength, viewModel.MAX_INFO_LEN)}" + android:text="@{@string/counter(viewModel.nowInfoLength, viewModel.MAX_INFO_LEN)}" android:textColor="@color/gray_200" app:layout_constraintEnd_toEndOf="@id/et_onboarding_profile_setting_info" app:layout_constraintTop_toBottomOf="@id/et_onboarding_profile_setting_info" /> diff --git a/presentation/src/main/res/layout/activity_tendency_test.xml b/presentation/src/main/res/layout/activity_tendency_test.xml new file mode 100644 index 00000000..a4a80452 --- /dev/null +++ b/presentation/src/main/res/layout/activity_tendency_test.xml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/values/strings.xml b/presentation/src/main/res/values/strings.xml index 56b9abeb..61fafb37 100644 --- a/presentation/src/main/res/values/strings.xml +++ b/presentation/src/main/res/values/strings.xml @@ -12,7 +12,7 @@ 여행을 시작해보세요 개인정보처리방침 - %1$d / %2$d + %1$d/%2$d 프로필 생성 @@ -26,4 +26,9 @@ 9개의 질문으로\n여행 성향을 분석해보세요 시작하기 + + 나의 여행 성향은? + 다음 + 제출하기 + diff --git a/presentation/src/main/res/values/themes.xml b/presentation/src/main/res/values/themes.xml index 7881fa21..f991c4db 100644 --- a/presentation/src/main/res/values/themes.xml +++ b/presentation/src/main/res/values/themes.xml @@ -1,4 +1,4 @@ - + + + + + + +