Showing
4 changed files
with
76 additions
and
63 deletions
No preview for this file type
No preview for this file type
| ... | @@ -3,22 +3,4 @@ | ... | @@ -3,22 +3,4 @@ |
| 3 | uuid = "91478161-56E8-4654-93F2-7756A39480EE" | 3 | uuid = "91478161-56E8-4654-93F2-7756A39480EE" |
| 4 | type = "0" | 4 | type = "0" |
| 5 | version = "2.0"> | 5 | version = "2.0"> |
| 6 | - <Breakpoints> | ||
| 7 | - <BreakpointProxy | ||
| 8 | - BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint"> | ||
| 9 | - <BreakpointContent | ||
| 10 | - uuid = "28AEA58D-19E0-4D42-BABE-9F1C341D6182" | ||
| 11 | - shouldBeEnabled = "Yes" | ||
| 12 | - ignoreCount = "0" | ||
| 13 | - continueAfterRunningActions = "No" | ||
| 14 | - filePath = "WarplySDKFrameworkIOS/CouponsView.swift" | ||
| 15 | - startingColumnNumber = "9223372036854775807" | ||
| 16 | - endingColumnNumber = "9223372036854775807" | ||
| 17 | - startingLineNumber = "100" | ||
| 18 | - endingLineNumber = "100" | ||
| 19 | - landmarkName = "previews" | ||
| 20 | - landmarkType = "24"> | ||
| 21 | - </BreakpointContent> | ||
| 22 | - </BreakpointProxy> | ||
| 23 | - </Breakpoints> | ||
| 24 | </Bucket> | 6 | </Bucket> | ... | ... |
| ... | @@ -9,36 +9,53 @@ | ... | @@ -9,36 +9,53 @@ |
| 9 | import SwiftUI | 9 | import SwiftUI |
| 10 | 10 | ||
| 11 | class DataModel { | 11 | class DataModel { |
| 12 | - var data: Array<NSDictionary>? | 12 | + var data: Array<NSDictionary> = [] |
| 13 | 13 | ||
| 14 | init() { //initializer method | 14 | init() { //initializer method |
| 15 | let instanceOfMyApi = MyApi() | 15 | let instanceOfMyApi = MyApi() |
| 16 | let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil) | 16 | let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil) |
| 17 | - let coupons = instanceOfMyApi.getCoupons() as AnyObject? | 17 | + let coupons = instanceOfMyApi.getCoupons() as AnyObject? |
| 18 | 18 | ||
| 19 | - | 19 | + if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] { |
| 20 | - if let myDictionary = coupons as? [String : AnyObject] { | 20 | + let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! Array<NSMutableDictionary>) |
| 21 | - self.data = (myDictionary["result"] as! Array<NSDictionary>) | 21 | + if let myCouponsDictionary = coupons as? [String : AnyObject] { |
| 22 | + let couponsData = (myCouponsDictionary["result"] as! Array<NSMutableDictionary>) | ||
| 23 | + if let sets = couponSetsData as? NSArray { | ||
| 24 | + for set in sets { | ||
| 25 | + let s = set as! NSDictionary | ||
| 26 | + if let cpns = couponsData as? NSArray { | ||
| 27 | + for coupon in cpns { | ||
| 28 | + var c = coupon as! NSDictionary | ||
| 29 | +// var temp = NSMutableDictionary(dictionary: s); | ||
| 30 | + if c["couponset_uuid"] as! String == s["uuid"] as! String { | ||
| 31 | + var temp = NSMutableDictionary(dictionary: s); | ||
| 32 | + temp.addEntries(from: c as! [AnyHashable : Any]) | ||
| 33 | + | ||
| 34 | + self.data.append(temp as NSDictionary) | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + } | ||
| 41 | + } | ||
| 42 | + } | ||
| 22 | } | 43 | } |
| 23 | } | 44 | } |
| 24 | 45 | ||
| 25 | var getData: Array<NSDictionary> { | 46 | var getData: Array<NSDictionary> { |
| 26 | get { // getter | 47 | get { // getter |
| 27 | - return data ?? [] | 48 | + return data |
| 28 | } | 49 | } |
| 29 | } | 50 | } |
| 30 | } | 51 | } |
| 31 | 52 | ||
| 32 | - | 53 | +extension CouponsView { |
| 33 | -@available(iOS 13.0.0, *) | 54 | + struct headerView: View { |
| 34 | -struct CouponsView: View { | 55 | + |
| 35 | - | 56 | + var uiscreen = UIScreen.main.bounds |
| 36 | - var data:Array<NSDictionary> = DataModel().getData | 57 | + |
| 37 | - | 58 | + var body: some View { |
| 38 | - var uiscreen = UIScreen.main.bounds | ||
| 39 | -// @State private var bottomRect: CGRect = .zero | ||
| 40 | - var body: some View { | ||
| 41 | - VStack { | ||
| 42 | ZStack { | 59 | ZStack { |
| 43 | Image("ic_back", bundle: Bundle(for: MyEmptyClass.self)) | 60 | Image("ic_back", bundle: Bundle(for: MyEmptyClass.self)) |
| 44 | .resizable() | 61 | .resizable() |
| ... | @@ -49,41 +66,55 @@ struct CouponsView: View { | ... | @@ -49,41 +66,55 @@ struct CouponsView: View { |
| 49 | .offset( y: self.uiscreen.height * 0.07) | 66 | .offset( y: self.uiscreen.height * 0.07) |
| 50 | .frame(width: self.uiscreen.width) | 67 | .frame(width: self.uiscreen.width) |
| 51 | } | 68 | } |
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + struct couponView: View { | ||
| 73 | + @Binding var result: NSDictionary | ||
| 74 | + | ||
| 75 | + var uiscreen = UIScreen.main.bounds | ||
| 76 | + | ||
| 77 | + var body: some View { | ||
| 78 | + ZStack { | ||
| 79 | + URLImage(url: URL(string: result["img_preview"] as! String? ?? "")) | ||
| 80 | +// .resizable() | ||
| 81 | + .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04) | ||
| 82 | + .cornerRadius(CGFloat(self.uiscreen.height * 0.02)) | ||
| 83 | +// .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07) | ||
| 84 | + | ||
| 85 | + } | ||
| 86 | +// .background( | ||
| 87 | +// Image("coupons_container", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 88 | +// .resizable() | ||
| 89 | +//// .edgesIgnoringSafeArea(.all) | ||
| 90 | +// .frame(width: UIScreen.main.bounds.width * 0.8, height: UIScreen.main.bounds.height * 0.17) | ||
| 91 | +// ) | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | +} | ||
| 96 | + | ||
| 97 | +@available(iOS 13.0.0, *) | ||
| 98 | +struct CouponsView: View { | ||
| 99 | + | ||
| 100 | + var data:Array<NSDictionary> = DataModel().getData | ||
| 101 | + | ||
| 102 | + var uiscreen = UIScreen.main.bounds | ||
| 103 | + | ||
| 104 | + var body: some View { | ||
| 105 | + VStack { | ||
| 106 | + headerView() | ||
| 52 | ScrollView { | 107 | ScrollView { |
| 53 | VStack { | 108 | VStack { |
| 54 | - | 109 | + if (data.count) > 0 { |
| 55 | - | 110 | + ForEach(data, id: \.self) { result in |
| 56 | -// let dataArray:[NSDictionary] = (data as! NSArray).compactMap({ $0 as? NSDictionary }) | 111 | + couponView(result: result) |
| 57 | - | 112 | + } |
| 58 | -// if (data?.count())! > 0 { | ||
| 59 | -// data?.forEach { (language) in | ||
| 60 | -// ForEach(data, id: \.self) { result in | ||
| 61 | -// | ||
| 62 | -// | ||
| 63 | -// | ||
| 64 | -// ZStack { | ||
| 65 | -// Image("logo", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 66 | -// .resizable() | ||
| 67 | -// .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04, alignment: .topLeading) | ||
| 68 | -// .cornerRadius(CGFloat(self.uiscreen.height * 0.02)) | ||
| 69 | -// .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07) | ||
| 70 | -// | ||
| 71 | -// }.background( | ||
| 72 | -// Image("coupons_container", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS")) | ||
| 73 | -// .resizable() | ||
| 74 | -// .edgesIgnoringSafeArea(.all) | ||
| 75 | -// .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) | ||
| 76 | -// ) | ||
| 77 | -// | ||
| 78 | } | 113 | } |
| 79 | -// | ||
| 80 | - | ||
| 81 | - | ||
| 82 | } | 114 | } |
| 83 | .frame(width:self.uiscreen.width, height:self.uiscreen.height ) | 115 | .frame(width:self.uiscreen.width, height:self.uiscreen.height ) |
| 84 | - | ||
| 85 | } | 116 | } |
| 86 | - | 117 | + } |
| 87 | } | 118 | } |
| 88 | } | 119 | } |
| 89 | #endif | 120 | #endif | ... | ... |
-
Please register or login to post a comment