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

[refactor] CourseDetail (코스 상세 + 관리자 아카이빙) 분기처리 리팩토링 #199

Merged
merged 23 commits into from
Aug 22, 2024

Conversation

jihyunniiii
Copy link
Contributor

Related issue 🛠

Work Description ✏️

  • CourseDetail (코스 상세 + 관리자 아카이빙) 분기처리 리팩토링을 진행했어요.
    1. 코스 상세(CourseDetail), 관리자 아카이빙(Advertisement) 분리
    두 뷰의 형태는 유사하나 코스 상세에서는 CourseDetail Data Class를 관리자 아카이빙에서는 Advertisement Data Class를 활용해 정보를 보여주기 때문에 이로 인한 분기처리가 추가됩니다. (다른 data class를 활용하기 때문에 같은 컴포넌트를 사용하더라도 data class에 따른 분기처리를 추가로 진행해야 함) 따라서 두 뷰를 나누어 분기처리의 depth를 줄였습니다.
    2. 공통 컴포넌트 추가 (DateRoadImagePager, DateRoadScrollResponsiveTopBar)
    data class가 달라 두 뷰를 분리하였지만 두 뷰의 형태가 유사하기 때문에 공통적인 부분을 재사용하려고 노력하였습니다. TopBar와 ImagePager를 공통 컴포넌트화 하였습니다.
    3. isViewable 변수 선언
    코스 상세 뷰는 크게 2가지의 뷰로 나누어집니다. (상세 정보를 모두 확인할 수 있는 뷰 - 이미 열람한 글이거나 내가 쓴 글인 경우, 상세 정보를 볼 수 없는 뷰 - 내가 작성하지 않은 글 중 아직 열람하지 않은 글) 따라서 이를 분기처리할 수 있도록 isViewable 변수를 선언하였습니다. (뷰가 달라지는 부분이 많기 때문에 Type을 선언하는 것보다는 변수를 활용하여 분기처리를 하는 것이 낫다고 판단하였습니다.)
    4. CourseDetailUnopenedDetailType
    상세 정보를 볼 수 없는 뷰는 2가지의 형태로 나누어집니다. (포인트 사용, 무료 열람 기회 사용) 이 두 뷰의 형태는 동일하나 내부의 텍스트 값만 변경되기 때문에 타입을 만들어 관리하였습니다.
    5. Component 세분화
    멘토님 피드백을 반영하여 컴포넌트를 세분화 하였습니다.

Screenshot 📸

Screen_recording_20240818_041046.mp4

Uncompleted Tasks 😅

  • N/A

To Reviewers 📢

  • 분기처리와 관련된 리팩토링만 진행하였습니다. 로직 설계 등 추가적인 리팩토링은 민석오빠가 나중에 해주세요! (하면서 분기처리 리팩 추가로 더 하고 싶으면 진행해주셔도 됩니다!)
  • 빼먹은 분기처리가 있다면 말씀해주세요!

Copy link
Contributor

@2hyunjinn 2hyunjinn left a comment

Choose a reason for hiding this comment

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

고생 많았슴당 진짜루 ㅜㅜ

Copy link
Contributor

@t1nm1ksun t1nm1ksun left a comment

Choose a reason for hiding this comment

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

내일 만나서 볼게!!

@jihyunniiii jihyunniiii merged commit a460ebc into develop Aug 22, 2024
1 check passed
@jihyunniiii jihyunniiii deleted the refactor-course-detail-view branch August 22, 2024 06:59
Copy link
Contributor

@t1nm1ksun t1nm1ksun left a comment

Choose a reason for hiding this comment

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

와 일단 컴포넌트 다 빼고 광고 따로 뷰만든거 미쳤다..
뒤늦게서야 봤는데 개지린다 역시... 코스상세 뷰 함수 완전 깔끔해졌네요
신고하기 pr머지되면 시작시간 타임라인위에 추가하는건 내가 후딱 할게!

Comment on lines +6 to +18
enum class CourseDetailUnopenedDetailType(
@StringRes val descriptionStringRes: Int,
@StringRes val buttonTextStringRes: Int
) {
POINT(
descriptionStringRes = R.string.course_detail_point_read_button_description,
buttonTextStringRes = R.string.course_detail_point_read_button
),
FREE(
descriptionStringRes = R.string.course_detail_free_read_button_description,
buttonTextStringRes = R.string.course_detail_free_read_button
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

스크린 함수 안에서 uiStateType으로 분기처리 해서 안에 값들을 처리안하고 이렇게 하니까 스크린 파일 훨씬 깔끔해지네요 ㄷㄷ

Comment on lines +9 to +22
class AdvertisementContract {
data class AdvertisementUiState(
val loadState: LoadState = LoadState.Idle,
val advertisementDetail: AdvertisementDetail = AdvertisementDetail()
) : UiState

sealed interface AdvertisementSideEffect : UiSideEffect {
data object PopBackStack : AdvertisementSideEffect
}

sealed class AdvertisementEvent : UiEvent {
data class FetchAdvertisementDetail(val loadState: LoadState, val advertisementDetail: AdvertisementDetail) : AdvertisementEvent()
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 처음에 코스상세 data class > advertisement data class 여서 필요한 인자만 가져와서 사용하면 된다고 생각했는데 같은 뷰에서 분기처리 하기 보다 이렇게 뷰를 따로 만드는게 추후에 더 좋은가요?? (궁금해서)

Comment on lines +26 to +33
fun DateRoadImagePager(
modifier: Modifier = Modifier,
pagerState: PagerState,
images: List<String>,
userScrollEnabled: Boolean,
like: String?
) {
Box(modifier = Modifier.fillMaxWidth()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

공통 컴포넌트화 이거 내가 했어야 했는데.. 감사링

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[refactor] CourseDetail (코스 상세 + 관리자 아카이빙) 분기처리 리팩토링
3 participants