-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- TFBaseCollectionViewCell를 상속받은UserCardViewCollectionViewCell 구현 - DimView Manager 클래스를 따로 빼려고 했지만, 셀이 생성됐을 때의 x, y좌표를 알아야 해서 cell을 커스텀하는 방식으로 구현함. - 또한, 셀 각각의 view model의 output을 구독하다보니 다른 셀에 대한 트리거를 처리하기 애매해서 미리 셀에 dimView를 추가해놓고 - 셀에서 시작 시간을 output으로 구독해서 타이머가 시작됐을 때 dim view를 hidden하는 방식으로 구현. - 특정 셀이 다른 모든 셀의 트리거를 알게 할 수는 있지만, 사이드 이펙트 및 비효율적이어서 이렇게 하지 않음.
- Loading branch information
Showing
3 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Projects/Modules/DesignSystem/Src/BaseView/UserCardViewCollectionViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// UserCardViewCollectionViewCell.swift | ||
// DSKit | ||
// | ||
// Created by SeungMin on 1/31/24. | ||
// | ||
|
||
import UIKit | ||
|
||
open class UserCardViewCollectionViewCell: TFBaseCollectionViewCell { | ||
private let userCardDimView: UIView = { | ||
let userCardWidth = (UIWindow.keyWindow?.bounds.width ?? .zero) - 32 | ||
let view = UIView( | ||
frame: CGRect( | ||
x: 0, | ||
y: 0, | ||
width: userCardWidth, | ||
height: userCardWidth * 1.64 | ||
) | ||
) | ||
view.layer.cornerRadius = 20 | ||
return view | ||
}() | ||
|
||
public func showUserCardDimView() { | ||
DispatchQueue.main.async { [weak self] in | ||
guard let self = self else { return } | ||
self.addSubviews(userCardDimView) | ||
print("DimView added!") | ||
UIView.animate(withDuration: 0.0) { | ||
self.userCardDimView.backgroundColor = DSKitAsset.Color.DimColor.default.color | ||
} | ||
} | ||
} | ||
|
||
public func hiddenUserCardDimView() { | ||
DispatchQueue.main.async { [weak self] in | ||
guard let self = self else { return } | ||
UIView.animate(withDuration: 0.0) { | ||
self.userCardDimView.backgroundColor = DSKitAsset.Color.clear.color | ||
} completion: { [weak self] _ in | ||
guard let self = self else { return } | ||
print("Removed DimView!") | ||
self.userCardDimView.removeFromSuperview() | ||
} | ||
} | ||
} | ||
} |