Another example struct preview with both light and black previews. The HStack in this view is all white not allowing the which i to be a header Name and Category. It is not in the list to prevent it from scrolling with long lists to he a header always visible. It works in the full on a device but can not be seen in ContentView but at the start no document is yet loaded so I use the Struct previews to see them with actually data examples. but dark view does not display correctly for the separate struct previews.
//
// DocumemtViewer.swift
// DocumentPicker
//
// Created by Jack Reigh on 3/23/21.
//
// Last Updated 5/5/21
import SwiftUI
struct DocumentViewer: View {
var inventory: [inventoryEntry]
@State private var showSheet1 = false
@State private var showSheet2 = false
@State var itemId: UUID? = nil
var body: some View {
VStack {
HStack{
Text("Name").padding(2)
.frame(width: 250, height: 40,alignment: .top)
Spacer()
.frame(width: 4, height: 40, alignment: .top).background(Color.orange)
.padding(.horizontal, 0 )
Text("Category").padding(2)
.frame(width: 200, height: 40,alignment: .top)
}
.padding(.horizontal, 0) //7 yes
.frame(width: 468, height: 40,alignment: .leading)
.overlay(RoundedRectangle(cornerRadius: 8.0).stroke(Color.orange, lineWidth: 5)).padding(5)
List {
ForEach(inventory, id: .self.id){ item in // 6
InventoryLineView(inventory: inventory, itemIn: item).frame(alignment: .center)
.frame(width: 483, height: 88, alignment: .center)//.background(Color.orange)
} // ForEach
.environment(.defaultMinListRowHeight, 0 ) // spacing between rows in list
.environment(.defaultMinListHeaderHeight, 0 ) // spacing between rows in list
.navigationTitle("Inventory File View")
}.environment(.defaultMinListRowHeight, 88) // List End
.frame(width: 510, height: length - 180, alignment: .bottom)//5
}.frame(height: length - 118,alignment: .bottom)
// Outer Border of Inventory VStack
.overlay(RoundedRectangle(cornerRadius: 8.0).stroke(Color.blue, lineWidth: 5)).padding(5)
}
}
struct DocumentViewer_Previews: PreviewProvider {
static var data = InventoryModel()
static var previews: some View {
let sample = data.setSampleInventory()
DocumentViewer(inventory: sample)
DocumentViewer(inventory: sample).environment(.colorScheme , .dark)
}
}