Skip to content

Commit

Permalink
[MERGE] CurriculumView Diffable 및 MVVM(Combine)-C로 리팩터링 (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimscastle authored Nov 24, 2023
2 parents a31663f + 7ab2e73 commit d154c10
Show file tree
Hide file tree
Showing 11 changed files with 397 additions and 189 deletions.
12 changes: 12 additions & 0 deletions LionHeart-iOS/LionHeart-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
B5234FBA2B0C799B00D6EE58 /* CurriculumListWeekViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234FB92B0C799B00D6EE58 /* CurriculumListWeekViewModel.swift */; };
B5234FBC2B0C79A100D6EE58 /* CurriculumListWeekViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234FBB2B0C79A100D6EE58 /* CurriculumListWeekViewModelImpl.swift */; };
B5234FBF2B0C7CB500D6EE58 /* CurriculumListWeekDiffableModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234FBE2B0C7CB500D6EE58 /* CurriculumListWeekDiffableModel.swift */; };
B5234FC62B0DC31E00D6EE58 /* CurriculumViewViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234FC52B0DC31E00D6EE58 /* CurriculumViewViewModel.swift */; };
B5234FC82B0DC32A00D6EE58 /* CurriculumViewViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234FC72B0DC32A00D6EE58 /* CurriculumViewViewModelImpl.swift */; };
B5234FCA2B0DC77200D6EE58 /* CurriculumViewDiffableModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234FC92B0DC77200D6EE58 /* CurriculumViewDiffableModel.swift */; };
B5234F9B2B0A61D700D6EE58 /* ArticleDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234F9A2B0A61D700D6EE58 /* ArticleDetailViewModel.swift */; };
B5234F9D2B0A61DE00D6EE58 /* ArticleDetailViewModelImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234F9C2B0A61DE00D6EE58 /* ArticleDetailViewModelImpl.swift */; };
B5234FA52B0B2C3700D6EE58 /* ArticleCategoryViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5234FA42B0B2C3700D6EE58 /* ArticleCategoryViewModel.swift */; };
Expand Down Expand Up @@ -409,6 +412,9 @@
B5234FB92B0C799B00D6EE58 /* CurriculumListWeekViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListWeekViewModel.swift; sourceTree = "<group>"; };
B5234FBB2B0C79A100D6EE58 /* CurriculumListWeekViewModelImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListWeekViewModelImpl.swift; sourceTree = "<group>"; };
B5234FBE2B0C7CB500D6EE58 /* CurriculumListWeekDiffableModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumListWeekDiffableModel.swift; sourceTree = "<group>"; };
B5234FC52B0DC31E00D6EE58 /* CurriculumViewViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumViewViewModel.swift; sourceTree = "<group>"; };
B5234FC72B0DC32A00D6EE58 /* CurriculumViewViewModelImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumViewViewModelImpl.swift; sourceTree = "<group>"; };
B5234FC92B0DC77200D6EE58 /* CurriculumViewDiffableModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CurriculumViewDiffableModel.swift; sourceTree = "<group>"; };
B5234F9A2B0A61D700D6EE58 /* ArticleDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailViewModel.swift; sourceTree = "<group>"; };
B5234F9C2B0A61DE00D6EE58 /* ArticleDetailViewModelImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleDetailViewModelImpl.swift; sourceTree = "<group>"; };
B5234FA42B0B2C3700D6EE58 /* ArticleCategoryViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleCategoryViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -844,6 +850,8 @@
children = (
B5234FB92B0C799B00D6EE58 /* CurriculumListWeekViewModel.swift */,
B5234FBB2B0C79A100D6EE58 /* CurriculumListWeekViewModelImpl.swift */,
B5234FC52B0DC31E00D6EE58 /* CurriculumViewViewModel.swift */,
B5234FC72B0DC32A00D6EE58 /* CurriculumViewViewModelImpl.swift */,
);
path = ViewModel;
sourceTree = "<group>";
Expand All @@ -861,6 +869,7 @@
isa = PBXGroup;
children = (
B5234FBE2B0C7CB500D6EE58 /* CurriculumListWeekDiffableModel.swift */,
B5234FC92B0DC77200D6EE58 /* CurriculumViewDiffableModel.swift */,
);
path = Diffable;
sourceTree = "<group>";
Expand Down Expand Up @@ -2202,6 +2211,7 @@
C09A564D2B030C070012A7FD /* GetPregnancyViewModel.swift in Sources */,
B57BEB702A6275F500D1727C /* ViewControllerServiceable.swift in Sources */,
C0DF032F2A5A92170037F740 /* NameSpace.swift in Sources */,
B5234FC82B0DC32A00D6EE58 /* CurriculumViewViewModelImpl.swift in Sources */,
B53F4EFC2ADE3341001C5752 /* BookmarkCoordinatorImpl.swift in Sources */,
C0856B6D2ABFBD840026D9F8 /* BookmarkServiceImpl.swift in Sources */,
B59892EE2A5B9AF300CE1FEB /* NavigationBarLayoutManager.swift in Sources */,
Expand Down Expand Up @@ -2267,6 +2277,7 @@
C0DF03752A5A9CD00037F740 /* TabBarViewController.swift in Sources */,
C0D47B6A2B09B851003B66E6 /* GestureSubscription.swift in Sources */,
C0DF03532A5A9BC80037F740 /* ArticleListByCategoryViewController.swift in Sources */,
B5234FCA2B0DC77200D6EE58 /* CurriculumViewDiffableModel.swift in Sources */,
C04BE3AF2ADD4F7F001967B5 /* TodayAdaptor.swift in Sources */,
C0856B812ABFCD830026D9F8 /* OnboardingManagerImpl.swift in Sources */,
B57BEB6C2A6149AD00D1727C /* NetworkRequest.swift in Sources */,
Expand Down Expand Up @@ -2352,6 +2363,7 @@
C0DF03412A5A95E40037F740 /* UIImage+.swift in Sources */,
C0F62FE72A691FC40003ADFA /* LHLoadingView.swift in Sources */,
C0B15E132AC010CD0058D56B /* LHKingfisherService.swift in Sources */,
B5234FC62B0DC31E00D6EE58 /* CurriculumViewViewModel.swift in Sources */,
C009E9F62ADBC41D00112F18 /* BookmarkFactory.swift in Sources */,
4A918E7B2AE11839003CB8F9 /* ArticleAdaptor.swift in Sources */,
B5E78E002B03302200EA67A2 /* GetFetalNicknameViewModel.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import UIKit


protocol CurriculumControllerable where Self: UIViewController {
var navigator: CurriculumNavigation { get set }
}
//protocol CurriculumControllerable where Self: UIViewController {}


Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@
//

import UIKit
import Combine

import SnapKit

protocol CurriculumTableViewToggleButtonTappedProtocol: AnyObject {
func toggleButtonTapped(indexPath: IndexPath?)
func moveToListByWeekButtonTapped(indexPath: IndexPath?)
}

final class CurriculumTableViewCell: UITableViewCell, TableViewCellRegisterDequeueProtocol {

weak var delegate: CurriculumTableViewToggleButtonTappedProtocol?

var cellIndexPath: IndexPath?

var rightArrowButtonTapped = PassthroughSubject<Void, Never>()
var cancelBag = Set<AnyCancellable>()

private let curriculumWeekLabelView = UIView()
private let curriculumWholeStackView = LHStackView(axis: .vertical, spacing: 15)
Expand All @@ -29,9 +24,7 @@ final class CurriculumTableViewCell: UITableViewCell, TableViewCellRegisterDeque
private let contentTextLabel = LHLabel(type: .body3R, color: .gray500, lines: 0)
private let contentImageView = LHImageView(contentMode: .scaleToFill)
private let divider = LHUnderLine(lineColor: .gray800)
lazy var curriculumToggleDirectionButton = LHToggleImageButton(normal: ImageLiterals.Curriculum.arrowDownSmall,
select: ImageLiterals.Curriculum.arrowUpSmall)
private lazy var moveToArticleListByWeekButton = LHImageButton(setImage: ImageLiterals.Curriculum.arrowRightCircle)
private var moveToArticleListByWeekButton = LHImageButton(setImage: ImageLiterals.Curriculum.arrowRightCircle)

var inputData: CurriculumDummyData? {
didSet {
Expand All @@ -45,13 +38,18 @@ final class CurriculumTableViewCell: UITableViewCell, TableViewCellRegisterDeque
setUI()
setHierarchy()
setLayout()
setAddTarget()
bindInput()
}

@available(*, unavailable)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func prepareForReuse() {
super.prepareForReuse()
cancelBag.removeAll()
}
}

private extension CurriculumTableViewCell {
Expand All @@ -64,13 +62,10 @@ private extension CurriculumTableViewCell {
self.backgroundColor = .designSystem(.background)
weekTitleLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
contentImageView.isUserInteractionEnabled = true
curriculumToggleDirectionButton.marginImageWithText(margin: 19)
curriculumToggleDirectionButton.setContentCompressionResistancePriority(.required, for: .horizontal)

}

func setHierarchy() {
curriculumWeekLabelView.addSubviews(weekLabel, weekTitleLabel, curriculumToggleDirectionButton)
curriculumWeekLabelView.addSubviews(weekLabel, weekTitleLabel)
contentImageView.addSubviews(moveToArticleListByWeekButton)
curriculumContentStackView.addArrangedSubviews(contentImageView, contentTextLabel)
curriculumWholeStackView.addArrangedSubviews(curriculumWeekLabelView, curriculumContentStackView)
Expand All @@ -89,12 +84,7 @@ private extension CurriculumTableViewCell {
$0.centerY.equalTo(weekLabel)
$0.leading.equalTo(weekLabel.snp.trailing).offset(8).priority(.high)
}

curriculumToggleDirectionButton.snp.makeConstraints {
$0.leading.greaterThanOrEqualTo(weekTitleLabel.snp.trailing).offset(8)
$0.centerY.equalTo(weekLabel)
$0.trailing.equalToSuperview().offset(12)
}


curriculumWholeStackView.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(16)
Expand All @@ -117,13 +107,9 @@ private extension CurriculumTableViewCell {
}
}

func setAddTarget() {
curriculumToggleDirectionButton.addButtonAction { _ in
self.delegate?.toggleButtonTapped(indexPath: self.cellIndexPath)
}

moveToArticleListByWeekButton.addButtonAction { _ in
self.delegate?.moveToListByWeekButtonTapped(indexPath: self.cellIndexPath)
func bindInput() {
moveToArticleListByWeekButton.addButtonAction { sender in
self.rightArrowButtonTapped.send(())
}
}

Expand All @@ -133,9 +119,6 @@ private extension CurriculumTableViewCell {
self.contentImageView.image = inputData.curriculumImage
self.contentTextLabel.text = inputData.curriculumText
self.contentTextLabel.setTextWithLineHeight(lineHeight: 22)
self.curriculumContentStackView.isHidden = !inputData.isExpanded
self.weekLabel.textColor = inputData.isExpanded ? .designSystem(.componentLionRed) : .designSystem(.gray500)
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// CurriculumViewDiffableModel.swift
// LionHeart-iOS
//
// Created by 김민재 on 11/22/23.
//

import Foundation


enum CurriculumViewSection: CaseIterable {
case month2
case month3
case month4
case month5
case month6
case month7
case month8
case month9
case month10
}

enum CurriculumViewItem: Hashable {
case article(weekData: CurriculumDummyData)
}
Loading

0 comments on commit d154c10

Please sign in to comment.