@@ -7,6 +7,9 @@ struct PostListView: View {
77
88 @State private var postCount : Int = 0
99
10+ var selectedCollection : WFACollection ?
11+ var showAllPosts : Bool
12+
1013 #if os(iOS)
1114 private var frameHeight : CGFloat {
1215 var height : CGFloat = 50
@@ -20,12 +23,12 @@ struct PostListView: View {
2023 #if os(iOS)
2124 ZStack ( alignment: . bottom) {
2225 PostListFilteredView (
23- collection: model . selectedCollection,
24- showAllPosts: model . showAllPosts,
26+ collection: selectedCollection,
27+ showAllPosts: showAllPosts,
2528 postCount: $postCount
2629 )
2730 . navigationTitle (
28- model . showAllPosts ? " All Posts " : model . selectedCollection? . title ?? (
31+ showAllPosts ? " All Posts " : selectedCollection? . title ?? (
2932 model. account. server == " https://write.as " ? " Anonymous " : " Drafts "
3033 )
3134 )
@@ -70,9 +73,28 @@ struct PostListView: View {
7073 } )
7174 . accessibilityLabel ( Text ( " Settings " ) )
7275 . accessibilityHint ( Text ( " Open the Settings sheet " ) )
76+ . sheet (
77+ isPresented: $model. isPresentingSettingsView,
78+ onDismiss: { model. isPresentingSettingsView = false } ,
79+ content: {
80+ SettingsView ( )
81+ . environmentObject ( model)
82+ }
83+ )
7384 Spacer ( )
7485 Text ( postCount == 1 ? " \( postCount) post " : " \( postCount) posts " )
7586 . foregroundColor ( . secondary)
87+ . alert ( isPresented: $model. isPresentingNetworkErrorAlert, content: {
88+ Alert (
89+ title: Text ( " Connection Error " ) ,
90+ message: Text ( """
91+ There is no internet connection at the moment. Please reconnect or try again later.
92+ """ ) ,
93+ dismissButton: . default( Text ( " OK " ) , action: {
94+ model. isPresentingNetworkErrorAlert = false
95+ } )
96+ )
97+ } )
7698 Spacer ( )
7799 if model. isProcessingRequest {
78100 ProgressView ( )
@@ -103,10 +125,14 @@ struct PostListView: View {
103125 . overlay ( Divider ( ) , alignment: . top)
104126 }
105127 . ignoresSafeArea ( )
128+ . onAppear {
129+ model. selectedCollection = selectedCollection
130+ model. showAllPosts = showAllPosts
131+ }
106132 #else
107133 PostListFilteredView (
108- collection: model . selectedCollection,
109- showAllPosts: model . showAllPosts,
134+ collection: selectedCollection,
135+ showAllPosts: showAllPosts,
110136 postCount: $postCount
111137 )
112138 . toolbar {
@@ -129,7 +155,7 @@ struct PostListView: View {
129155 }
130156 }
131157 . navigationTitle (
132- model . showAllPosts ? " All Posts " : model . selectedCollection? . title ?? (
158+ showAllPosts ? " All Posts " : selectedCollection? . title ?? (
133159 model. account. server == " https://write.as " ? " Anonymous " : " Drafts "
134160 )
135161 )
@@ -142,7 +168,7 @@ struct PostListView_Previews: PreviewProvider {
142168 let context = LocalStorageManager . persistentContainer. viewContext
143169 let model = WriteFreelyModel ( )
144170
145- return PostListView ( )
171+ return PostListView ( showAllPosts : true )
146172 . environment ( \. managedObjectContext, context)
147173 . environmentObject ( model)
148174 }
0 commit comments