-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
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.
넘 든든하네요,, 최고!
- 변수는 항상 class의 맨 위에 있어야 합니다!
- 반복되는 부분은 함수나 변수로 빼주세요! 코틀린은 변수에 함수도 넣을 수 있으니까요~ 🧸
private val _layoutTranslucent: MutableLiveData<Boolean> = MutableLiveData(false) | ||
val layoutTranslucent: LiveData<Boolean> | ||
get() = _layoutTranslucent |
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.
헉 이게 무슨 일이죠... 바로 고치겠습니닷
private var onItemClickListener: ((Theme) -> Unit)? = null | ||
fun setOnThemeClickListener(listener: (Theme) -> Unit) { | ||
onItemClickListener = listener | ||
} | ||
|
||
var selectedThemeArray = arrayListOf<Int>() |
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.
오우 감사합니다!!
var selectedThemeArray = arrayListOf<Int>() | ||
|
||
private fun themeSelection(binding: ItemOnboardingChoiceThemeBinding, theme: Theme) { | ||
if (selectedThemeArray.size == 3) { |
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.
3도 MAXIMUM_어쩌구,, 같이 companion으로 빼주세요!
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 themeSelection(binding: ItemOnboardingChoiceThemeBinding, theme: Theme) { | ||
if (selectedThemeArray.size == 3) { | ||
if (selectedThemeArray.contains(theme.themeId)) { |
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.
var isSelected = selectedThemeArray.contains(theme.themeId)
이렇게 boolean을 가지는 변수는 is로 시작하는 것이 좋습니다! (+ 가독성, 재사용성을 위해 변수로 뺀 다음 if문에 넣어주세요~
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.
네엡! 수정했습니당
selectedThemeArray.removeAt(selectedThemeArray.indexOf(theme.themeId)) | ||
changeThemeBackground(binding, false) | ||
} | ||
} else { | ||
if (selectedThemeArray.contains(theme.themeId)) { | ||
selectedThemeArray.removeAt(selectedThemeArray.indexOf(theme.themeId)) | ||
changeThemeBackground(binding, false) |
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.
selectedThemeArray.removeAt(selectedThemeArray.indexOf(theme.themeId))
changeThemeBackground(binding, false)
반복되는 코드이니 함수로 따로 빼는 것이 어떨까요~?
fun removeItem 같이 따로 빼주세요!
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.
함수로 따로 빼주는 게 더 좋을 것 같네요! 수정하겠습니다
binding.tvOnboardingChoiceThemeSpeech.text = | ||
getString(R.string.onboarding_choice_theme_speech_after) |
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.
바꾸라는 건 아니고 전 삼항 연산자^^,,를 선호하는 편이긴 합니다!
click하면 liveData 값을 true로 바꾼 뒤(or false) xml에서 string을 처리하긴 해요
이건 스타일 선호 차이니까 선호하시는 거로 작업하세요~
|
||
private fun setThemeBtn() { | ||
viewModel.selectedThemeArray.observe(viewLifecycleOwner) { | ||
if (it.size == 3) { |
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.
3 마찬가지입니다~ 여기서 따로 빼고 adapter에서 받아서 써도 되겠네요!
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:background="@color/onboarding_translucent" | ||
android:visibility="@{viewModel.layoutTranslucent ? View.VISIBLE : View.GONE}" |
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.
^--^
여기서 이미 layoutTranslucent으로 삼항 연산자를 처리하고 계시네요!
그렇다면 이참에 string 값도 layoutTranslucent값을 이용해서 삼항 연산자로 처리해볼까요?
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.
background 잘 설정한 거 같은데 왜 시연영상은 색이 다르게 보이는걸까요... 디스플레이 이슈인가 고생하셨습니다!
@@ -16,10 +18,55 @@ class ChoiceThemeAdapter : | |||
) | |||
) { | |||
|
|||
class ChoiceThemeViewHolder(private val binding: ItemOnboardingChoiceThemeBinding) : | |||
inner class ChoiceThemeViewHolder(private val binding: ItemOnboardingChoiceThemeBinding) : |
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.
내부에 inner 클래스를 선언하는게 ViewHolder를 따로 파는 것과 차이가 있나요?(그냥 궁금)
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.
사실 코틀린에서 inner class를 사용하는 것은 권장되지는 않습니다!
이거 읽어보세요~
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.
저는 clicklistener 때문에 inner class로 만들었습니다! 메모리 누수 문제는 destroy되면 메모리 해제할 수 있도록 수정했습니다!
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.
수고하셨습니당!
if (selectedThemeArray.contains(theme.themeId)) { | ||
selectedThemeArray.removeAt(selectedThemeArray.indexOf(theme.themeId)) | ||
changeThemeBackground(binding, false) | ||
} else { | ||
selectedThemeArray.add(theme.themeId) | ||
changeThemeBackground(binding, true) |
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.
선택된 테마 id가 포함되어 있으면 해당 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.
네 맞습니당!
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.
고생했어요~!~!
@@ -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}" |
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.
💞💞💞
📑 Work Description
🛠️ Issue
📷 Screenshot
feat.onboarding-theme.choice.webm
💬 To Reviewers