Skip to content

Commit 923a49a

Browse files
committed
[feat] #83 알림 눌렀을 때 처리 추가
1 parent 09fe82b commit 923a49a

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed

Projects/App/Sources/AppDelegate/AppDelegateFeature.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ public struct AppDelegateFeature {
7878
catch: { _, _ in }
7979
case let .userNotifications(.willPresentNotification(_, completionHandler)):
8080
return .run { _ in completionHandler(.banner) }
81+
82+
case let .userNotifications(.didReceiveResponse(_, completionHandler)):
83+
return .run { send in
84+
await userDefaults.setBool(true, .fromBanner)
85+
completionHandler()
86+
}
8187
case .userNotifications:
8288
return .none
8389

Projects/App/Sources/Intro/IntroFeature.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import FeatureLogin
1111
@Reducer
1212
public struct IntroFeature {
1313
/// - Dependency
14-
14+
@Dependency(\.userDefaults) var userDefaults
1515
/// - State
1616
@ObservableState
1717
public enum State {
@@ -68,6 +68,9 @@ private extension IntroFeature {
6868

6969
case .delegate(.loginNeeded):
7070
return .run { send in
71+
/// 알람을 통해 앱을 들어왔으나 자동 로그인을 실패했다면 배너로 이동하지 못하게 flag 삭제
72+
await userDefaults.removeBool(.fromBanner)
73+
/// Todo: 원하는 애니메이션 넣어줘~
7174
await send(._sceneChange(.login()), animation: .smooth)
7275
}
7376

Projects/App/Sources/MainTab/MainTabFeature.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public struct MainTabFeature {
2121
private var pasteBoard
2222
@Dependency(\.categoryClient)
2323
private var categoryClient
24+
@Dependency(\.userDefaults)
25+
private var userDefaults
2426
/// - State
2527
@ObservableState
2628
public struct State: Equatable {
@@ -80,6 +82,7 @@ public struct MainTabFeature {
8082
case 포킷추가하기
8183
case 로그아웃
8284
case 회원탈퇴
85+
case 알림함이동
8386
}
8487
}
8588
/// initiallizer
@@ -150,6 +153,12 @@ private extension MainTabFeature {
150153

151154
case .onAppear:
152155
return .run { send in
156+
let fromBanner = userDefaults.boolKey(.fromBanner)
157+
if fromBanner {
158+
await userDefaults.removeBool(.fromBanner)
159+
await send(.delegate(.알림함이동))
160+
}
161+
153162
for await _ in self.pasteBoard.changes() {
154163
let url = try await pasteBoard.probableWebURL()
155164
await send(.inner(.linkCopySuccess(url)), animation: .pokitSpring)

Projects/App/Sources/MainTab/MainTabPath.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public extension MainTabFeature {
6060
switch action {
6161
/// - 네비게이션 바 `알림`버튼 눌렀을 때
6262
case .pokit(.delegate(.alertButtonTapped)),
63-
.remind(.delegate(.alertButtonTapped)):
63+
.remind(.delegate(.alertButtonTapped)),
64+
.delegate(.알림함이동):
6465
state.path.append(.알림함(PokitAlertBoxFeature.State()))
6566
return .none
6667

Projects/App/Sources/Root/RootFeature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public struct RootFeature {
5555
}
5656

5757
case .mainTab(.delegate(.로그아웃)),
58-
.mainTab(.delegate(.회원탈퇴)):
58+
.mainTab(.delegate(.회원탈퇴)):
5959
return .run { send in await send(._sceneChange(.intro(.login()))) }
6060

6161
case .intro, .mainTab:

Projects/CoreKit/Sources/Data/Client/UserDefaults/UserDefaultsKey.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import Foundation
1010
public enum UserDefaultsKey {
1111
public enum BoolKey: String {
1212
case autoSaveSearch
13+
/// - 배너를 클릭해서 들어왔을 때
14+
case fromBanner
1315
}
1416
public enum StringKey: String {
1517
/// `구글` or `애플`

0 commit comments

Comments
 (0)