diff --git a/Segno/Segno.xcodeproj/project.pbxproj b/Segno/Segno.xcodeproj/project.pbxproj index 4aae17e..511c8b3 100644 --- a/Segno/Segno.xcodeproj/project.pbxproj +++ b/Segno/Segno.xcodeproj/project.pbxproj @@ -71,6 +71,7 @@ 982A2A472924AE74006F6ACD /* UserDefaultsKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982A2A462924AE74006F6ACD /* UserDefaultsKey.swift */; }; 982A3699292C905300FDC6CF /* DiaryDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982A3698292C905300FDC6CF /* DiaryDetailViewController.swift */; }; 982B3B7F292E68FB0077A44B /* DiaryDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 982B3B7E292E68FB0077A44B /* DiaryDetailViewModel.swift */; }; + 9838443E29387C0A00BCCEE2 /* ChangeNicknameEndpoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9838443D29387C0A00BCCEE2 /* ChangeNicknameEndpoint.swift */; }; 983AE9D22934F041006547BD /* NicknameCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983AE9D12934F041006547BD /* NicknameCell.swift */; }; 983AE9D4293513AD006547BD /* SettingsCellModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983AE9D3293513AD006547BD /* SettingsCellModel.swift */; }; 983AE9D6293514E8006547BD /* SettingsActionSheetCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 983AE9D5293514E8006547BD /* SettingsActionSheetCell.swift */; }; @@ -155,6 +156,7 @@ 982A2A462924AE74006F6ACD /* UserDefaultsKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsKey.swift; sourceTree = ""; }; 982A3698292C905300FDC6CF /* DiaryDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailViewController.swift; sourceTree = ""; }; 982B3B7E292E68FB0077A44B /* DiaryDetailViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DiaryDetailViewModel.swift; sourceTree = ""; }; + 9838443D29387C0A00BCCEE2 /* ChangeNicknameEndpoint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChangeNicknameEndpoint.swift; sourceTree = ""; }; 983AE9D12934F041006547BD /* NicknameCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NicknameCell.swift; sourceTree = ""; }; 983AE9D3293513AD006547BD /* SettingsCellModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsCellModel.swift; sourceTree = ""; }; 983AE9D5293514E8006547BD /* SettingsActionSheetCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsActionSheetCell.swift; sourceTree = ""; }; @@ -307,10 +309,10 @@ isa = PBXGroup; children = ( 9841D6162925FACC00318EA9 /* LoginUseCase.swift */, - 7940FB32292E065F00276EFC /* DiaryDetailUseCase.swift */, 988414DA2923606B007C9132 /* DiaryListUseCase.swift */, - 66A8CF682937945300C17F84 /* UserDetailUseCase.swift */, + 7940FB32292E065F00276EFC /* DiaryDetailUseCase.swift */, 791529D72932F364005A8DDB /* DiaryEditUseCase.swift */, + 66A8CF682937945300C17F84 /* UserDetailUseCase.swift */, 9894EAF429373385005F2B15 /* SettingsUseCase.swift */, 9825F41A29377875005F2163 /* ChangeUserNameUseCase.swift */, ); @@ -426,6 +428,7 @@ 4F4E0D7529252236005ABA8F /* LoginEndpoint.swift */, 66A8CF6C29379A9900C17F84 /* UserDetailEndpoint.swift */, 791529DD29333D40005A8DDB /* ImageEndpoint.swift */, + 9838443D29387C0A00BCCEE2 /* ChangeNicknameEndpoint.swift */, ); path = Endpoints; sourceTree = ""; @@ -593,6 +596,7 @@ 982A3699292C905300FDC6CF /* DiaryDetailViewController.swift in Sources */, 9825F41B29377875005F2163 /* ChangeUserNameUseCase.swift in Sources */, 666E6F8C291CFAC200CECD4B /* DiaryCollectionViewController.swift in Sources */, + 9838443E29387C0A00BCCEE2 /* ChangeNicknameEndpoint.swift in Sources */, 666E6F8A291CF82700CECD4B /* TabBarPageCase.swift in Sources */, 66A8CF652937934A00C17F84 /* MyPageRepository.swift in Sources */, 79183800292225DC00BC6992 /* UIFont+.swift in Sources */, diff --git a/Segno/Segno/Domain/UseCase/ChangeUserNameUseCase.swift b/Segno/Segno/Domain/UseCase/ChangeUserNameUseCase.swift index 296a51e..86b3357 100644 --- a/Segno/Segno/Domain/UseCase/ChangeUserNameUseCase.swift +++ b/Segno/Segno/Domain/UseCase/ChangeUserNameUseCase.swift @@ -8,7 +8,7 @@ import RxSwift protocol ChangeUserNameUseCase { - func requestChangeNickname(to nickname: String) -> Bool + func requestChangeNickname(to nickname: String) -> Single } final class ChangeUserNameUseCaseImpl: ChangeUserNameUseCase { @@ -19,9 +19,7 @@ final class ChangeUserNameUseCaseImpl: ChangeUserNameUseCase { self.repository = repository } - func requestChangeNickname(to nickname: String) -> Bool { - // 임시 처리입니다. - debugPrint("SettingsUseCase - requestChangeNickname : \(nickname)으로 변경") - return true + func requestChangeNickname(to nickname: String) -> Single { + return repository.changeNickname(to: nickname) } } diff --git a/Segno/Segno/Presentation/ViewController/SettingsViewController.swift b/Segno/Segno/Presentation/ViewController/SettingsViewController.swift index 6eb369d..ef1a8b8 100644 --- a/Segno/Segno/Presentation/ViewController/SettingsViewController.swift +++ b/Segno/Segno/Presentation/ViewController/SettingsViewController.swift @@ -70,17 +70,19 @@ final class SettingsViewController: UIViewController { let self = self else { return UITableViewCell() } cell.okButton.rx.tap - .flatMap { a in + .flatMap { _ in guard let newNickname = cell.nicknameTextField.text else { return Observable.empty() } + return self.viewModel.changeNickname(to: newNickname) + .asObservable() } .subscribe(onNext: { result in - debugPrint("여기에서 \(result)에 대한 피드백 Alert 띄웁니다.") + debugPrint("닉네임 변경 결과 : \(result)") + // TODO: 성공/실패 알럿띄우기 }) .disposed(by: self.disposeBag) - return cell case .settingsSwitch(let title, let isOn): guard let cell = tableView.dequeueReusableCell(withIdentifier: "SettingsSwitchCell") as? SettingsSwitchCell, diff --git a/Segno/Segno/Presentation/ViewModel/SettingsViewModel.swift b/Segno/Segno/Presentation/ViewModel/SettingsViewModel.swift index d180bf7..6e14a3c 100644 --- a/Segno/Segno/Presentation/ViewModel/SettingsViewModel.swift +++ b/Segno/Segno/Presentation/ViewModel/SettingsViewModel.swift @@ -26,12 +26,8 @@ final class SettingsViewModel { self.changeUserNameUseCase = changeUserNameUseCase } - func changeNickname(to nickname: String) -> Observable { - return Observable.create { emitter in - let result = self.changeUserNameUseCase.requestChangeNickname(to: nickname) - emitter.onNext(result) - return Disposables.create() - } + func changeNickname(to nickname: String) -> Single { + return self.changeUserNameUseCase.requestChangeNickname(to: nickname) } func getAutoPlayMode() -> Bool {