-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from boostcampwm-2024/feature/manageWhiteboard
[Feature] 화이트 보드 오브젝트/도구 관리 유즈케이스 추가
- Loading branch information
Showing
17 changed files
with
515 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Domain/Domain/Sources/Interface/UseCase/ManageWhiteboardObjectUseCaseInterface.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ManageWhiteboardObjectUseCaseInterface.swift | ||
// Domain | ||
// | ||
// Created by 이동현 on 11/16/24. | ||
// | ||
|
||
import Combine | ||
|
||
public protocol ManageWhiteboardObjectUseCaseInterface { | ||
/// 화이트보드 객체가 추가될 때 이벤트를 방출합니다. | ||
var addedObjectPublisher: AnyPublisher<WhiteboardObject, Never> { get } | ||
|
||
/// 화이트보드 객체가 수정될 때 이벤트를 방출합니다. | ||
var updatedObjectPublisher: AnyPublisher<WhiteboardObject, Never> { get } | ||
|
||
/// 화이트보드 객체가 제거될 때 이벤트를 방출합니다. | ||
var removedObjectPublisher: AnyPublisher<WhiteboardObject, Never> { get } | ||
|
||
/// 화이트보드 객체를 추가하는 메서드 | ||
/// - Parameter whiteboardObject: 추가할 화이트보드 객체 | ||
/// - Returns: 추가 성공 여부 | ||
func addObject(whiteboardObject: WhiteboardObject) -> Bool | ||
|
||
/// 화이트보드 객체를 수정하는 메서드 | ||
/// - Parameter whiteboardObject: 수정할 화이트보드 객체 | ||
/// - Returns: 추가 성공 여부 | ||
func updateObject(whiteboardObject: WhiteboardObject) -> Bool | ||
|
||
/// 화이트보드를 제거하는 메서드 | ||
/// - Returns: 추가 성공 여부 | ||
func removeObject(whiteboardObject: WhiteboardObject) -> Bool | ||
} |
24 changes: 24 additions & 0 deletions
24
Domain/Domain/Sources/Interface/UseCase/ManageWhiteboardToolUseCaseInterface.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// ManageWhiteboardToolUseCaseInterface.swift | ||
// Domain | ||
// | ||
// Created by 이동현 on 11/16/24. | ||
// | ||
|
||
import Combine | ||
|
||
public protocol ManageWhiteboardToolUseCaseInterface { | ||
/// 화이트보드 도구 선택/선택 해제 시 이벤트를 방출합니다. | ||
var currentToolPublisher: AnyPublisher<WhiteboardTool?, Never> { get } | ||
|
||
/// 현재 사용중인 화이트보드 도구를 반환합니다. | ||
/// - Returns: 사용중인 화이트보드 도구 | ||
func currentTool() -> WhiteboardTool? | ||
|
||
/// 화이트보드 도구를 선택합니다. | ||
/// - Parameter tool: 선택할 화이트보드 도구 | ||
func selectTool(tool: WhiteboardTool) | ||
|
||
/// 화이트보드 도구 사용을 완료합니다. | ||
func finishUsingTool() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// WhiteboardTool.swift | ||
// Domain | ||
// | ||
// Created by 이동현 on 11/16/24. | ||
// | ||
|
||
@frozen | ||
public enum WhiteboardTool: CaseIterable { | ||
case drawing | ||
case text | ||
case photo | ||
case game | ||
case chat | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Domain/Domain/Sources/UseCase/ManageWhiteboardObjectUseCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// ManageWhiteboardObjectUseCase.swift | ||
// Domain | ||
// | ||
// Created by 이동현 on 11/16/24. | ||
// | ||
|
||
import Combine | ||
|
||
public final class ManageWhiteboardObjectUseCase: ManageWhiteboardObjectUseCaseInterface { | ||
public var addedObjectPublisher: AnyPublisher<WhiteboardObject, Never> | ||
public var updatedObjectPublisher: AnyPublisher<WhiteboardObject, Never> | ||
public var removedObjectPublisher: AnyPublisher<WhiteboardObject, Never> | ||
private var whiteboardObjects: [WhiteboardObject] | ||
|
||
private let addedWhiteboardSubject: PassthroughSubject<WhiteboardObject, Never> | ||
private let updatedWhiteboardSubject: PassthroughSubject<WhiteboardObject, Never> | ||
private let removedWhiteboardSubject: PassthroughSubject<WhiteboardObject, Never> | ||
|
||
public init() { | ||
addedWhiteboardSubject = PassthroughSubject<WhiteboardObject, Never>() | ||
updatedWhiteboardSubject = PassthroughSubject<WhiteboardObject, Never>() | ||
removedWhiteboardSubject = PassthroughSubject<WhiteboardObject, Never>() | ||
|
||
whiteboardObjects = [] | ||
|
||
addedObjectPublisher = addedWhiteboardSubject.eraseToAnyPublisher() | ||
updatedObjectPublisher = updatedWhiteboardSubject.eraseToAnyPublisher() | ||
removedObjectPublisher = removedWhiteboardSubject.eraseToAnyPublisher() | ||
} | ||
|
||
public func addObject(whiteboardObject: WhiteboardObject) -> Bool { | ||
guard !whiteboardObjects.contains(whiteboardObject) else { return false } | ||
whiteboardObjects.append(whiteboardObject) | ||
addedWhiteboardSubject.send(whiteboardObject) | ||
return true | ||
} | ||
|
||
public func updateObject(whiteboardObject: WhiteboardObject) -> Bool { | ||
guard let index = whiteboardObjects.firstIndex(where: { $0 == whiteboardObject }) else { return false } | ||
whiteboardObjects[index] = whiteboardObject | ||
updatedWhiteboardSubject.send(whiteboardObject) | ||
return true | ||
} | ||
|
||
public func removeObject(whiteboardObject: WhiteboardObject) -> Bool { | ||
guard whiteboardObjects.contains(whiteboardObject) else { return false } | ||
whiteboardObjects.removeAll { $0 == whiteboardObject } | ||
removedWhiteboardSubject.send(whiteboardObject) | ||
return true | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Domain/Domain/Sources/UseCase/ManageWhiteboardToolUseCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// ManageWhiteboardToolUseCase.swift | ||
// Domain | ||
// | ||
// Created by 이동현 on 11/16/24. | ||
// | ||
|
||
import Combine | ||
|
||
public final class ManageWhiteboardToolUseCase: ManageWhiteboardToolUseCaseInterface { | ||
public var currentToolPublisher: AnyPublisher<WhiteboardTool?, Never> | ||
private let currentToolSubject: CurrentValueSubject<WhiteboardTool?, Never> | ||
|
||
public init() { | ||
currentToolSubject = CurrentValueSubject<WhiteboardTool?, Never>(nil) | ||
currentToolPublisher = currentToolSubject.eraseToAnyPublisher() | ||
} | ||
|
||
public func currentTool() -> WhiteboardTool? { | ||
return currentToolSubject.value | ||
} | ||
|
||
public func selectTool(tool: WhiteboardTool) { | ||
currentToolSubject.send(tool) | ||
} | ||
|
||
public func finishUsingTool() { | ||
currentToolSubject.send(nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.