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/#128 #144

Merged
merged 21 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
21 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
a238496
[CHORE] #128 : ์„ค๋ฌธ ๋“ฑ๋ก ๋งˆ์ง€๋ง‰ ๋ฒ„ํŠผ ํ…์ŠคํŠธ, ๋‹ค์Œ -> ์„ค๋ฌธ๋“ฑ๋ก์œผ๋กœ ๋ณ€๊ฒฝ
jeongjaino Feb 27, 2024
5201149
[CHORE] #128 : ์„ค๋ฌธ ์‘๋‹ต Limit 8๊ธ€์ž๋กœ ๋ณ€๊ฒฝ
jeongjaino Feb 27, 2024
fde88b8
[CHORE] #128 : ์ด์ „ ๋ฒ„ํŠผ ํด๋ฆญ์‹œ ๋‹ต๋ณ€ ์ˆ˜์ •๋˜๋„๋ก ๊ตฌํ˜„
jeongjaino Feb 27, 2024
6941989
[CHORE] #128 : Formmating
jeongjaino Feb 27, 2024
83a72f2
[CHORE] #128 : isValidEndTime, _eventStartTime ๋ณ€์ˆ˜๋กœ ๋นผ๊ธฐ
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
Loading