Skip to content

Commit

Permalink
(#192)-profile_edit: Auto stash before rebase of "feature/(#192)-prof…
Browse files Browse the repository at this point in the history
…ile_edit" onto "origin/develop"
  • Loading branch information
HongSJae committed Mar 29, 2024
1 parent ade350b commit 4694ae2
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ public extension TargetDependency.Modules {
target: "DesignSystem",
path: .relativeToRoot("Projects/Modules/DesignSystem")
)
static let utility = TargetDependency.project(
target: "Utility",
path: .relativeToRoot("Projects/Modules/Utility")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ extension BookmarkListResponseDTO {
BookmarkEntity(
companyName: $0.companyName,
recruitmentID: $0.recruitmentID,
createdAt: $0.createdAt.toJobisDate().toSting(),
createdAt: $0.createdAt.toJobisDate()
.toStringFormat("yyyy-MM-dd"),
companyLogoUrl: $0.companyLogoUrl
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Foundation
import Domain
import Utility

struct NoticeDetailResponseDTO: Decodable {
let title: String
Expand Down Expand Up @@ -33,7 +34,7 @@ extension NoticeDetailResponseDTO {
return NoticeDetailEntity(
title: title,
content: content,
createdAt: noticeDate.toSting(),
createdAt: noticeDate.toStringFormat("yyyy-MM-dd"),
attachments: attachments.map { $0.toDomain() }
)
}
Expand Down
4 changes: 2 additions & 2 deletions Projects/Data/Sources/DTO/Notice/NoticeListResponseDTO.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
import DesignSystem
import Utility
import Domain

struct NoticeListResponseDTO: Decodable {
Expand All @@ -25,7 +25,7 @@ extension NoticeListResponseDTO {
return NoticeEntity(
companyId: $0.id,
title: $0.title,
createdAt: noticeDate.toSting()
createdAt: noticeDate.toStringFormat("yyyy-MM-dd")
)
}
}
Expand Down
10 changes: 0 additions & 10 deletions Projects/Data/Sources/Utils/Date+toString.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Projects/Domain/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ let project = Project.makeModule(
product: .staticFramework,
targets: [.unitTest],
dependencies: [
.Projects.core
.Modules.utility
]
)
2 changes: 1 addition & 1 deletion Projects/Modules/AppNetwork/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ let project = Project.makeModule(
product: .framework,
targets: [.unitTest],
dependencies: [
.Projects.core
.Modules.utility
]
)
2 changes: 1 addition & 1 deletion Projects/Modules/DesignSystem/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let project = Project.makeModule(
product: .framework,
targets: [.demo],
dependencies: [
.Projects.core
.Modules.utility
],
resources: .resources,
resourceSynthesizers: .default + [
Expand Down
12 changes: 12 additions & 0 deletions Projects/Modules/Utility/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import ProjectDescription
import ProjectDescriptionHelpers
import DependencyPlugin

let project = Project.makeModule(
name: "Utility",
product: .framework,
targets: [],
dependencies: [
.Projects.core
]
)
7 changes: 7 additions & 0 deletions Projects/Modules/Utility/Sources/Rx+Ext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import RxSwift

extension ObservableType {
public var avoidDuplication: Observable<Element> {
throttle(.seconds(1), scheduler: MainScheduler.instance)
}
}
3 changes: 3 additions & 0 deletions Projects/Presentation/Sources/DI/PresentationAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public final class PresentationAssembly: Assembly {
}
container.register(MyPageViewModel.self) { resolver in
MyPageViewModel(
fetchPresignedURLUseCase: resolver.resolve(FetchPresignedURLUseCase.self)!,
uploadImageToS3UseCase: resolver.resolve(UploadImageToS3UseCase.self)!,
changeProfileImageUseCase: resolver.resolve(ChangeProfileImageUseCase.self)!,
fetchStudentInfoUseCase: resolver.resolve(FetchStudentInfoUseCase.self)!,
fetchWritableReviewListUseCase: resolver.resolve(FetchWritableReviewListUseCase.self)!,
logoutUseCase: resolver.resolve(LogoutUseCase.self)!
Expand Down
28 changes: 26 additions & 2 deletions Projects/Presentation/Sources/MyPage/MyPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Then
import Core
import Kingfisher
import DesignSystem
import Domain

public final class MyPageViewController: BaseViewController<MyPageViewModel> {
private let scrollView = UIScrollView().then {
Expand All @@ -20,7 +21,8 @@ public final class MyPageViewController: BaseViewController<MyPageViewModel> {
private let accountSectionView = AccountSectionView()
// private let bugSectionView = BugSectionView()
private let helpSectionView = HelpSectionView()

private let selectedImage = PublishRelay<UploadFileModel>()
private let picker = UIImagePickerController()
public override func addView() {
self.view.addSubview(scrollView)
self.scrollView.addSubview(contentView)
Expand Down Expand Up @@ -79,7 +81,8 @@ public final class MyPageViewController: BaseViewController<MyPageViewModel> {
public override func bind() {
let input = MyPageViewModel.Input(
viewAppear: self.viewDidLoadPublisher,
// reviewNavigate: reviewNavigateStackView.reviewNavigateButtonDidTap,
reviewNavigate: reviewNavigateStackView.reviewNavigateButtonDidTap,
selectedImage: selectedImage,
helpSectionDidTap: helpSectionView.getSelectedItem(type: .announcement),
changePasswordSectionDidTap: accountSectionView.getSelectedItem(type: .changePassword),
logoutSectionDidTap: accountSectionView.getSelectedItem(type: .logout),
Expand Down Expand Up @@ -111,6 +114,7 @@ public final class MyPageViewController: BaseViewController<MyPageViewModel> {
}

public override func configureViewController() {
self.picker.delegate = self
self.viewWillAppearPublisher.asObservable()
.subscribe(onNext: { [weak self] in
self?.showTabbar()
Expand All @@ -122,3 +126,23 @@ public final class MyPageViewController: BaseViewController<MyPageViewModel> {
self.setLargeTitle(title: "마이페이지")
}
}

extension MyPageViewController: UIImagePickerControllerDelegate {
func openLibrary() {
picker.sourceType = .photoLibrary
present(picker, animated: true, completion: nil)
}
}

extension MyPageViewController: UINavigationControllerDelegate {
public func imagePickerController(
_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]
) {
if let image = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
guard let imageData = image.pngData() else { return }
self.selectedImage.accept(.init(file: imageData, fileName: "profile.png"))
dismiss(animated: true, completion: nil)
}
}
}
40 changes: 39 additions & 1 deletion Projects/Presentation/Sources/MyPage/MyPageViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ import Domain

public final class MyPageViewModel: BaseViewModel, Stepper {
public let steps = PublishRelay<Step>()
private let fetchPresignedURLUseCase: FetchPresignedURLUseCase
private let uploadImageToS3UseCase: UploadImageToS3UseCase
private let changeProfileImageUseCase: ChangeProfileImageUseCase
private let fetchStudentInfoUseCase: FetchStudentInfoUseCase
private let fetchWritableReviewListUseCase: FetchWritableReviewListUseCase
private let logoutUseCase: LogoutUseCase

init(
fetchPresignedURLUseCase: FetchPresignedURLUseCase,
uploadImageToS3UseCase: UploadImageToS3UseCase,
changeProfileImageUseCase: ChangeProfileImageUseCase,
fetchStudentInfoUseCase: FetchStudentInfoUseCase,
fetchWritableReviewListUseCase: FetchWritableReviewListUseCase,
logoutUseCase: LogoutUseCase
) {
self.fetchPresignedURLUseCase = fetchPresignedURLUseCase
self.uploadImageToS3UseCase = uploadImageToS3UseCase
self.changeProfileImageUseCase = changeProfileImageUseCase
self.fetchStudentInfoUseCase = fetchStudentInfoUseCase
self.fetchWritableReviewListUseCase = fetchWritableReviewListUseCase
self.logoutUseCase = logoutUseCase
Expand All @@ -26,6 +35,8 @@ public final class MyPageViewModel: BaseViewModel, Stepper {
public struct Input {
let viewAppear: PublishRelay<Void>
// let reviewNavigate: PublishRelay<Int>
let reviewNavigate: PublishRelay<Int>
let selectedImage: PublishRelay<UploadFileModel>
let helpSectionDidTap: Observable<IndexPath>
let changePasswordSectionDidTap: Observable<IndexPath>
let logoutSectionDidTap: Observable<IndexPath>
Expand All @@ -35,11 +46,13 @@ public final class MyPageViewModel: BaseViewModel, Stepper {
public struct Output {
let studentInfo: PublishRelay<StudentInfoEntity>
let writableReviewList: BehaviorRelay<[WritableReviewCompanyEntity]>
let changedImageURL: PublishRelay<String>
}

public func transform(_ input: Input) -> Output {
let studentInfo = PublishRelay<StudentInfoEntity>()
let writableReviewList = BehaviorRelay<[WritableReviewCompanyEntity]>(value: [])
let changedImageURL = PublishRelay<String>()

input.viewAppear.asObservable()
.flatMap { self.fetchStudentInfoUseCase.execute() }
Expand All @@ -57,6 +70,30 @@ public final class MyPageViewModel: BaseViewModel, Stepper {
// print($0)
// }).disposed(by: disposeBag)

input.selectedImage.asObservable()
.flatMap { file in
self.fetchPresignedURLUseCase.execute(
req: .init(files: [.init(fileName: file.fileName)])
)
.asObservable()
.map { ($0.first, file.file) }
}
.map { url, data in
self.uploadImageToS3UseCase.execute(
presignedURL: url?.presignedUrl ?? "",
data: data
)
.asObservable()
.flatMap { _ in
self.changeProfileImageUseCase.execute(url: url?.filePath ?? "")
.asObservable()
.map { _ in url?.filePath ?? "" }
}
.map { _ in url?.filePath ?? "" }
}
.bind(to: changedImageURL)
.disposed(by: disposeBag)

input.helpSectionDidTap.asObservable()
.map { _ in MyPageStep.noticeIsRequired }
.bind(to: steps)
Expand Down Expand Up @@ -85,7 +122,8 @@ public final class MyPageViewModel: BaseViewModel, Stepper {

return Output(
studentInfo: studentInfo,
writableReviewList: writableReviewList
writableReviewList: writableReviewList,
changedImageURL: changedImageURL
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Domain
import RxFlow
import RxSwift
import RxCocoa
import Utility

public final class OnboardingViewModel: BaseViewModel, Stepper {
public let steps = PublishRelay<Step>()
Expand All @@ -29,13 +30,13 @@ public final class OnboardingViewModel: BaseViewModel, Stepper {
let showNavigationButton = PublishRelay<Void>()

input.navigateToSigninDidTap.asObservable()
.throttle(.seconds(1), scheduler: MainScheduler.instance)
.avoidDuplication
.map { _ in OnboardingStep.signinIsRequired }
.bind(to: steps)
.disposed(by: disposeBag)

input.navigateToSignupDidTap.asObservable()
.throttle(.seconds(1), scheduler: MainScheduler.instance)
.avoidDuplication
.map { _ in OnboardingStep.signupIsRequired }
.bind(to: steps)
.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import SnapKit
import Then
import Core
import DesignSystem
import Utility

public final class SigninViewController: BaseReactorViewController<SigninReactor> {
private let titleLabel = UILabel().then {
Expand Down Expand Up @@ -99,13 +100,13 @@ public final class SigninViewController: BaseReactorViewController<SigninReactor

forgetPasswordButton.rx.tapGesture()
.when(.recognized)
.throttle(.seconds(1), scheduler: MainScheduler.asyncInstance)
.avoidDuplication
.map { _ in SigninReactor.Action.foregetPasswordButtonDidTap }
.bind(to: reactor.action)
.disposed(by: disposeBag)

signinButton.rx.tap
.throttle(.seconds(1), scheduler: MainScheduler.asyncInstance)
.avoidDuplication
.map { SigninReactor.Action.signinButtonDidTap }
.bind(to: reactor.action)
.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Domain
import RxFlow
import RxSwift
import RxCocoa
import Utility

public final class GenderSettingViewModel: BaseViewModel, Stepper {
public var steps = PublishRelay<Step>()
Expand All @@ -25,6 +26,7 @@ public final class GenderSettingViewModel: BaseViewModel, Stepper {
public func transform(_ input: Input) -> Output {
input.nextButtonDidTap.asObservable()
.withLatestFrom(input.gender)
.avoidDuplication
.map { gender in
GenderSettingStep.profileSettingIsRequired(
name: input.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import RxFlow
import RxSwift
import RxCocoa
import Domain
import Utility

public final class InfoSettingViewModel: BaseViewModel, Stepper {
public let steps = PublishRelay<Step>()
Expand Down Expand Up @@ -32,6 +33,7 @@ public final class InfoSettingViewModel: BaseViewModel, Stepper {
input.nextButtonDidTap
.asObservable()
.withLatestFrom(info)
.avoidDuplication
.filter { name, gcn in
if name.isEmpty {
nameErrorDescription.accept(.error(description: "이름을 입력해주세요"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import RxFlow
import RxSwift
import RxCocoa
import Domain
import Utility

public final class PasswordSettingViewModel: BaseViewModel, Stepper {
public let steps = PublishRelay<Step>()
Expand All @@ -30,6 +31,7 @@ public final class PasswordSettingViewModel: BaseViewModel, Stepper {

input.nextButtonDidTap.asObservable()
.withLatestFrom(info)
.avoidDuplication
.filter { password, checkingPassword in
let passwordExpression =
#"^(?=.*[A-Za-z])(?=.*\d)(?=.*[$@$!%*#?&])[A-Za-z\d$@$!%*#?&]{8,16}$"#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import RxSwift
import RxCocoa
import Domain
import FirebaseMessaging
import Utility

public final class PrivacyViewModel: BaseViewModel, Stepper {
public let steps = PublishRelay<Step>()
Expand All @@ -29,6 +30,7 @@ public final class PrivacyViewModel: BaseViewModel, Stepper {
public func transform(_ input: Input) -> Output {
input.signupButtonDidTap
.asObservable()
.avoidDuplication
.flatMap { [self] in
signupUseCase.execute(
req: .init(
Expand Down
Loading

0 comments on commit 4694ae2

Please sign in to comment.