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/#236] 홈 뷰 / 1차 QA 반영 #243

Merged
merged 15 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import coil.request.ImageRequest
import com.terning.core.R
import com.terning.core.designsystem.theme.Grey300
import com.terning.core.designsystem.theme.Grey400
import com.terning.core.designsystem.theme.TerningMain
import com.terning.core.designsystem.theme.TerningPointTheme
Expand Down Expand Up @@ -86,7 +87,7 @@ fun InternItem(
Text(
text = dateDeadline,
style = TerningTheme.typography.detail0,
color = TerningMain,
color = if (dateDeadline == "지원마감") Grey300 else TerningMain,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거는 추출하는 게 좋을 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니당!!

)
TwoLineHeightText(
text = title,
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
<string name="calendar_button_description_list">list</string>

<!--SortByBottom-->
<string name="sort_by_earliest">채용 마감 이른순</string>
<string name="sort_by_shortest">짧은 근무 기간순</string>
<string name="sort_by_longest">긴 근무 기간순</string>
<string name="sort_by_scrap">스크랩 많은순</string>
<string name="sort_by_view_count">조회수 많은순</string>
<string name="sort_by_earliest">채용 마감 이른 순</string>
<string name="sort_by_shortest">짧은 근무 기간 순</string>
<string name="sort_by_longest">긴 근무 기간 순</string>
<string name="sort_by_scrap">스크랩 많은 순</string>
<string name="sort_by_view_count">조회수 많은 순</string>
<string name="sort_button_description">정렬 기준</string>
<string name="sort_bottom_sheet_title">공고 정렬 순서</string>

Expand Down Expand Up @@ -76,8 +76,8 @@
<string name="change_filter_grade_3">3학년</string>
<string name="change_filter_grade_4">4학년</string>
<string name="change_filter_period_title">희망 근무 기간</string>
<string name="change_filter_period_1">1개월 ~ 3개월</string>
<string name="change_filter_period_2">4개월 ~ 6개월</string>
<string name="change_filter_period_1">1 ~ 3개월</string>
<string name="change_filter_period_2">4 ~ 6개월</string>
<string name="change_filter_period_3">7개월 이상</string>
<string name="change_filter_start_work_title">근무 시작 시기</string>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import kotlinx.serialization.Serializable
@Serializable
data class ChangeFilterRequestDto(
@SerialName("grade")
val grade: Int,
val grade: String,
@SerialName("workingPeriod")
val workingPeriod: Int,
val workingPeriod: String,
@SerialName("startYear")
val startYear: Int,
@SerialName("startMonth")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import kotlinx.serialization.Serializable
@Serializable
data class HomeFilteringInfoResponseDto(
@SerialName("grade")
val grade: Int?,
val grade: String?,
@SerialName("workingPeriod")
val workingPeriod: Int?,
val workingPeriod: String?,
@SerialName("startYear")
val startYear: Int?,
@SerialName("startMonth")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ data class HomeUpcomingInternResponseDto(
val color: String,
@SerialName("startYearMonth")
val startYearMonth: String,
)
@SerialName("companyInfo")
val companyInfo: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ fun HomeUpcomingInternResponseDto.toHomeUpcomingInternList(): HomeUpcomingIntern
isScrapped = this.isScrapped,
startYearMonth = this.startYearMonth,
color = this.color,
)
companyInfo = this.companyInfo,
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.terning.domain.entity.home

data class HomeFilteringInfo(
val grade: Int?,
val workingPeriod: Int?,
val grade: String?,
val workingPeriod: String?,
val startYear: Int?,
val startMonth: Int?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ data class HomeUpcomingIntern(
val isScrapped: Boolean,
val color: String,
val startYearMonth: String,
val companyInfo: String,
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.terning.domain.entity.request

data class ChangeFilteringRequestModel(
val grade: Int,
val workingPeriod: Int,
val grade: String,
val workingPeriod: String,
val startYear: Int,
val startMonth: Int,
)
114 changes: 57 additions & 57 deletions feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fun HomeRoute(
val context = LocalContext.current

LaunchedEffect(key1 = true) {
viewModel.getProfile()
viewModel.getFilteringInfo()
}
Comment on lines 88 to 91
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정 감사합니당:)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎


Expand Down Expand Up @@ -158,9 +159,9 @@ fun HomeScreen(

if (changeFilteringSheetState) {
HomeFilteringBottomSheet(
defaultGrade = homeFilteringInfo.grade?.let { Grade.entries[it] },
defaultGrade = homeFilteringInfo.grade?.let { Grade.fromString(it) },
defaultWorkingPeriod = homeFilteringInfo.workingPeriod?.let {
WorkingPeriod.entries[it]
WorkingPeriod.fromString(it)
},
defaultStartYear = homeFilteringInfo.startYear,
defaultStartMonth = homeFilteringInfo.startMonth,
Expand All @@ -178,18 +179,48 @@ fun HomeScreen(
}
}

LaunchedEffect(
homeState.homeRecommendDialogVisibility,
homeState.homeUpcomingDialogVisibility
) {
with(homeState) {
if (!homeRecommendDialogVisibility && !homeUpcomingDialogVisibility) {
viewModel.getRecommendInternsData(
sortBy = sortBy.ordinal,
startYear = homeFilteringInfo.startYear ?: Calendar.getInstance().currentYear,
startMonth = homeFilteringInfo.startMonth
?: Calendar.getInstance().currentMonth,
)
if (homeState.homeRecommendDialogVisibility) {
with(homeState.homeInternModel) {
if (this != null) {
if (isScrapped) {
ScrapCancelDialog(
Comment on lines +182 to +186
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔꼼

internshipAnnouncementId = internshipAnnouncementId,
onDismissRequest = {
viewModel.updateRecommendDialogVisibility(false)
viewModel.getHomeUpcomingInternList()
viewModel.getRecommendInternsData(
sortBy = homeState.sortBy.ordinal,
startYear = homeFilteringInfo.startYear ?: Calendar.getInstance().currentYear,
startMonth = homeFilteringInfo.startMonth
?: Calendar.getInstance().currentMonth,
)
}
)
} else {
ScrapDialog(
title = title,
scrapColor = CalRed,
deadline = deadline,
startYearMonth = startYearMonth,
workingPeriod = workingPeriod,
internshipAnnouncementId = internshipAnnouncementId,
companyImage = companyImage,
isScrapped = isScrapped,
onDismissRequest = {
viewModel.updateRecommendDialogVisibility(
false
)
viewModel.getHomeUpcomingInternList()
viewModel.getRecommendInternsData(
sortBy = homeState.sortBy.ordinal,
startYear = homeFilteringInfo.startYear ?: Calendar.getInstance().currentYear,
startMonth = homeFilteringInfo.startMonth
?: Calendar.getInstance().currentMonth,
)
},
onClickNavigateButton = navigateToIntern
)
}
}
}
}
Expand All @@ -216,10 +247,7 @@ fun HomeScreen(
.fillMaxWidth(),
) {
item {
Column(
modifier = Modifier
.padding(bottom = 16.dp)
) {
Column {
ShowMainTitleWithName(homeUserName)
ShowUpcomingIntern(
homeUpcomingInternState = homeState.homeUpcomingInternState,
Expand Down Expand Up @@ -300,41 +328,6 @@ fun HomeScreen(
}
}
)

if (homeState.homeRecommendDialogVisibility) {
with(homeState.homeInternModel) {
if (this != null) {
if (isScrapped) {
ScrapCancelDialog(
internshipAnnouncementId = internshipAnnouncementId,
onDismissRequest = {
viewModel.updateRecommendDialogVisibility(false)
viewModel.getHomeUpcomingInternList()
}
)
} else {
ScrapDialog(
title = title,
scrapColor = CalRed,
deadline = deadline,
startYearMonth = startYearMonth,
workingPeriod = workingPeriod,
internshipAnnouncementId = internshipAnnouncementId,
companyImage = companyImage,
isScrapped = isScrapped,
onDismissRequest = {
viewModel.updateRecommendDialogVisibility(
false
)
viewModel.getHomeUpcomingInternList()
},
onClickChangeColor = { /*TODO*/ },
onClickNavigateButton = navigateToIntern
)
}
}
}
}
}
} else {
item {
Expand Down Expand Up @@ -382,8 +375,12 @@ private fun ShowMainTitleWithName(userName: String) {
else userName
),
modifier = Modifier
.padding(top = 11.dp, bottom = 19.dp)
.padding(horizontal = 24.dp),
.padding(
top = 2.dp,
bottom = 20.dp,
start = 24.dp,
end = 24.dp,
),
style = TerningTheme.typography.title1,
color = Black,
)
Expand Down Expand Up @@ -422,8 +419,11 @@ private fun ShowRecommendTitle() {
style = TerningTheme.typography.title1,
color = Black,
modifier = Modifier
.padding(top = 5.dp)
.padding(horizontal = 24.dp),
.padding(
top = 22.dp,
start = 24.dp,
end = 24.dp,
),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ class HomeViewModel @Inject constructor(
private val _homeSideEffect = MutableSharedFlow<HomeSideEffect>()
val homeSideEffect get() = _homeSideEffect.asSharedFlow()

init {
getProfile()
getFilteringInfo()
}

fun getRecommendInternsData(sortBy: Int, startYear: Int?, startMonth: Int?) {
viewModelScope.launch {
homeRepository.getRecommendIntern(
Expand Down Expand Up @@ -94,15 +89,15 @@ class HomeViewModel @Inject constructor(
}
}

fun putFilteringInfo(grade: Int, workingPeriod: Int, year: Int, month: Int) {
fun putFilteringInfo(grade: String, workingPeriod: String, year: Int, month: Int) {
viewModelScope.launch {
homeRepository.putFilteringInfo(
ChangeFilteringRequestModel(grade, workingPeriod, year, month)
)
}
}

private fun getProfile() {
fun getProfile() {
viewModelScope.launch {
myPageRepository.getProfile().onSuccess { response ->
_homeState.value = _homeState.value.copy(
Expand Down Expand Up @@ -138,6 +133,7 @@ class HomeViewModel @Inject constructor(
isScrapped: Boolean,
color: String?,
startYearMonth: String,
companyInfo: String = "",
) {
_homeState.update {
it.copy(
Expand All @@ -152,6 +148,7 @@ class HomeViewModel @Inject constructor(
isScrapped = isScrapped,
color = color ?: "",
startYearMonth = startYearMonth,
companyInfo = companyInfo,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fun HomeFilteringBottomSheet(
defaultStartYear: Int?,
defaultStartMonth: Int?,
onDismiss: () -> Unit,
onChangeButtonClick: (Int, Int, Int, Int) -> Unit,
onChangeButtonClick: (String, String, Int, Int) -> Unit,
) {
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)

Expand Down Expand Up @@ -126,8 +126,8 @@ fun HomeFilteringBottomSheet(

YearMonthPicker(
chosenYear = defaultStartYear ?: Calendar.getInstance().currentYear,
chosenMonth = defaultStartMonth?.minus(1)
?: Calendar.getInstance().currentMonth.minus(1),
chosenMonth = defaultStartMonth
?: Calendar.getInstance().currentMonth,
onYearChosen = { currentStartYear = it },
onMonthChosen = { currentStartMonth = it }
)
Expand All @@ -142,8 +142,8 @@ fun HomeFilteringBottomSheet(
currentGrade?.let { grade ->
currentPeriod?.let { workingPeriod ->
onChangeButtonClick(
grade.ordinal,
workingPeriod.ordinal,
grade.stringValue,
workingPeriod.stringValue,
currentStartYear,
currentStartMonth,
)
Expand Down Expand Up @@ -184,7 +184,7 @@ fun ChangeFilteringRadioGroup(

LazyVerticalGrid(
columns = GridCells.Fixed(optionList.size),
horizontalArrangement = Arrangement.spacedBy(12.dp),
horizontalArrangement = Arrangement.spacedBy(13.dp),
modifier = modifier
.fillMaxWidth()
.wrapContentHeight()
Expand Down
Loading
Loading