-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItemDetail.swift
46 lines (43 loc) · 1.13 KB
/
ItemDetail.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
//
// ItemDetail.swift
// iDine
//
// Created by WHGNR-1671 on 25/05/22.
//
import SwiftUI
struct ItemDetail: View {
@EnvironmentObject var order: Order
let item: MenuItem
var body: some View {
VStack {
ZStack(alignment: .bottomTrailing) {
Image(item.mainImage)
.resizable()
.scaledToFit()
Text("Photo credit: \(item.photoCredit)")
.padding(4)
.background(.black)
.font(.caption)
.foregroundColor(.white)
.offset(x: -5, y: -5)
}
Text(item.description)
.padding()
Button("Order This") {
order.add(item: item)
}
.font(.headline)
Spacer()
}
.navigationTitle(item.name)
.navigationBarTitleDisplayMode(.inline)
}
}
struct ItemDetail_Previews: PreviewProvider {
static var previews: some View {
NavigationView {
ItemDetail(item: MenuItem.example)
.environmentObject(Order())
}
}
}