Skip to content

Conversation

Kwon-Seokki
Copy link
Collaborator

📌 관련 이슈

✅ 과제 내용

  • tving 메인화면을 SwiftUI로 구현

🍎 문제 해결

기존의 화면플로우를 그대로 활용하고 싶어서 UIHostingController를 사용해서 기존의 플로우는 유지하고 메인화면만 SwiftUI로 구현했습니다.

 func loginFlowDidComplete() {
        let mainViewController = MainViewController()
        let hostingView = UIHostingController(rootView: SwiftUIView())
        let navigationController = UINavigationController(rootViewController: hostingView)
                
        window?.rootViewController = navigationController
    }

각각의 컬렉션뷰는 title, items를 외부에서 설정할 수 있도록 컴포넌트화 했습니다. 이 외에도 헤더 푸터도 비슷하게 컴포넌트롤 분리했습니다.

struct MovieListView: View {
    let items: [ContentModel]
    let title: String
    var isShowRanking = false
    
    var body: some View {
        VStack(spacing: 13) {
            HStack {
                Text(title)
                    .foregroundStyle(.white)
                    .fontWeight(.semibold)
                Spacer()
            }
            .padding(.leading, 15)
            .padding(.vertical, 10)
            ScrollView(.horizontal) {
                HStack(alignment: .bottom, spacing: 8) {
                    ForEach(Array(items.enumerated()), id: \.self.offset) { offset, item in
                        if isShowRanking {
                            Image("number\(offset+1)")
                        }
                        Image(uiImage: item.thumbnail)
                            .resizable()
                            .frame(width: 98, height: 146)
                            .cornerRadius(3)
                    }
                }
                .padding(.leading, 15)
            }
        }
    }
}

📸 시연연상

Simulator Screen Recording - iPhone 16 Pro - 2025-06-03 at 22 52 32

@Kwon-Seokki Kwon-Seokki self-assigned this Jun 3, 2025
Copy link

@SeungWon1125 SeungWon1125 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 +9 to +11

struct KimGaHyunBestListView: View {
let items: [ContentModel]

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ아 진짜 웃기다 ㅋㅋㅋㅋㅋ @mcrkgus

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 아 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

Comment on lines +25 to +46
VStack(spacing: 10) {
Image(uiImage: item.thumbnail)
.resizable()
.frame(width: 160, height: 80)
HStack(alignment: .top) {
Image("number\(offset + 1)")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 23)
VStack(alignment: .leading) {
Text(item.title)
.foregroundStyle(.white)
Text(item.description)
.foregroundStyle(.gray)
.font(.caption)
Text("\(item.rating)%")
.foregroundStyle(.gray)
.font(.caption)
}
}
}
.frame(maxWidth: 160)

Choose a reason for hiding this comment

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

요런 부분은 따로 컴포넌트로 분리할 수 있어 보이는데, 하지 않으신 이유가 있는지 궁금해요!!

Choose a reason for hiding this comment

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

저도 뎁스가 깊어지는 것 같아서 따로 Cell 등 ... 으로 분리하는 것도 좋아보여요 !
분리하지 않으신 이유는 저도 궁금합니다 ~ㅎㅎ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이런 경우에 보통은 무조건 분리를 합니다.!! 이번에 시간이슈가 조금 있어서
추후에 리뷰 반영하도록 하겠습니다!!

Comment on lines +28 to +30
if isShowRanking {
Image("number\(offset+1)")
}

Choose a reason for hiding this comment

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

isShowRanking 이 어떤 역할을 하는 변수인가요!! 궁금합니다ㅏ

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이탤릭체로 랭킹을 보여주는지 여부입니다!
리스트의 디자인이나 간격이 동일하기에 간단하게 isShowRanking으로 상황에따라 랭킹 숨김여부를 처리했어요!

Comment on lines +10 to 13
enum MockData: Hashable {
case thumbnail
case banner
case todayTving([ContentModel])

Choose a reason for hiding this comment

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

오 이렇게 MockData를 enum으로 관리하는 것도 좋아 보이네요! 배워갑니다

Comment on lines +10 to +42
struct SwiftUIView: View {
private let items = ["", "드라마", "예능", "영화", "스포츠", "뉴스"]
var body: some View {
ScrollView {
HeaderView()
MenuView(items: items)
ForEach(MockData.items, id: \.self) { type in
switch type {
case .thumbnail:
Image(.main)
.resizable()
case let .todayTving(items):
MovieListView(items: items, title: "오늘의 티빙 TOP 20", isShowRanking: true)
case let .popularLive(items):
LivePopularListView(items: items)
case let .popularMovie(items):
MovieListView(items: items, title: "실시간 인기 영화")
case .banner:
Image(.banner)
.resizable()
.aspectRatio(contentMode: .fit)
.padding(.vertical, 20)
case let .sport(items):
SportListView(items: items)
case let .kimGahyunBest(items):
KimGaHyunBestListView(items: items)
}
}
FooterView()
}
.background(.black)
}
}

Choose a reason for hiding this comment

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

MockData.item을 기반으로 섹션을 동적으로 구성하는 방법도 좋아보이네요!
UI변경에 유리해 보입니다 👍🏻 (예를 들어 갑자기 기획이 섹션의 순서를 바꾸자 하면 배열 순서만 바꾸면 되니까!!)
많이 배워갑니다ㅏㅏ

Copy link

@seojoozero seojoozero 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 +9 to +11

struct KimGaHyunBestListView: View {
let items: [ContentModel]

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ 아 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

Comment on lines +25 to +46
VStack(spacing: 10) {
Image(uiImage: item.thumbnail)
.resizable()
.frame(width: 160, height: 80)
HStack(alignment: .top) {
Image("number\(offset + 1)")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 23)
VStack(alignment: .leading) {
Text(item.title)
.foregroundStyle(.white)
Text(item.description)
.foregroundStyle(.gray)
.font(.caption)
Text("\(item.rating)%")
.foregroundStyle(.gray)
.font(.caption)
}
}
}
.frame(maxWidth: 160)

Choose a reason for hiding this comment

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

저도 뎁스가 깊어지는 것 같아서 따로 Cell 등 ... 으로 분리하는 것도 좋아보여요 !
분리하지 않으신 이유는 저도 궁금합니다 ~ㅎㅎ

@Kwon-Seokki
Copy link
Collaborator Author

스유 장인 ㄷ ㄷ .. 승원이가 남겨준 부분에도 많이 공감이 됐어요 ! 코드 너무 깔끔하고 .. 멋지고 .. 많이 배워갑니다 ~~👍🏻

아래의 리뷰에는 코멘트가 안달리네요..ㅎㅎ
Cell의 경우 무조건 컴포넌트로 나누는 편인데 이번에 개인적으로 시간을 많이 할애하지 못했어요ㅠ 이부분은 시간이 나면은 빠르게 반영할 예정입니다.
좋은 리뷰 감사합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Week7] 7주차 과제

4 participants