From 28856eb434c550c2ad656c8dee70f7a7253ecbf6 Mon Sep 17 00:00:00 2001 From: Angelo Stavrow Date: Fri, 27 Aug 2021 16:45:02 -0400 Subject: [PATCH] Display Settings sheet on iOS 15 and above --- Shared/Navigation/ContentView.swift | 39 +++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/Shared/Navigation/ContentView.swift b/Shared/Navigation/ContentView.swift index a60322f..82fc222 100644 --- a/Shared/Navigation/ContentView.swift +++ b/Shared/Navigation/ContentView.swift @@ -35,7 +35,22 @@ struct ContentView: View { .help("Create a new local draft.") } #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 #if os(macOS) @@ -49,15 +64,29 @@ struct ContentView: View { } } #else - PostListView() + if #available(iOS 15.0, *) { + PostListView() + .sheet( + isPresented: $model.isPresentingSettingsView, + onDismiss: { model.isPresentingSettingsView = false }, + content: { + SettingsView() + .environmentObject(model) + } + ) + } else { + PostListView() + } #endif Text("Select a post, or create a new local draft.") .foregroundColor(.secondary) } .environmentObject(model) - - #if os(iOS) + // For iOS 14 + if #available(iOS 15.0, *) { + // Do nothing. + } else { EmptyView() .sheet( isPresented: $model.isPresentingSettingsView, @@ -78,7 +107,7 @@ struct ContentView: View { }) ) }) - #endif + } } }