-
Notifications
You must be signed in to change notification settings - Fork 1
[Feat-T3-104] 마이페이지 UI 구현 #22
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3fcca13
Feat: 이미지 asset 추가 (#T3-104)
taipaise 154b422
Feat: NSObject extension 추가 (#T3-104)
taipaise 1021f0c
Feat: UserDataRepository 구현 (#T3-104)
taipaise a3f03b7
Feat: 마이페이지 화면 구현 (#T3-104)
taipaise 1ae7ba7
refactor: 코드 리뷰 반영
taipaise File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // | ||
| // UserError.swift | ||
| // DataSource | ||
| // | ||
| // Created by 이동현 on 7/20/25. | ||
| // | ||
|
|
||
| enum UserError: Error, CustomStringConvertible { | ||
| case accessTokenLoadFailed | ||
| case nicknameLoadFailed | ||
| case unknown(error: Error) | ||
|
|
||
|
|
||
| var description: String { | ||
| switch self { | ||
| case .accessTokenLoadFailed: | ||
| return "토큰 불러오기에 실패했습니다." | ||
| case .nicknameLoadFailed: | ||
| return "닉네임 불러오기에 실패했습니다." | ||
| case .unknown(let error): | ||
| return "알 수 없는 에러가 발생했습니다. \(error.localizedDescription)" | ||
| } | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
Projects/DataSource/Sources/Repository/UserDataRepository.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // | ||
| // UserDataRepository.swift | ||
| // DataSource | ||
| // | ||
| // Created by 이동현 on 7/20/25. | ||
| // | ||
|
|
||
| import Domain | ||
| import Foundation | ||
|
|
||
| final class UserDataRepository: UserDataRepositoryProtocol { | ||
| private let keychainStorage: KeychainStorageProtocol | ||
| private let userDefaultsStorage: UserDefaultsStorageProtocol | ||
|
|
||
| init(keychainStorage: KeychainStorageProtocol, userDefaultsStorage: UserDefaultsStorageProtocol) { | ||
| self.keychainStorage = keychainStorage | ||
| self.userDefaultsStorage = userDefaultsStorage | ||
| } | ||
|
|
||
| // TODO: - accessToken fetch 로직 상의 후 결정 | ||
| func loadAccessToken() throws -> String { | ||
| guard let token = keychainStorage.load(forKey: TokenType.accessToken.rawValue) else { | ||
| throw UserError.accessTokenLoadFailed | ||
| } | ||
|
|
||
| return token | ||
| } | ||
|
|
||
| func loadNickname() throws -> String { | ||
| guard let nickname: String = userDefaultsStorage.load(forKey: UserDefaultsKey.nickname.rawValue) else { | ||
| throw UserError.nicknameLoadFailed | ||
| } | ||
|
|
||
| return nickname | ||
| } | ||
| } | ||
|
|
17 changes: 17 additions & 0 deletions
17
Projects/Domain/Sources/Protocol/Repository/UserDataRepositoryProtocol.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // | ||
| // UserDataRepositoryProtocol.swift | ||
| // DataSource | ||
| // | ||
| // Created by 이동현 on 7/20/25. | ||
| // | ||
|
|
||
| /// 유저의 이름, 토큰 등 유저 정보와 관련된 데이터를 가져오는 Repository | ||
| public protocol UserDataRepositoryProtocol { | ||
| /// 저장한 accessToken을 가져옵니다. | ||
| /// - Returns: accessToken | ||
| func loadAccessToken() throws -> String | ||
|
|
||
| /// 저장한 닉네임을 가져옵니다. | ||
| /// - Returns: 유저 닉네임 | ||
| func loadNickname() throws -> String | ||
| } |
23 changes: 23 additions & 0 deletions
23
Projects/Presentation/Resources/Images.xcassets/chevron_right_icon.imageset/Contents.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "chevron_right_icon@1x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "chevron_right_icon@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "chevron_right_icon@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
Binary file added
BIN
+181 Bytes
...Resources/Images.xcassets/chevron_right_icon.imageset/chevron_right_icon@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+261 Bytes
...Resources/Images.xcassets/chevron_right_icon.imageset/chevron_right_icon@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+306 Bytes
...Resources/Images.xcassets/chevron_right_icon.imageset/chevron_right_icon@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
Projects/Presentation/Resources/Images.xcassets/setting_icon.imageset/Contents.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "images" : [ | ||
| { | ||
| "filename" : "setting_icon@1x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "1x" | ||
| }, | ||
| { | ||
| "filename" : "setting_icon@2x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "2x" | ||
| }, | ||
| { | ||
| "filename" : "setting_icon@3x.png", | ||
| "idiom" : "universal", | ||
| "scale" : "3x" | ||
| } | ||
| ], | ||
| "info" : { | ||
| "author" : "xcode", | ||
| "version" : 1 | ||
| } | ||
| } |
Binary file added
BIN
+724 Bytes
...resentation/Resources/Images.xcassets/setting_icon.imageset/setting_icon@1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.42 KB
...resentation/Resources/Images.xcassets/setting_icon.imageset/setting_icon@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.04 KB
...resentation/Resources/Images.xcassets/setting_icon.imageset/setting_icon@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
18 changes: 18 additions & 0 deletions
18
Projects/Presentation/Sources/Common/Extension/NSObject+.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // | ||
| // NSObject+.swift | ||
| // Presentation | ||
| // | ||
| // Created by 이동현 on 7/20/25. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| extension NSObject { | ||
| var className: String { | ||
| return String(describing: type(of: self)) | ||
| } | ||
|
|
||
| class var className: String { | ||
| return String(describing: self) | ||
| } | ||
| } | ||
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
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
58 changes: 58 additions & 0 deletions
58
Projects/Presentation/Sources/MyPage/View/Component/MypageTableViewCell.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // | ||
| // MyPageTableViewCell.swift | ||
| // Presentation | ||
| // | ||
| // Created by 이동현 on 7/17/25. | ||
| // | ||
|
|
||
| import SnapKit | ||
| import UIKit | ||
|
|
||
| final class MypageTableViewCell: UITableViewCell { | ||
| private enum Layout { | ||
| static let titleLableLeadingSpacing: CGFloat = 20 | ||
| static let titleLableTrailingSpacing: CGFloat = 8 | ||
| static let chevronImageViewTrailingSpacing: CGFloat = 6 | ||
| static let chevronImageViewSize: CGFloat = 36 | ||
| } | ||
|
|
||
| private let titleLabel = UILabel() | ||
| private let chevronImageView = UIImageView() | ||
|
|
||
| override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { | ||
| super.init(style: style, reuseIdentifier: reuseIdentifier) | ||
| configureAttribute() | ||
| configureLayout() | ||
| } | ||
|
|
||
| required init?(coder: NSCoder) { | ||
| fatalError("init(coder:) has not been implemented") | ||
| } | ||
|
|
||
| func configure(title: String) { | ||
| titleLabel.text = title | ||
| } | ||
|
|
||
| private func configureAttribute() { | ||
| titleLabel.font = BitnagilFont(style: .body1, weight: .regular).font | ||
|
|
||
| chevronImageView.image = BitnagilIcon.chevronRightIcon | ||
| } | ||
|
|
||
| private func configureLayout() { | ||
| contentView.addSubview(titleLabel) | ||
| contentView.addSubview(chevronImageView) | ||
|
|
||
| chevronImageView.snp.makeConstraints { make in | ||
| make.centerY.equalToSuperview() | ||
| make.trailing.equalToSuperview().inset(Layout.chevronImageViewTrailingSpacing) | ||
| make.size.equalTo(Layout.chevronImageViewSize) | ||
| } | ||
|
|
||
| titleLabel.snp.makeConstraints { make in | ||
| make.verticalEdges.equalToSuperview() | ||
| make.leading.equalToSuperview().offset(Layout.titleLableLeadingSpacing) | ||
| make.trailing.equalTo(chevronImageView.snp.leading).offset(-Layout.titleLableTrailingSpacing) | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요 className 너무너무 좋은 것 같아요 !!
테이블 뷰 셀 정의할 때 하드코딩 안하고 이렇게 하는 고지능적 개발 !!! 감사합니다.
다만 궁금한게
var className와class var className가 어떻게 다른지 알 수 있을까요 ??둘 다 사용해야만 className을 빼올 수 있는건가용 ??
제가 feat/myPage 브랜치에서 다음 부분을 주석처리해도 마이페이지가 잘 작동하는 것 같아 궁금해서 질문 남겨봅니다 !!!
추가적으로 이 extension이 public인 이유도 궁금합니다 !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우선 public일 필요는 전혀 없습니다!! 추가의 이뉴는 아시다시피 UIView가 NSObject의 서브 클래스이기 때문에 UIView 서브 클래스들의 클래스 면 사용을 편하게 하기 위해서 인데요!! 때문에 Presentation 모듈 밖에서 사용할 일이 없으니 떼는게 좋을거 같아요!! 진짜 꼼꼼하게 봐주셨군요 감사합니다!!!
두 변수의 차이점은 인스턴스 변수냐, 클래스 변수냐의 차이입니다.
var class의 경우, 인스턴스가 존재할 때 해당 인스턴스의 클래스 이름을 불러올 필요가 있을때 사용하시면 되구class var의 경우, 타입 자체의 이름을 String으로 불러올 때 사용하시면 좋을 것 같습니다!아직은 두 번째
class var만 사용하고 있지만, 정말 추후 혹시나 인스턴스의 클래스 이름을 String으로 빼오는 경우도 고려해서 한 번에 추가해 두었습니다!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
헐 ~ 바로 이해됩니다 .... 띵천재 띵고수 😎
많이 배워갑니다 ~~