Skip to content

Commit 15421ed

Browse files
authored
Merge pull request #263 from Team-return/feature/(#254)-feature_banner
🔗 :: (#254) 취업률 배너 추가
2 parents c316de1 + b3268a6 commit 15421ed

File tree

7 files changed

+158
-10
lines changed

7 files changed

+158
-10
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "Pie Chart.png",
5+
"idiom" : "universal",
6+
"scale" : "1x"
7+
},
8+
{
9+
"idiom" : "universal",
10+
"scale" : "2x"
11+
},
12+
{
13+
"idiom" : "universal",
14+
"scale" : "3x"
15+
}
16+
],
17+
"info" : {
18+
"author" : "xcode",
19+
"version" : 1
20+
}
21+
}
115 KB
Loading

Projects/Modules/DesignSystem/Sources/Image/JobisIcon.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public enum JobisIcon {
4343
case link
4444
case close
4545
case addPhoto
46+
case fileImage
4647

4748
func uiImage() -> UIImage {
4849
let dsIcons = DesignSystemAsset.Icons.self
@@ -152,6 +153,9 @@ public enum JobisIcon {
152153

153154
case .addPhoto:
154155
return dsIcons.addPhoto.image
156+
157+
case .fileImage:
158+
return dsIcons.fileImage.image
155159
}
156160
}
157161
}

Projects/Presentation/Sources/DI/PresentationAssembly.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public final class PresentationAssembly: Assembly {
1414
HomeViewModel(
1515
fetchStudentInfoUseCase: resolver.resolve(FetchStudentInfoUseCase.self)!,
1616
fetchApplicationUseCase: resolver.resolve(FetchApplicationUseCase.self)!,
17-
fetchBannerListUseCase: resolver.resolve(FetchBannerListUseCase.self)!
17+
fetchBannerListUseCase: resolver.resolve(FetchBannerListUseCase.self)!,
18+
fetchTotalPassStudentUseCase: resolver.resolve(FetchTotalPassStudentUseCase.self)!
1819
)
1920
}
2021

Projects/Presentation/Sources/Home/Components/Cell/BannerCollectionViewCell.swift

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,57 @@ final class BannerCollectionViewCell: BaseCollectionViewCell<FetchBannerEntity>
1111
$0.layer.cornerRadius = 16
1212
$0.clipsToBounds = true
1313
}
14+
private let passTitleLabel = UILabel().then {
15+
$0.numberOfLines = 0
16+
$0.setJobisText(
17+
"9기 대마고\n학생들의 취업률",
18+
font: .headLine,
19+
color: .GrayScale.gray90
20+
)
21+
}
22+
private let passLabel = UILabel().then {
23+
$0.setJobisText(
24+
" - ",
25+
font: .headLine,
26+
color: .Primary.blue20
27+
)
28+
}
29+
private let prePassCountTitleLabel = UILabel().then {
30+
$0.setJobisText(
31+
"현재",
32+
font: .subHeadLine,
33+
color: .GrayScale.gray60
34+
)
35+
}
36+
private let sufPassCountTitleLabel = UILabel().then {
37+
$0.setJobisText(
38+
"명이 취업했어요",
39+
font: .subHeadLine,
40+
color: .GrayScale.gray60
41+
)
42+
}
43+
private let passCountLabel = UILabel().then {
44+
$0.setJobisText(
45+
" - ",
46+
font: .subHeadLine,
47+
color: .GrayScale.gray70
48+
)
49+
}
50+
private let fileImageView = UIImageView().then {
51+
$0.contentMode = .scaleAspectFill
52+
$0.clipsToBounds = true
53+
$0.image = UIImage.jobisIcon(.fileImage)
54+
}
1455

1556
override func addView() {
1657
[
17-
imageView
58+
imageView,
59+
passTitleLabel,
60+
passLabel,
61+
prePassCountTitleLabel,
62+
sufPassCountTitleLabel,
63+
passCountLabel,
64+
fileImageView
1865
].forEach(contentView.addSubview(_:))
1966
}
2067

@@ -24,12 +71,58 @@ final class BannerCollectionViewCell: BaseCollectionViewCell<FetchBannerEntity>
2471
}
2572
}
2673

74+
func totalPassSetLayout() {
75+
passTitleLabel.snp.makeConstraints {
76+
$0.top.leading.equalToSuperview().inset(24)
77+
}
78+
79+
passLabel.snp.makeConstraints {
80+
$0.top.equalTo(passTitleLabel.snp.bottom)
81+
$0.leading.equalToSuperview().inset(24)
82+
}
83+
84+
prePassCountTitleLabel.snp.makeConstraints {
85+
$0.bottom.leading.equalToSuperview().inset(24)
86+
}
87+
88+
passCountLabel.snp.makeConstraints {
89+
$0.top.equalTo(prePassCountTitleLabel.snp.top)
90+
$0.leading.equalTo(prePassCountTitleLabel.snp.trailing).offset(4)
91+
}
92+
93+
sufPassCountTitleLabel.snp.makeConstraints {
94+
$0.bottom.equalToSuperview().inset(24)
95+
$0.leading.equalTo(passCountLabel.snp.trailing).offset(4)
96+
}
97+
98+
fileImageView.snp.makeConstraints {
99+
$0.width.height.equalTo(180)
100+
$0.top.trailing.equalToSuperview()
101+
}
102+
}
103+
27104
override func configureView() {
28105
self.layer.cornerRadius = 12
29106
self.backgroundColor = .GrayScale.gray30
30107
}
31108

32109
override func adapt(model: FetchBannerEntity) {
110+
setLayout()
33111
self.imageView.setJobisImage(urlString: model.bannerURL)
34112
}
113+
114+
func totalPassAdapt(model: TotalPassStudentEntity) {
115+
totalPassSetLayout()
116+
passLabel.setJobisText(
117+
"\(Int(Double(model.passedCount) / Double(model.totalStudentCount) * 100.0))%",
118+
font: .headLine,
119+
color: .Primary.blue20
120+
)
121+
122+
passCountLabel.setJobisText(
123+
"\(model.passedCount)/\(model.totalStudentCount)",
124+
font: .subHeadLine,
125+
color: .GrayScale.gray70
126+
)
127+
}
35128
}

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)