Skip to content

Commit

Permalink
Merge pull request #136 from Team-Notitime/fix/134-navigation-detail
Browse files Browse the repository at this point in the history
Fix/134 navigation detail
  • Loading branch information
easyhz authored Aug 22, 2024
2 parents 4ca3c91 + 3d05aff commit 03ff09a
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.easyhz.noffice.navigation.home.screen.Home
import com.easyhz.noffice.navigation.home.screen.Onboarding
import com.easyhz.noffice.navigation.home.screen.Splash
import com.easyhz.noffice.navigation.my_page.navigateToMyPage
import com.easyhz.noffice.navigation.organization.navigateToOrganizationDetail
import com.easyhz.noffice.navigation.organization.navigateToOrganizationJoin
import com.easyhz.noffice.navigation.sign.navigateToLogIn
import com.easyhz.noffice.navigation.sign.screen.LogIn
Expand Down Expand Up @@ -57,6 +58,7 @@ internal fun NavGraphBuilder.homeGraph(
modifier = modifier,
snackBarHostState = snackBarHostState,
navigateToAnnouncementDetail = navController::navigateToAnnouncementDetail,
navigateToOrganizationDetail = navController::navigateToOrganizationDetail,
navigateToMyPage = navController::navigateToMyPage,
navigateToOrganizationJoin = navController::navigateToOrganizationJoin
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.easyhz.noffice.feature.organization.screen.organization.OrganizationS
import com.easyhz.noffice.feature.organization.screen.standby.StandbyMemberScreen
import com.easyhz.noffice.navigation.announcement.navigateToAnnouncementDetail
import com.easyhz.noffice.navigation.home.navigateToHome
import com.easyhz.noffice.navigation.my_page.navigateToMyPage
import com.easyhz.noffice.navigation.organization.screen.MemberManagement
import com.easyhz.noffice.navigation.organization.screen.Organization
import com.easyhz.noffice.navigation.organization.screen.OrganizationCreation
Expand All @@ -49,6 +50,7 @@ internal fun NavGraphBuilder.organizationGraph(
) {
OrganizationScreen(
modifier = modifier,
navigateToMyPage = navController::navigateToMyPage,
navigateToCreation = navController::navigateToOrganizationCreation,
navigateToDetail = navController::navigateToOrganizationDetail
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
package com.easyhz.noffice.core.design_system.component.image

import androidx.compose.foundation.Image
import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import com.bumptech.glide.integration.compose.CrossFade
import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
import com.bumptech.glide.integration.compose.GlideImage
import com.bumptech.glide.integration.compose.placeholder
import com.easyhz.noffice.core.design_system.R
import com.easyhz.noffice.core.design_system.theme.Grey50

@OptIn(ExperimentalGlideComposeApi::class)
@Composable
fun AnnouncementImage(
modifier: Modifier = Modifier,
imageUrl: String
) {
if (imageUrl.isBlank() || imageUrl == "null") {
Image(
modifier = modifier.fillMaxWidth(),
painter = painterResource(id = R.drawable.img_illust_1),
contentScale = ContentScale.Crop,
contentDescription = "image"
)
} else {
GlideImage(
modifier = modifier,
model = imageUrl,
contentDescription = imageUrl,
loading = placeholder(R.drawable.img_illust_1),
failure = placeholder(R.drawable.img_illust_1),
contentScale = ContentScale.Crop,
transition = CrossFade,
)
AnimatedContent(targetState = imageUrl, label = "announcementImage") {
when (it.isBlank() || imageUrl == "null") {
true -> {
Box(
modifier = modifier
.fillMaxWidth()
.background(Grey50),
)
}
false -> {
GlideImage(
modifier = modifier,
model = imageUrl,
contentDescription = imageUrl,
loading = placeholder(ColorPainter(Grey50)),
failure = placeholder(ColorPainter(Grey50)),
contentScale = ContentScale.Crop,
transition = CrossFade,
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fun OpenGraphImage(
model = image,
contentDescription = image,
loading = placeholder(ColorPainter(Yellow300)),
failure = placeholder(ColorPainter(Yellow300)), // TODO 이 부분 색깔 랜덤으로 나오면 좋을듯 해서 3개 정도만 색깔 뽑아 달라 하자
failure = placeholder(ColorPainter(Yellow300)),
contentScale = ContentScale.Crop,
transition = CrossFade
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ fun NoticeView(
organizationList: LazyPagingItems<Organization>,
isLoading: Boolean,
isRefreshing: Boolean,
navigateToAnnouncementDetail: (Int, Int, String) -> Unit,
onClickOrganizationHeader: (Organization) -> Unit,
onClickAnnouncementCard: (organizationId: Int, announcementId: Int, announcementTitle: String) -> Unit,
) {
LazyColumn(
modifier = modifier,
Expand All @@ -60,7 +61,8 @@ fun NoticeView(
OrganizationSection(
organization = it,
isRefreshing = isRefreshing,
navigateToAnnouncementDetail = {id, title -> navigateToAnnouncementDetail(it.id, id, title) }
onClickOrganizationHeader = { onClickOrganizationHeader(it) },
onClickItemCard = { id, title -> onClickAnnouncementCard(it.id, id, title) }
)
}
}
Expand All @@ -73,7 +75,8 @@ private fun OrganizationSection(
noticeViewModel: NoticeViewModel = hiltViewModel(),
organization: Organization,
isRefreshing: Boolean,
navigateToAnnouncementDetail: (Int, String) -> Unit,
onClickOrganizationHeader: () -> Unit,
onClickItemCard: (announcementId: Int, announcementTitle: String) -> Unit,
) {
val announcementList = noticeViewModel.getAnnouncementStateByOrganization(organizationId = organization.id).collectAsLazyPagingItems()
val isRefreshingAnnouncement = announcementList.loadState.refresh == LoadState.Loading
Expand All @@ -94,9 +97,7 @@ private fun OrganizationSection(
.screenHorizonPadding()
.padding(vertical = 8.dp),
organizationName = organization.name
) {

}
) { onClickOrganizationHeader() }
LazyRow(
userScrollEnabled = (organization.joinStatus != JoinStatus.PENDING) && (announcementList.itemCount != 0),
horizontalArrangement = Arrangement.spacedBy(12.dp),
Expand All @@ -122,7 +123,7 @@ private fun OrganizationSection(
)
)
) {
navigateToAnnouncementDetail(it.announcementId, it.title)
onClickItemCard(it.announcementId, it.title)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import com.easyhz.noffice.feature.home.component.viewmodel.TaskViewModel
@Composable
internal fun TaskView(
modifier: Modifier = Modifier,
viewModel: TaskViewModel = hiltViewModel()
viewModel: TaskViewModel = hiltViewModel(),
onClickOrganizationHeader: (organizationId: Int, organizationTitle: String) -> Unit,
) {
val taskList = viewModel.taskListState.collectAsLazyPagingItems()
LazyColumn(
Expand All @@ -41,7 +42,7 @@ internal fun TaskView(
modifier = Modifier
.fillMaxWidth(),
organizationName = item.organizationName
) { }
) { onClickOrganizationHeader(item.organizationId, item.organizationName) }
item.tasks.forEach { task ->
TaskItem(
modifier = Modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.easyhz.noffice.feature.home.util.HomeTopBarMenu
sealed class HomeIntent: UiIntent() {
data class ChangeTopBarMenu(val topBarMenu: HomeTopBarMenu): HomeIntent()
data class ClickTopBarIconMenu(val iconMenu: TopBarIconMenu): HomeIntent()
data class ClickOrganizationHeader(val organizationId: Int, val organizationName: String): HomeIntent()
data class ClickAnnouncementCard(val organizationId: Int, val announcementId: Int, val announcementTitle: String): HomeIntent()
data class JoinToOrganization(val organizationId: Int): HomeIntent()
data object SetInitLoading: HomeIntent()
data object Refresh: HomeIntent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.easyhz.noffice.core.model.organization.OrganizationSignUpInformation
sealed class HomeSideEffect: UiSideEffect() {
data object NavigateToMyPage: HomeSideEffect()
data class NavigateToOrganizationJoin(val organizationSignUpInformation: OrganizationSignUpInformation): HomeSideEffect()
data class NavigateToOrganizationDetail(val organizationId: Int, val organizationName: String): HomeSideEffect()
data class NavigateToAnnouncementDetail(val organizationId: Int, val announcementId: Int, val announcementTitle: String): HomeSideEffect()
data class ShowSnackBar(@StringRes val stringId: Int): HomeSideEffect()
data object Refresh: HomeSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ fun HomeScreen(
viewModel: HomeViewModel = hiltViewModel(),
snackBarHostState: SnackbarHostState,
navigateToAnnouncementDetail: (Int, Int, String) -> Unit,
navigateToOrganizationDetail: (Int, String) -> Unit,
navigateToMyPage: () -> Unit,
navigateToOrganizationJoin: (OrganizationSignUpInformation) -> Unit
) {
Expand Down Expand Up @@ -82,7 +83,9 @@ fun HomeScreen(
viewModel.postIntent(HomeIntent.JoinToOrganization(organizationIdToJoin))
}
LaunchedEffect(key1 = organizationList.loadState) {
if (organizationList.loadState.prepend.endOfPaginationReached) { viewModel.postIntent(HomeIntent.SetInitLoading) }
if (organizationList.loadState.prepend.endOfPaginationReached) {
viewModel.postIntent(HomeIntent.SetInitLoading)
}
}
LoadingScreenProvider(
isLoading = uiState.isJoinLoading
Expand Down Expand Up @@ -124,19 +127,32 @@ fun HomeScreen(
organizationList = organizationList,
isLoading = uiState.isInitLoading,
isRefreshing = isRefreshing,
navigateToAnnouncementDetail = navigateToAnnouncementDetail
onClickOrganizationHeader = {
viewModel.postIntent(HomeIntent.ClickOrganizationHeader(it.id, it.name))
},
onClickAnnouncementCard = { organizationId, announcementId, announcementTitle ->
viewModel.postIntent(
HomeIntent.ClickAnnouncementCard(
organizationId,
announcementId,
announcementTitle
)
)
}
)
}

HomeTopBarMenu.TASK -> {
TaskView(
modifier = Modifier
.screenHorizonPadding()
)
) { organizationId, organizationName ->
viewModel.postIntent(HomeIntent.ClickOrganizationHeader(organizationId, organizationName))
}
}
}
}
if(!uiState.isInitLoading) {
if (!uiState.isInitLoading) {
PullRefreshIndicator(
refreshing = isRefreshing,
contentColor = Green500,
Expand All @@ -156,6 +172,12 @@ fun HomeScreen(
navigateToMyPage()
}

is HomeSideEffect.NavigateToOrganizationDetail -> {
navigateToOrganizationDetail(sideEffect.organizationId, sideEffect.organizationName)
}
is HomeSideEffect.NavigateToAnnouncementDetail -> {
navigateToAnnouncementDetail(sideEffect.organizationId, sideEffect.announcementId, sideEffect.announcementTitle)
}
is HomeSideEffect.NavigateToOrganizationJoin -> {
navigateToOrganizationJoin(sideEffect.organizationSignUpInformation)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import com.easyhz.noffice.core.common.error.handleError
import com.easyhz.noffice.core.common.manager.DeepLinkManager
import com.easyhz.noffice.core.common.util.DateFormat
import com.easyhz.noffice.core.common.util.errorLogging
import com.easyhz.noffice.core.design_system.R
import com.easyhz.noffice.core.design_system.util.topBar.TopBarIconMenu
import com.easyhz.noffice.core.model.organization.Organization
import com.easyhz.noffice.domain.home.usecase.member.FetchUserInfoUseCase
import com.easyhz.noffice.domain.organization.usecase.organization.FetchOrganizationSignUpInfoUseCase
import com.easyhz.noffice.domain.organization.usecase.organization.FetchOrganizationsUseCase
import com.easyhz.noffice.core.design_system.R
import com.easyhz.noffice.feature.home.contract.home.HomeIntent
import com.easyhz.noffice.feature.home.contract.home.HomeSideEffect
import com.easyhz.noffice.feature.home.contract.home.HomeState
Expand Down Expand Up @@ -48,6 +48,8 @@ class HomeViewModel @Inject constructor(
is HomeIntent.JoinToOrganization -> { joinToOrganization(intent.organizationId) }
is HomeIntent.Refresh -> { refresh() }
is HomeIntent.SetInitLoading -> { reduce { copy(isInitLoading = false) }}
is HomeIntent.ClickOrganizationHeader -> { navigateToOrganizationDetail(intent.organizationId, intent.organizationName) }
is HomeIntent.ClickAnnouncementCard -> { navigateToAnnouncementDetail(intent.organizationId, intent.announcementId, intent.announcementTitle) }
}
}

Expand Down Expand Up @@ -87,6 +89,14 @@ class HomeViewModel @Inject constructor(
postSideEffect { HomeSideEffect.NavigateToMyPage }
}

private fun navigateToOrganizationDetail(id: Int, name: String) {
postSideEffect { HomeSideEffect.NavigateToOrganizationDetail(organizationId = id, organizationName = name) }
}

private fun navigateToAnnouncementDetail(organizationId: Int, id: Int, title: String) {
postSideEffect { HomeSideEffect.NavigateToAnnouncementDetail(organizationId, id, title) }
}


private fun fetchOrganizations() = viewModelScope.launch {
fetchOrganizationsUseCase.invoke()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.easyhz.noffice.feature.organization.contract.organization

import com.easyhz.noffice.core.common.base.UiIntent
import com.easyhz.noffice.core.design_system.util.topBar.TopBarIconMenu

sealed class OrganizationIntent: UiIntent() {
data object ClickOrganizationCreation: OrganizationIntent()
data class ClickTopBarIconMenu(val iconMenu: TopBarIconMenu): OrganizationIntent()
data class ClickOrganization(val id: Int, val name: String): OrganizationIntent()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.easyhz.noffice.feature.organization.contract.organization
import com.easyhz.noffice.core.common.base.UiSideEffect

sealed class OrganizationSideEffect: UiSideEffect() {

data object NavigateToCreation: OrganizationSideEffect()
data class NavigateToDetail(val id: Int, val name: String): OrganizationSideEffect()
data object NavigateToMyPage: OrganizationSideEffect()
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import com.easyhz.noffice.feature.organization.util.OrganizationTopBarMenu
fun OrganizationScreen(
modifier: Modifier = Modifier,
viewModel: OrganizationViewModel = hiltViewModel(),
navigateToMyPage: () -> Unit,
navigateToDetail: (Int, String) -> Unit,
navigateToCreation: () -> Unit
) {
Expand All @@ -38,10 +39,8 @@ fun OrganizationScreen(
topBar = {
HomeTopBar(
tabs = enumValues<OrganizationTopBarMenu>(),
onClickIconMenu = { }
) {

}
onClickIconMenu = { viewModel.postIntent(OrganizationIntent.ClickTopBarIconMenu(it)) }
) { }
}
) { paddingValues ->
if(organizationList.itemCount == 0 && organizationList.loadState.refresh != LoadState.Loading) {
Expand Down Expand Up @@ -95,6 +94,7 @@ fun OrganizationScreen(
when(sideEffect) {
is OrganizationSideEffect.NavigateToCreation -> { navigateToCreation() }
is OrganizationSideEffect.NavigateToDetail -> { navigateToDetail(sideEffect.id, sideEffect.name) }
is OrganizationSideEffect.NavigateToMyPage -> { navigateToMyPage() }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.viewModelScope
import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.easyhz.noffice.core.common.base.BaseViewModel
import com.easyhz.noffice.core.design_system.util.topBar.TopBarIconMenu
import com.easyhz.noffice.core.model.organization.Organization
import com.easyhz.noffice.domain.organization.usecase.organization.FetchOrganizationsUseCase
import com.easyhz.noffice.feature.organization.contract.organization.OrganizationIntent
Expand Down Expand Up @@ -35,6 +36,8 @@ class OrganizationViewModel @Inject constructor(
is OrganizationIntent.ClickOrganization -> {
onClickOrganization(intent.id, intent.name)
}

is OrganizationIntent.ClickTopBarIconMenu -> { onClickTopBarIconMenu(intent.iconMenu) }
}
}

Expand All @@ -50,6 +53,13 @@ class OrganizationViewModel @Inject constructor(
}
}

private fun onClickTopBarIconMenu(iconMenu: TopBarIconMenu) {
when(iconMenu) {
TopBarIconMenu.NOTIFICATION -> { /* TODO 네비게이션 처리 */ }
TopBarIconMenu.USER -> { navigateToMyPage() }
}
}

private fun onClickOrganizationCreation() {
postSideEffect { OrganizationSideEffect.NavigateToCreation }
}
Expand All @@ -60,4 +70,8 @@ class OrganizationViewModel @Inject constructor(
OrganizationSideEffect.NavigateToDetail(id, name)
}
}

private fun navigateToMyPage() {
postSideEffect { OrganizationSideEffect.NavigateToMyPage }
}
}

0 comments on commit 03ff09a

Please sign in to comment.