Skip to content

Commit

Permalink
[ Feature ] : 팀 선택이 되지 않은 유저인경우 팀 선택하라는 팝업 노출 (#300)
Browse files Browse the repository at this point in the history
* [ Fix ] : 중복된 when 절 체크 제거

* [ Fix ] : BaseViewModel 접근제한자 추가

* [ Feature ] : 멤버 메인 mvi 구조 변경 및 추가

* [ Feature ] : 메인 멤버 mvi 구조 변경으로 인한 추가 로직 수정

* [ Feature ] : 팀 선택이 되지 않은 유저인경우 팀 선택하라는 팝업 노출 로직 추가

* [ chore ] : 스트링 리소스 추가

* [ Refactor ] : 코드리뷰 반영 ( operator 함수 )

navigateToTeam invoke 문구 제거

* [ Fix ] : Dialog onDismiss 가 발현되지 않던 문제 수정 (#312)

* fix: dialog 사이즈가 최대로 측정되어, dimm 영역이 무시되고 있는 상황 수정

* feat: dialog ondismiss에 취소 적용

---------

Co-authored-by: Choi Sang Rok <[email protected]>
  • Loading branch information
TaeseongYun and EvergreenTree97 authored Jul 28, 2023
1 parent bc9bec8 commit 984740e
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/com/yapp/common/base/BaseViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class BaseViewModel<S : UiState, A : UiSideEffect, E : UiEvent>(
dispatchEvent(event)
}

fun dispatchEvent(event: E) = viewModelScope.launch {
private fun dispatchEvent(event: E) = viewModelScope.launch {
handleEvent(event)
}

Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/com/yapp/common/yds/YDSPopupDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fun YDSPopupDialog(
) {
Surface(
modifier = modifier
.fillMaxSize()
.fillMaxWidth()
.wrapContentHeight()
.padding(horizontal = 32.dp),
shape = RoundedCornerShape(10.dp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ enum class TeamType(val value: String) {
"IOS" -> IOS
"WEB" -> WEB
"BASECAMP" -> BASECAMP
"NONE" -> NONE
else -> error("$rawValue 에 해당하는 TeamType이 없습니다.")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ fun AttendanceScreen(
} else {
navController.navigate(route)
}
},
navigateToTeam = {
navController.navigate(AttendanceScreenRoute.SIGNUP_TEAM.route)
}
)
}
Expand Down Expand Up @@ -387,4 +390,4 @@ fun SetStatusBarColorByRoute(route: String?) {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
Expand All @@ -30,22 +31,27 @@ import androidx.navigation.compose.composable
import androidx.navigation.compose.currentBackStackEntryAsState
import androidx.navigation.compose.rememberNavController
import com.google.accompanist.insets.systemBarsPadding
import com.yapp.common.flow.collectAsStateWithLifecycle
import com.yapp.common.theme.AttendanceTheme
import com.yapp.common.theme.AttendanceTypography
import com.yapp.common.yds.YDSPopupDialog
import com.yapp.presentation.R
import com.yapp.presentation.ui.AttendanceScreenRoute
import com.yapp.presentation.ui.SetStatusBarColorByRoute
import com.yapp.presentation.ui.member.score.MemberScore
import com.yapp.presentation.ui.member.todaysession.TodaySession


@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun MemberMain(
scaffoldState: ScaffoldState = rememberScaffoldState(),
viewModel: MemberMainViewModel = hiltViewModel(),
navigateToScreen: (String) -> Unit,
navigateToTeam: () -> Unit
) {
val childNavController = rememberNavController()
val uiState by viewModel.uiState.collectAsStateWithLifecycle()

AttendanceTheme {
Scaffold(
Expand All @@ -62,6 +68,19 @@ fun MemberMain(
backgroundColor = AttendanceTheme.colors.backgroundColors.backgroundBase
) { innerPadding ->


if(uiState.isShowTeamDialog) {
YDSPopupDialog(
title = stringResource(id = R.string.member_need_select_team),
content = stringResource(id = R.string.member_need_select_team_description),
negativeButtonText = stringResource(id = R.string.member_need_select_team_next_time),
positiveButtonText = stringResource(id = R.string.member_setting_select_team),
onClickNegativeButton = { viewModel.setEvent(MemberMainContract.MemberMainUiEvent.OnNextTime) },
onClickPositiveButton = { viewModel.setEvent(MemberMainContract.MemberMainUiEvent.OnSelectTeamScreen) },
onDismiss = { viewModel.setEvent(MemberMainContract.MemberMainUiEvent.OnNextTime) }
)
}

LaunchedEffect(key1 = viewModel.effect) {
viewModel.effect.collect { uiEffect ->
when (uiEffect) {
Expand All @@ -72,6 +91,9 @@ fun MemberMain(
tab = uiEffect.tab
)
}
MemberMainContract.MemberMainUiSideEffect.NavigateToTeam -> {
navigateToTeam()
}
}
}
}
Expand Down Expand Up @@ -206,4 +228,4 @@ private fun ChildNavigation(
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ import com.yapp.common.base.UiState
class MemberMainContract {
data class MemberMainUiState(
val isLoading: Boolean = true,
val showDialog: Boolean = false,
val isShowTeamDialog: Boolean = false,
val selectedTab: BottomNavigationItem = BottomNavigationItem.SESSION,
val isAttendanceCompleted: Boolean = false,
) : UiState

sealed class MemberMainUiSideEffect : UiSideEffect {
data class NavigateToRoute(val tab: BottomNavigationItem) : MemberMainUiSideEffect()
object NavigateToTeam : MemberMainUiSideEffect()
}

sealed class MemberMainUiEvent : UiEvent {
data class OnClickBottomNavigationTab(val tab: BottomNavigationItem) : MemberMainUiEvent()
object OnNextTime : MemberMainUiEvent()
object OnSelectTeamScreen : MemberMainUiEvent()
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,47 @@
package com.yapp.presentation.ui.member.main

import androidx.lifecycle.viewModelScope
import com.yapp.common.base.BaseViewModel
import com.yapp.domain.model.types.TeamType
import com.yapp.domain.usecases.GetCurrentMemberInfoUseCase
import com.yapp.presentation.ui.member.main.MemberMainContract.MemberMainUiEvent
import com.yapp.presentation.ui.member.main.MemberMainContract.MemberMainUiSideEffect
import com.yapp.presentation.ui.member.main.MemberMainContract.MemberMainUiState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import javax.inject.Inject

@HiltViewModel
class MemberMainViewModel @Inject constructor() :
class MemberMainViewModel @Inject constructor(
getMemberGetCurrentMemberInfoUseCase: GetCurrentMemberInfoUseCase
) :
BaseViewModel<MemberMainUiState, MemberMainUiSideEffect, MemberMainUiEvent>(MemberMainUiState()) {

init {
viewModelScope.launch {
val member = getMemberGetCurrentMemberInfoUseCase.invoke().getOrNull()

if(member != null) {
setState { copy(isShowTeamDialog = member.team.type.value == TeamType.NONE.value) }
}
}
}

override suspend fun handleEvent(event: MemberMainUiEvent) {
when (event) {
is MemberMainUiEvent.OnClickBottomNavigationTab -> {
setState { copy(selectedTab = event.tab) }
setEffect( MemberMainUiSideEffect.NavigateToRoute(event.tab))
}
is MemberMainUiEvent.OnNextTime -> {
setState { copy(isShowTeamDialog = false) }
}
is MemberMainUiEvent.OnSelectTeamScreen -> {
setState { copy(isShowTeamDialog = false) }
setEffect(MemberMainUiSideEffect.NavigateToTeam)
}

}
}

}

4 changes: 4 additions & 0 deletions presentation/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
<string name="member_signup_team_number">%d팀</string>
<string name="member_signup_team_confirm">확인</string>

<string name="member_need_select_team">팀을 선택해 주세요</string>
<string name="member_need_select_team_description">원활한 출석체크를 위해\n팀과 직무 선택이 꼭 필요해요!</string>
<string name="member_need_select_team_next_time">다음에요</string>

<string name="name_title">이름을 작성해주세요</string>
<string name="name_subtitle">실명을 작성해야 출석을 확인할 수 있어요</string>
<string name="name_example_hint">ex. 야뿌</string>
Expand Down

0 comments on commit 984740e

Please sign in to comment.