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

Feature/jaino/#126 #143

Merged
merged 16 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
f2019aa
[CHORE] #95 : λ‹€μŒ/제좜 λ²„νŠΌ μ»΄ν¬λ„ŒνŠΈ 생성 -> λ²„νŠΌ λ‚΄μ—μ„œ 뢄기에 따라 ν…μŠ€νŠΈλ§Œ λ³€κ²½λ˜λ„λ‘ μˆ˜μ •
jeongjaino Feb 6, 2024
2469613
[CHORE] #95 : LaunchedEffect μ•ˆ viewModel.apply둜 적용
jeongjaino Feb 6, 2024
c19ab64
Merge branch 'develop' of https://github.com/pknu-wap/WAPP into featu…
jeongjaino Feb 6, 2024
1bfc1f4
[CHORE] #95 : 병합 좩돌 ν•΄κ²°
jeongjaino Feb 6, 2024
06a118d
Merge branch 'develop' of https://github.com/pknu-wap/WAPP into featu…
jeongjaino Feb 17, 2024
bffbc80
[UI] #126 : 일정 등둝 상세 νŽ˜μ΄μ§€ λ‚ μ§œ μ»΄ν¬λ„ŒνŠΈμ™€ λ²„νŠΌκ°„μ˜ 간격 μ„€μ •
jeongjaino Feb 22, 2024
0938fa7
[UI] #126 : 슀크둀 컬럼 외뢀에 적용된 νŒ¨λ”© -> μ•ˆμͺ½μ˜ νŒ¨λ”©μœΌλ‘œ λ³€κ²½
jeongjaino Feb 22, 2024
00ef3ee
[UI] #126 : 일정 μˆ˜μ •μ‹œ BottomBar Hide
jeongjaino Feb 22, 2024
98532a8
[FEATURE] #126 : EventRegistrationState μ„€μ • ViewModel ν•¨μˆ˜ 둜직 μˆ˜μ • / λ‹€μŒ μƒνƒœβ€¦
jeongjaino Feb 26, 2024
8840a59
[FEATURE] #126 : onRegisterButton, onPreviousButton, onNextButton ν΄λ¦­μ‹œβ€¦
jeongjaino Feb 26, 2024
8ad2658
[FEATURE] #126 : λ²„νŠΌν΄λ¦­μ‹œ 검증 ν›„ λ‹€μŒ μƒνƒœλ‘œ λ³€ν™˜λ˜λ„λ‘ κ΅¬ν˜„
jeongjaino Feb 26, 2024
3918d99
[CHORE] #126 : String Resource μΆ”κ°€
jeongjaino Feb 26, 2024
783abfb
[MERGE] #126 : 병합 좩돌 ν•΄κ²°
jeongjaino Feb 26, 2024
d24de47
[UI] #126 : Event, SurveyForm Indicator와 Content 사이 40dp둜 κ³ μ •
jeongjaino Feb 27, 2024
91ba85d
[UI] #126 : ProgressBar Horizontal Margin μ„€μ •
jeongjaino Feb 27, 2024
37f21da
[CHORE] #126 : add String Resource SurveyFrom Registration Animated C…
jeongjaino Feb 27, 2024
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
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.wap.designsystem.WappTheme
import com.wap.designsystem.component.WappSubTopBar
import com.wap.wapp.core.commmon.extensions.toSupportingText
import com.wap.wapp.core.designresource.R.drawable
import com.wap.wapp.feature.management.event.R
import com.wap.wapp.feature.management.event.edit.EventEditViewModel.EventEditEvent
import com.wap.wapp.feature.management.event.registration.EventRegistrationContent
Expand Down Expand Up @@ -84,9 +85,6 @@ internal fun EventEditRoute(
val onStartTimeChanged = viewModel::setEventStartTime
val onEndDateChanged = viewModel::setEventEndDate
val onEndTimeChanged = viewModel::setEventEndTime
val onNextButtonClicked =
viewModel::setEventRegistrationState
val onRegisterButtonClicked = viewModel::updateEvent

LaunchedEffect(true) {
viewModel.getEvent(eventId = eventId)
Expand Down Expand Up @@ -125,10 +123,19 @@ internal fun EventEditRoute(
onStartTimeChanged = onStartTimeChanged,
onEndDateChanged = onEndDateChanged,
onEndTimeChanged = onEndTimeChanged,
onNextButtonClicked = onNextButtonClicked,
onEditButtonClicked = onRegisterButtonClicked,
onBackButtonClicked = navigateToManagement,
onNextButtonClicked = { currentState, nextState ->
if (viewModel.validateEvent(currentState)) {
viewModel.setEventRegistrationState(nextState)
}
},
onCloseButtonClicked = navigateToManagement,
onPreviousButtonClicked = viewModel::setEventRegistrationState,
deleteEvent = viewModel::deleteEvent,
onEditButtonClicked = { lastState ->
if (viewModel.validateEvent(lastState)) {
viewModel.updateEvent()
}
},
)
}

Expand All @@ -151,9 +158,10 @@ internal fun EventEditScreen(
onStartTimeChanged: (LocalTime) -> Unit,
onEndDateChanged: (LocalDate) -> Unit,
onEndTimeChanged: (LocalTime) -> Unit,
onNextButtonClicked: () -> Unit,
onEditButtonClicked: () -> Unit,
onBackButtonClicked: () -> Unit,
onNextButtonClicked: (EventRegistrationState, EventRegistrationState) -> Unit,
onEditButtonClicked: (EventRegistrationState) -> Unit,
onCloseButtonClicked: () -> Unit,
onPreviousButtonClicked: (EventRegistrationState) -> Unit,
deleteEvent: () -> Unit,
) {
var showStartDatePicker by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -190,7 +198,8 @@ internal fun EventEditScreen(
titleRes = R.string.event_edit,
showLeftButton = true,
showRightButton = true,
onClickLeftButton = onBackButtonClicked,
leftButtonDrawableRes = drawable.ic_close,
onClickLeftButton = onCloseButtonClicked,
onClickRightButton = { showDeleteEventDialog = true },
)

Expand All @@ -201,7 +210,7 @@ internal fun EventEditScreen(

EventRegistrationContent(
eventRegistrationState = currentEditState,
modifier = Modifier.padding(top = 50.dp, start = 20.dp, end = 20.dp),
modifier = Modifier.padding(horizontal = 20.dp),
eventTitle = title,
eventContent = content,
location = location,
Expand Down Expand Up @@ -229,6 +238,7 @@ internal fun EventEditScreen(
onEndTimePickerStateChanged = { state -> showEndTimePicker = state },
onNextButtonClicked = onNextButtonClicked,
onRegisterButtonClicked = onEditButtonClicked,
onPreviousButtonClicked = onPreviousButtonClicked,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,46 +84,53 @@ class EventEditViewModel @Inject constructor(
_eventEndTime.value = eventTime
}

fun setEventRegistrationState() {
if (_currentEditState.value == EventRegistrationState.EVENT_DETAILS) {
if (!isValidTitle()) {
emitValidationErrorMessage("행사 이름을 μž…λ ₯ν•˜μ„Έμš”.")
return
fun validateEvent(eventRegistrationState: EventRegistrationState): Boolean {
when (eventRegistrationState) {
EventRegistrationState.EVENT_DETAILS -> {
if (!isValidTitle()) {
emitValidationErrorMessage("행사 이름을 μž…λ ₯ν•˜μ„Έμš”.")
return false
}

if (!isValidContent()) {
emitValidationErrorMessage("행사 λ‚΄μš©μ„ μž…λ ₯ν•˜μ„Έμš”.")
return false
}
}
if (!isValidContent()) {
emitValidationErrorMessage("행사 λ‚΄μš©μ„ μž…λ ₯ν•˜μ„Έμš”.")
return

EventRegistrationState.EVENT_SCHEDULE -> {
if (!isValidLocation()) {
emitValidationErrorMessage("μž₯μ†Œλ₯Ό μž…λ ₯ν•˜μ„Έμš”.")
return false
}

if (!isValidEndTime(_eventEndTime.value)) {
emitValidationErrorMessage("일정 μ’…λ£ŒλŠ” μ‹œμž‘λ³΄λ‹€ λŠ¦μ–΄μ•Ό ν•©λ‹ˆλ‹€.")
return false
}
}
_currentEditState.value = EventRegistrationState.EVENT_SCHEDULE
}
return true
}

fun updateEvent() {
if (!isValidLocation()) {
emitValidationErrorMessage("μž₯μ†Œλ₯Ό μž…λ ₯ν•˜μ„Έμš”.")
return
}

if (!isValidEndTime(_eventEndTime.value)) {
emitValidationErrorMessage("일정 μ’…λ£ŒλŠ” μ‹œμž‘λ³΄λ‹€ λŠ¦μ–΄μ•Ό ν•©λ‹ˆλ‹€.")
return
}
fun setEventRegistrationState(eventRegistrationState: EventRegistrationState) {
_currentEditState.value = eventRegistrationState
}

viewModelScope.launch {
updateEventUseCase(
eventTitle = _eventTitle.value,
eventContent = _eventContent.value,
eventLocation = _eventLocation.value,
eventStartDate = _eventStartDate.value,
eventStartTime = _eventStartTime.value,
eventEndDate = _eventEndDate.value,
eventEndTime = _eventEndTime.value,
eventId = _eventId.value,
).onSuccess {
_eventEditEvent.emit(EventEditEvent.EditSuccess)
}.onFailure { throwable ->
_eventEditEvent.emit(EventEditEvent.Failure(throwable))
}
fun updateEvent() = viewModelScope.launch {
updateEventUseCase(
eventTitle = _eventTitle.value,
eventContent = _eventContent.value,
eventLocation = _eventLocation.value,
eventStartDate = _eventStartDate.value,
eventStartTime = _eventStartTime.value,
eventEndDate = _eventEndDate.value,
eventEndTime = _eventEndTime.value,
eventId = _eventId.value,
).onSuccess {
_eventEditEvent.emit(EventEditEvent.EditSuccess)
}.onFailure { throwable ->
_eventEditEvent.emit(EventEditEvent.Failure(throwable))
}
}

Expand All @@ -136,15 +143,13 @@ class EventEditViewModel @Inject constructor(
}

private fun isValidEndTime(eventTime: LocalTime): Boolean {
if (_eventEndDate.value > _eventStartDate.value) {
return true
}
val startDate = _eventStartDate.value
val endDate = _eventEndDate.value

if (_eventEndDate.value == _eventStartDate.value && eventTime > _eventStartTime.value) {
return true
if (startDate == endDate) {
return eventTime > _eventStartTime.value
}

return false
return startDate < endDate
}

private fun isValidEndDate(eventDate: LocalDate): Boolean = eventDate >= _eventStartDate.value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ internal fun EventRegistrationContent(
onStartTimePickerStateChanged: (Boolean) -> Unit,
onEndDatePickerStateChanged: (Boolean) -> Unit,
onEndTimePickerStateChanged: (Boolean) -> Unit,
onNextButtonClicked: () -> Unit,
onRegisterButtonClicked: () -> Unit,
onNextButtonClicked: (EventRegistrationState, EventRegistrationState) -> Unit,
onRegisterButtonClicked: (EventRegistrationState) -> Unit,
onPreviousButtonClicked: (EventRegistrationState) -> Unit,
) {
val coroutineScope = rememberCoroutineScope()
val focusManager = LocalFocusManager.current

Column(
modifier = modifier
.fillMaxSize()
.addFocusCleaner(focusManager),
.addFocusCleaner(focusManager)
.padding(top = 40.dp),
) {
AnimatedContent(
targetState = eventRegistrationState,
Expand All @@ -91,6 +93,7 @@ internal fun EventRegistrationContent(
slideOutHorizontally(targetOffsetX = { it }) + fadeOut()
}
},
label = stringResource(R.string.event_registration_content_navigation_animated_label),
) { eventState ->
when (eventState) {
EventRegistrationState.EVENT_DETAILS -> EventDetailsContent(
Expand All @@ -102,7 +105,10 @@ internal fun EventRegistrationContent(
coroutineScope.launch {
scrollState.scrollTo(0)
}
onNextButtonClicked()
onNextButtonClicked(
EventRegistrationState.EVENT_DETAILS, // current State
EventRegistrationState.EVENT_SCHEDULE, // next Stae
)
},
)

Expand All @@ -127,7 +133,12 @@ internal fun EventRegistrationContent(
onStartTimePickerStateChanged = onStartTimePickerStateChanged,
onEndDatePickerStateChanged = onEndDatePickerStateChanged,
onEndTimePickerStateChanged = onEndTimePickerStateChanged,
onRegisterButtonClicked = onRegisterButtonClicked,
onRegisterButtonClicked = {
onRegisterButtonClicked(EventRegistrationState.EVENT_SCHEDULE)
},
onPreviousButtonClicked = {
onPreviousButtonClicked(EventRegistrationState.EVENT_DETAILS)
},
)
}
}
Expand Down Expand Up @@ -214,6 +225,7 @@ private fun EventScheduleContent(
onEndDateChanged: (LocalDate) -> Unit,
onEndTimeChanged: (LocalTime) -> Unit,
onRegisterButtonClicked: () -> Unit,
onPreviousButtonClicked: () -> Unit,
) {
if (showEndDatePicker) {
WappDatePickerDialog(
Expand Down Expand Up @@ -328,10 +340,21 @@ private fun EventScheduleContent(

Spacer(modifier = Modifier.weight(1f))

WappButton(
onClick = onRegisterButtonClicked,
textRes = R.string.register_event,
)
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
WappButton(
textRes = R.string.previous,
onClick = onPreviousButtonClicked,
modifier = Modifier.weight(1f),
)

WappButton(
textRes = R.string.register_event,
onClick = onRegisterButtonClicked,
modifier = Modifier.weight(1f),
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.wap.designsystem.WappTheme
import com.wap.designsystem.component.WappSubTopBar
import com.wap.wapp.core.commmon.extensions.toSupportingText
import com.wap.wapp.core.designresource.R.drawable
import com.wap.wapp.feature.management.event.R
import kotlinx.coroutines.flow.collectLatest
import java.time.LocalDate
Expand Down Expand Up @@ -64,9 +65,6 @@ internal fun EventRegistrationRoute(
val onStartTimeChanged = viewModel::setEventStartTime
val onEndDateChanged = viewModel::setEventEndDate
val onEndTimeChanged = viewModel::setEventEndTime
val onNextButtonClicked =
viewModel::setEventRegistrationState
val onRegisterButtonClicked = viewModel::registerEvent

LaunchedEffect(true) {
viewModel.eventRegistrationEvent.collectLatest {
Expand Down Expand Up @@ -99,9 +97,18 @@ internal fun EventRegistrationRoute(
onStartTimeChanged = onStartTimeChanged,
onEndDateChanged = onEndDateChanged,
onEndTimeChanged = onEndTimeChanged,
onNextButtonClicked = onNextButtonClicked,
onRegisterButtonClicked = onRegisterButtonClicked,
onBackButtonClicked = navigateToManagement,
onNextButtonClicked = { currentState, nextState ->
if (viewModel.validateEvent(currentState)) {
viewModel.setEventRegistrationState(nextState)
}
},
onCloseButtonClicked = navigateToManagement,
onPreviousButtonClicked = viewModel::setEventRegistrationState,
onRegisterButtonClicked = { lastState ->
if (viewModel.validateEvent(lastState)) { // λ§ˆμ§€λ§‰ μƒνƒœ λŒ€μž…
viewModel.registerEvent()
}
},
)
}

Expand All @@ -124,9 +131,10 @@ internal fun EventRegistrationScreen(
onStartTimeChanged: (LocalTime) -> Unit,
onEndDateChanged: (LocalDate) -> Unit,
onEndTimeChanged: (LocalTime) -> Unit,
onNextButtonClicked: () -> Unit,
onRegisterButtonClicked: () -> Unit,
onBackButtonClicked: () -> Unit,
onNextButtonClicked: (EventRegistrationState, EventRegistrationState) -> Unit,
onPreviousButtonClicked: (EventRegistrationState) -> Unit,
onRegisterButtonClicked: (EventRegistrationState) -> Unit,
onCloseButtonClicked: () -> Unit,
) {
var showStartDatePicker by remember { mutableStateOf(false) }
var showStartTimePicker by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -154,7 +162,8 @@ internal fun EventRegistrationScreen(
WappSubTopBar(
titleRes = R.string.event_registration,
showLeftButton = true,
onClickLeftButton = onBackButtonClicked,
onClickLeftButton = onCloseButtonClicked,
leftButtonDrawableRes = drawable.ic_close,
)

EventRegistrationStateIndicator(
Expand All @@ -164,8 +173,7 @@ internal fun EventRegistrationScreen(

EventRegistrationContent(
eventRegistrationState = currentRegistrationState,
modifier = Modifier
.padding(top = 50.dp, start = 20.dp, end = 20.dp, bottom = 20.dp),
modifier = Modifier.padding(horizontal = 20.dp),
eventTitle = title,
eventContent = content,
location = location,
Expand All @@ -192,6 +200,7 @@ internal fun EventRegistrationScreen(
onEndDatePickerStateChanged = { state -> showEndDatePicker = state },
onEndTimePickerStateChanged = { state -> showEndTimePicker = state },
onNextButtonClicked = onNextButtonClicked,
onPreviousButtonClicked = onPreviousButtonClicked,
onRegisterButtonClicked = onRegisterButtonClicked,
)
}
Expand Down Expand Up @@ -241,6 +250,7 @@ private fun EventRegistrationStateProgressBar(
stiffness = Spring.StiffnessMediumLow,
dampingRatio = Spring.DampingRatioMediumBouncy,
),
label = stringResource(R.string.event_registration_state_progress_animation),
)

LinearProgressIndicator(
Expand Down
Loading