Manos Chorianopoulos

add OldCouponsView

...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
11 1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */; }; 11 1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */; };
12 1E735FF2281067320050A298 /* CampaignWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF1281067320050A298 /* CampaignWebview.swift */; }; 12 1E735FF2281067320050A298 /* CampaignWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF1281067320050A298 /* CampaignWebview.swift */; };
13 1E735FF42810681E0050A298 /* CampaignWebviewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */; }; 13 1E735FF42810681E0050A298 /* CampaignWebviewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */; };
14 + 1E879E25281AC96A0089F489 /* OldCouponsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E24281AC96A0089F489 /* OldCouponsView.swift */; };
15 + 1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */; };
14 1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; }; 16 1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; };
15 1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */; }; 17 1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */; };
16 1EBEB02D280D69D800BF802C /* GiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02C280D69D800BF802C /* GiftsView.swift */; }; 18 1EBEB02D280D69D800BF802C /* GiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02C280D69D800BF802C /* GiftsView.swift */; };
...@@ -149,6 +151,8 @@ ...@@ -149,6 +151,8 @@
149 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewInterface.swift; sourceTree = "<group>"; }; 151 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewInterface.swift; sourceTree = "<group>"; };
150 1E735FF1281067320050A298 /* CampaignWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebview.swift; sourceTree = "<group>"; }; 152 1E735FF1281067320050A298 /* CampaignWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebview.swift; sourceTree = "<group>"; };
151 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebviewInterface.swift; sourceTree = "<group>"; }; 153 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebviewInterface.swift; sourceTree = "<group>"; };
154 + 1E879E24281AC96A0089F489 /* OldCouponsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsView.swift; sourceTree = "<group>"; };
155 + 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsViewInterface.swift; sourceTree = "<group>"; };
152 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsView.swift; sourceTree = "<group>"; }; 156 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsView.swift; sourceTree = "<group>"; };
153 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsViewInterface.swift; sourceTree = "<group>"; }; 157 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsViewInterface.swift; sourceTree = "<group>"; };
154 1EBEB02C280D69D800BF802C /* GiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsView.swift; sourceTree = "<group>"; }; 158 1EBEB02C280D69D800BF802C /* GiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsView.swift; sourceTree = "<group>"; };
...@@ -346,6 +350,8 @@ ...@@ -346,6 +350,8 @@
346 E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */, 350 E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */,
347 1EBEB02C280D69D800BF802C /* GiftsView.swift */, 351 1EBEB02C280D69D800BF802C /* GiftsView.swift */,
348 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */, 352 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */,
353 + 1E879E24281AC96A0089F489 /* OldCouponsView.swift */,
354 + 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */,
349 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */, 355 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */,
350 1E735FF1281067320050A298 /* CampaignWebview.swift */, 356 1E735FF1281067320050A298 /* CampaignWebview.swift */,
351 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */, 357 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */,
...@@ -753,6 +759,7 @@ ...@@ -753,6 +759,7 @@
753 isa = PBXSourcesBuildPhase; 759 isa = PBXSourcesBuildPhase;
754 buildActionMask = 2147483647; 760 buildActionMask = 2147483647;
755 files = ( 761 files = (
762 + 1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */,
756 E6D8DF0B27A942920006A3A9 /* WLEvent.m in Sources */, 763 E6D8DF0B27A942920006A3A9 /* WLEvent.m in Sources */,
757 E6D8DF1E27A942920006A3A9 /* UIViewController+WLAdditions.m in Sources */, 764 E6D8DF1E27A942920006A3A9 /* UIViewController+WLAdditions.m in Sources */,
758 E6D8DF2E27A942920006A3A9 /* UIRefreshControl+AFNetworking.m in Sources */, 765 E6D8DF2E27A942920006A3A9 /* UIRefreshControl+AFNetworking.m in Sources */,
...@@ -781,6 +788,7 @@ ...@@ -781,6 +788,7 @@
781 E6D8DF1327A942920006A3A9 /* WLBeaconManager.m in Sources */, 788 E6D8DF1327A942920006A3A9 /* WLBeaconManager.m in Sources */,
782 E6D8DF0427A942920006A3A9 /* WLInboxItem.m in Sources */, 789 E6D8DF0427A942920006A3A9 /* WLInboxItem.m in Sources */,
783 E6D8DF5127A942920006A3A9 /* FMDatabaseAdditions.m in Sources */, 790 E6D8DF5127A942920006A3A9 /* FMDatabaseAdditions.m in Sources */,
791 + 1E879E25281AC96A0089F489 /* OldCouponsView.swift in Sources */,
784 E6D8DF2127A942920006A3A9 /* WLAPPActionHandler.m in Sources */, 792 E6D8DF2127A942920006A3A9 /* WLAPPActionHandler.m in Sources */,
785 E6D8DF5627A942920006A3A9 /* FMDatabasePool.m in Sources */, 793 E6D8DF5627A942920006A3A9 /* FMDatabasePool.m in Sources */,
786 E6D8DF4527A942920006A3A9 /* AFHTTPSessionManager.m in Sources */, 794 E6D8DF4527A942920006A3A9 /* AFHTTPSessionManager.m in Sources */,
......
...@@ -56,6 +56,15 @@ class DataModel { ...@@ -56,6 +56,15 @@ class DataModel {
56 }) 56 })
57 } 57 }
58 } 58 }
59 +
60 + var getOldCoupons: Array<NSDictionary> {
61 + get { // getter
62 + return data.filter({
63 + let couponData = $0["coupon_data"] as? [String: Any] ?? ["":""]
64 + return couponData["status"] as? Int != 1
65 + })
66 + }
67 + }
59 } 68 }
60 69
61 class ImageLoader: ObservableObject { 70 class ImageLoader: ObservableObject {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
22 - (UIViewController *) openCouponBarcode:(UIView*) parentView coupon:(NSDictionary*) coupon; 22 - (UIViewController *) openCouponBarcode:(UIView*) parentView coupon:(NSDictionary*) coupon;
23 - (UIViewController *) openGifts:(UIView*) parentView; 23 - (UIViewController *) openGifts:(UIView*) parentView;
24 - (UIViewController *) openAllGifts:(UIView*) parentView; 24 - (UIViewController *) openAllGifts:(UIView*) parentView;
25 +- (UIViewController *) openOldCoupons:(UIView*) parentView;
25 - (UIViewController *) openWallet:(UIView*) parentView; 26 - (UIViewController *) openWallet:(UIView*) parentView;
26 - (UIViewController *) openMoreForYou:(UIView*) parentView; 27 - (UIViewController *) openMoreForYou:(UIView*) parentView;
27 - (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign; 28 - (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign;
......
...@@ -77,6 +77,12 @@ NSString *LANG; ...@@ -77,6 +77,12 @@ NSString *LANG;
77 return allGiftsViewController; 77 return allGiftsViewController;
78 } 78 }
79 79
80 +- (UIViewController *) openOldCoupons:(UIView*) parentView{
81 +
82 + UIViewController *oldCouponsViewController = [OldCouponsViewInterface oldCouponsViewController:parentView];
83 + return oldCouponsViewController;
84 +}
85 +
80 - (UIViewController *) openWallet:(UIView*) parentView{ 86 - (UIViewController *) openWallet:(UIView*) parentView{
81 87
82 UIViewController *wallletViewController = [WalletViewInterface walletViewController:parentView]; 88 UIViewController *wallletViewController = [WalletViewInterface walletViewController:parentView];
......
1 +//
2 +// OldCouponsView.swift
3 +// WarplySDKFrameworkIOS
4 +//
5 +// Created by Manos Chorianopoulos on 28/4/22.
6 +//
7 +
8 +#if canImport(SwiftUI)
9 +import SwiftUI
10 +import Combine
11 +import Foundation
12 +import UIKit
13 +
14 +
15 +extension OldCouponsView {
16 + struct headerView: View {
17 + var goBack: () -> ()
18 +
19 + var uiscreen = UIScreen.main.bounds
20 +
21 + var body: some View {
22 + HStack(alignment: .center) {
23 + Button {
24 + // Button Action
25 + print("Back Button tapped!")
26 + goBack()
27 + } label: {
28 + Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
29 + .resizable()
30 + .aspectRatio(contentMode: .fit)
31 + .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
32 + }
33 +
34 + Text("Παλαιότερα κουπόνια")
35 + .fontWeight(.medium)
36 + .font(.system(size: 16))
37 + .foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196))
38 + .multilineTextAlignment(.center)
39 + .frame(maxWidth: .infinity)
40 + .padding(.horizontal)
41 +
42 + Button {
43 + // Button Action
44 + print("Wallet tapped!")
45 + } label: {
46 + Image("ic_wallet", bundle: Bundle(for: MyEmptyClass.self))
47 + .resizable()
48 + .aspectRatio(contentMode: .fit)
49 + .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04)
50 + }
51 + }
52 + .frame(maxWidth: .infinity)
53 + .padding(.horizontal)
54 + .padding(.vertical, 10)
55 + }
56 + }
57 +
58 + struct ImageView: View {
59 + @ObservedObject var imageLoader:UrlImageModel
60 + @State var width:CGFloat
61 + @State var isFill:Bool
62 +
63 + var uiscreen = UIScreen.main.bounds
64 +
65 + init(withURL url:String , width:CGFloat, isFill:Bool) {
66 + imageLoader = UrlImageModel(urlString:url)
67 + self.width = width
68 + self.isFill = isFill
69 + }
70 +
71 + var body: some View {
72 +
73 + Image(uiImage: imageLoader.image ?? UIImage())
74 + .resizable()
75 + .aspectRatio(contentMode: isFill ? .fill : .fit)
76 + .frame(width: self.width)
77 + .frame(maxHeight: .infinity)
78 + }
79 + }
80 +
81 + struct couponItemView: View {
82 + var item: NSDictionary
83 + var parentView: UIView
84 +
85 + var uiscreen = UIScreen.main.bounds
86 +
87 + var body: some View {
88 + let couponData = item["coupon_data"] as? [String: Any] ?? ["":""]
89 +
90 + Button {
91 + // Coupon Action
92 + print("Coupon tapped!")
93 +// let instanceOfMyApi = MyApi()
94 +// let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: item as! [String : Any])!
95 +// couponBarcodeViewController.view.tag = 7
96 +//// addChild(couponsViewController)
97 +// couponBarcodeViewController.view.frame = parentView.frame
98 +// parentView.addSubview(couponBarcodeViewController.view)
99 +// couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self))
100 + } label: {
101 +
102 + HStack(alignment: .center) {
103 +
104 + ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.15, isFill: false)
105 +
106 + VLine()
107 + .stroke(style: StrokeStyle(lineWidth: 1, dash: [5]))
108 + .foregroundColor(Color(red: 0.4392156862745098, green: 0.4392156862745098, blue: 0.4392156862745098))
109 + .frame(width: 1)
110 + .padding(.leading, 10)
111 +
112 + VStack(alignment: .leading, spacing: 5.0) {
113 + Text(item["name"] as? String ?? "")
114 + .fontWeight(.medium)
115 + .font(.system(size: 16))
116 + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
117 + .multilineTextAlignment(.leading)
118 +// .lineLimit(1)
119 +
120 + HStack(alignment: .center) {
121 + Text((couponData["discount"] as? String ?? "")+"€")
122 + .fontWeight(.bold)
123 + .font(.system(size: 35))
124 + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
125 + .multilineTextAlignment(.leading)
126 + .lineLimit(1)
127 +
128 +// Text(item["short_description"] as? String ?? "")
129 +// .fontWeight(.medium)
130 +// .font(.system(size: 11))
131 +// .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
132 +// .multilineTextAlignment(.leading)
133 +// .lineLimit(3)
134 + }
135 +
136 + Text("Εξαργυρώθηκε την " + OldCouponsView.couponsContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? ""))
137 + .fontWeight(.medium)
138 + .font(.system(size: 11))
139 + .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
140 + .multilineTextAlignment(.leading)
141 + }
142 + .padding(.all, 10)
143 +
144 + Spacer()
145 +
146 + }
147 + .padding(.leading, 28)
148 + .padding(.trailing)
149 + }
150 + .frame(width: self.uiscreen.width * 0.9, height: self.uiscreen.height * 0.14)
151 +// .cornerRadius(5)
152 +// .shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 30, x: 0, y: 3)
153 + .background(
154 + Image("coupon_bg", bundle: Bundle(for: MyEmptyClass.self))
155 + .resizable(resizingMode: .stretch)
156 + .frame(maxWidth: .infinity, maxHeight: .infinity)
157 + .colorMultiply(Color(red: 0.8901960784313725, green: 0.8901960784313725, blue: 0.8901960784313725))
158 + )
159 + }
160 + }
161 +
162 + struct VLine: Shape {
163 + func path(in rect: CGRect) -> Path {
164 + Path { path in
165 + path.move(to: CGPoint(x: rect.midX, y: rect.minY))
166 + path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY))
167 + }
168 + }
169 + }
170 +
171 + struct couponsContainer: View {
172 + @State var coupons:Array<NSDictionary> = []
173 + @State var parentView:UIView
174 +
175 + var uiscreen = UIScreen.main.bounds
176 +
177 + static func convertDateFormat(inputDate: String) -> String {
178 + let dateFormatter = DateFormatter()
179 + dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
180 + if let date = dateFormatter.date(from: inputDate) {
181 + dateFormatter.dateFormat = "dd/MM/yyyy"
182 + let resultString = dateFormatter.string(from: date)
183 + return resultString
184 + } else {
185 + return ""
186 + }
187 + }
188 +
189 + var body: some View {
190 + VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) {
191 +
192 + ForEach(Array(coupons.enumerated()), id: \.offset) { index, item in
193 +
194 + couponItemView(item: item, parentView: parentView)
195 + }
196 + }
197 + .frame(maxWidth: .infinity)
198 + .padding(.top, self.uiscreen.height * 0.05)
199 + .padding(.bottom, self.uiscreen.height * 0.1)
200 + }
201 + }
202 +
203 +}
204 +
205 +@available(iOS 13.0.0, *)
206 +struct OldCouponsView: View {
207 + var parentView: UIView
208 +
209 + var coupons:Array<NSDictionary> = DataModel().getOldCoupons
210 +
211 + var uiscreen = UIScreen.main.bounds
212 +
213 + func goBack(){
214 + for subview in parentView.subviews {
215 + if(subview.tag == 9) {
216 + subview.removeFromSuperview()
217 + }
218 + }
219 + }
220 +
221 + var body: some View {
222 + VStack {
223 + headerView(goBack: goBack)
224 +
225 + VStack {
226 + ScrollView(showsIndicators: false) {
227 + VStack {
228 +
229 + if (coupons.count) > 0 {
230 + couponsContainer(coupons: coupons, parentView: parentView )
231 + }
232 +
233 + }
234 + .frame(width:self.uiscreen.width)
235 + }
236 + .cornerRadius(30, corners: [.topLeft])
237 + .frame(width:self.uiscreen.width)
238 + .frame(maxHeight: .infinity)
239 + }
240 + .frame(width:self.uiscreen.width)
241 + .frame(maxHeight: .infinity)
242 + .padding(.top, 5)
243 + .background(
244 + Image("coupons_scrollview", bundle: Bundle(for: MyEmptyClass.self))
245 + .resizable()
246 + )
247 +
248 + }
249 + .edgesIgnoringSafeArea([.bottom])
250 + .frame(width:self.uiscreen.width)
251 + .frame(maxHeight: .infinity)
252 + }
253 +}
254 +#endif
255 +
256 +//struct OldCouponsView_Previews: PreviewProvider {
257 +// static var previews: some View {
258 +// OldCouponsView()
259 +// }
260 +//}
1 +//
2 +// OldCouponsViewInterface.swift
3 +// WarplySDKFrameworkIOS
4 +//
5 +// Created by Manos Chorianopoulos on 28/4/22.
6 +//
7 +
8 +
9 +import Foundation
10 +import SwiftUI
11 +
12 +@available(iOS 13.0.0, *)
13 +@objc public class OldCouponsViewInterface : NSObject {
14 +
15 + @objc(oldCouponsViewController:) static public func oldCouponsViewController(parentView: UIView?) -> UIViewController {
16 + return UIHostingController(rootView: OldCouponsView(parentView: parentView!))
17 + }
18 +
19 +}