Skip to content

한주헌) Lv.7 구현 완료 (26.01.29 21:13 수정)#5

Open
TyrHanz wants to merge 15 commits into
Han_Mainfrom
Han_Develop
Open

한주헌) Lv.7 구현 완료 (26.01.29 21:13 수정)#5
TyrHanz wants to merge 15 commits into
Han_Mainfrom
Han_Develop

Conversation

@TyrHanz

@TyrHanz TyrHanz commented Jan 27, 2026

Copy link
Copy Markdown
Collaborator

디자인 코드를 직접 짜는게 아직 어색해서 가시성이 많이 안좋습니다..

구현 중 하나 이슈사항이 있습니다.
책 상세뷰어를 스택뷰로 구현해야했는데 문제를 자세히 분석하지않아 UIView에 디자인을 배치하여 구현 하였습니다.
추후 해당 부분은 수정하여 구현하겠습니다.

- 해리포터 정보  모델 생성
- Lv 1 뷰 구현
- 해리포터 이미지 추가
- 해리포터 Json 파일 추가
- lv.2 구현 완료 (경고 알람, 책 상세정보 뷰)
- 주석 작성
- Lv.3 구현
- Lv.2 누락된 날짜 포멧 변경 기능 구현
- Lv.4 구현(챕터 레이블 및 스크롤 뷰)
- 주석 추가 작성
Comment on lines +321 to +338
switch series {
case 1:
imageInfoImage.image = .harrypotter1
case 2:
imageInfoImage.image = .harrypotter2
case 3:
imageInfoImage.image = .harrypotter3
case 4:
imageInfoImage.image = .harrypotter4
case 5:
imageInfoImage.image = .harrypotter5
case 6:
imageInfoImage.image = .harrypotter6
case 7:
imageInfoImage.image = .harrypotter7
default:
imageInfoImage.image = .none
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

switch문 대신 매개변수로 받는 series를 사용해보시는건 어떨까요 ?
imageInfoImage.image = UIImage(named:)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

말씀해주신대로 바꿔보니 한줄로 코드가 끝나네요!
거기 다 책이 많아지면 case 도 추가로 작성해야하니 그것도 빡세네요 ㅎ

Comment on lines +220 to +225
buttonBookCount.snp.makeConstraints{
$0.top.equalTo(labelHeader.snp.bottom).offset(16)
$0.centerX.equalToSuperview()
$0.leading.greaterThanOrEqualToSuperview().offset(20)
$0.trailing.lessThanOrEqualToSuperview().inset(20)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

버튼의 가로 세로 길이를 맞춰주는 속성이 추가되면 원이 더 예쁘게 보일 것 같습니다.

Copy link
Copy Markdown
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 +149 to +158
let stackDedication = UIStackView()
stackDedication.axis = .vertical
stackDedication.alignment = .top
stackDedication.spacing = 8

// 개요 스텍뷰
let stackSummary = UIStackView()
stackSummary.axis = .vertical
stackSummary.alignment = .top
stackSummary.spacing = 8

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

속성 정의가 같다면 묶어서 한번에 처리해보는 방법을 적용해보면 좋을 것 같습니다.
[].forEach

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

간이 배열로 담아서 쓸수있다는 걸 처음알았네요.. 감사합니다!

- lv.5 구현 완료
- 개요 전용 뷰 생성
- 피드백 받은 코드 리펙토링 진행
@TyrHanz TyrHanz changed the title 한주헌) Lv.2 구현 완료 한주헌) Lv.5 구현 완료 (26.01.29 15:48 수정) Jan 29, 2026
@Jaesung-Jung

Copy link
Copy Markdown

네이밍 조금만 고쳐봅시다.

[파일명]

ModelBook.swift -> Book.swift
ServiceJsonData -> DataService.swift
  • 파일이름은 그 클래스 또는 타입과 동일하게

[파일명 및 클래스명]

ViewSummary -> SummaryView
  • 네이밍만으로는 해당 타입이 View 자체를 표현하는 클래스인지, View와 관련된 데이터를 나타내는 타입인지 구분하기 어렵습니다
  • UIKit 관례에 맞추어 View는 ~View 접미사를 사용하도록 SummaryView로 바꾸면 좋을 것 같아요

Comment on lines +297 to +304
imageInfoImage.image = UIImage(named: "harrypotter\(series)")
labelHeader.text = bookData[series-1].title
labelInfoHeader.text = bookData[series-1].title
labelInfoAuthor.text = bookData[series-1].author
labelInfoRelesed.text = convertDateText(bookData[series-1].release_date)
labelInfoPages.text = "\(bookData[series-1].pages)"
labelInfoDedication.text = bookData[series-1].dedication
viewInfoSummry.setLabelText(bookData[series-1].summary)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

series라는 offset을 전달받지 말고 Book 타입을 받아서 쓰면 더 좋을 것 같습니다.
series - 1이라는 연산이 반복되어서 들어가고, -1 연산을 안넣는 실수하기에도 딱 좋은!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

감사합니다! Book타입으로 전달받아서 출력하는 형식으로 바꿔보겠습니다!

- lv,6 lv,7 구현
- 리펙토링 진행 (파일명 변경, 반복코드 수정, 챕터 Label 생성 로직 수정)
- 주석 추가
@TyrHanz TyrHanz changed the title 한주헌) Lv.5 구현 완료 (26.01.29 15:48 수정) 한주헌) Lv.7 구현 완료 (26.01.29 21:13 수정) Jan 29, 2026
- 메인 뷰 컨트롤러 기능 분할 (ViewControlller ->  MainView - MainViewController)
- 코드컨밴션에 맞게 코드 정리 진행

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

loadBooks에서 비동기 작업이 일어나는 게 아니니 클로저 없이도 사용가능할 것으로 생각됩니다..!

클로저가 없으면 사용부에서 dataService.loadBooks를 호출하면 결과로 (Result<[Book], Error>)가 바로 나올 것 같은데, 클로저를 사용하지 않아도 함수 내부에서 바로 처리할 수 있지 않을까요?

func loadBooks() {
    let result = dataService.loadBooks

    switch result {
    case .success(let books):
    case .failure(let error):
    }
}

- MVC 패턴에 맞게 뷰에 선언된 데이터들 뷰컨트롤러로 이관 및 기능 수정
- 클로져를 통한 버튼 이벤트 추가
- 기능별 분리 및 주석 추가
- 개요 및 메인 버튼 이벤트 관련 클로저 설정코드에서 강한 참조가 발생하는 이슈 해결
- 전반적인 코드컨벤션이 지켜지지 않는 코드 수정
- 앱 맨 처음 실행 시 개요 버튼이 더보기로 설정되는 이슈 수정
- 모델에 선언된 값들 중 수정되지 않는 파라미터들 상수로 변경
- 스크롤뷰 하단 잘리는 이슈 및 스크롤 위치 이슈 수정
- ViewController에서 View 할당 시, ViewDidLoad가 아닌 loadView에서 진행하게 변경
- 버튼명 변경
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.

4 participants