Vasilis
...@@ -5,4 +5,191 @@ ...@@ -5,4 +5,191 @@
5 // Created by Manos Chorianopoulos on 18/4/22. 5 // Created by Manos Chorianopoulos on 18/4/22.
6 // 6 //
7 7
8 -import Foundation 8 +
9 +#if canImport(SwiftUI)
10 +import SwiftUI
11 +
12 +class CouponDataModel {
13 + var data: Array<NSDictionary> = []
14 +
15 + init() { //initializer method
16 + let instanceOfMyApi = MyApi()
17 + let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil)
18 + let coupons = instanceOfMyApi.getCoupons() as AnyObject?
19 +
20 + if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] {
21 + let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! Array<NSMutableDictionary>)
22 + if let myCouponsDictionary = coupons as? [String : AnyObject] {
23 + let couponsData = (myCouponsDictionary["result"] as! Array<NSMutableDictionary>)
24 + if let sets = couponSetsData as? NSArray {
25 + for set in sets {
26 + let s = set as! NSDictionary
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 + }
44 + }
45 + }
46 +
47 + var getData: Array<NSDictionary> {
48 + get { // getter
49 + return data
50 + }
51 + }
52 +}
53 +
54 +class CampaignDataModel {
55 + var data: Array<NSDictionary> = []
56 +
57 + init() { //initializer method
58 + let instanceOfMyApi = MyApi()
59 + let products = instanceOfMyApi.getInbox()
60 +
61 + print("======== Inbox print =========")
62 + print(products?[0])
63 + print("======== Inbox dump =========")
64 + dump(products?[0])
65 + print("======== Inbox =========")
66 +
67 +
68 + // let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil)
69 + // let coupons = instanceOfMyApi.getCoupons() as AnyObject?
70 +
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 + }
97 +
98 + var getData: Array<NSDictionary> {
99 + get { // getter
100 + return data
101 + }
102 + }
103 +}
104 +
105 +extension GiftsView {
106 + struct headerView: View {
107 +
108 + var uiscreen = UIScreen.main.bounds
109 +
110 + var body: some View {
111 + ZStack {
112 + Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
113 + .resizable()
114 + .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
115 + .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.07)
116 + Text("Όλα τα κουπόνια μου")
117 + .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
118 + .offset( y: self.uiscreen.height * 0.07)
119 + .frame(width: self.uiscreen.width)
120 + }
121 + }
122 + }
123 +
124 + struct giftView: View {
125 +// @Binding var result: NSDictionary
126 +
127 + var uiscreen = UIScreen.main.bounds
128 +
129 + var body: some View {
130 + ZStack {
131 +// URLImage(url: URL(string: result["img_preview"] as! String? ?? ""))
132 +// .resizable()
133 +// .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04)
134 +// .cornerRadius(CGFloat(self.uiscreen.height * 0.02))
135 +// .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07)
136 +
137 + }
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 + }
145 + }
146 +
147 +}
148 +
149 +@available(iOS 13.0.0, *)
150 +struct GiftsView: View {
151 +
152 + var data:Array<NSDictionary> = CouponDataModel().getData
153 + var campains:Any = CampaignDataModel()
154 +
155 + var uiscreen = UIScreen.main.bounds
156 +
157 + var body: some View {
158 + VStack {
159 + headerView()
160 +// ScrollView {
161 +// VStack {
162 +// if (data.count) > 0 {
163 +// ForEach(data, id: \.self) { result in
164 +// couponView(result: result)
165 +// }
166 +// }
167 +// }
168 +// .frame(width:self.uiscreen.width, height:self.uiscreen.height )
169 +// }
170 + }
171 + }
172 +}
173 +#endif
174 +//struct ProfileView_Previews: PreviewProvider {
175 +// static var previews: some View {
176 +// ProfileView()
177 +// }
178 +//}
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 +}
......
...@@ -6,3 +6,13 @@ ...@@ -6,3 +6,13 @@
6 // 6 //
7 7
8 import Foundation 8 import Foundation
9 +import SwiftUI
10 +
11 +@available(iOS 13.0.0, *)
12 +@objc public class GiftsViewInterface : NSObject {
13 +
14 + @objc static public func giftsViewController() -> UIViewController {
15 + return UIHostingController(rootView: GiftsView())
16 + }
17 +
18 +}
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +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 - (void) applicationDidEnterBackground:(UIApplication *)application; 20 - (void) applicationDidEnterBackground:(UIApplication *)application;
20 - (void) applicationWillEnterForeground:(UIApplication *)application; 21 - (void) applicationWillEnterForeground:(UIApplication *)application;
21 - (void) applicationDidBecomeActive:(UIApplication *)application; 22 - (void) applicationDidBecomeActive:(UIApplication *)application;
......
...@@ -51,6 +51,15 @@ NSString *LANG; ...@@ -51,6 +51,15 @@ NSString *LANG;
51 return couponsViewController; 51 return couponsViewController;
52 } 52 }
53 53
54 +- (UIViewController *) openGifts{
55 +
56 + UIViewController *giftsViewController = [GiftsViewInterface giftsViewController];
57 +// controller = [[UINavigationController alloc]initWithRootViewController:profileViewController];
58 +
59 +// [window makeKeyAndVisible];
60 + return giftsViewController;
61 +}
62 +
54 //- (UIViewController *) openCoupons { 63 //- (UIViewController *) openCoupons {
55 //// NSString* const frameworkBundleID = @"framework.warp.ly.WarplySDKFrameworkIOS"; 64 //// NSString* const frameworkBundleID = @"framework.warp.ly.WarplySDKFrameworkIOS";
56 //// NSBundle* bundle = [NSBundle bundleWithIdentifier:frameworkBundleID]; 65 //// NSBundle* bundle = [NSBundle bundleWithIdentifier:frameworkBundleID];
......