Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Like animation #80

Merged
merged 13 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions Projects/Features/Falling/Src/Home/FallingHomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ final class FallingHomeViewController: TFBaseViewController {
})

dataSource.supplementaryViewProvider = { (view, kind, index) in
return self.homeView.collectionView.dequeueConfiguredReusableSupplementary(
return view.dequeueConfiguredReusableSupplementary(
using: footerRegistration,
for: index
)
Expand Down Expand Up @@ -177,39 +177,37 @@ final class FallingHomeViewController: TFBaseViewController {
alertContentView.photoTheftButton.rx.tap.asDriver(),
alertContentView.profanityButton.rx.tap.asDriver(),
alertContentView.sharingIllegalFootageButton.rx.tap.asDriver())
.do { _ in
.drive(with: self, onNext: { owner, _ in
complaintsButtonTapTrigger.accept(())

self.homeView.makeToast("신고하기가 완료되었습니다. 해당 사용자와\n서로 차단되며, 신고 사유는 검토 후 처리됩니다.", duration: 3.0, position: .bottom)
owner.homeView.makeToast("신고하기가 완료되었습니다. 해당 사용자와\n서로 차단되며, 신고 사유는 검토 후 처리됩니다.", duration: 3.0, position: .bottom)

UIWindow.keyWindow?.rootViewController?.dismiss(animated: false)
}
.drive()
})
.disposed(by: disposeBag)

reportButtonTapTriggerObserver.asDriverOnErrorJustEmpty()
.do { _ in
self.showAlert(
.drive(with: self) { owner, _ in
owner.showAlert(
topActionTitle: "신고하기",
bottomActionTitle: "차단하기",
dimColor: DSKitAsset.Color.clear.color,
topActionCompletion: {
self.showAlert(
contentView: self.alertContentView,
owner.showAlert(
contentView: owner.alertContentView,
topActionTitle: nil,
dimColor: DSKitAsset.Color.clear.color,
bottomActionCompletion: { timerActiveRelay.accept(true) },
dimActionCompletion: { timerActiveRelay.accept(true) }
)
},
bottomActionCompletion: {
self.showAlert(
owner.showAlert(
action: .block,
dimColor: DSKitAsset.Color.clear.color,
topActionCompletion: {
blockButtonTapTrigger.accept(())

self.homeView.makeToast("차단하기가 완료되었습니다. 해당 사용자와\n서로 차단되며 설정에서 확인 가능합니다.", duration: 3.0, position: .bottom)
owner.homeView.makeToast("차단하기가 완료되었습니다. 해당 사용자와\n서로 차단되며 설정에서 확인 가능합니다.", duration: 3.0, position: .bottom)
},
bottomActionCompletion: { timerActiveRelay.accept(true) },
dimActionCompletion: { timerActiveRelay.accept(true) }
Expand All @@ -218,21 +216,19 @@ final class FallingHomeViewController: TFBaseViewController {
dimActionCompletion: { timerActiveRelay.accept(true) }
)
}
.drive()
.disposed(by: disposeBag)

Driver.merge(output.complaintsAction, output.blockAction)
.do { indexPath in
guard let _ = self.homeView.collectionView.cellForItem(at: indexPath) as? FallingUserCollectionViewCell else { return }
.drive(with: self, onNext: { owner, indexPath in
guard let _ = owner.homeView.collectionView.cellForItem(at: indexPath) as? FallingUserCollectionViewCell else { return }

self.deleteItems(indexPath)
owner.deleteItems(indexPath)

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
timeOverSubject.onNext(.delete)
timerActiveRelay.accept(true)
}
}
.drive()
})
.disposed(by: disposeBag)
}
}
Expand Down
19 changes: 0 additions & 19 deletions Projects/Features/Falling/Src/Subviews/CardCircleTimerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,5 @@ final class CardCircleTimerView: TFBaseView {
gradientLayer.mask = trackLayer

layer.addSublayer(gradientLayer)

// // 그라디언트 방향 애니메이션 설정
// let startPointAnimation = CABasicAnimation(keyPath: "startPoint")
// startPointAnimation.fromValue = CGPoint(x: 0.5, y: 0.0)
// startPointAnimation.toValue = CGPoint(x: 0.5, y: 1.0)
//
// let endPointAnimation = CABasicAnimation(keyPath: "endPoint")
// endPointAnimation.fromValue = CGPoint(x: 0.5, y: 1.0)
// endPointAnimation.toValue = CGPoint(x: 0.5, y: 0.0)
//
// // 애니메이션 설정 (동일한 타이밍으로 적용)
// let animationGroup = CAAnimationGroup()
// animationGroup.animations = [startPointAnimation, endPointAnimation]
// animationGroup.duration = 2.0
// animationGroup.autoreverses = true
// animationGroup.repeatCount = .infinity
//
// // 그라디언트 레이어에 애니메이션 추가
// gradientLayer.add(animationGroup, forKey: "gradientMove")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ final class FallingUserCollectionViewCell: TFBaseCollectionViewCell {
.disposed(by: disposeBag)

output.rejectButtonAction
.throttle(.milliseconds(5000), latest: false)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

유저 좋아요, 싫어요 최근 이벤트 후, 5초 딜레이 시켰습니다.

.compactMap { [weak self] _ in self?.indexPath }
.map { FallingCellButtonAction.reject($0) }
.drive(with: self) { owner, action in
Expand All @@ -205,6 +206,7 @@ final class FallingUserCollectionViewCell: TFBaseCollectionViewCell {
.disposed(by: disposeBag)

output.likeButtonAction
.throttle(.milliseconds(5000), latest: false)
.compactMap { [weak self] _ in self?.indexPath }
.map { FallingCellButtonAction.like($0) }
.drive(with: self) { owner, action in
Expand Down
89 changes: 38 additions & 51 deletions Projects/Features/Falling/Src/Subviews/DummyFooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,27 @@ import UIKit
import DSKit

final class DummyFooterView: UICollectionReusableView {
private let backgroundGradientLayer = CAGradientLayer()
private let borderGradientLayer = CAGradientLayer()
private let maskLayer = CAShapeLayer()

private lazy var cardTimeView = CardTimeView()

override init(frame: CGRect) {
super.init(frame: .zero)

configureUI()
layer.cornerRadius = 20
clipsToBounds = true

makeUI()
setupLayers()
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
override func layoutSubviews() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bounds가 설정된 다음에 layer의 frame을 할당하도록 수정했습니다.

layoutGradientLayers()
}

private func configureUI() {
layer.borderWidth = 1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

layer를 추가하는 것이다보니 borderWidth가 추가적으로 설정되는 문제가 있어 삭제했습니다.

layer.cornerRadius = 20
clipsToBounds = true
// backgroundColor = .blue
// layer.borderColor = UIColor.orange.cgColor

addGradientBackground()
addGradientBorder()
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func makeUI() {
Expand All @@ -43,51 +42,39 @@ final class DummyFooterView: UICollectionReusableView {
}
}

private func addGradientBackground() {
let gradientLayer = CAGradientLayer()
gradientLayer.frame = bounds

gradientLayer.colors = [
DSKitAsset.Color.DummyUserGradient.backgroundFirst.color,
DSKitAsset.Color.DummyUserGradient.backgroundSecond.color,
DSKitAsset.Color.DummyUserGradient.backgroundFirst.color
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cgColor가 아니면 색상이 적용되지 않는 문제가 있었습니다..

private func setupLayers() {
backgroundGradientLayer.colors = [
DSKitAsset.Color.DummyUserGradient.backgroundFirst.color.cgColor,
DSKitAsset.Color.DummyUserGradient.backgroundSecond.color.cgColor,
DSKitAsset.Color.DummyUserGradient.backgroundFirst.color.cgColor
]

gradientLayer.locations = [0.0, 0.5, 1.0]

gradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0)
gradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0)
backgroundGradientLayer.locations = [0.0, 0.5, 1.0]

// layer.addSublayer(gradientLayer)
backgroundGradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0)
backgroundGradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0)
layer.addSublayer(backgroundGradientLayer)

layer.insertSublayer(gradientLayer, at: 0)
borderGradientLayer.colors = [
DSKitAsset.Color.DummyUserGradient.borderFirst.color.cgColor,
DSKitAsset.Color.DummyUserGradient.borderSecond.color.cgColor
]

borderGradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0)
borderGradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0)
borderGradientLayer.mask = maskLayer
layer.addSublayer(borderGradientLayer)
}

private func addGradientBorder() {
let gradientLayer = CAGradientLayer()
gradientLayer.frame = bounds

gradientLayer.colors = [
DSKitAsset.Color.DummyUserGradient.borderFirst.color,
DSKitAsset.Color.DummyUserGradient.borderSecond.color
]

// gradientLayer.locations = [0.0, 0.5, 1.0]
private func layoutGradientLayers() {
backgroundGradientLayer.frame = bounds
borderGradientLayer.frame = bounds

gradientLayer.startPoint = CGPoint(x: 0.5, y: 1.0)
gradientLayer.endPoint = CGPoint(x: 0.5, y: 0.0)

let shapeLayer = CAShapeLayer()
let path = UIBezierPath(roundedRect: bounds, cornerRadius: layer.cornerRadius)
shapeLayer.path = path.cgPath
shapeLayer.lineWidth = 1
shapeLayer.fillColor = DSKitAsset.Color.LikeGradient.gradientFirst.color.cgColor
shapeLayer.strokeColor = DSKitAsset.Color.LikeGradient.gradientFirst.color.cgColor

gradientLayer.mask = shapeLayer

// layer.addSublayer(gradientLayer)

layer.insertSublayer(gradientLayer, at: 0)

maskLayer.path = path.cgPath
maskLayer.lineWidth = 1
maskLayer.fillColor = UIColor.clear.cgColor
maskLayer.strokeColor = UIColor.orange.cgColor
}
}