Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX/#150] 1차 QA 반영 #160

Merged
merged 5 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ 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
import com.terning.core.designsystem.theme.CalBlue1
import com.terning.core.designsystem.theme.CalBlue2
import com.terning.core.designsystem.theme.CalGreen1
import com.terning.core.designsystem.theme.CalGreen2
import com.terning.core.designsystem.theme.CalOrange1
import com.terning.core.designsystem.theme.CalOrange2
import com.terning.core.designsystem.theme.CalPink
import com.terning.core.designsystem.theme.CalPurple
import com.terning.core.designsystem.theme.CalRed
import com.terning.core.designsystem.theme.CalYellow
import com.terning.core.designsystem.theme.Grey150
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.designsystem.theme.White
Expand Down Expand Up @@ -314,6 +324,22 @@ fun HomeScreen(
}
)
} else {
val colorList = listOf(
CalRed,
CalOrange1,
CalOrange2,
CalYellow,
CalGreen1,
CalGreen2,
CalBlue1,
CalBlue2,
CalPurple,
CalPink,
)

val selectedColorIndex =
colorList.indexOf(homeDialogState.selectedColor).takeIf { it >= 0 } ?: 0

with(recommendInternList[scrapId]) {
HomeRecommendInternDialog(
internInfoList = listOf(
Expand All @@ -322,6 +348,20 @@ fun HomeScreen(
stringResource(id = R.string.intern_info_start_date) to startYearMonth,
),
clickAction = {
if (homeDialogState.isPaletteOpen) {
viewModel.updatePaletteOpen(false)
viewModel.updateColorChange(false)
viewModel.updateScrapDialogVisible(false)
} else {
if (homeDialogState.isColorChange) {
viewModel.updateColorChange(false)
}
viewModel.updateScrapDialogVisible(false)
}
viewModel.postScrap(
recommendInternList[scrapId].internshipAnnouncementId,
selectedColorIndex,
)
viewModel.updateScrapDialogVisible(false)
if (homeDialogState.isScrappedState) {
viewModel.getRecommendInternsData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class HomeViewModel @Inject constructor(
updateScrapDialogVisible(visible = false)
updateScrapped(scrapped = true)
getHomeTodayInternList()
_homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.intern_scrap_add_toast_message))
}.onFailure {
_homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.server_failure))
}
Expand All @@ -150,6 +151,7 @@ class HomeViewModel @Inject constructor(
updateScrapDialogVisible(visible = false)
updateScrapped(scrapped = true)
getHomeTodayInternList()
_homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.intern_scrap_delete_toast_message))
}.onFailure {
_homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.server_failure))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,6 @@ fun HomeRecommendInternDialog(
) {
val state by viewModel.homeDialogState.collectAsStateWithLifecycle()

val colorList = listOf(
CalRed,
CalOrange1,
CalOrange2,
CalYellow,
CalGreen1,
CalGreen2,
CalBlue1,
CalBlue2,
CalPurple,
CalPink,
)

Box(
modifier = Modifier
.wrapContentSize()
Expand Down Expand Up @@ -225,30 +212,12 @@ fun HomeRecommendInternDialog(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.BottomCenter
) {
val selectedColorIndex =
colorList.indexOf(state.selectedColor).takeIf { it >= 0 } ?: 0

RoundButton(
style = TerningTheme.typography.button3,
paddingVertical = 12.dp,
cornerRadius = 8.dp,
text = R.string.dialog_scrap_button,
onButtonClick = {
if (state.isPaletteOpen) {
viewModel.updatePaletteOpen(false)
viewModel.updateColorChange(false)
viewModel.updateScrapDialogVisible(false)
} else {
if (state.isColorChange) {
viewModel.updateColorChange(false)
}
viewModel.updatePaletteOpen(false)
viewModel.updateScrapDialogVisible(false)
}
viewModel.postScrap(
homeRecommendInternModel.internshipAnnouncementId,
selectedColorIndex,
)
clickAction()
},
modifier = Modifier.padding(bottom = 8.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand All @@ -43,14 +44,26 @@ import com.terning.core.designsystem.component.item.InternItemWithShadow
import com.terning.core.designsystem.component.textfield.SearchTextField
import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar
import com.terning.core.designsystem.theme.Black
import com.terning.core.designsystem.theme.CalBlue1
import com.terning.core.designsystem.theme.CalBlue2
import com.terning.core.designsystem.theme.CalGreen1
import com.terning.core.designsystem.theme.CalGreen2
import com.terning.core.designsystem.theme.CalOrange1
import com.terning.core.designsystem.theme.CalOrange2
import com.terning.core.designsystem.theme.CalPink
import com.terning.core.designsystem.theme.CalPurple
import com.terning.core.designsystem.theme.CalRed
import com.terning.core.designsystem.theme.CalYellow
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningPointTheme
import com.terning.core.designsystem.theme.TerningTheme
import com.terning.core.extension.addFocusCleaner
import com.terning.core.extension.noRippleClickable
import com.terning.core.extension.toast
import com.terning.domain.entity.response.HomeRecommendInternModel
import com.terning.feature.R
import com.terning.feature.intern.component.ScrapDialogContent
import com.terning.feature.home.home.component.HomeRecommendInternDialog
import com.terning.feature.intern.navigation.navigateIntern

private const val MAX_LINES = 1
Expand All @@ -60,6 +73,7 @@ fun SearchProcessRoute(
navController: NavHostController,
viewModel: SearchProcessViewModel = hiltViewModel(),
) {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current

val currentSortBy: MutableState<Int> = remember {
Expand All @@ -70,17 +84,11 @@ fun SearchProcessRoute(
viewModel.sideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle)
.collect { sideEffect ->
when (sideEffect) {
is SearchProcessSideEffect.Toast -> {
sideEffect.message
}
is SearchProcessSideEffect.Toast -> context.toast(sideEffect.message)

is SearchProcessSideEffect.ScrapUpdate -> {
sideEffect.keyword
}

else -> {

}
}
}
}
Expand Down Expand Up @@ -280,27 +288,84 @@ fun SearchProcessScreen(
onClickScrapCancel = {
viewModel.updateScrapDialogVisible(false)
viewModel.deleteScrap(
selectedIntern.scrapId ?: -1,
internSearchResultData[selectedIndex].scrapId ?: -1,
)
if (dialogState.isScrappedState) {
viewModel.getSearchList(
keyword = state.text,
sortBy = SORT_BY,
page = 0,
size = 10
)
viewModel.updateScrapped(false)
}
viewModel.updateSelectColor(CalRed)
}
)
} else {
val internInfoList = listOf(
stringResource(id = R.string.intern_info_d_day) to selectedIntern.deadline,
stringResource(id = R.string.intern_info_working) to selectedIntern.workingPeriod,
stringResource(id = R.string.intern_info_start_date) to selectedIntern.startYearMonth,
)
ScrapDialogContent(
internInfoList = internInfoList,
dDay = selectedIntern.dDay,
title = selectedIntern.title,
companyImage = selectedIntern.companyImage,
announcementId = selectedIntern.internshipAnnouncementId,
type = 1
val colorList = listOf(
CalRed,
CalOrange1,
CalOrange2,
CalYellow,
CalGreen1,
CalGreen2,
CalBlue1,
CalBlue2,
CalPurple,
CalPink,
)

val selectedColorIndex =
colorList.indexOf(dialogState.selectedColor).takeIf { it >= 0 } ?: 0

with(selectedIntern) {
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 = {
if (dialogState.isPaletteOpen) {
viewModel.updatePaletteOpen(false)
viewModel.postScrap(
internshipAnnouncementId = internshipAnnouncementId,
selectedColorIndex,
)
viewModel.updateColorChange(false)
viewModel.updateScrapDialogVisible(false)
} else {
if (dialogState.isColorChange) {
viewModel.postScrap(
internshipAnnouncementId,
selectedColorIndex
)
viewModel.updateColorChange(false)
} else {
viewModel.postScrap(internshipAnnouncementId, 0)

}
viewModel.updateScrapDialogVisible(false)
}
viewModel.postScrap(
internshipAnnouncementId = internshipAnnouncementId,
selectedColorIndex,
)
},
homeRecommendInternModel = HomeRecommendInternModel(
scrapId = scrapId,
internshipAnnouncementId = internshipAnnouncementId,
companyImage = companyImage,
title = title,
deadline = deadline,
workingPeriod = workingPeriod,
startYearMonth = startYearMonth,
isScrapped = scrapId != null,
dDay = dDay
),
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SearchProcessViewModel @Inject constructor(
page = 0,
size = 10
)
_sideEffect.emit(SearchProcessSideEffect.Toast(R.string.intern_scrap_add_toast_message))
}.onFailure {
_sideEffect.emit(SearchProcessSideEffect.Toast(R.string.server_failure))
}
Expand All @@ -99,6 +100,7 @@ class SearchProcessViewModel @Inject constructor(
page = 0,
size = 10
)
_sideEffect.emit(SearchProcessSideEffect.Toast(R.string.intern_scrap_delete_toast_message))
}.onFailure {
_sideEffect.emit(SearchProcessSideEffect.Toast(R.string.server_failure))
}
Expand Down
Loading