Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#726 profile view #757

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 14th-team5-iOS/Bibbi/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
PrivacyDIContainer(),
PickDICotainer(),
ResignDIContainer(),
NotificationDIContainer()
]
containers.forEach {
$0.registerDependencies()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// NotificationDIContainer.swift
// Bibbi
//
// Created by 마경미 on 31.01.25.
//

import Core
import Data
import Domain

final class NotificationDIContainer: BaseContainer {
private func makeNotificationRepository() -> NotificationRepositoryPorotocol {
return NotificationRepository()
}

private func makeFetchNotificationUseCase() -> FetchNotificationUseCaseProtocol {
FetchNotificationUseCase(notificationRepository: makeNotificationRepository()
)
}

func registerDependencies() {
container.register(type: FetchNotificationUseCaseProtocol.self) { _ in self.makeFetchNotificationUseCase()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Domain

final class PostDIContainer: BaseContainer {
private let familyRepository: FamilyRepositoryProtocol = FamilyRepository()
private let postListRepository: PostListRepositoryProtocol = PostRepository()
private let postListRepository: PostRepositoryProtocol = PostRepository()

private func makePostUseCase() -> FetchPostListUseCaseProtocol {
return FetchPostListUseCase(postListRepository: postListRepository, familyRepository: familyRepository)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ protocol MainNavigatorProtocol: BaseNavigator {
func toDailyCalendar(_ date: String)
func toFamilyManagement()
func toMonthlyCalendar()
func toNotification()
}

final class MainNavigator: MainNavigatorProtocol {
Expand Down Expand Up @@ -86,4 +87,8 @@ final class MainNavigator: MainNavigatorProtocol {
navigationController.pushViewController(vc, animated: true)
}

func toNotification() {
let vc = NotificationViewControllerWrapper().viewController
navigationController.pushViewController(vc, animated: true)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// NotificationNavigator.swift
// Bibbi
//
// Created by 마경미 on 31.01.25.
//

import UIKit

import Core

protocol NotificationNavigatorProtocol: BaseNavigator {
func toPost()
func toMission()
func toPostComment()
}

final class NotificationNavigator: NotificationNavigatorProtocol {
var navigationController: UINavigationController

init(navigationController: UINavigationController) {
self.navigationController = navigationController
}

func toPost() {

}

func toMission() {

}

func toPostComment() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// NotificationViewControllerWrapper.swift
// Bibbi
//
// Created by 마경미 on 30.01.25.
//

import Core
import Foundation
import MacrosInterface

@Wrapper<NotificationReactor, NotificationViewController>
final class NotificationViewControllerWrapper {

// MARK: - Make

func makeReactor() -> NotificationReactor {
NotificationReactor()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,33 @@ import MacrosInterface
@Wrapper<PostReactor, PostViewController>
final class PostDetailViewControllerWrapper {

private let selectedIndex: Int
private let originPostLists: PostSection.Model
private var selectedIndex: Int?
private var originPostLists: PostSection.Model?

private var postId: String?

init(selectedIndex: Int, originPostLists: PostSection.Model) {
self.selectedIndex = selectedIndex
self.originPostLists = originPostLists
}

init(postId: String) {
self.postId = postId
}

func makeReactor() -> R {
return PostReactor(initialState: .init(selectedIndex: selectedIndex, originPostLists: originPostLists))
if let selectedIndex,
let originPostLists {
return PostReactor(
selectedIndex: selectedIndex,
originPostLists: originPostLists
)
}

if let postId {
return PostReactor(postId: postId)
}

return .init(postId: "null")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

podtId μ΄ˆκΈ°κ°’μœΌλ‘œ null은 μ™œ μžˆλŠ” κ±΄κ°€μš”?

}

}
109 changes: 109 additions & 0 deletions 14th-team5-iOS/Bibbi/Sources/Application/Router/DDeepLinkManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import Foundation
import Core
import UIKit

// MARK: - λ”₯링크 ν•Έλ“€λŸ¬
final class DeepLinkHandler {
var deepLink: DeepLinkProtocol?

init(urlString: String) {
guard let url = URL(string: urlString) else {
deepLink = nil
return
}

let pathComponents = url.pathComponents
.filter { !$0.isEmpty && $0 != "/" }

let queryParams = URLComponents(
url: url,
resolvingAgainstBaseURL: false
)?.queryItems

switch pathComponents.first?.lowercased() {
case "main":
deepLink = MainDeepLink(
pathComponents: pathComponents,
queryParams: queryParams
)
case "post":
deepLink = PostDeepLink(
pathComponents: pathComponents,
queryParams: queryParams
)
case "profile":
deepLink = ProfileDeepLink(
pathComponents: pathComponents
)
case "store":
deepLink = StoreDeepLink(
pathComponents: pathComponents
)
default:
deepLink = nil
}
}

func doDeepLink() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeepLinkHandler에 μ„ μ–ΈλœdoDeepLink λ©”μ„œλ“œλž‘ DeepLinkProtocol에 μ„ μ–Έλœ doDeepLink λž‘ 넀이밍이 κ²Ήμ³μ„œ λ‚˜μ€‘μ— μ°ΎκΈ° νž˜λ“€ 것 같은데 λ‹€λ₯΄κ²Œ μ„ μ–Έν•˜λŠ” 건 μ–΄λ–€κ°€μš”?

do {
guard let deepLink else {
throw DeepLinkError.notFound
}

try deepLink.doDeepLink()
} catch let error as DeepLinkError {
BBToast.text(error.message).show()
} catch {
BBToast.text("μ•Œ 수 μ—†λŠ” 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.").show()
}
}
}

enum DeepLinkError: Error {
case invalidLink
case notFound
case errorOccurred
case invalidNavigation

var message: String {
switch self {
case .invalidLink:
return "잘λͺ»λœ λ§ν¬μž…λ‹ˆλ‹€."
case .notFound:
return "μš”μ²­ν•œ νŽ˜μ΄μ§€λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."
case .errorOccurred:
return "μš”μ²­ 쀑 μ—λŸ¬κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€."
case .invalidNavigation:
return "ν˜„μž¬ νŽ˜μ΄μ§€λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."
}
}
}

protocol DeepLinkProtocol {
func doDeepLink() throws
}

extension DeepLinkProtocol {
func getNavigationController() -> UINavigationController? {
return (UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.flatMap { $0.windows }
.first { $0.isKeyWindow }?
.rootViewController as? UINavigationController)
}

func popToViewController<T: UIViewController>(ofType type: T.Type, animated: Bool = true) {
guard let navigationController = getNavigationController() else {
return
}

for controller in navigationController.viewControllers.reversed() {
if controller is T {
navigationController.popToViewController(controller, animated: animated)
return
}
}

navigationController.popToRootViewController(animated: animated)
}
}
59 changes: 59 additions & 0 deletions 14th-team5-iOS/Bibbi/Sources/Application/Router/MainDeepLink.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// MainDeepLink.swift
// Bibbi
//
// Created by 마경미 on 24.02.25.
//

import Foundation

import Core

// MARK: - Main λ”₯링크
final class MainDeepLink: DeepLinkProtocol {
enum MainDeepLinkType {
case openMain
case openMission
}

var type: MainDeepLinkType?

init(
pathComponents: [String],
queryParams: [URLQueryItem]?
) {
if let isMission = queryParams?.first(where: {
$0.name == "openMission"})?.value {

if isMission == "true" {
type = .openMission
} else {
type = .openMain
}
}
}

func doDeepLink() throws {
guard let type else {
throw DeepLinkError.invalidLink
}

switch type {
case .openMission: openMission()
case .openMain: popToMain()
}
}
}

extension MainDeepLink {
private func popToMain() {
popToViewController(
ofType: MainViewController.self,
animated: true
)
}

private func openMission() {
popToMain()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μš”κΈ° openMission 인데 popToMain이라 λ˜μ–΄ μžˆλŠ”κ±°λŠ” 쑰금 ν—·κ°ˆλ¦΄ 것 같은데 pushToMission 으둜 ν•˜λŠ” 건 μ–΄λ–€κ°€μš”?

}
}
Loading