Skip to content

[REFACTOR/#183] 캘린더 리팩토링#200

Merged
boiledeggg merged 16 commits intodevelopfrom
refactor/#183-calendar
Aug 28, 2024
Merged

[REFACTOR/#183] 캘린더 리팩토링#200
boiledeggg merged 16 commits intodevelopfrom
refactor/#183-calendar

Conversation

@boiledeggg
Copy link
Copy Markdown
Member

⛳️ Work Description

  • 컴포저블 코드 리팩토링
  • 메인 캘린더 뷰모델 기능 간소화
  • 기능 분리
    • 캘린더 화면별(월간, 주간, 목록) ViewModel 추가
    • 캘린더 화면별(월간, 주간, 목록) SideEffect 추가

📸 Screenshot

UI는 바뀌지 않았습니다!

📢 To Reviewers

길고 길었던 달력 코드 리팩토링이 끝났습니다!
원래 화면별로 나눠서 하려다, 하나 하고 리뷰받는 작업이 번거로워서 그냥 리팩토링을 한번에 진행했습니다!

바꾼게 많아서 제가 놓친 부분이 많을텐데 잘 봐주세요~:)

Copy link
Copy Markdown
Member

@leeeyubin leeeyubin left a comment

Choose a reason for hiding this comment

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

리팩하느라 수고 너무너무 많았어요!!!!!

Comment on lines +10 to +11
import androidx.compose.runtime.remember
import javax.inject.Singleton
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

이 임포트는 어디에 쓰이는 건가용..?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

앗,, 삭제할게요!

Comment on lines +46 to +51
fun CalendarWeekRoute(
modifier: Modifier = Modifier,
calendarUiState: CalendarUiState,
navController: NavController = rememberNavController(),
viewModel: CalendarViewModel = hiltViewModel()
navigateToAnnouncement: (Long) -> Unit,
updateSelectedDate: (LocalDate) -> Unit,
viewModel: CalendarWeekViewModel = hiltViewModel()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

modifier는 옵셔널인 매개변수 아래에 넣어주면 좋을 것 같아요!

Comment on lines +142 to +143
CalendarWeekSuccess(
scrapList = uiState.loadState.data.toImmutableList(),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

오 아주 굿이네요

Copy link
Copy Markdown
Contributor

@arinming arinming left a comment

Choose a reason for hiding this comment

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

너무잘하시는데요,,,?ㅜㅜ 캘린더 고생하셨어요~~~~~!!!!!!!

Comment on lines +49 to +57
BackHandler {
if (uiState.isWeekEnabled) {
viewModel.updateSelectedDate(uiState.selectedDate)
} else if (uiState.isListEnabled) {
viewModel.updateListVisibility(false)
} else {
navigateUp()
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

네이밍이 전체적으로 편안해서 백 핸들러가 어떻게 구현되어있는지 알기 쉬운 것 가타용

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

그걸 알아주시다니,, 뿌듯하네요ㅎㅎㅎ

Comment on lines +62 to +63
updateSelectedDate = viewModel::updateSelectedDate,
updatePage = viewModel::updatePage,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

우왕 이런식으로 선언할 수 있군요....!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

굳이 람다 안쓰고 깔끔하게 함수 호출이 가능해서 써봤습니당

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

우오 신기하네요..!!

Comment on lines +32 to 57
fun updatePage(page: Int) = viewModelScope.launch {
_uiState.update { currentState ->
currentState.copy(
isScrapButtonClicked = !currentState.isScrapButtonClicked,
scrapId = scrapId
currentPage = page
)
}
}

fun updateInternDialogVisible(visibility: Boolean = false) {
fun updateListVisibility(
visibility: Boolean
) {
_uiState.update { currentState ->
currentState.copy(
isInternshipClicked = visibility
isListEnabled = visibility
)
}
}

fun updateInternshipModel(scrapDetailModel: CalendarScrapDetail?) {
fun updateWeekVisibility(
visibility: Boolean
) {
_uiState.update { currentState ->
currentState.copy(
internshipModel = scrapDetailModel
isWeekEnabled = visibility
)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

진짜 레전드 깔끔,,,,

scrapList: List<CalendarScrapDetail>,
onScrapButtonClicked: (Long) -> Unit,
onInternshipClicked: (CalendarScrapDetail) -> Unit,
modifier: Modifier = Modifier,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

modifier 사용 안하는 상태인데 일단 추가해두신 건가요??

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

네넵!! 뭔가 빼긴 아쉬워서 추가만 해놨습니다,,

Comment on lines +143 to +155
private fun getColorIndex(color: Color): Int = listOf(
CalRed,
CalOrange1,
CalOrange2,
CalYellow,
CalGreen1,
CalGreen2,
CalBlue1,
CalBlue2,
CalPurple,
CalPink
).indexOf(color)
} No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getColorIndex 함수가 모든 뷰모델마다 있는데 해당 함수를 전역적으로 사용할 수는 없을까용...!?! 궁금

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

나중에 domain/type 패키지 안에 enum 클래스들을 만들어서 저런 선택지들을 관리하는게 좋을 것 같아요!!
다음 안드회의때 논의해봅시닷

Copy link
Copy Markdown
Member

@Hyobeen-Park Hyobeen-Park left a comment

Choose a reason for hiding this comment

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

정말 수고 많으셨습니다~~~!!!! 진짜 짱이다...💚

Comment on lines +62 to +63
updateSelectedDate = viewModel::updateSelectedDate,
updatePage = viewModel::updatePage,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

우오 신기하네요..!!

@boiledeggg boiledeggg merged commit 6d31941 into develop Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

REFACTOR ♻️ 전면 수정 석준💜 석준

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REFACTOR] 캘린더 리팩토링

4 participants