GiftsView.swift
7.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//
// GiftsView.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 18/4/22.
//
#if canImport(SwiftUI)
import SwiftUI
class CouponDataModel {
var data: Array<NSDictionary> = []
init() { //initializer method
let instanceOfMyApi = MyApi()
let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil)
let coupons = instanceOfMyApi.getCoupons() as AnyObject?
if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] {
let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! Array<NSMutableDictionary>)
if let myCouponsDictionary = coupons as? [String : AnyObject] {
let couponsData = (myCouponsDictionary["result"] as! Array<NSMutableDictionary>)
if let sets = couponSetsData as? NSArray {
for set in sets {
let s = set as! NSDictionary
if let cpns = couponsData as? NSArray {
for coupon in cpns {
var c = coupon as! NSDictionary
// var temp = NSMutableDictionary(dictionary: s);
if c["couponset_uuid"] as! String == s["uuid"] as! String {
var temp = NSMutableDictionary(dictionary: s);
temp.addEntries(from: c as! [AnyHashable : Any])
self.data.append(temp as NSDictionary)
}
}
}
}
}
}
}
}
var getData: Array<NSDictionary> {
get { // getter
return data
}
}
}
class CampaignDataModel {
var data: Array<NSDictionary> = []
init() { //initializer method
let instanceOfMyApi = MyApi()
let products = instanceOfMyApi.getInbox()
print("======== Inbox print =========")
print(products?[0])
print("======== Inbox dump =========")
dump(products?[0])
print("======== Inbox =========")
// let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil)
// let coupons = instanceOfMyApi.getCoupons() as AnyObject?
// if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] {
// let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! Array<NSMutableDictionary>)
// if let myCouponsDictionary = coupons as? [String : AnyObject] {
// let couponsData = (myCouponsDictionary["result"] as! Array<NSMutableDictionary>)
// if let sets = couponSetsData as? NSArray {
// for set in sets {
// let s = set as! NSDictionary
// if let cpns = couponsData as? NSArray {
// for coupon in cpns {
// var c = coupon as! NSDictionary
// // var temp = NSMutableDictionary(dictionary: s);
// if c["couponset_uuid"] as! String == s["uuid"] as! String {
// var temp = NSMutableDictionary(dictionary: s);
// temp.addEntries(from: c as! [AnyHashable : Any])
// self.data.append(temp as NSDictionary)
// }
// }
// }
// }
// }
// }
// }
}
var getData: Array<NSDictionary> {
get { // getter
return data
}
}
}
extension GiftsView {
struct headerView: View {
var uiscreen = UIScreen.main.bounds
var body: some View {
ZStack {
Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
.offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.07)
Text("Όλα τα κουπόνια μου")
.frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
.offset( y: self.uiscreen.height * 0.07)
.frame(width: self.uiscreen.width)
}
}
}
struct giftView: View {
// @Binding var result: NSDictionary
var uiscreen = UIScreen.main.bounds
var body: some View {
ZStack {
// URLImage(url: URL(string: result["img_preview"] as! String? ?? ""))
// .resizable()
// .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04)
// .cornerRadius(CGFloat(self.uiscreen.height * 0.02))
// .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07)
}
// .background(
// Image("coupons_container", bundle: Bundle(for: MyEmptyClass.self))
// .resizable()
//// .edgesIgnoringSafeArea(.all)
// .frame(width: UIScreen.main.bounds.width * 0.8, height: UIScreen.main.bounds.height * 0.17)
// )
}
}
}
@available(iOS 13.0.0, *)
struct GiftsView: View {
var data:Array<NSDictionary> = CouponDataModel().getData
var campains:Any = CampaignDataModel()
var uiscreen = UIScreen.main.bounds
var body: some View {
VStack {
headerView()
// ScrollView {
// VStack {
// if (data.count) > 0 {
// ForEach(data, id: \.self) { result in
// couponView(result: result)
// }
// }
// }
// .frame(width:self.uiscreen.width, height:self.uiscreen.height )
// }
}
}
}
#endif
//struct ProfileView_Previews: PreviewProvider {
// static var previews: some View {
// ProfileView()
// }
//}
@available(iOS 13.0.0, *)
struct Previews_GiftsView_Previews: PreviewProvider {
static var uiscreen = UIScreen.main.bounds
static var previews: some View {
ZStack {
Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
.offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.07)
Text("Όλα τα κουπόνια μου")
.frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
.offset( y: self.uiscreen.height * 0.07)
}
}
}