@@ -11,6 +11,7 @@ import FeaturePokit
1111import FeatureRemind
1212import FeatureContentDetail
1313import Domain
14+ import DSKit
1415import Util
1516import CoreKit
1617
@@ -28,7 +29,7 @@ public struct MainTabFeature {
2829 public struct State : Equatable {
2930 var selectedTab : MainTab = . pokit
3031 var isBottomSheetPresented : Bool = false
31- var isLinkSheetPresented : Bool = false
32+ var linkPopup : PokitLinkPopup . PopupType ?
3233 var isErrorSheetPresented : Bool = false
3334 var link : String ?
3435
@@ -40,6 +41,7 @@ public struct MainTabFeature {
4041 @Presents var contentDetail : ContentDetailFeature . State ?
4142 @Shared ( . inMemory( " SelectCategory " ) ) var categoryId : Int ?
4243 @Shared ( . inMemory( " PushTapped " ) ) var isPushTapped : Bool = false
44+ var categoryOfSavedContent : BaseCategoryItem ?
4345
4446 public init ( ) {
4547 self . pokit = . init( )
@@ -64,7 +66,7 @@ public struct MainTabFeature {
6466 public enum View : Equatable {
6567 case addButtonTapped
6668 case addSheetTypeSelected( TabAddSheetType )
67- case linkCopyButtonTapped
69+ case 링크팝업_버튼_눌렀을때
6870 case onAppear
6971 case onOpenURL( url: URL )
7072 case 경고_확인버튼_클릭
@@ -75,6 +77,8 @@ public struct MainTabFeature {
7577 case 공유포킷_이동( sharedCategory: CategorySharing . SharedCategory )
7678 case 경고_띄움( BaseError )
7779 case errorSheetPresented( Bool )
80+ case 링크팝업_활성화( PokitLinkPopup . PopupType )
81+ case 카테고리상세_이동( category: BaseCategoryItem )
7882 }
7983 public enum AsyncAction : Equatable {
8084 case 공유받은_카테고리_조회( categoryId: Int )
@@ -93,6 +97,10 @@ public struct MainTabFeature {
9397 /// - Reducer Core
9498 private func core( into state: inout State , action: Action ) -> Effect < Action > {
9599 switch action {
100+ case . binding( \. linkPopup) :
101+ guard state. linkPopup == nil else { return . none }
102+ state. categoryOfSavedContent = nil
103+ return . none
96104 case . binding:
97105 return . none
98106 case let . pushAlertTapped( isTapped) :
@@ -156,9 +164,8 @@ private extension MainTabFeature {
156164 case . 포킷추가: return . send( . delegate( . 포킷추가하기) )
157165 }
158166
159- case . linkCopyButtonTapped:
160- state. isLinkSheetPresented = false
161- return . run { send in await send ( . delegate( . 링크추가하기) ) }
167+ case . 링크팝업_버튼_눌렀을때:
168+ return linkPopupButtonTapped ( state: & state)
162169
163170 case . onAppear:
164171 if state. isPushTapped {
@@ -177,15 +184,15 @@ private extension MainTabFeature {
177184 }
178185 )
179186 case . onOpenURL( url: let url) :
180- guard let components = URLComponents ( url : url , resolvingAgainstBaseURL : false ) else {
181- return . none
182- }
187+ guard
188+ let components = URLComponents ( url : url , resolvingAgainstBaseURL : false )
189+ else { return . none }
183190
184191 let queryItems = components. queryItems ?? [ ]
185- guard let categoryIdString = queryItems . first ( where : { $0 . name == " categoryId " } ) ? . value ,
186- let categoryId = Int ( categoryIdString ) else {
187- return . none
188- }
192+ guard
193+ let categoryIdString = queryItems . first ( where : { $0 . name == " categoryId " } ) ? . value ,
194+ let categoryId = Int ( categoryIdString )
195+ else { return . none }
189196
190197 return . send( . async( . 공유받은_카테고리_조회( categoryId: categoryId) ) )
191198 case . 경고_확인버튼_클릭:
@@ -198,7 +205,10 @@ private extension MainTabFeature {
198205 switch action {
199206 case let . linkCopySuccess( url) :
200207 guard let url else { return . none }
201- state. isLinkSheetPresented = true
208+ state. linkPopup = . link(
209+ title: Constants . 복사한_링크_저장하기_문구,
210+ url: url. absoluteString
211+ )
202212 state. link = url. absoluteString
203213 return . none
204214
@@ -209,7 +219,18 @@ private extension MainTabFeature {
209219 case let . errorSheetPresented( isPresented) :
210220 state. isErrorSheetPresented = isPresented
211221 return . none
212-
222+
223+ case let . 링크팝업_활성화( type) :
224+ state. linkPopup = type
225+ return . none
226+ case let . 카테고리상세_이동( category) :
227+ if category. categoryName == " 미분류 " {
228+ state. selectedTab = . pokit
229+ state. path. removeAll ( )
230+ return . send( . pokit( . delegate( . 미분류_카테고리_활성화) ) )
231+ }
232+ state. path. append ( . 카테고리상세( . init( category: category) ) )
233+ return . none
213234 default : return . none
214235 }
215236 }
@@ -238,4 +259,19 @@ private extension MainTabFeature {
238259 func handleDelegateAction( _ action: Action . DelegateAction , state: inout State ) -> Effect < Action > {
239260 return . none
240261 }
262+
263+ func linkPopupButtonTapped( state: inout State ) -> Effect < Action > {
264+ switch state. linkPopup {
265+ case . link:
266+ state. linkPopup = nil
267+ return . send( . delegate( . 링크추가하기) )
268+ case . success:
269+ state. linkPopup = nil
270+ guard let category = state. categoryOfSavedContent else { return . none }
271+ state. categoryOfSavedContent = nil
272+ return . send( . inner( . 카테고리상세_이동( category: category) ) )
273+ case . error, . text, . warning, . none:
274+ return . none
275+ }
276+ }
241277}
0 commit comments