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

#220 : 신고 페이지 쪽지 수신함 위 노출하도록 변경해요. #222

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 0 additions & 2 deletions app/src/main/kotlin/com/bff/wespot/AppNavGraphs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import com.bff.wespot.entire.screen.destinations.RevokeConfirmScreenDestination
import com.bff.wespot.entire.screen.destinations.RevokeScreenDestination
import com.bff.wespot.entire.screen.destinations.SettingScreenDestination
import com.bff.wespot.message.screen.destinations.MessageEditScreenDestination
import com.bff.wespot.message.screen.destinations.MessageReportScreenDestination
import com.bff.wespot.message.screen.destinations.MessageScreenDestination
import com.bff.wespot.message.screen.destinations.MessageWriteScreenDestination
import com.bff.wespot.message.screen.destinations.ReceiverSelectionScreenDestination
Expand Down Expand Up @@ -76,7 +75,6 @@ object AppNavGraphs {
MessageEditScreenDestination,
ReceiverSelectionScreenDestination,
ReservedMessageScreenDestination,
MessageReportScreenDestination,
).routedIn(this)
.associateBy { it.route }
}
Expand Down
11 changes: 1 addition & 10 deletions app/src/main/kotlin/com/bff/wespot/CommonNavGraphNavigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ import com.bff.wespot.entire.screen.setting.RevokeConfirmNavigator
import com.bff.wespot.entire.screen.setting.RevokeNavigator
import com.bff.wespot.entire.screen.setting.SettingNavigator
import com.bff.wespot.message.screen.MessageNavigator
import com.bff.wespot.message.screen.MessageReportNavigator
import com.bff.wespot.message.screen.MessageReportScreenArgs
import com.bff.wespot.message.screen.MessageScreenArgs
import com.bff.wespot.message.screen.ReservedMessageNavigator
import com.bff.wespot.message.screen.destinations.MessageEditScreenDestination
import com.bff.wespot.message.screen.destinations.MessageReportScreenDestination
import com.bff.wespot.message.screen.destinations.MessageScreenDestination
import com.bff.wespot.message.screen.destinations.MessageWriteScreenDestination
import com.bff.wespot.message.screen.destinations.ReceiverSelectionScreenDestination
Expand Down Expand Up @@ -70,8 +66,7 @@ class CommonNavGraphNavigator(
VoteStorageNavigator,
ReservedMessageNavigator,
IndividualVoteNavigator,
ProfileEditNavigator,
MessageReportNavigator {
ProfileEditNavigator {
override fun navigateUp() {
navController.navigateUp()
}
Expand Down Expand Up @@ -157,8 +152,4 @@ class CommonNavGraphNavigator(
override fun navigateToEntireScreen() {
navController.navigate(EntireScreenDestination within navGraph)
}

override fun navigateMessageReportScreen(args: MessageReportScreenArgs) {
navController.navigate(MessageReportScreenDestination(args) within navGraph)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
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
Expand All @@ -38,27 +39,17 @@ import com.bff.wespot.ui.component.ListBottomGradient
import com.bff.wespot.ui.component.WSSelectionItem
import com.bff.wespot.ui.model.ToastState
import com.bff.wespot.ui.util.handleSideEffect
import com.ramcosta.composedestinations.annotation.Destination
import kotlinx.collections.immutable.persistentListOf
import org.orbitmvi.orbit.compose.collectAsState
import org.orbitmvi.orbit.compose.collectSideEffect

interface MessageReportNavigator {
fun navigateUp()
fun popUpToMessageScreen()
}

data class MessageReportScreenArgs(
val messageId: Int,
)

@OptIn(ExperimentalMaterial3Api::class)
@Destination(navArgsDelegate = MessageReportScreenArgs::class)
@Composable
fun MessageReportScreen(
viewModel: ReportViewModel = hiltViewModel(),
messageId: Int,
showToast: (ToastState) -> Unit,
navigator: MessageReportNavigator,
onDismiss: () -> Unit,
) {
val scrollState = rememberScrollState()

Expand All @@ -69,9 +60,7 @@ fun MessageReportScreen(

viewModel.collectSideEffect {
when (it) {
ReportSideEffect.NavigateToMessage -> {
navigator.popUpToMessageScreen()
}
ReportSideEffect.NavigateToMessage -> onDismiss()

is ReportSideEffect.ShowToast -> {
showToast(
Expand All @@ -90,7 +79,7 @@ fun MessageReportScreen(
WSTopBar(
title = stringResource(id = R.string.report_title),
canNavigateBack = true,
navigateUp = navigator::navigateUp,
navigateUp = onDismiss,
)
},
) { innerPadding ->
Expand Down Expand Up @@ -170,7 +159,9 @@ fun MessageReportScreen(
}

Box(
modifier = Modifier.fillMaxSize().zIndex(1f),
modifier = Modifier
.fillMaxSize()
.zIndex(1f),
contentAlignment = Alignment.BottomCenter,
) {
ListBottomGradient(height = 120)
Expand All @@ -186,4 +177,8 @@ fun MessageReportScreen(
)
}
}

LaunchedEffect(Unit) {
viewModel.onAction(ReportAction.OnMessageReportScreenEntered(messageId))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import kotlinx.collections.immutable.persistentListOf

interface MessageNavigator {
fun navigateUp()
fun navigateMessageReportScreen(args: MessageReportScreenArgs)
fun navigateReceiverSelectionScreen(args: ReceiverSelectionScreenArgs)
fun navigateToReservedMessageScreen()
}
Expand Down Expand Up @@ -95,9 +94,6 @@ internal fun MessageScreen(
navigateToReservedMessageScreen = {
messageNavigator.navigateToReservedMessageScreen()
},
navigateToMessageReportScreen = { args ->
messageNavigator.navigateMessageReportScreen(args)
},
showToast = showToast,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import androidx.compose.ui.zIndex
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.LifecycleStartEffect
Expand All @@ -58,7 +59,7 @@ import com.bff.wespot.message.common.SENT_MESSAGE_INDEX
import com.bff.wespot.message.common.toStringWithDotSeparator
import com.bff.wespot.message.component.ReservedMessageBanner
import com.bff.wespot.message.model.MessageOptionType
import com.bff.wespot.message.screen.MessageReportScreenArgs
import com.bff.wespot.message.screen.MessageReportScreen
import com.bff.wespot.message.state.storage.StorageAction
import com.bff.wespot.message.state.storage.StorageSideEffect
import com.bff.wespot.message.viewmodel.StorageViewModel
Expand All @@ -84,7 +85,6 @@ fun MessageStorageScreen(
type: NotificationType,
messageId: Int? = null,
navigateToReservedMessageScreen: () -> Unit,
navigateToMessageReportScreen: (MessageReportScreenArgs) -> Unit,
showToast: (ToastState) -> Unit,
viewModel: StorageViewModel = hiltViewModel(),
) {
Expand All @@ -96,6 +96,7 @@ fun MessageStorageScreen(
var showBottomSheet by remember { mutableStateOf(false) }
var showMessageDialog by remember { mutableStateOf(false) }
var showMessageOptionDialog by remember { mutableStateOf(false) }
var showMessageReportScreen by remember { mutableStateOf(false) }

val networkState by viewModel.networkState.collectAsStateWithLifecycle()
val context = LocalContext.current
Expand All @@ -114,6 +115,10 @@ fun MessageStorageScreen(
is StorageSideEffect.ShowMessageDialog -> {
showMessageDialog = true
}

is StorageSideEffect.ShowReportMessageScreen -> {
showMessageReportScreen = true
}
}
}

Expand Down Expand Up @@ -236,18 +241,14 @@ fun MessageStorageScreen(
okButtonClick = {
when (state.messageOptionType) {
MessageOptionType.DELETE -> {
action(
StorageAction.OnMessageDeleteButtonClicked,
)
action(StorageAction.OnMessageDeleteButtonClicked)
}
MessageOptionType.BLOCK -> {
action(
StorageAction.OnMessageBlockButtonClicked,
)
action(StorageAction.OnMessageBlockButtonClicked)
}
MessageOptionType.REPORT -> {
action(StorageAction.OnMessageReportButtonClicked)
}
MessageOptionType.REPORT -> navigateToMessageReportScreen(
MessageReportScreenArgs(state.optionButtonClickedMessageId),
)
}
showMessageOptionDialog = false
showBottomSheet = false
Expand All @@ -257,6 +258,19 @@ fun MessageStorageScreen(
)
}

if (showMessageReportScreen) {
Dialog(
onDismissRequest = { },
properties = DialogProperties(usePlatformDefaultWidth = false),
) {
MessageReportScreen(
messageId = state.optionButtonClickedMessageId,
showToast = showToast,
onDismiss = { showMessageReportScreen = false },
)
}
}

if (state.isLoading) {
LoadingAnimation()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.bff.wespot.message.model.ReportReason

sealed class ReportAction {
data object OnMessageReportButtonClicked : ReportAction()
data class OnMessageReportScreenEntered(val messageId: Int) : ReportAction()
data class OnReportReasonSelected(val reportReason: ReportReason) : ReportAction()
data class OnReportReasonChanged(val reason: String) : ReportAction()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.bff.wespot.message.state.report
import com.bff.wespot.message.model.ReportReason

data class ReportUiState(
val messageId: Int,
val messageId: Int = -1,
val reportReason: ReportReason = ReportReason(),
val inputReportReason: String = "",
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sealed class StorageAction {
data object CancelTimeTracking : StorageAction()
data object OnMessageBlockButtonClicked : StorageAction()
data object OnMessageDeleteButtonClicked : StorageAction()
data object OnMessageReportButtonClicked : StorageAction()
data class OnStorageChipSelected(val messageType: MessageType) : StorageAction()
data class OnReceivedMessageClicked(val message: ReceivedMessage) : StorageAction()
data class OnSentMessageClicked(val message: Message) : StorageAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import com.bff.wespot.ui.model.ToastState
sealed class StorageSideEffect {
data class ShowToast(val toastState: ToastState) : StorageSideEffect()
data object ShowMessageDialog : StorageSideEffect()
data object ShowReportMessageScreen : StorageSideEffect()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.bff.wespot.message.viewmodel

import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.viewModelScope
import com.bff.wespot.common.extension.onNetworkFailure
import com.bff.wespot.domain.repository.CommonRepository
Expand All @@ -24,22 +23,27 @@ import javax.inject.Inject
@HiltViewModel
class ReportViewModel @Inject constructor(
private val commonRepository: CommonRepository,
savedStateHandle: SavedStateHandle,
) : BaseViewModel(), ContainerHost<ReportUiState, ReportSideEffect> {
override val container = container<ReportUiState, ReportSideEffect>(
ReportUiState(
messageId = savedStateHandle["messageId"] ?: -1,
),
)
override val container = container<ReportUiState, ReportSideEffect>(ReportUiState())

fun onAction(action: ReportAction) {
when (action) {
is ReportAction.OnMessageReportScreenEntered -> {
handleMessageReportScreenEntered(action.messageId)
}
is ReportAction.OnReportReasonSelected -> handleReportReasonSelected(action.reportReason)
is ReportAction.OnReportReasonChanged -> handleReportReasonChanged(action.reason)
ReportAction.OnMessageReportButtonClicked -> reportMessage()
}
}

private fun handleMessageReportScreenEntered(messageId: Int) = intent {
/** MessageReportScreen이 Dialog로, 보이지 않아도 상태가 유지되므로 진입시에 상태를 초기화 한다.*/
reduce {
ReportUiState(messageId = messageId)
}
}

private fun handleReportReasonSelected(reportReason: ReportReason) = intent {
reduce {
/** 이미 선택된 신고 사유를 클릭한 경우 선택 해제됨. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,9 @@ class StorageViewModel @Inject constructor(
when (action) {
StorageAction.StartTimeTracking -> startTimePeriodChecker()
StorageAction.CancelTimeTracking -> cancelTimePeriodChecker()
StorageAction.OnMessageDeleteButtonClicked -> {
handleDeleteMessageButtonClicked()
}
StorageAction.OnMessageBlockButtonClicked -> {
handleBlockMessageButtonClicked()
}
StorageAction.OnMessageDeleteButtonClicked -> handleMessageDeleteButtonClicked()
StorageAction.OnMessageBlockButtonClicked -> handleMessageBlockButtonClicked()
StorageAction.OnMessageReportButtonClicked -> handleMessageReportButtonClicked()
is StorageAction.OnStorageChipSelected -> {
when (action.messageType) {
MessageType.SENT -> {
Expand Down Expand Up @@ -216,7 +213,7 @@ class StorageViewModel @Inject constructor(
}
}

private fun handleDeleteMessageButtonClicked() = intent {
private fun handleMessageDeleteButtonClicked() = intent {
viewModelScope.launch {
messageStorageRepository.deleteMessage(state.optionButtonClickedMessageId)
.onSuccess {
Expand All @@ -241,7 +238,7 @@ class StorageViewModel @Inject constructor(
}
}

private fun handleBlockMessageButtonClicked() = intent {
private fun handleMessageBlockButtonClicked() = intent {
viewModelScope.launch {
messageStorageRepository.blockMessage(state.optionButtonClickedMessageId)
.onSuccess {
Expand All @@ -261,4 +258,8 @@ class StorageViewModel @Inject constructor(
}
}
}

private fun handleMessageReportButtonClicked() = intent {
postSideEffect(StorageSideEffect.ShowReportMessageScreen)
}
}
Loading