7주차 과제#5
Open
sssthnnhee wants to merge 15 commits into
Open
Conversation
hemssy
approved these changes
Jun 1, 2026
|
|
||
| import SwiftUI | ||
|
|
||
| struct mainStack : View{ |
There was a problem hiding this comment.
여기 구조체 이름이 소문자 시작인데 다른파일은 대문자시작이어서 여기도 대문자로 맞추면 좋을것같아요!!
|
|
||
| ScrollViewReader { startPoint in | ||
|
|
||
| ScrollView(.horizontal) { |
There was a problem hiding this comment.
저도 이번에 과제하면서 알았는데
ScrollView(.horizontal, showsIndicators: false) {
이렇게 속성붙이면 가로스크롤할때 나오는 인디케이터가 숨겨져용
|
|
||
| extension PosterModel { | ||
| static let mPosters: [PosterModel] = [ | ||
| PosterModel(id: 0, posterImage: .t1), |
There was a problem hiding this comment.
여기
struct PosterModel: Identifiable {
let id = UUID()
let posterImage: ImageResource
}이렇게 uuid 쓰면 더 깔끔할것같아요~
|
|
||
| struct SubscribeTabView: View { | ||
|
|
||
| var body: some View { |
There was a problem hiding this comment.
여기 body가 조금 긴것같은데
private var headerView: some View
private var newContentSection: some View
private var watgorythmSection: some View
private var upcomingSection: some View
private var partySection: some View이렇게 나누면 더 깔끔해질것같아요!! 개인적인 생각입니닷
gleamminn
approved these changes
Jun 2, 2026
| .font(.head2) | ||
| .foregroundStyle(.WATCHA_WHITE) | ||
|
|
||
| Image("mandoo") |
|
|
||
| extension PosterModel { | ||
| static let mPosters: [PosterModel] = [ | ||
| PosterModel(id: 0, posterImage: .t1), |
| import SwiftUI | ||
|
|
||
| struct PosterModel: Identifiable { | ||
| let id: Int |
Comment on lines
+29
to
+30
| .onAppear { | ||
| startPoint.scrollTo(1, anchor: .center) |
Comment on lines
+101
to
+109
| VStack(alignment: .leading) { Text("오늘 22:02에 시작") | ||
| .font(.body1) | ||
| .foregroundStyle(.WATCHA_PINK) | ||
| .padding(.bottom,6) | ||
|
|
||
| Text("#왕가사는남자") | ||
| .font(.subhead3) | ||
| .foregroundStyle(.WATCHA_WHITE)} | ||
| Spacer() |
|
|
||
| Spacer() | ||
|
|
||
| Image("Video") |
Comment on lines
+61
to
+75
| HStack{ | ||
|
|
||
| VStack(alignment: .leading) { | ||
|
|
||
| Text("방금 막 도착한 신상 컨텐츠") | ||
| .font(.head3) | ||
| .foregroundStyle(.WATCHA_WHITE) | ||
|
|
||
| Text("예능부터 드라마까지!") | ||
| .font(.subhead1) | ||
| .foregroundStyle(.GRAY_200) | ||
| } | ||
| Spacer() | ||
| } | ||
| .padding(.leading, 24) |
Comment on lines
+85
to
+87
| #Preview { | ||
| NavigationBarView() | ||
| } |
| var body: some Scene { | ||
| WindowGroup { | ||
| NavigationStack { | ||
| WelcomeView(nickname: "승희") |
Comment on lines
+16
to
+18
| private var displayName: String { | ||
| nickname ?? "익명의 사용자" | ||
| } |
dearosmar
approved these changes
Jun 2, 2026
| selectedView | ||
| .padding(.bottom, 99) | ||
|
|
||
| customNavigationBar |
| private var selectedView: some View { | ||
|
|
||
| Group { | ||
| if selectedIndex == 0 { |
| .scaledToFit() | ||
| .frame(width: 100, height: 100) | ||
|
|
||
| Text(" . . 텅 ~") |
| struct posterStack : View { | ||
|
|
||
| var body: some View { | ||
|
|
| HStack { | ||
| Text("구독") | ||
| .font(.head1) | ||
| .foregroundStyle(.WATCHA_WHITE) |
There was a problem hiding this comment.
보통 에셋 파일 컬러는 lowercamelcase로 주는 것 같습니다!
| @State private var isShowingMainView = false | ||
|
|
||
| private var displayName: String { | ||
| nickname ?? "익명의 사용자" |
| } | ||
| } | ||
|
|
||
| #Preview { |
|
|
||
| import SwiftUI | ||
|
|
||
| struct mainStack : View{ |
There was a problem hiding this comment.
stack들이 위치만 다르고 구조가 거의 비슷해서 파라미터로 받아 주는 것도 좋을 것 같아요
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 7주차 과제
📄 작업 내용
✅ 기본과제
✅ 심화과제
💻 주요 코드 설명 및 Trouble Shooting 🚀
1.
WelcomeView에서 메인 뷰로 넘어가는 네비게이션위와 같이 메인뷰(NavigationBarView)로 향하는 코드를 작성하였다.
@State 로 isShowingMainView 라는 값을 감시하고, 버튼을 눌르면 이 값이 true가 되어 NavigationBarView로 이동한다
해당 코드들은 전부 NavigationStack 내부에 있어야하므로
앱의 시작점에서 시작뷰를 네비게이션스택으로 감쌌다
여기에 써주는 게 더 마음에 들었다
근데 안 좋은것이라면 고치겠습니다 ! (네비게이션 이동을 사용하는 뷰에 적는 것이 좋다든가)
2.
NavigationBarView커스텀 탭바최근에 enum과 case를 좀 많이 봐서 그걸 이용해 작성해볼까 하는 생각도 들었지만,
기존에 내가 작성했던 코드가 배열 기반이고, 이번 과제는 마이그레이션... 느낌이라고 생각해서 그대로 그 방식을 가져왔다
이전에도 탭바를 커스텀하여 사용했었는데, 그때는 UIKit가 제공하는 UITabBarController 를 상속받는 것으로 버튼의 상태를 관리했다.
그러나 SwiftUI에는 !!! 상태 관리를 해주는 @State가 떡하니 있으니!!!!! 얘가 바뀔때마다 화면을 새로 그려주니!!
딱히 뭘 상속받지 않고도 훨씬 쉽게 만들 수 있을 것 같았다.
끝..
선택된 인덱스를 감시하고, 그에 따라 보여줄 뷰를 연결해줬다
저 Group 이라는 건 레이아웃에 영향을 주지않는 논리적 묶음 이라고 한다
처음에 Group 없이 작성하려고 햇는데 자꾸 에러가 나서 추가했다 ( 지피티가 각 분기를 서로 다른 타입의 뷰로 봐서? 생길수있는 에러라고 했다 )
그리고 이미지배열 (에셋 네이밍 여전히 nav라서 죄송합니다) 가져와서 탭바 모양 만들고 선택상태에 따라서 tint 처리 해주면 정말 끝
위 코드는 이미지 + Spacer()를 반복하는 코드에서 맨 마지막거엔 안 넣기 위한 코드인데
하드코딩 안하고 저렇게 해본것이 조금 뿌듯해서 적어봤습니다
3.
SubscribeTabView메인 뷰가로스크롤뷰에 스크롤 시작점을 지정하는 코드를 넣었다
ScrollView를 ScrollViewReader 로 감싸주고 .onAppear 를 통해 어떤 id의 요소를 어떻게 보여주고 싶은지 지정하면 된다
메인 포스터 스크롤뷰와 가로 포스터 스크롤뷰가 2번째것이 가운데에 와있는것 같아서 설정해두었다.
지금은 몇 개 없어서 그냥 모델에 identifiable 을 채택하고 id를 그냥 Int로 줬는데
나중에 데이터가 많아지면 UUID로 아이디를 만들고 scrollTo에
PosterModel.mPosters[1].id라고 주면 좋을 것 같다위 가로스크롤뷰는 따로
SubscribeTabScrollView파일에 분리해두었는데,시간이 부족하여 헤더는 컴포넌트화 하지 못했다
그치만,
덕분에 더 크게 느낄 수 있었다...
swiftUI는 정말 코드를 1/2 수준으로 줄여서 작성할 수 있구나.. 정말 편하구나
중복된 코드를 적어도 그렇게 길어지지 않고... 생각하는대로 코드를 적어도 어느 정도 구현이 되고,
프리뷰를 통해 바로바로 화면을 확인할 수 있고... 만약 이번 과제가 UIKit였으면 절대 시간안에 못했을 것 같다
👀 To Reviewers
스유를 아랑하게 된 나는 모든 것을 받아들일 준비가 되었소