Skip to content

Commit c46b96a

Browse files
authored
[NL-69] : merge 오류 해결 (#50)
* [NL-69] : profile 수정 * [NL-69] : 정보 수정 API 연결 * [NL-69] : PopUpComponent 생성 * [NL-69] : Popup 적용 * [NL-69] : 파일 이름 수정 * [NL-69] : Toas 구현 - Layout 문제 해결 * [NL-69] : 오류 해결 * [NL-69] : Modal 수정
1 parent 06139bc commit c46b96a

File tree

11 files changed

+52
-80
lines changed

11 files changed

+52
-80
lines changed

Common/Base/Sources/Model/UserDTO.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ public struct UserDTO: Decodable {
2020
public let birthDate: String?
2121
public let birthTime: [String]?
2222
public let gender: GenderDTO
23-
24-
public init(id: String, name: String, birthDate: String?, birthTime: [String]?, gender: GenderDTO)
25-
{
23+
24+
public init(id: String, name: String, birthDate: String?, birthTime: [String]?, gender: GenderDTO) {
2625
self.id = id
2726
self.name = name
2827
self.birthDate = birthDate

DesignSystem/DesignSystem/Sources/GenderSelectionView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ import Then
1010
import UIKit
1111

1212
// MARK: - GenderSelectionViewDelegate (성별 선택 그룹에서 선택된 성별을 알리는 프로토콜)
13-
protocol GenderSelectionViewDelegate: AnyObject {
13+
public protocol GenderSelectionViewDelegate: AnyObject {
1414
func genderSelectionView(_ view: GenderSelectionView, didSelectGender gender: String?)
1515
}
1616

1717
// MARK: - GenderSelectionView (라디오 버튼 그룹)
1818
public final class GenderSelectionView: UIView {
1919

2020
// 델리게이트를 통해 상위 뷰에 선택된 성별을 알림
21-
weak var delegate: GenderSelectionViewDelegate?
21+
public weak var delegate: GenderSelectionViewDelegate?
2222

2323
// 라디오 버튼들을 정렬하기 위한 스택 뷰
2424
private let stackView = UIStackView().then {

DesignSystem/DesignSystem/Sources/PopUp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public final class PopUp: UIView {
105105
outButton.snp.makeConstraints { make in
106106
make.height.equalTo(48)
107107
}
108-
108+
109109
actionButton.snp.makeConstraints { make in
110110
make.height.equalTo(48)
111111
}

DesignSystem/DesignSystem/Sources/Toast.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public final class Toast: UIView {
7373
}
7474

7575
stackView.addArrangedSubview(toast)
76-
7776
toast.snp.makeConstraints { make in
7877
make.width.equalTo(327)
7978
make.height.equalTo(44)

Feature/Setting/Sources/EditPage/EditProfileViewController.swift

Lines changed: 24 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import DIInjector
1111
import DesignSystem
1212
import Foundation
1313
import UIKit
14+
import DIInjector
1415

1516
public protocol EditProfileViewControllerProtocol {
1617
func showToast()
@@ -36,17 +37,15 @@ final class EditProfileViewController: BaseViewController {
3637
$0.spacing = 28
3738
$0.alignment = .leading
3839
}
39-
40+
4041
private lazy var backgourndView = UIView().then {
4142
$0.isHidden = true
4243
$0.backgroundColor = STColors.black.color.withAlphaComponent(0.5)
4344
}
44-
45+
4546
private lazy var popup = PopUp().then {
4647
$0.isHidden = true
47-
$0.update(
48-
titile: "수정 중인 내용이 있소", description: "저장하지 않고 화면을 벗어나면\n감쪽같이 사라질 것이오",
49-
actionButtonTitle: "계속 수정하기", outButtonTitle: "나가기")
48+
$0.update(titile: "수정 중인 내용이 있소", description: "저장하지 않고 화면을 벗어나면\n감쪽같이 사라질 것이오", actionButtonTitle: "계속 수정하기", outButtonTitle: "나가기")
5049
}
5150

5251
private lazy var nameStack = UIStackView().then {
@@ -198,13 +197,13 @@ extension EditProfileViewController {
198197
private func setDelegate() {
199198
self.nameTextField.delegate = self
200199
self.birthTextField.delegate = self
200+
genderSelectionView.delegate = self
201201
}
202202

203203
private func setupUI() {
204204
self.view.backgroundColor = STColors.white.color
205205
self.view.addSubview(scrollView)
206206
self.view.addSubview(saveButton)
207-
self.view.addSubview(backgourndView)
208207
backgourndView.addSubview(popup)
209208
scrollView.addSubview(contentView)
210209
contentView.addSubview(contentStackView)
@@ -240,21 +239,7 @@ extension EditProfileViewController {
240239
make.top.bottom.equalToSuperview()
241240
make.leading.trailing.equalToSuperview().inset(24)
242241
}
243-
244-
backgourndView.snp.makeConstraints { make in
245-
make.edges.equalToSuperview()
246-
}
247-
248-
popup.snp.makeConstraints { make in
249-
make.center.equalToSuperview()
250-
make.width.equalTo(327)
251-
make.height.equalTo(206)
252-
}
253-
254-
backgourndView.snp.makeConstraints { make in
255-
make.edges.equalToSuperview()
256-
}
257-
242+
258243
popup.snp.makeConstraints { make in
259244
make.center.equalToSuperview()
260245
make.width.equalTo(327)
@@ -402,6 +387,10 @@ extension EditProfileViewController {
402387
.receive(on: RunLoop.main)
403388
.sink { [weak self] isHidden in
404389
guard let self else { return }
390+
self.navigationController?.view.addSubview(backgourndView)
391+
backgourndView.snp.makeConstraints { make in
392+
make.edges.equalToSuperview()
393+
}
405394
self.popup.isHidden = isHidden
406395
self.backgourndView.isHidden = isHidden
407396
}
@@ -410,45 +399,15 @@ extension EditProfileViewController {
410399
popup.outButton.tapPublisher
411400
.sink { [weak self] _ in
412401
guard let self else { return }
413-
self.navigationController?.popViewController(animated: true)
414-
}
415-
.store(in: &store)
416-
417-
viewModel.output.setTimePickerLabel
418-
.receive(on: RunLoop.main)
419-
.sink { [weak self] time in
420-
guard let self else { return }
421-
self.bornTimeSetButton.selectedItem = time
422-
}
423-
.store(in: &store)
424-
425-
viewModel.output.navigate
426-
.receive(on: RunLoop.main)
427-
.sink { [weak self] route in
428-
guard let self else { return }
429-
if route == .pop { self.navigationController?.popViewController(animated: true) }
430-
}
431-
.store(in: &store)
432-
433-
viewModel.output.updatePopupHiden
434-
.receive(on: RunLoop.main)
435-
.sink { [weak self] isHidden in
436-
guard let self else { return }
437-
self.popup.isHidden = isHidden
438-
self.backgourndView.isHidden = isHidden
439-
}
440-
.store(in: &store)
441-
442-
popup.outButton.tapPublisher
443-
.sink { [weak self] _ in
444-
guard let self else { return }
402+
self.backgourndView.removeFromSuperview()
445403
self.navigationController?.popViewController(animated: true)
446404
}
447405
.store(in: &store)
448406

449407
popup.actionButton.tapPublisher
450408
.sink { [weak self] _ in
451409
guard let self else { return }
410+
self.backgourndView.removeFromSuperview()
452411
self.popup.isHidden = true
453412
self.backgourndView.isHidden = true
454413
}
@@ -527,6 +486,18 @@ extension EditProfileViewController {
527486
}
528487
}
529488

489+
extension EditProfileViewController : GenderSelectionViewDelegate {
490+
func genderSelectionView(_ view: DesignSystem.GenderSelectionView, didSelectGender gender: String?) {
491+
guard let gender = gender else { return }
492+
493+
var genderType: GenderType
494+
495+
if gender == "남성" { genderType = .male } else { genderType = .female }
496+
viewModel.send(input: .genderSelected(isSelected: genderType))
497+
}
498+
499+
}
500+
530501
extension EditProfileViewController: UITextFieldDelegate {
531502
public func textFieldDidBeginEditing(_ textField: UITextField) {
532503
textField.layer.borderColor = STColors.primary2.color.cgColor

Feature/Setting/Sources/EditPage/EditProfileViewModel.swift

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import Combine
1111
import DIInjector
1212
import Foundation
1313
import Lib
14+
import Auth
15+
import DIInjector
1416

1517
final class EditProfileViewModel {
1618
enum Input {
@@ -45,9 +47,10 @@ final class EditProfileViewModel {
4547
let output: Output = Output()
4648

4749
private var state: State = .init()
48-
49-
@Injected private var userDataManager: UserDataManager
50+
51+
@Injected private var userDataManager : UserDataManager
5052
@Injected private var router: SettingRouter
53+
5154
private var _isNameValid: Bool = true
5255
private var _isBirthDateValid: Bool = true
5356
private var _isBornTimeValied: Bool = true
@@ -80,22 +83,21 @@ final class EditProfileViewModel {
8083
self.output.setTimePickerLabel.send(time)
8184
self._isDontKnowButtonSelected = false
8285
}
83-
86+
8487
case .checkBirthFormat(let birth):
8588
self._isBirthDateValid = checkBirthFormat(birth: birth)
8689
if self._isBirthDateValid { self.state.birthDate = birth }
8790
self.output.showBirthError.send(self._isBirthDateValid)
8891
self.output.isSaveButtonEnabled.send(_isNameValid && _isBirthDateValid && _isBornTimeValied)
89-
92+
9093
case .checkNameFormat(let name):
9194
self._isNameValid = checkNameFormat(name: name)
9295
if self._isNameValid { self.state.name = name }
9396
self.output.showNameError.send(self._isNameValid)
9497
self.output.isSaveButtonEnabled.send(_isNameValid && _isBirthDateValid && _isBornTimeValied)
95-
98+
9699
case .genderSelected(let isSelected):
97100
self.state.gender = isSelected
98-
99101
case .timePickerTap:
100102
Task { @MainActor in
101103
self.router.navigate(
@@ -112,14 +114,12 @@ final class EditProfileViewModel {
112114
self.output.navigate.send(.popWithToast)
113115
self.router.navigate(to: SettingRoute.myPage, how: .pop, with: [:])
114116
}
115-
116117
} catch {
117118
// TODO: API 호출 에러처리
118119
print(error)
119120
}
120121
}
121122
}
122-
123123
case .backButtonTapped:
124124
if hasChanges() {
125125
self.output.updatePopupHiden.send(false)
@@ -201,13 +201,17 @@ extension EditProfileViewModel {
201201

202202
private func hasChanges() -> Bool {
203203
guard let originalUser = self.state.originalUser else { return false }
204+
204205

205206
if let name = self.state.name, name != originalUser.name {
206207
return true
207208
}
208209

209-
if let gender = self.state.gender, gender.rawValue != originalUser.gender.rawValue {
210-
return true
210+
if let gender = self.state.gender {
211+
let gendervalue = gender == .male ? GenderDTO.male : GenderDTO.female
212+
if gendervalue != originalUser.gender {
213+
return true
214+
}
211215
}
212216

213217
if let birthDate = self.state.birthDate, birthDate != originalUser.birthDate {

Feature/Setting/Sources/MyPage/Cells/MyPageMenuCollectionViewCell.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import DesignSystem
1010
import SnapKit
1111
import Then
1212
import UIKit
13+
import Base
1314

1415
struct MyPageMenuCollectionViewCellModel {
1516

Feature/Setting/Sources/MyPage/Cells/SendFeedbackCollectionViewCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ final class SendFeedbackCollectionViewCell: UICollectionViewCell {
9696
make.leading.equalToSuperview().offset(12)
9797
make.centerY.equalToSuperview()
9898
}
99-
99+
100100
arrowRightView.snp.makeConstraints { make in
101101
make.height.width.equalTo(15)
102102
make.trailing.equalToSuperview().inset(12)

Feature/Setting/Sources/MyPage/MyPageService.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ struct MyPageService {
3131

3232
return "알수 없소"
3333
}()
34-
3534
let birthDate = userData.birthDate ?? "알수 없소"
3635
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String
3736
return [

Feature/Setting/Sources/MyPage/MyPageViewController.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Extension
1212
import SnapKit
1313
import Then
1414
import UIKit
15+
import Base
1516

1617
enum MyPageSection {
1718
case profile(MyProfileInfoCollectionViewCellModel)
@@ -59,7 +60,7 @@ public final class MyPageViewController: BaseViewController {
5960
setupBinding()
6061
viewModel.send(input: .viewDidLoad)
6162
}
62-
63+
6364
public override func viewWillAppear(_ animated: Bool) {
6465
super.viewWillAppear(animated)
6566

@@ -89,7 +90,6 @@ public final class MyPageViewController: BaseViewController {
8990
let toast = Toast().then {
9091
$0.update(message: "프로필 수정이 완료됐소.")
9192
}
92-
9393
guard let tabBar = self.tabBarController?.view else { return }
9494
tabBar.addSubview(toast)
9595
toast.snp.makeConstraints { make in
@@ -98,7 +98,6 @@ public final class MyPageViewController: BaseViewController {
9898
make.trailing.equalToSuperview().offset(-24)
9999
make.height.equalTo(44)
100100
}
101-
102101
UIView.animate(
103102
withDuration: 0.5, delay: 3, options: .curveEaseOut,
104103
animations: {
@@ -268,7 +267,7 @@ extension MyPageViewController: UICollectionViewDelegateFlowLayout {
268267
SettingAssembly(),
269268
NetworkCoreAssembly(),
270269
])
271-
270+
272271
return MyPageViewController(viewModel: MyPageViewModel())
273272
}
274273
#endif

0 commit comments

Comments
 (0)