Skip to content

Commit

Permalink
Merge pull request #80 from THT-Team/like_animation
Browse files Browse the repository at this point in the history
Like animation
  • Loading branch information
Minny27 authored May 30, 2024
2 parents db3e678 + 4b6754b commit e20fddd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 88 deletions.
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)
.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() {
layoutGradientLayers()
}

private func configureUI() {
layer.borderWidth = 1
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
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
}
}

0 comments on commit e20fddd

Please sign in to comment.