Skip to content

Commit

Permalink
📝 :: Temporary Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
audgns10 committed Nov 29, 2024
1 parent f878bcc commit a958047
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ internal fun ExpoCreateRoute(
val coverImageState by viewModel.cover_image.collectAsStateWithLifecycle()
val trainingProgramTextState by viewModel.trainingProgramTextState.collectAsStateWithLifecycle()
val standardProgramTextState by viewModel.standardProgramTextState.collectAsStateWithLifecycle()
val startedTextState by viewModel.trainingStartedList.collectAsStateWithLifecycle()
val endedTextState by viewModel.trainingEndedList.collectAsStateWithLifecycle()
val categoryList by viewModel.trainingCategoryList.collectAsStateWithLifecycle()
val startedTextState by viewModel.started.collectAsStateWithLifecycle()
val endedTextState by viewModel.ended.collectAsStateWithLifecycle()

var selectedImageUri by remember { mutableStateOf<Uri?>(null) }

Expand All @@ -119,10 +118,6 @@ internal fun ExpoCreateRoute(
}
}

LaunchedEffect(Unit) {
viewModel.addTrainingProgram()
}

LaunchedEffect(imageUpLoadUiState) {
when (imageUpLoadUiState) {
is ImageUpLoadUiState.Loading -> Unit
Expand Down Expand Up @@ -155,12 +150,12 @@ internal fun ExpoCreateRoute(
is RegisterExpoInformationUiState.Success -> {
viewModel.registerTrainingProgramList(
expoId = (registerExpoInformationUiState as RegisterExpoInformationUiState.Success).data.expoId,
body = viewModel.trainingProgramTextState.value.mapIndexed { index, title ->
body = viewModel.trainingProgramTextState.value.map { title ->
TrainingDtoModel(
title = title,
startedAt = startedTextState[index],
endedAt = endedTextState[index],
category = categoryList[index].toString()
startedAt = viewModel.started.value,
endedAt = viewModel.ended.value,
category = viewModel.categoryState.value.toString()
)
}
)
Expand Down Expand Up @@ -218,15 +213,9 @@ internal fun ExpoCreateRoute(
onRemoveStandardProgram = viewModel::removeStandardProgramText,
startedTextState = startedTextState,
endedTextState = endedTextState,
onStartedChange = { index, value ->
viewModel.updateTrainingStarted(index, value)
},
onEndedChange = { index, value ->
viewModel.updateTrainingEnded(index, value)
},
onTrainingCategoryChange = { index, value ->
viewModel.updateTrainingCategory(index, value)
}
onStartedChange = viewModel::onStartedChange,
onEndedChange = viewModel::onEndedChange,
onTrainingCategoryChange = viewModel::updateCategory
)
}

Expand Down Expand Up @@ -258,11 +247,11 @@ internal fun ExpoCreateScreen(
onStandardProgramChange: (Int, String) -> Unit,
onAddStandardProgram: () -> Unit,
onRemoveStandardProgram: (Int) -> Unit,
startedTextState: List<String>,
endedTextState: List<String>,
onStartedChange: (Int, String) -> Unit,
onEndedChange: (Int, String) -> Unit,
onTrainingCategoryChange: (Int, TrainingCategory) -> Unit
startedTextState: String,
endedTextState: String,
onStartedChange: (String) -> Unit,
onEndedChange: (String) -> Unit,
onTrainingCategoryChange: (TrainingCategory) -> Unit
) {
val (openTrainingSettingBottomSheet, isOpenTrainingSettingBottomSheet) = rememberSaveable { mutableStateOf(false) }

Expand Down Expand Up @@ -580,10 +569,10 @@ private fun ExpoCreateScreenPreview() {
onStandardProgramChange = { _, _ -> },
onAddStandardProgram = {},
onRemoveStandardProgram = {},
startedTextState = listOf(),
endedTextState = listOf(),
onStartedChange = {_, _ ->},
onEndedChange = {_, _ ->},
onTrainingCategoryChange = {_, _ ->}
startedTextState = "",
endedTextState = "",
onStartedChange = {},
onEndedChange = {},
onTrainingCategoryChange = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ import com.school_of_company.expo.enum.TrainingCategory
fun ExpoTrainingSettingBottomSheet(
modifier: Modifier = Modifier,
onCancelClick: () -> Unit,
startedTextState: List<String>,
endedTextState: List<String>,
onStartedTextChange: (Int, String) -> Unit,
onEndedTextChange: (Int, String) -> Unit,
startedTextState: String,
endedTextState: String,
onStartedTextChange: (String) -> Unit,
onEndedTextChange: (String) -> Unit,
onButtonClick: () -> Unit,
categoryState: TrainingCategory = TrainingCategory.CHOICE,
onCategoryChange: (Int, TrainingCategory) -> Unit,
onCategoryChange: (TrainingCategory) -> Unit,
focusManager: FocusManager = LocalFocusManager.current
) {
val sheetState = rememberModalBottomSheetState()
Expand Down Expand Up @@ -113,60 +113,56 @@ fun ExpoTrainingSettingBottomSheet(
)
}

startedTextState.forEachIndexed { index, startedTextState ->
Row(verticalAlignment = Alignment.CenterVertically) {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.Top),
modifier = Modifier.weight(1f)
) {
ExpoNoneLineTextField(
textState = startedTextState,
placeHolder = {
Text(
text = "yyyy-MM-dd HH:mm",
style = typography.titleBold2,
color = colors.gray300,
maxLines = 1
)
},
onTextChange = { newText ->
onStartedTextChange(index, newText)
}
)

ExpoNoneLineTextField(
textState = endedTextState[index],
placeHolder = {
Text(
text = "yyyy-MM-dd HH:mm",
style = typography.titleBold2,
color = colors.gray300,
maxLines = 1
)
},
onTextChange = { newText ->
onEndedTextChange(index, newText)
}
)
}

Row(
horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "필수",
style = typography.bodyRegular2,
color = colors.gray500
)

CustomCheckBox(
categoryState = categoryState,
onCategoryChange = { newCategory ->
onCategoryChange(index, newCategory)
}
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Column(
verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.Top),
modifier = Modifier.weight(1f)
) {
ExpoNoneLineTextField(
textState = startedTextState,
placeHolder = {
Text(
text = "yyyy-MM-dd HH:mm",
style = typography.titleBold2,
color = colors.gray300,
maxLines = 1
)
},
onTextChange = { newText ->
onStartedTextChange(newText)
}
)

ExpoNoneLineTextField(
textState = endedTextState,
placeHolder = {
Text(
text = "yyyy-MM-dd HH:mm",
style = typography.titleBold2,
color = colors.gray300,
maxLines = 1
)
},
onTextChange = { newText ->
onEndedTextChange(newText)
}
)
}

Row(
horizontalArrangement = Arrangement.spacedBy(16.dp, Alignment.Start),
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = "필수",
style = typography.bodyRegular2,
color = colors.gray500
)

CustomCheckBox(
categoryState = categoryState,
onCategoryChange = onCategoryChange
)
}
}

Expand Down Expand Up @@ -232,13 +228,13 @@ fun CustomCheckBox(
private fun ExpoTrainingSettingBottomSheetPreview() {
ExpoTrainingSettingBottomSheet(
onCancelClick = {},
startedTextState = listOf(),
endedTextState = listOf(),
onStartedTextChange = {_, _ ->},
onEndedTextChange = {_, _ ->},
startedTextState = "",
endedTextState = "",
onStartedTextChange = {},
onEndedTextChange = {},
onButtonClick = {},
categoryState = TrainingCategory.ESSENTIAL,
onCategoryChange = {_, _ ->}
onCategoryChange = {}
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ExpoViewModel @Inject constructor(
private val _categoryState = MutableStateFlow(TrainingCategory.CHOICE)
val categoryState = _categoryState.asStateFlow()


private val _getExpoInformationUiState = MutableStateFlow<GetExpoInformationUiState>(GetExpoInformationUiState.Loading)
internal val getExpoInformationUiState = _getExpoInformationUiState.asStateFlow()

Expand Down Expand Up @@ -120,33 +121,6 @@ class ExpoViewModel @Inject constructor(

internal var ended = savedStateHandle.getStateFlow(key = ENDED, initialValue = "")

private val _trainingStartedList = MutableStateFlow<List<String>>(emptyList())
val trainingStartedList: StateFlow<List<String>> = _trainingStartedList

private val _trainingEndedList = MutableStateFlow<List<String>>(emptyList())
val trainingEndedList: StateFlow<List<String>> = _trainingEndedList

private val _trainingCategoryList = MutableStateFlow<List<TrainingCategory>>(emptyList())
val trainingCategoryList: StateFlow<List<TrainingCategory>> = _trainingCategoryList

fun updateTrainingStarted(index: Int, value: String) {
_trainingStartedList.value = _trainingStartedList.value.toMutableList().apply { this[index] = value }
}

fun updateTrainingEnded(index: Int, value: String) {
_trainingEndedList.value = _trainingEndedList.value.toMutableList().apply { this[index] = value }
}

fun updateTrainingCategory(index: Int, value: TrainingCategory) {
_trainingCategoryList.value = _trainingCategoryList.value.toMutableList().apply { this[index] = value }
}

fun addTrainingProgram() {
_trainingStartedList.value += ""
_trainingEndedList.value += ""
_trainingCategoryList.value += TrainingCategory.CHOICE
}

internal fun getExpoInformation(expoId: String) = viewModelScope.launch {
getExpoInformationUseCase(expoId = expoId)
.asResult()
Expand Down

0 comments on commit a958047

Please sign in to comment.