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

[fix] 3차 스프린트 QA 수정사항 반영 #249

Merged
merged 12 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class JoinGroupCodeActivity :

initLayout()
addListeners()
addObservers()
collectData()
}

Expand Down Expand Up @@ -60,12 +59,6 @@ class JoinGroupCodeActivity :
}
}

private fun addObservers() {
viewModel.joinGroupCodeEditText.observe(this) { editText ->
binding.btnJoinGroupCodeNext.isEnabled = editText.isNotEmpty()
}
}

private fun collectData() {
viewModel.joinGroupInfoState.flowWithLifecycle(lifecycle).onEach { uiState ->
when (uiState) {
Expand Down Expand Up @@ -131,6 +124,10 @@ class JoinGroupCodeActivity :
is UiState.Empty -> Timber.tag(JOIN_GROUP_CODE_ACTIVITY).d(EMPTY)
}
}.launchIn(lifecycleScope)

viewModel.joinGroupCodeEditText.flowWithLifecycle(lifecycle).onEach { editText ->
binding.btnJoinGroupCodeNext.isEnabled = editText.isNotEmpty()
}.launchIn(lifecycleScope)
}

private fun navigateToJoinGroupSuccess() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.sopt.pingle.presentation.ui.joingroup

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
Expand Down Expand Up @@ -45,7 +44,7 @@ class JoinViewModel @Inject constructor(
MutableStateFlow<UiState<GroupEntity>>(UiState.Empty)

val joinGroupCodeState get() = _joinGroupCodeState
val joinGroupCodeEditText = MutableLiveData<String>()
val joinGroupCodeEditText = MutableStateFlow<String>("")

private var oldPosition = DEFAULT_OLD_POSITION

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class MyPingleFragment : BindingFragment<FragmentMyPingleBinding>(R.layout.fragm
binding.rvMyPingle.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
when (viewModel.myPingleType.value) {
MyPingleType.SOON -> AmplitudeUtils.trackEvent(SCROLL_SOONPINGLE)
MyPingleType.DONE -> AmplitudeUtils.trackEvent(SCROLL_DONEPINGLE)
Expand Down
Copy link
Collaborator

Choose a reason for hiding this comment

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

중복확인 후 안내 페이지 띄웠을 때 중복확인 버튼이 비활성화 안 되어 있는 문제
-> onResume에 btnEditTextCheck.isEnabled 값 세팅해주기

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.sopt.pingle.R
Expand All @@ -31,6 +32,13 @@ class NewGroupInputFragment :
collectData()
}

override fun onResume() {
super.onResume()

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

private fun addListeners() {
Comment on lines +35 to 42
Copy link
Collaborator

Choose a reason for hiding this comment

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

좋네요 ~

binding.etNewGroupInputGroupName.btnEditTextCheck.setOnClickListener { newGroupViewModel.getNewGroupCheckName() }
}
Expand All @@ -48,32 +56,38 @@ class NewGroupInputFragment :
}

private fun collectNewGroupCheckNameState() {
newGroupViewModel.newGroupCheckNameState.flowWithLifecycle(lifecycle).onEach { uiState ->
when (uiState) {
is UiState.Success -> {
if (uiState.data.result) {
PingleSnackbar.makeSnackbar(
binding.root,
stringOf(R.string.new_group_input_snackbar_guide),
SNACKBAR_BOTTOM_MARGIN,
SnackbarType.GUIDE
)
binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled = false
newGroupViewModel.setIsNewGroupBtnCheckName(true)
} else {
PingleSnackbar.makeSnackbar(
binding.root,
stringOf(R.string.new_group_input_snackbar_warning),
SNACKBAR_BOTTOM_MARGIN,
SnackbarType.WARNING
newGroupViewModel.newGroupCheckNameState.flowWithLifecycle(lifecycle)
.distinctUntilChanged()
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기서도 distinctUntilChange를 안 쓰면 안 되는 문제가 생겼었나 보네요,, 무슨 문제였나요??

Copy link
Collaborator

Choose a reason for hiding this comment

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

이거 지도뷰랑 같은 문제염 ㅜㅜ 위에 액티비티 떴다가 사라지면 값이 같은데도 방출쓰

.onEach { uiState ->
when (uiState) {
is UiState.Success -> {
if (uiState.data.result) {
PingleSnackbar.makeSnackbar(
binding.root,
stringOf(R.string.new_group_input_snackbar_guide),
SNACKBAR_BOTTOM_MARGIN,
SnackbarType.GUIDE
)
binding.etNewGroupInputGroupName.btnEditTextCheck.isEnabled = false
newGroupViewModel.setIsNewGroupBtnCheckName(true)
} else {
PingleSnackbar.makeSnackbar(
binding.root,
stringOf(R.string.new_group_input_snackbar_warning),
SNACKBAR_BOTTOM_MARGIN,
SnackbarType.WARNING
)
}
AmplitudeUtils.trackEventWithProperty(
COMPLETE_DOUBLECHECK,
GROUP_NAME,
binding.etNewGroupInputGroupName.editText.text
)
}
AmplitudeUtils.trackEventWithProperty(COMPLETE_DOUBLECHECK, GROUP_NAME, binding.etNewGroupInputGroupName.editText.text)
}

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

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.sopt.pingle.presentation.ui.newgroup.newgroupkeyword

import android.os.Bundle
import android.view.View
import androidx.core.view.forEach
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand All @@ -28,6 +29,20 @@ class NewGroupKeywordFragment :
collectData()
}

override fun onResume() {
super.onResume()

with(newGroupViewModel.newGroupKeywordValue.value) {
if (isNotEmpty()) {
binding.cgNewGroupKeyword.forEach { childChip ->
(childChip as Chip).let { chip ->
if (chip.text == this) chip.isChecked = true
}
}
}
}
}

private fun initLayout() {
newGroupViewModel.getNewGroupKeywords()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,70 @@ package org.sopt.pingle.presentation.ui.splash

import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.sopt.pingle.R
import org.sopt.pingle.data.datasource.local.PingleLocalDataSource
import org.sopt.pingle.databinding.ActivitySplashBinding
import org.sopt.pingle.presentation.ui.auth.AuthViewModel
import org.sopt.pingle.presentation.ui.main.MainActivity
import org.sopt.pingle.presentation.ui.onboarding.onboarding.OnboardingActivity
import org.sopt.pingle.presentation.ui.onboarding.onboardingexplanation.OnboardingExplanationActivity
import org.sopt.pingle.util.base.BindingActivity
import org.sopt.pingle.util.view.UiState

@AndroidEntryPoint
class SplashActivity : BindingActivity<ActivitySplashBinding>(R.layout.activity_splash) {
@Inject
lateinit var localStorage: PingleLocalDataSource
private val authViewModel by viewModels<AuthViewModel>()

override fun onCreate(savedInstanceState: Bundle?) {
installSplashScreen()
super.onCreate(savedInstanceState)
loadSplashScreen()
collectData()
}

private fun loadSplashScreen() {
lifecycleScope.launch {
delay(SPLASH_SCREEN_DELAY_TIME)
navigateToAuth()
if (authViewModel.isLocalToken()) {
if (authViewModel.isLocalGroupId()) navigateToMain() else authViewModel.getUserInfo()
Copy link
Collaborator

Choose a reason for hiding this comment

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

저는 여기 authViewModel.getUserInfo() 다음에 navigateToOnboarding()을 넣어주는 방식으로 구현했었는데
collectData에서 서버통신 성공여부 검사하고 넘어가는 게 훨씬 안정적이네요! 좋은 로직 같아용

} else {
navigateToOnboardingExplanation()
}
}
}

private fun collectData() {
authViewModel.userInfoState.flowWithLifecycle(lifecycle).onEach { uiState ->
when (uiState) {
is UiState.Success -> if (uiState.data.groups.isEmpty()) navigateToOnboarding() else navigateToMain()
else -> Unit
}
}.launchIn(lifecycleScope)
}

private fun navigateToMain() {
Intent(this, MainActivity::class.java).apply {
startActivity(this)
}
finish()
}

private fun navigateToOnboarding() {
Intent(this, OnboardingActivity::class.java).apply {
startActivity(this)
}
finish()
}

private fun navigateToAuth() {
private fun navigateToOnboardingExplanation() {
Intent(this, OnboardingExplanationActivity::class.java).apply {
startActivity(this)
}
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/res/layout/activity_join_group_code.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,10 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:maxLines="2"
android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.24"
android:textColor="@color/black"
app:layout_constraintEnd_toStartOf="@id/gl_group_info_end"
app:layout_constraintStart_toEndOf="@id/gl_group_info_start"
app:layout_constraintTop_toBottomOf="@id/tv_join_group_code_tag"
tools:text="SOPT" />
Expand Down Expand Up @@ -170,8 +172,8 @@
app:layout_constraintEnd_toStartOf="@id/gl_end"
app:layout_constraintStart_toEndOf="@id/gl_start"
app:layout_constraintTop_toBottomOf="@id/layout_join_group_code_group_info"
app:pingleEditTextMaxLength="12"
app:pingleEditTextHint="@string/join_group_code_invitation_hint"
app:pingleEditTextMaxLength="12"
app:pingleEditTextTitle="@string/join_group_code_invitation" />

<TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@

<TextView
android:id="@+id/tv_new_group_announcement_group_name"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="0dp"
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_constraintTop_toBottomOf="@id/tv_new_group_announcement_title"
tools:text="@string/new_group_announcement_group_name" />

Expand Down
38 changes: 24 additions & 14 deletions app/src/main/res/layout/item_join_group_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,49 @@
android:orientation="vertical"
app:layout_constraintGuide_begin="@dimen/spacing18" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="@dimen/spacing34" />

<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_end"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_end="@dimen/spacing18" />
app:layout_constraintGuide_end="@dimen/spacing10" />

<TextView
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_end="@dimen/spacing34" />

<org.sopt.pingle.util.component.PingleChip
android:id="@+id/tv_join_group_search_tag"
android:layout_width="0dp"
style="@style/Theme.Pingle.Chip.Tag.S"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="35dp"
android:background="@drawable/shape_border_radius_50"
android:backgroundTint="@color/g_10"
android:paddingHorizontal="@dimen/spacing8"
android:paddingVertical="@dimen/spacing3"
android:text="@{joinGroupSearch.keyword}"
android:textAppearance="@style/TextAppearance.Pingle.Cap.Semi.10"
android:textColor="@color/pingle_green"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/gl_bottom"
app:layout_constraintStart_toEndOf="@id/gl_start"
app:layout_constraintTop_toTopOf="parent"
tools:text="목적 키워드" />
app:layout_constraintTop_toBottomOf="@id/gl_top" />

<TextView
android:id="@+id/tv_join_group_search_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="20dp"
android:maxLines="2"
android:text="@{joinGroupSearch.name}"
android:textAppearance="@style/TextAppearance.Pingle.Body.Med.16"
android:textColor="@color/white"
app:layout_constraintBottom_toBottomOf="@id/tv_join_group_search_tag"
app:layout_constraintEnd_toStartOf="@id/iv_join_group_search_check"
app:layout_constraintStart_toEndOf="@id/tv_join_group_search_tag"
app:layout_constraintTop_toTopOf="@id/tv_join_group_search_tag"
tools:text="단체 이름" />
Expand All @@ -63,7 +73,7 @@
android:id="@+id/iv_join_group_search_check"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing10"
android:layout_marginEnd="10dp"
android:src="@{joinGroupSearch.isSelected ? @drawable/ic_all_check_selected_24 : @drawable/ic_all_check_default_24}"
app:layout_constraintBottom_toBottomOf="@id/tv_join_group_search_tag"
app:layout_constraintEnd_toStartOf="@id/gl_end"
Expand Down
Loading