Display Settings sheet on iOS 15 and above

This commit is contained in:
Angelo Stavrow 2021-08-27 16:45:02 -04:00
parent badf80ef5c
commit 28856eb434
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE

View File

@ -35,7 +35,22 @@ struct ContentView: View {
.help("Create a new local draft.") .help("Create a new local draft.")
} }
#else #else
CollectionListView() if #available(iOS 15.0, *) {
CollectionListView()
.alert(isPresented: $model.isPresentingNetworkErrorAlert, content: {
Alert(
title: Text("Connection Error"),
message: Text("""
There is no internet connection at the moment. Please reconnect or try again later.
"""),
dismissButton: .default(Text("OK"), action: {
model.isPresentingNetworkErrorAlert = false
})
)
})
} else {
CollectionListView()
}
#endif #endif
#if os(macOS) #if os(macOS)
@ -49,15 +64,29 @@ struct ContentView: View {
} }
} }
#else #else
PostListView() if #available(iOS 15.0, *) {
PostListView()
.sheet(
isPresented: $model.isPresentingSettingsView,
onDismiss: { model.isPresentingSettingsView = false },
content: {
SettingsView()
.environmentObject(model)
}
)
} else {
PostListView()
}
#endif #endif
Text("Select a post, or create a new local draft.") Text("Select a post, or create a new local draft.")
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
.environmentObject(model) .environmentObject(model)
// For iOS 14
#if os(iOS) if #available(iOS 15.0, *) {
// Do nothing.
} else {
EmptyView() EmptyView()
.sheet( .sheet(
isPresented: $model.isPresentingSettingsView, isPresented: $model.isPresentingSettingsView,
@ -78,7 +107,7 @@ struct ContentView: View {
}) })
) )
}) })
#endif }
} }
} }