Skip to content

feat: Base 뷰 구현 (#14)#15

Merged
rafa-e1 merged 2 commits intodevelopfrom
feat/#14
Jun 8, 2025
Merged

feat: Base 뷰 구현 (#14)#15
rafa-e1 merged 2 commits intodevelopfrom
feat/#14

Conversation

@rafa-e1
Copy link
Contributor

@rafa-e1 rafa-e1 commented Jun 8, 2025

🚀 Pull Request

No merge conflict? Where’s the fun in that.


📌 요약

  • SnapKit과 Then 설치
  • BaseViewController 구현 및 각 뷰 컨트롤러에 채택

📄 상세 설명

  • SnapKit: 오토레이아웃을 코드로 간결하게 작성하기 위해
  • Then: 초기화 및 설정을 체이닝 스타일로 간결하게 작성하기 위해
  • 중복 코드 제거, 공통 기능의 재사용, 일관된 아키텍처 구성, 그리고 유지보수성을 높이기 위해

🔗 관련 이슈 (Issue)


✅ PR Check List

  • Merge 대상 브랜치가 올바른가?
  • 최종 코드가 에러 없이 잘 동작하는가?
  • 전체 변경사항이 500줄을 넘지 않는가?

Summary by CodeRabbit

  • New Features
    • 공통 스타일, 레이아웃, 제약 조건 설정을 위한 BaseViewController가 추가되었습니다.
  • Refactor
    • 홈, 지도, 북마크, 프로필 화면이 BaseViewController를 상속하도록 구조가 개선되었습니다.
  • Chores
    • SnapKit 및 Then 라이브러리가 프로젝트에 추가되어 UI 구성과 코드 작성이 더 편리해졌습니다.

rafa-e1 added 2 commits June 8, 2025 14:39
- SnapKit: 오토레이아웃을 코드로 간결하게 작성하기 위해
- Then:  초기화 및 설정을 체이닝 스타일로 간결하게 작성하기 위해
@rafa-e1 rafa-e1 requested a review from alstjr7437 June 8, 2025 06:03
@rafa-e1 rafa-e1 self-assigned this Jun 8, 2025
@rafa-e1 rafa-e1 added the ✨ Feature 기능 구현 label Jun 8, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 8, 2025

Walkthrough

공통 기능 재사용과 중복 코드 제거를 위해 BaseViewController가 새로 도입되었습니다. 기존의 여러 ViewController들은 BaseViewController를 상속하도록 변경되었고, 스타일 및 레이아웃 설정 책임이 BaseViewController로 이전되었습니다. SnapKit, Then 라이브러리 의존성도 추가되었습니다.

Changes

파일/경로 그룹 변경 요약
MatzipBook/MatzipBook/Presentation/Common/Base/BaseViewController.swift BaseViewController 클래스 신규 추가, 스타일/레이아웃/제약 설정 메서드 포함
.../Bookmark/BookmarkViewController.swift
.../Home/HomeViewController.swift
.../Map/MapViewController.swift
.../Profile/ProfileViewController.swift
각 ViewController가 UIViewController → BaseViewController 상속으로 변경, viewDidLoad 및 배경색 설정 제거
MatzipBook/Podfile SnapKit, Then 라이브러리 의존성 추가
MatzipBook/MatzipBook.xcodeproj/project.pbxproj CocoaPods 프레임워크 임베드 빌드 단계 추가

Sequence Diagram(s)

sequenceDiagram
    participant SubclassVC as (예: HomeViewController)
    participant BaseVC as BaseViewController
    participant UIKit as UIViewController

    SubclassVC->>BaseVC: viewDidLoad()
    BaseVC->>UIKit: super.viewDidLoad()
    BaseVC->>BaseVC: setupStyles()
    BaseVC->>BaseVC: setupLayouts()
    BaseVC->>BaseVC: setupConstraints()
Loading

Assessment against linked issues

Objective (이슈 번호) Addressed Explanation
BaseViewController 구현 (#14)

Assessment against linked issues: Out-of-scope changes

Code Change (파일 및 라인) Explanation
SnapKit, Then 의존성 추가 (MatzipBook/Podfile) BaseViewController 구현과 직접적 관련은 없으며, 별도 명시된 요구사항이 아닙니다.
CocoaPods 빌드 단계 추가 (MatzipBook/MatzipBook.xcodeproj/project.pbxproj) BaseViewController 구현과 직접적 관련은 없으며, 별도 명시된 요구사항이 아닙니다.

Poem

🐇
새하얀 베이스 위에 꿈을 그려요,
중복된 코드는 이제 안녕,
SnapKit과 Then이 손을 잡고,
뷰의 세계가 더 넓어졌죠!
BaseViewController와 함께
깔끔한 아키텍처로
토끼도 신나게 뛰어놀아요!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
MatzipBook/Podfile (1)

8-9: 의존성 추가가 적절합니다.

SnapKit과 Then은 iOS 개발에서 널리 사용되는 신뢰할 수 있는 라이브러리입니다. BaseViewController 구현에 필요한 Auto Layout DSL과 체이닝 초기화 기능을 제공합니다.

특정 버전을 고정하는 것을 고려해보세요:

- pod 'SnapKit'
- pod 'Then'
+ pod 'SnapKit', '~> 5.7.0'
+ pod 'Then', '~> 3.0.0'
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ffc72b and 80c77f8.

⛔ Files ignored due to path filters (1)
  • MatzipBook/Podfile.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • MatzipBook/MatzipBook.xcodeproj/project.pbxproj (2 hunks)
  • MatzipBook/MatzipBook/Presentation/Bookmark/BookmarkViewController.swift (1 hunks)
  • MatzipBook/MatzipBook/Presentation/Common/Base/BaseViewController.swift (1 hunks)
  • MatzipBook/MatzipBook/Presentation/Home/HomeViewController.swift (1 hunks)
  • MatzipBook/MatzipBook/Presentation/Map/MapViewController.swift (1 hunks)
  • MatzipBook/MatzipBook/Presentation/Profile/ProfileViewController.swift (1 hunks)
  • MatzipBook/Podfile (1 hunks)
🔇 Additional comments (8)
MatzipBook/MatzipBook/Presentation/Map/MapViewController.swift (1)

10-10:

Details

❓ Verification inconclusive

BaseViewController 상속으로의 리팩토링이 훌륭합니다.

공통 기능을 BaseViewController로 중앙화하는 접근법이 코드 중복을 줄이고 일관성을 높입니다.

BaseViewController가 올바르게 구현되었는지 확인해보겠습니다:


🏁 Script executed:

#!/bin/bash
# BaseViewController 구현 확인
fd -t f -e swift BaseViewController

# BaseViewController의 구현 내용 확인
ast-grep --pattern 'class BaseViewController: UIViewController {
  $$$
}'

Length of output: 185


BaseViewController 구현 내용 확인을 위해 파일 내용을 출력하고 viewDidLoad 오버라이드 여부를 검사해보겠습니다.


🏁 Script executed:

#!/bin/bash
# BaseViewController.swift 내용 출력 (상위 200줄)
sed -n '1,200p' MatzipBook/MatzipBook/Presentation/Common/Base/BaseViewController.swift

# viewDidLoad 오버라이드 존재 여부 확인
grep -R "override func viewDidLoad" -n MatzipBook/MatzipBook/Presentation/Common/Base/BaseViewController.swift

Length of output: 1750


BaseViewController viewDidLoad 오버라이드 및 setup 메서드 구현 확인됨

  • BaseViewController.swift (15번째 줄)에 override func viewDidLoad() 가 정의되어 있으며
  • setupStyles(), setupLayouts(), setupConstraints() 가 모두 구현되어 있습니다

위 구현으로 공통 기능이 정상 작동하므로 리팩토링 방향은 적절합니다.
MapViewController가 BaseViewController의 기본 동작만 사용하는 것이 의도된 것인지 최종 확인 부탁드립니다.

MatzipBook/MatzipBook/Presentation/Home/HomeViewController.swift (1)

10-10: 일관된 리팩토링 패턴이 잘 적용되었습니다.

BaseViewController 상속과 final 키워드 사용이 적절합니다. 향후 HomeViewController에 고유한 기능이 필요하다면 setupStyles(), setupLayouts(), setupConstraints() 메서드를 오버라이드하여 확장할 수 있습니다.

MatzipBook/MatzipBook/Presentation/Profile/ProfileViewController.swift (1)

10-10: 전체 아키텍처 개선이 성공적으로 완료되었습니다.

모든 뷰 컨트롤러가 BaseViewController를 일관되게 상속하도록 리팩토링되어, 코드 중복 제거와 유지보수성 향상이 달성되었습니다. 이러한 구조는 향후 공통 기능 추가 시에도 유연하게 대응할 수 있습니다.

MatzipBook/MatzipBook/Presentation/Bookmark/BookmarkViewController.swift (1)

10-10: BaseViewController 상속 변경 승인

코드 중복을 제거하고 일관된 아키텍처를 구축하는 좋은 리팩토링입니다. BaseViewController에서 공통 설정 로직을 중앙화하여 maintainability가 향상되었습니다.

MatzipBook/MatzipBook.xcodeproj/project.pbxproj (1)

103-103: CocoaPods 프레임워크 임베딩 빌드 페이즈 추가 승인

SnapKit과 Then 라이브러리 추가에 따른 표준적인 CocoaPods 설정입니다. 프레임워크들이 앱 번들에 올바르게 임베딩되도록 보장합니다.

Also applies to: 182-202

MatzipBook/MatzipBook/Presentation/Common/Base/BaseViewController.swift (3)

15-21: viewDidLoad 구조 승인

설정을 세 단계(스타일 → 레이아웃 → 제약조건)로 나누는 체계적인 접근 방식이 우수합니다. 명확한 순서와 관심사 분리가 잘 되어 있습니다.


23-48: 한국어 문서화 품질 우수

메서드별 역할과 사용 예시가 명확하게 문서화되어 있어 개발자들이 올바르게 사용할 수 있도록 도움을 줍니다. SnapKit 사용 예시도 적절합니다.


35-35:

Details

✅ Verification successful

mainBackgroundColor 색상 정의 확인 필요

.mainBackgroundColor가 프로젝트에서 정의되어 있는지 확인이 필요합니다.


🏁 Script executed:

#!/bin/bash
# UIColor extension에서 mainBackgroundColor 정의 확인
rg -A 3 "mainBackgroundColor" --type swift

Length of output: 1300


확인 완료: mainBackgroundColor 정의됨
MatzipBook/Core/DesignSystem/Foundation/UIColor+.swift에서

static let mainBackgroundColor: UIColor = UIColor(hex: "FAFAFA")

로 정의되어 있어 별도 수정이 필요 없습니다.

Comment on lines +34 to +36
func setupStyles() {
view.backgroundColor = .mainBackgroundColor
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

설정 메서드들의 접근 제어자 개선 필요

하위 클래스에서 이 메서드들을 오버라이드할 수 있도록 open func으로 선언하는 것이 좋습니다.

-    func setupStyles() {
+    open func setupStyles() {
         view.backgroundColor = .mainBackgroundColor
     }
     
-    func setupLayouts() {}
+    open func setupLayouts() {}
     
-    func setupConstraints() {}
+    open func setupConstraints() {}

Also applies to: 49-49, 63-63

🤖 Prompt for AI Agents
In MatzipBook/MatzipBook/Presentation/Common/Base/BaseViewController.swift at
lines 34-36, 49, and 63, the setup methods should be declared as open functions
instead of default or internal to allow subclasses to override them. Change the
access control of these methods to `open func` to enable overriding in
subclasses.

import SnapKit
import Then

class BaseViewController: UIViewController {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

상속을 위한 접근 제어자 개선 필요

BaseViewController가 다른 모듈에서도 상속될 가능성을 고려하여 open class로 선언하는 것이 좋습니다.

-class BaseViewController: UIViewController {
+open class BaseViewController: UIViewController {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
class BaseViewController: UIViewController {
open class BaseViewController: UIViewController {
🤖 Prompt for AI Agents
In MatzipBook/MatzipBook/Presentation/Common/Base/BaseViewController.swift at
line 13, the BaseViewController class is declared as a default class, which
restricts inheritance outside the module. Change the class declaration from
'class' to 'open class' to allow other modules to inherit from
BaseViewController.

@rafa-e1 rafa-e1 merged commit 3c1c751 into develop Jun 8, 2025
2 checks passed
@rafa-e1 rafa-e1 deleted the feat/#14 branch June 8, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Feature 기능 구현

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Base 뷰 구현

2 participants