Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐Ÿ”— :: (#254) ์ทจ์—…๋ฅ  ๋ฐฐ๋„ˆ ์ถ”๊ฐ€ #263

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Pie Chart.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Projects/Modules/DesignSystem/Sources/Image/JobisIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public enum JobisIcon {
case link
case close
case addPhoto
case fileImage

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

case .addPhoto:
return dsIcons.addPhoto.image

case .fileImage:
return dsIcons.fileImage.image
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public final class PresentationAssembly: Assembly {
HomeViewModel(
fetchStudentInfoUseCase: resolver.resolve(FetchStudentInfoUseCase.self)!,
fetchApplicationUseCase: resolver.resolve(FetchApplicationUseCase.self)!,
fetchBannerListUseCase: resolver.resolve(FetchBannerListUseCase.self)!
fetchBannerListUseCase: resolver.resolve(FetchBannerListUseCase.self)!,
fetchTotalPassStudentUseCase: resolver.resolve(FetchTotalPassStudentUseCase.self)!
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,57 @@ final class BannerCollectionViewCell: BaseCollectionViewCell<FetchBannerEntity>
$0.layer.cornerRadius = 16
$0.clipsToBounds = true
}
private let passTitleLabel = UILabel().then {
$0.numberOfLines = 0
$0.setJobisText(
"9๊ธฐ ๋Œ€๋งˆ๊ณ \nํ•™์ƒ๋“ค์˜ ์ทจ์—…๋ฅ ",
font: .headLine,
color: .GrayScale.gray90
)
}
private let passLabel = UILabel().then {
$0.setJobisText(
" - ",
font: .headLine,
color: .Primary.blue20
)
}
private let prePassCountTitleLabel = UILabel().then {
$0.setJobisText(
"ํ˜„์žฌ",
font: .subHeadLine,
color: .GrayScale.gray60
)
}
private let sufPassCountTitleLabel = UILabel().then {
$0.setJobisText(
"๋ช…์ด ์ทจ์—…ํ–ˆ์–ด์š”",
font: .subHeadLine,
color: .GrayScale.gray60
)
}
private let passCountLabel = UILabel().then {
$0.setJobisText(
" - ",
font: .subHeadLine,
color: .GrayScale.gray70
)
}
private let fileImageView = UIImageView().then {
$0.contentMode = .scaleAspectFill
$0.clipsToBounds = true
$0.image = UIImage.jobisIcon(.fileImage)
}

override func addView() {
[
imageView
imageView,
passTitleLabel,
passLabel,
prePassCountTitleLabel,
sufPassCountTitleLabel,
passCountLabel,
fileImageView
].forEach(contentView.addSubview(_:))
}

Expand All @@ -24,12 +71,58 @@ final class BannerCollectionViewCell: BaseCollectionViewCell<FetchBannerEntity>
}
}

func totalPassSetLayout() {
passTitleLabel.snp.makeConstraints {
$0.top.leading.equalToSuperview().inset(24)
}

passLabel.snp.makeConstraints {
$0.top.equalTo(passTitleLabel.snp.bottom)
$0.leading.equalToSuperview().inset(24)
}

prePassCountTitleLabel.snp.makeConstraints {
$0.bottom.leading.equalToSuperview().inset(24)
}

passCountLabel.snp.makeConstraints {
$0.top.equalTo(prePassCountTitleLabel.snp.top)
$0.leading.equalTo(prePassCountTitleLabel.snp.trailing).offset(4)
}

sufPassCountTitleLabel.snp.makeConstraints {
$0.bottom.equalToSuperview().inset(24)
$0.leading.equalTo(passCountLabel.snp.trailing).offset(4)
}

fileImageView.snp.makeConstraints {
$0.width.height.equalTo(180)
$0.top.trailing.equalToSuperview()
}
}

override func configureView() {
self.layer.cornerRadius = 12
self.backgroundColor = .GrayScale.gray30
}

override func adapt(model: FetchBannerEntity) {
setLayout()
self.imageView.setJobisImage(urlString: model.bannerURL)
}

func totalPassAdapt(model: TotalPassStudentEntity) {
totalPassSetLayout()
passLabel.setJobisText(
"\(Int(Double(model.passedCount) / Double(model.totalStudentCount) * 100.0))%",
font: .headLine,
color: .Primary.blue20
)

passCountLabel.setJobisText(
"\(model.passedCount)/\(model.totalStudentCount)",
font: .subHeadLine,
color: .GrayScale.gray70
)
}
}
24 changes: 18 additions & 6 deletions Projects/Presentation/Sources/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,28 @@ public final class HomeViewController: BaseViewController<HomeViewModel> {
}
.disposed(by: disposeBag)

output.bannerList
.filter { !$0.isEmpty }
.do(onNext: {
self.bannerView.setPageControl(count: $0.count)
let totalPassBannerModel = output.totalPassStudentInfo.value

let combinedBanners = output.bannerList
.map { banners in
return [totalPassBannerModel] + banners
}

combinedBanners
.do(onNext: { banners in
self.bannerView.setPageControl(count: banners.count)
})
.bind(to: bannerView.collectionView.rx.items(
cellIdentifier: BannerCollectionViewCell.identifier,
cellType: BannerCollectionViewCell.self
)) { _, element, cell in
cell.adapt(model: element)
)) { index, element, cell in
if index == 0 {
cell.totalPassAdapt(model: output.totalPassStudentInfo.value)
} else {
if let fetchBanner = element as? FetchBannerEntity {
cell.adapt(model: fetchBanner)
}
}
}
.disposed(by: disposeBag)
}
Expand Down
21 changes: 19 additions & 2 deletions Projects/Presentation/Sources/Home/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ public final class HomeViewModel: BaseViewModel, Stepper {
private let fetchStudentInfoUseCase: FetchStudentInfoUseCase
private let fetchApplicationUseCase: FetchApplicationUseCase
private let fetchBannerListUseCase: FetchBannerListUseCase
private let fetchTotalPassStudentUseCase: FetchTotalPassStudentUseCase

private var touchedPopcatCount = 0

init(
fetchStudentInfoUseCase: FetchStudentInfoUseCase,
fetchApplicationUseCase: FetchApplicationUseCase,
fetchBannerListUseCase: FetchBannerListUseCase
fetchBannerListUseCase: FetchBannerListUseCase,
fetchTotalPassStudentUseCase: FetchTotalPassStudentUseCase
) {
self.fetchStudentInfoUseCase = fetchStudentInfoUseCase
self.fetchApplicationUseCase = fetchApplicationUseCase
self.fetchBannerListUseCase = fetchBannerListUseCase
self.fetchTotalPassStudentUseCase = fetchTotalPassStudentUseCase
}

public struct Input {
Expand All @@ -40,12 +43,18 @@ public final class HomeViewModel: BaseViewModel, Stepper {
let studentInfo: PublishRelay<StudentInfoEntity>
let applicationList: PublishRelay<[ApplicationEntity]>
let bannerList: BehaviorRelay<[FetchBannerEntity]>
let totalPassStudentInfo: BehaviorRelay<TotalPassStudentEntity>
}

public func transform(_ input: Input) -> Output {
let studentInfo = PublishRelay<StudentInfoEntity>()
let applicationList = PublishRelay<[ApplicationEntity]>()
let bannerList = BehaviorRelay<[FetchBannerEntity]>(value: [])
let totalPassStudentInfo = BehaviorRelay<TotalPassStudentEntity>(value: TotalPassStudentEntity.init(
totalStudentCount: 0,
passedCount: 0,
approvedCount: 0
))

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

input.viewAppear.asObservable()
.flatMap { [self] in
fetchTotalPassStudentUseCase.execute()
}
.bind(to: totalPassStudentInfo)
.disposed(by: disposeBag)

input.viewAppear.asObservable()
.flatMap { [self] in
fetchBannerListUseCase.execute()
Expand Down Expand Up @@ -146,7 +162,8 @@ public final class HomeViewModel: BaseViewModel, Stepper {
return Output(
studentInfo: studentInfo,
applicationList: applicationList,
bannerList: bannerList
bannerList: bannerList,
totalPassStudentInfo: totalPassStudentInfo
)
}
}
Loading