diff --git a/Domain/Domain/Sources/Interface/UseCase/ManageWhiteboardObjectUseCaseInterface.swift b/Domain/Domain/Sources/Interface/UseCase/ManageWhiteboardObjectUseCaseInterface.swift index a0918e6..0342aab 100644 --- a/Domain/Domain/Sources/Interface/UseCase/ManageWhiteboardObjectUseCaseInterface.swift +++ b/Domain/Domain/Sources/Interface/UseCase/ManageWhiteboardObjectUseCaseInterface.swift @@ -75,4 +75,7 @@ public protocol ManageWhiteboardObjectUseCaseInterface { whiteboardObjectID: UUID, scale: CGFloat, angle: CGFloat) async -> Bool + + /// 화이트보드 오브젝트들을 모두 삭제합니다. + func removeAllWhiteboardObjects() } diff --git a/Domain/Domain/Sources/Interface/WhiteboardObjectSetInterface.swift b/Domain/Domain/Sources/Interface/WhiteboardObjectSetInterface.swift index 4b4d70d..98b7cec 100644 --- a/Domain/Domain/Sources/Interface/WhiteboardObjectSetInterface.swift +++ b/Domain/Domain/Sources/Interface/WhiteboardObjectSetInterface.swift @@ -22,6 +22,9 @@ public protocol WhiteboardObjectSetInterface { /// - Parameter object: 삭제할 오브젝트 func remove(object: WhiteboardObject) async + /// 모든 화이트보드 오브젝트들을 삭제합니다. + func removeAll() async + /// 집합에 있는 오브젝트를 업데이트 합니다. /// - Parameter object: 업데이트할 오브젝트 func update(object: WhiteboardObject) async diff --git a/Domain/Domain/Sources/Model/WhiteboardObjectSet.swift b/Domain/Domain/Sources/Model/WhiteboardObjectSet.swift index 378b495..2e82c38 100644 --- a/Domain/Domain/Sources/Model/WhiteboardObjectSet.swift +++ b/Domain/Domain/Sources/Model/WhiteboardObjectSet.swift @@ -26,6 +26,10 @@ public actor WhiteboardObjectSet: WhiteboardObjectSetInterface { whiteboardObjects.remove(object) } + public func removeAll() async { + whiteboardObjects.removeAll() + } + public func update(object: WhiteboardObject) { remove(object: object) insert(object: object) diff --git a/Domain/Domain/Sources/UseCase/ManageWhiteboardObjectUseCase.swift b/Domain/Domain/Sources/UseCase/ManageWhiteboardObjectUseCase.swift index 0ac737f..bcd3dfd 100644 --- a/Domain/Domain/Sources/UseCase/ManageWhiteboardObjectUseCase.swift +++ b/Domain/Domain/Sources/UseCase/ManageWhiteboardObjectUseCase.swift @@ -175,6 +175,12 @@ public final class ManageWhiteboardObjectUseCase: ManageWhiteboardObjectUseCaseI } } } + + public func removeAllWhiteboardObjects() { + Task { + await whiteboardObjectSet.removeAll() + } + } } extension ManageWhiteboardObjectUseCase: WhiteboardObjectRepositoryDelegate { diff --git a/Presentation/Presentation/Sources/Whiteboard/View/WhiteboardViewController.swift b/Presentation/Presentation/Sources/Whiteboard/View/WhiteboardViewController.swift index 634f16d..614ecd7 100644 --- a/Presentation/Presentation/Sources/Whiteboard/View/WhiteboardViewController.swift +++ b/Presentation/Presentation/Sources/Whiteboard/View/WhiteboardViewController.swift @@ -60,6 +60,7 @@ public final class WhiteboardViewController: UIViewController { } deinit { + viewModel.action(input: .removeAll) configureTearDownObserver() } @@ -270,6 +271,7 @@ public final class WhiteboardViewController: UIViewController { let objectViewPanGeture: UIPanGestureRecognizer objectViewPanGeture = UIPanGestureRecognizer(target: self, action: #selector(handleMoveObjectView)) objectView.addGestureRecognizer(objectViewPanGeture) + objectViewPanGeture.isEnabled = false canvasView.addSubview(objectView) } diff --git a/Presentation/Presentation/Sources/Whiteboard/ViewModel/WhiteboardViewModel.swift b/Presentation/Presentation/Sources/Whiteboard/ViewModel/WhiteboardViewModel.swift index 7162952..c89afee 100644 --- a/Presentation/Presentation/Sources/Whiteboard/ViewModel/WhiteboardViewModel.swift +++ b/Presentation/Presentation/Sources/Whiteboard/ViewModel/WhiteboardViewModel.swift @@ -30,6 +30,7 @@ public final class WhiteboardViewModel: ViewModel { case checkIsDeletion(point: CGPoint, deletionZone: CGRect) case dragObject(point: CGPoint) case changeObjectPosition(point: CGPoint) + case removeAll } struct Output { @@ -146,6 +147,8 @@ public final class WhiteboardViewModel: ViewModel { checkIsDeletionZoneEnable(with: point, deletionZone: deletionZone) case .dragObject(let point): dragObject(to: point) + case .removeAll: + removeAllWhiteboardObjects() } } @@ -302,4 +305,8 @@ public final class WhiteboardViewModel: ViewModel { } .store(in: &cancellables) } + + private func removeAllWhiteboardObjects() { + manageWhiteboardObjectUseCase.removeAllWhiteboardObjects() + } }