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

[hotfix] 신규단체개설뷰 이슈 해결 #252

Merged
merged 8 commits into from
Mar 13, 2024
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android {
applicationId = "org.sopt.pingle"
minSdk = 28
targetSdk = 34
versionCode = 16
versionCode = 17
versionName = "2.0.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />

<activity
android:name=".presentation.ui.newgroup.NewGroupActivity"
android:exported="false"
Expand All @@ -98,6 +97,11 @@
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.ui.newgroup.newgroupinfo.NewGroupInfoActivity"
android:exported="false"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity" />
<activity
android:name=".presentation.ui.onboarding.onboarding.OnboardingActivity"
android:exported="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ class NewGroupViewModel @Inject constructor(

val newGroupName = MutableStateFlow<String>("")
val newGroupEmail = MutableStateFlow<String>("")
val isNewGroupBtnCheckName = MutableStateFlow<Boolean>(false)
val isGroupNameDuplicatedCheck = MutableStateFlow<Boolean>(false)
val newGroupKeywordName = MutableStateFlow<String>("")
val newGroupKeywordValue = MutableStateFlow<String>("")

val isNewGroupBtnEnabled: StateFlow<Boolean> = listOf(
currentPage,
newGroupName,
newGroupEmail,
isNewGroupBtnCheckName,
isGroupNameDuplicatedCheck,
Copy link
Member

Choose a reason for hiding this comment

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

제 네이밍이 별로였나여..?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

아 ㅋㅋ 오빠가 만들어놓은 거랑 다른 목적으로 사용하려고 네이밍 수정했슴다 ㅋㅋ ㅜㅜ

newGroupKeywordValue
).combineAll().map { values ->
val currentPage = values[0] as Int
Expand All @@ -78,8 +78,8 @@ class NewGroupViewModel @Inject constructor(
newGroupKeywordValue.value = keywordValue
}

fun setIsNewGroupBtnCheckName(boolean: Boolean) {
isNewGroupBtnCheckName.value = boolean
fun setIsGroupNameDuplicatedCheck(boolean: Boolean) {
isGroupNameDuplicatedCheck.value = boolean
}

fun isEmailValid() = EMAIL_PATTERN.matches(newGroupEmail.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,39 @@ class NewGroupInputFragment :
collectData()
}

override fun onResume() {
super.onResume()

binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled =
newGroupViewModel.isNewGroupBtnCheckName.value
}

private fun addListeners() {
binding.etNewGroupInputGroupName.btnEditTextCheck.setOnClickListener { newGroupViewModel.getNewGroupCheckName() }
binding.etNewGroupInputGroupName.btnEditTextCheck.setOnClickListener {
with(newGroupViewModel) {
newGroupName.apply { value = value.trim() }
getNewGroupCheckName()
}
}
}

private fun collectData() {
collectNewGroupTeamNameIsEnabled()
collectIsGroupNameDuplicatedCheck()
collectNewGroupName()
collectNewGroupCheckNameState()
}

private fun collectNewGroupTeamNameIsEnabled() {
newGroupViewModel.newGroupName.flowWithLifecycle(lifecycle).onEach { newGroupName ->
binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled = newGroupName.isNotBlank()
newGroupViewModel.setIsNewGroupBtnCheckName(false)
}.launchIn(lifecycleScope)
private fun collectIsGroupNameDuplicatedCheck() {
newGroupViewModel.isGroupNameDuplicatedCheck.flowWithLifecycle(viewLifecycleOwner.lifecycle)
.onEach { isGroupNameDuplicatedCheck ->
binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled =
!isGroupNameDuplicatedCheck && newGroupViewModel.newGroupName.value.isNotBlank()
}.launchIn(viewLifecycleOwner.lifecycleScope)
}

private fun collectNewGroupName() {
newGroupViewModel.newGroupName.flowWithLifecycle(viewLifecycleOwner.lifecycle)
.distinctUntilChanged().onEach { newGroupName ->
binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled = newGroupName.isNotBlank()
newGroupViewModel.setIsGroupNameDuplicatedCheck(false)
}.launchIn(viewLifecycleOwner.lifecycleScope)
}

private fun collectNewGroupCheckNameState() {
newGroupViewModel.newGroupCheckNameState.flowWithLifecycle(lifecycle)
newGroupViewModel.newGroupCheckNameState.flowWithLifecycle(viewLifecycleOwner.lifecycle)
.distinctUntilChanged()
.onEach { uiState ->
when (uiState) {
Expand All @@ -68,15 +76,15 @@ class NewGroupInputFragment :
SNACKBAR_BOTTOM_MARGIN,
SnackbarType.GUIDE
)
binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled = false
newGroupViewModel.setIsNewGroupBtnCheckName(true)
newGroupViewModel.setIsGroupNameDuplicatedCheck(true)
} else {
PingleSnackbar.makeSnackbar(
binding.root,
stringOf(R.string.new_group_input_snackbar_warning),
SNACKBAR_BOTTOM_MARGIN,
SnackbarType.WARNING
)
newGroupViewModel.setIsGroupNameDuplicatedCheck(false)
}
AmplitudeUtils.trackEventWithProperty(
COMPLETE_DOUBLECHECK,
Expand All @@ -87,7 +95,7 @@ class NewGroupInputFragment :

else -> {}
}
}.launchIn(lifecycleScope)
}.launchIn(viewLifecycleOwner.lifecycleScope)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@ class NewGroupKeywordFragment :
}

private fun collectData() {
newGroupViewModel.newGroupKeywordsState.flowWithLifecycle(lifecycle).onEach { uiState ->
newGroupViewModel.newGroupKeywordsState.flowWithLifecycle(viewLifecycleOwner.lifecycle).onEach { uiState ->
Copy link
Member

Choose a reason for hiding this comment

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

내가 나중에 리팩할려고 아껴둔건데 ㅠㅠㅠㅠㅠㅠㅠㅠㅠ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ㅋㅋ 이런 건 빨리 리팩하라핑

when (uiState) {
is UiState.Success -> setChipKeyword(uiState.data)

else -> {}
else -> Unit
}
}.launchIn(lifecycleScope)
}.launchIn(viewLifecycleOwner.lifecycleScope)
}

private fun setChipKeyword(keywords: List<NewGroupKeywordEntity>) {
Expand Down
Loading