From 7a4f0cf6f64f968cc9ef03db7fb5752fbc8f513d Mon Sep 17 00:00:00 2001 From: ysh Date: Wed, 2 Nov 2022 16:27:24 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=EC=98=A4=EC=98=A4.....=20=EA=B3=A0?= =?UTF-8?q?=EC=B3=A4=EB=8B=A4.=20=EC=B4=88=EA=B8=B0=20=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8VC=EC=97=90=EC=84=9C=20FeedVC=EB=A1=9C=20=EA=B0=88?= =?UTF-8?q?=EB=95=8C=20mainTAbVC=EC=97=AD=ED=99=9C=EC=9D=B4=20=ED=81=B0?= =?UTF-8?q?=EC=A4=84=20=EC=95=8C=EC=95=98=EB=8A=94=EB=8D=B0=20=EB=8B=A4?= =?UTF-8?q?=EC=8B=9C=20=EC=83=9D=EA=B0=81=ED=95=B4=EB=B3=B4=EB=8B=88=20?= =?UTF-8?q?=ED=83=AD=EB=B0=94=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=EB=8A=94?= =?UTF-8?q?=20=EC=BB=A8=ED=85=8C=EC=9D=B4=EB=84=88=EB=B7=B0=EA=B3=A0=20?= =?UTF-8?q?=EC=B2=AB=EB=B2=88=EC=A7=B8VC=EB=A5=BC=20=EC=B6=9C=EB=A0=A5?= =?UTF-8?q?=ED=95=98=EB=8A=94=EB=8D=B0=20=EA=B4=9C=ED=9E=88=20mainTabViewC?= =?UTF-8?q?ontroller=EB=A7=8C=20=EA=B3=A0=EC=B3=A4=EB=8B=A4..=20FeedVC=20v?= =?UTF-8?q?iewWillAppear(=5F:)=20=EC=88=98=EC=A0=95=ED=95=98=EB=8B=88?= =?UTF-8?q?=EA=B9=8C=20=EB=90=9C=EB=8B=A4..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Instagram/Controller/FeedController.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Clone App/Instagram/Instagram/Controller/FeedController.swift b/Clone App/Instagram/Instagram/Controller/FeedController.swift index 52a76f81..600ba091 100644 --- a/Clone App/Instagram/Instagram/Controller/FeedController.swift +++ b/Clone App/Instagram/Instagram/Controller/FeedController.swift @@ -10,14 +10,18 @@ import Firebase class FeedController: UICollectionViewController { - private let reuseIdentifier = "FeedCell" //MARK: - LifeCycle override func viewDidLoad() { super.viewDidLoad() - collectionView.register(FeedCell.self, forCellWithReuseIdentifier: reuseIdentifier ) + collectionView.register(FeedCell.self, forCellWithReuseIdentifier: FEEDCELLRESUIDENTIFIER ) + setupNavigationUI() + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + collectionView.register(FeedCell.self, forCellWithReuseIdentifier: FEEDCELLRESUIDENTIFIER) setupNavigationUI() - } } @@ -50,7 +54,7 @@ extension FeedController { } override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { - guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as? FeedCell else { + guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: FEEDCELLRESUIDENTIFIER, for: indexPath) as? FeedCell else { fatalError() } From 811b0a6c760c9f10268116c58f144f0882832fcb Mon Sep 17 00:00:00 2001 From: ysh Date: Wed, 2 Nov 2022 16:29:21 +0900 Subject: [PATCH 2/3] =?UTF-8?q?FeedVC=EC=9D=98=20id=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Clone App/Instagram/Instagram/Utils/Constants.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Clone App/Instagram/Instagram/Utils/Constants.swift b/Clone App/Instagram/Instagram/Utils/Constants.swift index 390862e5..76076683 100644 --- a/Clone App/Instagram/Instagram/Utils/Constants.swift +++ b/Clone App/Instagram/Instagram/Utils/Constants.swift @@ -20,3 +20,8 @@ let AUTH = Auth.auth() //MARK: - profile subview's ID let COLLECTIONHEADERREUSEABLEID = "UserProfileCollectionHeaderView" let CELLREUSEABLEID = "CollectionViewCell" + + +//MARK: - FeedVieController subview's ID + +let FEEDCELLRESUIDENTIFIER = "FeedCell" From 80f65ca9dbfe4e3d89a2915be226233324e68d32 Mon Sep 17 00:00:00 2001 From: ysh Date: Thu, 3 Nov 2022 00:38:21 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=EC=B4=88=EA=B8=B0=EC=97=90=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=B4=EC=96=B4=EB=B2=A0=EC=9D=B4=EC=8A=A4=EC=97=90=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=EB=90=9C=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=EA=B0=80=20=EC=97=86=EC=96=B4=EC=84=9C=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=99=94=EB=A9=B4=EC=97=90?= =?UTF-8?q?=EC=84=9C=EB=B6=80=ED=84=B0=20=EC=95=B1=EC=9D=B4=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=ED=95=A0=20=EB=95=8C=20MainTabVC=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=9D=B4=20=EB=A1=9C=EB=93=9C=EB=90=A0=20?= =?UTF-8?q?=EB=95=8C=20=EC=82=AC=EC=9A=A9=EC=9E=90=EA=B0=80=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=B4=EC=96=B4=EB=B2=A0=EC=9D=B4=EC=8A=A4=EC=97=90=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=90=9C=20=EA=B8=B0=EB=A1=9D?= =?UTF-8?q?=EC=9D=B4=20=EC=9E=88=EB=8A=94=EC=A7=80=20=ED=99=95=EC=9D=B8?= =?UTF-8?q?=ED=95=9C=20=ED=9B=84=EC=97=90=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=95=88=EB=90=98=EC=96=B4=EC=9E=88=EC=9C=BC=EB=A9=B4=20LoginV?= =?UTF-8?q?C=EB=A1=9C=20=EC=A0=84=ED=99=98=20=ED=9B=84=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=EC=9E=90=EA=B0=80=20=EB=A1=9C=EA=B7=B8=EC=9D=B8?= =?UTF-8?q?=EC=9D=84=20=EB=81=9D=EB=82=B4=EB=A9=B4=20mainhome=EC=9D=84=20?= =?UTF-8?q?=ED=86=B5=ED=95=B4=20first=20ViewControllers=EC=9D=98=20FeedVC?= =?UTF-8?q?=EB=A1=9C=20=EC=99=80=EC=95=BC=ED=95=98=EB=8A=94=EB=8D=B0=20mai?= =?UTF-8?q?nTabVC=EA=B0=80=20=EC=99=84=EC=A0=84=ED=9E=88=20=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=EB=90=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20=EC=B1=84?= =?UTF-8?q?=EB=A1=9C=20LoginVC=EB=A1=9C=20=ED=99=94=EB=A9=B4=20=EC=A0=84?= =?UTF-8?q?=ED=99=98=EC=9D=B4=20=EC=9D=BC=EC=96=B4=EB=82=98=EC=84=9C=20?= =?UTF-8?q?=EB=B6=80=EC=A0=81=EC=A0=88=ED=95=9C=20dismiss=EA=B0=80=20?= =?UTF-8?q?=EB=90=AC=EC=97=88=EB=8A=94=EB=8D=B0=20=EC=9D=B4=EB=A5=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=96=88=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xcdebugger/Expressions.xcexplist | 8 +++++ .../Instagram/Controller/FeedController.swift | 1 - .../Controller/MainHomeTabController.swift | 34 ++++++++++++++----- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Clone App/Instagram/Instagram.xcworkspace/xcuserdata/yangseunghyeon.xcuserdatad/xcdebugger/Expressions.xcexplist b/Clone App/Instagram/Instagram.xcworkspace/xcuserdata/yangseunghyeon.xcuserdatad/xcdebugger/Expressions.xcexplist index b40c5435..ba841b5d 100644 --- a/Clone App/Instagram/Instagram.xcworkspace/xcuserdata/yangseunghyeon.xcuserdatad/xcdebugger/Expressions.xcexplist +++ b/Clone App/Instagram/Instagram.xcworkspace/xcuserdata/yangseunghyeon.xcuserdatad/xcdebugger/Expressions.xcexplist @@ -38,5 +38,13 @@ + + + + + + diff --git a/Clone App/Instagram/Instagram/Controller/FeedController.swift b/Clone App/Instagram/Instagram/Controller/FeedController.swift index 600ba091..ce9b8715 100644 --- a/Clone App/Instagram/Instagram/Controller/FeedController.swift +++ b/Clone App/Instagram/Instagram/Controller/FeedController.swift @@ -15,7 +15,6 @@ class FeedController: UICollectionViewController { override func viewDidLoad() { super.viewDidLoad() collectionView.register(FeedCell.self, forCellWithReuseIdentifier: FEEDCELLRESUIDENTIFIER ) - setupNavigationUI() } override func viewWillAppear(_ animated: Bool) { diff --git a/Clone App/Instagram/Instagram/Controller/MainHomeTabController.swift b/Clone App/Instagram/Instagram/Controller/MainHomeTabController.swift index 20312990..2c6ec83a 100644 --- a/Clone App/Instagram/Instagram/Controller/MainHomeTabController.swift +++ b/Clone App/Instagram/Instagram/Controller/MainHomeTabController.swift @@ -17,22 +17,37 @@ class MainHomeTabController: UITabBarController { } } + private var isLogin: Bool? { + didSet { + guard let isLogin = isLogin else { return } + if !isLogin { + DispatchQueue.main.async { + self.presentLoginScene() + } + } + } + } + + //MARK: - Lifecycle override func viewDidLoad() { super.viewDidLoad() view.backgroundColor = .white + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) configure() } -} +} //MARK: - Helpers extension MainHomeTabController { func configure() { customTabBarUI() - checkIfUserIsLoggedIn() - fetchUserInfo() + isLogin = isUserLogined() } func configureViewControllers() { @@ -114,15 +129,16 @@ extension MainHomeTabController { } //MARK: - API. check user's membership - func checkIfUserIsLoggedIn() { + func isUserLogined() -> Bool { if Auth.auth().currentUser == nil { - DispatchQueue.main.async { - self.view.isHidden = true - self.presentLoginScene() - } + return false } + fetchUserInfo() + return true } + + func presentLoginScene() { let controller = LoginController() controller.authDelegate = self @@ -138,10 +154,10 @@ extension MainHomeTabController: AuthentificationDelegate { func authenticationCompletion() { UserService.fetchCurrentUserInfo() { userInfo in guard let userInfo = userInfo else { return } + self.viewDidLoad() self.userVM = UserInfoViewModel(user: userInfo, profileImage: nil) } self.dismiss(animated: false) } - }