Merge branch 'master' of https://git.warp.ly/open-source/warply_sdk_framework
Showing
5 changed files
with
28 additions
and
19 deletions
No preview for this file type
| ... | @@ -77,7 +77,7 @@ extension CouponBarcodeView { | ... | @@ -77,7 +77,7 @@ extension CouponBarcodeView { | 
| 77 | } | 77 | } | 
| 78 | 78 | ||
| 79 | struct couponContainer: View { | 79 | struct couponContainer: View { | 
| 80 | - @State var coupon: Dictionary<String, Any> | 80 | + @State var coupon: swiftApi.CouponItemModel | 
| 81 | // @State var couponset:CouponSetItemModel | 81 | // @State var couponset:CouponSetItemModel | 
| 82 | 82 | ||
| 83 | var uiscreen = UIScreen.main.bounds | 83 | var uiscreen = UIScreen.main.bounds | 
| ... | @@ -98,8 +98,8 @@ extension CouponBarcodeView { | ... | @@ -98,8 +98,8 @@ extension CouponBarcodeView { | 
| 98 | 98 | ||
| 99 | func constructBarcode() -> String? { | 99 | func constructBarcode() -> String? { | 
| 100 | // EAN 13 barcode construction | 100 | // EAN 13 barcode construction | 
| 101 | - let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""] | 101 | + let couponData = coupon.couponset_data | 
| 102 | - let couponString = couponData["coupon"] as? String ?? "" | 102 | + let couponString = coupon.coupon ?? "" | 
| 103 | 103 | ||
| 104 | if (!couponString.isEmpty) { | 104 | if (!couponString.isEmpty) { | 
| 105 | var checkDigit = 0; | 105 | var checkDigit = 0; | 
| ... | @@ -132,17 +132,17 @@ extension CouponBarcodeView { | ... | @@ -132,17 +132,17 @@ extension CouponBarcodeView { | 
| 132 | 132 | ||
| 133 | 133 | ||
| 134 | var body: some View { | 134 | var body: some View { | 
| 135 | - let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""] | 135 | + let couponData = coupon.couponset_data | 
| 136 | let barcodeString = constructBarcode() ?? "" | 136 | let barcodeString = constructBarcode() ?? "" | 
| 137 | 137 | ||
| 138 | GeometryReader { geometry in | 138 | GeometryReader { geometry in | 
| 139 | ScrollView(showsIndicators: false) { | 139 | ScrollView(showsIndicators: false) { | 
| 140 | VStack(alignment: .leading) { | 140 | VStack(alignment: .leading) { | 
| 141 | 141 | ||
| 142 | - ImageView(withURL: coupon["img_preview"] as? String ?? "") | 142 | + ImageView(withURL: couponData?.img_preview ?? "") | 
| 143 | 143 | ||
| 144 | VStack(alignment: .leading) { | 144 | VStack(alignment: .leading) { | 
| 145 | - Text(coupon["name"] as? String ?? "") | 145 | + Text(coupon.name!) | 
| 146 | .fontWeight(.bold) | 146 | .fontWeight(.bold) | 
| 147 | .font(.system(size: 16)) | 147 | .font(.system(size: 16)) | 
| 148 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 148 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 
| ... | @@ -151,7 +151,7 @@ extension CouponBarcodeView { | ... | @@ -151,7 +151,7 @@ extension CouponBarcodeView { | 
| 151 | .padding(.top, self.uiscreen.height * 0.04) | 151 | .padding(.top, self.uiscreen.height * 0.04) | 
| 152 | .frame(maxHeight: .infinity) | 152 | .frame(maxHeight: .infinity) | 
| 153 | 153 | ||
| 154 | - Text(coupon["short_description"] as? String ?? "") | 154 | + Text(couponData?.short_description! ?? "") | 
| 155 | .fontWeight(.regular) | 155 | .fontWeight(.regular) | 
| 156 | .font(.system(size: 14)) | 156 | .font(.system(size: 14)) | 
| 157 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 157 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 
| ... | @@ -170,7 +170,7 @@ extension CouponBarcodeView { | ... | @@ -170,7 +170,7 @@ extension CouponBarcodeView { | 
| 170 | 170 | ||
| 171 | VStack(alignment: .center) { | 171 | VStack(alignment: .center) { | 
| 172 | VStack { | 172 | VStack { | 
| 173 | - Text(couponData["coupon"] as? String ?? "") | 173 | + Text(coupon.coupon!) | 
| 174 | .fontWeight(.bold) | 174 | .fontWeight(.bold) | 
| 175 | .font(.system(size: 27)) | 175 | .font(.system(size: 27)) | 
| 176 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 176 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 
| ... | @@ -185,7 +185,7 @@ extension CouponBarcodeView { | ... | @@ -185,7 +185,7 @@ extension CouponBarcodeView { | 
| 185 | } | 185 | } | 
| 186 | .frame(maxWidth: .infinity) | 186 | .frame(maxWidth: .infinity) | 
| 187 | 187 | ||
| 188 | - if (CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: couponData["coupon"] as? String ?? ""))) { | 188 | + if (CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: coupon.coupon ?? ""))) { | 
| 189 | VStack(alignment: .center) { | 189 | VStack(alignment: .center) { | 
| 190 | VStack {} | 190 | VStack {} | 
| 191 | .frame(height: 1) | 191 | .frame(height: 1) | 
| ... | @@ -233,7 +233,7 @@ extension CouponBarcodeView { | ... | @@ -233,7 +233,7 @@ extension CouponBarcodeView { | 
| 233 | 233 | ||
| 234 | 234 | ||
| 235 | 235 | ||
| 236 | - Text("Το κουπόνι ισχύει έως " + CouponBarcodeView.couponContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? "")) | 236 | + Text("Το κουπόνι ισχύει έως " + CouponBarcodeView.couponContainer.convertDateFormat(inputDate: couponData?.expiration ?? "")) | 
| 237 | .fontWeight(.medium) | 237 | .fontWeight(.medium) | 
| 238 | .font(.system(size: 14)) | 238 | .font(.system(size: 14)) | 
| 239 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 239 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 
| ... | @@ -348,7 +348,7 @@ extension CouponBarcodeView { | ... | @@ -348,7 +348,7 @@ extension CouponBarcodeView { | 
| 348 | @available(iOS 13.0.0, *) | 348 | @available(iOS 13.0.0, *) | 
| 349 | struct CouponBarcodeView: View { | 349 | struct CouponBarcodeView: View { | 
| 350 | var parentView: UIView | 350 | var parentView: UIView | 
| 351 | - var coupon: Dictionary<String, Any> | 351 | + var coupon: swiftApi.CouponItemModel | 
| 352 | @State var couponset: CouponSetItemModel? | 352 | @State var couponset: CouponSetItemModel? | 
| 353 | 353 | ||
| 354 | var uiscreen = UIScreen.main.bounds | 354 | var uiscreen = UIScreen.main.bounds | ... | ... | 
| ... | @@ -48,7 +48,7 @@ extension CouponView { | ... | @@ -48,7 +48,7 @@ extension CouponView { | 
| 48 | } | 48 | } | 
| 49 | 49 | ||
| 50 | struct couponContainer: View { | 50 | struct couponContainer: View { | 
| 51 | - @State var coupon: Dictionary<String, Any> | 51 | + @State var coupon: swiftApi.CouponSetItemModel | 
| 52 | // @State var couponset:CouponSetItemModel | 52 | // @State var couponset:CouponSetItemModel | 
| 53 | 53 | ||
| 54 | var uiscreen = UIScreen.main.bounds | 54 | var uiscreen = UIScreen.main.bounds | 
| ... | @@ -58,9 +58,9 @@ extension CouponView { | ... | @@ -58,9 +58,9 @@ extension CouponView { | 
| 58 | ScrollView(showsIndicators: false) { | 58 | ScrollView(showsIndicators: false) { | 
| 59 | VStack(alignment: .leading) { | 59 | VStack(alignment: .leading) { | 
| 60 | 60 | ||
| 61 | - ImageView(withURL: coupon["img_preview"] as? String ?? "") | 61 | + ImageView(withURL: coupon.img_preview as? String ?? "") | 
| 62 | 62 | ||
| 63 | - Text(coupon["name"] as? String ?? "") | 63 | + Text(coupon.name as? String ?? "") | 
| 64 | .fontWeight(.bold) | 64 | .fontWeight(.bold) | 
| 65 | .font(.system(size: 16)) | 65 | .font(.system(size: 16)) | 
| 66 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 66 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 
| ... | @@ -68,7 +68,7 @@ extension CouponView { | ... | @@ -68,7 +68,7 @@ extension CouponView { | 
| 68 | .padding(.horizontal) | 68 | .padding(.horizontal) | 
| 69 | .padding(.top, self.uiscreen.height * 0.04) | 69 | .padding(.top, self.uiscreen.height * 0.04) | 
| 70 | 70 | ||
| 71 | - Text(coupon["short_description"] as? String ?? "") | 71 | + Text(coupon.short_description as? String ?? "") | 
| 72 | .fontWeight(.regular) | 72 | .fontWeight(.regular) | 
| 73 | .font(.system(size: 14)) | 73 | .font(.system(size: 14)) | 
| 74 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 74 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 
| ... | @@ -152,7 +152,7 @@ extension CouponView { | ... | @@ -152,7 +152,7 @@ extension CouponView { | 
| 152 | @available(iOS 13.0.0, *) | 152 | @available(iOS 13.0.0, *) | 
| 153 | struct CouponView: View { | 153 | struct CouponView: View { | 
| 154 | var parentView: UIView | 154 | var parentView: UIView | 
| 155 | - var coupon: Dictionary<String, Any> | 155 | + var coupon: swiftApi.CouponSetItemModel | 
| 156 | @State var couponset: CouponSetItemModel? | 156 | @State var couponset: CouponSetItemModel? | 
| 157 | 157 | ||
| 158 | var uiscreen = UIScreen.main.bounds | 158 | var uiscreen = UIScreen.main.bounds | ... | ... | 
| ... | @@ -187,13 +187,13 @@ extension CouponsView { | ... | @@ -187,13 +187,13 @@ extension CouponsView { | 
| 187 | VStack(alignment: .leading) { | 187 | VStack(alignment: .leading) { | 
| 188 | Button { | 188 | Button { | 
| 189 | // GiftItem Action | 189 | // GiftItem Action | 
| 190 | - let instanceOfMyApi = MyApi() | 190 | + let instanceOfMySwiftApi = swiftApi() | 
| 191 | - let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: result as! [String : Any])! | 191 | + let couponBarcodeViewController = instanceOfMySwiftApi.openCouponBarcode(parent: parentView, coupon: result) | 
| 192 | couponBarcodeViewController.view.tag = 7 | 192 | couponBarcodeViewController.view.tag = 7 | 
| 193 | // addChild(couponsViewController) | 193 | // addChild(couponsViewController) | 
| 194 | couponBarcodeViewController.view.frame = parentView.frame | 194 | couponBarcodeViewController.view.frame = parentView.frame | 
| 195 | parentView.addSubview(couponBarcodeViewController.view) | 195 | parentView.addSubview(couponBarcodeViewController.view) | 
| 196 | - couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self)) | 196 | +// couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self)) | 
| 197 | } label: { | 197 | } label: { | 
| 198 | HStack(alignment: .center) { | 198 | HStack(alignment: .center) { | 
| 199 | ImageView(withURL: couponSetData?.img_preview ?? "") | 199 | ImageView(withURL: couponSetData?.img_preview ?? "") | ... | ... | 
| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ | 
| 6 | // | 6 | // | 
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation | 
| 9 | +import SwiftUI | ||
| 9 | 10 | ||
| 10 | public class swiftApi { | 11 | public class swiftApi { | 
| 11 | 12 | ||
| ... | @@ -330,4 +331,12 @@ public class swiftApi { | ... | @@ -330,4 +331,12 @@ public class swiftApi { | 
| 330 | public func getCampaigns() -> Array<CampaignItemModel> { | 331 | public func getCampaigns() -> Array<CampaignItemModel> { | 
| 331 | return CampaignDataModel().getData | 332 | return CampaignDataModel().getData | 
| 332 | } | 333 | } | 
| 334 | + | ||
| 335 | + public func openCoupon(parent: UIView, coupon: CouponSetItemModel) -> UIViewController { | ||
| 336 | + return UIHostingController(rootView: CouponView(parentView: parent, coupon: coupon)) | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + public func openCouponBarcode(parent: UIView, coupon: CouponItemModel) -> UIViewController { | ||
| 340 | + return UIHostingController(rootView: CouponBarcodeView(parentView: parent, coupon: coupon)) | ||
| 341 | + } | ||
| 333 | } | 342 | } | ... | ... | 
- 
Please register or login to post a comment
