From aebbcedfc934051ad7f02aacc985e8ddc022e2de Mon Sep 17 00:00:00 2001 From: solbat Date: Tue, 13 Dec 2022 22:14:09 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=ED=9B=84=20=EC=B2=AB=20=ED=99=88=20=ED=99=94=EB=A9=B4=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EB=B9=88=20=ED=99=94=EB=A9=B4=EC=9D=B4=20=EB=82=98?= =?UTF-8?q?=EC=98=A4=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TabBar/Home/HomeViewController.swift | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/SpaceCapsule/SpaceCapsule/Scene/TabBar/Home/HomeViewController.swift b/SpaceCapsule/SpaceCapsule/Scene/TabBar/Home/HomeViewController.swift index 2819491..00a076f 100644 --- a/SpaceCapsule/SpaceCapsule/Scene/TabBar/Home/HomeViewController.swift +++ b/SpaceCapsule/SpaceCapsule/Scene/TabBar/Home/HomeViewController.swift @@ -27,11 +27,9 @@ final class HomeViewController: UIViewController, BaseViewController { override func viewDidLoad() { super.viewDidLoad() - configure() + title = "홈" configureView() bind() - - title = "홈" } override func viewWillAppear(_ animated: Bool) { @@ -39,12 +37,23 @@ final class HomeViewController: UIViewController, BaseViewController { viewModel?.input.viewWillAppear.onNext(()) } - private func configure() { - AppDataManager.shared.fetchCapsules() - } - private func configureView() { view.backgroundColor = .themeBackground + + viewModel?.output.featuredCapsuleCellItems + .withUnretained(self) + .bind { owner, capsuleCellItems in + owner.view.subviews.forEach({ $0.removeFromSuperview() }) + if capsuleCellItems.isEmpty { + owner.showEmptyView() + } else { + owner.emptyView = nil + owner.showHomeView() + } + } + .disposed(by: disposeBag) + + AppDataManager.shared.fetchCapsules() } private func showEmptyView() { @@ -79,19 +88,6 @@ final class HomeViewController: UIViewController, BaseViewController { return } - viewModel.output.featuredCapsuleCellItems - .withUnretained(self) - .bind { owner, capsuleCellItems in - owner.view.subviews.forEach({ $0.removeFromSuperview() }) - if capsuleCellItems.isEmpty { - owner.showEmptyView() - } else { - owner.emptyView = nil - owner.showHomeView() - } - } - .disposed(by: disposeBag) - viewModel.output.featuredCapsuleCellItems .bind(to: homeView.capsuleCollectionView.rx.items) { collectionView, index, element in guard let cell = collectionView.dequeueReusableCell(