-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathContentView.swift
76 lines (68 loc) · 1.85 KB
/
ContentView.swift
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
64
65
66
67
68
69
70
71
72
73
74
75
76
//
// ContentView.swift
// NeppatsrevCoffee
//
// Created by Ryan Mackintosh on 2/5/2024.
//
import SwiftUI
// ContentView struct defines the main view for the NeppastrevCoffee app.
struct ContentView: View {
// Access shared cartManager instance defined elsewhere in the app.
@EnvironmentObject var cartManager: CartManager
var body: some View {
// TabView to hold various main views of the app as tab items.
TabView {
// Menu view tab
MenuView()
.tabItem {
Label("Menu", systemImage: "list.bullet") // System icon and text label for the tab.
}
// VIP section view tab
VIPView()
.tabItem {
Label("VIP", systemImage: "star") // System icon and text label for the tab.
}
// Map view for store locations tab
MapView()
.tabItem {
Label("Stores", systemImage: "map.fill") // System icon and text label for the tab.
}
// Cart view wrapped in a NavigationView to allow navigation to detailed views.
NavigationView {
CartView()
}
.tabItem {
Label {
Text("Cart")
} icon: {
// Icon for the cart, showing number of items dynamically
if cartManager.items.count > 0 {
Image(systemName: "cart")
Text("\(cartManager.items.count)")
.font(.caption2)
.foregroundColor(.white)
.padding(5)
.background(Color.red)
.clipShape(Circle())
.offset(x: 10, y: -10)
} else {
Image(systemName: "cart")
}
}
}
// Settings view tab
SettingsView()
.tabItem {
Label("Settings", systemImage: "gear") // System icon and text label for the tab.
}
}
}
}
// SwiftUI preview for ContentView
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.environmentObject(ProductManager())
.environmentObject(CartManager()) // Providing the environment object for preview
}
}