pietropizzi/GridStack

cellWidth is negative

Opened this issue · 1 comments

Screen Shot 2564-03-12 at 17 58 13

struct ContentView: View {
    
    // Setup
    init() {
        UITableView.appearance().backgroundColor = .clear
        // UITableViewCell.appearance().backgroundColor = .clear
    }
    
    var body: some View {
        NavigationView{
            Sidebar()
                .navigationTitle("Recon")
            GridStack(minCellWidth: 300, spacing: 2, numItems: 15) { (index, cellWidth) in
                Text("\(index)")
                    .frame(width: cellWidth, height: 100)
                    .background(Color.blue)
            } 
        }
    }
}

Hi!

Seems like a guard is missing for when the calculated size is lower than 0

There is also a flaw in your code under the NavigationView, you cannot just add your Sidebar and your GridStack under the NavigationView, you have to put them under either a Vstack or a HStack depending of what's your intention