-
Notifications
You must be signed in to change notification settings - Fork 2
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
[UI/#13] onboarding profile setting #14
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
89fb554
[ADD/#7] TextInputLayout custom style 추가
chattymin c78c6a3
[ADD/#7] Onboarding Profile 페이지 string 리소스 추가
chattymin eabbdf9
[UI/#7] Onboarding Profile 페이지 UI 와이어프레임 구현
chattymin 076a94e
[FEAT/#7] 글자 수 검증 with 이모지, 공백
chattymin 6a8b598
[FIX/#7] 버튼 검증과 입력값 유효성 검증이 다르던 코드 수정
chattymin 6e4cccc
[ADD/#7] 텍스트박스 커서 색 변경
chattymin 86bf4d9
[ADD/#13] hideKeyboard에 focus Clear 기능 추가
chattymin 7c87fc7
[FEAT/#13] 버튼 연동 및 페이지 이동 함수 구현
chattymin 0544c36
[FEAT/#13] 글자수 세기 커스텀 함수 구현
chattymin aad46aa
[UI/#13] 글자수 세기 string 리소스 생성 및 ui 구현
chattymin 97de0bb
[MOD/#13] 글자수 검사 함수 리펙토링 및 변수명 수정
chattymin 4f0844d
[CHORE/#13] xml 배경색 제거
chattymin 774af30
Merge branch 'develop' into ui/#13-onboarding-profile-setting
chattymin 8d82e62
[CHORE/#13] 정책 변경으로 인한 이름 최대 길이 수 변경
chattymin b6a6603
[UI/#13] Button radius 처리 및 색상 처리
chattymin 7679e1f
[REFACTOR/#13] 입력창 UI 및 로직 전체 리펙토링 및 커스텀
chattymin 03fe1eb
[UI/#13] 에러 외곽 테두리 색 변경
chattymin 93f0536
[CHORE/#13] enum class 분리
chattymin a35d5fa
[CHORE/#13] 함수 로직 간략화
chattymin 2e99854
[CHORE/#13] 변수명 변경
chattymin 4f30c20
[CHORE/#13] 변수명 변경 및 불필요 내용 삭제
chattymin fd8150a
Merge remote-tracking branch 'origin/ui/#13-onboarding-profile-settin…
chattymin 3297edb
[CHORE/#13] 실수로 삭제한 내용 복구
chattymin afcb5af
[CHORE/#13] 색상코드 변경 반영
chattymin f6d6187
[CHORE/#13] 변수명 변경
chattymin 32fc59f
[CHORE/#13] 중복 내용 함수화 진행
chattymin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.going.domain.entity | ||
|
||
enum class NameState { | ||
Empty, Success, Blank | ||
} |
112 changes: 112 additions & 0 deletions
112
...ation/src/main/java/com/going/presentation/onboarding/OnboardingProfileSettingActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package com.going.presentation.onboarding | ||
|
||
import android.os.Bundle | ||
import android.view.inputmethod.EditorInfo | ||
import androidx.activity.viewModels | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import com.going.domain.entity.NameState | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ActivityOnboardingProfileSettingBinding | ||
import com.going.ui.base.BaseActivity | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
|
||
class OnboardingProfileSettingActivity : | ||
BaseActivity<ActivityOnboardingProfileSettingBinding>(R.layout.activity_onboarding_profile_setting) { | ||
private val viewModel by viewModels<OnboardingProfileSettingViewModel>() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
initBindingViewModel() | ||
initOnLineInfoEditorActionListener() | ||
initSetOnFucusChangeListener() | ||
observeIsProfileAvailable() | ||
observeTextLength() | ||
observeIsNameAvailable() | ||
} | ||
|
||
private fun initBindingViewModel() { | ||
binding.viewModel = viewModel | ||
} | ||
|
||
private fun initOnLineInfoEditorActionListener() { | ||
binding.etOnboardingProfileSettingInfo.setOnEditorActionListener { view, actionId, _ -> | ||
if (actionId == EditorInfo.IME_ACTION_DONE) view.clearFocus() | ||
false | ||
} | ||
} | ||
|
||
private fun initSetOnFucusChangeListener() { | ||
binding.etOnboardingProfileSettingName.setOnFocusChangeListener { _, hasFocus -> | ||
if (hasFocus) { | ||
setNameCounterColor(R.color.gray_700) | ||
} else { | ||
setNameCounterColor(R.color.gray_200) | ||
} | ||
if (viewModel.isNameAvailable.value == NameState.Blank) { | ||
setNameCounterColor(R.color.red_400) | ||
} | ||
} | ||
|
||
binding.etOnboardingProfileSettingInfo.setOnFocusChangeListener { _, hasFocus -> | ||
if (hasFocus) { | ||
setNameCounterColor(R.color.gray_700) | ||
} else { | ||
setNameCounterColor(R.color.gray_200) | ||
} | ||
if (viewModel.isNameAvailable.value == NameState.Blank) { | ||
setNameCounterColor(R.color.red_400) | ||
} | ||
} | ||
} | ||
|
||
private fun setNameCounterColor(color: Int) { | ||
binding.tvNameCounter.setTextColor(getColor(color)) | ||
} | ||
|
||
private fun observeIsProfileAvailable() { | ||
viewModel.isMoveScreenAvailable.flowWithLifecycle(lifecycle).onEach { isEnd -> | ||
if (isEnd) moveSplash() | ||
}.launchIn(lifecycleScope) | ||
} | ||
|
||
// 커스텀 글자수 제한 함수 | ||
private fun observeTextLength() { | ||
viewModel.nowNameLength.observe(this) { length -> | ||
val maxNameLength = viewModel.getMaxNameLen() | ||
|
||
if (length > maxNameLength) { | ||
binding.etOnboardingProfileSettingName.apply { | ||
setText(text?.subSequence(0, maxNameLength)) | ||
setSelection(maxNameLength) | ||
} | ||
} | ||
} | ||
|
||
viewModel.nowInfoLength.observe(this) { length -> | ||
val maxInfoLength = viewModel.getMaxInfoLen() | ||
|
||
if (length > maxInfoLength) { | ||
binding.etOnboardingProfileSettingInfo.apply { | ||
setText(text?.subSequence(0, maxInfoLength)) | ||
setSelection(maxInfoLength) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun observeIsNameAvailable() { | ||
viewModel.isNameAvailable.observe(this) { state -> | ||
when (state) { | ||
NameState.Blank -> binding.tvNameCounter.setTextColor(getColor(R.color.red_400)) | ||
else -> binding.tvNameCounter.setTextColor(getColor(R.color.gray_700)) | ||
} | ||
} | ||
} | ||
|
||
private fun moveSplash() { | ||
// 스플래시로 이동 | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...tion/src/main/java/com/going/presentation/onboarding/OnboardingProfileSettingViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.going.presentation.onboarding | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import com.going.domain.entity.NameState | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
import java.text.BreakIterator | ||
|
||
class OnboardingProfileSettingViewModel : ViewModel() { | ||
val name = MutableLiveData(String()) | ||
val nowNameLength = MutableLiveData(0) | ||
val info = MutableLiveData(String()) | ||
val nowInfoLength = MutableLiveData(0) | ||
|
||
val isNameAvailable = MutableLiveData(NameState.Empty) | ||
val isProfileAvailable = MutableLiveData(false) | ||
|
||
private val _isMoveScreenAvailable = MutableStateFlow(false) | ||
val isMoveScreenAvailable: StateFlow<Boolean> = _isMoveScreenAvailable | ||
|
||
fun getMaxNameLen() = MAX_NAME_LEN | ||
fun getMaxInfoLen() = MAX_INFO_LEN | ||
|
||
fun checkProfileAvailable() { | ||
nowNameLength.value = getGraphemeLength(name.value) | ||
nowInfoLength.value = getGraphemeLength(info.value) | ||
|
||
isNameAvailable.value = when { | ||
nowNameLength.value == 0 -> NameState.Empty | ||
name.value.isNullOrBlank() -> NameState.Blank | ||
else -> NameState.Success | ||
} | ||
|
||
val isInfoAvailable = getGraphemeLength(info.value) in 1..MAX_INFO_LEN | ||
|
||
isProfileAvailable.value = | ||
(isNameAvailable.value == NameState.Success) && isInfoAvailable | ||
} | ||
|
||
// 이모지 포함 글자 수 세는 함수 | ||
private fun getGraphemeLength(value: String?): Int { | ||
BREAK_ITERATOR.setText(value) | ||
|
||
var count = 0 | ||
while (BREAK_ITERATOR.next() != BreakIterator.DONE) { | ||
count++ | ||
} | ||
|
||
return count | ||
} | ||
|
||
fun setIsMoveScreenAvailable() { | ||
_isMoveScreenAvailable.value = true | ||
} | ||
|
||
companion object { | ||
val BREAK_ITERATOR: BreakIterator = BreakIterator.getCharacterInstance() | ||
|
||
const val MAX_NAME_LEN = 3 | ||
const val MAX_INFO_LEN = 20 | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
presentation/src/main/res/drawable/rounded_corner_button.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 셀렉터 네이밍은 sel_ 로 해주세용~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵! 수정했습니당 |
||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_enabled="false"> | ||
<shape> | ||
<corners android:radius="4dp" /> | ||
<solid android:color="@color/gray_200" /> | ||
</shape> | ||
</item> | ||
|
||
<!-- State Enabled --> | ||
<item android:state_enabled="true"> | ||
<shape> | ||
<corners android:radius="4dp" /> | ||
<solid android:color="@color/gray_500" /> | ||
</shape> | ||
</item> | ||
|
||
</selector> |
17 changes: 17 additions & 0 deletions
17
presentation/src/main/res/drawable/rounded_corner_edit_text.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_focused="false"> | ||
<shape> | ||
<stroke android:width="2dp"/> | ||
<stroke android:color="@color/gray_200"/> | ||
<corners android:radius="4dp" /> | ||
</shape> | ||
</item> | ||
<item android:state_focused="true"> | ||
<shape> | ||
<stroke android:width="2dp"/> | ||
<stroke android:color="@color/gray_700"/> | ||
<corners android:radius="4dp" /> | ||
</shape> | ||
</item> | ||
</selector> |
10 changes: 10 additions & 0 deletions
10
presentation/src/main/res/drawable/rounded_corner_edit_text_error.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:state_focused="false"> | ||
<shape> | ||
<stroke android:width="2dp"/> | ||
<stroke android:color="@color/red_400"/> | ||
<corners android:radius="4dp" /> | ||
</shape> | ||
</item> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
역시 디테일 킹상호!