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

[feat] SwiftUI로 UI짜기 기본편 #11

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

mmaybei
Copy link
Collaborator

@mmaybei mmaybei commented Nov 29, 2024

🔥Pull requests

⛳️ 작업한 브랜치: feat/#10-week06

📟 관련 이슈: #10

👷 작업한 내용

  • 인기차트 뷰를 SwiftUI로 리팩토링했습니다!

💻 주요 코드

let popularChartView = PopularChartView()
let hostingController = UIHostingController(rootView: popularChartView)
self?.navigationController?.pushViewController(hostingController, animated: true)

SwiftUI로 구현된 뷰를 hostingController를 통해 연결해주었습니다!
요 경우 UINavigationController가 UIHostingController를 관리하기 때문에 addChild를 하지 않았지만, 뷰 컨트롤러 간에 부모-자식 관계를 명시적으로 설정해야 하는 상황(예를 들면 뷰 컨트롤러를 서브뷰로 추가할 때)이라면 addChild를 명시해줘야 할 것 같습니다!

📸 스크린샷

기능 스크린샷
인기차트

🚨 참고 사항

  • 스유 첨 써봐요! ㅋㅋ 어떤 피드백이든 모두 감사합니다!
  • 제가 얼마 전에 렛츠스위프트를 다녀 와서 UIKit 베이스 프로젝트에 SwiftUI를 도입하는 것에 대한 세션을 인상깊게 들었는데용. 관련 레포를 함께 첨부합니다! 다들 도움이 되면 좋겠어요오

Copy link
Member

@sozohoy sozohoy 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 +104 to +117
var downloadButtonFont: Font {
switch popularApp.downloadState {
case .paid(_):
return .system(size: 14, weight: .bold)
default:
return .system(size: 16, weight: .bold)
}
}

func formatPrice(_ price: Int) -> String {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
return formatter.string(from: NSNumber(value: price)) ?? "\(price)"
}
Copy link
Member

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
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants