1
1
//
2
2
// MyPageView.swift
3
- // EatSSU-iOS
3
+ // EATSSU
4
4
//
5
- // Created by 최지우 on 2023/07 /25.
5
+ // Edited by Jiwoong CHOI on 1/31 /25.
6
6
//
7
7
8
8
import UIKit
@@ -12,79 +12,82 @@ import EATSSUDesign
12
12
import SnapKit
13
13
import Then
14
14
15
+ /// `MyPageView`
16
+ ///
17
+ /// 사용자 마이페이지 화면의 UI를 담당하는 뷰입니다.
18
+ /// - 사용자 프로필 이미지, 닉네임, 계정 정보 등을 표시합니다.
19
+ /// - 앱 버전 정보 및 회원 탈퇴 기능을 제공합니다.
20
+ ///
15
21
final class MyPageView : BaseUIView {
16
22
// MARK: - UI Components
17
23
18
- /// MyPageView 전체 스크롤뷰
19
- private let scrollView = UIScrollView ( )
24
+ /// **마이페이지 전체를 감싸는 스크롤 뷰**
25
+ let scrollView = UIScrollView ( )
20
26
21
- /// 스크롤뷰 안에 들어갈 콘텐츠 뷰
22
- private let contentView = UIView ( )
27
+ /// **스크롤 뷰 내부 콘텐츠 뷰**
28
+ let contentView = UIView ( )
23
29
24
- // 사용자 이미지
25
- var userImage = UIImageView ( ) . then {
30
+ /// ** 사용자 프로필 이미지**
31
+ let userImage = UIImageView ( ) . then {
26
32
$0. image = EATSSUDesignAsset . Images. profile. image
27
33
}
28
34
29
- // 닉네임이 들어간 닉네임 변경 버튼
30
- var userNicknameButton = UIButton ( ) . then {
31
- $0. addTitleAttribute (
32
- title: " 다시 시도해주세요 " ,
33
- titleColor: . black,
34
- fontName: EATSSUDesignFontFamily . Pretendard. regular. font ( size: 16 )
35
- )
35
+ /// **사용자 닉네임 라벨**
36
+ let userNicknameLabel = UILabel ( ) . then {
37
+ $0. text = " 다시 시도해주세요 "
38
+ $0. font = EATSSUDesignFontFamily . Pretendard. regular. font ( size: 16 )
36
39
}
37
40
38
- // "연결된 계정" 레이블
41
+ /// ** "연결된 계정" 라벨**
39
42
let accountTitleLabel = UILabel ( ) . then {
40
43
$0. text = ESTextLiteral . MyPage. linkedAccount
41
44
$0. font = EATSSUDesignFontFamily . Pretendard. regular. font ( size: 14 )
42
45
}
43
46
44
- // 서버에서 계정 정보를 가져오기 전 기본값
45
- var accountTypeLabel = UILabel ( ) . then {
47
+ /// **소셜 로그인 계정 유형 라벨 (초기값: "없음")**
48
+ let accountTypeLabel = UILabel ( ) . then {
46
49
$0. text = " 없음 "
47
50
$0. font = EATSSUDesignFontFamily . Pretendard. regular. font ( size: 14 )
48
- $0. font = . bold( size: 14 )
49
51
}
50
52
51
- // 소셜 로그인 공급업체 아이콘
52
- var accountTypeImage = UIImageView ( )
53
+ /// ** 소셜 로그인 공급업체 아이콘**
54
+ let accountTypeImage = UIImageView ( )
53
55
54
- lazy var totalAccountStackView = UIStackView (
55
- arrangedSubviews: [ accountTitleLabel , accountStackView ] ) . then {
56
+ /// **"연결된 계정" 라벨과 계정 정보를 포함하는 수직 스택 뷰**
57
+ lazy var accountStackView = UIStackView ( arrangedSubviews: [ accountTypeLabel , accountTypeImage ] ) . then {
56
58
$0. alignment = . bottom
57
59
$0. axis = . horizontal
58
- $0. spacing = 20
60
+ $0. spacing = 5
59
61
}
60
62
61
- lazy var accountStackView = UIStackView (
62
- arrangedSubviews: [ accountTypeLabel , accountTypeImage ] ) . then {
63
+ /// **"연결된 계정" 제목과 계정 정보를 포함하는 수평 스택 뷰**
64
+ lazy var totalAccountStackView = UIStackView ( arrangedSubviews: [ accountTitleLabel , accountStackView ] ) . then {
63
65
$0. alignment = . bottom
64
66
$0. axis = . horizontal
65
- $0. spacing = 5
67
+ $0. spacing = 20
66
68
}
67
69
70
+ /// **마이페이지 목록 테이블 뷰**
68
71
let myPageTableView = UITableView ( ) . then {
69
72
$0. separatorStyle = . none
70
73
$0. isScrollEnabled = false
71
74
}
72
75
73
- // " 앱 버전" 레이블
74
- private let appVersionStringLabel = UILabel ( ) . then { label in
75
- label . text = ESTextLiteral . MyPage. appVersion
76
- label . font = EATSSUDesignFontFamily . Pretendard. regular. font ( size: 12 )
77
- label . textColor = EATSSUDesignAsset . Color. GrayScale. gray400. color
76
+ /// ** 앱 버전 정보 라벨**
77
+ let appVersionStringLabel = UILabel ( ) . then {
78
+ $0 . text = ESTextLiteral . MyPage. appVersion
79
+ $0 . font = EATSSUDesignFontFamily . Pretendard. regular. font ( size: 12 )
80
+ $0 . textColor = EATSSUDesignAsset . Color. GrayScale. gray400. color
78
81
}
79
82
80
- // 현재 배포된 앱의 버전
81
- private let appVersionLabel = UILabel ( ) . then { label in
82
- label . text = MyPageRightItemData . version
83
- label . font = EATSSUDesignFontFamily . Pretendard. regular. font ( size: 12 )
84
- label . textColor = EATSSUDesignAsset . Color. GrayScale. gray400. color
83
+ /// ** 현재 앱 버전 표시 라벨**
84
+ let appVersionLabel = UILabel ( ) . then {
85
+ $0 . text = MyPageRightItemData . version
86
+ $0 . font = EATSSUDesignFontFamily . Pretendard. regular. font ( size: 12 )
87
+ $0 . textColor = EATSSUDesignAsset . Color. GrayScale. gray400. color
85
88
}
86
89
87
- /// "탈퇴하기" 레이블과 탈퇴하기 아이콘
90
+ /// **회원 탈퇴 버튼 ( 아이콘 포함)**
88
91
let userWithdrawButton : UIButton = {
89
92
let button = UIButton ( )
90
93
button. setTitle ( ESTextLiteral . MyPage. withdraw, for: . normal)
@@ -95,30 +98,30 @@ final class MyPageView: BaseUIView {
95
98
return button
96
99
} ( )
97
100
98
- /// "탈퇴하기" 레이블 underline
99
- private let underLineView : UIView = {
101
+ /// **회원 탈퇴 버튼 아래에 표시되는 언더라인 뷰**
102
+ let underLineView : UIView = {
100
103
let view = UIView ( )
101
104
view. backgroundColor = EATSSUDesignAsset . Color. GrayScale. gray400. color
102
105
return view
103
106
} ( )
104
107
105
- // MARK: - Intializer
108
+ // MARK: - Initializer
106
109
107
110
override init ( frame: CGRect ) {
108
111
super. init ( frame: frame)
109
-
110
112
registerTableViewCells ( )
111
113
}
112
114
113
- // MARK: - Functions
115
+ // MARK: - UI 설정
114
116
117
+ /// UI 구성 요소를 화면에 추가합니다.
115
118
override func configureUI( ) {
116
119
addSubview ( scrollView)
117
120
scrollView. addSubview ( contentView)
118
121
119
122
contentView. addSubviews (
120
123
userImage,
121
- userNicknameButton ,
124
+ userNicknameLabel ,
122
125
totalAccountStackView,
123
126
myPageTableView,
124
127
appVersionStringLabel,
@@ -128,6 +131,7 @@ final class MyPageView: BaseUIView {
128
131
)
129
132
}
130
133
134
+ /// UI 레이아웃을 설정합니다.
131
135
override func setLayout( ) {
132
136
scrollView. snp. makeConstraints {
133
137
$0. edges. equalToSuperview ( )
@@ -144,15 +148,15 @@ final class MyPageView: BaseUIView {
144
148
$0. height. width. equalTo ( 100 )
145
149
}
146
150
147
- userNicknameButton . snp. makeConstraints {
151
+ userNicknameLabel . snp. makeConstraints {
148
152
$0. top. equalTo ( userImage. snp. bottom) . offset ( 6 )
149
153
$0. centerX. equalTo ( userImage)
150
154
$0. height. equalTo ( 40 )
151
155
}
152
156
153
157
totalAccountStackView. snp. makeConstraints {
154
158
$0. centerX. equalToSuperview ( )
155
- $0. top. equalTo ( userNicknameButton . snp. bottom) . offset ( 10 )
159
+ $0. top. equalTo ( userNicknameLabel . snp. bottom) . offset ( 10 )
156
160
}
157
161
158
162
myPageTableView. snp. makeConstraints {
@@ -162,21 +166,20 @@ final class MyPageView: BaseUIView {
162
166
$0. width. equalToSuperview ( )
163
167
}
164
168
165
- appVersionStringLabel. snp. makeConstraints { make in
166
- make . top. equalTo ( myPageTableView. snp. bottom) . offset ( 6 )
167
- make . leading. equalToSuperview ( ) . inset ( 24 )
169
+ appVersionStringLabel. snp. makeConstraints {
170
+ $0 . top. equalTo ( myPageTableView. snp. bottom) . offset ( 6 )
171
+ $0 . leading. equalToSuperview ( ) . inset ( 24 )
168
172
}
169
173
170
- appVersionLabel. snp. makeConstraints { make in
171
- make . top. equalTo ( myPageTableView. snp. bottom) . offset ( 6 )
172
- make . trailing. equalToSuperview ( ) . inset ( 24 )
174
+ appVersionLabel. snp. makeConstraints {
175
+ $0 . top. equalTo ( myPageTableView. snp. bottom) . offset ( 6 )
176
+ $0 . trailing. equalToSuperview ( ) . inset ( 24 )
173
177
}
174
178
175
- // TODO: withdrawStackView를 프로퍼티로 선언할 때, lazy를 사용하면 레이아웃이 한 타임 늦게 잡히는 문제로 인해서 여기에서 스택 안에 들어갈 뷰를 추가함. 개선 방법이 없는지 확인.
176
- userWithdrawButton. snp. makeConstraints { make in
177
- make. top. equalTo ( appVersionLabel. snp. bottom) . offset ( 16 )
178
- make. trailing. equalToSuperview ( ) . inset ( 24 )
179
- make. bottom. equalToSuperview ( ) . inset ( 70 )
179
+ userWithdrawButton. snp. makeConstraints {
180
+ $0. top. equalTo ( appVersionLabel. snp. bottom) . offset ( 16 )
181
+ $0. trailing. equalToSuperview ( ) . inset ( 24 )
182
+ $0. bottom. equalToSuperview ( ) . inset ( 70 )
180
183
}
181
184
182
185
underLineView. snp. makeConstraints {
@@ -186,23 +189,21 @@ final class MyPageView: BaseUIView {
186
189
}
187
190
}
188
191
189
- private func registerTableViewCells( ) {
190
- myPageTableView. register (
191
- MyPageTableDefaultCell . self,
192
- forCellReuseIdentifier: MyPageTableDefaultCell . identifier
193
- )
194
- myPageTableView. register (
195
- NotificationSettingTableViewCell . self,
196
- forCellReuseIdentifier: NotificationSettingTableViewCell . identifier
197
- )
192
+ // MARK: - 기능
193
+
194
+ /// 마이페이지 테이블 뷰의 셀을 등록합니다.
195
+ func registerTableViewCells( ) {
196
+ myPageTableView. register ( MyPageTableDefaultCell . self, forCellReuseIdentifier: MyPageTableDefaultCell . identifier)
197
+ myPageTableView. register ( NotificationSettingTableViewCell . self, forCellReuseIdentifier: NotificationSettingTableViewCell . identifier)
198
198
}
199
199
200
- public func setUserInfo( nickname: String ) {
201
- userNicknameButton. addTitleAttribute (
202
- title: " \( nickname) > " ,
203
- titleColor: . black,
204
- fontName: . semiBold( size: 20 )
205
- )
200
+ /// 사용자 정보를 설정합니다.
201
+ ///
202
+ /// - Parameter nickname: 사용자 닉네임
203
+ func setUserInfo( nickname: String ) {
204
+ userNicknameLabel. text = nickname
205
+ userNicknameLabel. font = EATSSUDesignFontFamily . Pretendard. semiBold. font ( size: 20 )
206
+
206
207
if let accountType = UserInfoManager . shared. getCurrentUserInfo ( ) ? . accountType {
207
208
switch accountType {
208
209
case . apple:
0 commit comments