Skip to content
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

[IDLE-000] 설정화면 딥링크및 탈퇴사유 입력필드 추가 #66

Merged
merged 5 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public extension DefaultAuthRepository {
.map { _ in }
}

func deregisterCenterAccount(reasons: [DeregisterReasonVO], password: String) -> RxSwift.Single<Void> {
func deregisterCenterAccount(reasons: [String], password: String) -> RxSwift.Single<Void> {

let reasonString = reasons.map { $0.reasonText }.joined(separator: "|")
let reasonString = reasons.joined(separator: "|")

return networkService
.request(
Expand Down Expand Up @@ -119,8 +119,8 @@ public extension DefaultAuthRepository {
.map { _ in }
}

func deregisterWorkerAccount(reasons: [Entity.DeregisterReasonVO]) -> RxSwift.Single<Void> {
let reasonString = reasons.map { $0.reasonText }.joined(separator: "|")
func deregisterWorkerAccount(reasons: [String]) -> RxSwift.Single<Void> {
let reasonString = reasons.joined(separator: "|")

return networkService
.request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class DefaultSettingUseCase: SettingScreenUseCase {

// MARK: 회원탈퇴 & 로그아웃
// 센터 회원탈퇴
public func deregisterCenterAccount(reasons: [Entity.DeregisterReasonVO], password: String) -> RxSwift.Single<Result<Void, Entity.DomainError>> {
public func deregisterCenterAccount(reasons: [String], password: String) -> RxSwift.Single<Result<Void, Entity.DomainError>> {
let task = authRepository
.deregisterCenterAccount(reasons: reasons, password: password)
.map { [weak self] _ in
Expand All @@ -118,7 +118,7 @@ public class DefaultSettingUseCase: SettingScreenUseCase {
}

// 요양보호사 회원탈퇴
public func deregisterWorkerAccount(reasons: [Entity.DeregisterReasonVO]) -> RxSwift.Single<Result<Void, Entity.DomainError>> {
public func deregisterWorkerAccount(reasons: [String]) -> RxSwift.Single<Result<Void, Entity.DomainError>> {
let task = authRepository
.deregisterWorkerAccount(reasons: reasons)
.map { [weak self] _ in
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// SettingAdditionalInfoType.swift
// Entity
//
// Created by choijunios on 9/15/24.
//

import Foundation

public enum SettingAdditionalInfoType {

case frequentQuestion
case contact
case termsandPolicies
case privacyPolicy

public func getWebUrl() -> URL {
var urlString: String!
switch self {
case .frequentQuestion:
urlString = "https://grove-maraca-55d.notion.site/8579186ee8ca4dbb8dc55e3b8b744d11?pvs=4"
case .contact:
urlString = "https://docs.google.com/forms/d/1I1N9xmYuqlpy8K1ga8xOECPZl-1sW33WrKIzXas74Is/viewform?edit_requested=true"
case .termsandPolicies:
urlString = "https://grove-maraca-55d.notion.site/2e4d597aff1f406e9164cdb6f9195de0?pvs=4"
case .privacyPolicy:
urlString = "https://grove-maraca-55d.notion.site/ad4f62dff5304d63a162f1269639afca?pvs=4"
}

return URL(string: urlString)!
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public protocol AuthRepository: RepositoryBase {
func requestRegisterCenterAccount(managerName: String, phoneNumber: String, businessNumber: String, id: String, password: String) -> Single<Void>
func requestCenterLogin(id: String, password: String) -> Single<Void>
func signoutCenterAccount() -> Single<Void>
func deregisterCenterAccount(reasons: [DeregisterReasonVO], password: String) -> Single<Void>
func deregisterCenterAccount(reasons: [String], password: String) -> Single<Void>
func getCenterJoinStatus() -> Single<CenterJoinStatusInfoVO>
func requestCenterJoin() -> Single<Void>
func setNewPassword(phoneNumber: String, password: String) -> Single<Void>
Expand All @@ -24,5 +24,5 @@ public protocol AuthRepository: RepositoryBase {
func requestRegisterWorkerAccount(registerState: WorkerRegisterState) -> Single<Void>
func requestWorkerLogin(phoneNumber: String, authNumber: String) -> Single<Void>
func signoutWorkerAccount() -> Single<Void>
func deregisterWorkerAccount(reasons: [DeregisterReasonVO]) -> Single<Void>
func deregisterWorkerAccount(reasons: [String]) -> Single<Void>
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public protocol SettingScreenUseCase: BaseUseCase {

/// 요양보호사 회원 탈퇴
func deregisterWorkerAccount(
reasons: [DeregisterReasonVO]
reasons: [String]
) -> Single<Result<Void, DomainError>>

/// 요양보호사 로그아웃
Expand All @@ -48,7 +48,7 @@ public protocol SettingScreenUseCase: BaseUseCase {

/// 센터 회원 탈퇴
func deregisterCenterAccount(
reasons: [DeregisterReasonVO],
reasons: [String],
password: String
) -> Single<Result<Void, DomainError>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class MultiLineTextField: UITextView {
let label = IdleLabel(typography: typography)
label.attrTextColor = DSKitAsset.Colors.gray200.color
label.textAlignment = .left
label.numberOfLines = 0
label.lineBreakMode = .byCharWrapping
return label
}()

Expand Down Expand Up @@ -88,10 +90,12 @@ public class MultiLineTextField: UITextView {
self.addSubview(placeHolderLabel)
placeHolderLabel.translatesAutoresizingMaskIntoConstraints = false

let frameGuide = self.frameLayoutGuide
let textContainerInset = self.textContainerInset
NSLayoutConstraint.activate([
placeHolderLabel.topAnchor.constraint(equalTo: self.topAnchor, constant: self.textContainerInset.top),
placeHolderLabel.leadingAnchor.constraint(equalTo: self.leadingAnchor, constant: self.textContainerInset.left),
placeHolderLabel.trailingAnchor.constraint(equalTo: self.trailingAnchor, constant: self.textContainerInset.right),
placeHolderLabel.topAnchor.constraint(equalTo: frameGuide.topAnchor, constant: textContainerInset.top),
placeHolderLabel.leftAnchor.constraint(equalTo: frameGuide.leftAnchor, constant: textContainerInset.left),
placeHolderLabel.rightAnchor.constraint(equalTo: frameGuide.rightAnchor, constant: -textContainerInset.right),
])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public class PasswordForDeregisterCoordinator: ChildCoordinator {

public struct Dependency {
let settingUseCase: SettingScreenUseCase
let reasons: [DeregisterReasonVO]
let reasons: [String]
let navigationController: UINavigationController

public init(settingUseCase: SettingScreenUseCase, reasons: [DeregisterReasonVO], navigationController: UINavigationController) {
public init(settingUseCase: SettingScreenUseCase, reasons: [String], navigationController: UINavigationController) {
self.settingUseCase = settingUseCase
self.reasons = reasons
self.navigationController = navigationController
Expand All @@ -29,7 +29,7 @@ public class PasswordForDeregisterCoordinator: ChildCoordinator {

public let navigationController: UINavigationController
let settingUseCase: SettingScreenUseCase
let reasons: [DeregisterReasonVO]
let reasons: [String]

public init(
dependency: Dependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ public class CenterSettingVC: BaseViewController {
.bind(to: viewModel.removeAccountButtonClicked)
.disposed(by: disposeBag)

// 설정화면에 종속적인 뷰들입니다.
Observable
.merge(
frequentQuestionButton.rx.tap
.map { _ in SettingAdditionalInfoType.frequentQuestion },
askButton.rx.tap
.map { _ in SettingAdditionalInfoType.contact },
applicationPolicyButton.rx.tap
.map { _ in SettingAdditionalInfoType.termsandPolicies },
personalDataProcessingPolicyButton.rx.tap
.map { _ in SettingAdditionalInfoType.privacyPolicy }
)
.bind(to: viewModel.additionalInfoButtonClieck)
.disposed(by: disposeBag)

// Output
viewModel
.pushNotificationApproveState?
Expand Down Expand Up @@ -216,39 +231,6 @@ public class CenterSettingVC: BaseViewController {

private func setObservable() {

// 설정화면에 종속적인 뷰들입니다.
frequentQuestionButton.rx.tap
.subscribe(onNext: {

// 자주하는 질문뷰

})
.disposed(by: disposeBag)

askButton.rx.tap
.subscribe(onNext: {

// 문의하기 뷰

})
.disposed(by: disposeBag)

applicationPolicyButton.rx.tap
.subscribe(onNext: {

// 약관및 정책

})
.disposed(by: disposeBag)

personalDataProcessingPolicyButton.rx.tap
.subscribe(onNext: {

// 개인정보 처리방침

})
.disposed(by: disposeBag)

signOutButton
.rx.tap
.subscribe(onNext: { [weak self] _ in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public protocol CenterSettingVMable: BaseViewModel {
var signOutButtonComfirmed: PublishRelay<Void> { get }
var removeAccountButtonClicked: PublishRelay<Void> { get }

var additionalInfoButtonClieck: PublishRelay<SettingAdditionalInfoType> { get }

// Output
var pushNotificationApproveState: Driver<Bool>? { get }
var showSettingAlert: Driver<Void>? { get }
Expand All @@ -40,12 +42,14 @@ public class CenterSettingVM: BaseViewModel, CenterSettingVMable {
weak var coordinator: CenterSettingScreenCoordinator?
let settingUseCase: SettingScreenUseCase

public var viewWillAppear: RxRelay.PublishRelay<Void> = .init()
public var myCenterProfileButtonClicked: RxRelay.PublishRelay<Void> = .init()
public var approveToPushNotification: RxRelay.PublishRelay<Bool> = .init()
public var viewWillAppear: PublishRelay<Void> = .init()
public var myCenterProfileButtonClicked: PublishRelay<Void> = .init()
public var approveToPushNotification: PublishRelay<Bool> = .init()

public var signOutButtonComfirmed: PublishRelay<Void> = .init()
public var removeAccountButtonClicked: PublishRelay<Void> = .init()

public var signOutButtonComfirmed: RxRelay.PublishRelay<Void> = .init()
public var removeAccountButtonClicked: RxRelay.PublishRelay<Void> = .init()
public let additionalInfoButtonClieck: PublishRelay<SettingAdditionalInfoType> = .init()

public var pushNotificationApproveState: RxCocoa.Driver<Bool>?
public var centerInfo: RxCocoa.Driver<(name: String, location: String)>?
Expand Down Expand Up @@ -125,6 +129,26 @@ public class CenterSettingVM: BaseViewModel, CenterSettingVMable {
})
.disposed(by: disposeBag)

// MARK: 추가정보
additionalInfoButtonClieck
.subscribe(onNext: {
[weak self] type in
guard let self else { return }

let url = type.getWebUrl()

if !openURL(url) {

alert.onNext(
.init(
title: "오류가 발생했습니다.",
message: "잠시후 다시시도해 주세요."
)
)
}
})
.disposed(by: disposeBag)


// MARK: 로그아웃
let signOutRequestResult = signOutButtonComfirmed.flatMap({ [settingUseCase] _ in
Expand Down Expand Up @@ -181,6 +205,14 @@ public class CenterSettingVM: BaseViewModel, CenterSettingVMable {

return viewModel
}

private func openURL(_ url: URL) -> Bool {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:])
return true
}
return false
}
}

class CenterSingOutVM: IdleAlertViewModelable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class PasswordForDeregisterVM: BaseViewModel {
let settingUseCase: SettingScreenUseCase

public init(
deregisterReasons: [DeregisterReasonVO],
deregisterReasons: [String],
coordinator: PasswordForDeregisterCoordinator,
settingUseCase: SettingScreenUseCase
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class DeRegisterCoordinator: DeregisterCoordinatable {
coordinator.start()
}

public func showFinalPasswordScreen(reasons: [Entity.DeregisterReasonVO]) {
public func showFinalPasswordScreen(reasons: [String]) {

let coordinator = PasswordForDeregisterCoordinator(
dependency: .init(
Expand All @@ -76,7 +76,7 @@ public class DeRegisterCoordinator: DeregisterCoordinatable {
coordinator.start()
}

public func showFinalPhoneAuthScreen(reasons: [Entity.DeregisterReasonVO]) {
public func showFinalPhoneAuthScreen(reasons: [String]) {
let coordinator = PhoneNumberValidationForDeregisterCoordinator(
dependency: .init(
settingUseCase: settingUseCase,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public class SelectReasonCoordinator: ChildCoordinator {
parent?.removeChildCoordinator(self)
}

public func showPasswordAuthScreen(reasons: [DeregisterReasonVO]) {
public func showPasswordAuthScreen(reasons: [String]) {
parent?.showFinalPasswordScreen(reasons: reasons)
}

public func showPhoneNumberAuthScreen(reasons: [DeregisterReasonVO]) {
public func showPhoneNumberAuthScreen(reasons: [String]) {
parent?.showFinalPhoneAuthScreen(reasons: reasons)
}
}
Expand Down
Loading
Loading