Skip to content

Commit ace03f5

Browse files
authored
[NL-73]: 홈 화면 API 연동 및 로또 추천 로딩 화면 구현 (#43)
* [NL-73]: 로또 번호 추천 확인 API 연동 * [NL-73]: develop 빌드 에러 해결 * [NL-73]: Kingfisher 의존성 추가 * [NL-73]: 홈 API 연동 * [NL-73]: 폴더링 * [NL-73]: 로또 번호 추천 로딩 화면 구현 * [NL-73]: hidesBottomBarWhenPushed 옵션 구현
1 parent 1d72109 commit ace03f5

33 files changed

+1382
-124
lines changed

App/Sources/AppDelegate+Assembly.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Lib
1313
import NetworkCore
1414
import Onboarding
1515
import Setting
16+
import Home
1617

1718
extension AppDelegate {
1819
func setupDependencyInjector() {
@@ -23,6 +24,7 @@ extension AppDelegate {
2324
LibAssembly(),
2425
FortuneAssembly(),
2526
OnboardingAssembly(),
27+
HomeAssembly()
2628
])
2729
}
2830
}

App/Sources/AppDependencyHandler.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ struct AppDependencyHandler: DependencyRegistrable {
2727
// TODO: 이미 TabBarController 가 있는 경우에 대한 예외 처리
2828
let tabBarController = BaseTabBarController()
2929
tabBarController.viewControllers = [
30-
HomeViewController(viewModel: HomeViewModel()),
31-
FortuneViewController(viewModel: FortuneViewModel()),
32-
HistoryWebViewController(viewModel: HistoryWebViewModel()),
33-
MyPageViewController(viewModel: MyPageViewModel()),
30+
BaseNavigationController(rootViewController: HomeViewController(viewModel: HomeViewModel())),
31+
BaseNavigationController(rootViewController: FortuneViewController(viewModel: FortuneViewModel())),
32+
BaseNavigationController(rootViewController: HistoryWebViewController(viewModel: HistoryWebViewModel())),
33+
BaseNavigationController(rootViewController: MyPageViewController(viewModel: MyPageViewModel())),
3434
]
3535
UIApplication.shared.activeWindow?.rootViewController = tabBarController
3636
}

Common/Auth/Sources/UserDataManager.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ public final class UserDataManager {
1616
@Injected private var deviceUUIDManager: DeviceUUIDManager
1717
@Injected private var networkProvider: NetworkProvider
1818
public var user: UserDTO?
19+
public var userID: String { user?.id ?? deviceUUIDManager.deviceUUID }
1920

2021
@discardableResult
2122
public func fetch() async throws -> UserDTO {
22-
let userID = user?.id ?? deviceUUIDManager.deviceUUID
2323
let target = AuthTarget.GetUser(userID: userID)
2424
do {
2525
let user = try await networkProvider.request(target: target)
@@ -35,7 +35,6 @@ public final class UserDataManager {
3535
public func create(name: String, birthDate: String, birthTime: [String]?, gender: GenderDTO)
3636
async throws -> UserDTO
3737
{
38-
let userID = user?.id ?? deviceUUIDManager.deviceUUID
3938
let userModel = UserModel(
4039
id: userID, name: name, birthDate: birthDate, birthTime: birthTime, gender: gender)
4140
let target = AuthTarget.PostUser(userModel: userModel)
@@ -52,7 +51,6 @@ public final class UserDataManager {
5251
public func update(name: String, birthDate: String, birthTime: [String]?, gender: GenderDTO)
5352
async throws -> UserDTO
5453
{
55-
let userID = user?.id ?? deviceUUIDManager.deviceUUID
5654
let userModel = UserModel(
5755
id: userID, name: name, birthDate: birthDate, birthTime: birthTime, gender: gender)
5856
let target = AuthTarget.PutUser(userModel: userModel)

Common/Base/Sources/BaseViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ open class BaseViewController: UIViewController {
5353
navigationController?.setNavigationBarHidden(true, animated: false)
5454
view.addSubview(navigationBar)
5555
navigationBar.snp.makeConstraints { make in
56-
make.top.equalTo(view.snp.top)
5756
make.bottom.equalTo(view.safeAreaLayoutGuide.snp.top)
5857
make.horizontalEdges.equalToSuperview()
5958
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// BaseNavigationController.swift
3+
// Base
4+
//
5+
// Created by ttozzi on 8/17/25.
6+
//
7+
8+
import UIKit
9+
10+
public final class BaseNavigationController: UINavigationController {
11+
12+
public override func pushViewController(_ viewController: UIViewController, animated: Bool) {
13+
if viewController.hidesBottomBarWhenPushed {
14+
(tabBarController as? BaseTabBarController)?.setTabBarHidden(true, animated: false)
15+
}
16+
super.pushViewController(viewController, animated: animated)
17+
}
18+
19+
@discardableResult
20+
public override func popViewController(animated: Bool) -> UIViewController? {
21+
let popped = super.popViewController(animated: animated)
22+
let top = topViewController
23+
let shouldHideTabBar = top?.hidesBottomBarWhenPushed ?? false
24+
(tabBarController as? BaseTabBarController)?.setTabBarHidden(shouldHideTabBar, animated: false)
25+
return popped
26+
}
27+
28+
public override func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? {
29+
let poppedControllers = super.popToViewController(viewController, animated: animated)
30+
(tabBarController as? BaseTabBarController)?.setTabBarHidden(viewController.hidesBottomBarWhenPushed, animated: false)
31+
return poppedControllers
32+
}
33+
34+
public override func popToRootViewController(animated: Bool) -> [UIViewController]? {
35+
let poppedControllers = super.popToRootViewController(animated: animated)
36+
let shouldHideTabBar = viewControllers.first?.hidesBottomBarWhenPushed ?? false
37+
(tabBarController as? BaseTabBarController)?.setTabBarHidden(shouldHideTabBar, animated: false)
38+
return poppedControllers
39+
}
40+
}

Common/Base/Sources/NavigationBarItem.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public final class NaivgationBarButtonItem: UIButton, NavigationBarItem {
2525
make.size.equalTo(24)
2626
}
2727
}
28+
29+
override public func tintColorDidChange() {
30+
super.tintColorDidChange()
31+
let image = image(for: .normal)?.withRenderingMode(.alwaysTemplate)
32+
setImage(image?.withTintColor(tintColor), for: .normal)
33+
}
2834
}
2935

3036
extension NaivgationBarButtonItem {

Common/Base/Sources/TabBar/BaseTabBarController.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public final class BaseTabBarController: UITabBarController {
3333
}
3434
}
3535
}
36+
37+
override public func setTabBarHidden(_ hidden: Bool, animated: Bool) {
38+
customTabBar.isHidden = hidden
39+
}
3640

3741
private func setupTabBar() {
3842
tabBar.isHidden = true

Common/Lib/Sources/Router/AppRouter.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ extension Routable {
3434

3535
public func manageViewController(_ viewController: UIViewController, how: NavigateType) {
3636
switch how {
37-
case .push:
37+
case .push(let hidesBottomBarWhenPushed):
3838
if let navigationController = topViewController()?.navigationController {
39+
viewController.hidesBottomBarWhenPushed = hidesBottomBarWhenPushed
3940
navigationController.pushViewController(viewController, animated: true)
4041
}
4142
case .present:

Common/Lib/Sources/Router/Concreate/NavigateType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
public enum NavigateType {
9-
case push // NavigationController.pushViewController
9+
case push(hidesBottomBarWhenPushed: Bool = false) // NavigationController.pushViewController
1010
case present // 기본 present (모달)
1111
case fullscreen // modalPresentationStyle = .fullScreen
1212
case currentContext // modalPresentationStyle = .currentContext

Common/Project.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct CommonLayer: Layer {
4545
dependencies: [
4646
.external(name: "Then"),
4747
.external(name: "SnapKit"),
48+
.external(name: "Kingfisher"),
4849
.project(target: "CoreLayer", path: "../Core"),
4950
]
5051
),

0 commit comments

Comments
 (0)