Skip to content

Commit

Permalink
Merge pull request #252 from TeamPINGLE/hotfix-new-group
Browse files Browse the repository at this point in the history
[hotfix] 신규단체개설뷰 이슈 해결
  • Loading branch information
jihyunniiii authored Mar 13, 2024
2 parents 2fc735f + a9551dd commit b463eb0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 31 deletions.
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,
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 ->
when (uiState) {
is UiState.Success -> setChipKeyword(uiState.data)

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

private fun setChipKeyword(keywords: List<NewGroupKeywordEntity>) {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/layout/activity_new_group_announcement.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@

<TextView
android:id="@+id/tv_new_group_announcement_group_name"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="@style/TextAppearance.Pingle.Body.Med.16"
android:textColor="@color/g_03"
app:layout_constraintStart_toEndOf="@id/gl_start"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/gl_start"
app:layout_constraintTop_toBottomOf="@id/tv_new_group_announcement_title"
tools:text="@string/new_group_announcement_group_name" />

Expand Down

0 comments on commit b463eb0

Please sign in to comment.