split ios and mac implementations of primary layout

This commit is contained in:
Satindar Dhillon 2022-03-09 20:53:57 -08:00
parent c1e9bbe690
commit 2f0158de8d
2 changed files with 34 additions and 20 deletions

View file

@ -186,6 +186,7 @@ struct LinkItemDetailView: View {
}
}
@available(macOS 12.0, *)
@available(iOS 15.0, *)
var navBar: some View {
HStack(alignment: .center) {

View file

@ -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 {