From 0b75498eedb04dd3255954f41347bde1fdb56660 Mon Sep 17 00:00:00 2001 From: Ethan Lipnik Date: Wed, 29 Sep 2021 16:52:07 -0400 Subject: [PATCH] Fixed macOS compile issues --- Shared/Documents/ImportDocumentView.swift | 4 ++++ Shared/Views/ContentView/ContentView+List.swift | 6 +++++- Shared/Views/ContentView/ContentView.swift | 2 ++ Shared/Views/NoteView.swift | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Shared/Documents/ImportDocumentView.swift b/Shared/Documents/ImportDocumentView.swift index 370c41d..66df101 100644 --- a/Shared/Documents/ImportDocumentView.swift +++ b/Shared/Documents/ImportDocumentView.swift @@ -55,6 +55,7 @@ struct ImportDocumentView: View { } } } +#if os(iOS) .listStyle(.insetGrouped) .navigationTitle(file.url.lastPathComponent) .navigationBarTitleDisplayMode(.inline) @@ -76,6 +77,9 @@ struct ImportDocumentView: View { dismiss.callAsFunction() } } +#else + .listStyle(.inset(alternatesRowBackgrounds: true)) +#endif } private func add(encryptionKey: SymmetricKey) throws { diff --git a/Shared/Views/ContentView/ContentView+List.swift b/Shared/Views/ContentView/ContentView+List.swift index 0dbc50b..b3ce601 100644 --- a/Shared/Views/ContentView/ContentView+List.swift +++ b/Shared/Views/ContentView/ContentView+List.swift @@ -94,7 +94,11 @@ extension ContentView { Button { guard let writeReviewURL = URL(string: "https://apps.apple.com/app/id1581907821?action=write-review") else { fatalError("Expected a valid URL") } - UIApplication.shared.open(writeReviewURL, options: [:], completionHandler: nil) +#if os(iOS) + UIApplication.shared.open(writeReviewURL, options: [:], completionHandler: nil) +#else + NSWorkspace.shared.open(writeReviewURL) +#endif UserDefaults.standard.set(true, forKey: "didRequestReview") } label: { diff --git a/Shared/Views/ContentView/ContentView.swift b/Shared/Views/ContentView/ContentView.swift index a49002a..393ed7b 100644 --- a/Shared/Views/ContentView/ContentView.swift +++ b/Shared/Views/ContentView/ContentView.swift @@ -142,9 +142,11 @@ struct ContentView_Previews: PreviewProvider { } } +#if os(iOS) extension UISplitViewController { open override func viewDidLoad() { super.viewDidLoad() self.show(.primary) } } +#endif diff --git a/Shared/Views/NoteView.swift b/Shared/Views/NoteView.swift index b2bd8a2..9be41b9 100644 --- a/Shared/Views/NoteView.swift +++ b/Shared/Views/NoteView.swift @@ -100,7 +100,6 @@ struct NoteView: View { Spacer() .frame(maxWidth: .infinity) } - .navigationBarTitleDisplayMode(.inline) .onAppear { displayedBody = CryptoSecurityService.randomString(length: Int(note.bodyLength))! newColor = Int(note.color) @@ -110,6 +109,7 @@ struct NoteView: View { print(color) } #if os(iOS) + .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button {