Skip to content

Commit

Permalink
II-15-[added NavigationSplitView usage]
Browse files Browse the repository at this point in the history
  • Loading branch information
spopovshakuro committed Feb 24, 2024
1 parent 7496f10 commit c35d00d
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions PullToRefreshSample/PullToRefreshSampleiOS/UI/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,39 @@ import SwiftUI

struct ContentView: View {

@State private var preferredColumn = NavigationSplitViewColumn.detail
private enum Option {
case list
case scroll
}

@State private var preferredColumn = NavigationSplitViewColumn.sidebar
@State private var options: [Option] = [.list, .scroll]
@State private var selectedOption: Option?

//https://developer.apple.com/documentation/swiftui/navigationsplitview
// navigationsplitview + navigationstack
var body: some View {
NavigationSplitView(preferredCompactColumn: $preferredColumn) {
Color.yellow
List(selection: $selectedOption) {
ForEach(Array(options), id: \.self) { (option) in
NavigationLink(value: option) {
switch option {
case .list:
Text("List View")
case .scroll:
Text("Scroll View")
}
}
}
}
.navigationTitle("Options")
} detail: {
ScrollContentView()
switch selectedOption {
case .list:
ListContentView()
case .scroll:
ScrollContentView()
case .none:
Text("Choose an item from the content")
}
}
}

Expand Down

0 comments on commit c35d00d

Please sign in to comment.