-
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
[FIX/#262] Second QA 수정사항 반영 #264
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a36fe1f
[FIX/#252] 점선 간격 수정 및 글자 수정
chattymin 82bae1e
[FIX/#262] 글자 겹침 해결
chattymin 6771b25
[FIX/#262] 이모지 글자수 판정 오류 해결
chattymin a369d32
[FIX/#262] 엔터 방지를 위한 새 컴포넌트 생성 및 적용
chattymin 3ae7ad0
[FIX/#262] 성향 검사 완료시 흰색 여백 생기는 현상 해결
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
152 changes: 152 additions & 0 deletions
152
...c/main/java/com/going/presentation/designsystem/edittext/EmojiCounterEditTextMultiLine.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,152 @@ | ||
package com.going.presentation.designsystem.edittext | ||
|
||
import android.content.Context | ||
import android.content.res.TypedArray | ||
import android.text.method.ScrollingMovementMethod | ||
import android.util.AttributeSet | ||
import android.view.LayoutInflater | ||
import android.view.View.OnFocusChangeListener | ||
import androidx.constraintlayout.widget.ConstraintLayout | ||
import androidx.core.content.res.ResourcesCompat | ||
import androidx.core.view.isVisible | ||
import androidx.core.widget.doAfterTextChanged | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ViewEmojiCounterEdittextMultilineBinding | ||
import com.going.ui.extension.colorOf | ||
import com.going.ui.extension.getGraphemeLength | ||
import com.going.ui.extension.setOnSingleClickListener | ||
|
||
class EmojiCounterEditTextMultiLine(context: Context, attrs: AttributeSet) : | ||
ConstraintLayout(context, attrs) { | ||
|
||
private val binding: ViewEmojiCounterEdittextMultilineBinding | ||
|
||
private var maxLen: Int = 0 | ||
private var canBlankError: Boolean = false | ||
lateinit var overWarning: String | ||
var blankWarning: String = "" | ||
|
||
private val editTextStateMap by lazy { | ||
mapOf( | ||
EditTextState.SUCCESS to Triple( | ||
R.color.gray_700, | ||
R.drawable.shape_rect_4_gray700_line, | ||
"" | ||
), | ||
EditTextState.EMPTY to Triple( | ||
R.color.gray_200, | ||
R.drawable.shape_rect_4_gray200_line, | ||
"" | ||
), | ||
EditTextState.BLANK to Triple( | ||
R.color.red_500, | ||
R.drawable.shape_rect_4_red500_line, | ||
blankWarning | ||
), | ||
EditTextState.OVER to Triple( | ||
R.color.red_500, | ||
R.drawable.shape_rect_4_red500_line, | ||
overWarning | ||
), | ||
) | ||
} | ||
|
||
val editText | ||
get() = binding.etEmojiCounterEtContent | ||
|
||
var state: EditTextState = EditTextState.EMPTY | ||
set(value) { | ||
field = value | ||
|
||
binding.run { | ||
btnDeleteText.isVisible = | ||
(value != EditTextState.EMPTY) && etEmojiCounterEtContent.hasFocus() | ||
} | ||
|
||
editTextStateMap[field]?.let { setEditTextState(it) } | ||
} | ||
|
||
init { | ||
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.EmojiCounterEditText) | ||
binding = ViewEmojiCounterEdittextMultilineBinding.inflate( | ||
LayoutInflater.from(context), | ||
this, | ||
true, | ||
) | ||
|
||
initDeleteBtnClickListener() | ||
setBindingContent(typedArray) | ||
initEtFocusChangeListener() | ||
|
||
typedArray.recycle() | ||
|
||
checkTextAvailable() | ||
} | ||
|
||
private fun initDeleteBtnClickListener() = with(binding) { | ||
btnDeleteText.setOnSingleClickListener { | ||
etEmojiCounterEtContent.text = null | ||
} | ||
} | ||
|
||
private fun setBindingContent(typedArray: TypedArray) { | ||
with(binding) { | ||
tvEmojiCounterEtTitle.text = | ||
typedArray.getString(R.styleable.EmojiCounterEditText_title) | ||
etEmojiCounterEtContent.hint = | ||
typedArray.getString(R.styleable.EmojiCounterEditText_hint) | ||
etEmojiCounterEtContent.minLines = | ||
typedArray.getInt(R.styleable.EmojiCounterEditText_minLines, 1) | ||
etEmojiCounterEtContent.maxLines = | ||
typedArray.getInt(R.styleable.EmojiCounterEditText_minLines, 2) | ||
etEmojiCounterEtContent.movementMethod = ScrollingMovementMethod() | ||
tvEmojiCounterEtNameCounter.text = context.getString(R.string.counter, 0, maxLen) | ||
} | ||
canBlankError = typedArray.getBoolean(R.styleable.EmojiCounterEditText_canBlankError, false) | ||
} | ||
|
||
private fun initEtFocusChangeListener() { | ||
binding.etEmojiCounterEtContent.onFocusChangeListener = | ||
OnFocusChangeListener { _, hasFocus -> | ||
binding.btnDeleteText.isVisible = hasFocus && (state != EditTextState.EMPTY) | ||
} | ||
} | ||
|
||
private fun checkTextAvailable() { | ||
binding.etEmojiCounterEtContent.doAfterTextChanged { text -> | ||
val len = text.toString().getGraphemeLength() | ||
|
||
state = when { | ||
text.toString().isBlank() && len != 0 && canBlankError -> EditTextState.BLANK | ||
len > maxLen -> EditTextState.OVER | ||
len > 0 -> EditTextState.SUCCESS | ||
else -> EditTextState.EMPTY | ||
} | ||
|
||
binding.tvEmojiCounterEtNameCounter.text = | ||
context.getString(R.string.counter, len, maxLen) | ||
} | ||
} | ||
|
||
fun setMaxLen(len: Int) { | ||
maxLen = len | ||
binding.tvEmojiCounterEtNameCounter.text = context.getString(R.string.counter, 0, maxLen) | ||
} | ||
|
||
private fun setEditTextState(info: Triple<Int, Int, String>) { | ||
val color = info.first | ||
val background = info.second | ||
val text = info.third | ||
|
||
with(binding) { | ||
tvEmojiCounterEtWarningMessage.isVisible = color == R.color.red_500 | ||
tvEmojiCounterEtNameCounter.setTextColor(context.colorOf(color)) | ||
etEmojiCounterEtContent.background = ResourcesCompat.getDrawable( | ||
[email protected], | ||
background, | ||
context.theme, | ||
) | ||
tvEmojiCounterEtWarningMessage.text = text | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.viewModelScope | ||
import com.going.domain.entity.request.UserProfileRequestModel | ||
import com.going.domain.repository.ProfileRepository | ||
import com.going.presentation.designsystem.edittext.EditTextState | ||
import com.going.presentation.onboarding.signup.SignUpViewModel | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.MutableSharedFlow | ||
|
@@ -40,23 +41,23 @@ class ProfileEditViewModel @Inject constructor( | |
defaultInfo = info | ||
} | ||
|
||
fun checkIsNameChanged(name: String) { | ||
fun checkIsNameChanged(name: String, nameState: EditTextState, infoState: EditTextState) { | ||
nowName = name | ||
isNameChanged = name != defaultName | ||
|
||
checkIsValueChanged() | ||
checkIsValueChanged(nameState, infoState) | ||
} | ||
|
||
fun checkIsInfoChanged(info: String) { | ||
fun checkIsInfoChanged(info: String, nameState: EditTextState, infoState: EditTextState) { | ||
nowInfo = info | ||
isInfoChanged = info != defaultInfo | ||
|
||
checkIsValueChanged() | ||
checkIsValueChanged(nameState, infoState) | ||
} | ||
|
||
private fun checkIsValueChanged() { | ||
private fun checkIsValueChanged(nameState: EditTextState, infoState: EditTextState) { | ||
_isValueChanged.value = | ||
nowName.isNotBlank() && nowName.length <= getMaxNameLen() && nowInfo.isNotBlank() && nowInfo.length <= getMaxInfoLen() && (isInfoChanged || isNameChanged) | ||
nowName.isNotBlank() && nameState == EditTextState.SUCCESS && nowInfo.isNotBlank() && infoState == EditTextState.SUCCESS && (isInfoChanged || isNameChanged) | ||
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. 오호라!!!! 좋숩니다 |
||
} | ||
|
||
fun patchUserInfo() { | ||
|
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
14 changes: 10 additions & 4 deletions
14
presentation/src/main/res/drawable/shape_line_gray100_fill_dash_5_vertical.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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<rotate xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:fromDegrees="90" | ||
android:toDegrees="90" | ||
android:drawable="@drawable/shape_line_gray100_fill_dash_5"/> | ||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:left="-600dp" | ||
android:right="-600dp"> | ||
<rotate | ||
android:drawable="@drawable/shape_line_gray100_fill_dash_5" | ||
android:fromDegrees="90" | ||
android:visible="true" /> | ||
</item> | ||
</layer-list> |
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
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
Oops, something went wrong.
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.
오,,,,깔꼼하다