Skip to content

Commit

Permalink
[#59]Enhance: 멈춤 뷰 add, remove에서 hidden으로 수정
Browse files Browse the repository at this point in the history
- 이벤트가 자주 발생할 수 있어서 바꿈
- 필요없는 코드 삭제
- 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.
  • Loading branch information
Minny27 authored and ibcylon committed Feb 2, 2024
1 parent fd49f76 commit 782420d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 56 deletions.
9 changes: 3 additions & 6 deletions Projects/Features/Chat/Src/Room/ChatRoomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import UIKit

import Core
import DSKit

final class ChatRoomView: TFBaseView {
Expand All @@ -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)
Expand All @@ -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) {
Expand Down
18 changes: 0 additions & 18 deletions Projects/Features/Chat/Src/Room/ChatRoomViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -36,6 +39,10 @@ final class FallingUserCollectionViewCell: UserCardViewCollectionViewCell {
$0.height.equalTo(32)
}

self.pauseView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

self.showDimView()
}

Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 }
Expand All @@ -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()
}
}
}
}
16 changes: 16 additions & 0 deletions Projects/Features/Falling/Src/Subviews/PauseView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
// }
// }
}

0 comments on commit 782420d

Please sign in to comment.