Skip to content

Commit

Permalink
Merge pull request sopt-makers#345 from lsj8706/fix/sopt-makers#344-P…
Browse files Browse the repository at this point in the history
…oke-QA-반영

[Fix] sopt-makers#344- 콕 찌르기 1차 QA 반영
  • Loading branch information
lsj8706 authored Jan 2, 2024
2 parents 5cc3282 + 2de24a8 commit 68d5326
Show file tree
Hide file tree
Showing 35 changed files with 247 additions and 58 deletions.
2 changes: 1 addition & 1 deletion SOPT-iOS/Projects/Core/Sources/Literals/NotiList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
/// enum형 NotiList를 Notification.Name으로 return
/// - ex) NotificationCenter.default.post(name: NotiList.makeNotiName(list: <NotiList>), object: <>, userInfo: <>)
public enum NotiList: String {
case sample
case pokedResponse

public static func makeNotiName(list: NotiList) -> NSNotification.Name {
return Notification.Name(String(describing: list))
Expand Down
3 changes: 2 additions & 1 deletion SOPT-iOS/Projects/Core/Sources/Literals/StringLiterals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ public struct I18N {
public static let pokeMyFriends = "내 친구를 찔러보세요"
public static let pokeNearbyFriends = "내 친구의 친구를 찔러보세요"
public static let emptyFriendDescription = "아직 없어요 T.T\n내 친구가 더 많은 친구가 생길 때까지 기다려주세요"
public static let refreshGuide = "화면을 밑으로 당기면\n다른 친구를 볼 수 있어요"
public static let refreshGuide = "화면을 당기면\n다른 친구를 볼 수 있어요"
public static let pokeSuccess = "콕 찌르기를 완료했어요"
public static func makingFriendCompleted(name: String) -> String {
return "찌르기 답장으로\n\(name)님과 친구가 되었어요!"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ extension PokeMainRepository: PokeMainRepositoryInterface {
.map { $0.toDomain() }
.eraseToAnyPublisher()
}

public func checkPokeNewUser() -> AnyPublisher<Bool, Error> {
pokeService.isNewUser()
.map { $0.isNew }
.eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extension PokeOnboardingRepository: PokeOnboardingRepositoryInterface {
public func getMesseageTemplates(type: PokeMessageType) -> AnyPublisher<PokeMessagesModel, Error> {
self.pokeService
.getPokeMessages(messageType: type.rawValue)
.map { $0.messages.map { $0.toDomain() } }
.map { $0.toDomain() }
.eraseToAnyPublisher()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ public protocol PokeMainRepositoryInterface: PokeRepositoryInterface {
func getWhoPokeToMe() -> AnyPublisher<PokeUserModel?, Error>
func getFriend() -> AnyPublisher<[PokeUserModel], Error>
func getFriendRandomUser() -> AnyPublisher<[PokeFriendRandomUserModel], Error>
func checkPokeNewUser() -> AnyPublisher<Bool, Error>
}
17 changes: 15 additions & 2 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/PokeMainUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ public protocol PokeMainUseCase {
var pokedResponse: PassthroughSubject<PokeUserModel, Never> { get }
var madeNewFriend: PassthroughSubject<PokeUserModel, Never> { get }
var errorMessage: PassthroughSubject<String?, Never> { get }

var isPokeNewUser: PassthroughSubject<Bool, Never> { get set }

func getWhoPokedToMe()
func getFriend()
func getFriendRandomUser()
func poke(userId: Int, message: PokeMessageModel, willBeNewFriend: Bool)
func checkPokeNewUser()
}

public class DefaultPokeMainUseCase {
Expand All @@ -34,7 +36,8 @@ public class DefaultPokeMainUseCase {
public let pokedResponse = PassthroughSubject<PokeUserModel, Never>()
public let madeNewFriend = PassthroughSubject<PokeUserModel, Never>()
public let errorMessage = PassthroughSubject<String?, Never>()

public var isPokeNewUser = PassthroughSubject<Bool, Never>()

public init(repository: PokeMainRepositoryInterface) {
self.repository = repository
}
Expand Down Expand Up @@ -85,4 +88,14 @@ extension DefaultPokeMainUseCase: PokeMainUseCase {
}
}.store(in: self.cancelBag)
}

public func checkPokeNewUser() {
repository.checkPokeNewUser()
.catch { error in
print("CheckPokeNewUser State: \(error)")
return Just(false)
}.sink { [weak self] isNewUser in
self?.isPokeNewUser.send(isNewUser)
}.store(in: cancelBag)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public protocol PokeOnboardingUsecase {

var randomAcquaintances: PassthroughSubject<[PokeUserModel], Never> { get }
var pokedResponse: PassthroughSubject<PokeUserModel, Never> { get }
var errorMessage: PassthroughSubject<String?, Never> { get }
}

public final class DefaultPokeOnboardingUsecase {
Expand All @@ -24,6 +25,7 @@ public final class DefaultPokeOnboardingUsecase {

public let randomAcquaintances = PassthroughSubject<[PokeUserModel], Never>()
public let pokedResponse = PassthroughSubject<PokeUserModel, Never>()
public let errorMessage = PassthroughSubject<String?, Never>()

public init(repository: PokeOnboardingRepositoryInterface) {
self.repository = repository
Expand All @@ -45,6 +47,11 @@ extension DefaultPokeOnboardingUsecase: PokeOnboardingUsecase {
public func poke(userId: Int, message: PokeMessageModel) {
self.repository
.poke(userId: userId, message: message.content)
.catch { [weak self] error in
let message = error.toastMessage
self?.errorMessage.send(message)
return Empty<PokeUserModel, Never>()
}
.sink(
receiveCompletion: { _ in },
receiveValue: { [weak self] value in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Domain
public struct AttendanceModalDeepLink: DeepLinkExecutable {
public let name = "attendance-modal"
public let children: [DeepLinkExecutable] = []
public var isDestination: Bool = false

public init() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation
public protocol DeepLinkTreeNode {
var name: String { get }
var children: [DeepLinkExecutable] { get }
var isDestination: Bool { get set }
func findChild(name: String) -> DeepLinkExecutable?
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import BaseFeatureDependency
public struct NotificationDetailDeepLink: DeepLinkExecutable {
public let name = "detail"
public let children: [DeepLinkExecutable] = []
public var isDestination: Bool = false

public init() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Foundation
import Domain

public protocol PokeFeatureBuildable {
func makePokeMain() -> PokeMainPresentable
func makePokeMain(isRouteFromRoot: Bool) -> PokeMainPresentable
func makePokeMyFriends() -> PokeMyFriendsPresentable
func makePokeMyFriendsList(relation: PokeRelation) -> PokeMyFriendsListPresentable
func makePokeOnboarding() -> PokeOnboardingPresentable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public protocol PokeMainCoordinatable {
var onProfileImageTapped: ((Int) -> Void)? { get set }
var onPokeButtonTapped: ((PokeUserModel) -> Driver<(PokeUserModel, PokeMessageModel)>)? { get set }
var onNewFriendMade: ((String) -> Void)? { get set }
var switchToOnboarding: (() -> Void)? { get set }
}

public typealias PokeMainViewModelType = ViewModelType & PokeMainCoordinatable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// PokeNotificationListDeepLink.swift
// PokeFeature
//
// Created by sejin on 12/30/23.
// Copyright © 2023 SOPT-iOS. All rights reserved.
//

import Foundation
import BaseFeatureDependency

public struct PokeNotificationListDeepLink: DeepLinkExecutable {
public let name = "notification-list"
public let children: [DeepLinkExecutable] = []
public var isDestination: Bool = false

public init() {}

public func execute(with coordinator: Coordinator, queryItems: [URLQueryItem]?) -> Coordinator? {
guard let coordinator = coordinator as? PokeCoordinator else { return nil }

coordinator.runPokeNotificationListFlow()

return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public final class PokeBuilder {
}

extension PokeBuilder: PokeFeatureBuildable {
public func makePokeMain() -> PokeFeatureInterface.PokeMainPresentable {
public func makePokeMain(isRouteFromRoot: Bool) -> PokeFeatureInterface.PokeMainPresentable {
let useCase = DefaultPokeMainUseCase(repository: pokeMainRepository)
let viewModel = PokeMainViewModel(useCase: useCase)
let viewModel = PokeMainViewModel(useCase: useCase, isRouteFromRoot: isRouteFromRoot)
let pokeMainVC = PokeMainVC(viewModel: viewModel)
return (pokeMainVC, viewModel)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ final class PokeCoordinator: DefaultCoordinator {
}

public override func start() {
showPokeMain()
showPokeMain(isRouteFromRoot: false)
}

private func showPokeMain() {
var pokeMain = factory.makePokeMain()
public func showPokeMain(isRouteFromRoot: Bool) {
var pokeMain = factory.makePokeMain(isRouteFromRoot: isRouteFromRoot)

pokeMain.vm.onNaviBackTap = { [weak self] in
self?.router.dismissModule(animated: true)
Expand Down Expand Up @@ -66,14 +66,36 @@ final class PokeCoordinator: DefaultCoordinator {
pokeMain.vc.viewController.present(pokeMakingFriendCompletedVC, animated: false)
}

pokeMain.vm.switchToOnboarding = { [weak self] in
guard let self = self else { return }
self.runPokeOnboardingFlow()
}

rootController = pokeMain.vc.asNavigationController
router.present(rootController, animated: true, modalPresentationSytle: .overFullScreen)
}

private func runPokeNotificationListFlow() {
internal func runPokeOnboardingFlow() {
let pokeOnboardingCoordinator = PokeOnboardingCoordinator(
router: Router(
rootController: rootController ?? self.router.asNavigationController
),
factory: factory
)

pokeOnboardingCoordinator.finishFlow = { [weak self, weak pokeOnboardingCoordinator] in
pokeOnboardingCoordinator?.childCoordinators = []
self?.removeDependency(pokeOnboardingCoordinator)
}

addDependency(pokeOnboardingCoordinator)
pokeOnboardingCoordinator.switchToPokeOnboardingView()
}

internal func runPokeNotificationListFlow() {
let pokeNotificationListCoordinator = PokeNotificationListCoordinator(
router: Router(
rootController: rootController!
rootController: rootController ?? self.router.asNavigationController
),
factory: factory
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ public final class PokeOnboardingCoordinator: DefaultCoordinator {

extension PokeOnboardingCoordinator {
private func showPokeOnboardingView() {
var pokeOnboarding = makePokeOnboardingView()

self.rootController = pokeOnboarding.vc.asNavigationController
self.router.present(self.rootController, animated: true, modalPresentationSytle: .overFullScreen)
}

func switchToPokeOnboardingView() {
var pokeOnboarding = makePokeOnboardingView()

self.rootController = router.asNavigationController
self.router.setRootModule(pokeOnboarding.vc, hideBar: true, animated: false)
}

func makePokeOnboardingView() -> PokeOnboardingPresentable {
var pokeOnboarding = self.factory.makePokeOnboarding()

pokeOnboarding.vm.onNaviBackTapped = { [weak self] in
Expand Down Expand Up @@ -71,8 +85,7 @@ extension PokeOnboardingCoordinator {
let webView = SOPTWebView(startWith: url)
self?.rootController?.pushViewController(webView, animated: true)
}

self.rootController = pokeOnboarding.vc.asNavigationController
self.router.present(self.rootController, animated: true, modalPresentationSytle: .overFullScreen)

return pokeOnboarding
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,10 @@ extension PokeMainVC {
pokeUserView.changeUIAfterPoke(newUserModel: updatedUser)
}
}.store(in: cancelBag)

output.isLoading
.sink { [weak self] isLoading in
isLoading ? self?.showLoading() : self?.stopLoading()
}.store(in: self.cancelBag)
}
}
Loading

0 comments on commit 68d5326

Please sign in to comment.