@@ -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 ( )
@@ -105,8 +127,8 @@ struct PostListView: View {
105127 . ignoresSafeArea ( )
106128 #else
107129 PostListFilteredView (
108- collection: model . selectedCollection,
109- showAllPosts: model . showAllPosts,
130+ collection: selectedCollection,
131+ showAllPosts: showAllPosts,
110132 postCount: $postCount
111133 )
112134 . toolbar {
@@ -129,7 +151,7 @@ struct PostListView: View {
129151 }
130152 }
131153 . navigationTitle (
132- model . showAllPosts ? " All Posts " : model . selectedCollection? . title ?? (
154+ showAllPosts ? " All Posts " : selectedCollection? . title ?? (
133155 model. account. server == " https://write.as " ? " Anonymous " : " Drafts "
134156 )
135157 )
@@ -142,7 +164,7 @@ struct PostListView_Previews: PreviewProvider {
142164 let context = LocalStorageManager . persistentContainer. viewContext
143165 let model = WriteFreelyModel ( )
144166
145- return PostListView ( )
167+ return PostListView ( showAllPosts : true )
146168 . environment ( \. managedObjectContext, context)
147169 . environmentObject ( model)
148170 }
0 commit comments