Skip to content

Commit a04f570

Browse files
authored
[NL-52]: BaseCollectionViewCell 구현 (#32)
* [NL-53]: Base 모듈 정의 (cherry picked from commit 0d0c0cf) * [NL-52]: BaseCollectionViewCell 구현
1 parent 668ad77 commit a04f570

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// BaseCollectionViewCell.swift
3+
// Base
4+
//
5+
// Created by ttozzi on 8/10/25.
6+
//
7+
8+
import Combine
9+
import UIKit
10+
11+
open class BaseCollectionViewCell: UICollectionViewCell {
12+
13+
public var cancellables = Set<AnyCancellable>()
14+
15+
open override func prepareForReuse() {
16+
super.prepareForReuse()
17+
cancellables.removeAll()
18+
}
19+
}

Feature/Home/Sources/HomeRecommendationCollectionViewCell.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by ttozzi on 7/31/25.
66
//
77

8+
import Base
89
import Combine
910
import DesignSystem
1011
import SnapKit
@@ -23,7 +24,7 @@ struct HomeRecommendationCollectionViewCellModel: HomeCellModel {
2324
let state: State
2425
}
2526

26-
final class HomeRecommendationCollectionViewCell: UICollectionViewCell {
27+
final class HomeRecommendationCollectionViewCell: BaseCollectionViewCell {
2728

2829
private enum Constant {
2930
static let seeMoreAreaHeight: CGFloat = 43
@@ -67,7 +68,6 @@ final class HomeRecommendationCollectionViewCell: UICollectionViewCell {
6768
private var internalCancellables = Set<AnyCancellable>()
6869
private let buttonTapSubject = PassthroughSubject<Void, Never>()
6970
var butonTapPublisher: AnyPublisher<Void, Never> { buttonTapSubject.eraseToAnyPublisher() }
70-
var cancellables = Set<AnyCancellable>()
7171

7272
override init(frame: CGRect) {
7373
super.init(frame: frame)
@@ -79,11 +79,6 @@ final class HomeRecommendationCollectionViewCell: UICollectionViewCell {
7979
fatalError("init(coder:) has not been implemented")
8080
}
8181

82-
override func prepareForReuse() {
83-
super.prepareForReuse()
84-
cancellables.removeAll()
85-
}
86-
8782
private func setupUI() {
8883
contentView.backgroundColor = STColors.white.color
8984
contentView.layer.cornerRadius = 12

Feature/Setting/Sources/MyPage/Cells/MyProfileInfoCollectionViewCell.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by ttozzi on 7/26/25.
66
//
77

8+
import Base
89
import Combine
910
import DesignSystem
1011
import SnapKit
@@ -19,7 +20,7 @@ struct MyProfileInfoCollectionViewCellModel {
1920
let birthTime: String
2021
}
2122

22-
final class MyProfileInfoCollectionViewCell: UICollectionViewCell {
23+
final class MyProfileInfoCollectionViewCell: BaseCollectionViewCell {
2324

2425
private lazy var contentStackView = UIStackView().then {
2526
$0.spacing = .zero
@@ -56,7 +57,6 @@ final class MyProfileInfoCollectionViewCell: UICollectionViewCell {
5657
private lazy var birthTimeLabel = UILabel().then {
5758
$0.style = Typography.Caption_12_B
5859
}
59-
var cancellables = Set<AnyCancellable>()
6060

6161
override init(frame: CGRect) {
6262
super.init(frame: frame)
@@ -67,12 +67,7 @@ final class MyProfileInfoCollectionViewCell: UICollectionViewCell {
6767
required init?(coder: NSCoder) {
6868
fatalError("init(coder:) has not been implemented")
6969
}
70-
71-
override func prepareForReuse() {
72-
super.prepareForReuse()
73-
cancellables.removeAll()
74-
}
75-
70+
7671
private func setupUI() {
7772
backgroundColor = .clear
7873
contentStackView.backgroundColor = .clear

Feature/Setting/Sources/PushSetting/Cells/PushSettingToggleCollectionViewCell.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by ttozzi on 7/31/25.
66
//
77

8+
import Base
89
import Combine
910
import DesignSystem
1011
import Extension
@@ -22,7 +23,7 @@ final class PushSettingToggleCollectionViewCellModel: PushSettingCellModel {
2223
}
2324
}
2425

25-
final class PushSettingToggleCollectionViewCell: UICollectionViewCell {
26+
final class PushSettingToggleCollectionViewCell: BaseCollectionViewCell {
2627

2728
private lazy var contentStackView = UIStackView().then {
2829
$0.axis = .horizontal
@@ -42,7 +43,6 @@ final class PushSettingToggleCollectionViewCell: UICollectionViewCell {
4243
})
4344
.eraseToAnyPublisher()
4445
}
45-
var cancellables = Set<AnyCancellable>()
4646

4747
override init(frame: CGRect) {
4848
super.init(frame: frame)
@@ -53,11 +53,6 @@ final class PushSettingToggleCollectionViewCell: UICollectionViewCell {
5353
fatalError("init(coder:) has not been implemented")
5454
}
5555

56-
override func prepareForReuse() {
57-
super.prepareForReuse()
58-
cancellables.removeAll()
59-
}
60-
6156
private func setupUI() {
6257
contentView.backgroundColor = .clear
6358

0 commit comments

Comments
 (0)