Showing
23 changed files
with
591 additions
and
129 deletions
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "coupon_bg.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "coupon_bg-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "coupon_bg-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
2.28 KB
2.28 KB
2.28 KB
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "filters_btn.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "filters_btn-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "filters_btn-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
2.03 KB
2.03 KB
2.03 KB
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "location_icon.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "location_icon-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "location_icon-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "search_icon.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "search_icon-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "search_icon-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
2.58 KB
2.58 KB
2.58 KB
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> | 7 | <key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> | 7 | <key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
... | @@ -8,139 +8,497 @@ | ... | @@ -8,139 +8,497 @@ |
8 | 8 | ||
9 | #if canImport(SwiftUI) | 9 | #if canImport(SwiftUI) |
10 | import SwiftUI | 10 | import SwiftUI |
11 | +import Combine | ||
12 | +import Foundation | ||
13 | +import UIKit | ||
14 | + | ||
15 | + | ||
16 | +class CouponSetItemModel { | ||
17 | + let uuid: String? | ||
18 | + let admin_name: String? | ||
19 | + let name: String? | ||
20 | + let img_preview: String? | ||
21 | + let expiration: String? | ||
22 | + let description: String? | ||
23 | + let short_description: String? | ||
24 | + let discount: String? | ||
25 | + | ||
26 | + init(dictionary: [String: Any]) { | ||
27 | + self.uuid = dictionary["uuid"] as? String? ?? "" | ||
28 | + self.admin_name = dictionary["admin_name"] as? String? ?? "" | ||
29 | + self.name = dictionary["name"] as? String? ?? "" | ||
30 | + self.img_preview = dictionary["img_preview"] as? String? ?? "" | ||
31 | + self.description = dictionary["description"] as? String? ?? "" | ||
32 | + self.short_description = dictionary["short_description"] as? String? ?? "" | ||
33 | + self.discount = dictionary["discount"] as? String? ?? "" | ||
34 | + | ||
35 | + let expirationObject = dictionary["expiration"] as? [String: Any]? ?? ["":""] | ||
36 | + let expirationString = expirationObject?["value"] as? String? ?? "" | ||
37 | + | ||
38 | +// Example expirationString: Optional(2022-12-05 01:55) | ||
39 | + | ||
40 | + let dateFormatter = DateFormatter() | ||
41 | + dateFormatter.dateFormat = "yyyy-MM-dd hh:mm" | ||
42 | + let date = dateFormatter.date(from: expirationString ?? "") | ||
43 | + dateFormatter.dateFormat = "dd/MM/yyyy" | ||
44 | + let resultString = dateFormatter.string(from: date!) | ||
45 | + self.expiration = resultString | ||
46 | + | ||
47 | + } | ||
48 | +} | ||
11 | 49 | ||
12 | class CouponDataModel { | 50 | class CouponDataModel { |
13 | - var data: Array<NSDictionary> = [] | 51 | + var data: Array<CouponSetItemModel> = [] |
14 | 52 | ||
15 | init() { //initializer method | 53 | init() { //initializer method |
16 | let instanceOfMyApi = MyApi() | 54 | let instanceOfMyApi = MyApi() |
17 | let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil) | 55 | let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil) |
18 | - let coupons = instanceOfMyApi.getCoupons() as AnyObject? | 56 | + var couponSetsArray:Array<CouponSetItemModel> = [] |
19 | 57 | ||
20 | if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] { | 58 | if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] { |
21 | - let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! Array<NSMutableDictionary>) | 59 | + let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! NSArray) |
22 | - if let myCouponsDictionary = coupons as? [String : AnyObject] { | 60 | + |
23 | - let couponsData = (myCouponsDictionary["result"] as! Array<NSMutableDictionary>) | 61 | + |
24 | - if let sets = couponSetsData as? NSArray { | 62 | + for couponset in couponSetsData { |
25 | - for set in sets { | 63 | + let tempCouponset = CouponSetItemModel(dictionary: couponset as! [String : Any]) |
26 | - let s = set as! NSDictionary | 64 | + couponSetsArray.append(tempCouponset) |
27 | - if let cpns = couponsData as? NSArray { | ||
28 | - for coupon in cpns { | ||
29 | - var c = coupon as! NSDictionary | ||
30 | -// var temp = NSMutableDictionary(dictionary: s); | ||
31 | - if c["couponset_uuid"] as! String == s["uuid"] as! String { | ||
32 | - var temp = NSMutableDictionary(dictionary: s); | ||
33 | - temp.addEntries(from: c as! [AnyHashable : Any]) | ||
34 | - | ||
35 | - self.data.append(temp as NSDictionary) | ||
36 | - } | ||
37 | - | ||
38 | - } | ||
39 | - } | ||
40 | - | ||
41 | - } | ||
42 | - } | ||
43 | } | 65 | } |
66 | + | ||
44 | } | 67 | } |
68 | + self.data = couponSetsArray | ||
45 | } | 69 | } |
46 | 70 | ||
47 | - var getData: Array<NSDictionary> { | 71 | + var getData: Array<CouponSetItemModel> { |
48 | get { // getter | 72 | get { // getter |
49 | return data | 73 | return data |
50 | } | 74 | } |
51 | } | 75 | } |
52 | } | 76 | } |
53 | 77 | ||
78 | + | ||
79 | +class CampaignItemModel { | ||
80 | + let index_url: String? | ||
81 | + let logo_url: String? | ||
82 | + let offer_category: String? | ||
83 | + let title: String? | ||
84 | + let subtitle: String? | ||
85 | + let session_uuid: String? | ||
86 | + let subcategory: String? | ||
87 | + | ||
88 | + init(dictionary: [String: Any]) { | ||
89 | + self.index_url = dictionary["index_url"] as? String? ?? "" | ||
90 | + self.logo_url = dictionary["logo_url"] as? String? ?? "" | ||
91 | + self.offer_category = dictionary["offer_category"] as? String? ?? "" | ||
92 | + self.title = dictionary["title"] as? String? ?? "" | ||
93 | + self.subtitle = dictionary["subtitle"] as? String? ?? "" | ||
94 | + self.session_uuid = dictionary["session_uuid"] as? String? ?? "" | ||
95 | + | ||
96 | +// let extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? ["":""] | ||
97 | + let extra_fields = dictionary["extra_fields"] as AnyObject | ||
98 | + var extra_fields_parsed:[String: Any] | ||
99 | + | ||
100 | + let json = extra_fields.data(using: String.Encoding.utf8.rawValue) | ||
101 | + do { | ||
102 | + if let jsonArray = try JSONSerialization.jsonObject(with: json!, options: .allowFragments) as? [String:AnyObject] | ||
103 | + { | ||
104 | + extra_fields_parsed = jsonArray; | ||
105 | + self.subcategory = extra_fields_parsed["subcategory"] as? String? ?? "" | ||
106 | + } else { | ||
107 | + self.subcategory = "" | ||
108 | + print("bad json") | ||
109 | + } | ||
110 | + } catch let error as NSError { | ||
111 | + self.subcategory = "" | ||
112 | + print(error) | ||
113 | + } | ||
114 | + | ||
115 | + } | ||
116 | +} | ||
117 | + | ||
54 | class CampaignDataModel { | 118 | class CampaignDataModel { |
55 | - var data: Array<NSDictionary> = [] | 119 | + var data: Array<CampaignItemModel> = [] |
56 | 120 | ||
57 | init() { //initializer method | 121 | init() { //initializer method |
58 | let instanceOfMyApi = MyApi() | 122 | let instanceOfMyApi = MyApi() |
59 | - let products = instanceOfMyApi.getInbox() | 123 | + let products = instanceOfMyApi.getInbox() as NSMutableArray? |
60 | - | 124 | + |
61 | - print("======== Inbox print =========") | 125 | + var giftsArray:Array<CampaignItemModel> = [] |
62 | - print(products?[0]) | 126 | + |
63 | - print("======== Inbox dump =========") | 127 | + |
64 | - dump(products?[0]) | 128 | + for gift in products ?? [] { |
65 | - print("======== Inbox =========") | 129 | + let tempGift = CampaignItemModel(dictionary: gift as! [String : Any]) |
66 | - | 130 | + giftsArray.append(tempGift) |
67 | - | 131 | + } |
68 | - // let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil) | 132 | + |
69 | - // let coupons = instanceOfMyApi.getCoupons() as AnyObject? | 133 | + self.data = giftsArray; |
70 | - | 134 | + |
71 | -// if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] { | ||
72 | -// let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! Array<NSMutableDictionary>) | ||
73 | -// if let myCouponsDictionary = coupons as? [String : AnyObject] { | ||
74 | -// let couponsData = (myCouponsDictionary["result"] as! Array<NSMutableDictionary>) | ||
75 | -// if let sets = couponSetsData as? NSArray { | ||
76 | -// for set in sets { | ||
77 | -// let s = set as! NSDictionary | ||
78 | -// if let cpns = couponsData as? NSArray { | ||
79 | -// for coupon in cpns { | ||
80 | -// var c = coupon as! NSDictionary | ||
81 | -// // var temp = NSMutableDictionary(dictionary: s); | ||
82 | -// if c["couponset_uuid"] as! String == s["uuid"] as! String { | ||
83 | -// var temp = NSMutableDictionary(dictionary: s); | ||
84 | -// temp.addEntries(from: c as! [AnyHashable : Any]) | ||
85 | - | ||
86 | -// self.data.append(temp as NSDictionary) | ||
87 | -// } | ||
88 | - | ||
89 | -// } | ||
90 | -// } | ||
91 | - | ||
92 | -// } | ||
93 | -// } | ||
94 | -// } | ||
95 | -// } | ||
96 | } | 135 | } |
97 | 136 | ||
98 | - var getData: Array<NSDictionary> { | 137 | + var getData: Array<CampaignItemModel> { |
99 | get { // getter | 138 | get { // getter |
100 | return data | 139 | return data |
101 | } | 140 | } |
102 | } | 141 | } |
103 | } | 142 | } |
104 | 143 | ||
144 | +extension String { | ||
145 | + func htmlToString() -> String { | ||
146 | + return try! NSAttributedString(data: self.data(using: .utf8)!, | ||
147 | + options: [.documentType: NSAttributedString.DocumentType.html], | ||
148 | + documentAttributes: nil).string | ||
149 | + } | ||
150 | +} | ||
151 | + | ||
152 | +extension View { | ||
153 | + func cornerRadius(_ radius: CGFloat, corners: UIRectCorner) -> some View { | ||
154 | + clipShape( RoundedCorner(radius: radius, corners: corners) ) | ||
155 | + } | ||
156 | +} | ||
157 | + | ||
158 | +struct RoundedCorner: Shape { | ||
159 | + | ||
160 | + var radius: CGFloat = .infinity | ||
161 | + var corners: UIRectCorner = .allCorners | ||
162 | + | ||
163 | + func path(in rect: CGRect) -> Path { | ||
164 | + let path = UIBezierPath(roundedRect: rect, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) | ||
165 | + return Path(path.cgPath) | ||
166 | + } | ||
167 | +} | ||
168 | + | ||
169 | +class ImageLoaderGifts: ObservableObject { | ||
170 | + var didChange = PassthroughSubject<Data, Never>() | ||
171 | + var data = Data() { | ||
172 | + didSet { | ||
173 | + didChange.send(data) | ||
174 | + } | ||
175 | + } | ||
176 | + | ||
177 | + init(urlString:String) { | ||
178 | + guard let url = URL(string: urlString) else { return } | ||
179 | + let task = URLSession.shared.dataTask(with: url) { data, response, error in | ||
180 | + guard let data = data else { return } | ||
181 | + DispatchQueue.main.async { | ||
182 | + self.data = data | ||
183 | + } | ||
184 | + } | ||
185 | + task.resume() | ||
186 | + } | ||
187 | +} | ||
188 | + | ||
189 | + | ||
105 | extension GiftsView { | 190 | extension GiftsView { |
106 | struct headerView: View { | 191 | struct headerView: View { |
192 | + var goBack: () -> () | ||
107 | 193 | ||
108 | var uiscreen = UIScreen.main.bounds | 194 | var uiscreen = UIScreen.main.bounds |
109 | 195 | ||
110 | var body: some View { | 196 | var body: some View { |
111 | - ZStack { | 197 | + HStack(alignment: .center) { |
112 | - Image("ic_back", bundle: Bundle(for: MyEmptyClass.self)) | 198 | + Button { |
113 | - .resizable() | 199 | + // Button Action |
114 | - .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02) | 200 | + print("Back Button tapped!") |
115 | - .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.07) | 201 | + goBack() |
116 | - Text("Όλα τα κουπόνια μου") | 202 | + } label: { |
117 | - .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center) | 203 | + Image("ic_back", bundle: Bundle(for: MyEmptyClass.self)) |
118 | - .offset( y: self.uiscreen.height * 0.07) | 204 | + .resizable() |
119 | - .frame(width: self.uiscreen.width) | 205 | + .aspectRatio(contentMode: .fit) |
206 | + .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02) | ||
207 | + } | ||
208 | + | ||
209 | + Text("Gifts for You") | ||
210 | + .fontWeight(.medium) | ||
211 | + .font(.system(size: 16)) | ||
212 | + .foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196)) | ||
213 | + .multilineTextAlignment(.center) | ||
214 | + .frame(maxWidth: .infinity) | ||
215 | + .padding(.horizontal) | ||
216 | + | ||
217 | + Button { | ||
218 | + // Button Action | ||
219 | + print("Location tapped!") | ||
220 | + } label: { | ||
221 | + Image("location_icon", bundle: Bundle(for: MyEmptyClass.self)) | ||
222 | + .resizable() | ||
223 | + .aspectRatio(contentMode: .fit) | ||
224 | + .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04) | ||
225 | + } | ||
226 | + | ||
120 | } | 227 | } |
228 | + .frame(maxWidth: .infinity) | ||
229 | + .padding(.horizontal) | ||
230 | + .padding(.vertical, 10) | ||
121 | } | 231 | } |
122 | } | 232 | } |
123 | 233 | ||
124 | - struct giftView: View { | 234 | + struct searchView: View { |
125 | -// @Binding var result: NSDictionary | 235 | + @State var searchText: String = "" |
126 | 236 | ||
127 | var uiscreen = UIScreen.main.bounds | 237 | var uiscreen = UIScreen.main.bounds |
128 | 238 | ||
129 | var body: some View { | 239 | var body: some View { |
130 | - ZStack { | 240 | + HStack(alignment: .center) { |
131 | -// URLImage(url: URL(string: result["img_preview"] as! String? ?? "")) | 241 | + HStack(alignment: .center) { |
132 | -// .resizable() | 242 | + Image("search_icon", bundle: Bundle(for: MyEmptyClass.self)) |
133 | -// .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04) | 243 | + .resizable() |
134 | -// .cornerRadius(CGFloat(self.uiscreen.height * 0.02)) | 244 | + .aspectRatio(contentMode: .fit) |
135 | -// .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07) | 245 | + .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.025) |
246 | + .padding([.top, .leading, .bottom], 10) | ||
247 | + TextField("Βρες το gift που σε ενδιαφέρει", text: $searchText) | ||
248 | + .frame(maxWidth: .infinity) | ||
249 | + .padding(.all, 10) | ||
250 | + .foregroundColor(Color(red: 0.48627450980392156, green: 0.48627450980392156, blue: 0.48627450980392156)) | ||
251 | + .font(.system(size: 16, weight: .regular, design: .default)) | ||
252 | + } | ||
253 | + .overlay( | ||
254 | + RoundedRectangle(cornerRadius: 9) | ||
255 | + .stroke(Color(red: 0.8235294117647058, green: 0.8235294117647058, blue: 0.8235294117647058), lineWidth: 1) | ||
256 | + ) | ||
257 | + | ||
258 | + Button { | ||
259 | + // Button Action | ||
260 | + print("Filters tapped!") | ||
261 | + } label: { | ||
262 | + Image("filters_btn", bundle: Bundle(for: MyEmptyClass.self)) | ||
263 | + .resizable() | ||
264 | + .aspectRatio(contentMode: .fit) | ||
265 | + .frame(width: self.uiscreen.height * 0.06, height: self.uiscreen.height * 0.04) | ||
266 | + .padding(.leading, 5) | ||
267 | + } | ||
268 | + } | ||
269 | + .frame(maxWidth: .infinity) | ||
270 | + .padding(.horizontal, 20) | ||
271 | + .padding(.vertical, 5) | ||
272 | + } | ||
273 | + } | ||
274 | + | ||
275 | + struct ImageView: View { | ||
276 | + @ObservedObject var imageLoader:ImageLoaderGifts | ||
277 | + @State var image:UIImage = UIImage() | ||
278 | + @State var width:CGFloat | ||
279 | + @State var isFill:Bool | ||
280 | + | ||
281 | + var uiscreen = UIScreen.main.bounds | ||
282 | + | ||
283 | + init(withURL url:String , width:CGFloat, isFill:Bool) { | ||
284 | + imageLoader = ImageLoaderGifts(urlString:url) | ||
285 | + self.width = width | ||
286 | + self.isFill = isFill | ||
287 | + } | ||
136 | 288 | ||
289 | + var body: some View { | ||
290 | + | ||
291 | + Image(uiImage: image) | ||
292 | + .resizable() | ||
293 | + .aspectRatio(contentMode: isFill ? .fill : .fit) | ||
294 | + .frame(width: self.width) | ||
295 | + .frame(maxHeight: .infinity) | ||
296 | + .onReceive(imageLoader.didChange) { data in | ||
297 | + self.image = UIImage(data: data) ?? UIImage() | ||
298 | + } | ||
299 | + } | ||
300 | + } | ||
301 | + | ||
302 | + | ||
303 | + struct giftItemView: View { | ||
304 | + var item: CampaignItemModel | ||
305 | + var isFirst: Bool | ||
306 | + var isLast: Bool | ||
307 | + | ||
308 | + var uiscreen = UIScreen.main.bounds | ||
309 | + | ||
310 | + var body: some View { | ||
311 | + Button { | ||
312 | + // GiftItem Action | ||
313 | + print("GiftItem tapped!") | ||
314 | + } label: { | ||
315 | + HStack(alignment: .center) { | ||
316 | + | ||
317 | + ImageView(withURL: item.logo_url ?? "", width: self.uiscreen.width * 0.5, isFill: true) | ||
318 | + | ||
319 | + Text(item.title ?? "") | ||
320 | + .fontWeight(.regular) | ||
321 | + .font(.system(size: 16)) | ||
322 | + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | ||
323 | + .multilineTextAlignment(.center) | ||
324 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
325 | + .padding(.all, 10) | ||
326 | + .background(Color.white) | ||
327 | + } | ||
328 | + } | ||
329 | + .frame(width: self.uiscreen.width * 0.9, height: self.uiscreen.height * 0.16) | ||
330 | + .background(Color.white) | ||
331 | + .cornerRadius(5) | ||
332 | + .shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 30, x: 0, y: 3) | ||
333 | + .padding(.leading, isFirst ? 18 : 0) | ||
334 | + .padding(.trailing, isLast ? 18 : 0) | ||
335 | + } | ||
336 | + } | ||
337 | + | ||
338 | + struct giftsContainer: View { | ||
339 | + @State var gifts:Array<CampaignItemModel> = [] | ||
340 | + @State var title:String = "" | ||
341 | + | ||
342 | + var uiscreen = UIScreen.main.bounds | ||
343 | + | ||
344 | + var body: some View { | ||
345 | + VStack(alignment: .leading) { | ||
346 | + | ||
347 | + Text(title) | ||
348 | + .fontWeight(.bold) | ||
349 | + .font(.system(size: 17)) | ||
350 | + .foregroundColor(Color.white) | ||
351 | + .multilineTextAlignment(.leading) | ||
352 | + .padding(.horizontal) | ||
353 | + .padding(.top, self.uiscreen.height * 0.05) | ||
354 | + .padding(.bottom, self.uiscreen.height * 0.015) | ||
355 | + | ||
356 | + ScrollView(.horizontal, showsIndicators: false) { | ||
357 | + HStack(alignment: .center) { | ||
358 | + ForEach(Array(gifts.enumerated()), id: \.offset) { index, item in | ||
359 | + | ||
360 | + giftItemView(item: item, isFirst: index == 0, isLast: index == (gifts.count-1)) | ||
361 | + } | ||
362 | + | ||
363 | + } | ||
364 | + .frame(maxWidth: .infinity) | ||
365 | + } | ||
366 | + .frame(maxWidth: .infinity) | ||
367 | + | ||
368 | + } | ||
369 | + .frame(maxWidth: .infinity) | ||
370 | + } | ||
371 | + } | ||
372 | + | ||
373 | + struct couponsContainer: View { | ||
374 | + @State var coupons:Array<CouponSetItemModel> = [] | ||
375 | + @State var title:String = "" | ||
376 | + | ||
377 | + var uiscreen = UIScreen.main.bounds | ||
378 | + | ||
379 | + var body: some View { | ||
380 | + VStack(alignment: .leading) { | ||
381 | + | ||
382 | + Text(title) | ||
383 | + .fontWeight(.bold) | ||
384 | + .font(.system(size: 17)) | ||
385 | + .foregroundColor(Color.white) | ||
386 | + .multilineTextAlignment(.leading) | ||
387 | + .padding(.horizontal) | ||
388 | + .padding(.top, self.uiscreen.height * 0.05) | ||
389 | + .padding(.bottom, self.uiscreen.height * 0.015) | ||
390 | + | ||
391 | + ScrollView(.horizontal, showsIndicators: false) { | ||
392 | + HStack(alignment: .center) { | ||
393 | + ForEach(Array(coupons.enumerated()), id: \.offset) { index, item in | ||
394 | + | ||
395 | + couponItemView(item: item, isFirst: index == 0, isLast: index == (coupons.count-1)) | ||
396 | + } | ||
397 | + | ||
398 | + } | ||
399 | + .frame(maxWidth: .infinity) | ||
400 | + } | ||
401 | + .frame(maxWidth: .infinity) | ||
402 | + | ||
403 | + } | ||
404 | + .frame(maxWidth: .infinity) | ||
405 | + .padding(.bottom, self.uiscreen.height * 0.1) | ||
406 | + } | ||
407 | + } | ||
408 | + | ||
409 | + struct couponItemView: View { | ||
410 | + var item: CouponSetItemModel | ||
411 | + var isFirst: Bool | ||
412 | + var isLast: Bool | ||
413 | + | ||
414 | + var uiscreen = UIScreen.main.bounds | ||
415 | + | ||
416 | + var body: some View { | ||
417 | + Button { | ||
418 | + // GiftItem Action | ||
419 | + print("GiftItem tapped!") | ||
420 | + } label: { | ||
421 | + | ||
422 | + HStack(alignment: .center) { | ||
423 | + | ||
424 | + ImageView(withURL: item.img_preview ?? "", width: self.uiscreen.width * 0.15, isFill: false) | ||
425 | + | ||
426 | + VLine() | ||
427 | + .stroke(style: StrokeStyle(lineWidth: 1, dash: [5])) | ||
428 | + .foregroundColor(Color(red: 0.4392156862745098, green: 0.4392156862745098, blue: 0.4392156862745098)) | ||
429 | + .frame(width: 1) | ||
430 | + .padding(.leading, 10) | ||
431 | + | ||
432 | + VStack(alignment: .leading) { | ||
433 | + Text(item.name ?? "") | ||
434 | + .fontWeight(.medium) | ||
435 | + .font(.system(size: 16)) | ||
436 | + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | ||
437 | + .multilineTextAlignment(.leading) | ||
438 | + .lineLimit(1) | ||
439 | +// .frame(maxWidth: .infinity) | ||
440 | + | ||
441 | + HStack(alignment: .center) { | ||
442 | + Text((item.discount ?? "")+"€") | ||
443 | + .fontWeight(.bold) | ||
444 | + .font(.system(size: 25)) | ||
445 | + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | ||
446 | + .multilineTextAlignment(.leading) | ||
447 | + .lineLimit(1) | ||
448 | +// .frame(width: self.uiscreen.width * 0.3) | ||
449 | +// .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
450 | + | ||
451 | + Text(item.short_description ?? "") | ||
452 | + .fontWeight(.medium) | ||
453 | + .font(.system(size: 11)) | ||
454 | + .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) | ||
455 | + .multilineTextAlignment(.leading) | ||
456 | + .lineLimit(3) | ||
457 | +// .frame(maxWidth: .infinity) | ||
458 | +// .padding(.leading, 10) | ||
459 | + } | ||
460 | +// .padding(.vertical, 5) | ||
461 | + .frame(maxHeight: .infinity) | ||
462 | + | ||
463 | + Text("Ισχύει έως "+(item.expiration ?? "")) | ||
464 | + .fontWeight(.medium) | ||
465 | + .font(.system(size: 11)) | ||
466 | + .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) | ||
467 | + .multilineTextAlignment(.leading) | ||
468 | +// .frame(maxWidth: .infinity) | ||
469 | +// .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
470 | +// .padding(.all, 10) | ||
471 | + } | ||
472 | + .padding(.all, 10) | ||
473 | +// .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
474 | + | ||
475 | + Spacer() | ||
476 | + | ||
477 | + } | ||
478 | + .padding(.leading, 28) | ||
479 | + .padding(.trailing) | ||
480 | + } | ||
481 | + .frame(width: self.uiscreen.width * 0.9, height: self.uiscreen.height * 0.14) | ||
482 | + .cornerRadius(5) | ||
483 | + .shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 30, x: 0, y: 3) | ||
484 | + .padding(.leading, isFirst ? 18 : 0) | ||
485 | + .padding(.trailing, isLast ? 18 : 0) | ||
486 | + .background( | ||
487 | + Image("coupon_bg", bundle: Bundle(for: MyEmptyClass.self)) | ||
488 | + .resizable(resizingMode: .stretch) | ||
489 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
490 | + .padding(.leading, isFirst ? 18 : 0) | ||
491 | + .padding(.trailing, isLast ? 18 : 0) | ||
492 | + ) | ||
493 | + } | ||
494 | + } | ||
495 | + | ||
496 | + struct VLine: Shape { | ||
497 | + func path(in rect: CGRect) -> Path { | ||
498 | + Path { path in | ||
499 | + path.move(to: CGPoint(x: rect.midX, y: rect.minY)) | ||
500 | + path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY)) | ||
137 | } | 501 | } |
138 | -// .background( | ||
139 | -// Image("coupons_container", bundle: Bundle(for: MyEmptyClass.self)) | ||
140 | -// .resizable() | ||
141 | -//// .edgesIgnoringSafeArea(.all) | ||
142 | -// .frame(width: UIScreen.main.bounds.width * 0.8, height: UIScreen.main.bounds.height * 0.17) | ||
143 | -// ) | ||
144 | } | 502 | } |
145 | } | 503 | } |
146 | 504 | ||
... | @@ -148,48 +506,63 @@ extension GiftsView { | ... | @@ -148,48 +506,63 @@ extension GiftsView { |
148 | 506 | ||
149 | @available(iOS 13.0.0, *) | 507 | @available(iOS 13.0.0, *) |
150 | struct GiftsView: View { | 508 | struct GiftsView: View { |
509 | + var parentView: UIView | ||
151 | 510 | ||
152 | - var data:Array<NSDictionary> = CouponDataModel().getData | 511 | + var coupons:Array<CouponSetItemModel> = CouponDataModel().getData |
153 | - var campains:Any = CampaignDataModel() | 512 | + var campains:Array<CampaignItemModel> = CampaignDataModel().getData.filter { $0.offer_category == "gifts_for_you" } |
154 | 513 | ||
155 | var uiscreen = UIScreen.main.bounds | 514 | var uiscreen = UIScreen.main.bounds |
156 | 515 | ||
516 | + func goBack(){ | ||
517 | + for subview in parentView.subviews { | ||
518 | + if(subview.tag == 5) { | ||
519 | + subview.removeFromSuperview() | ||
520 | + } | ||
521 | + } | ||
522 | + } | ||
523 | + | ||
157 | var body: some View { | 524 | var body: some View { |
158 | VStack { | 525 | VStack { |
159 | - headerView() | 526 | + headerView(goBack: goBack) |
160 | -// ScrollView { | 527 | + searchView() |
161 | -// VStack { | 528 | + |
162 | -// if (data.count) > 0 { | 529 | + ScrollView(showsIndicators: false) { |
163 | -// ForEach(data, id: \.self) { result in | 530 | + VStack { |
164 | -// couponView(result: result) | 531 | + if (campains.filter { $0.subcategory == "gifts" }.count) > 0 { |
165 | -// } | 532 | + giftsContainer(gifts: campains.filter { $0.subcategory == "gifts" }, title: "ΔΩΡΑ") |
166 | -// } | 533 | + } |
167 | -// } | 534 | + |
168 | -// .frame(width:self.uiscreen.width, height:self.uiscreen.height ) | 535 | + |
169 | -// } | 536 | + if (campains.filter { $0.subcategory == "rewards" }.count) > 0 { |
537 | + giftsContainer(gifts: campains.filter { $0.subcategory == "rewards"}, title: "ΕΠΙΒΡΑΒΕΥΣΕΙΣ" ) | ||
538 | + } | ||
539 | + | ||
540 | + if (coupons.count) > 0 { | ||
541 | + couponsContainer(coupons: coupons, title: "ΚΟΥΠΟΝΙΑ" ) | ||
542 | + } | ||
543 | + | ||
544 | + } | ||
545 | + .frame(width:self.uiscreen.width) | ||
546 | + } | ||
547 | + .background( | ||
548 | + LinearGradient(gradient: Gradient(colors: [Color(red: 0.06, green: 0.67, blue: 0.84), Color(red: 0.47, green: 0.75, blue: 0.43)]), startPoint: .top, endPoint: .bottom) | ||
549 | + ) | ||
550 | + .cornerRadius(30, corners: [.topLeft]) | ||
551 | + .frame(width:self.uiscreen.width) | ||
552 | + .frame(maxHeight: .infinity) | ||
170 | } | 553 | } |
554 | + .edgesIgnoringSafeArea([.bottom]) | ||
555 | + .frame(width:self.uiscreen.width) | ||
556 | + .frame(maxHeight: .infinity) | ||
171 | } | 557 | } |
172 | } | 558 | } |
173 | #endif | 559 | #endif |
174 | -//struct ProfileView_Previews: PreviewProvider { | 560 | + |
561 | +//@available(iOS 13.0.0, *) | ||
562 | +//struct GiftsView_Previews: PreviewProvider { | ||
175 | // static var previews: some View { | 563 | // static var previews: some View { |
176 | -// ProfileView() | 564 | +// |
565 | +// GiftsView() | ||
566 | +// | ||
177 | // } | 567 | // } |
178 | //} | 568 | //} |
179 | - | ||
180 | -@available(iOS 13.0.0, *) | ||
181 | -struct Previews_GiftsView_Previews: PreviewProvider { | ||
182 | - static var uiscreen = UIScreen.main.bounds | ||
183 | - static var previews: some View { | ||
184 | - ZStack { | ||
185 | - Image("ic_back", bundle: Bundle(for: MyEmptyClass.self)) | ||
186 | - .resizable() | ||
187 | - .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02) | ||
188 | - .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.07) | ||
189 | - Text("Όλα τα κουπόνια μου") | ||
190 | - .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center) | ||
191 | - .offset( y: self.uiscreen.height * 0.07) | ||
192 | - } | ||
193 | - | ||
194 | - } | ||
195 | -} | ... | ... |
... | @@ -11,8 +11,8 @@ import SwiftUI | ... | @@ -11,8 +11,8 @@ import SwiftUI |
11 | @available(iOS 13.0.0, *) | 11 | @available(iOS 13.0.0, *) |
12 | @objc public class GiftsViewInterface : NSObject { | 12 | @objc public class GiftsViewInterface : NSObject { |
13 | 13 | ||
14 | - @objc static public func giftsViewController() -> UIViewController { | 14 | + @objc(giftsViewController:) static public func giftsViewController(parentView: UIView?) -> UIViewController { |
15 | - return UIHostingController(rootView: GiftsView()) | 15 | + return UIHostingController(rootView: GiftsView(parentView: parentView!)) |
16 | } | 16 | } |
17 | 17 | ||
18 | } | 18 | } | ... | ... |
... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
16 | - (void) setToStage; | 16 | - (void) setToStage; |
17 | - (void) setLang:(NSString*) lang; | 17 | - (void) setLang:(NSString*) lang; |
18 | - (UIViewController *) openCoupons:(UIView*) parentView; | 18 | - (UIViewController *) openCoupons:(UIView*) parentView; |
19 | -- (UIViewController *) openGifts; | 19 | +- (UIViewController *) openGifts:(UIView*) parentView; |
20 | - (void) applicationDidEnterBackground:(UIApplication *)application; | 20 | - (void) applicationDidEnterBackground:(UIApplication *)application; |
21 | - (void) applicationWillEnterForeground:(UIApplication *)application; | 21 | - (void) applicationWillEnterForeground:(UIApplication *)application; |
22 | - (void) applicationDidBecomeActive:(UIApplication *)application; | 22 | - (void) applicationDidBecomeActive:(UIApplication *)application; | ... | ... |
... | @@ -52,12 +52,9 @@ NSString *LANG; | ... | @@ -52,12 +52,9 @@ NSString *LANG; |
52 | return couponsViewController; | 52 | return couponsViewController; |
53 | } | 53 | } |
54 | 54 | ||
55 | -- (UIViewController *) openGifts{ | 55 | +- (UIViewController *) openGifts:(UIView*) parentView{ |
56 | 56 | ||
57 | - UIViewController *giftsViewController = [GiftsViewInterface giftsViewController]; | 57 | + UIViewController *giftsViewController = [GiftsViewInterface giftsViewController:parentView]; |
58 | -// controller = [[UINavigationController alloc]initWithRootViewController:profileViewController]; | ||
59 | - | ||
60 | -// [window makeKeyAndVisible]; | ||
61 | return giftsViewController; | 58 | return giftsViewController; |
62 | } | 59 | } |
63 | 60 | ... | ... |
-
Please register or login to post a comment