Skip to content

Instantly share code, notes, and snippets.

@MarcusAdriano
Created February 25, 2021 00:48
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 MarcusAdriano/9affed479cd7b47cbedb5d9d940628aa to your computer and use it in GitHub Desktop.
Save MarcusAdriano/9affed479cd7b47cbedb5d9d940628aa to your computer and use it in GitHub Desktop.
CartView demo for BottomSheet troubleshooting
//
// 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