Skip to content

Commit

Permalink
feature: 화이트보드 화면을 나가면 관리중이던 오브젝트를 초기화하는 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
taipaise committed Dec 3, 2024
1 parent bfc892a commit 0630873
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,7 @@ public protocol ManageWhiteboardObjectUseCaseInterface {
whiteboardObjectID: UUID,
scale: CGFloat,
angle: CGFloat) async -> Bool

/// 화이트보드 오브젝트들을 모두 삭제합니다.
func removeAllWhiteboardObjects()
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public protocol WhiteboardObjectSetInterface {
/// - Parameter object: 삭제할 오브젝트
func remove(object: WhiteboardObject) async

/// 모든 화이트보드 오브젝트들을 삭제합니다.
func removeAll() async

/// 집합에 있는 오브젝트를 업데이트 합니다.
/// - Parameter object: 업데이트할 오브젝트
func update(object: WhiteboardObject) async
Expand Down
4 changes: 4 additions & 0 deletions Domain/Domain/Sources/Model/WhiteboardObjectSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ public final class ManageWhiteboardObjectUseCase: ManageWhiteboardObjectUseCaseI
}
}
}

public func removeAllWhiteboardObjects() {
Task {
await whiteboardObjectSet.removeAll()
}
}
}

extension ManageWhiteboardObjectUseCase: WhiteboardObjectRepositoryDelegate {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public final class WhiteboardViewController: UIViewController {
}

deinit {
viewModel.action(input: .removeAll)
configureTearDownObserver()
}

Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -146,6 +147,8 @@ public final class WhiteboardViewModel: ViewModel {
checkIsDeletionZoneEnable(with: point, deletionZone: deletionZone)
case .dragObject(let point):
dragObject(to: point)
case .removeAll:
removeAllWhiteboardObjects()
}
}

Expand Down Expand Up @@ -302,4 +305,8 @@ public final class WhiteboardViewModel: ViewModel {
}
.store(in: &cancellables)
}

private func removeAllWhiteboardObjects() {
manageWhiteboardObjectUseCase.removeAllWhiteboardObjects()
}
}

0 comments on commit 0630873

Please sign in to comment.