-
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
[FEAT/#220] 2차 스프린트 뷰 / 프로필, 확장함수, CustomEtv 전체 삭제 기능 구현 #222
Changes from 20 commits
6336fe1
ec39b2f
1ffee9f
5c3e502
677489d
353318a
e4e9f31
16bbb9c
486bcc8
2701460
300c5d4
a62475d
00a4c38
fe5c517
96c250d
213956a
d431d87
c08f687
418be77
6bee71f
a965f82
079a8aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ dependencies { | |
implementation(circularProgressBar) | ||
implementation(circleIndicator) | ||
implementation(flexbox) | ||
implementation(circleImageView) | ||
Comment on lines
86
to
+87
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. 좋아요!! |
||
} | ||
|
||
KakaoDependencies.run { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,8 @@ class EmojiCounterEditText(context: Context, attrs: AttributeSet) : | |
var state: EditTextState = EditTextState.EMPTY | ||
set(value) { | ||
field = value | ||
|
||
binding.btnDeleteText.isVisible = value != EditTextState.EMPTY | ||
editTextStateMap[field]?.let { setEditTextState(it) } | ||
} | ||
|
||
|
@@ -65,15 +67,23 @@ class EmojiCounterEditText(context: Context, attrs: AttributeSet) : | |
true, | ||
) | ||
|
||
initDeleteBtnClickListener() | ||
setBindingContent(typedArray) | ||
|
||
typedArray.recycle() | ||
|
||
checkTextAvailable() | ||
} | ||
|
||
private fun initDeleteBtnClickListener() = with(binding) { | ||
btnDeleteText.setOnClickListener { | ||
etEmojiCounterEtContent.text = null | ||
} | ||
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. 물론 성능에 크게 영향은 없다만, 싱글클릭으로 사용하는거는 어떨까요! 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. 넹~ 수정했습니당! 근데 혹시 이유를 알 수 있을까요?? 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. 사실 상관없습니다! ㅋㅋ |
||
} | ||
|
||
private fun setBindingContent(typedArray: TypedArray) { | ||
with(binding) { | ||
btnDeleteText.isVisible = state != EditTextState.EMPTY | ||
tvEmojiCounterEtTitle.text = | ||
typedArray.getString(R.styleable.EmojiCounterEditText_title) | ||
etEmojiCounterEtContent.hint = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package com.going.presentation.profile.edit | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Bundle | ||
import androidx.activity.viewModels | ||
import androidx.core.widget.doAfterTextChanged | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import com.going.presentation.R | ||
import com.going.presentation.databinding.ActivityProfileEditBinding | ||
import com.going.ui.base.BaseActivity | ||
import com.going.ui.extension.setOnSingleClickListener | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.flow.launchIn | ||
import kotlinx.coroutines.flow.onEach | ||
|
||
@AndroidEntryPoint | ||
class ProfileEditActivity : | ||
BaseActivity<ActivityProfileEditBinding>(R.layout.activity_profile_edit) { | ||
private val viewModel by viewModels<ProfileEditViewModel>() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
setEtNameArguments() | ||
setEtInfoArguments() | ||
getUserInfo() | ||
observeNameTextChanged() | ||
observeInfoTextChanged() | ||
observeIsValueChanged() | ||
initBackBtnClickListener() | ||
} | ||
|
||
private fun setEtNameArguments() { | ||
with(binding.etProfileEditNickname) { | ||
Comment on lines
+35
to
+36
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. 오 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. 근데 진심 이거 쩌는 것 같아요...... 확 간결해지는 마법 |
||
setMaxLen(viewModel.getMaxNameLen()) | ||
overWarning = getString(R.string.name_over_error) | ||
blankWarning = getString(R.string.name_blank_error) | ||
} | ||
} | ||
|
||
private fun setEtInfoArguments() { | ||
with(binding.etProfileEditInfo) { | ||
setMaxLen(viewModel.getMaxInfoLen()) | ||
overWarning = getString(R.string.info_over_error) | ||
} | ||
} | ||
|
||
private fun observeNameTextChanged() { | ||
binding.etProfileEditNickname.editText.doAfterTextChanged { name -> | ||
viewModel.checkIsNameChanged(name.toString()) | ||
} | ||
} | ||
|
||
private fun observeInfoTextChanged() { | ||
binding.etProfileEditInfo.editText.doAfterTextChanged { info -> | ||
viewModel.checkIsInfoChanged(info.toString()) | ||
} | ||
} | ||
Comment on lines
+50
to
+60
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. 오,,, |
||
|
||
private fun getUserInfo() { | ||
val name = intent.getStringExtra(NICKNAME) | ||
val info = intent.getStringExtra(INFO) | ||
|
||
with(binding) { | ||
etProfileEditNickname.editText.setText(name) | ||
etProfileEditInfo.editText.setText(info) | ||
} | ||
viewModel.setDefaultValues(name.orEmpty(), info.orEmpty()) | ||
} | ||
|
||
private fun observeIsValueChanged() { | ||
viewModel.isValueChanged.flowWithLifecycle(lifecycle).onEach { state -> | ||
binding.btnProfileEditFinish.isEnabled = state | ||
}.launchIn(lifecycleScope) | ||
} | ||
|
||
private fun initBackBtnClickListener() { | ||
binding.btnProfileEditBack.setOnSingleClickListener { | ||
finish() | ||
} | ||
} | ||
|
||
companion object { | ||
const val NICKNAME = "NICKNAME" | ||
const val INFO = "INFO" | ||
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. createIntent를 활용하면 키값을 private으로 돌려도 작동함당 ! 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. private 했습니다... 그것이..캡슐화니까... |
||
|
||
@JvmStatic | ||
fun createIntent( | ||
context: Context, | ||
nickName: String, | ||
info: String, | ||
): Intent = Intent(context, ProfileEditActivity::class.java).apply { | ||
putExtra(NICKNAME, nickName) | ||
putExtra(INFO, info) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.going.presentation.profile.edit | ||
|
||
import androidx.lifecycle.ViewModel | ||
import com.going.presentation.onboarding.signup.SignUpViewModel | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.StateFlow | ||
|
||
class ProfileEditViewModel : ViewModel() { | ||
private val _isValueChanged = MutableStateFlow(false) | ||
val isValueChanged: StateFlow<Boolean> = _isValueChanged | ||
|
||
private var isNameChanged = false | ||
private var isInfoChanged = false | ||
|
||
private lateinit var nowName: String | ||
private lateinit var nowInfo: String | ||
private lateinit var defaultName: String | ||
private lateinit var defaultInfo: String | ||
|
||
fun setDefaultValues(name: String, info: String) { | ||
nowName = name | ||
nowInfo = info | ||
|
||
defaultName = name | ||
defaultInfo = info | ||
} | ||
Comment on lines
+20
to
+26
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 checkIsNameChanged(name: String) { | ||
nowName = name | ||
isNameChanged = name != defaultName | ||
|
||
checkIsValueChanged() | ||
} | ||
|
||
fun checkIsInfoChanged(info: String) { | ||
nowInfo = info | ||
isInfoChanged = info != defaultInfo | ||
|
||
checkIsValueChanged() | ||
} | ||
|
||
private fun checkIsValueChanged() { | ||
_isValueChanged.value = | ||
nowName.length <= getMaxNameLen() && nowInfo.length <= getMaxInfoLen() && (isInfoChanged || isNameChanged) | ||
} | ||
|
||
fun getMaxNameLen() = SignUpViewModel.MAX_NAME_LEN | ||
|
||
fun getMaxInfoLen() = SignUpViewModel.MAX_INFO_LEN | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package com.going.presentation.tendency.splash | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import com.going.presentation.R | ||
import com.going.presentation.dashboard.DashBoardActivity | ||
import com.going.presentation.databinding.ActivityTendencySplashBinding | ||
import com.going.presentation.tendency.ttest.TendencyTestActivity | ||
import com.going.presentation.util.initOnBackPressedListener | ||
import com.going.presentation.util.navigateToScreen | ||
import com.going.presentation.util.navigateToScreenClear | ||
import com.going.ui.base.BaseActivity | ||
import com.going.ui.extension.setOnSingleClickListener | ||
|
||
|
@@ -16,13 +16,18 @@ class TendencySplashActivity : | |
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
|
||
initSkipBtnClickListener() | ||
initStartBtnClickListener() | ||
initOnBackPressedListener(binding.root) | ||
} | ||
|
||
private fun initStartBtnClickListener() { | ||
private fun initSkipBtnClickListener() = | ||
binding.btnTendencySplashSkip.setOnSingleClickListener { | ||
navigateToScreenClear<DashBoardActivity>() | ||
} | ||
|
||
private fun initStartBtnClickListener() = | ||
binding.btnTendencySplashStart.setOnSingleClickListener { | ||
navigateToScreen<TendencyTestActivity>(listOf(Intent.FLAG_ACTIVITY_CLEAR_TOP)) | ||
navigateToScreenClear<TendencyTestActivity>() | ||
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. 좋습니다!! 만들어주신 확장함수 유용하게 잘 쓰고 있어요!! |
||
} | ||
} | ||
} |
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.
와 보니깐 아워투두 친구목록에도 테두리 있었네 머지하면 쓰겟삼 최고~~