From 2c8938749394b81930e528ca782fa5b48dc5aa81 Mon Sep 17 00:00:00 2001 From: Do-hyun-Kim Date: Thu, 26 Sep 2024 20:14:18 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20CameraDisplayNavigator=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20-=20CameraDisplayViewController=20BBToast=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80=20-=20CameraDi?= =?UTF-8?q?splayViewController=20=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DIContainer/NavigatorDIContainer.swift | 6 ++ .../Navigator/CameraDisplayNavigator.swift | 69 +++++++++++++++++++ .../Camera/CameraDisplayViewController.swift | 69 +++++++------------ .../Reactor/CameraDisplayViewReactor.swift | 25 ++++++- .../BBToast/BBToastConfiguration.swift | 4 +- 5 files changed, 124 insertions(+), 49 deletions(-) create mode 100644 14th-team5-iOS/App/Sources/Application/Navigator/CameraDisplayNavigator.swift diff --git a/14th-team5-iOS/App/Sources/Application/DIContainer/NavigatorDIContainer.swift b/14th-team5-iOS/App/Sources/Application/DIContainer/NavigatorDIContainer.swift index 71427a118..455e810bc 100644 --- a/14th-team5-iOS/App/Sources/Application/DIContainer/NavigatorDIContainer.swift +++ b/14th-team5-iOS/App/Sources/Application/DIContainer/NavigatorDIContainer.swift @@ -77,6 +77,12 @@ final class NavigatorDIContainer: BaseContainer { ) } + container.register(type: CameraDisplayNavigatorProtocol.self) { _ in + CameraDisplayNavigator( + navigationController: makeUINavigationController() + ) + } + container.register(type: ManagementNavigatorProtocol.self) { _ in ManagementNavigator( navigationController: makeUINavigationController() diff --git a/14th-team5-iOS/App/Sources/Application/Navigator/CameraDisplayNavigator.swift b/14th-team5-iOS/App/Sources/Application/Navigator/CameraDisplayNavigator.swift new file mode 100644 index 000000000..c7eb6f71a --- /dev/null +++ b/14th-team5-iOS/App/Sources/Application/Navigator/CameraDisplayNavigator.swift @@ -0,0 +1,69 @@ +// +// CameraDisplayNavigator.swift +// App +// +// Created by Kim dohyun on 9/26/24. +// + +import Core +import DesignSystem +import UIKit + +protocol CameraDisplayNavigatorProtocol: BaseNavigator { + func toHome() + func showToast() + func showArchiveToast() + func showWarningToast() +} + +final class CameraDisplayNavigator: CameraDisplayNavigatorProtocol { + + //MARK: - Properties + var navigationController: UINavigationController + + + //MARK: - Intializer + init(navigationController: UINavigationController) { + self.navigationController = navigationController + } + + //MARK: - Configure + func toHome() { + let vc = MainViewControllerWrapper().viewController + navigationController.setViewControllers([vc], animated: true) + } + + func showToast() { + let config = BBToastConfiguration(direction: .bottom(yOffset: -360), animationTime: 1.0) + let viewConfig = BBToastViewConfiguration(minWidth: 207) + BBToast.default( + image: DesignSystemAsset.warning.image, + title: "8자까지 입력 가능해요", + viewConfig: viewConfig, + config: config + ).show() + } + + func showArchiveToast() { + let config = BBToastConfiguration(direction: .bottom(yOffset: 75)) + let viewConfig = BBToastViewConfiguration(minWidth: 194) + BBToast.default( + image: DesignSystemAsset.camera.image.withTintColor(DesignSystemAsset.gray300.color), + title: "사진이 저장되었습니다.", + viewConfig: viewConfig, + config: config + ).show() + } + + func showWarningToast() { + let config = BBToastConfiguration(direction: .bottom(yOffset: -360), animationTime: 1.0) + let viewConfig = BBToastViewConfiguration(minWidth: 207) + BBToast.default( + image: DesignSystemAsset.warning.image, + title: "띄어쓰기는 할 수 없어요", + viewConfig: viewConfig, + config: config + ).show() + + } +} diff --git a/14th-team5-iOS/App/Sources/Presentation/Camera/CameraDisplayViewController.swift b/14th-team5-iOS/App/Sources/Presentation/Camera/CameraDisplayViewController.swift index 1f87b607c..9d2e26e59 100644 --- a/14th-team5-iOS/App/Sources/Presentation/Camera/CameraDisplayViewController.swift +++ b/14th-team5-iOS/App/Sources/Presentation/Camera/CameraDisplayViewController.swift @@ -200,7 +200,7 @@ public final class CameraDisplayViewController: BaseViewController 8) } - .debounce(.milliseconds(300), scheduler: MainScheduler.instance) - .withUnretained(self) - .bind { owner, isShow in - guard isShow == true else { return } - owner.makeBibbiToastView(text: "8자까지 입력가능해요", image: DesignSystemAsset.warning.image, offset: 400) - }.disposed(by: disposeBag) + .filter{ $0.count > 8 } + .debounce(RxInterval._600milliseconds, scheduler: RxScheduler.main) + .map { _ in Reactor.Action.showInputTextError } + .bind(to: reactor.action) + .disposed(by: disposeBag) displayEditTextField.rx .text.orEmpty + .filter { !$0.contains(" ")} + .debounce(RxInterval._600milliseconds, scheduler: RxScheduler.main) .scan("") { previous, new -> String in if new.count > 8 { return previous @@ -290,7 +293,7 @@ public final class CameraDisplayViewController: BaseViewController Observable in + .withUnretained(self) + .flatMap { owner, entity -> Observable in if entity == nil { return .just(.setError(true)) } else { + owner.cameraDisplayNavigator.toHome() return .concat( .just(.setLoading(false)), .just(.setPostEntity(entity)), .just(.setLoading(true)), .just(.setError(false)), - self.provider.mainService.refreshMain() + owner.provider.mainService.refreshMain() .flatMap { _ in Observable.empty() } ) } @@ -176,6 +185,14 @@ public final class CameraDisplayViewReactor: Reactor { .just(.setDescription("")), .just(.setDisplayEditSection([])) ) + case .showInputTextError: + cameraDisplayNavigator.showToast() + return .empty() + + case let .showInputBlankTextError(displayText): + cameraDisplayNavigator.showWarningToast() + let generateText = displayText.trimmingCharacters(in: .whitespaces) + return .just(.setTrimedText(generateText)) } } @@ -202,6 +219,8 @@ public final class CameraDisplayViewReactor: Reactor { newState.displayPostEntity = entity case let .setError(isError): newState.isError = isError + case let .setTrimedText(displayText): + newState.displayText = displayText } return newState } diff --git a/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToast/BBToastConfiguration.swift b/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToast/BBToastConfiguration.swift index d58310b72..0c33cc656 100644 --- a/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToast/BBToastConfiguration.swift +++ b/14th-team5-iOS/Core/Sources/Bibbi/BBCommons/BBToast/BBToastConfiguration.swift @@ -84,12 +84,12 @@ private extension BBToastConfiguration { switch direction { case let .top(yOffset): return .custom( - transformation: CGAffineTransform(scaleX: 0.9, y: 0.9).translatedBy(x: 0, y: -yOffset - 100) + transformation: CGAffineTransform(scaleX: 0.9, y: 0.9).translatedBy(x: 0, y: -yOffset - 300) ) case let .bottom(yOffset): return .custom( - transformation: CGAffineTransform(scaleX: 0.9, y: 0.9).translatedBy(x: 0, y: +yOffset + 100) + transformation: CGAffineTransform(scaleX: 0.9, y: 0.9).translatedBy(x: 0, y: -yOffset + 300) ) case .center: