-
-
Save MarcusAdriano/9affed479cd7b47cbedb5d9d940628aa to your computer and use it in GitHub Desktop.
CartView demo for BottomSheet troubleshooting
This file contains 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
// | |
// CartView.swift | |
// PersonalCart | |
// | |
// Created by Marcus Adriano on 14/01/21. | |
// | |
import SwiftUI | |
import BottomSheet | |
struct CartView: View { | |
@State private var toBuy = true | |
@State private var bottomSheetIsOpen = false | |
@ObservedObject var cart: CartViewModel | |
var body: some View { | |
NavigationView { | |
List { | |
Toggle(isOn: $toBuy) { | |
Text("To buy only") | |
} | |
ForEach(cart.items(toBuy), id: \.id) { item in | |
NavigationLink(destination: CartItemDetailView(item: item)) { | |
CartItemView(cartItem: item) | |
} | |
} | |
} | |
.navigationTitle(cart.isLoading ? "My Cart" : cart.name) | |
.onAppear() { | |
cart.subscribe(for: "eV2DY1Hqo30xlsZWiBKu") | |
} | |
.toolbar { | |
ToolbarItemGroup(placement: .bottomBar) { | |
Spacer() | |
Button(action: { self.bottomSheetIsOpen.toggle() }) { | |
Image(systemName: "cart.badge.plus") | |
} | |
} | |
} | |
.bottomSheet(isPresented: $bottomSheetIsOpen, height: 500) { | |
Text("Hello") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment