From 4e6b295af7964519343e4d31b00c2651f82576f6 Mon Sep 17 00:00:00 2001 From: Choyoungjun Date: Tue, 19 Nov 2024 08:55:22 +0900 Subject: [PATCH 1/4] =?UTF-8?q?refact=20::=20[#117]=20=EC=A3=BC=EB=A7=90?= =?UTF-8?q?=EA=B8=89=EC=8B=9D=20=EB=A1=9C=EC=A7=81=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DTO/SchoolMeal/SchoolMealDTO.swift | 10 +++--- .../Entity/SchoolMeal/SchoolMealEntity.swift | 4 +-- .../Scene/Home/HomeViewController.swift | 36 +++++++------------ .../Sources/Scene/Home/HomeViewModel.swift | 4 +-- .../OnBoarding/OnBoardingViewController.swift | 3 -- .../SchoolMeal/SchoolMealViewController.swift | 9 ++--- .../SchoolMeal/SchoolMealViewModel.swift | 10 +++--- 7 files changed, 30 insertions(+), 46 deletions(-) diff --git a/Projects/Data/Sources/DTO/SchoolMeal/SchoolMealDTO.swift b/Projects/Data/Sources/DTO/SchoolMeal/SchoolMealDTO.swift index d0735e87..0cff0bbe 100644 --- a/Projects/Data/Sources/DTO/SchoolMeal/SchoolMealDTO.swift +++ b/Projects/Data/Sources/DTO/SchoolMeal/SchoolMealDTO.swift @@ -19,18 +19,16 @@ extension SchoolMealDTO { } struct SchoolMealDTOElement: Decodable { - public let breakfast: MealDTOElement - public let lunch: MealDTOElement - public let dinner: MealDTOElement + public let breakfast, lunch, dinner: MealDTOElement } extension SchoolMealDTOElement { func toDomain() -> SchoolMealEntityElement { return .init( mealBundle: [ - (0, "조식", breakfast.toDomain()), - (1, "중식", lunch.toDomain()), - (2, "석식", dinner.toDomain()) + ("조식", breakfast.toDomain()), + ("중식", lunch.toDomain()), + ("석식", dinner.toDomain()) ] ) } diff --git a/Projects/Domain/Sources/Entity/SchoolMeal/SchoolMealEntity.swift b/Projects/Domain/Sources/Entity/SchoolMeal/SchoolMealEntity.swift index 1a185203..6c0622f4 100644 --- a/Projects/Domain/Sources/Entity/SchoolMeal/SchoolMealEntity.swift +++ b/Projects/Domain/Sources/Entity/SchoolMeal/SchoolMealEntity.swift @@ -9,9 +9,9 @@ public struct SchoolMealEntity { } public struct SchoolMealEntityElement { - public let mealBundle: [(Int, String, MealEntityElement)] + public let mealBundle: [(String, MealEntityElement)] - public init(mealBundle: [(Int, String, MealEntityElement)]) { + public init(mealBundle: [(String, MealEntityElement)]) { self.mealBundle = mealBundle } } diff --git a/Projects/Presentation/Sources/Scene/Home/HomeViewController.swift b/Projects/Presentation/Sources/Scene/Home/HomeViewController.swift index c864e49c..492237e9 100644 --- a/Projects/Presentation/Sources/Scene/Home/HomeViewController.swift +++ b/Projects/Presentation/Sources/Scene/Home/HomeViewController.swift @@ -6,8 +6,6 @@ import Then import RxSwift import RxCocoa -import Starscream - import Core import Domain import DesignSystem @@ -25,7 +23,7 @@ public class HomeViewController: BaseViewController { width: self.view.frame.width, height: 0 ) - private lazy var timeTableHeight = BehaviorRelay(value: 0) + private lazy var timeTableHeight = BehaviorRelay(value: 100) private lazy var schoolMealHeight = BehaviorRelay(value: 0) private let scrollView = UIScrollView().then { @@ -242,9 +240,7 @@ public class HomeViewController: BaseViewController { output.timeTableHeight.asObservable() .withUnretained(self) .bind { owner, height in - if height == 0 { - owner.timeTableHeight.accept(100) - } else { + if height != 0 { owner.timeTableHeight.accept(height) } @@ -314,24 +310,16 @@ public class HomeViewController: BaseViewController { } private func setupViewType(type: HomeViewType) { - switch type { - case .timeTable: - self.todaysLabel.text = "오늘의 시간표" - self.schoolMealView.isHidden = true - self.timeTableView.isHidden = false - - mainStackView.snp.remakeConstraints { - $0.height.equalTo(self.timeTableHeight.value) - } - - case .schoolMeal: - self.todaysLabel.text = "오늘의 급식" - self.timeTableView.isHidden = true - self.schoolMealView.isHidden = false - - mainStackView.snp.remakeConstraints { - $0.height.equalTo(self.schoolMealHeight.value) - } + let isTimeTable = (type == .timeTable) + self.todaysLabel.text = isTimeTable ? "오늘의 시간표" : "오늘의 급식" + + self.timeTableView.isHidden = !isTimeTable + self.schoolMealView.isHidden = isTimeTable + + let height = isTimeTable ? self.timeTableHeight.value : self.schoolMealHeight.value + + mainStackView.snp.remakeConstraints { + $0.height.equalTo(height) } } diff --git a/Projects/Presentation/Sources/Scene/Home/HomeViewModel.swift b/Projects/Presentation/Sources/Scene/Home/HomeViewModel.swift index 95c7df64..35fbaeaa 100644 --- a/Projects/Presentation/Sources/Scene/Home/HomeViewModel.swift +++ b/Projects/Presentation/Sources/Scene/Home/HomeViewModel.swift @@ -62,7 +62,7 @@ public class HomeViewModel: BaseViewModel, Stepper { let applyStatusData: Signal let weekendMealPeriodData: Signal let timetableData: Driver<[TimeTableEntityElement]> - let schoolMealData: Driver<[(Int, String, MealEntityElement)]> + let schoolMealData: Driver<[(String, MealEntityElement)]> let noticeListData: Signal let selfStudyData: Driver let outingPassData: Signal @@ -76,7 +76,7 @@ public class HomeViewModel: BaseViewModel, Stepper { private let applyStatusData = PublishRelay() private let weekendMealPeriodData = PublishRelay() private let timetableData = BehaviorRelay<[TimeTableEntityElement]>(value: []) - private let schoolMealData = BehaviorRelay<[(Int, String, MealEntityElement)]>(value: []) + private let schoolMealData = BehaviorRelay<[(String, MealEntityElement)]>(value: []) private let outingPassData = PublishRelay() private let noticeListData = PublishRelay() private let selfStudyData = BehaviorRelay(value: []) diff --git a/Projects/Presentation/Sources/Scene/OnBoarding/OnBoardingViewController.swift b/Projects/Presentation/Sources/Scene/OnBoarding/OnBoardingViewController.swift index 0819f022..0c046d6f 100644 --- a/Projects/Presentation/Sources/Scene/OnBoarding/OnBoardingViewController.swift +++ b/Projects/Presentation/Sources/Scene/OnBoarding/OnBoardingViewController.swift @@ -69,9 +69,6 @@ public class OnboardingViewController: BaseViewController { ) { print("click") } - alert.modalTransitionStyle = .crossDissolve - alert.modalPresentationStyle = .overFullScreen - owner.present(alert, animated: true) }.disposed(by: disposeBag) } diff --git a/Projects/Presentation/Sources/Scene/SchoolMeal/SchoolMealViewController.swift b/Projects/Presentation/Sources/Scene/SchoolMeal/SchoolMealViewController.swift index 76bd79bc..16388f3f 100644 --- a/Projects/Presentation/Sources/Scene/SchoolMeal/SchoolMealViewController.swift +++ b/Projects/Presentation/Sources/Scene/SchoolMeal/SchoolMealViewController.swift @@ -58,15 +58,16 @@ public class SchoolMealViewController: BaseViewController { ) let output = viewModel.transform(input: input) - output.schoolMealData.asObservable() + output.schoolMealData + .asObservable() .bind(to: schoolMealCollectionView.rx.items( cellIdentifier: SchoolMealCollectionViewCell.identifier, cellType: SchoolMealCollectionViewCell.self )) { _, item, cell in cell.setup( - mealTime: item.1, - menu: item.2.menu, - kcal: item.2.kcal + mealTime: item.0, + menu: item.1.menu, + kcal: item.1.kcal ) }.disposed(by: disposeBag) diff --git a/Projects/Presentation/Sources/Scene/SchoolMeal/SchoolMealViewModel.swift b/Projects/Presentation/Sources/Scene/SchoolMeal/SchoolMealViewModel.swift index c7ae5ac3..bb3fef22 100644 --- a/Projects/Presentation/Sources/Scene/SchoolMeal/SchoolMealViewModel.swift +++ b/Projects/Presentation/Sources/Scene/SchoolMeal/SchoolMealViewModel.swift @@ -23,10 +23,10 @@ public class SchoolMealViewModel: BaseViewModel, Stepper { let schoolMealDate: Observable } public struct Output { - let schoolMealData: Driver<[(Int, String, MealEntityElement)]> + let schoolMealData: Driver<[(String, MealEntityElement)]> } - private let schoolMealData = BehaviorRelay<[(Int, String, MealEntityElement)]>(value: []) + private let schoolMealData = BehaviorRelay<[(String, MealEntityElement)]>(value: []) public func transform(input: Input) -> Output { input.schoolMealDate @@ -37,9 +37,9 @@ public class SchoolMealViewModel: BaseViewModel, Stepper { return .never() } } - .subscribe(onNext: { [weak self] data in - self?.schoolMealData.accept(data.meals.mealBundle) - }) + .bind { data in + self.schoolMealData.accept(data.meals.mealBundle) + } .disposed(by: disposeBag) return Output(schoolMealData: schoolMealData.asDriver()) From f51249821f724f738785bcd07fa5ef8568e794b2 Mon Sep 17 00:00:00 2001 From: Choyoungjun Date: Tue, 19 Nov 2024 08:56:23 +0900 Subject: [PATCH 2/4] =?UTF-8?q?chore=20::=20=EC=9E=90=EC=9E=98=ED=95=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesignSystem/Sources/Component/Alert/PiCKAlert.swift | 2 ++ .../Sources/Scene/AllTab/AllTabViewController.swift | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Projects/Modules/DesignSystem/Sources/Component/Alert/PiCKAlert.swift b/Projects/Modules/DesignSystem/Sources/Component/Alert/PiCKAlert.swift index 9f3ee0bf..f3c35004 100644 --- a/Projects/Modules/DesignSystem/Sources/Component/Alert/PiCKAlert.swift +++ b/Projects/Modules/DesignSystem/Sources/Component/Alert/PiCKAlert.swift @@ -67,6 +67,8 @@ public class PiCKAlert: UIViewController { } self.clickLogout = clickLogout super.init(nibName: nil, bundle: nil) + self.modalTransitionStyle = .crossDissolve + self.modalPresentationStyle = .overFullScreen } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") diff --git a/Projects/Presentation/Sources/Scene/AllTab/AllTabViewController.swift b/Projects/Presentation/Sources/Scene/AllTab/AllTabViewController.swift index 01099475..a8c07e99 100644 --- a/Projects/Presentation/Sources/Scene/AllTab/AllTabViewController.swift +++ b/Projects/Presentation/Sources/Scene/AllTab/AllTabViewController.swift @@ -79,8 +79,6 @@ public class AllTabViewController: BaseViewController { ) { owner.logoutRelay.accept(()) } - alert.modalPresentationStyle = .overFullScreen - alert.modalTransitionStyle = .crossDissolve owner.present(alert, animated: true) }.disposed(by: disposeBag) } From ff2bb36ff3bc32e83d979aedaf901e1356552d82 Mon Sep 17 00:00:00 2001 From: Choyoungjun Date: Tue, 19 Nov 2024 08:56:45 +0900 Subject: [PATCH 3/4] =?UTF-8?q?chore=20::=20=EB=B7=B0=20=EB=A1=9C=EB=93=9C?= =?UTF-8?q?=20=EC=8B=9C=EC=A0=90=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Presentation/Sources/Base/BaseViewController.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Projects/Presentation/Sources/Base/BaseViewController.swift b/Projects/Presentation/Sources/Base/BaseViewController.swift index cb1ce542..14b838b6 100644 --- a/Projects/Presentation/Sources/Base/BaseViewController.swift +++ b/Projects/Presentation/Sources/Base/BaseViewController.swift @@ -35,10 +35,13 @@ open class BaseViewController: UIViewController, UIGes viewWillAppearRelay.accept(()) bindAction() } - open override func viewDidLayoutSubviews() { - super.viewDidLayoutSubviews() + open override func viewWillLayoutSubviews() { + super.viewWillLayoutSubviews() addView() setLayout() + } + open override func viewDidLayoutSubviews() { + super.viewDidLayoutSubviews() configureNavgationBarLayOutSubviews() setLayoutData() } From abe5cc9d565b60978b129ca27d189f46093d176c Mon Sep 17 00:00:00 2001 From: Choyoungjun Date: Tue, 19 Nov 2024 10:12:12 +0900 Subject: [PATCH 4/4] =?UTF-8?q?chore=20::=20[#117]=20=ED=8A=9C=ED=94=8C=20?= =?UTF-8?q?=EA=B0=92=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Scene/Home/View/HomeSchoolMealView.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Projects/Presentation/Sources/Scene/Home/View/HomeSchoolMealView.swift b/Projects/Presentation/Sources/Scene/Home/View/HomeSchoolMealView.swift index a9944fc3..aea22e0a 100644 --- a/Projects/Presentation/Sources/Scene/Home/View/HomeSchoolMealView.swift +++ b/Projects/Presentation/Sources/Scene/Home/View/HomeSchoolMealView.swift @@ -11,7 +11,7 @@ import Domain import DesignSystem public class HomeSchoolMealView: BaseView { - private let schoolMealData = BehaviorRelay<[(Int, String, MealEntityElement)]>(value: []) + private let schoolMealData = BehaviorRelay<[(String, MealEntityElement)]>(value: []) private lazy var collectionViewFlowLayout = UICollectionViewFlowLayout().then { $0.scrollDirection = .vertical @@ -33,7 +33,7 @@ public class HomeSchoolMealView: BaseView { } public func setup( - schoolMealData: [(Int, String, MealEntityElement)] + schoolMealData: [(String, MealEntityElement)] ) { self.schoolMealData.accept(schoolMealData) } @@ -45,9 +45,9 @@ public class HomeSchoolMealView: BaseView { cellType: SchoolMealHomeCell.self )) { _, item, cell in cell.setup( - mealTime: item.1, - menu: item.2.menu, - kcal: item.2.kcal + mealTime: item.0, + menu: item.1.menu, + kcal: item.1.kcal ) }.disposed(by: disposeBag) }