From d5d2055656c7d46389b6c7bccb651c24517e5088 Mon Sep 17 00:00:00 2001 From: Dagyeong Choi Date: Tue, 26 Nov 2024 17:05:54 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feature:=20WhiteboardList=20=EC=83=88?= =?UTF-8?q?=EB=A1=9C=EA=B3=A0=EC=B9=A8=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20=EB=B0=8F=20=EB=8B=A4=ED=81=AC=EB=AA=A8=EB=93=9C=20?= =?UTF-8?q?=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Interface/NearbyNetworkInterface.swift | 3 +++ .../Repository/WhiteboardRepository.swift | 4 ++++ .../WhiteboardRepositoryInterface.swift | 3 +++ .../UseCase/WhiteboardUseCaseInterface.swift | 3 +++ .../Sources/UseCase/WhiteboardUseCase.swift | 4 ++++ .../Sources/NearbyNetworkService.swift | 8 ++++++++ .../WhiteboardList/View/WhiteboardCell.swift | 2 +- .../View/WhiteboardListViewController.swift | 17 ++++++++++++++++- .../ViewModel/WhiteboardListViewModel.swift | 7 +++++++ 9 files changed, 49 insertions(+), 2 deletions(-) diff --git a/DataSource/DataSource/Sources/Interface/NearbyNetworkInterface.swift b/DataSource/DataSource/Sources/Interface/NearbyNetworkInterface.swift index 5b00cea..cf0940d 100644 --- a/DataSource/DataSource/Sources/Interface/NearbyNetworkInterface.swift +++ b/DataSource/DataSource/Sources/Interface/NearbyNetworkInterface.swift @@ -17,6 +17,9 @@ public protocol NearbyNetworkInterface { /// 주변 기기 검색을 중지합니다. func stopSearching() + /// 주변 기기 검색을 중지 후 다시 시작합니다. + func restartSearching() + /// 주변에 내 기기를 정보와 함께 알립니다. /// - Parameter data: 담을 정보 func startPublishing(with info: [String: String]) diff --git a/DataSource/DataSource/Sources/Repository/WhiteboardRepository.swift b/DataSource/DataSource/Sources/Repository/WhiteboardRepository.swift index d9a2716..b65e9cb 100644 --- a/DataSource/DataSource/Sources/Repository/WhiteboardRepository.swift +++ b/DataSource/DataSource/Sources/Repository/WhiteboardRepository.swift @@ -55,6 +55,10 @@ public final class WhiteboardRepository: WhiteboardRepositoryInterface { nearbyNetwork.stopSearching() } + public func restartSearching() { + nearbyNetwork.restartSearching() + } + private func updatePublishingInfo(myProfile: Profile) { var newIconList: [String] = [] newIconList.append(myProfile.profileIcon.emoji) diff --git a/Domain/Domain/Sources/Interface/Repository/WhiteboardRepositoryInterface.swift b/Domain/Domain/Sources/Interface/Repository/WhiteboardRepositoryInterface.swift index 195fc83..3ddeadb 100644 --- a/Domain/Domain/Sources/Interface/Repository/WhiteboardRepositoryInterface.swift +++ b/Domain/Domain/Sources/Interface/Repository/WhiteboardRepositoryInterface.swift @@ -18,6 +18,9 @@ public protocol WhiteboardRepositoryInterface { /// 화이트보드 탐색을 중지합니다. func stopSearching() + + /// 화이트보드 탐색을 중단 후 다시 시작합니다. + func restartSearching() /// 선택한 화이트보드와 연결을 시도합니다. /// - Parameter whiteboard: 연결할 화이트보드 diff --git a/Domain/Domain/Sources/Interface/UseCase/WhiteboardUseCaseInterface.swift b/Domain/Domain/Sources/Interface/UseCase/WhiteboardUseCaseInterface.swift index 1e9177a..d8735a8 100644 --- a/Domain/Domain/Sources/Interface/UseCase/WhiteboardUseCaseInterface.swift +++ b/Domain/Domain/Sources/Interface/UseCase/WhiteboardUseCaseInterface.swift @@ -25,4 +25,7 @@ public protocol WhiteboardUseCaseInterface { /// 화이트보드 탐색을 중지합니다. func stopSearchingWhiteboard() + + /// 화이트보드 탐색을 중단 후 다시 시작합니다. + func refreshWhiteboardList() } diff --git a/Domain/Domain/Sources/UseCase/WhiteboardUseCase.swift b/Domain/Domain/Sources/UseCase/WhiteboardUseCase.swift index 97b4482..5a5267a 100644 --- a/Domain/Domain/Sources/UseCase/WhiteboardUseCase.swift +++ b/Domain/Domain/Sources/UseCase/WhiteboardUseCase.swift @@ -50,6 +50,10 @@ public final class WhiteboardUseCase: WhiteboardUseCaseInterface { let profile = profileRepository.loadProfile() try whiteboardRepository.joinWhiteboard(whiteboard: whiteboard, myProfile: profile) } + + public func refreshWhiteboardList() { + whiteboardRepository.restartSearching() + } } extension WhiteboardUseCase: WhiteboardRepositoryDelegate { diff --git a/NearbyNetwork/NearbyNetwork/Sources/NearbyNetworkService.swift b/NearbyNetwork/NearbyNetwork/Sources/NearbyNetworkService.swift index ac1a69b..7945a99 100644 --- a/NearbyNetwork/NearbyNetwork/Sources/NearbyNetworkService.swift +++ b/NearbyNetwork/NearbyNetwork/Sources/NearbyNetworkService.swift @@ -53,6 +53,14 @@ extension NearbyNetworkService: NearbyNetworkInterface { serviceBrowser.stopBrowsingForPeers() } + public func restartSearching() { + serialQueue.sync { + serviceBrowser.stopBrowsingForPeers() + foundPeers.removeAll() + serviceBrowser.startBrowsingForPeers() + } + } + public func startPublishing(with info: [String: String]) { isHost = true serviceAdvertiser.stopAdvertisingPeer() diff --git a/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardCell.swift b/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardCell.swift index ccd8e3b..87ebfc4 100644 --- a/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardCell.swift +++ b/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardCell.swift @@ -28,7 +28,7 @@ class WhiteboardCell: UICollectionViewCell { private let titleLabel: UILabel = { let label = UILabel() label.font = AirplainFont.Subtitle2 - label.textColor = .airplainBlack + label.textColor = .black return label }() diff --git a/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardListViewController.swift b/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardListViewController.swift index c222bab..da729bb 100644 --- a/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardListViewController.swift +++ b/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardListViewController.swift @@ -56,6 +56,7 @@ public final class WhiteboardListViewController: UIViewController { }() private let collectionView = UICollectionView(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout()) + private let refreshControl = UIRefreshControl() private var dataSource: UICollectionViewDiffableDataSource? private let viewModel: WhiteboardListViewModel private var cancellables = Set() @@ -171,8 +172,14 @@ public final class WhiteboardListViewController: UIViewController { private func configureCollectionView() { collectionView.delegate = self collectionView.collectionViewLayout = createCollectionViewLayout() - collectionView.backgroundColor = .white + collectionView.backgroundColor = .systemBackground collectionView.register(WhiteboardCell.self, forCellWithReuseIdentifier: WhiteboardCell.reuseIdentifier) + + let refreshAction = UIAction { [weak self] _ in + self?.refreshWhiteboardList() + } + refreshControl.addAction(refreshAction, for: .valueChanged) + collectionView.refreshControl = refreshControl } private func createCollectionViewLayout() -> UICollectionViewLayout { @@ -237,6 +244,7 @@ public final class WhiteboardListViewController: UIViewController { guard let dataSource = dataSource else { return } dataSource.apply(snapshot, animatingDifferences: true) } + private func bind() { viewModel.output.whiteboardPublisher .receive(on: DispatchQueue.main) @@ -253,6 +261,13 @@ public final class WhiteboardListViewController: UIViewController { } .store(in: &cancellables) } + + private func refreshWhiteboardList() { + viewModel.action(input: .refreshWhiteboardList) + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in + self?.refreshControl.endRefreshing() + } + } } // MARK: - UICollectionViewDelegate diff --git a/Presentation/Presentation/Sources/WhiteboardList/ViewModel/WhiteboardListViewModel.swift b/Presentation/Presentation/Sources/WhiteboardList/ViewModel/WhiteboardListViewModel.swift index 28e23f8..558a58d 100644 --- a/Presentation/Presentation/Sources/WhiteboardList/ViewModel/WhiteboardListViewModel.swift +++ b/Presentation/Presentation/Sources/WhiteboardList/ViewModel/WhiteboardListViewModel.swift @@ -18,6 +18,7 @@ public final class WhiteboardListViewModel: ViewModel { case searchWhiteboard case joinWhiteboard(whiteboard: Whiteboard) case stopSearchingWhiteboard + case refreshWhiteboardList } struct Output { @@ -46,6 +47,8 @@ public final class WhiteboardListViewModel: ViewModel { joinWhiteboard(whiteboard: whiteboard) case .stopSearchingWhiteboard: stopSearchingWhiteboard() + case .refreshWhiteboardList: + refreshWhiteboardList() } } @@ -70,4 +73,8 @@ public final class WhiteboardListViewModel: ViewModel { private func stopSearchingWhiteboard() { whiteboardUseCase.stopSearchingWhiteboard() } + + private func refreshWhiteboardList() { + whiteboardUseCase.refreshWhiteboardList() + } } From 2df87828ac991f6627f84f24faa07c684217738d Mon Sep 17 00:00:00 2001 From: Dagyeong Choi Date: Tue, 26 Nov 2024 17:46:02 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=EB=8B=A4=ED=81=AC=EB=AA=A8=EB=93=9C?= =?UTF-8?q?=20=EC=83=89=EC=83=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/WhiteboardList/View/WhiteboardCell.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardCell.swift b/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardCell.swift index 87ebfc4..37b7bd3 100644 --- a/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardCell.swift +++ b/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardCell.swift @@ -28,7 +28,9 @@ class WhiteboardCell: UICollectionViewCell { private let titleLabel: UILabel = { let label = UILabel() label.font = AirplainFont.Subtitle2 - label.textColor = .black + let originColor = UIColor(named: "AirplainBlack") ?? .black + let resolvedColor = originColor.resolvedColor(with: UITraitCollection(userInterfaceStyle: .light)) + label.textColor = resolvedColor return label }() From e398f47cd91eecdd7d55da1614c627f80e87e9dd Mon Sep 17 00:00:00 2001 From: Dagyeong Choi Date: Tue, 26 Nov 2024 17:53:25 +0900 Subject: [PATCH 3/3] =?UTF-8?q?style:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WhiteboardList/View/WhiteboardListViewController.swift | 7 ------- .../WhiteboardList/ViewModel/WhiteboardListViewModel.swift | 2 -- 2 files changed, 9 deletions(-) diff --git a/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardListViewController.swift b/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardListViewController.swift index da729bb..d1f7978 100644 --- a/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardListViewController.swift +++ b/Presentation/Presentation/Sources/WhiteboardList/View/WhiteboardListViewController.swift @@ -246,13 +246,6 @@ public final class WhiteboardListViewController: UIViewController { } private func bind() { - viewModel.output.whiteboardPublisher - .receive(on: DispatchQueue.main) - .sink { _ in - // TODO: 화이트보드 추가 - } - .store(in: &cancellables) - viewModel.output.whiteboardListPublisher .receive(on: DispatchQueue.main) .sink { [weak self] whiteboards in diff --git a/Presentation/Presentation/Sources/WhiteboardList/ViewModel/WhiteboardListViewModel.swift b/Presentation/Presentation/Sources/WhiteboardList/ViewModel/WhiteboardListViewModel.swift index 558a58d..1d340db 100644 --- a/Presentation/Presentation/Sources/WhiteboardList/ViewModel/WhiteboardListViewModel.swift +++ b/Presentation/Presentation/Sources/WhiteboardList/ViewModel/WhiteboardListViewModel.swift @@ -22,7 +22,6 @@ public final class WhiteboardListViewModel: ViewModel { } struct Output { - let whiteboardPublisher: AnyPublisher let whiteboardListPublisher: AnyPublisher<[Whiteboard], Never> } @@ -33,7 +32,6 @@ public final class WhiteboardListViewModel: ViewModel { self.whiteboardUseCase = whiteboardUseCase whiteboardSubject = PassthroughSubject() self.output = Output( - whiteboardPublisher: whiteboardSubject.eraseToAnyPublisher(), whiteboardListPublisher: whiteboardUseCase.whiteboardListPublisher) }