Skip to content

Commit

Permalink
[CHORE] #90 : 병합 충돌 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongjaino committed Jan 7, 2024
1 parent b54296d commit 2e2f5b3
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal fun ManagementEventCard(
colors = CardDefaults.cardColors(
containerColor = WappTheme.colors.black25,
),
modifier = Modifier.padding(horizontal = 8.dp),
) {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@

package com.wap.wapp.feature.management

import android.content.Context
import android.widget.Toast
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
Expand All @@ -19,8 +23,10 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.wap.designsystem.WappTheme
import com.wap.designsystem.component.WappMainTopBar
import com.wap.wapp.core.commmon.extensions.toSupportingText
Expand All @@ -37,11 +43,33 @@ internal fun ManagementRoute(
viewModel: ManagementViewModel = hiltViewModel(),
) {
var isShowDialog by rememberSaveable { mutableStateOf(false) }
val snackBarHostState = remember { SnackbarHostState() }
val surveyFormsState by viewModel.surveyFormList.collectAsStateWithLifecycle()
val eventsState by viewModel.eventList.collectAsStateWithLifecycle()
val context = LocalContext.current

LaunchedEffect(true) {
viewModel.errorFlow.collectLatest { throwable ->
snackBarHostState.showSnackbar(
message = throwable.toSupportingText(),
)
}
}

LaunchedEffect(true) {
viewModel.managerState.collectLatest { managerState ->
when (managerState) {
ManagerState.Init -> {}
ManagerState.NonManager -> { isShowDialog = true }
ManagerState.Manager -> viewModel.getEventSurveyList()
}
}
}

ManagementScreen(
viewModel = viewModel,
showManageCodeDialog = { isShowDialog = true },
snackBarHostState = snackBarHostState,
surveyFormsState = surveyFormsState,
eventsState = eventsState,
navigateToEventRegistration = navigateToEventRegistration,
navigateToSurveyRegistration = navigateToSurveyRegistration,
navigateToSurveyCheck = navigateToSurveyCheck,
Expand All @@ -58,73 +86,53 @@ internal fun ManagementRoute(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun ManagementScreen(
viewModel: ManagementViewModel,
showManageCodeDialog: () -> Unit,
snackBarHostState: SnackbarHostState,
surveyFormsState: ManagementViewModel.SurveyFormsState,
eventsState: ManagementViewModel.EventsState,
navigateToEventEdit: (String, String) -> Unit,
navigateToEventRegistration: () -> Unit,
navigateToSurveyRegistration: () -> Unit,
navigateToSurveyCheck: (String) -> Unit,
) {
val snackBarHostState = remember { SnackbarHostState() }
val surveysState by viewModel.surveyList.collectAsState()
val eventsState by viewModel.eventList.collectAsState()

LaunchedEffect(true) {
viewModel.managerState.collectLatest { managerState ->
when (managerState) {
ManagerState.Init -> {}
ManagerState.NonManager -> showManageCodeDialog()
ManagerState.Manager -> viewModel.getEventSurveyList()
}
}

viewModel.errorFlow.collectLatest { throwable ->
snackBarHostState.showSnackbar(
message = throwable.toSupportingText(),
)
}
}
Scaffold(
containerColor = WappTheme.colors.backgroundBlack,
contentWindowInsets = WindowInsets(0.dp),
snackbarHost = { SnackbarHost(snackBarHostState) },
) { paddingValues ->
WappMainTopBar(
titleRes = R.string.management,
contentRes = R.string.management_content,
)

Column(
modifier = Modifier.padding(paddingValues),
) {
WappMainTopBar(
titleRes = R.string.management,
contentRes = R.string.management_content,
)

ManagementEventContent(
ManagementEventCard(
eventsState = eventsState,
onCardClicked = navigateToEventEdit,
onAddEventButtonClicked = navigateToEventRegistration,
modifier = Modifier.padding(horizontal = 8.dp),
)

ManagementSurveyContent(
surveysState = surveysState,
ManagementSurveyCard(
surveyFormsState = surveyFormsState,
onCardClicked = navigateToSurveyCheck,
onAddSurveyButtonClicked = navigateToSurveyRegistration,
modifier = Modifier
.padding(top = 20.dp)
.padding(horizontal = 8.dp),
)
}
}
}

@Composable
internal fun ManagementCardColor(currentIndex: Int): Color =
if (currentIndex % 2 == 0) {
internal fun ManagementCardColor(currentIndex: Int): Color {
return if (currentIndex % 2 == 0) {
WappTheme.colors.black82
} else {
WappTheme.colors.black42
}
}

private fun showToast(text: String, context: Context) =
private fun showToast(text: String, context: Context) {
Toast.makeText(context, text, Toast.LENGTH_SHORT).show()
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ internal fun ManagementSurveyCard(
colors = CardDefaults.cardColors(
containerColor = WappTheme.colors.black25,
),
modifier = Modifier.padding(top = 20.dp),
modifier = Modifier
.padding(top = 20.dp)
.padding(horizontal = 8.dp),
) {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp),
Expand Down

0 comments on commit 2e2f5b3

Please sign in to comment.