Skip to content

Commit

Permalink
Merge pull request #41 from team-haribo/feature/40-publishing-late-list
Browse files Browse the repository at this point in the history
🔀 :: (#40) - publishing late list
  • Loading branch information
diejdkll authored Feb 7, 2024
2 parents a739429 + b73d4af commit 6ad4dc3
Show file tree
Hide file tree
Showing 11 changed files with 450 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import com.goms.login.navigation.loginRoute
import com.goms.login.navigation.loginScreen
import com.goms.login.navigation.navigateToInputLogin
import com.goms.login.navigation.navigateToLogin
import com.goms.main.navigation.lateListScreen
import com.goms.main.navigation.mainScreen
import com.goms.main.navigation.navigateToLateList
import com.goms.main.navigation.navigateToMain
import com.goms.main.navigation.navigateToOutingStatus
import com.goms.main.navigation.outingStatusScreen
Expand Down Expand Up @@ -59,11 +61,15 @@ fun GomsNavHost(
)
mainScreen(
viewModelStoreOwner = viewModelStoreOwner,
onOutingStatusClick = navController::navigateToOutingStatus
onOutingStatusClick = navController::navigateToOutingStatus,
onLateListClick = navController::navigateToLateList
)
outingStatusScreen(
viewModelStoreOwner = viewModelStoreOwner,
onBackClick = navController::popBackStack
)
lateListScreen(
onBackClick = navController::popBackStack
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.goms.design_system.component.bottomsheet

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.goms.design_system.component.modifier.gomsClickable
import com.goms.design_system.icon.CloseIcon
import com.goms.design_system.theme.GomsTheme

@Composable
fun BottomSheetHeader(
modifier: Modifier,
title: String,
closeSheet: () -> Unit
) {
GomsTheme { colors, typography ->
Row(
modifier = modifier
.fillMaxWidth()
.height(32.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = title,
style = typography.titleSmall,
fontWeight = FontWeight.Bold,
color = colors.WHITE
)
CloseIcon(
modifier = Modifier.gomsClickable { closeSheet() },
tint = colors.WHITE
)
}
Spacer(modifier = Modifier.height(16.dp))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.goms.design_system.component.bottomsheet

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.BottomSheetDefaults
import androidx.compose.material3.DatePicker
import androidx.compose.material3.DatePickerDefaults
import androidx.compose.material3.DatePickerState
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.goms.design_system.theme.GomsTheme

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun DatePickerBottomSheet(
state: DatePickerState,
closeSheet: () -> Unit
) {
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)

GomsTheme { colors, typography ->
ModalBottomSheet(
onDismissRequest = closeSheet,
sheetState = sheetState,
shape = RoundedCornerShape(topStart = 12.dp, topEnd = 12.dp),
containerColor = colors.G1,
dragHandle = { BottomSheetDefaults.DragHandle() },
) {
Column(modifier = Modifier.fillMaxWidth()) {
BottomSheetHeader(
modifier = Modifier.padding(horizontal = 20.dp),
title = "날짜 선택",
closeSheet = closeSheet
)
DatePicker(
state = state,
showModeToggle = false,
title = null,
headline = null,
colors = DatePickerDefaults.colors(
containerColor = colors.G1,
weekdayContentColor = colors.G4,
navigationContentColor = colors.WHITE,
yearContentColor = colors.WHITE,
disabledYearContentColor = colors.WHITE,
currentYearContentColor = colors.WHITE,
selectedYearContentColor = colors.WHITE,
dayContentColor = colors.WHITE,
disabledDayContentColor = colors.WHITE,
selectedDayContentColor = Color.White,
disabledSelectedDayContentColor = colors.WHITE,
selectedDayContainerColor = colors.A7,
disabledSelectedDayContainerColor = colors.G1,
todayDateBorderColor = colors.A7
)
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,11 @@ fun SelectorBottomSheet(
}
}
) {
Row(
modifier = Modifier
.fillMaxWidth()
.height(32.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
text = title,
style = typography.titleSmall,
fontWeight = FontWeight.Bold,
color = colors.WHITE
)
CloseIcon(
modifier = Modifier.gomsClickable { closeSheet() },
tint = colors.WHITE
)
}
Spacer(modifier = Modifier.height(16.dp))
BottomSheetHeader(
modifier = Modifier,
title = title,
closeSheet = closeSheet
)
LazyRow(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(16.dp)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.goms.design_system.util

import java.time.DayOfWeek
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
import java.time.temporal.TemporalAdjusters

fun getDefaultWednesday(): Instant {
val currentDate = LocalDate.now()

return if (currentDate.dayOfWeek != DayOfWeek.WEDNESDAY) {
val lastWednesday = currentDate.with(TemporalAdjusters.previous(DayOfWeek.WEDNESDAY))
lastWednesday.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()
} else {
currentDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()
}
}
107 changes: 107 additions & 0 deletions feature/main/src/main/java/com/goms/main/LateListScreen.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.goms.main

import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTapGestures
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.rememberDatePickerState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import com.goms.design_system.component.bottomsheet.DatePickerBottomSheet
import com.goms.design_system.component.button.GomsBackButton
import com.goms.design_system.component.modifier.gomsClickable
import com.goms.design_system.component.textfield.GomsSearchTextField
import com.goms.design_system.theme.GomsTheme
import com.goms.design_system.util.getDefaultWednesday
import com.goms.design_system.util.keyboardAsState
import com.goms.main.component.LateList
import com.goms.main.component.LateListText
import java.time.Instant
import java.time.ZoneId

@Composable
fun LateListRoute(
onBackClick: () -> Unit
) {
LateListScreen(
onBackClick = onBackClick
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun LateListScreen(
onBackClick: () -> Unit,
) {
val scrollState = rememberScrollState()
val focusManager = LocalFocusManager.current
val isKeyboardOpen by keyboardAsState()
val datePickerState = rememberDatePickerState()
var onDatePickerBottomSheetOpenClick by remember { mutableStateOf(false) }
val selectedDate = Instant.ofEpochMilli(datePickerState.selectedDateMillis ?: getDefaultWednesday().toEpochMilli())
.atZone(ZoneId.systemDefault())
.toLocalDate()

LaunchedEffect(isKeyboardOpen) {
if (!isKeyboardOpen) {
focusManager.clearFocus()
}
}

GomsTheme { colors, typography ->
Column(
modifier = Modifier
.fillMaxSize()
.background(colors.BLACK)
.statusBarsPadding()
.navigationBarsPadding()
.pointerInput(Unit) {
detectTapGestures {
focusManager.clearFocus()
}
}
) {
GomsBackButton {
onBackClick()
}
Column(
modifier = Modifier
.verticalScroll(scrollState)
.padding(horizontal = 20.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
LateListText(modifier = Modifier.align(Alignment.Start))
Spacer(modifier = Modifier.height(8.dp))
LateList(
onBottomSheetOpenClick = { onDatePickerBottomSheetOpenClick = true }
)
}
}
if (onDatePickerBottomSheetOpenClick) {
DatePickerBottomSheet(
state = datePickerState,
closeSheet = { onDatePickerBottomSheetOpenClick = false }
)
}
}
}
11 changes: 8 additions & 3 deletions feature/main/src/main/java/com/goms/main/MainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import com.goms.main.viewmodel.MainViewModelProvider
@Composable
fun MainRoute(
viewModelStoreOwner: ViewModelStoreOwner,
onOutingStatusClick: () -> Unit
onOutingStatusClick: () -> Unit,
onLateListClick: () -> Unit
) {
MainViewModelProvider(viewModelStoreOwner = viewModelStoreOwner) { viewModel ->
val role by viewModel.role.collectAsStateWithLifecycle(initialValue = "")
Expand All @@ -55,7 +56,8 @@ fun MainRoute(
viewModel.getLateRankList()
viewModel.getOutingCount()
},
onOutingStatusClick = onOutingStatusClick
onOutingStatusClick = onOutingStatusClick,
onLateListClick = onLateListClick
)
}
}
Expand All @@ -69,6 +71,7 @@ fun MainScreen(
getOutingCountUiState: GetOutingCountUiState,
getData: () -> Unit,
onOutingStatusClick: () -> Unit,
onLateListClick: () -> Unit
) {
LaunchedEffect(true) {
getData()
Expand Down Expand Up @@ -105,7 +108,9 @@ fun MainScreen(
MainLateCard(
role = role,
getLateRankListUiState = getLateRankListUiState
) {}
) {
onLateListClick()
}
MainOutingCard(
role = role,
getOutingListUiState = getOutingListUiState,
Expand Down
31 changes: 31 additions & 0 deletions feature/main/src/main/java/com/goms/main/component/FilterText.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.goms.main.component

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.goms.design_system.component.modifier.gomsClickable
import com.goms.design_system.theme.GomsTheme

@Composable
fun FilterText(onFilterTextClick: () -> Unit) {
GomsTheme { colors, typography ->
Box(
modifier = Modifier
.height(40.dp)
.gomsClickable { onFilterTextClick() }
) {
Text(
modifier = Modifier.align(Alignment.Center),
text = "필터",
style = typography.buttonLarge,
fontWeight = FontWeight.Normal,
color = colors.I5
)
}
}
}
Loading

0 comments on commit 6ad4dc3

Please sign in to comment.