Skip to content

Commit 7930a40

Browse files
[Feature/#87] Coordinator 적용 및 나가기 버튼 구현 (#97)
* [STYLE]: swiftLint 해결 * [FEAT]: BaseCoordinator 구현 * [FEAT]: Container 추가 및 Coordinator 구현 * [FEAT]: Connection에 Coordinator 적용 * [FEAT]: GroupInfo에 Coordinator 적용 * [FEAT]: VideoList에 Coordinator 적용 * [FEAT]: ShareVideoEdit에 Coordinator 적용 * [REFACT]: GroupInforView 레이아웃 수정 * [FEAT]: Preview에 Coordinator 적용 * [FEAT]: SharedVideoEdit에 Preview 연결 * [STYLE]: 메서드 네이밍 변경 * [FEAT]: AppDelegate & SceneDelegate Main에 맞게 수정 * [FEAT]: AppRoot에 MainViewController 구현 * [FEAT]: 불필요한 파일 삭제 및 의존성 주입 수정 * [FIX]: owner.name으로 하면 발생하는 버그 임시 조치
1 parent 2c925b8 commit 7930a40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+771
-355
lines changed
File renamed without changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// SceneDelegate.swift
3+
// App
4+
//
5+
// Created by jung on 11/4/24.
6+
//
7+
8+
import Core
9+
import Data
10+
import Feature
11+
import Interfaces
12+
import P2PSocket
13+
import UIKit
14+
import UseCase
15+
16+
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
17+
var window: UIWindow?
18+
let container = MainContainer()
19+
var coordinator: Coordinator?
20+
21+
func scene(
22+
_ scene: UIScene,
23+
willConnectTo session: UISceneSession,
24+
options connectionOptions: UIScene.ConnectionOptions
25+
) {
26+
guard let windowScene = (scene as? UIWindowScene) else { return }
27+
28+
let coordinator = container.coordinator()
29+
self.coordinator = coordinator
30+
coordinator.start(nil)
31+
let window = UIWindow(windowScene: windowScene)
32+
window.rootViewController = coordinator.viewController
33+
34+
self.window = window
35+
window.makeKeyAndVisible()
36+
}
37+
}

App/App/MainContainer.swift

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//
2+
// MainContainer.swift
3+
// App
4+
//
5+
// Created by jung on 12/6/24.
6+
//
7+
8+
import Core
9+
import Feature
10+
import P2PSocket
11+
import UseCase
12+
import Data
13+
import Interfaces
14+
15+
final class MainContainer:
16+
ConnectionDependency,
17+
VideoListDependency,
18+
GroupInfoDependency,
19+
SharedEditVideoDependency,
20+
PreviewDependency {
21+
let socketProvider = SocketProvider()
22+
23+
func coordinator() -> Coordinator {
24+
let groupInfoContainer = GroupInfoContainer(dependency: self)
25+
let connectionContainer = ConnectionContainer(dependency: self)
26+
27+
return MainCoordinator(
28+
groupInfoContainer: groupInfoContainer,
29+
connectionContainer: connectionContainer
30+
)
31+
}
32+
33+
// MARK: - Containable
34+
var videoListContaiable: VideoListContainable {
35+
return VideoListContainer(dependency: self)
36+
}
37+
38+
var sharedEditVideoContainer: SharedEditVideoContainable {
39+
return SharedVideoEditContainer(dependency: self)
40+
}
41+
42+
var previewContainer: PreviewContainable {
43+
return PreviewContainer(dependency: self)
44+
}
45+
46+
// MARK: - Repository
47+
var browsingUserRepository: BrowsingUserRepositoryInterface {
48+
return BrowsingUserRepository(socketProvider: socketProvider)
49+
}
50+
51+
var connectedUserRepository: ConnectedUserRepositoryInterface {
52+
return ConnectedUserRepository(socketProvider: socketProvider)
53+
}
54+
55+
var sharingVideoRepository: SharingVideoRepositoryInterface {
56+
return SharingVideoRepository(socketProvider: socketProvider)
57+
}
58+
59+
var editVideoRepository: EditVideoRepositoryInterface {
60+
return EditVideoRepository(socketProvider: socketProvider)
61+
}
62+
63+
// MARK: - UseCase
64+
var browsingUseCase: BrowsingUserUseCaseInterface {
65+
return BrowsingUserUseCase(repository: browsingUserRepository)
66+
}
67+
68+
var connectedUserUseCase: ConnectedUserUseCaseInterface {
69+
return ConnectedUserUseCase(repository: connectedUserRepository)
70+
}
71+
72+
lazy var videoUseCase: VideoUseCase = {
73+
return VideoUseCase(sharingVideoRepository: sharingVideoRepository, editVideoRepository: editVideoRepository)
74+
}()
75+
76+
var sharingVideoUseCase: SharingVideoUseCaseInterface {
77+
videoUseCase
78+
}
79+
80+
var editVideoUseCase: EditVideoUseCaseInterface {
81+
videoUseCase
82+
}
83+
}

App/App/MainCoordinator.swift

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//
2+
// MainCoordinator.swift
3+
// App
4+
//
5+
// Created by jung on 12/6/24.
6+
//
7+
8+
import Core
9+
import Feature
10+
import UIKit
11+
12+
public final class MainCoordinator: Coordinator {
13+
private var bottomNavigationController: UINavigationController?
14+
15+
// MARK: - Coordinatables
16+
private let groupInfoContainer: GroupInfoContainable
17+
private var groupInfoCoordinatable: Coordinatable?
18+
19+
private let connectionContainer: ConnectionContainable
20+
private var connectionCoordinatable: Coordinatable?
21+
22+
// MARK: - Initializer
23+
public init(
24+
groupInfoContainer: GroupInfoContainable,
25+
connectionContainer: ConnectionContainable
26+
) {
27+
self.groupInfoContainer = groupInfoContainer
28+
self.connectionContainer = connectionContainer
29+
super.init(viewController: MainViewController())
30+
}
31+
32+
public override func start(_ navigationController: UINavigationController?) {
33+
guard let viewController = viewController as? MainViewController else { return }
34+
35+
let topViewController = groupInfoViewController()
36+
let bottomViewController = connectionViewController()
37+
viewController.attachTopViewController(topViewController)
38+
viewController.attachBottomViewController(bottomViewController)
39+
}
40+
}
41+
42+
private extension MainCoordinator {
43+
func connectionViewController() -> UIViewController {
44+
let coordinator = connectionContainer.coordinator(listener: self)
45+
connectionCoordinatable = coordinator
46+
let navigation = UINavigationController(rootViewController: coordinator.viewController)
47+
bottomNavigationController = navigation
48+
coordinator.start(navigation)
49+
50+
return navigation
51+
}
52+
53+
func groupInfoViewController() -> UIViewController {
54+
let coordinator = groupInfoContainer.coordinator(listener: self)
55+
groupInfoCoordinatable = coordinator
56+
let navigation = UINavigationController(rootViewController: coordinator.viewController)
57+
coordinator.start(navigation)
58+
59+
return navigation
60+
}
61+
}
62+
63+
// MARK: - ConnectionListener
64+
extension MainCoordinator: ConnectionListener { }
65+
66+
// MARK: - GroupInfoListener
67+
extension MainCoordinator: GroupInfoListener {
68+
public func exitGroupButtonDidTap() {
69+
FileSystemManager.shared.deleteAllFiles()
70+
bottomNavigationController?.popToRootViewController(animated: true)
71+
connectionCoordinatable?.start(bottomNavigationController)
72+
}
73+
}

App/App/MainViewController.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// MainViewController.swift
3+
// App
4+
//
5+
// Created by jung on 12/6/24.
6+
//
7+
8+
import SnapKit
9+
import UIKit
10+
11+
final class MainViewController: UIViewController {
12+
private enum Constants {
13+
static let topViewHeight: CGFloat = 200
14+
}
15+
16+
func attachTopViewController(_ viewController: UIViewController) {
17+
addChild(viewController)
18+
view.addSubview(viewController.view)
19+
viewController.didMove(toParent: self)
20+
viewController.view.backgroundColor = .red
21+
viewController.view.snp.makeConstraints { make in
22+
make.top.equalTo(view.safeAreaLayoutGuide)
23+
make.leading.equalToSuperview()
24+
make.trailing.equalToSuperview()
25+
make.height.equalTo(Constants.topViewHeight)
26+
}
27+
}
28+
29+
func attachBottomViewController(_ viewController: UIViewController) {
30+
addChild(viewController)
31+
view.addSubview(viewController.view)
32+
viewController.didMove(toParent: self)
33+
34+
viewController.view.snp.makeConstraints { make in
35+
make.top.equalToSuperview().offset(Constants.topViewHeight)
36+
make.leading.trailing.equalToSuperview()
37+
make.bottom.equalTo(view.safeAreaLayoutGuide)
38+
}
39+
}
40+
}

App/App/RootViewController.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

App/App/SceneDelegate.swift

Lines changed: 0 additions & 145 deletions
This file was deleted.

0 commit comments

Comments
 (0)