Skip to content

Commit

Permalink
Merge pull request #282 from Project-Unifest/qa/qa
Browse files Browse the repository at this point in the history
[QA] 웨이팅 부재 다이얼로그 처리, 새로고침에 딜레이 추가
  • Loading branch information
wjdtkdgns777 authored Oct 25, 2024
2 parents d9415b4 + 5890f97 commit ad217e9
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,26 @@ fun NoShowWaitingCancelDialog(
}
}

@Composable
fun NoShowAlertDialog(
onCancelClick: () -> Unit,
onConfirmClick: () -> Unit,
) {
UnifestTheme {
UnifestDialog(
onDismissRequest = {},
titleResId = R.string.waiting_no_show_title,
iconResId = designR.drawable.ic_caution,
iconDescription = "Caution Icon",
descriptionResId = R.string.waiting_no_show_alert_description,
confirmTextResId = R.string.waiting_no_show_button,
cancelTextResId = R.string.waiting_no_show_cancel,
onCancelClick = onCancelClick,
onConfirmClick = onConfirmClick,
)
}
}

@ComponentPreview
@Composable
private fun WaitingPinDialogPreview() {
Expand Down Expand Up @@ -584,3 +604,14 @@ private fun WaitingConfirmDialogPreview() {
)
}
}

@ComponentPreview
@Composable
private fun NoShowAlertDialogPreview() {
UnifestTheme {
NoShowAlertDialog(
onCancelClick = { },
onConfirmClick = { },
)
}
}
5 changes: 5 additions & 0 deletions core/ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@
<string name="waiting_cancel_dialog_description">정말 취소 하시겠습니까?</string>
<string name="waiting_no_show_dialog_title">부재 웨이팅을 지웁니다</string>
<string name="waiting_no_show_dialog_description">문제가 있는 경우 해당 부스 운영자에 문의바랍니다</string>
<string name="waiting_no_show_title">부재 처리된 부스에요</string>
<string name="waiting_no_show_alert_description">다시 웨이팅하려면 부재 웨이팅을 지워야해요.\n웨이팅 탭으로 이동하시겠어요?</string>
<string name="waiting_no_show_button">이동하기</string>
<string name="waiting_no_show_cancel">취소</string>


</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.unifest.android.core.designsystem.theme.DarkGrey100
import com.unifest.android.core.designsystem.theme.Title2
import com.unifest.android.core.designsystem.theme.UnifestTheme
import com.unifest.android.core.ui.DevicePreview
import com.unifest.android.core.ui.component.NoShowAlertDialog
import com.unifest.android.core.ui.component.WaitingConfirmDialog
import com.unifest.android.core.ui.component.WaitingDialog
import com.unifest.android.core.ui.component.WaitingPinDialog
Expand All @@ -73,6 +74,7 @@ internal fun BoothDetailRoute(
padding: PaddingValues,
onBackClick: () -> Unit,
navigateToBoothLocation: () -> Unit,
navigateToWaiting: () -> Unit,
viewModel: BoothViewModel = hiltViewModel(),
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
Expand Down Expand Up @@ -101,6 +103,7 @@ internal fun BoothDetailRoute(
when (event) {
is BoothUiEvent.NavigateBack -> onBackClick()
is BoothUiEvent.NavigateToBoothLocation -> navigateToBoothLocation()
is BoothUiEvent.NavigateToWaiting -> navigateToWaiting()
is BoothUiEvent.NavigateToPrivatePolicy -> uriHandler.openUri(BuildConfig.UNIFEST_PRIVATE_POLICY_URL)
is BoothUiEvent.NavigateToThirdPartyPolicy -> uriHandler.openUri(BuildConfig.UNIFEST_THIRD_PARTY_POLICY_URL)
is BoothUiEvent.ShowSnackBar -> {
Expand Down Expand Up @@ -232,6 +235,13 @@ fun BoothDetailScreen(
onConfirmClick = { onAction(BoothUiAction.OnConfirmDialogDismiss) },
)
}

if (uiState.isNoShowDialogVisible) {
NoShowAlertDialog(
onCancelClick = { onAction(BoothUiAction.OnNoShowDialogCancelClick) },
onConfirmClick = { onAction(BoothUiAction.OnMoveClick) },
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const val BOOTH_ID = "booth_id"
const val BOOTH_ROUTE = "booth_route/{$BOOTH_ID}"
const val BOOTH_DETAIL_ROUTE = "booth_detail_route"
const val BOOTH_LOCATION_ROUTE = "booth_location_route"
const val WAITING_ROUTE = "waiting_route"

fun NavController.navigateToBoothDetail(
boothId: Long,
Expand All @@ -35,6 +36,7 @@ fun NavGraphBuilder.boothNavGraph(
navController: NavHostController,
popBackStack: () -> Unit,
navigateToBoothLocation: () -> Unit,
navigateToWaiting: () -> Unit,
) {
// navigation<Route.Booth>(
// startDestination = Route.Booth.BoothDetail::class,
Expand All @@ -55,6 +57,7 @@ fun NavGraphBuilder.boothNavGraph(
padding = padding,
onBackClick = popBackStack,
navigateToBoothLocation = navigateToBoothLocation,
navigateToWaiting = navigateToWaiting,
viewModel = viewModel,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ sealed interface BoothUiAction {
data object OnPrivatePolicyClick : BoothUiAction
data object OnThirdPartyPolicyClick : BoothUiAction
data object OnRunningClick : BoothUiAction
data object OnMoveClick : BoothUiAction
data object OnNoShowDialogCancelClick : BoothUiAction
}

enum class ErrorType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ sealed interface BoothUiEvent {
data object NavigateToThirdPartyPolicy : BoothUiEvent
data class ShowToast(val message: UiText) : BoothUiEvent
data object NavigateToAppSetting : BoothUiEvent
data object NavigateToWaiting : BoothUiEvent
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ data class BoothUiState(
val isPinCheckDialogVisible: Boolean = false,
val isWaitingDialogVisible: Boolean = false,
val isConfirmDialogVisible: Boolean = false,
val isNoShowDialogVisible: Boolean = false,
val isMenuImageDialogVisible: Boolean = false,
val isWrongPinInserted: Boolean = false,
val selectedMenu: MenuModel? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class BoothViewModel @Inject constructor(
is BoothUiAction.OnPrivatePolicyClick -> navigateToPrivatePolicy()
is BoothUiAction.OnThirdPartyPolicyClick -> navigateToThirdPartyPolicy()
is BoothUiAction.OnRunningClick -> expandRunningTime()
is BoothUiAction.OnMoveClick -> navigateToWaiting()
is BoothUiAction.OnNoShowDialogCancelClick -> setNoShowDialogVisible(false)
}
}

Expand All @@ -84,17 +86,21 @@ class BoothViewModel @Inject constructor(
_uiState.update {
it.copy(myWaitingList = waitingLists.toImmutableList())
}
val currentBoothId = _uiState.value.boothDetailInfo.id
val matchingBooth = _uiState.value.myWaitingList.find { it.boothId == currentBoothId }

val isAlreadyInWaitingList = _uiState.value.myWaitingList.any { it.boothId == _uiState.value.boothDetailInfo.id }
when {
isAlreadyInWaitingList -> {
matchingBooth?.status == "NOSHOW" -> {
setNoShowDialogVisible(true)
}

matchingBooth != null -> {
_uiEvent.send(BoothUiEvent.ShowSnackBar(UiText.StringResource(R.string.booth_waiting_already_exists)))
}

_uiState.value.myWaitingList.size >= 3 -> {
_uiEvent.send(BoothUiEvent.ShowSnackBar(UiText.StringResource(R.string.booth_waiting_full)))
}

else -> {
setPinCheckDialogVisible(true)
}
Expand Down Expand Up @@ -193,6 +199,13 @@ class BoothViewModel @Inject constructor(
}
}

private fun navigateToWaiting() {
setNoShowDialogVisible(false)
viewModelScope.launch {
_uiEvent.send(BoothUiEvent.NavigateToWaiting)
}
}

private fun expandRunningTime() {
_uiState.update {
it.copy(isRunning = !it.isRunning)
Expand Down Expand Up @@ -419,6 +432,12 @@ class BoothViewModel @Inject constructor(
}
}

private fun setNoShowDialogVisible(flag: Boolean) {
_uiState.update {
it.copy(isNoShowDialogVisible = flag)
}
}

private fun setConfirmDialogVisible(flag: Boolean) {
_uiState.update {
it.copy(isConfirmDialogVisible = flag)
Expand Down
1 change: 1 addition & 0 deletions feature/booth/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<string name="booth_is_closed">운영종료</string>
<string name="booth_waiting_full">웨이팅은 최대 3부스까지 가능해요!</string>
<string name="booth_waiting_already_exists">이미 웨이팅 한 부스에요!</string>
<string name="booth_waiting_noshow">웨이팅 부재처리를 먼저 삭제해주세요!</string>
<string name="sold_out">품절</string>
<string name="almost_sold_out_less_than_5_left">품절 임박 5개 미만 남음</string>
<string name="no_menu_status">등록된 정보 없음</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ internal class MainNavController(
navController.navigateToLikedBooth()
}

fun navigateToWaiting() {
navigate(MainTab.WAITING)
}

private fun popBackStack() {
navController.popBackStack()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ internal fun MainScreen(
navController = navigator.navController,
popBackStack = navigator::popBackStackIfNotMap,
navigateToBoothLocation = navigator::navigateToBoothLocation,
navigateToWaiting = navigator::navigateToWaiting,
)
waitingNavGraph(
padding = innerPadding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshContainer
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
// import androidx.compose.material3.pulltorefresh.PullToRefreshContainer
// import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.nestedscroll.nestedScroll
// import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextDecoration
Expand All @@ -41,6 +41,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.unifest.android.core.common.ObserveAsEvents
import com.unifest.android.core.common.extension.clickableSingle
import com.unifest.android.core.designsystem.component.LoadingWheel
import com.unifest.android.core.designsystem.theme.BoothTitle2
import com.unifest.android.core.designsystem.theme.Content2
import com.unifest.android.core.designsystem.theme.Content7
Expand All @@ -56,7 +57,7 @@ import com.unifest.android.feature.waiting.viewmodel.WaitingUiAction
import com.unifest.android.feature.waiting.viewmodel.WaitingUiEvent
import com.unifest.android.feature.waiting.viewmodel.WaitingUiState
import com.unifest.android.feature.waiting.viewmodel.WaitingViewModel
import kotlinx.coroutines.delay
// import kotlinx.coroutines.delay

@Composable
internal fun WaitingRoute(
Expand All @@ -75,7 +76,7 @@ internal fun WaitingRoute(
}
}
LaunchedEffect(key1 = Unit) {
viewModel.getMyWaitingList()
viewModel.getMyWaitingList(false)
}

WaitingScreen(
Expand All @@ -92,20 +93,20 @@ internal fun WaitingScreen(
waitingUiState: WaitingUiState,
onWaitingUiAction: (WaitingUiAction) -> Unit,
) {
val pullToRefreshState = rememberPullToRefreshState()
// val pullToRefreshState = rememberPullToRefreshState()

LaunchedEffect(key1 = pullToRefreshState.isRefreshing) {
if (pullToRefreshState.isRefreshing) {
delay(1000)
onWaitingUiAction(WaitingUiAction.OnRefresh)
pullToRefreshState.endRefresh()
}
}
// LaunchedEffect(key1 = pullToRefreshState.isRefreshing) {
// if (pullToRefreshState.isRefreshing) {
// delay(1000)
// onWaitingUiAction(WaitingUiAction.OnRefresh)
// pullToRefreshState.endRefresh()
// }
// }

Box(
modifier = Modifier
.fillMaxSize()
.nestedScroll(pullToRefreshState.nestedScrollConnection)
// .nestedScroll(pullToRefreshState.nestedScrollConnection)
.background(MaterialTheme.colorScheme.background)
.padding(padding),
) {
Expand Down Expand Up @@ -192,12 +193,12 @@ internal fun WaitingScreen(
Spacer(modifier = Modifier.height(8.dp))
}
}
if (pullToRefreshState.isRefreshing) {
PullToRefreshContainer(
modifier = Modifier.align(Alignment.TopCenter),
state = pullToRefreshState,
)
}
// if (pullToRefreshState.isRefreshing) {
// PullToRefreshContainer(
// modifier = Modifier.align(Alignment.TopCenter),
// state = pullToRefreshState,
// )
// }
}
if (waitingUiState.myWaitingList.isEmpty()) {
Box(
Expand Down Expand Up @@ -242,6 +243,10 @@ internal fun WaitingScreen(
onConfirmClick = { onWaitingUiAction(WaitingUiAction.OnNoShowWaitingCancelDialogConfirmClick) },
)
}

if (waitingUiState.isLoading) {
LoadingWheel(modifier = Modifier.fillMaxSize())
}
}

@DevicePreview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ sealed interface WaitingUiAction {
data class OnCancelWaitingClick(val waitingId: Long) : WaitingUiAction
data class OnCancelNoShowWaitingClick(val waitingId: Long) : WaitingUiAction
data class OnCheckBoothDetailClick(val boothId: Long) : WaitingUiAction
data object OnPullToRefresh : WaitingUiAction
data object OnWaitingCancelDialogCancelClick : WaitingUiAction
data object OnWaitingCancelDialogConfirmClick : WaitingUiAction
data object OnNoShowWaitingCancelDialogCancelClick : WaitingUiAction
data object OnNoShowWaitingCancelDialogConfirmClick : WaitingUiAction
data object OnLookForBoothClick : WaitingUiAction
data object OnRefresh : WaitingUiAction
// data object OnPullToRefresh : WaitingUiAction
}
Loading

0 comments on commit ad217e9

Please sign in to comment.