Browse Source

Added Home Screen after login (search screen for now)

Hector Carrion 3 years ago
parent
commit
b3bca5dded
65 changed files with 1041 additions and 501 deletions
  1. 60
    4
      Comedores Sociales.xcodeproj/project.pbxproj
  2. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/100.png
  3. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/1024.png
  4. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/114.png
  5. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/120.png
  6. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/144.png
  7. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/152.png
  8. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/167.png
  9. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/180.png
  10. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/20.png
  11. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/29.png
  12. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/40.png
  13. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/50.png
  14. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/57.png
  15. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/58.png
  16. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/60.png
  17. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/72.png
  18. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/76.png
  19. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/80.png
  20. BIN
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/87.png
  21. 1
    98
      Comedores Sociales/Assets.xcassets/AppIcon.appiconset/Contents.json
  22. 21
    0
      Comedores Sociales/Assets.xcassets/Beans.imageset/Contents.json
  23. BIN
      Comedores Sociales/Assets.xcassets/Beans.imageset/PngItem_1822351.png
  24. 21
    0
      Comedores Sociales/Assets.xcassets/Carrots.imageset/Contents.json
  25. BIN
      Comedores Sociales/Assets.xcassets/Carrots.imageset/fresh-shredded-carrots-bowl-white_147493-79.png
  26. 21
    0
      Comedores Sociales/Assets.xcassets/Crackers.imageset/Contents.json
  27. BIN
      Comedores Sociales/Assets.xcassets/Crackers.imageset/Screen Shot 2020-11-30 at 12.19.45 PM.png
  28. 21
    0
      Comedores Sociales/Assets.xcassets/Eggs.imageset/Contents.json
  29. BIN
      Comedores Sociales/Assets.xcassets/Eggs.imageset/IMGBIN_boiled-egg-breakfast-scrambled-eggs-cooking-png_C9SB6xW2.png
  30. 21
    0
      Comedores Sociales/Assets.xcassets/Green Peppers.imageset/Contents.json
  31. BIN
      Comedores Sociales/Assets.xcassets/Green Peppers.imageset/kisspng-bell-pepper-vegetarian-cuisine-vegetable-bowl-a-bowl-of-sliced-__vegetables-with-green-peppe-5aa22eb1bc02e7.5961195015205782257701.png
  32. 21
    0
      Comedores Sociales/Assets.xcassets/Malanga.imageset/Contents.json
  33. BIN
      Comedores Sociales/Assets.xcassets/Malanga.imageset/taro.png
  34. 21
    0
      Comedores Sociales/Assets.xcassets/Oatmeal.imageset/Contents.json
  35. BIN
      Comedores Sociales/Assets.xcassets/Oatmeal.imageset/klipartz.com.png
  36. 21
    0
      Comedores Sociales/Assets.xcassets/Pasta.imageset/Contents.json
  37. BIN
      Comedores Sociales/Assets.xcassets/Pasta.imageset/pasta_PNG66.png
  38. 21
    0
      Comedores Sociales/Assets.xcassets/Pineapple.imageset/Contents.json
  39. BIN
      Comedores Sociales/Assets.xcassets/Pineapple.imageset/PngItem_1736567.png
  40. 21
    0
      Comedores Sociales/Assets.xcassets/Potatoes.imageset/Contents.json
  41. BIN
      Comedores Sociales/Assets.xcassets/Potatoes.imageset/pngfind.com-potato-png-1824199.png
  42. 21
    0
      Comedores Sociales/Assets.xcassets/Rice.imageset/Contents.json
  43. BIN
      Comedores Sociales/Assets.xcassets/Rice.imageset/—Pngtree—a bowl of white rice_4583461.png
  44. BIN
      Comedores Sociales/Assets.xcassets/Sausages.imageset/5a0abef65a997e1c2cea1080.png
  45. 21
    0
      Comedores Sociales/Assets.xcassets/Sausages.imageset/Contents.json
  46. 21
    0
      Comedores Sociales/Assets.xcassets/Vegetable Oil.imageset/Contents.json
  47. BIN
      Comedores Sociales/Assets.xcassets/Vegetable Oil.imageset/pngkey.com-vegetable-oil-png-4175496.png
  48. 21
    0
      Comedores Sociales/Assets.xcassets/Yellow Onions.imageset/Contents.json
  49. BIN
      Comedores Sociales/Assets.xcassets/Yellow Onions.imageset/pngwing.com.png
  50. 21
    0
      Comedores Sociales/Assets.xcassets/Yuca.imageset/Contents.json
  51. BIN
      Comedores Sociales/Assets.xcassets/Yuca.imageset/cassava-png-4-png-image-cassava-png-277_184.png
  52. 6
    3
      Comedores Sociales/Comedores_SocialesApp.swift
  53. 8
    68
      Comedores Sociales/ContentView.swift
  54. 49
    0
      Comedores Sociales/Model/FoodItem.swift
  55. 180
    0
      Comedores Sociales/Model/NetworkingModel.swift
  56. 0
    0
      Comedores Sociales/Model/Persistence.swift
  57. 15
    0
      Comedores Sociales/Model/UserSettings.swift
  58. 0
    79
      Comedores Sociales/NetworkingModel.swift
  59. 0
    188
      Comedores Sociales/RegisterView.swift
  60. 103
    0
      Comedores Sociales/View/CustomNavigationView.swift
  61. 62
    0
      Comedores Sociales/View/FoodCardView.swift
  62. 5
    61
      Comedores Sociales/View/Login/LoginView.swift
  63. 164
    0
      Comedores Sociales/View/Login/RegisterView.swift
  64. 33
    0
      Comedores Sociales/View/Search/Search.swift
  65. 40
    0
      Comedores Sociales/View/Search/SearchContainer.swift

+ 60
- 4
Comedores Sociales.xcodeproj/project.pbxproj View File

@@ -7,6 +7,12 @@
7 7
 	objects = {
8 8
 
9 9
 /* Begin PBXBuildFile section */
10
+		350E75AA25756829006B17CC /* Search.swift in Sources */ = {isa = PBXBuildFile; fileRef = 350E75A925756829006B17CC /* Search.swift */; };
11
+		350E75AF2575687C006B17CC /* FoodItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 350E75AE2575687C006B17CC /* FoodItem.swift */; };
12
+		350E75B425757572006B17CC /* FoodCardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 350E75B325757572006B17CC /* FoodCardView.swift */; };
13
+		350E75BC257576BD006B17CC /* CustomNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 350E75BB257576BD006B17CC /* CustomNavigationView.swift */; };
14
+		350E75C125757B24006B17CC /* SearchContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 350E75C025757B24006B17CC /* SearchContainer.swift */; };
15
+		350E75CD25758D92006B17CC /* UserSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 350E75CC25758D92006B17CC /* UserSettings.swift */; };
10 16
 		3565338325449C3600F2F0DE /* Comedores_SocialesApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3565338225449C3600F2F0DE /* Comedores_SocialesApp.swift */; };
11 17
 		3565338525449C3600F2F0DE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3565338425449C3600F2F0DE /* ContentView.swift */; };
12 18
 		3565338725449C3800F2F0DE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3565338625449C3800F2F0DE /* Assets.xcassets */; };
@@ -38,6 +44,12 @@
38 44
 /* End PBXContainerItemProxy section */
39 45
 
40 46
 /* Begin PBXFileReference section */
47
+		350E75A925756829006B17CC /* Search.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Search.swift; sourceTree = "<group>"; };
48
+		350E75AE2575687C006B17CC /* FoodItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoodItem.swift; sourceTree = "<group>"; };
49
+		350E75B325757572006B17CC /* FoodCardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FoodCardView.swift; sourceTree = "<group>"; };
50
+		350E75BB257576BD006B17CC /* CustomNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomNavigationView.swift; sourceTree = "<group>"; };
51
+		350E75C025757B24006B17CC /* SearchContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchContainer.swift; sourceTree = "<group>"; };
52
+		350E75CC25758D92006B17CC /* UserSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserSettings.swift; sourceTree = "<group>"; };
41 53
 		3565337F25449C3600F2F0DE /* Comedores Sociales.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Comedores Sociales.app"; sourceTree = BUILT_PRODUCTS_DIR; };
42 54
 		3565338225449C3600F2F0DE /* Comedores_SocialesApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Comedores_SocialesApp.swift; sourceTree = "<group>"; };
43 55
 		3565338425449C3600F2F0DE /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -82,6 +94,46 @@
82 94
 /* End PBXFrameworksBuildPhase section */
83 95
 
84 96
 /* Begin PBXGroup section */
97
+		350E75972575672F006B17CC /* View */ = {
98
+			isa = PBXGroup;
99
+			children = (
100
+				350E75B325757572006B17CC /* FoodCardView.swift */,
101
+				350E759D257567F2006B17CC /* Search */,
102
+				350E759C257567E4006B17CC /* Login */,
103
+				350E75BB257576BD006B17CC /* CustomNavigationView.swift */,
104
+			);
105
+			path = View;
106
+			sourceTree = "<group>";
107
+		};
108
+		350E759825756737006B17CC /* Model */ = {
109
+			isa = PBXGroup;
110
+			children = (
111
+				358E946F2558AC130074E928 /* NetworkingModel.swift */,
112
+				3565338B25449C3800F2F0DE /* Persistence.swift */,
113
+				350E75AE2575687C006B17CC /* FoodItem.swift */,
114
+				350E75CC25758D92006B17CC /* UserSettings.swift */,
115
+			);
116
+			path = Model;
117
+			sourceTree = "<group>";
118
+		};
119
+		350E759C257567E4006B17CC /* Login */ = {
120
+			isa = PBXGroup;
121
+			children = (
122
+				356533B82544A1AF00F2F0DE /* LoginView.swift */,
123
+				356533C32544B1FF00F2F0DE /* RegisterView.swift */,
124
+			);
125
+			path = Login;
126
+			sourceTree = "<group>";
127
+		};
128
+		350E759D257567F2006B17CC /* Search */ = {
129
+			isa = PBXGroup;
130
+			children = (
131
+				350E75A925756829006B17CC /* Search.swift */,
132
+				350E75C025757B24006B17CC /* SearchContainer.swift */,
133
+			);
134
+			path = Search;
135
+			sourceTree = "<group>";
136
+		};
85 137
 		3565337625449C3600F2F0DE = {
86 138
 			isa = PBXGroup;
87 139
 			children = (
@@ -107,11 +159,9 @@
107 159
 			children = (
108 160
 				3565338225449C3600F2F0DE /* Comedores_SocialesApp.swift */,
109 161
 				3565338425449C3600F2F0DE /* ContentView.swift */,
110
-				356533B82544A1AF00F2F0DE /* LoginView.swift */,
111
-				356533C32544B1FF00F2F0DE /* RegisterView.swift */,
112
-				358E946F2558AC130074E928 /* NetworkingModel.swift */,
162
+				350E759825756737006B17CC /* Model */,
163
+				350E75972575672F006B17CC /* View */,
113 164
 				3565338625449C3800F2F0DE /* Assets.xcassets */,
114
-				3565338B25449C3800F2F0DE /* Persistence.swift */,
115 165
 				3565339025449C3800F2F0DE /* Info.plist */,
116 166
 				3565338D25449C3800F2F0DE /* Comedores_Sociales.xcdatamodeld */,
117 167
 				3565338825449C3800F2F0DE /* Preview Content */,
@@ -278,8 +328,14 @@
278 328
 				356533B92544A1AF00F2F0DE /* LoginView.swift in Sources */,
279 329
 				3565338C25449C3800F2F0DE /* Persistence.swift in Sources */,
280 330
 				3565338525449C3600F2F0DE /* ContentView.swift in Sources */,
331
+				350E75CD25758D92006B17CC /* UserSettings.swift in Sources */,
332
+				350E75AF2575687C006B17CC /* FoodItem.swift in Sources */,
333
+				350E75C125757B24006B17CC /* SearchContainer.swift in Sources */,
281 334
 				356533C42544B1FF00F2F0DE /* RegisterView.swift in Sources */,
335
+				350E75AA25756829006B17CC /* Search.swift in Sources */,
282 336
 				3565338F25449C3800F2F0DE /* Comedores_Sociales.xcdatamodeld in Sources */,
337
+				350E75BC257576BD006B17CC /* CustomNavigationView.swift in Sources */,
338
+				350E75B425757572006B17CC /* FoodCardView.swift in Sources */,
283 339
 				3565338325449C3600F2F0DE /* Comedores_SocialesApp.swift in Sources */,
284 340
 			);
285 341
 			runOnlyForDeploymentPostprocessing = 0;

BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/100.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/1024.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/114.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/120.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/144.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/152.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/167.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/180.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/20.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/29.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/40.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/50.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/57.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/58.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/60.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/72.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/76.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/80.png View File


BIN
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/87.png View File


+ 1
- 98
Comedores Sociales/Assets.xcassets/AppIcon.appiconset/Contents.json View File

@@ -1,98 +1 @@
1
-{
2
-  "images" : [
3
-    {
4
-      "idiom" : "iphone",
5
-      "scale" : "2x",
6
-      "size" : "20x20"
7
-    },
8
-    {
9
-      "idiom" : "iphone",
10
-      "scale" : "3x",
11
-      "size" : "20x20"
12
-    },
13
-    {
14
-      "idiom" : "iphone",
15
-      "scale" : "2x",
16
-      "size" : "29x29"
17
-    },
18
-    {
19
-      "idiom" : "iphone",
20
-      "scale" : "3x",
21
-      "size" : "29x29"
22
-    },
23
-    {
24
-      "idiom" : "iphone",
25
-      "scale" : "2x",
26
-      "size" : "40x40"
27
-    },
28
-    {
29
-      "idiom" : "iphone",
30
-      "scale" : "3x",
31
-      "size" : "40x40"
32
-    },
33
-    {
34
-      "idiom" : "iphone",
35
-      "scale" : "2x",
36
-      "size" : "60x60"
37
-    },
38
-    {
39
-      "idiom" : "iphone",
40
-      "scale" : "3x",
41
-      "size" : "60x60"
42
-    },
43
-    {
44
-      "idiom" : "ipad",
45
-      "scale" : "1x",
46
-      "size" : "20x20"
47
-    },
48
-    {
49
-      "idiom" : "ipad",
50
-      "scale" : "2x",
51
-      "size" : "20x20"
52
-    },
53
-    {
54
-      "idiom" : "ipad",
55
-      "scale" : "1x",
56
-      "size" : "29x29"
57
-    },
58
-    {
59
-      "idiom" : "ipad",
60
-      "scale" : "2x",
61
-      "size" : "29x29"
62
-    },
63
-    {
64
-      "idiom" : "ipad",
65
-      "scale" : "1x",
66
-      "size" : "40x40"
67
-    },
68
-    {
69
-      "idiom" : "ipad",
70
-      "scale" : "2x",
71
-      "size" : "40x40"
72
-    },
73
-    {
74
-      "idiom" : "ipad",
75
-      "scale" : "1x",
76
-      "size" : "76x76"
77
-    },
78
-    {
79
-      "idiom" : "ipad",
80
-      "scale" : "2x",
81
-      "size" : "76x76"
82
-    },
83
-    {
84
-      "idiom" : "ipad",
85
-      "scale" : "2x",
86
-      "size" : "83.5x83.5"
87
-    },
88
-    {
89
-      "idiom" : "ios-marketing",
90
-      "scale" : "1x",
91
-      "size" : "1024x1024"
92
-    }
93
-  ],
94
-  "info" : {
95
-    "author" : "xcode",
96
-    "version" : 1
97
-  }
98
-}
1
+{"images":[{"size":"60x60","expected-size":"180","filename":"180.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"40x40","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"60x60","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"57x57","expected-size":"57","filename":"57.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"57x57","expected-size":"114","filename":"114.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"60","filename":"60.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"1024x1024","filename":"1024.png","expected-size":"1024","idiom":"ios-marketing","folder":"Assets.xcassets/AppIcon.appiconset/","scale":"1x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"72x72","expected-size":"72","filename":"72.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"76x76","expected-size":"152","filename":"152.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"50x50","expected-size":"100","filename":"100.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"76x76","expected-size":"76","filename":"76.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"50x50","expected-size":"50","filename":"50.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"72x72","expected-size":"144","filename":"144.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"40x40","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"83.5x83.5","expected-size":"167","filename":"167.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"},{"size":"20x20","expected-size":"20","filename":"20.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"1x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"ipad","scale":"2x"}]}

+ 21
- 0
Comedores Sociales/Assets.xcassets/Beans.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "PngItem_1822351.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Beans.imageset/PngItem_1822351.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Carrots.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "fresh-shredded-carrots-bowl-white_147493-79.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Carrots.imageset/fresh-shredded-carrots-bowl-white_147493-79.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Crackers.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "Screen Shot 2020-11-30 at 12.19.45 PM.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Crackers.imageset/Screen Shot 2020-11-30 at 12.19.45 PM.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Eggs.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "IMGBIN_boiled-egg-breakfast-scrambled-eggs-cooking-png_C9SB6xW2.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Eggs.imageset/IMGBIN_boiled-egg-breakfast-scrambled-eggs-cooking-png_C9SB6xW2.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Green Peppers.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "kisspng-bell-pepper-vegetarian-cuisine-vegetable-bowl-a-bowl-of-sliced-__vegetables-with-green-peppe-5aa22eb1bc02e7.5961195015205782257701.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Green Peppers.imageset/kisspng-bell-pepper-vegetarian-cuisine-vegetable-bowl-a-bowl-of-sliced-__vegetables-with-green-peppe-5aa22eb1bc02e7.5961195015205782257701.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Malanga.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "taro.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Malanga.imageset/taro.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Oatmeal.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "klipartz.com.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Oatmeal.imageset/klipartz.com.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Pasta.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "pasta_PNG66.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Pasta.imageset/pasta_PNG66.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Pineapple.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "PngItem_1736567.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Pineapple.imageset/PngItem_1736567.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Potatoes.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "pngfind.com-potato-png-1824199.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Potatoes.imageset/pngfind.com-potato-png-1824199.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Rice.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "—Pngtree—a bowl of white rice_4583461.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Rice.imageset/—Pngtree—a bowl of white rice_4583461.png View File


BIN
Comedores Sociales/Assets.xcassets/Sausages.imageset/5a0abef65a997e1c2cea1080.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Sausages.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "5a0abef65a997e1c2cea1080.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

+ 21
- 0
Comedores Sociales/Assets.xcassets/Vegetable Oil.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "pngkey.com-vegetable-oil-png-4175496.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Vegetable Oil.imageset/pngkey.com-vegetable-oil-png-4175496.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Yellow Onions.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "pngwing.com.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Yellow Onions.imageset/pngwing.com.png View File


+ 21
- 0
Comedores Sociales/Assets.xcassets/Yuca.imageset/Contents.json View File

@@ -0,0 +1,21 @@
1
+{
2
+  "images" : [
3
+    {
4
+      "filename" : "cassava-png-4-png-image-cassava-png-277_184.png",
5
+      "idiom" : "universal",
6
+      "scale" : "1x"
7
+    },
8
+    {
9
+      "idiom" : "universal",
10
+      "scale" : "2x"
11
+    },
12
+    {
13
+      "idiom" : "universal",
14
+      "scale" : "3x"
15
+    }
16
+  ],
17
+  "info" : {
18
+    "author" : "xcode",
19
+    "version" : 1
20
+  }
21
+}

BIN
Comedores Sociales/Assets.xcassets/Yuca.imageset/cassava-png-4-png-image-cassava-png-277_184.png View File


+ 6
- 3
Comedores Sociales/Comedores_SocialesApp.swift View File

@@ -5,16 +5,19 @@
5 5
 //  Created by Hector Carrion on 10/24/20.
6 6
 //
7 7
 
8
+// This is the new SceneDelegate / AppDelegate
9
+
8 10
 import SwiftUI
9 11
 
10 12
 @main
11 13
 struct Comedores_SocialesApp: App {
12
-    let persistenceController = PersistenceController.shared
14
+    
15
+    @StateObject var userSettings = UserSettings()
13 16
 
14 17
     var body: some Scene {
15 18
         WindowGroup {
16
-            LoginView()
17
-                .environment(\.managedObjectContext, persistenceController.container.viewContext)
19
+            ContentView()
20
+                .environmentObject(userSettings)
18 21
         }
19 22
     }
20 23
 }

+ 8
- 68
Comedores Sociales/ContentView.swift View File

@@ -6,79 +6,19 @@
6 6
 //
7 7
 
8 8
 import SwiftUI
9
-import CoreData
10
-
11
-let lightGreyColor = Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0, opacity: 1.0)
12
-let darkGreyColor = Color(red: 41.0/255.0, green: 42.0/255.0, blue: 47.0/255.0, opacity: 1.0)
13
-
14 9
 
15 10
 struct ContentView: View {
16
-    @Environment(\.managedObjectContext) private var viewContext
17
-
18
-    @FetchRequest(
19
-        sortDescriptors: [NSSortDescriptor(keyPath: \Item.timestamp, ascending: true)],
20
-        animation: .default)
21
-    private var items: FetchedResults<Item>
11
+    @StateObject var lvm = LoginViewModel()
12
+    @StateObject var rvm = RegisterViewModel()
22 13
 
23 14
     var body: some View {
24
-        List {
25
-            ForEach(items) { item in
26
-                Text("Item at \(item.timestamp!, formatter: itemFormatter)")
27
-            }
28
-            .onDelete(perform: deleteItems)
29
-        }
30
-        .toolbar {
31
-            #if os(iOS)
32
-            EditButton()
33
-            #endif
34
-
35
-            Button(action: addItem) {
36
-                Label("Add Item", systemImage: "plus")
37
-            }
38
-        }
39
-    }
40
-
41
-    private func addItem() {
42
-        withAnimation {
43
-            let newItem = Item(context: viewContext)
44
-            newItem.timestamp = Date()
45
-
46
-            do {
47
-                try viewContext.save()
48
-            } catch {
49
-                // Replace this implementation with code to handle the error appropriately.
50
-                // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
51
-                let nsError = error as NSError
52
-                fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
53
-            }
54
-        }
55
-    }
56
-
57
-    private func deleteItems(offsets: IndexSet) {
58
-        withAnimation {
59
-            offsets.map { items[$0] }.forEach(viewContext.delete)
60
-
61
-            do {
62
-                try viewContext.save()
63
-            } catch {
64
-                // Replace this implementation with code to handle the error appropriately.
65
-                // fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
66
-                let nsError = error as NSError
67
-                fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
68
-            }
15
+        if lvm.response ?? false || rvm.response ?? false {
16
+            SearchContainer()
17
+        } else {
18
+            LoginView()
19
+                .environmentObject(lvm)
20
+                .environmentObject(rvm)
69 21
         }
70
-    }
71
-}
72
-
73
-private let itemFormatter: DateFormatter = {
74
-    let formatter = DateFormatter()
75
-    formatter.dateStyle = .short
76
-    formatter.timeStyle = .medium
77
-    return formatter
78
-}()
79 22
 
80
-struct ContentView_Previews: PreviewProvider {
81
-    static var previews: some View {
82
-        ContentView().environment(\.managedObjectContext, PersistenceController.preview.container.viewContext)
83 23
     }
84 24
 }

+ 49
- 0
Comedores Sociales/Model/FoodItem.swift View File

@@ -0,0 +1,49 @@
1
+//
2
+//  FoodItem.swift
3
+//  Comedores Sociales
4
+//
5
+//  Created by Hector Carrion on 11/30/20.
6
+//
7
+
8
+import SwiftUI
9
+
10
+struct FoodItem: Identifiable {
11
+    var id = UUID().uuidString
12
+    // both Image And Name Are Same...
13
+    var name: String
14
+    var cuantity: String
15
+    var priceLocal: Float
16
+    var priceExternal: Float
17
+    // Computed property
18
+    var savings: Float {
19
+        return (priceExternal - priceLocal).rounded(toPlaces: 2)
20
+    }
21
+}
22
+
23
+var foods = [
24
+
25
+    FoodItem(name: "Beans", cuantity: "15.5 Oz", priceLocal: 0.58, priceExternal: 0.79),
26
+    FoodItem(name: "Carrots", cuantity: "1 Lb", priceLocal: 0.58, priceExternal: 0.99),
27
+    FoodItem(name: "Crackers", cuantity: "7.6 Oz", priceLocal: 1.61, priceExternal: 2.29),
28
+    FoodItem(name: "Eggs", cuantity: "1 Dozen", priceLocal: 1.11, priceExternal: 1.78),
29
+    FoodItem(name: "Malanga", cuantity: "1 Lb", priceLocal: 0.84, priceExternal: 0.99),
30
+    FoodItem(name: "Oatmeal", cuantity: "12 Oz", priceLocal: 1.67, priceExternal: 1.78),
31
+    FoodItem(name: "Pasta", cuantity: "14 Oz", priceLocal: 0.56, priceExternal: 0.69),
32
+    FoodItem(name: "Green Peppers", cuantity: "1 Lb", priceLocal: 1.72, priceExternal: 2.59),
33
+    FoodItem(name: "Pineapple", cuantity: "1 Lb", priceLocal: 0.78, priceExternal: 0.99),
34
+    FoodItem(name: "Potatoes", cuantity: "1 Lb", priceLocal: 0.49, priceExternal: 0.60),
35
+    FoodItem(name: "Rice", cuantity: "3 Lb", priceLocal: 1, priceExternal: 1.25),
36
+    FoodItem(name: "Sausages", cuantity: "4.6 Oz", priceLocal: 0.55, priceExternal: 0.69),
37
+    FoodItem(name: "Vegetable Oil", cuantity: "16 Oz", priceLocal: 1.29, priceExternal: 1.78),
38
+    FoodItem(name: "Yellow Onions", cuantity: "1 Lb", priceLocal: 0.58, priceExternal: 0.60),
39
+    FoodItem(name: "Yuca", cuantity: "1 Lb", priceLocal: 0.62, priceExternal: 0.99)
40
+]
41
+
42
+
43
+extension Float {
44
+    /// Rounds the double to decimal places value
45
+    func rounded(toPlaces places:Int) -> Float {
46
+        let divisor = pow(10.0, Float(places))
47
+        return (self * divisor).rounded() / divisor
48
+    }
49
+}

+ 180
- 0
Comedores Sociales/Model/NetworkingModel.swift View File

@@ -0,0 +1,180 @@
1
+//
2
+//  DataModel.swift
3
+//  Comedores Sociales
4
+//
5
+//  Created by Hector Carrion on 11/8/20.
6
+//
7
+
8
+import Foundation
9
+
10
+let serverAddress: String = "http://161.35.60.201/"
11
+
12
+class Authentication: Codable {
13
+    var username: String
14
+    var password: String
15
+    
16
+    init(email: String, password: String) {
17
+        self.username = email
18
+        self.password = password
19
+    }
20
+    
21
+    func isComplete() -> Bool {
22
+        if username != "" && password != "" {
23
+            return true
24
+        } else {
25
+            return false
26
+        }
27
+    }
28
+}
29
+
30
+class Registration: Codable {
31
+    var username: String
32
+    var password: String
33
+    var nombre: String
34
+    var urbanizacion: String
35
+    var calle: String
36
+    var pueblo: String
37
+    var cpostal: String
38
+    var telefono: String
39
+    var correo: String
40
+    var organizacion: String?
41
+    var puesto: String?
42
+    
43
+    init(email: String, password: String, name: String, urb: String, street: String, city: String, zip: String, phone: String, org: String? = nil, position: String? = nil) {
44
+        if org != "" {
45
+            self.username = email
46
+            self.password = password
47
+            self.nombre = name
48
+            self.urbanizacion = urb
49
+            self.calle = street
50
+            self.pueblo = city
51
+            self.cpostal = zip
52
+            self.telefono = phone
53
+            self.correo = email
54
+            self.organizacion = org
55
+            self.puesto = position
56
+            
57
+        } else {
58
+            self.username = email
59
+            self.password = password
60
+            self.nombre = name
61
+            self.urbanizacion = urb
62
+            self.calle = street
63
+            self.pueblo = city
64
+            self.cpostal = zip
65
+            self.telefono = phone
66
+            self.correo = email
67
+            self.organizacion = nil
68
+            self.puesto = nil
69
+        }
70
+    }
71
+    
72
+    func isComplete() -> Bool {
73
+        if username != "" && password != "" && nombre != "" && urbanizacion != "" && calle != "" && pueblo != "" && cpostal != "" && telefono != "" && correo != "" {
74
+            return true
75
+        } else {
76
+            return false
77
+        }
78
+    }
79
+}
80
+
81
+
82
+class LoginViewModel: ObservableObject {
83
+    @Published var response: Bool?
84
+    
85
+    func changeResponse(response: Bool) {
86
+        self.response = response
87
+    }
88
+    
89
+    func login(data: Authentication) {
90
+        
91
+        let service = "login.php"
92
+        guard let encodedData = try? JSONEncoder().encode(data)
93
+        else {
94
+            print("Failed to encode login request")
95
+            return
96
+        }
97
+        
98
+        //print("JSON to send:", String(data: encodedData, encoding: .utf8)!)
99
+        
100
+        let url = URL(string: serverAddress + service)!
101
+        var request = URLRequest(url: url)
102
+        request.setValue("applogin/json", forHTTPHeaderField: "Content-Type")
103
+        request.httpMethod = "POST"
104
+        request.httpBody = encodedData
105
+        
106
+        URLSession.shared.dataTask(with: request) {data, response, error in
107
+            
108
+            //handle result here
109
+            guard let data = data
110
+            else {
111
+                print("No data in response: \(error?.localizedDescription ?? "Unknown error").")
112
+                return
113
+            }
114
+            print(response ?? "No response")
115
+            print("Recieved data:", data)
116
+            print(error ?? "No error")
117
+            
118
+            if let httpResponse = response as? HTTPURLResponse {
119
+                DispatchQueue.main.async {
120
+                    if httpResponse.statusCode == 200 {
121
+                        self.changeResponse(response: true)
122
+                    } else {
123
+                        self.changeResponse(response: false)
124
+                    }
125
+                    
126
+                }
127
+            }
128
+            
129
+        }.resume()
130
+    }
131
+}
132
+
133
+class RegisterViewModel: ObservableObject {
134
+    @Published var response: Bool?
135
+    
136
+    func changeResponse(response: Bool) {
137
+        self.response = response
138
+    }
139
+    
140
+    func register(data: Registration) {
141
+        
142
+        let service = "signup.php"
143
+        guard let encodedData = try? JSONEncoder().encode(data)
144
+        else {
145
+            print("Failed to encode register request")
146
+            return
147
+        }
148
+        
149
+        print("Reg JSON to send:", String(data: encodedData, encoding: .utf8)!)
150
+        
151
+        let url = URL(string: serverAddress + service)!
152
+        var request = URLRequest(url: url)
153
+        request.setValue("appregister/json", forHTTPHeaderField: "Content-Type")
154
+        request.httpMethod = "POST"
155
+        request.httpBody = encodedData
156
+        
157
+        URLSession.shared.dataTask(with: request) {data, response, error in
158
+            
159
+            //handle result here
160
+            guard let data = data
161
+            else {
162
+                print("No data in response: \(error?.localizedDescription ?? "Unknown error").")
163
+                return
164
+            }
165
+            print(response ?? "No response")
166
+            print("Recieved data:", data)
167
+            print(error ?? "No error")
168
+            
169
+            if let httpResponse = response as? HTTPURLResponse {
170
+                DispatchQueue.main.async {
171
+                    if httpResponse.statusCode == 200 {
172
+                        self.changeResponse(response: true)
173
+                    } else {
174
+                        self.changeResponse(response: false)
175
+                    }
176
+                }
177
+            }
178
+        }.resume()
179
+    }
180
+}

Comedores Sociales/Persistence.swift → Comedores Sociales/Model/Persistence.swift View File


+ 15
- 0
Comedores Sociales/Model/UserSettings.swift View File

@@ -0,0 +1,15 @@
1
+//
2
+//  UserSettings.swift
3
+//  Comedores Sociales
4
+//
5
+//  Created by Hector Carrion on 11/30/20.
6
+//
7
+
8
+import SwiftUI
9
+
10
+class UserSettings: ObservableObject {
11
+    @Published var isAuthenticated: Bool = false
12
+}
13
+
14
+let lightGreyColor = Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0, opacity: 1.0)
15
+let darkGreyColor = Color(red: 41.0/255.0, green: 42.0/255.0, blue: 47.0/255.0, opacity: 1.0)

+ 0
- 79
Comedores Sociales/NetworkingModel.swift View File

@@ -1,79 +0,0 @@
1
-//
2
-//  DataModel.swift
3
-//  Comedores Sociales
4
-//
5
-//  Created by Hector Carrion on 11/8/20.
6
-//
7
-
8
-import Foundation
9
-
10
-let serverAddress: String = "http://161.35.60.201/"
11
-
12
-class Authentication: Codable {
13
-    var username: String
14
-    var password: String
15
-    
16
-    init(email: String, password: String) {
17
-        self.username = email
18
-        self.password = password
19
-    }
20
-    
21
-    func isComplete() -> Bool {
22
-        if username != "" && password != "" {
23
-            return true
24
-        } else {
25
-            return false
26
-        }
27
-    }
28
-}
29
-
30
-class Registration: Codable {
31
-    var username: String
32
-    var password: String
33
-    var nombre: String
34
-    var urbanizacion: String
35
-    var calle: String
36
-    var pueblo: String
37
-    var cpostal: String
38
-    var telefono: String
39
-    var correo: String
40
-    var organizacion: String?
41
-    var puesto: String?
42
-    
43
-    init(email: String, password: String, name: String, urb: String, street: String, city: String, zip: String, phone: String, org: String? = nil, position: String? = nil) {
44
-        if org != "" {
45
-            self.username = email
46
-            self.password = password
47
-            self.nombre = name
48
-            self.urbanizacion = urb
49
-            self.calle = street
50
-            self.pueblo = city
51
-            self.cpostal = zip
52
-            self.telefono = phone
53
-            self.correo = email
54
-            self.organizacion = org
55
-            self.puesto = position
56
-            
57
-        } else {
58
-            self.username = email
59
-            self.password = password
60
-            self.nombre = name
61
-            self.urbanizacion = urb
62
-            self.calle = street
63
-            self.pueblo = city
64
-            self.cpostal = zip
65
-            self.telefono = phone
66
-            self.correo = email
67
-            self.organizacion = nil
68
-            self.puesto = nil
69
-        }
70
-    }
71
-    
72
-    func isComplete() -> Bool {
73
-        if username != "" && password != "" && nombre != "" && urbanizacion != "" && calle != "" && pueblo != "" && cpostal != "" && telefono != "" && correo != "" {
74
-            return true
75
-        } else {
76
-            return false
77
-        }
78
-    }
79
-}

+ 0
- 188
Comedores Sociales/RegisterView.swift View File

@@ -1,188 +0,0 @@
1
-//
2
-//  RegisterView.swift
3
-//  Comedores Sociales
4
-//
5
-//  Created by Hector Carrion on 10/24/20.
6
-//
7
-
8
-import SwiftUI
9
-
10
-class RegisterViewModel: ObservableObject {
11
-    @Published var response: Bool?
12
-    
13
-    func changeResponse(response: Bool) {
14
-        self.response = response
15
-    }
16
-    
17
-    func register(data: Registration) {
18
-        
19
-        let service = "signup.php"
20
-        guard let encodedData = try? JSONEncoder().encode(data)
21
-        else {
22
-            print("Failed to encode register request")
23
-            return
24
-        }
25
-        
26
-        print("Reg JSON to send:", String(data: encodedData, encoding: .utf8)!)
27
-        
28
-        let url = URL(string: serverAddress + service)!
29
-        var request = URLRequest(url: url)
30
-        request.setValue("appregister/json", forHTTPHeaderField: "Content-Type")
31
-        request.httpMethod = "POST"
32
-        request.httpBody = encodedData
33
-        
34
-        URLSession.shared.dataTask(with: request) {data, response, error in
35
-            
36
-            //handle result here
37
-            guard let data = data
38
-            else {
39
-                print("No data in response: \(error?.localizedDescription ?? "Unknown error").")
40
-                return
41
-            }
42
-            print(response ?? "No response")
43
-            print("Recieved data:", data)
44
-            print(error ?? "No error")
45
-            
46
-            if let httpResponse = response as? HTTPURLResponse {
47
-                DispatchQueue.main.async {
48
-                    if httpResponse.statusCode == 200 {
49
-                        self.changeResponse(response: true)
50
-                    } else {
51
-                        self.changeResponse(response: false)
52
-                    }
53
-                }
54
-            }
55
-        }.resume()
56
-    }
57
-}
58
-
59
-struct RegisterView: View {
60
-    @State var name: String = ""
61
-    @State var phoneNumber: String = ""
62
-    @State var email: String = ""
63
-    @State var password: String = ""
64
-    @State var urb: String = ""
65
-    @State var city: String = ""
66
-    @State var street: String = ""
67
-    @State var org: String = ""
68
-    @State var position: String = ""
69
-    @State var zip: String = ""
70
-    @Environment(\.colorScheme) var colorScheme
71
-    
72
-    @ObservedObject var registerVM = RegisterViewModel()
73
-    @State private var showingAlert = false
74
-    
75
-    var body: some View {
76
-        VStack {
77
-            Text("Details")
78
-                .font(.largeTitle)
79
-                .fontWeight(.semibold)
80
-                .frame(width: 350, height: 25, alignment: .topLeading)
81
-                .padding(.bottom, 20)
82
-            
83
-            ScrollView {
84
-                Group {
85
-                    TextField("Full Name", text: $name)
86
-                        .padding()
87
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
88
-                        .cornerRadius(5.0)
89
-                        .padding(.bottom, 5)
90
-                    TextField("Email", text: $email)
91
-                        .autocapitalization(.none)
92
-                        .padding()
93
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
94
-                        .cornerRadius(5.0)
95
-                        .padding(.bottom, 5)
96
-                    SecureField("Password", text: $password)
97
-                        .autocapitalization(.none)
98
-                        .padding()
99
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
100
-                        .cornerRadius(5.0)
101
-                        .padding(.bottom, 5)
102
-                    TextField("Phone Number", text: $phoneNumber)
103
-                        .keyboardType(.numberPad)
104
-                        .padding()
105
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
106
-                        .cornerRadius(5.0)
107
-                        .padding(.bottom, 5)
108
-                    TextField("Urbanization", text: $urb)
109
-                        .padding()
110
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
111
-                        .cornerRadius(5.0)
112
-                        .padding(.bottom, 5)
113
-                    TextField("Street", text: $street)
114
-                        .padding()
115
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
116
-                        .cornerRadius(5.0)
117
-                        .padding(.bottom, 5)
118
-                    TextField("City", text: $city)
119
-                        .padding()
120
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
121
-                        .cornerRadius(5.0)
122
-                        .padding(.bottom, 5)
123
-                    TextField("Zip Code", text: $zip)
124
-                        .keyboardType(.numberPad)
125
-                        .padding()
126
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
127
-                        .cornerRadius(5.0)
128
-                        .padding(.bottom, 5)
129
-                    TextField("Organization (optional)", text: $org)
130
-                        .padding()
131
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
132
-                        .cornerRadius(5.0)
133
-                        .padding(.bottom, 5)
134
-                    TextField("Position (optional)", text: $position)
135
-                        .padding()
136
-                        .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
137
-                        .cornerRadius(5.0)
138
-                        //.padding(.bottom, 5)
139
-                    
140
-                }.padding(5)
141
-            }
142
-            
143
-            if self.registerVM.response == false {
144
-                Text("Registration failed, please try again")
145
-                    //.offset(y: -5)
146
-                    .foregroundColor(.red)
147
-            } else if self.registerVM.response == true {
148
-                Text("Registration successful 🎉")
149
-                    //.offset(y: -5)
150
-                    .foregroundColor(.green)
151
-            }
152
-            
153
-            
154
-            Button(action: {
155
-                print("register tapped")
156
-                
157
-                let registrationData = Registration(email: email, password: password, name: name, urb: urb, street: street, city: city, zip: zip, phone: phoneNumber, org: org, position: position)
158
-                
159
-                if registrationData.isComplete() {
160
-                    self.registerVM.register(data: registrationData)
161
-                } else {
162
-                    // Alert here
163
-                    self.showingAlert = true
164
-                }
165
-                
166
-            }) {
167
-                Text("Register")
168
-                    .font(.headline)
169
-                    .foregroundColor(.white)
170
-                    .padding()
171
-                    .frame(width: 220, height: 50)
172
-                    .background(Color.blue)
173
-                    .cornerRadius(5)
174
-                    .padding(.bottom, 5)
175
-            }
176
-            
177
-            
178
-        }.alert(isPresented: $showingAlert) {
179
-            Alert(title: Text("Fields incomplete"), message: Text("Please enter a all required information"), dismissButton: .default(Text("OK")))}
180
-        .padding()
181
-    }
182
-}
183
-
184
-struct RegisterView_Previews: PreviewProvider {
185
-    static var previews: some View {
186
-        RegisterView()
187
-    }
188
-}

+ 103
- 0
Comedores Sociales/View/CustomNavigationView.swift View File

@@ -0,0 +1,103 @@
1
+//
2
+//  CustomNavigationView.swift
3
+//  Comedores Sociales
4
+//
5
+//  Created by Hector Carrion on 11/30/20.
6
+//
7
+
8
+import SwiftUI
9
+
10
+struct CustomNavigationView: UIViewControllerRepresentable {
11
+    
12
+    
13
+    func makeCoordinator() -> Coordinator {
14
+        return CustomNavigationView.Coordinator(parent: self)
15
+    }
16
+    
17
+    // Just Change Your View That Requires Search Bar...
18
+    var view: AnyView
19
+    
20
+    // Ease Of Use.....
21
+    
22
+    var largeTitle: Bool
23
+    var title: String
24
+    var placeHolder: String
25
+    
26
+    // onSearch And OnCancel Closures....
27
+    var onSearch: (String)->()
28
+    var onCancel: ()->()
29
+    
30
+    // requre closure on Call...
31
+    
32
+    init(view: AnyView,placeHolder: String? = "Search",largeTitle: Bool? = true,title: String,onSearch: @escaping (String)->(),onCancel: @escaping ()->()) {
33
+      
34
+        self.title = title
35
+        self.largeTitle = largeTitle!
36
+        self.placeHolder = placeHolder!
37
+        self.view = view
38
+        self.onSearch = onSearch
39
+        self.onCancel = onCancel
40
+    }
41
+    
42
+    // Integrating UIKit Navigation Controller With SwiftUI View...
43
+    func makeUIViewController(context: Context) -> UINavigationController {
44
+        
45
+        // requires SwiftUI View...
46
+        let childView = UIHostingController(rootView: view)
47
+        
48
+        let controller = UINavigationController(rootViewController: childView)
49
+        
50
+        // Nav Bar Data...
51
+        
52
+        controller.navigationBar.topItem?.title = title
53
+        controller.navigationBar.prefersLargeTitles = largeTitle
54
+        
55
+        // search Bar....
56
+        
57
+        let searchController = UISearchController()
58
+        searchController.searchBar.placeholder = placeHolder
59
+        
60
+        // setting delegate...
61
+        searchController.searchBar.delegate = context.coordinator
62
+        
63
+        // setting Search Bar In NavBar...
64
+        // disabling hide on scroll...
65
+        
66
+        // disabling dim bg..
67
+        searchController.obscuresBackgroundDuringPresentation = false
68
+        
69
+        controller.navigationBar.topItem?.hidesSearchBarWhenScrolling = false
70
+        controller.navigationBar.topItem?.searchController = searchController
71
+        
72
+        return controller
73
+    }
74
+    
75
+    func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {
76
+        
77
+        // Updating Real Time...
78
+        uiViewController.navigationBar.topItem?.title = title
79
+        uiViewController.navigationBar.topItem?.searchController?.searchBar.placeholder = placeHolder
80
+        uiViewController.navigationBar.prefersLargeTitles = largeTitle
81
+    }
82
+    
83
+    // search Bar Delegate...
84
+    
85
+    class Coordinator: NSObject,UISearchBarDelegate{
86
+        
87
+        var parent: CustomNavigationView
88
+        
89
+        init(parent: CustomNavigationView) {
90
+            self.parent = parent
91
+        }
92
+        
93
+        func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
94
+            // when text changes....
95
+            self.parent.onSearch(searchText)
96
+        }
97
+        
98
+        func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
99
+            // when cancel button is clicked...
100
+            self.parent.onCancel()
101
+        }
102
+    }
103
+}

+ 62
- 0
Comedores Sociales/View/FoodCardView.swift View File

@@ -0,0 +1,62 @@
1
+//
2
+//  FoodCardView.swift
3
+//  Comedores Sociales
4
+//
5
+//  Created by Hector Carrion on 11/30/20.
6
+//
7
+
8
+import SwiftUI
9
+
10
+struct FoodCardView: View {
11
+    
12
+    var item: FoodItem
13
+    @State var show = false
14
+    
15
+    var body: some View {
16
+        
17
+        HStack(spacing: 15){
18
+            
19
+            Image(item.name)
20
+                .resizable()
21
+                .frame(width: 65, height: 65)
22
+            
23
+            VStack{
24
+                
25
+                HStack{
26
+                    
27
+                    VStack(alignment: .leading, spacing: 5) {
28
+                        
29
+                        Text(item.name)
30
+                            .font(.title2)
31
+                        
32
+                        Text(item.cuantity)
33
+                            .font(.caption)
34
+                            .foregroundColor(.gray)
35
+                    }
36
+                    
37
+                    Spacer(minLength: 10)
38
+                    
39
+                    VStack{
40
+                        
41
+                        Button(action: {show.toggle()}) {
42
+                            
43
+                            Text(show ? "Added" : "$" + String(item.priceLocal))
44
+                                .fontWeight(.heavy)
45
+                                .padding(.vertical,8)
46
+                                .padding(.horizontal,20)
47
+                                .background(Color.primary.opacity(0.1))
48
+                                .clipShape(Capsule())
49
+                        }
50
+                        
51
+                        Text("Savings of $" + String(item.savings))
52
+                            .font(.caption2)
53
+                            .foregroundColor(.green)
54
+                    }
55
+                }
56
+                
57
+                Divider()
58
+            }
59
+        }
60
+        .padding(.horizontal)
61
+    }
62
+}

Comedores Sociales/LoginView.swift → Comedores Sociales/View/Login/LoginView.swift View File

@@ -7,63 +7,12 @@
7 7
 
8 8
 import SwiftUI
9 9
 
10
-class LoginViewModel: ObservableObject {
11
-    @Published var response: Bool?
12
-    
13
-    func changeResponse(response: Bool) {
14
-        self.response = response
15
-    }
16
-    
17
-    func login(data: Authentication) {
18
-        
19
-        let service = "login.php"
20
-        guard let encodedData = try? JSONEncoder().encode(data)
21
-        else {
22
-            print("Failed to encode login request")
23
-            return
24
-        }
25
-        
26
-        //print("JSON to send:", String(data: encodedData, encoding: .utf8)!)
27
-        
28
-        let url = URL(string: serverAddress + service)!
29
-        var request = URLRequest(url: url)
30
-        request.setValue("applogin/json", forHTTPHeaderField: "Content-Type")
31
-        request.httpMethod = "POST"
32
-        request.httpBody = encodedData
33
-        
34
-        URLSession.shared.dataTask(with: request) {data, response, error in
35
-            
36
-            //handle result here
37
-            guard let data = data
38
-            else {
39
-                print("No data in response: \(error?.localizedDescription ?? "Unknown error").")
40
-                return
41
-            }
42
-            print(response ?? "No response")
43
-            print("Recieved data:", data)
44
-            print(error ?? "No error")
45
-            
46
-            if let httpResponse = response as? HTTPURLResponse {
47
-                DispatchQueue.main.async {
48
-                    if httpResponse.statusCode == 200 {
49
-                        self.changeResponse(response: true)
50
-                    } else {
51
-                        self.changeResponse(response: false)
52
-                    }
53
-                    
54
-                }
55
-            }
56
-            
57
-        }.resume()
58
-    }
59
-}
60
-
61 10
 struct LoginView: View {
11
+    @EnvironmentObject var loginVM: LoginViewModel
12
+    
62 13
     @State var email: String = ""
63 14
     @State var password: String = ""
64 15
     @State var showingRegister: Bool = false
65
-    
66
-    @ObservedObject var loginVM = LoginViewModel()
67 16
     @State private var showingAlert = false
68 17
     
69 18
     var body: some View {
@@ -73,11 +22,11 @@ struct LoginView: View {
73 22
             EmailField(email: $email)
74 23
             PasswordField(password: $password)
75 24
             
76
-            if self.loginVM.response == false {
25
+            if loginVM.response == false {
77 26
                 Text("Information incorrect, please try again")
78 27
                     .offset(y: -10)
79 28
                     .foregroundColor(.red)
80
-            } else if self.loginVM.response == true {
29
+            } else if loginVM.response == true {
81 30
                 Text("Login successful 🎉")
82 31
                     .offset(y: -10)
83 32
                     .foregroundColor(.green)
@@ -86,7 +35,7 @@ struct LoginView: View {
86 35
             Button(action: {
87 36
                 let authData = Authentication(email: email, password: password)
88 37
                 if authData.isComplete() {
89
-                    self.loginVM.login(data: authData)
38
+                    loginVM.login(data: authData)
90 39
                 } else {
91 40
                     // alert
92 41
                     self.showingAlert = true
@@ -109,11 +58,6 @@ struct LoginView: View {
109 58
     }
110 59
 }
111 60
 
112
-struct LogInView_Previews: PreviewProvider {
113
-    static var previews: some View {
114
-        LoginView()
115
-    }
116
-}
117 61
 
118 62
 struct WelcomeText: View {
119 63
     var body: some View {

+ 164
- 0
Comedores Sociales/View/Login/RegisterView.swift View File

@@ -0,0 +1,164 @@
1
+//
2
+//  RegisterView.swift
3
+//  Comedores Sociales
4
+//
5
+//  Created by Hector Carrion on 10/24/20.
6
+//
7
+
8
+import SwiftUI
9
+
10
+struct RegisterView: View {
11
+    @EnvironmentObject var registerVM: RegisterViewModel
12
+    
13
+    @State var name: String = ""
14
+    @State var phoneNumber: String = ""
15
+    @State var email: String = ""
16
+    @State var password: String = ""
17
+    @State var passwordConf: String = ""
18
+    @State var urb: String = ""
19
+    @State var city: String = ""
20
+    @State var street: String = ""
21
+    @State var org: String = ""
22
+    @State var position: String = ""
23
+    @State var zip: String = ""
24
+    @Environment(\.colorScheme) var colorScheme
25
+    
26
+    @State private var showingAlert = false
27
+    @State private var passwordsAlert = false
28
+    
29
+    var body: some View {
30
+        VStack {
31
+            Text("Details")
32
+                .font(.largeTitle)
33
+                .fontWeight(.semibold)
34
+                .frame(width: 350, height: 25, alignment: .topLeading)
35
+                .padding(.bottom, 20)
36
+            
37
+            ScrollView {
38
+                Group {
39
+                    Group {
40
+                        TextField("Full Name", text: $name)
41
+                            .autocapitalization(.words)
42
+                            .padding()
43
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
44
+                            .cornerRadius(5.0)
45
+                            .padding(.bottom, 5)
46
+                        TextField("Email", text: $email)
47
+                            .disableAutocorrection(true)
48
+                            .autocapitalization(.none)
49
+                            .padding()
50
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
51
+                            .cornerRadius(5.0)
52
+                            .padding(.bottom, 5)
53
+                        SecureField("Password", text: $password)
54
+                            .autocapitalization(.none)
55
+                            .padding()
56
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
57
+                            .cornerRadius(5.0)
58
+                            .padding(.bottom, 5)
59
+                        SecureField("Password (confirmation)", text: $passwordConf)
60
+                            .autocapitalization(.none)
61
+                            .padding()
62
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
63
+                            .cornerRadius(5.0)
64
+                            .padding(.bottom, 5)
65
+                    }
66
+                        TextField("Phone Number", text: $phoneNumber)
67
+                            .keyboardType(.numberPad)
68
+                            .padding()
69
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
70
+                            .cornerRadius(5.0)
71
+                            .padding(.bottom, 5)
72
+                        TextField("Urbanization", text: $urb)
73
+                            .padding()
74
+                            .autocapitalization(.words)
75
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
76
+                            .cornerRadius(5.0)
77
+                            .padding(.bottom, 5)
78
+                        TextField("Street", text: $street)
79
+                            .autocapitalization(.words)
80
+                            .padding()
81
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
82
+                            .cornerRadius(5.0)
83
+                            .padding(.bottom, 5)
84
+                        TextField("City", text: $city)
85
+                            .autocapitalization(.words)
86
+                            .padding()
87
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
88
+                            .cornerRadius(5.0)
89
+                            .padding(.bottom, 5)
90
+                        TextField("Zip Code", text: $zip)
91
+                            .keyboardType(.numberPad)
92
+                            .padding()
93
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
94
+                            .cornerRadius(5.0)
95
+                            .padding(.bottom, 5)
96
+                        TextField("Organization (optional)", text: $org)
97
+                            .autocapitalization(.words)
98
+                            .padding()
99
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
100
+                            .cornerRadius(5.0)
101
+                            .padding(.bottom, 5)
102
+                        TextField("Position (optional)", text: $position)
103
+                            .padding()
104
+                            .background(colorScheme == .dark ? darkGreyColor : lightGreyColor)
105
+                            .cornerRadius(5.0)
106
+                            //.padding(.bottom, 5)
107
+                    
108
+                }.padding(5)
109
+            }
110
+            
111
+            if registerVM.response == false {
112
+                Text("Registration failed, please try again")
113
+                    //.offset(y: -5)
114
+                    .foregroundColor(.red)
115
+            } else if registerVM.response == true {
116
+                Text("Registration successful 🎉")
117
+                    //.offset(y: -5)
118
+                    .foregroundColor(.green)
119
+            }
120
+            
121
+            
122
+            Button(action: {
123
+                print("register tapped")
124
+                
125
+                let registrationData = Registration(email: email, password: password, name: name, urb: urb, street: street, city: city, zip: zip, phone: phoneNumber, org: org, position: position)
126
+                
127
+                if password == passwordConf {
128
+                    if registrationData.isComplete() {
129
+                        registerVM.register(data: registrationData)
130
+                    } else {
131
+                        // Alert here
132
+                        self.showingAlert = true
133
+                    }
134
+                } else {
135
+                    // Alert here
136
+                    self.passwordsAlert = true
137
+                }
138
+                
139
+                
140
+            }) {
141
+                Text("Register")
142
+                    .font(.headline)
143
+                    .foregroundColor(.white)
144
+                    .padding()
145
+                    .frame(width: 220, height: 50)
146
+                    .background(Color.blue)
147
+                    .cornerRadius(5)
148
+                    .padding(.bottom, 5)
149
+            }
150
+            
151
+            
152
+        }.alert(isPresented: $showingAlert) {
153
+            Alert(title: Text("Fields incomplete"), message: Text("Please enter a all required information"), dismissButton: .default(Text("OK")))}
154
+        .alert(isPresented: $passwordsAlert) {
155
+            Alert(title: Text("Passwords do not match"), message: Text("Please retype your password and try again"), dismissButton: .default(Text("OK")))}
156
+        .padding()
157
+    }
158
+}
159
+
160
+struct RegisterView_Previews: PreviewProvider {
161
+    static var previews: some View {
162
+        RegisterView()
163
+    }
164
+}

+ 33
- 0
Comedores Sociales/View/Search/Search.swift View File

@@ -0,0 +1,33 @@
1
+//
2
+//  Search.swift
3
+//  Comedores Sociales
4
+//
5
+//  Created by Hector Carrion on 11/30/20.
6
+//
7
+
8
+import SwiftUI
9
+
10
+struct Search: View {
11
+    // for search Bar...
12
+    @Binding var filteredItems : [FoodItem]
13
+    
14
+    var body: some View {
15
+        
16
+        // Food List View...
17
+        
18
+        ScrollView(.vertical, showsIndicators: false) {
19
+            
20
+            VStack(spacing: 15){
21
+                
22
+                // Food List...
23
+                ForEach(filteredItems){item in
24
+                    
25
+                    // Card View....
26
+                    
27
+                    FoodCardView(item: item)
28
+                }
29
+            }
30
+            .padding()
31
+        }
32
+    }
33
+}

+ 40
- 0
Comedores Sociales/View/Search/SearchContainer.swift View File

@@ -0,0 +1,40 @@
1
+//
2
+//  SearchContainer.swift
3
+//  Comedores Sociales
4
+//
5
+//  Created by Hector Carrion on 11/30/20.
6
+//
7
+
8
+import SwiftUI
9
+
10
+struct SearchContainer: View {
11
+    @State var filteredItems = foods
12
+    
13
+    var body: some View {
14
+
15
+        CustomNavigationView(view: AnyView(Search(filteredItems: $filteredItems)), placeHolder: "Search", largeTitle: true, title: "Inventory",
16
+                             
17
+            onSearch: { (txt) in
18
+
19
+            // filterting Data...
20
+            if txt != ""{
21
+                self.filteredItems = foods.filter{$0.name.lowercased().contains(txt.lowercased())}
22
+            }
23
+            else{
24
+                self.filteredItems = foods
25
+            }
26
+            
27
+        }, onCancel: {
28
+            // Do Your Own Code When Search And Canceled....
29
+            self.filteredItems = foods
30
+            
31
+        })
32
+        .ignoresSafeArea()
33
+    }
34
+}
35
+
36
+struct SearchContainer_Previews: PreviewProvider {
37
+    static var previews: some View {
38
+        SearchContainer()
39
+    }
40
+}