@@ -13,18 +13,20 @@ import CommonUI
1313import ComposableArchitecture
1414
1515struct FavoriteView : View {
16+ @Environment ( \. dismiss) var pop
1617 let store : StoreOf < FavoriteReducer >
1718
1819 var body : some View {
1920 WithViewStore ( store, observe: { $0 } ) { viewStore in
20- NavigationView {
21+ ZStack {
2122 ScrollView ( . vertical, showsIndicators: false ) {
2223 SearchField { query in
2324 viewStore. send ( . fetch( request: query) )
2425 }
2526 . padding ( . horizontal, 16 )
2627 . padding ( . vertical, 20 )
27-
28+ . padding ( . top, 62 )
29+
2830 if viewStore. state. list. isEmpty {
2931 FavoriteEmptyView ( )
3032 . padding ( . top, 50 )
@@ -54,42 +56,60 @@ struct FavoriteView: View {
5456 . animation ( . easeInOut( duration: 0.2 ) , value: viewStore. list. count)
5557 . navigationBarBackButtonHidden ( false )
5658 . navigationBarTitleDisplayMode ( . inline)
57- . toolbar {
58- ToolbarItem ( placement: . topBarLeading) {
59- IconButton (
60- iconName: " chevron.left " ,
61- tint: . blue,
62- onClick: {
63- viewStore. send ( . didBackPressed)
64- }
65- )
66- }
67-
68- ToolbarItem ( placement: . principal) {
69- Text ( key: . titleFavorite)
70- . font ( . bold, size: 16 )
59+ . showDialog (
60+ shouldDismissOnTapOutside: true ,
61+ isShowing: viewStore. binding (
62+ get: { $0. shareImage != nil } ,
63+ send: . showShare( nil )
64+ )
65+ ) {
66+ ShareView ( store: viewStore. share)
67+ }
68+ . onAppear {
69+ viewStore. send ( . fetch( ) )
70+ }
71+ . onReceive ( viewStore. state. detailDisappear) { _ in
72+ viewStore. send ( . fetch( ) )
73+ }
74+
75+ VStack {
76+ FavoriteToolbar ( title: Localizable . titleFavorite. tr ( ) ) {
77+ pop ( )
7178 }
79+ Spacer ( )
7280 }
7381 }
74- . showDialog (
75- shouldDismissOnTapOutside: true ,
76- isShowing: viewStore. binding (
77- get: { $0. shareImage != nil } ,
78- send: . showShare( nil )
79- )
80- ) {
81- ShareView ( store: viewStore. share)
82- }
83- . onAppear {
84- viewStore. send ( . fetch( ) )
85- }
86- . onReceive ( viewStore. state. detailDisappear) { _ in
87- viewStore. send ( . fetch( ) )
88- }
8982 }
9083 }
9184}
9285
86+ struct FavoriteToolbar : View {
87+ var title : String
88+ var onBackPressed : ( ) -> Void
89+
90+ var body : some View {
91+ HStack {
92+ IconButton (
93+ iconName: " chevron.left " ,
94+ tint: . Theme. red,
95+ size: 26 ,
96+ onClick: onBackPressed
97+ )
98+
99+ Spacer ( )
100+
101+ Text ( title)
102+ . font ( . system( size: 16 , weight: . bold) )
103+
104+ Spacer ( )
105+
106+ Spacer ( ) . frame ( width: 32 )
107+ }
108+ . padding ( 8 )
109+ . background ( Blur ( style: . prominent) . edgesIgnoringSafeArea ( . top) )
110+ }
111+ }
112+
93113#Preview {
94114 FavoriteView ( store: Injection . resolve ( ) )
95115}
0 commit comments