Skip to content

Instantly share code, notes, and snippets.

@miotke
Last active June 23, 2020 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miotke/ed477959a89a002e30a1f8ee7e83fffd to your computer and use it in GitHub Desktop.
Save miotke/ed477959a89a002e30a1f8ee7e83fffd to your computer and use it in GitHub Desktop.
// This code does not create a functional list view
// but does split the views into two different functional views.
// The button acts strictly as a button therefore the highlight
// disappears immediatly after the tap gesture is dismissed.
// I'm sure there will be a better way to do this and hopefully
// we learn of one at WWDC2020. For now this kind gets you by.
import SwiftUI
struct ContentView: View {
@State var listNumber = 0
var body: some View {
NavigationView {
VStack {
List {
ForEach(1..<100) { noteIndex in
Button(action: {
self.listNumber = noteIndex
}) {
Text("Note \(noteIndex)")
}
}
}
}
.navigationTitle(Text("Split view?"))
ZStack {
VStack {
Text("Body of what could be a note")
.fontWeight(.heavy)
.font(.system(size: 30))
.foregroundColor(.blue)
Text("Just some text, blah blah blah")
.font(.subheadline)
.foregroundColor(.gray)
Text("Selected cell \(listNumber)")
}
}
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment