Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13 [feat] 온보딩 테마 선택 뷰 #16

Merged
merged 14 commits into from
Jan 10, 2024

Conversation

emjayMJkim
Copy link
Member

@emjayMJkim emjayMJkim commented Jan 9, 2024

📑 Work Description

  • 온보딩 뷰 테마 선택 구현 완
  • 테마 4번째 아이템 클릭 비활성화 + 토스트 메시지 띄우기
  • 테마 3개 선택 시 버튼 활성화

🛠️ Issue

📷 Screenshot

feat.onboarding-theme.choice.webm

💬 To Reviewers

@emjayMJkim emjayMJkim self-assigned this Jan 9, 2024
@emjayMJkim emjayMJkim added Pull Request pr 날림! Feat 새로운 기능 추가 민정🦊 민정이가 작업함! labels Jan 9, 2024
Copy link
Contributor

@stellar-halo stellar-halo left a comment

Choose a reason for hiding this comment

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

넘 든든하네요,, 최고!

  • 변수는 항상 class의 맨 위에 있어야 합니다!
  • 반복되는 부분은 함수나 변수로 빼주세요! 코틀린은 변수에 함수도 넣을 수 있으니까요~ 🧸

Comment on lines 49 to 51
private val _layoutTranslucent: MutableLiveData<Boolean> = MutableLiveData(false)
val layoutTranslucent: LiveData<Boolean>
get() = _layoutTranslucent
Copy link
Contributor

Choose a reason for hiding this comment

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

변수 맨 위로 올려주세요~

Copy link
Member Author

Choose a reason for hiding this comment

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

헉 이게 무슨 일이죠... 바로 고치겠습니닷

Comment on lines 31 to 36
private var onItemClickListener: ((Theme) -> Unit)? = null
fun setOnThemeClickListener(listener: (Theme) -> Unit) {
onItemClickListener = listener
}

var selectedThemeArray = arrayListOf<Int>()
Copy link
Contributor

Choose a reason for hiding this comment

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

마찬가지 입니다! 변수들은 클래스의 맨 위에 올려주세요!

Copy link
Member Author

Choose a reason for hiding this comment

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

오우 감사합니다!!

var selectedThemeArray = arrayListOf<Int>()

private fun themeSelection(binding: ItemOnboardingChoiceThemeBinding, theme: Theme) {
if (selectedThemeArray.size == 3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

3도 MAXIMUM_어쩌구,, 같이 companion으로 빼주세요!

Copy link
Member Author

Choose a reason for hiding this comment

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

정말 이런 발견 너무 감사합니다..


private fun themeSelection(binding: ItemOnboardingChoiceThemeBinding, theme: Theme) {
if (selectedThemeArray.size == 3) {
if (selectedThemeArray.contains(theme.themeId)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

var isSelected = selectedThemeArray.contains(theme.themeId)

이렇게 boolean을 가지는 변수는 is로 시작하는 것이 좋습니다! (+ 가독성, 재사용성을 위해 변수로 뺀 다음 if문에 넣어주세요~

Copy link
Member Author

Choose a reason for hiding this comment

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

네엡! 수정했습니당

Comment on lines 41 to 47
selectedThemeArray.removeAt(selectedThemeArray.indexOf(theme.themeId))
changeThemeBackground(binding, false)
}
} else {
if (selectedThemeArray.contains(theme.themeId)) {
selectedThemeArray.removeAt(selectedThemeArray.indexOf(theme.themeId))
changeThemeBackground(binding, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

selectedThemeArray.removeAt(selectedThemeArray.indexOf(theme.themeId))
                changeThemeBackground(binding, false)

반복되는 코드이니 함수로 따로 빼는 것이 어떨까요~?
fun removeItem 같이 따로 빼주세요!

Copy link
Member Author

Choose a reason for hiding this comment

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

함수로 따로 빼주는 게 더 좋을 것 같네요! 수정하겠습니다

Comment on lines 44 to 45
binding.tvOnboardingChoiceThemeSpeech.text =
getString(R.string.onboarding_choice_theme_speech_after)
Copy link
Contributor

Choose a reason for hiding this comment

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

바꾸라는 건 아니고 전 삼항 연산자^^,,를 선호하는 편이긴 합니다!
click하면 liveData 값을 true로 바꾼 뒤(or false) xml에서 string을 처리하긴 해요
이건 스타일 선호 차이니까 선호하시는 거로 작업하세요~


private fun setThemeBtn() {
viewModel.selectedThemeArray.observe(viewLifecycleOwner) {
if (it.size == 3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

3 마찬가지입니다~ 여기서 따로 빼고 adapter에서 받아서 써도 되겠네요!

android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/onboarding_translucent"
android:visibility="@{viewModel.layoutTranslucent ? View.VISIBLE : View.GONE}"
Copy link
Contributor

Choose a reason for hiding this comment

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

^--^
여기서 이미 layoutTranslucent으로 삼항 연산자를 처리하고 계시네요!
그렇다면 이참에 string 값도 layoutTranslucent값을 이용해서 삼항 연산자로 처리해볼까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

네엡!!

Copy link
Collaborator

@pump9918 pump9918 left a comment

Choose a reason for hiding this comment

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

background 잘 설정한 거 같은데 왜 시연영상은 색이 다르게 보이는걸까요... 디스플레이 이슈인가 고생하셨습니다!

@@ -16,10 +18,55 @@ class ChoiceThemeAdapter :
)
) {

class ChoiceThemeViewHolder(private val binding: ItemOnboardingChoiceThemeBinding) :
inner class ChoiceThemeViewHolder(private val binding: ItemOnboardingChoiceThemeBinding) :
Copy link
Collaborator

Choose a reason for hiding this comment

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

내부에 inner 클래스를 선언하는게 ViewHolder를 따로 파는 것과 차이가 있나요?(그냥 궁금)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

@emjayMJkim emjayMJkim Jan 10, 2024

Choose a reason for hiding this comment

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

저는 clicklistener 때문에 inner class로 만들었습니다! 메모리 누수 문제는 destroy되면 메모리 해제할 수 있도록 수정했습니다!

Copy link
Member

@minemi00 minemi00 left a comment

Choose a reason for hiding this comment

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

수고하셨습니당!

Comment on lines 48 to 53
if (selectedThemeArray.contains(theme.themeId)) {
selectedThemeArray.removeAt(selectedThemeArray.indexOf(theme.themeId))
changeThemeBackground(binding, false)
} else {
selectedThemeArray.add(theme.themeId)
changeThemeBackground(binding, true)
Copy link
Member

Choose a reason for hiding this comment

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

선택된 테마 id가 포함되어 있으면 해당 id의 인덱스가 삭제되는 건가여../?

Copy link
Member Author

Choose a reason for hiding this comment

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

네 맞습니당!

Copy link
Contributor

@stellar-halo stellar-halo left a comment

Choose a reason for hiding this comment

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

고생했어요~!~!

@@ -42,7 +88,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="14dp"
android:text="@string/onboarding_choice_theme_speech"
android:text="@{themeViewModel.layoutTranslucent ? @string/onboarding_choice_theme_speech : @string/onboarding_choice_theme_speech_after}"
Copy link
Contributor

Choose a reason for hiding this comment

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

💞💞💞

@emjayMJkim emjayMJkim merged commit 3a962a1 into develop Jan 10, 2024
1 check passed
@emjayMJkim emjayMJkim deleted the feature/#13-onboarding-theme branch January 10, 2024 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feat 새로운 기능 추가 Pull Request pr 날림! 민정🦊 민정이가 작업함!
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[feat] 온보딩 - 테마 선택
4 participants