Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ data class CalendarAppointmentDayDto(

@Serializable
data class CalendarAppointmentDto(
@SerialName("id") val id: Long,
@SerialName("appointmentId") val appointmentId: Long,
@SerialName("optionId") val optionId: Long,
Comment on lines +22 to +23
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: 넘넘 고마워이ㅣㅣ

@SerialName("name") val name: String,
@SerialName("date") val date: String,
@SerialName("startTime") val startTime: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ data class ResponseGetTimeTableDto(

@Serializable
data class ResponseAppointmentScheduleDto(
@SerialName("duration") val duration: Long,
@SerialName("appointmentHostSelectionTimes") val appointmentHostSelectionTimes: List<BaseTimeDto>,
@SerialName("appointmentMembersInfo") val appointmentMembersInfo: List<ResponseAppointmentMembersInfoDto?>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ fun CalendarAppointmentDayDto.toCalendarAppointmentDayEntity() = CalendarAppoint
)

fun CalendarAppointmentDto.toCalendarAppointmentEntity() = CalendarAppointmentEntity(
id = id,
appointmentId = appointmentId,
optionId = optionId,
name = name,
date = date,
startTime = startTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fun ResponseGetTimeTableDto.toTimeTableEntity() = TimeTableEntity(
)

fun ResponseAppointmentScheduleDto.toAppointmentScheduleEntity() = AppointmentScheduleEntity(
duration = duration,
appointmentHostSelectionTimes = appointmentHostSelectionTimes.map { it.toTimeEntity() },
appointmentMembersInfo = appointmentMembersInfo.map {
it?.toAppointmentMembersInfoEntity() ?: AppointmentMembersInfoEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ data class CalendarAppointmentDayEntity(
)

data class CalendarAppointmentEntity(
val id: Long,
val appointmentId: Long,
val optionId: Long,
val name: String,
val date: String,
val startTime: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data class TimeTableEntity(
)

data class AppointmentScheduleEntity(
val duration: Long,
val appointmentHostSelectionTimes: List<TimeEntity>,
val appointmentMembersInfo: List<AppointmentMembersInfoEntity>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fun AppointmentRoute(
appointmentId: Long,
appointmentName: String,
navigateUp: () -> Unit,
navigateToAppointmentCheck: (Long, Long, String, List<TimeEntity>) -> Unit,
navigateToAppointmentCheck: (Long, Long, String, List<TimeEntity>, Long) -> Unit,
navigateToAppointmentConfirm: (Long, Long, Long, String, Boolean) -> Unit,
appointmentViewModel: AppointmentViewModel = hiltViewModel()
) {
Expand All @@ -85,7 +85,8 @@ fun AppointmentRoute(
sideEffect.groupId,
sideEffect.appointmentsId,
sideEffect.appointmentName,
sideEffect.availablePeriods
sideEffect.availablePeriods,
sideEffect.duration
)
}

Expand Down Expand Up @@ -122,7 +123,8 @@ fun AppointmentRoute(
groupId,
appointmentId,
appointmentName,
(getTimeTableState as UiState.Success).data.appointmentSchedule.appointmentHostSelectionTimes
(getTimeTableState as UiState.Success).data.appointmentSchedule.appointmentHostSelectionTimes,
(getTimeTableState as UiState.Success).data.appointmentSchedule.duration
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ sealed class AppointmentSideEffect {
val groupId: Long,
val appointmentsId: Long,
val appointmentName: String,
val availablePeriods: List<TimeEntity>
val availablePeriods: List<TimeEntity>,
val duration: Long
) : AppointmentSideEffect()

data class NavigateToAppointmentConfirm(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.sopt.presentation.appointment.appointmentCheck

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -8,15 +11,20 @@ import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
Expand All @@ -27,12 +35,16 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.sopt.core.designsystem.component.button.NoostakBottomButton
import com.sopt.core.designsystem.component.dialog.NoostakDialog
import com.sopt.core.designsystem.component.snackbar.NoostakSnackBar
import com.sopt.core.designsystem.component.snackbar.SNACK_BAR_DURATION
import com.sopt.core.designsystem.component.timetable.NoostakEditableTimeTable
import com.sopt.core.designsystem.component.topappbar.NoostakTopAppBar
import com.sopt.core.designsystem.theme.NoostakAndroidTheme
import com.sopt.core.designsystem.theme.NoostakTheme
import com.sopt.domain.entity.TimeEntity
import com.sopt.presentation.R
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import timber.log.Timber

@Composable
Expand All @@ -41,14 +53,30 @@ fun AppointmentCheckRoute(
appointmentId: Long,
appointmentName: String,
availablePeriods: List<TimeEntity>,
duration: Long,
navigateUp: () -> Unit,
navigateToAppointment: (Long, Long, String) -> Unit,
navigateToGroupDetail: (Long) -> Unit,
appointmentCheckViewModel: AppointmentCheckViewModel = hiltViewModel()
) {
val context = LocalContext.current
val showErrorDialog by appointmentCheckViewModel.showErrorDialog.collectAsStateWithLifecycle()
var selectedData by remember { mutableStateOf(emptyList<TimeEntity>()) }
val rememberedAvailablePeriods = remember { availablePeriods }
val snackBarHostState = remember { SnackbarHostState() }
val coroutineScope = rememberCoroutineScope()
val snackBarVisible = remember { mutableStateOf(false) }

val onShowFailureSnackBar: (message: String) -> Unit = {
coroutineScope.launch {
snackBarVisible.value = true
val job = launch { snackBarHostState.showSnackbar(message = it) }
delay(SNACK_BAR_DURATION)
job.cancel()
snackBarVisible.value = false
}
}

LaunchedEffect(key1 = appointmentCheckViewModel.sideEffects) {
appointmentCheckViewModel.sideEffects.collect { sideEffect ->
when (sideEffect) {
Expand All @@ -69,6 +97,10 @@ fun AppointmentCheckRoute(
sideEffect.show,
sideEffect.dialogType
)

is AppointmentCheckSideEffect.ShowSnackBar -> onShowFailureSnackBar(
context.getString(sideEffect.message)
)
}
}
}
Expand All @@ -80,13 +112,16 @@ fun AppointmentCheckRoute(
onSelectedDataChange = { selectedData = it },
onBackButtonClick = appointmentCheckViewModel::navigateToGroupDetail,
onConfirmButtonClick = {
// TODO: selectedData가 duration 이하인지 체크하는 로직 추가
appointmentCheckViewModel.postTimeTable(
groupId,
appointmentId,
appointmentName,
selectedData
)
}
},
snackBarHostState = snackBarHostState,
snackBarVisible = snackBarVisible
)

if (showErrorDialog.first) {
Expand Down Expand Up @@ -115,7 +150,9 @@ fun AppointmentCheckScreen(
availablePeriods: List<TimeEntity>,
onSelectedDataChange: (List<TimeEntity>) -> Unit = {},
onBackButtonClick: (Long) -> Unit,
onConfirmButtonClick: () -> Unit
onConfirmButtonClick: () -> Unit,
snackBarHostState: SnackbarHostState,
snackBarVisible: MutableState<Boolean>
) {
Scaffold(
modifier = Modifier
Expand All @@ -127,6 +164,26 @@ fun AppointmentCheckScreen(
isIconVisible = true,
onBackButtonClick = { onBackButtonClick(groupId) }
)
},
snackbarHost = {
AnimatedVisibility(
visible = snackBarVisible.value,
enter = slideInVertically(initialOffsetY = { it }),
exit = slideOutVertically(targetOffsetY = { it })
) {
SnackbarHost(
modifier = Modifier.padding(bottom = dimensionResource(id = R.dimen.bottom_padding_snack_bar_non_exist_code)),
hostState = snackBarHostState,
snackbar = { snackBarData ->
NoostakSnackBar(
message = snackBarData.visuals.message,
textStyle = NoostakTheme.typography.c3SemiBold,
textColor = NoostakTheme.colors.red01,
backgroundColor = NoostakTheme.colors.pink
)
}
)
}
Comment on lines +168 to +186
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: 베리굿~!!

}
) { innerPadding ->
Box(
Expand Down Expand Up @@ -195,7 +252,9 @@ fun PreviewAppointmentConfirmScreen() {
)
),
onBackButtonClick = {},
onConfirmButtonClick = {}
onConfirmButtonClick = {},
snackBarHostState = SnackbarHostState(),
snackBarVisible = remember { mutableStateOf(true) }
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,6 @@ sealed class AppointmentCheckSideEffect {
data class NavigateToGroupDetail(val groupId: Long) : AppointmentCheckSideEffect()
data class ShowErrorDialog(val show: Boolean, val dialogType: DialogType) :
AppointmentCheckSideEffect()

data class ShowSnackBar(val message: Int) : AppointmentCheckSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ fun NavController.navigateAppointmentCheck(
groupId: Long,
appointmentId: Long,
appointmentName: String,
duration: Long,
navOptions: NavOptions? = null
) {
navigate(
route = AppointmentCheck(
groupId = groupId,
appointmentId = appointmentId,
appointmentName = appointmentName
appointmentName = appointmentName,
duration = duration
),
navOptions = navOptions
)
Expand Down Expand Up @@ -82,15 +84,16 @@ fun NavGraphBuilder.appointmentNavGraph(
appointmentId = args.appointmentId,
appointmentName = args.appointmentName,
navigateUp = navHostController::navigateUp,
navigateToAppointmentCheck = { groupId, appointmentId, appointmentName, availablePeriods ->
navigateToAppointmentCheck = { groupId, appointmentId, appointmentName, availablePeriods, duration ->
navHostController.currentBackStackEntry?.savedStateHandle?.set(
"availablePeriods",
availablePeriods
)
navHostController.navigateAppointmentCheck(
groupId = groupId,
appointmentId = appointmentId,
appointmentName = appointmentName
appointmentName = appointmentName,
duration = duration
)
},
navigateToAppointmentConfirm = { groupId, appointmentId, optionId, appointmentName, isHost ->
Expand All @@ -116,6 +119,7 @@ fun NavGraphBuilder.appointmentNavGraph(
appointmentId = args.appointmentId,
appointmentName = args.appointmentName,
availablePeriods = availablePeriods,
duration = args.duration,
navigateUp = navHostController::navigateUp,
navigateToAppointment = { groupId, appointmentId, appointmentName ->
navHostController.navigateAppointment(
Expand Down Expand Up @@ -156,7 +160,8 @@ data class Appointment(
data class AppointmentCheck(
val groupId: Long,
val appointmentId: Long,
val appointmentName: String
val appointmentName: String,
val duration: Long
) : Route

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ fun AppointmentCreateInfoScreen(
val time = appointmentDuration.toIntOrNull() ?: 0
onButtonClick(groupId, trimmedName, appointmentCategory, time)
},
isEnabled = appointmentName.isNotEmpty() &&appointmentCategory.isNotBlank() &&
appointmentDuration.isNotBlank() &&
(appointmentDuration.toIntOrNull()?.let { it in 1..10 } == true),
isEnabled = appointmentName.isNotEmpty() && appointmentCategory.isNotBlank() &&
appointmentDuration.isNotBlank() &&
(appointmentDuration.toIntOrNull()?.let { it in 1..10 } == true),
deactivateColor = NoostakTheme.colors.gray500,
activateColor = NoostakTheme.colors.gray900
)
Expand All @@ -329,7 +329,7 @@ fun AppointmentCreateInfoScreenPreview() {
snackBarVisible = snackBarVisible,
showSnackBar = {
snackBarVisible.value = true
},
}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fun CalendarRoute(
val currentYearMonth by remember { derivedStateOf { getYearMonthByPage(pagerState.currentPage) } }

var clickDate by remember { mutableStateOf<LocalDate?>(null) }
var clickAppointmentId by remember { mutableLongStateOf(-1) }
var clickOptionId by remember { mutableLongStateOf(-1) }

LaunchedEffect(pagerState) {
snapshotFlow { pagerState.currentPage }
Expand Down Expand Up @@ -118,7 +118,7 @@ fun CalendarRoute(
NoostakDialog(
dialogType = DialogType.DATA_FAILURE,
onClick = {
calendarViewModel.getConfirmedDetail(clickAppointmentId)
calendarViewModel.getConfirmedDetail(clickOptionId)
},
onDismissRequest = {
calendarViewModel.showDataErrorDialog(false)
Expand Down Expand Up @@ -158,7 +158,8 @@ fun CalendarRoute(
date = date,
scheduleList = calendarViewModel.selectedDayAppointments.value.map {
CalendarAppointmentEntity(
id = it.id,
appointmentId = it.appointmentId,
optionId = it.optionId,
name = it.name,
category = it.category,
startTime = it.startTime,
Expand All @@ -169,8 +170,8 @@ fun CalendarRoute(
}
),
onItemClick = { id ->
clickAppointmentId = id
calendarViewModel.getConfirmedDetail(clickAppointmentId)
clickOptionId = id
calendarViewModel.getConfirmedDetail(clickOptionId)
navController.navigate(SCHEDULE_DETAIL)
},
onCreateAppointmentBtnClick = {
Expand Down
Loading