Skip to content

Commit

Permalink
[FEAT/#146] 딱 맞는 인턴 공고 다이얼로그 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyobeen-Park committed Jul 18, 2024
1 parent dce4741 commit 388abe9
Show file tree
Hide file tree
Showing 5 changed files with 327 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fun InternItemWithShadow(
dateDeadline: String,
workingPeriod: String,
isScrapped: Boolean,
onScrapButtonClicked: (Long) -> Unit = {}
) {
Box(
modifier = modifier
Expand All @@ -40,7 +41,8 @@ fun InternItemWithShadow(
title = title,
dateDeadline = dateDeadline,
workingPeriod = workingPeriod,
isScraped = isScrapped
isScraped = isScrapped,
onScrapButtonClicked = onScrapButtonClicked
)
}
}
63 changes: 61 additions & 2 deletions feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import androidx.navigation.NavHostController
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.terning.core.designsystem.component.bottomsheet.SortingBottomSheet
import com.terning.core.designsystem.component.button.SortingButton
import com.terning.core.designsystem.component.dialog.ScrapCancelDialogContent
import com.terning.core.designsystem.component.dialog.TerningBasicDialog
import com.terning.core.designsystem.component.item.InternItemWithShadow
import com.terning.core.designsystem.component.topappbar.LogoTopAppBar
import com.terning.core.designsystem.theme.Black
Expand All @@ -52,6 +54,7 @@ import com.terning.feature.home.changefilter.navigation.navigateChangeFilter
import com.terning.feature.home.home.component.HomeFilteringEmptyIntern
import com.terning.feature.home.home.component.HomeFilteringScreen
import com.terning.feature.home.home.component.HomeRecommendEmptyIntern
import com.terning.feature.home.home.component.HomeRecommendInternDialog
import com.terning.feature.home.home.component.HomeTodayEmptyWithImg
import com.terning.feature.home.home.component.HomeTodayIntern
import com.terning.feature.home.home.model.HomeDialogState
Expand Down Expand Up @@ -168,6 +171,7 @@ fun HomeScreen(
navController: NavHostController,
) {
var sheetState by remember { mutableStateOf(false) }
var scrapId by remember { mutableStateOf(-1) }

if (sheetState) {
SortingBottomSheet(
Expand Down Expand Up @@ -247,7 +251,12 @@ fun HomeScreen(
items(recommendInternList.size) { index ->
RecommendInternItem(
navController = navController,
intern = recommendInternList[index]
intern = recommendInternList[index],
onScrapButtonClicked = {
viewModel.updateScrapDialogVisible(true)
viewModel.updateIsToday(false)
scrapId = index
}
)
}
}
Expand All @@ -264,13 +273,62 @@ fun HomeScreen(
}
}
}

if (homeDialogState.isScrapDialogVisible && !homeDialogState.isToday) {
TerningBasicDialog(
onDismissRequest = { viewModel.updateScrapDialogVisible(false) },
content = {
if (recommendInternList[scrapId].scrapId != null) {
ScrapCancelDialogContent(
onClickScrapCancel = {
viewModel.updateScrapDialogVisible(false)
viewModel.deleteScrap(
recommendInternList[scrapId].scrapId ?: -1,
)
if(homeDialogState.isScrappedState) {
viewModel.getRecommendInternsData(
currentSortBy.value,
homeFilteringInfo.startYear ?: viewModel.currentYear,
homeFilteringInfo.startMonth ?: viewModel.currentMonth,
)
viewModel.updateScrapped(false)
}
}
)
} else {
with(recommendInternList[scrapId]) {
HomeRecommendInternDialog(
internInfoList = listOf(
stringResource(id = R.string.intern_info_d_day) to deadline,
stringResource(id = R.string.intern_info_working) to workingPeriod,
stringResource(id = R.string.intern_info_start_date) to startYearMonth,
),
clickAction = {
viewModel.updateScrapDialogVisible(false)
if(homeDialogState.isScrappedState) {
viewModel.getRecommendInternsData(
currentSortBy.value,
homeFilteringInfo.startYear ?: viewModel.currentYear,
homeFilteringInfo.startMonth ?: viewModel.currentMonth,
)
viewModel.updateScrapped(false)
}
},
homeRecommendInternModel = this,
)
}
}
}
)
}
}


@Composable
private fun RecommendInternItem(
navController: NavHostController,
intern: HomeRecommendInternModel,
onScrapButtonClicked: (Long) -> Unit,
) {
InternItemWithShadow(
modifier = Modifier
Expand All @@ -286,7 +344,8 @@ private fun RecommendInternItem(
workingPeriod = intern.workingPeriod,
isScrapped = intern.isScrapped,
shadowRadius = 5.dp,
shadowWidth = 1.dp
shadowWidth = 1.dp,
onScrapButtonClicked = onScrapButtonClicked,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class HomeViewModel @Inject constructor(
).onSuccess {
updateScrapDialogVisible(visible = false)
updateScrapped(scrapped = true)
getHomeTodayInternList()
}.onFailure {
_homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.server_failure))
}
Expand All @@ -148,7 +149,8 @@ class HomeViewModel @Inject constructor(
ScrapRequestModel(id = scrapId)
).onSuccess {
updateScrapDialogVisible(visible = false)
updateScrapped(scrapped = false)
updateScrapped(scrapped = true)
getHomeTodayInternList()
}.onFailure {
_homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.server_failure))
}
Expand Down
Loading

0 comments on commit 388abe9

Please sign in to comment.