diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f0ca4e4d..f0b717d7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -41,7 +41,7 @@ dependencies { androidTestImplementation(libs.androidx.test.espresso) } -tasks.getByPath(":app:preBuild").dependsOn("installGitHook") +/*tasks.getByPath(":app:preBuild").dependsOn("installGitHook") tasks.register("installGitHook") { dependsOn("deletePreviousGitHook") @@ -58,4 +58,4 @@ tasks.register("deletePreviousGitHook") { if (file(prePush).exists()) { delete(prePush) } -} +}*/ diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeFragment.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeFragment.kt index 890d6c82..1ab3bcfc 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeFragment.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeFragment.kt @@ -6,7 +6,6 @@ import android.view.View import android.view.ViewGroup import androidx.compose.ui.platform.ComposeView import androidx.fragment.app.Fragment -import androidx.hilt.navigation.compose.hiltViewModel import com.wap.designsystem.WappTheme import dagger.hilt.android.AndroidEntryPoint @@ -27,12 +26,9 @@ class NoticeFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - composeView.setContent { WappTheme { - NoticeScreen( - viewModel = hiltViewModel(), - ) + NoticeScreen() } } } diff --git a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeScreen.kt b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeScreen.kt index 412dcd72..88f01857 100644 --- a/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeScreen.kt +++ b/feature/notice/src/main/java/com/wap/wapp/feature/notice/NoticeScreen.kt @@ -1,6 +1,5 @@ package com.wap.wapp.feature.notice -import android.util.Log import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.clickable @@ -36,6 +35,7 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.layout.layout import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel @@ -49,9 +49,9 @@ import kotlinx.coroutines.launch internal fun NoticeScreen( viewModel: NoticeViewModel = hiltViewModel(), ) { - var expandHeight: Dp by remember { mutableStateOf(0.dp) } var defaultHeight: Dp by remember { mutableStateOf(0.dp) } - + var expandableHeight: Dp by remember { mutableStateOf(0.dp) } + val coroutineScope = rememberCoroutineScope() val scaffoldState = rememberBottomSheetScaffoldState( bottomSheetState = SheetState( skipPartiallyExpanded = false, @@ -59,7 +59,6 @@ internal fun NoticeScreen( skipHiddenState = true, ), ) - val coroutineScope = rememberCoroutineScope() Column( modifier = Modifier @@ -70,31 +69,16 @@ internal fun NoticeScreen( scaffoldState = scaffoldState, sheetContainerColor = WappTheme.colors.black25, sheetPeekHeight = defaultHeight, - sheetContent = { - Column( - horizontalAlignment = Alignment.Start, - modifier = Modifier.height(expandHeight), - ) { - Text( - text = "10.25 수요일", - style = WappTheme.typography.titleBold, - color = WappTheme.colors.white, - modifier = Modifier.padding(start = 15.dp, bottom = 15.dp), - ) - - NoticeList(getDummyNotices()) - } - }, + sheetContent = { BottomSheetContent(expandableHeight) }, ) { Column( modifier = Modifier .fillMaxWidth() .background(WappTheme.colors.black25) - .layout { measurable, constriants -> - val placeable = measurable.measure(constriants) - - defaultHeight = (constriants.maxHeight - placeable.height).toDp() + .layout { measurable, constraints -> + val placeable = measurable.measure(constraints) + defaultHeight = (constraints.maxHeight - placeable.height).toDp() layout(placeable.width, placeable.height) { placeable.placeRelative(0, 0) } @@ -103,25 +87,24 @@ internal fun NoticeScreen( Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier - .padding(vertical = 10.dp) - .fillMaxWidth() - .layout { measurable, constriants -> - val placeable = measurable.measure(constriants) - - expandHeight = (constriants.maxHeight - placeable.height).toDp() - 50.dp + .layout { measurable, constraints -> + val placeable = measurable.measure(constraints) + expandableHeight = + constraints.maxHeight.toDp() - (placeable.height.toDp() * 2) layout(placeable.width, placeable.height) { placeable.placeRelative(0, 0) } - }, + } + .padding(vertical = 10.dp) + .fillMaxWidth(), ) { Image( painter = painterResource(id = R.drawable.ic_threelines), - contentDescription = "공지사항 목록만을 보여줍니다.", + contentDescription = + stringResource(R.string.calendarToggleImageContextDescription), modifier = Modifier .clickable { - scaffoldState.bottomSheetState.let { sheetState -> - handleSheetState(coroutineScope, sheetState) - } + handleSheetState(coroutineScope, scaffoldState.bottomSheetState) } .padding(start = 16.dp), ) @@ -135,7 +118,7 @@ internal fun NoticeScreen( Image( painter = painterResource(id = R.drawable.ic_calendar), - contentDescription = "공지사항을 띄워주는 달력입니다.", + contentDescription = stringResource(id = R.string.calendarContextDescription), contentScale = ContentScale.FillWidth, modifier = Modifier .padding(top = 10.dp) @@ -146,21 +129,24 @@ internal fun NoticeScreen( } } -@OptIn(ExperimentalMaterial3Api::class) -private fun handleSheetState(coroutineScope: CoroutineScope, sheetState: SheetState) { - coroutineScope.launch { - Log.d("test", sheetState.currentValue.toString()) - - when (sheetState.currentValue) { - SheetValue.Expanded -> sheetState.partialExpand() - SheetValue.PartiallyExpanded -> sheetState.expand() - SheetValue.Hidden -> sheetState.expand() - } +@Composable +private fun BottomSheetContent(expandableHeight: Dp) { + Column( + horizontalAlignment = Alignment.Start, + modifier = Modifier.height(expandableHeight), + ) { + Text( + text = "10.25 수요일", + style = WappTheme.typography.titleBold, + color = WappTheme.colors.white, + modifier = Modifier.padding(start = 15.dp, bottom = 15.dp), + ) + NoticeList(getDummyNotices()) } } @Composable -fun NoticeList(notices: List) { +private fun NoticeList(notices: List) { LazyColumn( contentPadding = PaddingValues(horizontal = 15.dp), verticalArrangement = Arrangement.spacedBy(12.dp), @@ -168,15 +154,15 @@ fun NoticeList(notices: List) { ) { itemsIndexed( items = notices, - key = { index, notice -> notice.title }, - ) { index, notice -> + key = { _, notice -> notice.title }, + ) { _, notice -> NoticeItem(notice = notice) } } } @Composable -fun NoticeItem(notice: Notice) { +private fun NoticeItem(notice: Notice) { Column { Row( modifier = Modifier @@ -222,6 +208,20 @@ fun NoticeItem(notice: Notice) { } } +@OptIn(ExperimentalMaterial3Api::class) +private fun handleSheetState( + coroutineScope: CoroutineScope, + sheetState: SheetState, +) { + coroutineScope.launch { + when (sheetState.currentValue) { + SheetValue.Expanded -> sheetState.partialExpand() + SheetValue.PartiallyExpanded -> sheetState.expand() + SheetValue.Hidden -> sheetState.expand() + } + } +} + // forTest private fun getDummyNotices(): List = listOf( Notice( diff --git a/feature/notice/src/main/res/values/strings.xml b/feature/notice/src/main/res/values/strings.xml index 6048840e..b80baa46 100644 --- a/feature/notice/src/main/res/values/strings.xml +++ b/feature/notice/src/main/res/values/strings.xml @@ -1,4 +1,4 @@ - - Hello blank fragment - \ No newline at end of file + 공지사항 목록만을 보여주거나, 캘린더를 다시 보여줍니다. + 공지사항을 보여주는 달력입니다. +