1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
//
// BOMView.swift
// ShedCalc
//
// Created by Jacky Jack on 28/07/2026.
//
import SwiftUI
import Combine
struct Materials: Identifiable {
let materialName: String
let pricePerMeter: Double
let totalMeters: Double
let totalPrice: Double
let metersPerPiece: Double
let totalPieces: Double
let id = UUID()
}
struct BOMView: View {
@Environment(ParamModel.self) private var paramModel
@State private var materials = [
Materials(materialName: "2x4", pricePerMeter: 1.2, totalMeters: 10, totalPrice: 12, metersPerPiece: 4.8, totalPieces: 23),
Materials(materialName: "OSB", pricePerMeter: 1.2, totalMeters: 10, totalPrice: 12, metersPerPiece: 4.8, totalPieces: 23),
Materials(materialName: "Roof Felt", pricePerMeter: 1.2, totalMeters: 10, totalPrice: 12, metersPerPiece: 4.8, totalPieces: 23),
Materials(materialName: "Nails", pricePerMeter: 1.2, totalMeters: 10, totalPrice: 12, metersPerPiece: 4.8, totalPieces: 23),
Materials(materialName: "Cladding", pricePerMeter: 1.2, totalMeters: 10, totalPrice: 12, metersPerPiece: 4.8, totalPieces: 23)
]
var body: some View {
VStack {
Text("BOM")
}
VStack {
Table(materials) {
TableColumn("Material", value: \.materialName)
TableColumn("Price per m") { material in
Text(material.pricePerMeter, format: .number.precision(.fractionLength(2)))
}
TableColumn("Total m") { material in
Text(material.totalMeters, format: .number.precision(.fractionLength(2)))
}
TableColumn("Total price") { material in
Text(material.totalPrice, format: .number.precision(.fractionLength(2)))
}
TableColumn("m per Piece") { material in
Text(material.metersPerPiece, format: .number.precision(.fractionLength(2)))
}
TableColumn("Pieces") { material in
Text(material.totalPieces, format: .number)
}
}
}
HStack {
Text("Total price: 0.00")
}
}
}
|