Showing
2 changed files
with
19 additions
and
8 deletions
No preview for this file type
... | @@ -71,16 +71,18 @@ extension AllGiftsView { | ... | @@ -71,16 +71,18 @@ extension AllGiftsView { |
71 | 71 | ||
72 | 72 | ||
73 | struct giftItemView: View { | 73 | struct giftItemView: View { |
74 | - var item: NSDictionary | 74 | + var item: swiftApi.CouponItemModel |
75 | var parentView: UIView | 75 | var parentView: UIView |
76 | 76 | ||
77 | var uiscreen = UIScreen.main.bounds | 77 | var uiscreen = UIScreen.main.bounds |
78 | 78 | ||
79 | var body: some View { | 79 | var body: some View { |
80 | + let couponSetData = item.couponset_data | ||
81 | + | ||
80 | Button { | 82 | Button { |
81 | // GiftItem Action | 83 | // GiftItem Action |
82 | - let instanceOfMyApi = MyApi() | 84 | + let instanceOfMySwiftApi = swiftApi() |
83 | - let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: item as! [String : Any])! | 85 | + let couponBarcodeViewController = instanceOfMySwiftApi.openCouponBarcode(parent: parentView, coupon: item) |
84 | couponBarcodeViewController.view.tag = 7 | 86 | couponBarcodeViewController.view.tag = 7 |
85 | // addChild(couponsViewController) | 87 | // addChild(couponsViewController) |
86 | couponBarcodeViewController.view.frame = parentView.frame | 88 | couponBarcodeViewController.view.frame = parentView.frame |
... | @@ -89,10 +91,10 @@ extension AllGiftsView { | ... | @@ -89,10 +91,10 @@ extension AllGiftsView { |
89 | } label: { | 91 | } label: { |
90 | HStack(alignment: .center, spacing: 0.0) { | 92 | HStack(alignment: .center, spacing: 0.0) { |
91 | 93 | ||
92 | - ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.5, isFill: true) | 94 | + ImageView(withURL: couponSetData?.img_preview ?? "", width: self.uiscreen.width * 0.5, isFill: true) |
93 | 95 | ||
94 | VStack(alignment: .leading, spacing: 5.0) { | 96 | VStack(alignment: .leading, spacing: 5.0) { |
95 | - Text(item["name"] as? String ?? "") | 97 | + Text(couponSetData?.name ?? "") |
96 | .fontWeight(.bold) | 98 | .fontWeight(.bold) |
97 | .font(.system(size: 16)) | 99 | .font(.system(size: 16)) |
98 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 100 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) |
... | @@ -100,7 +102,7 @@ extension AllGiftsView { | ... | @@ -100,7 +102,7 @@ extension AllGiftsView { |
100 | .padding([.top,.horizontal], 15) | 102 | .padding([.top,.horizontal], 15) |
101 | .background(Color.white) | 103 | .background(Color.white) |
102 | 104 | ||
103 | - Text(item["short_description"] as? String ?? "") | 105 | + Text(couponSetData?.short_description ?? "") |
104 | .fontWeight(.regular) | 106 | .fontWeight(.regular) |
105 | .font(.system(size: 16)) | 107 | .font(.system(size: 16)) |
106 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 108 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) |
... | @@ -123,7 +125,7 @@ extension AllGiftsView { | ... | @@ -123,7 +125,7 @@ extension AllGiftsView { |
123 | } | 125 | } |
124 | 126 | ||
125 | struct couponsContainer: View { | 127 | struct couponsContainer: View { |
126 | - @State var coupons:Array<NSDictionary> = [] | 128 | + @State var coupons:Array<swiftApi.CouponItemModel> = [] |
127 | @State var parentView:UIView | 129 | @State var parentView:UIView |
128 | 130 | ||
129 | var uiscreen = UIScreen.main.bounds | 131 | var uiscreen = UIScreen.main.bounds |
... | @@ -148,10 +150,19 @@ extension AllGiftsView { | ... | @@ -148,10 +150,19 @@ extension AllGiftsView { |
148 | struct AllGiftsView: View { | 150 | struct AllGiftsView: View { |
149 | var parentView: UIView | 151 | var parentView: UIView |
150 | 152 | ||
151 | - var coupons:Array<NSDictionary> = DataModel().getData | 153 | + var coupons:Array<swiftApi.CouponItemModel> = [] |
152 | 154 | ||
153 | var uiscreen = UIScreen.main.bounds | 155 | var uiscreen = UIScreen.main.bounds |
154 | 156 | ||
157 | + init(parentView: UIView) { //initializer method | ||
158 | + | ||
159 | + let instanceOfMySwiftApi = swiftApi() | ||
160 | + let couponsData = instanceOfMySwiftApi.getCoupons() | ||
161 | + | ||
162 | + self.coupons = couponsData | ||
163 | + self.parentView = parentView | ||
164 | + } | ||
165 | + | ||
155 | func goBack(){ | 166 | func goBack(){ |
156 | for subview in parentView.subviews { | 167 | for subview in parentView.subviews { |
157 | if(subview.tag == 8) { | 168 | if(subview.tag == 8) { | ... | ... |
-
Please register or login to post a comment