From 2f0158de8d346671de3859b0f2818ea6ef8e0266 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Wed, 9 Mar 2022 20:53:57 -0800 Subject: [PATCH] split ios and mac implementations of primary layout --- .../App/Views/LinkItemDetailView.swift | 1 + .../App/Views/PrimaryContentView.swift | 53 ++++++++++++------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift index 36b19523f..0d0234d29 100644 --- a/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/LinkItemDetailView.swift @@ -186,6 +186,7 @@ struct LinkItemDetailView: View { } } + @available(macOS 12.0, *) @available(iOS 15.0, *) var navBar: some View { HStack(alignment: .center) { diff --git a/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift b/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift index f8ca2f10d..1320cfc07 100644 --- a/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/PrimaryContentView.swift @@ -4,40 +4,53 @@ import SwiftUI import Views public struct PrimaryContentView: View { + let categories = [ + PrimaryContentCategory.feed, + PrimaryContentCategory.profile + ] + public var body: some View { #if os(iOS) if UIDevice.isIPad { - regularView + splitView } else { HomeView() } #elseif os(macOS) - regularView + splitView #endif } - // ipad and mac view container - private var regularView: some View { - let categories = [ - PrimaryContentCategory.feed, - PrimaryContentCategory.profile - ] + #if os(macOS) + private var splitView: some View { + NavigationView { + // The first column is the sidebar. + PrimaryContentSidebar(categories: categories) + .navigationTitle("Categories") - return NavigationView { - // The first column is the sidebar. - PrimaryContentSidebar(categories: categories) - .navigationTitle("Categories") + // Second column is the Primary Nav Stack + PrimaryContentCategory.feed.destinationView - // Second column is the Primary Nav Stack - PrimaryContentCategory.feed.destinationView - - // Add a third column for macOS only - #if os(macOS) + // Third column is the detail view Text("Select a link from the feed") - #endif + } + .accentColor(.appGrayTextContrast) } - .accentColor(.appGrayTextContrast) - } + #endif + + #if os(iOS) + private var splitView: some View { + NavigationView { + // The first column is the sidebar. + PrimaryContentSidebar(categories: categories) + .navigationTitle("Categories") + + // Second column is the Primary Nav Stack + PrimaryContentCategory.feed.destinationView + } + .accentColor(.appGrayTextContrast) + } + #endif } struct PrimaryContentSidebar: View {