From 782420d5071ef5dbb6cf24da7dc592b6368d9a47 Mon Sep 17 00:00:00 2001 From: LeeSeungmin Date: Thu, 1 Feb 2024 22:44:08 +0900 Subject: [PATCH] =?UTF-8?q?[#59]Enhance:=20=EB=A9=88=EC=B6=A4=20=EB=B7=B0?= =?UTF-8?q?=20add,=20remove=EC=97=90=EC=84=9C=20hidden=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 이벤트가 자주 발생할 수 있어서 바꿈 - 필요없는 코드 삭제 - pauseview를 collection view cell에 직접 추가 - isTimerActive를 hidden과 바인딩 Fix: convert notification to keyboardLayoutGuide Revert "Fix: convert notification to keyboardLayoutGuide" This reverts commit 2b1647182c8121d199344d8ed7ed2d81f11dbfa9. Revert "Fix: convert notification to keyboardLayoutGuide" This reverts commit 2b1647182c8121d199344d8ed7ed2d81f11dbfa9. --- .../Features/Chat/Src/Room/ChatRoomView.swift | 9 +++---- .../Src/Room/ChatRoomViewController.swift | 18 ------------- .../Cell/FallingUserCollectionViewCell.swift | 15 ++++++----- .../Cell/UserCardViewCollectionViewCell.swift | 26 +------------------ .../Falling/Src/Subviews/PauseView.swift | 16 ++++++++++++ 5 files changed, 28 insertions(+), 56 deletions(-) diff --git a/Projects/Features/Chat/Src/Room/ChatRoomView.swift b/Projects/Features/Chat/Src/Room/ChatRoomView.swift index d1b40e4f..0a68f98a 100644 --- a/Projects/Features/Chat/Src/Room/ChatRoomView.swift +++ b/Projects/Features/Chat/Src/Room/ChatRoomView.swift @@ -7,7 +7,6 @@ import UIKit -import Core import DSKit final class ChatRoomView: TFBaseView { @@ -18,8 +17,6 @@ final class ChatRoomView: TFBaseView { lazy var topicBar = TFTopicBannerView() private(set) lazy var chatInputView = ChatInputView() - var bottomConstraint: NSLayoutConstraint? - lazy var collectionView: UICollectionView = { let layout = UICollectionViewCompositionalLayout.listLayoutAutomaticHeight(withEstimatedHeight: 50) let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout) @@ -40,14 +37,14 @@ final class ChatRoomView: TFBaseView { collectionView.snp.makeConstraints { $0.top.equalTo(topicBar.snp.bottom) - $0.leading.trailing.bottom.equalToSuperview() + $0.leading.trailing.equalToSuperview() } chatInputView.snp.makeConstraints { + $0.top.equalTo(collectionView.snp.bottom) $0.leading.trailing.equalToSuperview() $0.height.equalTo(50).priority(.low) } - bottomConstraint = chatInputView.bottomAnchor.constraint(equalTo: self.safeAreaLayoutGuide.bottomAnchor) - bottomConstraint?.isActive = true + chatInputView.bottomAnchor.constraint(equalTo: self.keyboardLayoutGuide.topAnchor).isActive = true } func topicBind(_ title: String, _ content: String) { diff --git a/Projects/Features/Chat/Src/Room/ChatRoomViewController.swift b/Projects/Features/Chat/Src/Room/ChatRoomViewController.swift index 9b456f0c..9acd865c 100644 --- a/Projects/Features/Chat/Src/Room/ChatRoomViewController.swift +++ b/Projects/Features/Chat/Src/Room/ChatRoomViewController.swift @@ -16,11 +16,6 @@ final class ChatRoomViewController: TFBaseViewController { private let viewModel: ChatRoomViewModel private var dataSource: DataSource! - private lazy var keyboardHandler: KeyboardHandler = DefaultKeyboardHandler( - parentVC: self, - bottomConstraint: self.mainView.bottomConstraint - ) - init(viewModel: ChatRoomViewModel) { self.viewModel = viewModel super.init(nibName: nil, bundle: nil) @@ -41,19 +36,6 @@ final class ChatRoomViewController: TFBaseViewController { navigationItem.rightBarButtonItems = [self.mainView.reportButton, self.mainView.exitButton] } - override func viewDidAppear(_ animated: Bool) { - super.viewDidAppear(animated) - - keyboardHandler.start() - } - - override func viewDidDisappear(_ animated: Bool) { - super.viewDidDisappear(animated) - - keyboardHandler.stop() - } - - override func bindViewModel() { self.setupDataSource() diff --git a/Projects/Features/Falling/Src/Subviews/Cell/FallingUserCollectionViewCell.swift b/Projects/Features/Falling/Src/Subviews/Cell/FallingUserCollectionViewCell.swift index 9bcb72df..2647077e 100644 --- a/Projects/Features/Falling/Src/Subviews/Cell/FallingUserCollectionViewCell.swift +++ b/Projects/Features/Falling/Src/Subviews/Cell/FallingUserCollectionViewCell.swift @@ -21,11 +21,14 @@ final class FallingUserCollectionViewCell: UserCardViewCollectionViewCell { lazy var cardTimeView = CardTimeView() + private lazy var pauseView = PauseView(frame: cellFrame) + override func makeUI() { self.layer.cornerRadius = 20 self.contentView.addSubview(profileCarouselView) self.profileCarouselView.addSubview(cardTimeView) + self.profileCarouselView.addSubview(pauseView) self.profileCarouselView.snp.makeConstraints { $0.edges.equalToSuperview() @@ -36,6 +39,10 @@ final class FallingUserCollectionViewCell: UserCardViewCollectionViewCell { $0.height.equalTo(32) } + self.pauseView.snp.makeConstraints { + $0.edges.equalToSuperview() + } + self.showDimView() } @@ -75,13 +82,7 @@ final class FallingUserCollectionViewCell: UserCardViewCollectionViewCell { .disposed(by: disposeBag) output.isTimerActive - .drive(with: self) { owner, value in - if value { - owner.hiddenPauseView() - } else { - owner.showPauseView() - } - } + .drive(pauseView.rx.isHidden) .disposed(by: disposeBag) profileCarouselView.infoButton.rx.tap.asDriver() diff --git a/Projects/Features/Falling/Src/Subviews/Cell/UserCardViewCollectionViewCell.swift b/Projects/Features/Falling/Src/Subviews/Cell/UserCardViewCollectionViewCell.swift index 9fdeeded..bd65e747 100644 --- a/Projects/Features/Falling/Src/Subviews/Cell/UserCardViewCollectionViewCell.swift +++ b/Projects/Features/Falling/Src/Subviews/Cell/UserCardViewCollectionViewCell.swift @@ -10,7 +10,7 @@ import UIKit import DSKit open class UserCardViewCollectionViewCell: TFBaseCollectionViewCell { - private let cellFrame = CGRect( + let cellFrame = CGRect( x: 0, y: 0, width: (UIWindow.keyWindow?.bounds.width ?? .zero) - 32, @@ -19,8 +19,6 @@ open class UserCardViewCollectionViewCell: TFBaseCollectionViewCell { private lazy var dimView = UIView(frame: cellFrame) - private lazy var pauseView = PauseView(frame: cellFrame) - public func showDimView() { DispatchQueue.main.async { [weak self] in guard let self = self else { return } @@ -42,26 +40,4 @@ open class UserCardViewCollectionViewCell: TFBaseCollectionViewCell { } } } - - public func showPauseView() { - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - self.addSubview(pauseView) - UIView.animate(withDuration: 0.0) { - self.pauseView.backgroundColor = DSKitAsset.Color.blur.color - } - } - } - - public func hiddenPauseView() { - DispatchQueue.main.async { [weak self] in - guard let self = self else { return } - UIView.animate(withDuration: 0.0) { - self.pauseView.backgroundColor = DSKitAsset.Color.clear.color - } completion: { [weak self] _ in - guard let self = self else { return } - self.pauseView.removeFromSuperview() - } - } - } } diff --git a/Projects/Features/Falling/Src/Subviews/PauseView.swift b/Projects/Features/Falling/Src/Subviews/PauseView.swift index 8e16bd80..cabb03a7 100644 --- a/Projects/Features/Falling/Src/Subviews/PauseView.swift +++ b/Projects/Features/Falling/Src/Subviews/PauseView.swift @@ -73,6 +73,8 @@ open class PauseView: TFBaseView { }() open override func makeUI() { + self.isHidden = true + self.addSubview(blurView) self.blurView.contentView.addSubview(stackView) self.blurView.contentView.addSubview(resumeLabel) @@ -99,4 +101,18 @@ open class PauseView: TFBaseView { $0.centerX.centerY.equalToSuperview() } } + +// public func show() { +// UIView.animate(withDuration: 0.2) { [weak self] in +// guard let self = self else { return } +// self.isHidden = false +// } +// } +// +// public func hidden() { +// UIView.animate(withDuration: 0.2) { [weak self] in +// guard let self = self else { return } +// self.isHidden = true +// } +// } }