Skip to content

Commit b3268a6

Browse files
committed
🧩 :: 취업률 배너 cell 구현
1 parent 17f72a1 commit b3268a6

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed

Projects/Presentation/Sources/Home/HomeViewController.swift

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,28 @@ public final class HomeViewController: BaseViewController<HomeViewModel> {
168168
}
169169
.disposed(by: disposeBag)
170170

171-
output.bannerList
172-
.filter { !$0.isEmpty }
173-
.do(onNext: {
174-
self.bannerView.setPageControl(count: $0.count)
171+
let totalPassBannerModel = output.totalPassStudentInfo.value
172+
173+
let combinedBanners = output.bannerList
174+
.map { banners in
175+
return [totalPassBannerModel] + banners
176+
}
177+
178+
combinedBanners
179+
.do(onNext: { banners in
180+
self.bannerView.setPageControl(count: banners.count)
175181
})
176182
.bind(to: bannerView.collectionView.rx.items(
177183
cellIdentifier: BannerCollectionViewCell.identifier,
178184
cellType: BannerCollectionViewCell.self
179-
)) { _, element, cell in
180-
cell.adapt(model: element)
185+
)) { index, element, cell in
186+
if index == 0 {
187+
cell.totalPassAdapt(model: output.totalPassStudentInfo.value)
188+
} else {
189+
if let fetchBanner = element as? FetchBannerEntity {
190+
cell.adapt(model: fetchBanner)
191+
}
192+
}
181193
}
182194
.disposed(by: disposeBag)
183195
}

Projects/Presentation/Sources/Home/HomeViewModel.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ public final class HomeViewModel: BaseViewModel, Stepper {
1111
private let fetchStudentInfoUseCase: FetchStudentInfoUseCase
1212
private let fetchApplicationUseCase: FetchApplicationUseCase
1313
private let fetchBannerListUseCase: FetchBannerListUseCase
14+
private let fetchTotalPassStudentUseCase: FetchTotalPassStudentUseCase
1415

1516
private var touchedPopcatCount = 0
1617

1718
init(
1819
fetchStudentInfoUseCase: FetchStudentInfoUseCase,
1920
fetchApplicationUseCase: FetchApplicationUseCase,
20-
fetchBannerListUseCase: FetchBannerListUseCase
21+
fetchBannerListUseCase: FetchBannerListUseCase,
22+
fetchTotalPassStudentUseCase: FetchTotalPassStudentUseCase
2123
) {
2224
self.fetchStudentInfoUseCase = fetchStudentInfoUseCase
2325
self.fetchApplicationUseCase = fetchApplicationUseCase
2426
self.fetchBannerListUseCase = fetchBannerListUseCase
27+
self.fetchTotalPassStudentUseCase = fetchTotalPassStudentUseCase
2528
}
2629

2730
public struct Input {
@@ -40,12 +43,18 @@ public final class HomeViewModel: BaseViewModel, Stepper {
4043
let studentInfo: PublishRelay<StudentInfoEntity>
4144
let applicationList: PublishRelay<[ApplicationEntity]>
4245
let bannerList: BehaviorRelay<[FetchBannerEntity]>
46+
let totalPassStudentInfo: BehaviorRelay<TotalPassStudentEntity>
4347
}
4448

4549
public func transform(_ input: Input) -> Output {
4650
let studentInfo = PublishRelay<StudentInfoEntity>()
4751
let applicationList = PublishRelay<[ApplicationEntity]>()
4852
let bannerList = BehaviorRelay<[FetchBannerEntity]>(value: [])
53+
let totalPassStudentInfo = BehaviorRelay<TotalPassStudentEntity>(value: TotalPassStudentEntity.init(
54+
totalStudentCount: 0,
55+
passedCount: 0,
56+
approvedCount: 0
57+
))
4958

5059
input.viewAppear.asObservable()
5160
.flatMap { [self] in
@@ -94,6 +103,13 @@ public final class HomeViewModel: BaseViewModel, Stepper {
94103
.bind(to: steps)
95104
.disposed(by: disposeBag)
96105

106+
input.viewAppear.asObservable()
107+
.flatMap { [self] in
108+
fetchTotalPassStudentUseCase.execute()
109+
}
110+
.bind(to: totalPassStudentInfo)
111+
.disposed(by: disposeBag)
112+
97113
input.viewAppear.asObservable()
98114
.flatMap { [self] in
99115
fetchBannerListUseCase.execute()
@@ -146,7 +162,8 @@ public final class HomeViewModel: BaseViewModel, Stepper {
146162
return Output(
147163
studentInfo: studentInfo,
148164
applicationList: applicationList,
149-
bannerList: bannerList
165+
bannerList: bannerList,
166+
totalPassStudentInfo: totalPassStudentInfo
150167
)
151168
}
152169
}

0 commit comments

Comments
 (0)