Created
August 20, 2022 14:24
-
-
Save pitt500/9997d37ee4b9d1c59b04c865f86600af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ContentView.swift | |
// DemoSheet | |
// | |
// Created by Pedro Rojas on 20/08/22. | |
// | |
import SwiftUI | |
struct ContentView: View { | |
@State var isSheetPresented = false | |
var body: some View { | |
NavigationView { | |
List { | |
Text("Item 1") | |
Text("Item 2") | |
Text("Item 3") | |
} | |
.sheet(isPresented: $isSheetPresented) { | |
CartView() | |
} | |
.toolbar { | |
ToolbarItem(placement: .navigationBarTrailing) { | |
Button { | |
isSheetPresented = true | |
} label: { | |
Text("Go to cart") | |
} | |
} | |
} | |
.navigationTitle("Products") | |
} | |
} | |
} | |
struct ContentView_Previews: PreviewProvider { | |
static var previews: some View { | |
ContentView() | |
} | |
} | |
struct CartView: View { | |
var body: some View { | |
NavigationView { | |
List { | |
Text("Item 1, 1") | |
Text("Item 2, 2") | |
Text("Item 3, 1") | |
} | |
.navigationTitle("Cart") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment