Skip to content

Commit fe51712

Browse files
committed
Update code for iOS 17.0
1 parent 4ffdf99 commit fe51712

File tree

7 files changed

+42
-47
lines changed

7 files changed

+42
-47
lines changed

PizzaShop.xcodeproj/project.pbxproj

+12
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
F0741F31272D856B0073F60D /* FoodDetailViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0741F30272D856B0073F60D /* FoodDetailViewControllerTests.swift */; };
6666
F0741F332730517D0073F60D /* CartViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0741F322730517D0073F60D /* CartViewControllerTests.swift */; };
6767
F0741F35273279D90073F60D /* ReservationViewControllerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0741F34273279D90073F60D /* ReservationViewControllerTests.swift */; };
68+
F07692F52ABEF6200077458A /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = F07692F22ABEF6200077458A /* README.md */; };
69+
F07692F62ABEF6200077458A /* Screenshots.png in Resources */ = {isa = PBXBuildFile; fileRef = F07692F32ABEF6200077458A /* Screenshots.png */; };
70+
F07692F72ABEF6200077458A /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = F07692F42ABEF6200077458A /* LICENSE */; };
6871
F0D10EB928A23D0500246564 /* pizzahut-font.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F0D10EB828A238D700246564 /* pizzahut-font.ttf */; };
6972
F0FE14B427661E0400BDE5C2 /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0FE14B327661E0400BDE5C2 /* HomeView.swift */; };
7073
F0FE14B727662A7800BDE5C2 /* UIViewControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0FE14B627662A7800BDE5C2 /* UIViewControllerExtension.swift */; };
@@ -174,6 +177,9 @@
174177
F0741F30272D856B0073F60D /* FoodDetailViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoodDetailViewControllerTests.swift; sourceTree = "<group>"; };
175178
F0741F322730517D0073F60D /* CartViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CartViewControllerTests.swift; sourceTree = "<group>"; };
176179
F0741F34273279D90073F60D /* ReservationViewControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReservationViewControllerTests.swift; sourceTree = "<group>"; };
180+
F07692F22ABEF6200077458A /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
181+
F07692F32ABEF6200077458A /* Screenshots.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Screenshots.png; sourceTree = "<group>"; };
182+
F07692F42ABEF6200077458A /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
177183
F0D10EB828A238D700246564 /* pizzahut-font.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "pizzahut-font.ttf"; sourceTree = "<group>"; };
178184
F0FE14B327661E0400BDE5C2 /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
179185
F0FE14B627662A7800BDE5C2 /* UIViewControllerExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerExtension.swift; sourceTree = "<group>"; };
@@ -314,6 +320,9 @@
314320
F0349D6626D78E4400C6B154 = {
315321
isa = PBXGroup;
316322
children = (
323+
F07692F42ABEF6200077458A /* LICENSE */,
324+
F07692F22ABEF6200077458A /* README.md */,
325+
F07692F32ABEF6200077458A /* Screenshots.png */,
317326
F0349D7126D78E4400C6B154 /* PizzaShop */,
318327
F0349D8826D78E4500C6B154 /* PizzaShopTests */,
319328
F0349D9326D78E4500C6B154 /* PizzaShopUITests */,
@@ -583,7 +592,10 @@
583592
F06742E5276C665100488A5C /* MenuCell.xib in Resources */,
584593
F0125B5E26F4990800C5AA8C /* Auth.storyboard in Resources */,
585594
F01A697D2899B22700B7AC60 /* art.scnassets in Resources */,
595+
F07692F72ABEF6200077458A /* LICENSE in Resources */,
596+
F07692F62ABEF6200077458A /* Screenshots.png in Resources */,
586597
F0349D7F26D78E4500C6B154 /* LaunchScreen.storyboard in Resources */,
598+
F07692F52ABEF6200077458A /* README.md in Resources */,
587599
F0349D7C26D78E4500C6B154 /* Assets.xcassets in Resources */,
588600
F0349D7A26D78E4400C6B154 /* Main.storyboard in Resources */,
589601
);

PizzaShop/Controllers/ProfileViewController.swift

+3-9
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,7 @@ class ProfileViewController: UIViewController {
129129

130130
}
131131

132-
#if DEBUG
133-
import SwiftUI
134-
135-
@available(iOS 13, *)
136-
struct ProfileViewControllerPreview: PreviewProvider {
137-
static var previews: some View {
138-
UIStoryboard(name: "Main", bundle: nil).instantiateViewController(identifier: "ProfileViewController").toPreview()
139-
}
132+
#Preview {
133+
let view = ProfileViewController()
134+
return view
140135
}
141-
#endif

PizzaShop/Utils/Constants.swift

+2-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ struct K {
1111

1212
struct Information {
1313
static let appName = "Pizza Shop"
14+
static let freeIran = "Woman, Life, Freedom"
1415
static let locationLatitude = 34.402341
1516
static let locationLongitude = -119.726045
1617
static let description1 = "Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, tempor incididunt ut magna aliqua. ut labore et dolore magna aliqua."
@@ -74,15 +75,5 @@ struct K {
7475
static let login = "\(baseUrl)/api/v1/users/login"
7576
static let register = "\(baseUrl)/api/v1/users/register"
7677
}
77-
78-
struct Images {
79-
static let storeImage = "store"
80-
static let img1 = "Img1"
81-
static let img2 = "Img2"
82-
static let img3 = "Img3"
83-
static let img4 = "Img4"
84-
static let img5 = "Img5"
85-
static let img6 = "Img6"
86-
}
87-
78+
8879
}

PizzaShop/View Models/HomeViewModel.swift

+5-8
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ import MapKit
1010

1111
final class HomeViewModel: ObservableObject {
1212

13-
var images: [String] = [K.Images.img1, K.Images.img2, K.Images.img3, K.Images.img4, K.Images.img5, K.Images.img6]
14-
let places = [
15-
Place(name: K.Information.appName,
16-
latitude: K.Information.locationLatitude,
17-
longitude: K.Information.locationLongitude)
18-
]
19-
@Published var region = MKCoordinateRegion(
13+
var images: [ImageResource] = [.img1, .img2, .img3, .img4, .img5, .img6]
14+
let coordinate = CLLocationCoordinate2D(latitude: K.Information.locationLatitude,
15+
longitude: K.Information.locationLongitude)
16+
@Published var position = MapCameraPosition.region(MKCoordinateRegion(
2017
center: CLLocationCoordinate2D(latitude: K.Information.locationLatitude,
2118
longitude: K.Information.locationLongitude),
2219
span: MKCoordinateSpan(latitudeDelta: 0.01,
2320
longitudeDelta: 0.075)
24-
)
21+
))
2522

2623
}
2724

PizzaShop/Views/HomeView.swift

+18-17
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ struct HomeView: View {
1717
Color.black.ignoresSafeArea()
1818
ScrollView {
1919
ZStack(alignment: .bottomTrailing) {
20-
Image(K.Images.storeImage)
20+
Image(.store)
2121
.resizable()
2222
.scaledToFill()
2323
.cornerRadius(8)
24-
Text(K.Information.appName)
25-
.font(.custom(K.Fonts.pizzaHut, size: 40))
26-
.padding(5)
27-
.background(Color.black.opacity(0.75))
28-
.cornerRadius(8)
29-
.padding(10)
24+
VStack (spacing: 0) {
25+
Text(K.Information.appName)
26+
.font(.custom(K.Fonts.pizzaHut, size: 40))
27+
Text(K.Information.freeIran)
28+
.font(.custom(K.Fonts.pizzaHut, size: 16))
29+
}
30+
.padding(5)
31+
.background(Color.black.opacity(0.75))
32+
.cornerRadius(8)
33+
.padding(10)
3034
}
3135
.padding(.bottom)
3236

@@ -75,13 +79,12 @@ struct HomeView: View {
7579

7680
@ViewBuilder
7781
func MapView() -> some View {
78-
Map(coordinateRegion: $homeViewModel.region,
79-
showsUserLocation: false,
80-
annotationItems: homeViewModel.places) {
81-
MapMarker(coordinate: $0.coordinate)
82+
Map(position: $homeViewModel.position) {
83+
Marker(K.Information.appName,
84+
coordinate: homeViewModel.coordinate)
8285
}
83-
.frame(height: 100)
84-
.clipShape(RoundedRectangle(cornerRadius: 8))
86+
.frame(height: 100)
87+
.clipShape(RoundedRectangle(cornerRadius: 8))
8588
}
8689

8790
@ViewBuilder
@@ -99,8 +102,6 @@ struct HomeView: View {
99102
}
100103
}
101104

102-
struct HomeView_Previews: PreviewProvider {
103-
static var previews: some View {
104-
HomeView()
105-
}
105+
#Preview {
106+
HomeView()
106107
}

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Food Ordering iOS application. Built with UIKit, SwiftUI, MapKit, ARKit, CoreDat
1818
- [x] Menu screen with categories and detail for each item (UITableView)
1919
- [x] Cart built with Core Data
2020
- [x] Reservation screen
21-
- [x] Profile Page: UI from code (no storyboard) with preview (canvas)
21+
- [x] Profile Page: UI from code (no storyboard)
2222
- [x] ARKit - See the pizza on surfaces in augmented reality (AR)
2323
- [x] Notification and Observer pattern (NotificationCenter) for updating Cart's badge
2424
- [x] Haptic Feedbacks
@@ -34,7 +34,7 @@ Food Ordering iOS application. Built with UIKit, SwiftUI, MapKit, ARKit, CoreDat
3434
- [ ] UI Tests
3535
- [Total lines of code](https://medium.com/@armanabkar/how-to-calculate-total-lines-of-code-in-xcode-projects-6d5a826f7d30): 2585
3636
- No External Dependency
37-
- Requires **iOS 16.1** or later.
37+
- Requires **iOS 17.0** or later.
3838

3939
### Contributing
4040

0 commit comments

Comments
 (0)