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

Fix/tgyuu/#112 #120

Merged
merged 5 commits into from
Feb 6, 2024
34 changes: 21 additions & 13 deletions app/src/main/java/com/wap/wapp/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,23 +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.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.material3.Scaffold
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
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
Expand Down Expand Up @@ -51,9 +50,10 @@ class MainActivity : ComponentActivity() {
setContent {
WappTheme {
val navController = rememberNavController()
val density = LocalDensity.current
val navigationBarHeight = getNavigationBarHeight(density)
Copy link
Member

Choose a reason for hiding this comment

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

โœจโœจ


Scaffold(
modifier = Modifier.fillMaxSize(),
containerColor = WappTheme.colors.backgroundBlack,
bottomBar = {
val navBackStackEntry by
Expand All @@ -69,11 +69,6 @@ class MainActivity : ComponentActivity() {
},
)

val systemBars = WindowInsets.systemBars
val density = LocalDensity.current
val bottomPadding =
remember { with(density) { systemBars.getBottom(this).toDp() } }

WappBottomBar(
currentRoute = currentRoute,
bottomBarState = bottomBarState,
Expand All @@ -83,11 +78,12 @@ class MainActivity : ComponentActivity() {
destination,
)
},
modifier = Modifier
.padding(bottom = bottomPadding)
.height(70.dp),
modifier = Modifier.height(70.dp),
)
},
modifier = Modifier
.padding(bottom = navigationBarHeight)
.fillMaxSize(),
) { innerPadding ->
WappNavHost(
signInUseCase = signInUseCase,
Expand Down Expand Up @@ -117,7 +113,7 @@ private fun handleBottomBarState(
attendanceManagementNavigationRoute -> setBottomBarState(false)
ManagementSurveyRoute.surveyFormRegistrationRoute -> setBottomBarState(false)
eventRegistrationNavigationRoute -> setBottomBarState(false)
SurveyRoute.answerRoute("{id}") ->setBottomBarState(false)
SurveyRoute.answerRoute("{id}") -> setBottomBarState(false)
else -> setBottomBarState(true)
}

Expand All @@ -133,3 +129,15 @@ private fun navigateToTopLevelDestination(
restoreState = true
}
}

private fun getNavigationBarHeight(density: Density) = with(density) {
Resources.getSystem().run {
getDimensionPixelSize(
getIdentifier(
"navigation_bar_height",
"dimen",
"android",
),
).toDp()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun WappSubTopBarWithRightButton() {
WappSubTopBar(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
.padding(vertical = 16.dp),
titleRes = R.string.notice,
showRightButton = true,
)
Expand All @@ -115,7 +115,7 @@ fun WappSubTopBarWithLeftButton() {
WappSubTopBar(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
.padding(vertical = 16.dp),
titleRes = R.string.notice,
showLeftButton = true,
)
Expand All @@ -133,7 +133,7 @@ fun WappSubTopBarWithBothButton() {
WappSubTopBar(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
.padding(vertical = 16.dp),
titleRes = R.string.notice,
showRightButton = true,
showLeftButton = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ internal fun SignUpScreen(
.padding(horizontal = 16.dp),
) {
WappSubTopBar(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 16.dp),
modifier = Modifier.fillMaxWidth(),
titleRes = string.sign_up,
showLeftButton = true,
onClickLeftButton = { navigateToSignIn() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ internal fun EventEditScreen(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues)
.padding(16.dp),
.padding(vertical = 16.dp),
) {
WappSubTopBar(
titleRes = R.string.event_edit,
Expand All @@ -187,12 +187,12 @@ internal fun EventEditScreen(

EventEditStateIndicator(
eventRegistrationState = currentEditState,
modifier = Modifier.padding(top = 16.dp),
modifier = Modifier.padding(top = 16.dp, start = 20.dp, end = 20.dp),
)

EventRegistrationContent(
eventRegistrationState = currentEditState,
modifier = Modifier.padding(top = 50.dp),
modifier = Modifier.padding(top = 50.dp, start = 20.dp, end = 20.dp),
eventTitle = title,
eventContent = content,
location = location,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private fun EventDetailsContent(
WappButton(
onClick = onNextButtonClicked,
textRes = R.string.next,
modifier = Modifier.padding(vertical = 20.dp),
modifier = Modifier.padding(top = 20.dp),
)
}
}
Expand Down Expand Up @@ -311,7 +311,6 @@ private fun EventScheduleContent(
WappButton(
onClick = onRegisterButtonClicked,
textRes = R.string.register_event,
modifier = Modifier.padding(bottom = 20.dp),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ internal fun EventRegistrationScreen(
titleRes = R.string.event_registration,
showLeftButton = true,
onClickLeftButton = onBackButtonClicked,
modifier = Modifier.padding(start = 10.dp),
)

EventRegistrationStateIndicator(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import com.wap.designsystem.WappTheme
@Composable
internal fun SurveyFormStateIndicator(
surveyRegistrationState: SurveyFormState,
modifier: Modifier = Modifier,
) {
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(8.dp),
modifier = modifier,
) {
SurveyRegistrationStateProgressBar(surveyRegistrationState.progress)
SurveyRegistrationStateText(surveyRegistrationState.page)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ internal fun SurveyFormEditScreen(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues) // paddingValue padding
.padding(16.dp), // dp value padding
.padding(vertical = 16.dp), // dp value padding
verticalArrangement = Arrangement.spacedBy(32.dp),
) {
if (showDeleteSurveyDialog) {
Expand All @@ -127,6 +127,7 @@ internal fun SurveyFormEditScreen(

SurveyFormStateIndicator(
surveyRegistrationState = currentRegistrationState,
modifier = Modifier.padding(horizontal = 20.dp),
)
}

Expand All @@ -145,6 +146,7 @@ internal fun SurveyFormEditScreen(
showTimePicker = showTimePicker,
currentQuestionIndex = totalQuestionSize,
totalQuestionSize = totalQuestionSize,
modifier = Modifier.padding(horizontal = 20.dp),
onDatePickerStateChanged = { state -> showDatePicker = state },
onTimePickerStateChanged = { state -> showTimePicker = state },
onEventListChanged = { viewModel.getEventList() },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal fun SurveyRegistrationScreen(
modifier = Modifier
.fillMaxSize()
.padding(paddingValues) // paddingValue padding
.padding(top = 16.dp, start = 20.dp, end = 20.dp), // dp value padding
.padding(top = 16.dp), // dp value padding
) {
WappSubTopBar(
titleRes = R.string.survey_registeration,
Expand All @@ -88,6 +88,7 @@ internal fun SurveyRegistrationScreen(

SurveyFormStateIndicator(
surveyRegistrationState = currentRegistrationState,
modifier = Modifier.padding(horizontal = 20.dp),
)

SurveyFormContent(
Expand All @@ -105,6 +106,7 @@ internal fun SurveyRegistrationScreen(
showTimePicker = showTimePicker,
currentQuestionIndex = totalQuestionSize,
totalQuestionSize = totalQuestionSize,
modifier = Modifier.padding(horizontal = 20.dp),
onDatePickerStateChanged = { state -> showDatePicker = state },
onTimePickerStateChanged = { state -> showTimePicker = state },
onEventListChanged = { viewModel.getEventList() },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

package com.wap.wapp.feature.management

import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.Scaffold
Expand All @@ -15,6 +15,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.wap.designsystem.WappTheme
Expand Down Expand Up @@ -44,7 +45,7 @@ internal fun ManagementRoute(

viewModel.userRole.collectLatest { userRoleUiState ->
when (userRoleUiState) {
is ManagementViewModel.UserRoleUiState.Init -> { }
is ManagementViewModel.UserRoleUiState.Init -> {}
is ManagementViewModel.UserRoleUiState.Success -> {
when (userRoleUiState.userRole) {
UserRole.GUEST -> { showGuestScreen = true }
Expand All @@ -56,9 +57,7 @@ internal fun ManagementRoute(
}

viewModel.errorFlow.collectLatest { throwable ->
snackBarHostState.showSnackbar(
message = throwable.toSupportingText(),
)
snackBarHostState.showSnackbar(message = throwable.toSupportingText())
}
}

Expand Down Expand Up @@ -101,16 +100,15 @@ internal fun ManagementScreen(
Scaffold(
containerColor = WappTheme.colors.backgroundBlack,
snackbarHost = { SnackbarHost(snackBarHostState) },
contentWindowInsets = WindowInsets(0.dp),
topBar = {
WappLeftMainTopBar(
titleRes = R.string.management,
contentRes = R.string.management_content,
)
},
) { paddingValues ->
LazyColumn(
modifier = Modifier.padding(paddingValues),
) {
LazyColumn(modifier = Modifier.padding(paddingValues)) {
item {
ManagementEventCard(
eventsState = eventsState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ internal fun ManagementSurveyCard(
containerColor = WappTheme.colors.black25,
),
modifier = Modifier
.padding(top = 20.dp)
.padding(vertical = 20.dp)
.padding(horizontal = 8.dp),
) {
Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ internal fun ProfileSettingScreen(
titleRes = string.more,
showLeftButton = true,
onClickLeftButton = navigateToProfile,
modifier = Modifier.padding(top = 20.dp),
modifier = Modifier.padding(top = 16.dp),
)

Row(
Expand Down
Loading