-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat/onboarding_view]: 온보딩 UI 작업, 뷰 연결 #56
Conversation
# Conflicts: # app/src/main/java/com/hmh/hamyeonham/SampleActivity.kt # feature/onboarding/build.gradle.kts # feature/onboarding/src/main/AndroidManifest.xml # feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingAccessibilityService.kt # feature/onboarding/src/main/java/com/hmh/hamyeonham/feature/onboarding/OnBoardingActivity.kt # feature/onboarding/src/main/res/layout/activity_on_boarding.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트 확인해주시고 일단 클릭시 기능 구현을 완료한 코드까지 올려주시면 감사하겠습니다~!
OnBoardingFragmentType.SELECT_DATA_TIME -> OnBoardingSelectDataFragment.newInstance( | ||
OnBoardingQuestionList.OnBoardingQuestionTime[0], | ||
OnBoardingQuestionList.OnBoardingQuestionTime[1], | ||
OnBoardingQuestionList.OnBoardingQuestionTime[2], | ||
OnBoardingQuestionList.OnBoardingQuestionTime[3], | ||
OnBoardingQuestionList.OnBoardingQuestionTime[4], | ||
OnBoardingQuestionList.OnBoardingQuestionTime[5], | ||
) | ||
|
||
OnBoardingFragmentType.SELECT_DATA_PROBLEM -> OnBoardingSelectDataFragment.newInstance( | ||
OnBoardingQuestionList.OnBoardingQuestionProblem[0], | ||
OnBoardingQuestionList.OnBoardingQuestionProblem[1], | ||
OnBoardingQuestionList.OnBoardingQuestionProblem[2], | ||
OnBoardingQuestionList.OnBoardingQuestionProblem[3], | ||
OnBoardingQuestionList.OnBoardingQuestionProblem[4], | ||
OnBoardingQuestionList.OnBoardingQuestionProblem[5], | ||
) | ||
|
||
OnBoardingFragmentType.SELECT_DATA_PERIOD -> OnBoardingSelectDataFragment.newInstance( | ||
OnBoardingQuestionList.OnBoardingChallengePeriod[0], | ||
OnBoardingQuestionList.OnBoardingChallengePeriod[1], | ||
OnBoardingQuestionList.OnBoardingChallengePeriod[2], | ||
OnBoardingQuestionList.OnBoardingChallengePeriod[3], | ||
OnBoardingQuestionList.OnBoardingChallengePeriod[4], | ||
OnBoardingQuestionList.OnBoardingChallengePeriod[5], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기 싱글톤 리스트 관리가 아닌 dataclass로 객체 생성해서 주입받는 방식을 사용해보면 좋을 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어댑터 내에 enum class로 각 프래그먼트 타입 생성된 것으로 수정 되었습니다~!
var onBoardingFragments: ArrayList<Fragment> = ArrayList() | ||
override fun getItemCount(): Int { | ||
return onBoardingFragments.size | ||
} | ||
|
||
override fun createFragment(position: Int): Fragment { | ||
return onBoardingFragments[position] | ||
} | ||
|
||
fun removeOnboardingFragments() { | ||
onBoardingFragments.removeLast() | ||
} | ||
|
||
fun addOnboardingFragment(fragmentType: OnBoardingFragmentType) { | ||
val fragment = when (fragmentType) { | ||
OnBoardingFragmentType.REQUEST_PERMISSION -> OnBoardingRequestPermissionFragment() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum classd, when문으로 관리해보면 좋을 것 같습니다.
val question = requireArguments().getString(ARG_QUESTION) | ||
val description = requireArguments().getString(ARG_DESCRIPTION) | ||
val btn1 = requireArguments().getString(ARG_BTN1) | ||
val btn2 = requireArguments().getString(ARG_BTN2) | ||
val btn3 = requireArguments().getString(ARG_BTN3) | ||
val btn4 = requireArguments().getString(ARG_BTN4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
스코프함수 활용 ㄱㄱ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val question = requireArguments().getString(ARG_QUESTION) | |
val description = requireArguments().getString(ARG_DESCRIPTION) | |
val btn1 = requireArguments().getString(ARG_BTN1) | |
val btn2 = requireArguments().getString(ARG_BTN2) | |
val btn3 = requireArguments().getString(ARG_BTN3) | |
val btn4 = requireArguments().getString(ARG_BTN4) | |
requireArguments().run { | |
val question = getString(ARG_QUESTION) | |
val description = getString(ARG_DESCRIPTION) | |
val btn1 = getString(ARG_BTN1) | |
val btn2 = getString(ARG_BTN2) | |
val btn3 = getString(ARG_BTN3) | |
val btn4 = getString(ARG_BTN4) | |
} | |
private fun setOnboardingViewPager(pagerAdapter: OnBoardingFragmentStateAdapter) { | ||
val currentItem = binding.vpOnboardingContainer.currentItem | ||
if (currentItem < pagerAdapter.itemCount - 1) { | ||
binding.vpOnboardingContainer.currentItem = currentItem + 1 | ||
} | ||
if (currentItem == pagerAdapter.itemCount - 1) { | ||
pagerAdapter.removeOnboardingFragments() | ||
startActivity( | ||
Intent(this, OnBoardingDoneSingUpActivity::class.java).addFlags( | ||
FLAG_ACTIVITY_NO_ANIMATION, | ||
), | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- pagerAdapter.removeOnboardingFragments() 없애야할 것 같습니다
- startActivity 한 후에 finish
- agerAdapter.itemCount - 1 대신 조금 더 안전한 방법이 필요해요
|
||
binding.run { | ||
npOnboardingScreentimeGoal.minValue = 1 | ||
npOnboardingScreentimeGoal.maxValue = 6 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수 추출 고고
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확장함수로 추출했고, common 모듈에 NumberPickerExt 파일 만들어두었습니다!
binding.run { | ||
npOnboardingUseTimeGoalHour.minValue = 1 | ||
npOnboardingUseTimeGoalHour.maxValue = 6 | ||
npOnboardingUseTimeGoalMinute.minValue = 0 | ||
npOnboardingUseTimeGoalMinute.maxValue = 59 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun NumberPicker.setRangeTime(minValue: Int, maxValue: Int) {
minValue = minValue
maxValue ] maxValue
}
|
||
|
||
<TextView | ||
android:id="@+id/tv_onboarding_done_sing_up_description" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
줄바꿈 고쳐주세요
private fun initFragmentType() { | ||
val args = requireArguments().getString(ARG_FRAGMENT_TYPE)?.toOnboardingFragmentType() | ||
if (args != null) { | ||
viewModel.initQuestionData(args) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요기 이름 변경이 필요해보입니당
private fun initViews() { | ||
viewModel.onBoardingSelectDataState.onEach { | ||
binding.apply { | ||
val onBoardingQuestion = it.onBoardingQuestion | ||
tvOnboardingSelectDataQuestion.text = onBoardingQuestion.title | ||
tvOnboardingSelectDataDescription.text = onBoardingQuestion.description | ||
btnOnboardingSelectData1.text = onBoardingQuestion.options.getOrNull(0).orEmpty() | ||
btnOnboardingSelectData2.text = onBoardingQuestion.options.getOrNull(1).orEmpty() | ||
btnOnboardingSelectData3.text = onBoardingQuestion.options.getOrNull(2).orEmpty() | ||
btnOnboardingSelectData4.text = onBoardingQuestion.options.getOrNull(3).orEmpty() | ||
} | ||
}.launchIn(lifecycleScope) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2차 릴리즈에서는 id에 숫자를 붙이지 않는 방법도 있을지 고려해보면 좋을 것 같긴합니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 기록해두겠습니다!
fun initQuestionData(fragmentType: OnBoardingFragmentType) { | ||
val onBoardingQuestionTime = OnBoardingQuestion( | ||
"하루 평균 휴대폰을\n얼마나 사용하시나요?", | ||
"", | ||
listOf("1-4시간", "4-8시간", "8-12시간", "12시간 이상") | ||
) | ||
|
||
val onBoardingQuestionProblem = OnBoardingQuestion( | ||
"휴대폰을 사용할 때\n어떤 문제를 겪고 계시나요?", | ||
"해당 문항은 최대 2개의 복수 응답이 가능해요", | ||
listOf("중독이 너무 심해요", "무의식적으로 사용하게 돼요", "스스로 제어가 안돼요", "일상생활에 영향을 끼쳐요") | ||
) | ||
|
||
val onBoardingChallengePeriod = OnBoardingQuestion( | ||
"챌린지 기간을 선택해주세요", | ||
"첫 챌린지로 가볍게 도전하기 좋은 7일을 추천해요!", | ||
listOf("7일", "14일", "21일", "30일") | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2차에서는 요 아이들을 어떻게 관리할지도 확인해봐야할 것 같습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
서버로 부터 문항 불러오는 것 2차 논의 사항인데 이것도 기록해두겠습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~!!
개요
작업 사항
변경 사항(optional)
논의 필요한 부분
스크린샷(optional)
기본 기능 구현만 진행했고, pr 확인 후 코드, 파일 구조 디벨롭 진행할 예정입니다.
https://github.com/Team-HMH/HMH-Android/assets/83583757/38b382f4-2c6c-4421-80f4-03767ad61e94