Skip to content

Commit 32810c2

Browse files
committed
✨ [feat] 게스트 진입 시 북마크 버튼 탭 시 회원가입 유도하도록 구현
1 parent ce4ad28 commit 32810c2

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

Fitfty/Projects/Common/Sources/Extension/Notification.Name+extension.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ public extension Notification.Name {
1414
static let selectPhAsset = Notification.Name(rawValue: "selectPhAsset")
1515
static let resignKeyboard = Notification.Name(rawValue: "resignKeyboard")
1616
static let showKeyboard = Notification.Name(rawValue: "showKeyboard")
17+
static let showLoginNotification = Notification.Name(rawValue: "showLoginNotification")
1718
}

Fitfty/Projects/Coordinator/Sources/TabCoordinator.swift

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ final class TabCoordinator: NSObject, Coordinator, TabCoordinatorProtocol {
8888
let controllers: [BaseNavigationController] = pages.map({ getTabController($0) })
8989

9090
prepareTabBarController(withTabControllers: controllers)
91+
NotificationCenter.default.addObserver(
92+
self,
93+
selector: #selector(showLoginNotification(_:)),
94+
name: .showLoginNotification,
95+
object: nil
96+
)
9197
}
9298

9399
private func prepareTabBarController(withTabControllers tabControllers: [UIViewController]) {
@@ -175,6 +181,16 @@ final class TabCoordinator: NSObject, Coordinator, TabCoordinatorProtocol {
175181
return TabBarPage.init(index: tabBarController.selectedIndex)
176182
}
177183

184+
@objc
185+
private func showLoginNotification(_ sender: Notification? = nil) {
186+
let alert = UIAlertController(title: "", message: "회원가입 시 코디 저장, 내 핏프티 업로드,\n계정 관리 등이 가능합니다.\n3초 소셜 로그인으로 더 많은 핏프티의 기능을 누려보세요!", preferredStyle: .alert)
187+
alert.addAction(UIAlertAction(title: "그냥 둘러보기", style: .default))
188+
alert.addAction(UIAlertAction(title: "회원가입", style: .default, handler: { _ in
189+
self.reloadWindow()
190+
}))
191+
tabBarController.present(alert, animated: true)
192+
}
193+
178194
}
179195

180196
extension TabCoordinator: UITabBarControllerDelegate {
@@ -184,12 +200,7 @@ extension TabCoordinator: UITabBarControllerDelegate {
184200
shouldSelect viewController: UIViewController
185201
) -> Bool {
186202
if DefaultUserManager.shared.getCurrentGuestState() {
187-
let alert = UIAlertController(title: "", message: "회원가입 시 코디 저장, 내 핏프티 업로드,\n계정 관리 등이 가능합니다.\n3초 소셜 로그인으로 더 많은 핏프티의 기능을 누려보세요!", preferredStyle: .alert)
188-
alert.addAction(UIAlertAction(title: "그냥 둘러보기", style: .default))
189-
alert.addAction(UIAlertAction(title: "회원가입", style: .default, handler: { _ in
190-
self.reloadWindow()
191-
}))
192-
navigationController.present(alert, animated: true)
203+
showLoginNotification()
193204
return false
194205
} else {
195206
guard let indexOfTab = tabBarController.viewControllers?.firstIndex(of: viewController),

Fitfty/Projects/MainFeed/Sources/Main/Home/ViewModel/CodyCellViewModel.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ final class CodyCellViewModel {
2121

2222
private let cody: CodyResponse
2323
private let fitftyRepository: FitftyRepository
24+
private let userManager: UserManager
2425
private var currentState: CurrentValueSubject<ViewModelState?, Never> = .init(nil)
2526
private var isBookmark: Bool
2627

27-
init(fitftyRepository: FitftyRepository, cody: CodyResponse) {
28+
init(
29+
fitftyRepository: FitftyRepository,
30+
userManager: UserManager,
31+
cody: CodyResponse
32+
) {
2833
self.fitftyRepository = fitftyRepository
34+
self.userManager = userManager
2935
self.cody = cody
3036
self.isBookmark = cody.bookmarked
3137
}
@@ -58,6 +64,11 @@ extension CodyCellViewModel: CodyCellViewModelInput {
5864
private extension CodyCellViewModel {
5965

6066
func requestBookmark() {
67+
guard userManager.getCurrentGuestState() == false else {
68+
NotificationCenter.default.post(name: .showLoginNotification, object: nil)
69+
currentState.send(.bookmarkState(false))
70+
return
71+
}
6172
Task { [weak self] in
6273
guard let self = self else {
6374
return

Fitfty/Projects/MainFeed/Sources/Main/Home/Views/CodyCell.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ final class CodyCell: UICollectionViewCell {
125125
extension CodyCell {
126126

127127
func setUp(cody: CodyResponse) {
128-
viewModel = .init(fitftyRepository: DefaultFitftyRepository(), cody: cody)
128+
viewModel = .init(
129+
fitftyRepository: DefaultFitftyRepository(),
130+
userManager: DefaultUserManager.shared,
131+
cody: cody
132+
)
129133
bind()
130134
viewModel?.input.fetch()
131135
}

0 commit comments

Comments
 (0)