diff --git a/app/src/main/java/com/wap/wapp/MainActivity.kt b/app/src/main/java/com/wap/wapp/MainActivity.kt index 1caf56f4..8f737474 100644 --- a/app/src/main/java/com/wap/wapp/MainActivity.kt +++ b/app/src/main/java/com/wap/wapp/MainActivity.kt @@ -1,22 +1,22 @@ package com.wap.wapp -import android.content.res.Resources import android.os.Bundle import androidx.activity.ComponentActivity import androidx.activity.SystemBarStyle import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.material3.Scaffold import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier -import androidx.compose.ui.platform.LocalDensity -import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.dp import androidx.navigation.NavController import androidx.navigation.NavGraph.Companion.findStartDestination @@ -32,6 +32,8 @@ import com.wap.wapp.feature.management.event.navigation.eventRegistrationNavigat import com.wap.wapp.feature.management.survey.navigation.ManagementSurveyRoute import com.wap.wapp.feature.profile.profilesetting.navigation.profileSettingNavigationRoute import com.wap.wapp.feature.splash.navigation.splashNavigationRoute +import com.wap.wapp.feature.survey.check.navigation.SurveyCheckRoute +import com.wap.wapp.feature.survey.check.navigation.SurveyCheckRoute.surveyCheckRoute import com.wap.wapp.feature.survey.navigation.SurveyRoute import com.wap.wapp.navigation.TopLevelDestination import com.wap.wapp.navigation.WappNavHost @@ -50,8 +52,6 @@ class MainActivity : ComponentActivity() { setContent { WappTheme { val navController = rememberNavController() - val density = LocalDensity.current - val navigationBarHeight = getNavigationBarHeight(density) Scaffold( containerColor = WappTheme.colors.backgroundBlack, @@ -82,7 +82,7 @@ class MainActivity : ComponentActivity() { ) }, modifier = Modifier - .padding(bottom = navigationBarHeight) + .windowInsetsPadding(WindowInsets.navigationBars) .fillMaxSize(), ) { innerPadding -> WappNavHost( @@ -115,6 +115,8 @@ private fun handleBottomBarState( ManagementSurveyRoute.surveyFormEditRoute("{id}") -> setBottomBarState(false) eventRegistrationNavigationRoute -> setBottomBarState(false) SurveyRoute.answerRoute("{id}") -> setBottomBarState(false) + surveyCheckRoute -> setBottomBarState(false) + SurveyCheckRoute.surveyDetailRoute("{id}") -> setBottomBarState(false) else -> setBottomBarState(true) } @@ -130,15 +132,3 @@ private fun navigateToTopLevelDestination( restoreState = true } } - -private fun getNavigationBarHeight(density: Density) = with(density) { - Resources.getSystem().run { - getDimensionPixelSize( - getIdentifier( - "navigation_bar_height", - "dimen", - "android", - ), - ).toDp() - } -} diff --git a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt index 19df1438..0c8c407c 100644 --- a/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt +++ b/app/src/main/java/com/wap/wapp/navigation/WappNavHost.kt @@ -36,6 +36,7 @@ import com.wap.wapp.feature.profile.profilesetting.navigation.profileSettingNavi import com.wap.wapp.feature.profile.profilesetting.navigation.profileSettingScreen import com.wap.wapp.feature.splash.navigation.splashNavigationRoute import com.wap.wapp.feature.splash.navigation.splashScreen +import com.wap.wapp.feature.survey.check.navigation.SurveyCheckRoute.surveyCheckRoute import com.wap.wapp.feature.survey.check.navigation.navigateToSurveyCheck import com.wap.wapp.feature.survey.check.navigation.navigateToSurveyDetail import com.wap.wapp.feature.survey.check.navigation.surveyCheckNavGraph @@ -65,9 +66,7 @@ fun WappNavHost( }, navigateToNotice = { navController.navigateToNotice( - navOptions { - popUpTo(splashNavigationRoute) { inclusive = true } - }, + navOptions { popUpTo(splashNavigationRoute) { inclusive = true } }, ) }, ) @@ -88,7 +87,11 @@ fun WappNavHost( navigateToSurveyCheck = navController::navigateToSurveyCheck, ) surveyCheckNavGraph( - navigateToSurveyCheck = navController::navigateToSurveyCheck, + navigateToSurveyCheck = { + navController.navigateToSurveyCheck( + navOptions { popUpTo(surveyCheckRoute) { inclusive = true } }, + ) + }, navigateToSurveyDetail = navController::navigateToSurveyDetail, ) managementSurveyNavGraph( diff --git a/core/network/src/main/java/com/wap/wapp/core/network/source/attendance/AttendanceDataSourceImpl.kt b/core/network/src/main/java/com/wap/wapp/core/network/source/attendance/AttendanceDataSourceImpl.kt index cd48913c..a36c8b28 100644 --- a/core/network/src/main/java/com/wap/wapp/core/network/source/attendance/AttendanceDataSourceImpl.kt +++ b/core/network/src/main/java/com/wap/wapp/core/network/source/attendance/AttendanceDataSourceImpl.kt @@ -6,6 +6,8 @@ import com.wap.wapp.core.network.constant.ATTENDANCE_COLLECTION import com.wap.wapp.core.network.model.attendance.AttendanceRequest import com.wap.wapp.core.network.model.attendance.AttendanceResponse import com.wap.wapp.core.network.utils.await +import com.wap.wapp.core.network.utils.toISOLocalDateTimeString +import java.time.LocalDateTime import javax.inject.Inject class AttendanceDataSourceImpl @Inject constructor( @@ -35,6 +37,10 @@ class AttendanceDataSourceImpl @Inject constructor( .await() val attendanceResponse = task.toObject() - checkNotNull(attendanceResponse) + attendanceResponse ?: AttendanceResponse( + eventId = eventId, + "", + LocalDateTime.MIN.toISOLocalDateTimeString(), + ) } } diff --git a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceScreen.kt b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceScreen.kt index c63e1fce..af5567c8 100644 --- a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceScreen.kt +++ b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceScreen.kt @@ -76,9 +76,7 @@ internal fun AttendanceRoute( getTodayEventsAttendanceStatus() } - is Failure -> snackBarHostState.showSnackbar( - getString(context, R.string.attendance_failure), - ) + is Failure -> snackBarHostState.showSnackbar(event.message) } } } diff --git a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceViewModel.kt b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceViewModel.kt index 04d56f8b..02e62ecb 100644 --- a/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceViewModel.kt +++ b/feature/attendance/src/main/java/com/wap/wapp/feature/attendance/AttendanceViewModel.kt @@ -95,7 +95,11 @@ class AttendanceViewModel @Inject constructor( private suspend fun getEventListAttendance(eventList: List, userId: String) = getEventListAttendanceUseCase(eventList.map { it.eventId }) .onSuccess { attendanceList -> - val eventAttendanceList = eventList.zip(attendanceList) + val filteredEventList = eventList.filter { + it.eventId in attendanceList.map { it.eventId } + } + + val eventAttendanceList = filteredEventList.zip(attendanceList) .map { (event, attendance) -> EventAttendanceStatus( eventId = event.eventId, @@ -104,6 +108,7 @@ class AttendanceViewModel @Inject constructor( remainAttendanceDateTime = attendance.calculateDeadline(), ) } + getEventListAttendanceStatus( eventAttendanceList = eventAttendanceList, userId = userId, @@ -129,6 +134,7 @@ class AttendanceViewModel @Inject constructor( isAttendance = attendanceStatus.isAttendance(), ) } + _todayEventsAttendanceStatus.value = EventAttendanceStatusState.Success(eventAttendanceStatusList) }.onFailure { _errorFlow.emit(it) }