Skip to content

Commit

Permalink
[REFACTOR] Migrate Full Content View to Independent Composable
Browse files Browse the repository at this point in the history
  - Remove unnecessary functions.
  - Replace action to be initiate when user select notice for full content view.
  • Loading branch information
doyoonkim3312 committed Nov 10, 2024
1 parent 4e91829 commit b4f97d8
Showing 1 changed file with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.doyoonkim.knutice.model.FullContent
import com.doyoonkim.knutice.model.NoticeCategory
import com.doyoonkim.knutice.presentation.component.NotificationPreview
import com.doyoonkim.knutice.ui.theme.containerBackground
Expand All @@ -40,7 +41,8 @@ fun MoreCategorizedNotification(
modifier: Modifier = Modifier,
viewModel: MoreCategorizedNotificationViewModel = hiltViewModel(),
category: NoticeCategory,
backButtonHandler: () -> Unit = { }
backButtonHandler: () -> Unit = { },
onNoticeSelected: (FullContent) -> Unit = { }
) {
val uiState by viewModel.uiState.collectAsStateWithLifecycle()

Expand All @@ -52,8 +54,7 @@ fun MoreCategorizedNotification(
)

BackHandler {
if (uiState.isDetailedContentVisible) viewModel.updatedDetailedContentRequest(false)
else backButtonHandler()
backButtonHandler()
}

Box(
Expand Down Expand Up @@ -96,12 +97,11 @@ fun MoreCategorizedNotification(
Row(
modifier = Modifier.wrapContentSize()
.clickable {
viewModel.updatedDetailedContentRequest(
true,
onNoticeSelected(FullContent(
notice.title,
"[${notice.departName}] ${notice.timestamp}",
notice.url
)
))
}
) {
NotificationPreview(
Expand All @@ -123,15 +123,15 @@ fun MoreCategorizedNotification(
)
}

AnimatedVisibility(
uiState.isDetailedContentVisible
) {
DetailedNoticeContent(
modifier = Modifier.padding(15.dp),
requested = uiState.detailedContentState
) {
viewModel.updatedDetailedContentRequest(false)
}
}
// AnimatedVisibility(
// uiState.isDetailedContentVisible
// ) {
// DetailedNoticeContent(
// modifier = Modifier.padding(7.dp),
// requested = uiState.detailedContentState
// ) {
// viewModel.updatedDetailedContentRequest(false)
// }
// }
}

0 comments on commit b4f97d8

Please sign in to comment.