Merge branch 'master' of https://git.warp.ly/open-source/warply_sdk_framework
Showing
3 changed files
with
36 additions
and
34 deletions
No preview for this file type
... | @@ -79,13 +79,14 @@ extension OldCouponsView { | ... | @@ -79,13 +79,14 @@ extension OldCouponsView { |
79 | } | 79 | } |
80 | 80 | ||
81 | struct couponItemView: View { | 81 | struct couponItemView: View { |
82 | - var item: NSDictionary | 82 | + var item: swiftApi.CouponItemModel |
83 | var parentView: UIView | 83 | var parentView: UIView |
84 | 84 | ||
85 | var uiscreen = UIScreen.main.bounds | 85 | var uiscreen = UIScreen.main.bounds |
86 | 86 | ||
87 | var body: some View { | 87 | var body: some View { |
88 | - let couponData = item["coupon_data"] as? [String: Any] ?? ["":""] | 88 | +// let couponData = item["coupon_data"] as? [String: Any] ?? ["":""] |
89 | + let couponSetData = item.couponset_data | ||
89 | 90 | ||
90 | Button { | 91 | Button { |
91 | // Coupon Action | 92 | // Coupon Action |
... | @@ -101,7 +102,7 @@ extension OldCouponsView { | ... | @@ -101,7 +102,7 @@ extension OldCouponsView { |
101 | 102 | ||
102 | HStack(alignment: .center) { | 103 | HStack(alignment: .center) { |
103 | 104 | ||
104 | - ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.15, isFill: false) | 105 | + ImageView(withURL: couponSetData?.img_preview ?? "", width: self.uiscreen.width * 0.15, isFill: false) |
105 | 106 | ||
106 | VLine() | 107 | VLine() |
107 | .stroke(style: StrokeStyle(lineWidth: 1, dash: [5])) | 108 | .stroke(style: StrokeStyle(lineWidth: 1, dash: [5])) |
... | @@ -110,7 +111,7 @@ extension OldCouponsView { | ... | @@ -110,7 +111,7 @@ extension OldCouponsView { |
110 | .padding(.leading, 10) | 111 | .padding(.leading, 10) |
111 | 112 | ||
112 | VStack(alignment: .leading, spacing: 5.0) { | 113 | VStack(alignment: .leading, spacing: 5.0) { |
113 | - Text(item["name"] as? String ?? "") | 114 | + Text(couponSetData?.name ?? "") |
114 | .fontWeight(.medium) | 115 | .fontWeight(.medium) |
115 | .font(.system(size: 16)) | 116 | .font(.system(size: 16)) |
116 | .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | 117 | .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) |
... | @@ -118,14 +119,14 @@ extension OldCouponsView { | ... | @@ -118,14 +119,14 @@ extension OldCouponsView { |
118 | // .lineLimit(1) | 119 | // .lineLimit(1) |
119 | 120 | ||
120 | HStack(alignment: .center) { | 121 | HStack(alignment: .center) { |
121 | - Text((couponData["discount"] as? String ?? "")+"€") | 122 | + Text((item.discount ?? "")+"€") |
122 | .fontWeight(.bold) | 123 | .fontWeight(.bold) |
123 | .font(.system(size: 35)) | 124 | .font(.system(size: 35)) |
124 | .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | 125 | .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) |
125 | .multilineTextAlignment(.leading) | 126 | .multilineTextAlignment(.leading) |
126 | .lineLimit(1) | 127 | .lineLimit(1) |
127 | 128 | ||
128 | -// Text(item["short_description"] as? String ?? "") | 129 | +// Text(couponSetData?.short_description ?? "") |
129 | // .fontWeight(.medium) | 130 | // .fontWeight(.medium) |
130 | // .font(.system(size: 11)) | 131 | // .font(.system(size: 11)) |
131 | // .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) | 132 | // .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) |
... | @@ -133,7 +134,7 @@ extension OldCouponsView { | ... | @@ -133,7 +134,7 @@ extension OldCouponsView { |
133 | // .lineLimit(3) | 134 | // .lineLimit(3) |
134 | } | 135 | } |
135 | 136 | ||
136 | - Text("Εξαργυρώθηκε την " + OldCouponsView.couponsContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? "")) | 137 | + Text("Εξαργυρώθηκε την " + (item.expiration ?? "")) |
137 | .fontWeight(.medium) | 138 | .fontWeight(.medium) |
138 | .font(.system(size: 11)) | 139 | .font(.system(size: 11)) |
139 | .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) | 140 | .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) |
... | @@ -169,22 +170,22 @@ extension OldCouponsView { | ... | @@ -169,22 +170,22 @@ extension OldCouponsView { |
169 | } | 170 | } |
170 | 171 | ||
171 | struct couponsContainer: View { | 172 | struct couponsContainer: View { |
172 | - @State var coupons:Array<NSDictionary> = [] | 173 | + @State var coupons:Array<swiftApi.CouponItemModel> = [] |
173 | @State var parentView:UIView | 174 | @State var parentView:UIView |
174 | 175 | ||
175 | var uiscreen = UIScreen.main.bounds | 176 | var uiscreen = UIScreen.main.bounds |
176 | 177 | ||
177 | - static func convertDateFormat(inputDate: String) -> String { | 178 | +// static func convertDateFormat(inputDate: String) -> String { |
178 | - let dateFormatter = DateFormatter() | 179 | +// let dateFormatter = DateFormatter() |
179 | - dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss" | 180 | +// dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss" |
180 | - if let date = dateFormatter.date(from: inputDate) { | 181 | +// if let date = dateFormatter.date(from: inputDate) { |
181 | - dateFormatter.dateFormat = "dd/MM/yyyy" | 182 | +// dateFormatter.dateFormat = "dd/MM/yyyy" |
182 | - let resultString = dateFormatter.string(from: date) | 183 | +// let resultString = dateFormatter.string(from: date) |
183 | - return resultString | 184 | +// return resultString |
184 | - } else { | 185 | +// } else { |
185 | - return "" | 186 | +// return "" |
186 | - } | 187 | +// } |
187 | - } | 188 | +// } |
188 | 189 | ||
189 | var body: some View { | 190 | var body: some View { |
190 | VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) { | 191 | VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) { |
... | @@ -206,10 +207,20 @@ extension OldCouponsView { | ... | @@ -206,10 +207,20 @@ extension OldCouponsView { |
206 | struct OldCouponsView: View { | 207 | struct OldCouponsView: View { |
207 | var parentView: UIView | 208 | var parentView: UIView |
208 | 209 | ||
209 | - var coupons:Array<NSDictionary> = DataModel().getOldCoupons | 210 | + var coupons:Array<swiftApi.CouponItemModel> = [] |
210 | 211 | ||
211 | var uiscreen = UIScreen.main.bounds | 212 | var uiscreen = UIScreen.main.bounds |
212 | 213 | ||
214 | + | ||
215 | + init(parentView: UIView) { //initializer method | ||
216 | + | ||
217 | + let instanceOfMySwiftApi = swiftApi() | ||
218 | + let couponsData = instanceOfMySwiftApi.getOldCoupons() | ||
219 | + | ||
220 | + self.coupons = couponsData | ||
221 | + self.parentView = parentView | ||
222 | + } | ||
223 | + | ||
213 | func goBack(){ | 224 | func goBack(){ |
214 | for subview in parentView.subviews { | 225 | for subview in parentView.subviews { |
215 | if(subview.tag == 9) { | 226 | if(subview.tag == 9) { | ... | ... |
... | @@ -6,7 +6,6 @@ | ... | @@ -6,7 +6,6 @@ |
6 | // | 6 | // |
7 | 7 | ||
8 | import Foundation | 8 | import Foundation |
9 | -import SwiftUI | ||
10 | 9 | ||
11 | public class swiftApi { | 10 | public class swiftApi { |
12 | 11 | ||
... | @@ -26,22 +25,10 @@ public class swiftApi { | ... | @@ -26,22 +25,10 @@ public class swiftApi { |
26 | 25 | ||
27 | } | 26 | } |
28 | 27 | ||
29 | - public func setCCMSLoyaltyCampaigns(campaigns: Array<LoyaltyContextualOfferModel>) { | 28 | + public func setCCMSLoyaltyCampaigns(campaigns: Array<Dictionary<String, String>>) { |
30 | 29 | ||
31 | } | 30 | } |
32 | 31 | ||
33 | - public class LoyaltyContextualOfferModel { | ||
34 | - var sessionId: String | ||
35 | - var eligibleAssets: Array<String> | ||
36 | - var id: String | ||
37 | - | ||
38 | - init(sessionId: String, eligibleAssets: Array<String>, id: String) { | ||
39 | - self.sessionId = sessionId | ||
40 | - self.eligibleAssets = eligibleAssets | ||
41 | - self.id = id | ||
42 | - } | ||
43 | - } | ||
44 | - | ||
45 | public class CouponSetItemModel { | 32 | public class CouponSetItemModel { |
46 | let uuid: String? | 33 | let uuid: String? |
47 | let admin_name: String? | 34 | let admin_name: String? |
... | @@ -271,6 +258,10 @@ public class swiftApi { | ... | @@ -271,6 +258,10 @@ public class swiftApi { |
271 | return CouponsDataModel().getData | 258 | return CouponsDataModel().getData |
272 | } | 259 | } |
273 | 260 | ||
261 | + public func getOldCoupons() -> Array<CouponItemModel> { | ||
262 | + return CouponsDataModel().getOldCoupons | ||
263 | + } | ||
264 | + | ||
274 | public class CampaignItemModel { | 265 | public class CampaignItemModel { |
275 | let index_url: String? | 266 | let index_url: String? |
276 | let logo_url: String? | 267 | let logo_url: String? | ... | ... |
-
Please register or login to post a comment