Merge branch 'master' of https://git.warp.ly/open-source/warply_sdk_framework
Showing
13 changed files
with
584 additions
and
14 deletions
No preview for this file type
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> | 7 | <key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> |
| 8 | <dict> | 8 | <dict> |
| 9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
| 10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
| 11 | </dict> | 11 | </dict> |
| 12 | </dict> | 12 | </dict> |
| 13 | </dict> | 13 | </dict> | ... | ... |
| ... | @@ -11,6 +11,10 @@ | ... | @@ -11,6 +11,10 @@ |
| 11 | 1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */; }; | 11 | 1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */; }; |
| 12 | 1E735FF2281067320050A298 /* CampaignWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF1281067320050A298 /* CampaignWebview.swift */; }; | 12 | 1E735FF2281067320050A298 /* CampaignWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF1281067320050A298 /* CampaignWebview.swift */; }; |
| 13 | 1E735FF42810681E0050A298 /* CampaignWebviewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */; }; | 13 | 1E735FF42810681E0050A298 /* CampaignWebviewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */; }; |
| 14 | + 1E879E25281AC96A0089F489 /* OldCouponsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E24281AC96A0089F489 /* OldCouponsView.swift */; }; | ||
| 15 | + 1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */; }; | ||
| 16 | + 1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; }; | ||
| 17 | + 1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */; }; | ||
| 14 | 1EBEB02D280D69D800BF802C /* GiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02C280D69D800BF802C /* GiftsView.swift */; }; | 18 | 1EBEB02D280D69D800BF802C /* GiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02C280D69D800BF802C /* GiftsView.swift */; }; |
| 15 | 1EBEB02F280D6AA500BF802C /* GiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */; }; | 19 | 1EBEB02F280D6AA500BF802C /* GiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */; }; |
| 16 | 260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1353B8C484CC0649CAC2EB74 /* Pods_WarplySDKFrameworkIOS.framework */; }; | 20 | 260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1353B8C484CC0649CAC2EB74 /* Pods_WarplySDKFrameworkIOS.framework */; }; |
| ... | @@ -147,6 +151,10 @@ | ... | @@ -147,6 +151,10 @@ |
| 147 | 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewInterface.swift; sourceTree = "<group>"; }; | 151 | 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewInterface.swift; sourceTree = "<group>"; }; |
| 148 | 1E735FF1281067320050A298 /* CampaignWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebview.swift; sourceTree = "<group>"; }; | 152 | 1E735FF1281067320050A298 /* CampaignWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebview.swift; sourceTree = "<group>"; }; |
| 149 | 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebviewInterface.swift; sourceTree = "<group>"; }; | 153 | 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebviewInterface.swift; sourceTree = "<group>"; }; |
| 154 | + 1E879E24281AC96A0089F489 /* OldCouponsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsView.swift; sourceTree = "<group>"; }; | ||
| 155 | + 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsViewInterface.swift; sourceTree = "<group>"; }; | ||
| 156 | + 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsView.swift; sourceTree = "<group>"; }; | ||
| 157 | + 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsViewInterface.swift; sourceTree = "<group>"; }; | ||
| 150 | 1EBEB02C280D69D800BF802C /* GiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsView.swift; sourceTree = "<group>"; }; | 158 | 1EBEB02C280D69D800BF802C /* GiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsView.swift; sourceTree = "<group>"; }; |
| 151 | 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsViewInterface.swift; sourceTree = "<group>"; }; | 159 | 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsViewInterface.swift; sourceTree = "<group>"; }; |
| 152 | B9413513157AD76ECE896B81 /* Pods-WarplySDKFrameworkIOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WarplySDKFrameworkIOS.release.xcconfig"; path = "Target Support Files/Pods-WarplySDKFrameworkIOS/Pods-WarplySDKFrameworkIOS.release.xcconfig"; sourceTree = "<group>"; }; | 160 | B9413513157AD76ECE896B81 /* Pods-WarplySDKFrameworkIOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WarplySDKFrameworkIOS.release.xcconfig"; path = "Target Support Files/Pods-WarplySDKFrameworkIOS/Pods-WarplySDKFrameworkIOS.release.xcconfig"; sourceTree = "<group>"; }; |
| ... | @@ -341,6 +349,10 @@ | ... | @@ -341,6 +349,10 @@ |
| 341 | E639EFA0280810E300B9DD94 /* CouponsView.swift */, | 349 | E639EFA0280810E300B9DD94 /* CouponsView.swift */, |
| 342 | E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */, | 350 | E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */, |
| 343 | 1EBEB02C280D69D800BF802C /* GiftsView.swift */, | 351 | 1EBEB02C280D69D800BF802C /* GiftsView.swift */, |
| 352 | + 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */, | ||
| 353 | + 1E879E24281AC96A0089F489 /* OldCouponsView.swift */, | ||
| 354 | + 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */, | ||
| 355 | + 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */, | ||
| 344 | 1E735FF1281067320050A298 /* CampaignWebview.swift */, | 356 | 1E735FF1281067320050A298 /* CampaignWebview.swift */, |
| 345 | 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */, | 357 | 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */, |
| 346 | 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */, | 358 | 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */, |
| ... | @@ -747,12 +759,14 @@ | ... | @@ -747,12 +759,14 @@ |
| 747 | isa = PBXSourcesBuildPhase; | 759 | isa = PBXSourcesBuildPhase; |
| 748 | buildActionMask = 2147483647; | 760 | buildActionMask = 2147483647; |
| 749 | files = ( | 761 | files = ( |
| 762 | + 1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */, | ||
| 750 | E6D8DF0B27A942920006A3A9 /* WLEvent.m in Sources */, | 763 | E6D8DF0B27A942920006A3A9 /* WLEvent.m in Sources */, |
| 751 | E6D8DF1E27A942920006A3A9 /* UIViewController+WLAdditions.m in Sources */, | 764 | E6D8DF1E27A942920006A3A9 /* UIViewController+WLAdditions.m in Sources */, |
| 752 | E6D8DF2E27A942920006A3A9 /* UIRefreshControl+AFNetworking.m in Sources */, | 765 | E6D8DF2E27A942920006A3A9 /* UIRefreshControl+AFNetworking.m in Sources */, |
| 753 | E6D8DF4827A942920006A3A9 /* AFURLRequestSerialization.m in Sources */, | 766 | E6D8DF4827A942920006A3A9 /* AFURLRequestSerialization.m in Sources */, |
| 754 | E67D1EC228113EED00940F01 /* CouponView.swift in Sources */, | 767 | E67D1EC228113EED00940F01 /* CouponView.swift in Sources */, |
| 755 | 1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */, | 768 | 1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */, |
| 769 | + 1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */, | ||
| 756 | E6D8DEF327A942920006A3A9 /* WLNativeVideoTableViewCell.m in Sources */, | 770 | E6D8DEF327A942920006A3A9 /* WLNativeVideoTableViewCell.m in Sources */, |
| 757 | E6D8DF2527A942920006A3A9 /* WLSMSActionHanlder.m in Sources */, | 771 | E6D8DF2527A942920006A3A9 /* WLSMSActionHanlder.m in Sources */, |
| 758 | E67D1EBE2810573900940F01 /* WalletView.swift in Sources */, | 772 | E67D1EBE2810573900940F01 /* WalletView.swift in Sources */, |
| ... | @@ -774,6 +788,7 @@ | ... | @@ -774,6 +788,7 @@ |
| 774 | E6D8DF1327A942920006A3A9 /* WLBeaconManager.m in Sources */, | 788 | E6D8DF1327A942920006A3A9 /* WLBeaconManager.m in Sources */, |
| 775 | E6D8DF0427A942920006A3A9 /* WLInboxItem.m in Sources */, | 789 | E6D8DF0427A942920006A3A9 /* WLInboxItem.m in Sources */, |
| 776 | E6D8DF5127A942920006A3A9 /* FMDatabaseAdditions.m in Sources */, | 790 | E6D8DF5127A942920006A3A9 /* FMDatabaseAdditions.m in Sources */, |
| 791 | + 1E879E25281AC96A0089F489 /* OldCouponsView.swift in Sources */, | ||
| 777 | E6D8DF2127A942920006A3A9 /* WLAPPActionHandler.m in Sources */, | 792 | E6D8DF2127A942920006A3A9 /* WLAPPActionHandler.m in Sources */, |
| 778 | E6D8DF5627A942920006A3A9 /* FMDatabasePool.m in Sources */, | 793 | E6D8DF5627A942920006A3A9 /* FMDatabasePool.m in Sources */, |
| 779 | E6D8DF4527A942920006A3A9 /* AFHTTPSessionManager.m in Sources */, | 794 | E6D8DF4527A942920006A3A9 /* AFHTTPSessionManager.m in Sources */, |
| ... | @@ -786,6 +801,7 @@ | ... | @@ -786,6 +801,7 @@ |
| 786 | E6D8DF2C27A942920006A3A9 /* UIProgressView+AFNetworking.m in Sources */, | 801 | E6D8DF2C27A942920006A3A9 /* UIProgressView+AFNetworking.m in Sources */, |
| 787 | E6D8DF3C27A942920006A3A9 /* UIWebView+AFNetworking.m in Sources */, | 802 | E6D8DF3C27A942920006A3A9 /* UIWebView+AFNetworking.m in Sources */, |
| 788 | E639EFA2280810E300B9DD94 /* CouponsView.swift in Sources */, | 803 | E639EFA2280810E300B9DD94 /* CouponsView.swift in Sources */, |
| 804 | + 1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */, | ||
| 789 | E6D8DF1427A942920006A3A9 /* WLLocationManager.m in Sources */, | 805 | E6D8DF1427A942920006A3A9 /* WLLocationManager.m in Sources */, |
| 790 | E6D8DF6027A9429E0006A3A9 /* MyApi.m in Sources */, | 806 | E6D8DF6027A9429E0006A3A9 /* MyApi.m in Sources */, |
| 791 | E6D8DF3F27A942920006A3A9 /* AFImageDownloader.m in Sources */, | 807 | E6D8DF3F27A942920006A3A9 /* AFImageDownloader.m in Sources */, | ... | ... |
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | <key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> | 7 | <key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> |
| 8 | <dict> | 8 | <dict> |
| 9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
| 10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
| 11 | </dict> | 11 | </dict> |
| 12 | </dict> | 12 | </dict> |
| 13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
| 1 | +// | ||
| 2 | +// AllGiftsView.swift | ||
| 3 | +// WarplySDKFrameworkIOS | ||
| 4 | +// | ||
| 5 | +// Created by Manos Chorianopoulos on 27/4/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | + | ||
| 9 | +#if canImport(SwiftUI) | ||
| 10 | +import SwiftUI | ||
| 11 | +import Combine | ||
| 12 | +import Foundation | ||
| 13 | +import UIKit | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +extension AllGiftsView { | ||
| 17 | + struct headerView: View { | ||
| 18 | + var goBack: () -> () | ||
| 19 | + | ||
| 20 | + var uiscreen = UIScreen.main.bounds | ||
| 21 | + | ||
| 22 | + var body: some View { | ||
| 23 | + HStack(alignment: .center) { | ||
| 24 | + Button { | ||
| 25 | + // Button Action | ||
| 26 | + print("Back Button tapped!") | ||
| 27 | + goBack() | ||
| 28 | + } label: { | ||
| 29 | + Image("ic_back", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 30 | + .resizable() | ||
| 31 | + .aspectRatio(contentMode: .fit) | ||
| 32 | + .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02) | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + Text("Όλα τα δώρα μου") | ||
| 36 | + .fontWeight(.medium) | ||
| 37 | + .font(.system(size: 16)) | ||
| 38 | + .foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196)) | ||
| 39 | + .multilineTextAlignment(.center) | ||
| 40 | + .frame(maxWidth: .infinity) | ||
| 41 | + .padding(.horizontal) | ||
| 42 | + } | ||
| 43 | + .frame(maxWidth: .infinity) | ||
| 44 | + .padding(.horizontal) | ||
| 45 | + .padding(.vertical, 10) | ||
| 46 | + } | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + struct ImageView: View { | ||
| 50 | + @ObservedObject var imageLoader:UrlImageModel | ||
| 51 | + @State var width:CGFloat | ||
| 52 | + @State var isFill:Bool | ||
| 53 | + | ||
| 54 | + var uiscreen = UIScreen.main.bounds | ||
| 55 | + | ||
| 56 | + init(withURL url:String , width:CGFloat, isFill:Bool) { | ||
| 57 | + imageLoader = UrlImageModel(urlString:url) | ||
| 58 | + self.width = width | ||
| 59 | + self.isFill = isFill | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + var body: some View { | ||
| 63 | + | ||
| 64 | + Image(uiImage: imageLoader.image ?? UIImage()) | ||
| 65 | + .resizable() | ||
| 66 | + .aspectRatio(contentMode: isFill ? .fill : .fit) | ||
| 67 | + .frame(width: self.width) | ||
| 68 | + .frame(maxHeight: .infinity) | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + | ||
| 73 | + struct giftItemView: View { | ||
| 74 | + var item: NSDictionary | ||
| 75 | + var parentView: UIView | ||
| 76 | + | ||
| 77 | + var uiscreen = UIScreen.main.bounds | ||
| 78 | + | ||
| 79 | + var body: some View { | ||
| 80 | + Button { | ||
| 81 | + // GiftItem Action | ||
| 82 | + let instanceOfMyApi = MyApi() | ||
| 83 | + let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: item as! [String : Any])! | ||
| 84 | + couponBarcodeViewController.view.tag = 7 | ||
| 85 | +// addChild(couponsViewController) | ||
| 86 | + couponBarcodeViewController.view.frame = parentView.frame | ||
| 87 | + parentView.addSubview(couponBarcodeViewController.view) | ||
| 88 | + couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self)) | ||
| 89 | + } label: { | ||
| 90 | + HStack(alignment: .center, spacing: 0.0) { | ||
| 91 | + | ||
| 92 | + ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.5, isFill: true) | ||
| 93 | + | ||
| 94 | + VStack(alignment: .leading, spacing: 5.0) { | ||
| 95 | + Text(item["name"] as? String ?? "") | ||
| 96 | + .fontWeight(.bold) | ||
| 97 | + .font(.system(size: 16)) | ||
| 98 | + .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | ||
| 99 | + .multilineTextAlignment(.leading) | ||
| 100 | + .padding([.top,.horizontal], 15) | ||
| 101 | + .background(Color.white) | ||
| 102 | + | ||
| 103 | + Text(item["short_description"] as? String ?? "") | ||
| 104 | + .fontWeight(.regular) | ||
| 105 | + .font(.system(size: 16)) | ||
| 106 | + .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | ||
| 107 | + .multilineTextAlignment(.leading) | ||
| 108 | + .padding([.bottom,.horizontal], 15) | ||
| 109 | + .background(Color.white) | ||
| 110 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
| 111 | + } | ||
| 112 | + .background(Color.white) | ||
| 113 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
| 114 | + } | ||
| 115 | + .background(Color.white) | ||
| 116 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
| 117 | + } | ||
| 118 | + .frame(width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.17) | ||
| 119 | + .background(Color.white) | ||
| 120 | + .cornerRadius(5) | ||
| 121 | + .shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 6, x: 0, y: 3) | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + struct couponsContainer: View { | ||
| 126 | + @State var coupons:Array<NSDictionary> = [] | ||
| 127 | + @State var parentView:UIView | ||
| 128 | + | ||
| 129 | + var uiscreen = UIScreen.main.bounds | ||
| 130 | + | ||
| 131 | + var body: some View { | ||
| 132 | + VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) { | ||
| 133 | + | ||
| 134 | + ForEach(Array(coupons.enumerated()), id: \.offset) { index, item in | ||
| 135 | + | ||
| 136 | + giftItemView(item: item, parentView: parentView) | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | + .frame(maxWidth: .infinity) | ||
| 140 | + .padding(.top, self.uiscreen.height * 0.05) | ||
| 141 | + .padding(.bottom, self.uiscreen.height * 0.1) | ||
| 142 | + } | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | +} | ||
| 146 | + | ||
| 147 | +@available(iOS 13.0.0, *) | ||
| 148 | +struct AllGiftsView: View { | ||
| 149 | + var parentView: UIView | ||
| 150 | + | ||
| 151 | + var coupons:Array<NSDictionary> = DataModel().getData | ||
| 152 | + | ||
| 153 | + var uiscreen = UIScreen.main.bounds | ||
| 154 | + | ||
| 155 | + func goBack(){ | ||
| 156 | + for subview in parentView.subviews { | ||
| 157 | + if(subview.tag == 8) { | ||
| 158 | + subview.removeFromSuperview() | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + var body: some View { | ||
| 164 | + VStack { | ||
| 165 | + headerView(goBack: goBack) | ||
| 166 | + | ||
| 167 | + VStack { | ||
| 168 | + ScrollView(showsIndicators: false) { | ||
| 169 | + VStack { | ||
| 170 | + | ||
| 171 | + if (coupons.count) > 0 { | ||
| 172 | + couponsContainer(coupons: coupons, parentView: parentView ) | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + } | ||
| 176 | + .frame(width:self.uiscreen.width) | ||
| 177 | + } | ||
| 178 | + .cornerRadius(30, corners: [.topLeft]) | ||
| 179 | + .frame(width:self.uiscreen.width) | ||
| 180 | + .frame(maxHeight: .infinity) | ||
| 181 | + } | ||
| 182 | + .frame(width:self.uiscreen.width) | ||
| 183 | + .frame(maxHeight: .infinity) | ||
| 184 | + .padding(.top, 5) | ||
| 185 | + .background( | ||
| 186 | + Image("coupons_scrollview", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 187 | + .resizable() | ||
| 188 | + ) | ||
| 189 | + | ||
| 190 | + } | ||
| 191 | + .edgesIgnoringSafeArea([.bottom]) | ||
| 192 | + .frame(width:self.uiscreen.width) | ||
| 193 | + .frame(maxHeight: .infinity) | ||
| 194 | + } | ||
| 195 | +} | ||
| 196 | +#endif | ||
| 197 | + | ||
| 198 | +//struct AllGiftsView_Previews: PreviewProvider { | ||
| 199 | +// static var previews: some View { | ||
| 200 | +// AllGiftsView() | ||
| 201 | +// } | ||
| 202 | +//} |
| 1 | +// | ||
| 2 | +// AllGiftsViewInterface.swift | ||
| 3 | +// WarplySDKFrameworkIOS | ||
| 4 | +// | ||
| 5 | +// Created by Manos Chorianopoulos on 27/4/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import Foundation | ||
| 9 | +import SwiftUI | ||
| 10 | + | ||
| 11 | +@available(iOS 13.0.0, *) | ||
| 12 | +@objc public class AllGiftsViewInterface : NSObject { | ||
| 13 | + | ||
| 14 | + @objc(allGiftsViewController:) static public func allGiftsViewController(parentView: UIView?) -> UIViewController { | ||
| 15 | + return UIHostingController(rootView: AllGiftsView(parentView: parentView!)) | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | +} |
| ... | @@ -56,7 +56,7 @@ extension CouponBarcodeView { | ... | @@ -56,7 +56,7 @@ extension CouponBarcodeView { |
| 56 | 56 | ||
| 57 | static func convertDateFormat(inputDate: String) -> String { | 57 | static func convertDateFormat(inputDate: String) -> String { |
| 58 | let dateFormatter = DateFormatter() | 58 | let dateFormatter = DateFormatter() |
| 59 | - dateFormatter.dateFormat = "yyyy-MM-dd hh:mm" | 59 | + dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss" |
| 60 | if let date = dateFormatter.date(from: inputDate) { | 60 | if let date = dateFormatter.date(from: inputDate) { |
| 61 | dateFormatter.dateFormat = "dd/MM/yyyy" | 61 | dateFormatter.dateFormat = "dd/MM/yyyy" |
| 62 | let resultString = dateFormatter.string(from: date) | 62 | let resultString = dateFormatter.string(from: date) |
| ... | @@ -97,6 +97,8 @@ extension CouponBarcodeView { | ... | @@ -97,6 +97,8 @@ extension CouponBarcodeView { |
| 97 | 97 | ||
| 98 | 98 | ||
| 99 | var body: some View { | 99 | var body: some View { |
| 100 | + let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""] | ||
| 101 | + | ||
| 100 | GeometryReader { geometry in | 102 | GeometryReader { geometry in |
| 101 | ScrollView(showsIndicators: false) { | 103 | ScrollView(showsIndicators: false) { |
| 102 | VStack(alignment: .leading) { | 104 | VStack(alignment: .leading) { |
| ... | @@ -111,6 +113,7 @@ extension CouponBarcodeView { | ... | @@ -111,6 +113,7 @@ extension CouponBarcodeView { |
| 111 | .multilineTextAlignment(.leading) | 113 | .multilineTextAlignment(.leading) |
| 112 | .padding(.horizontal) | 114 | .padding(.horizontal) |
| 113 | .padding(.top, self.uiscreen.height * 0.04) | 115 | .padding(.top, self.uiscreen.height * 0.04) |
| 116 | + .frame(maxHeight: .infinity) | ||
| 114 | 117 | ||
| 115 | Text(coupon["short_description"] as? String ?? "") | 118 | Text(coupon["short_description"] as? String ?? "") |
| 116 | .fontWeight(.regular) | 119 | .fontWeight(.regular) |
| ... | @@ -131,7 +134,7 @@ extension CouponBarcodeView { | ... | @@ -131,7 +134,7 @@ extension CouponBarcodeView { |
| 131 | 134 | ||
| 132 | VStack(alignment: .center) { | 135 | VStack(alignment: .center) { |
| 133 | VStack { | 136 | VStack { |
| 134 | - Text("1A2C378") | 137 | + Text(couponData["coupon"] as? String ?? "") |
| 135 | .fontWeight(.bold) | 138 | .fontWeight(.bold) |
| 136 | .font(.system(size: 27)) | 139 | .font(.system(size: 27)) |
| 137 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 140 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) |
| ... | @@ -146,7 +149,7 @@ extension CouponBarcodeView { | ... | @@ -146,7 +149,7 @@ extension CouponBarcodeView { |
| 146 | } | 149 | } |
| 147 | .frame(maxWidth: .infinity) | 150 | .frame(maxWidth: .infinity) |
| 148 | 151 | ||
| 149 | - if (CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: coupon["coupon"] as? String ?? ""))) { | 152 | + if (CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: couponData["coupon"] as? String ?? ""))) { |
| 150 | VStack(alignment: .center) { | 153 | VStack(alignment: .center) { |
| 151 | VStack {} | 154 | VStack {} |
| 152 | .frame(height: 1) | 155 | .frame(height: 1) |
| ... | @@ -194,7 +197,7 @@ extension CouponBarcodeView { | ... | @@ -194,7 +197,7 @@ extension CouponBarcodeView { |
| 194 | // .aspectRatio(contentMode: .fit) | 197 | // .aspectRatio(contentMode: .fit) |
| 195 | // .frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.1) | 198 | // .frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.1) |
| 196 | 199 | ||
| 197 | - Text(coupon["coupon"] as? String ?? "") | 200 | + Text(couponData["coupon"] as? String ?? "") |
| 198 | .fontWeight(.regular) | 201 | .fontWeight(.regular) |
| 199 | .font(.system(size: 22)) | 202 | .font(.system(size: 22)) |
| 200 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 203 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) |
| ... | @@ -215,7 +218,7 @@ extension CouponBarcodeView { | ... | @@ -215,7 +218,7 @@ extension CouponBarcodeView { |
| 215 | 218 | ||
| 216 | 219 | ||
| 217 | 220 | ||
| 218 | - Text("Το κουπόνι ισχύει έως " + CouponBarcodeView.couponContainer.convertDateFormat(inputDate: coupon["expiration"] as? String ?? "")) | 221 | + Text("Το κουπόνι ισχύει έως " + CouponBarcodeView.couponContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? "")) |
| 219 | .fontWeight(.medium) | 222 | .fontWeight(.medium) |
| 220 | .font(.system(size: 14)) | 223 | .font(.system(size: 14)) |
| 221 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) | 224 | .foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803)) |
| ... | @@ -296,7 +299,7 @@ extension CouponBarcodeView { | ... | @@ -296,7 +299,7 @@ extension CouponBarcodeView { |
| 296 | 299 | ||
| 297 | } | 300 | } |
| 298 | .frame(width:self.uiscreen.width) | 301 | .frame(width:self.uiscreen.width) |
| 299 | - .frame(minHeight: geometry.size.height) | 302 | +// .frame(minHeight: geometry.size.height) |
| 300 | .padding(.bottom, self.uiscreen.height * 0.03) | 303 | .padding(.bottom, self.uiscreen.height * 0.03) |
| 301 | } | 304 | } |
| 302 | .frame(width:self.uiscreen.width) | 305 | .frame(width:self.uiscreen.width) | ... | ... |
| ... | @@ -32,7 +32,9 @@ class DataModel { | ... | @@ -32,7 +32,9 @@ class DataModel { |
| 32 | // var temp = NSMutableDictionary(dictionary: s); | 32 | // var temp = NSMutableDictionary(dictionary: s); |
| 33 | if c["couponset_uuid"] as! String == s["uuid"] as! String { | 33 | if c["couponset_uuid"] as! String == s["uuid"] as! String { |
| 34 | var temp = NSMutableDictionary(dictionary: s); | 34 | var temp = NSMutableDictionary(dictionary: s); |
| 35 | - temp.addEntries(from: c as! [AnyHashable : Any]) | 35 | +// temp.addEntries(from: c as! [AnyHashable : Any]) |
| 36 | + | ||
| 37 | + temp.setValue(c as! [AnyHashable : Any],forKey: "coupon_data") | ||
| 36 | 38 | ||
| 37 | self.data.append(temp as NSDictionary) | 39 | self.data.append(temp as NSDictionary) |
| 38 | } | 40 | } |
| ... | @@ -48,7 +50,19 @@ class DataModel { | ... | @@ -48,7 +50,19 @@ class DataModel { |
| 48 | 50 | ||
| 49 | var getData: Array<NSDictionary> { | 51 | var getData: Array<NSDictionary> { |
| 50 | get { // getter | 52 | get { // getter |
| 51 | - return data.filter({ $0["status"] as! String == "1" }) | 53 | + return data.filter({ |
| 54 | + let couponData = $0["coupon_data"] as? [String: Any] ?? ["":""] | ||
| 55 | + return couponData["status"] as? Int == 1 | ||
| 56 | + }) | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + var getOldCoupons: Array<NSDictionary> { | ||
| 61 | + get { // getter | ||
| 62 | + return data.filter({ | ||
| 63 | + let couponData = $0["coupon_data"] as? [String: Any] ?? ["":""] | ||
| 64 | + return couponData["status"] as? Int != 1 | ||
| 65 | + }) | ||
| 52 | } | 66 | } |
| 53 | } | 67 | } |
| 54 | } | 68 | } |
| ... | @@ -118,6 +132,8 @@ extension CouponsView { | ... | @@ -118,6 +132,8 @@ extension CouponsView { |
| 118 | } | 132 | } |
| 119 | } | 133 | } |
| 120 | Text("Όλα τα κουπόνια μου") | 134 | Text("Όλα τα κουπόνια μου") |
| 135 | + .fontWeight(.medium) | ||
| 136 | + .foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196)) | ||
| 121 | .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center) | 137 | .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center) |
| 122 | .offset( y: self.uiscreen.height * 0.02) | 138 | .offset( y: self.uiscreen.height * 0.02) |
| 123 | .font(.system(size: 15)) | 139 | .font(.system(size: 15)) |
| ... | @@ -129,6 +145,7 @@ extension CouponsView { | ... | @@ -129,6 +145,7 @@ extension CouponsView { |
| 129 | struct couponView: View { | 145 | struct couponView: View { |
| 130 | var result: NSDictionary | 146 | var result: NSDictionary |
| 131 | var index: Int | 147 | var index: Int |
| 148 | + var parentView: UIView | ||
| 132 | 149 | ||
| 133 | var uiscreen = UIScreen.main.bounds | 150 | var uiscreen = UIScreen.main.bounds |
| 134 | 151 | ||
| ... | @@ -149,9 +166,20 @@ extension CouponsView { | ... | @@ -149,9 +166,20 @@ extension CouponsView { |
| 149 | } | 166 | } |
| 150 | 167 | ||
| 151 | var body: some View { | 168 | var body: some View { |
| 169 | + let couponData = result["coupon_data"] as? [String: Any] ?? ["":""] | ||
| 152 | 170 | ||
| 153 | 171 | ||
| 154 | VStack(alignment: .leading) { | 172 | VStack(alignment: .leading) { |
| 173 | + Button { | ||
| 174 | + // GiftItem Action | ||
| 175 | + let instanceOfMyApi = MyApi() | ||
| 176 | + let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: result as! [String : Any])! | ||
| 177 | + couponBarcodeViewController.view.tag = 7 | ||
| 178 | + // addChild(couponsViewController) | ||
| 179 | + couponBarcodeViewController.view.frame = parentView.frame | ||
| 180 | + parentView.addSubview(couponBarcodeViewController.view) | ||
| 181 | + couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self)) | ||
| 182 | + } label: { | ||
| 155 | HStack(alignment: .center) { | 183 | HStack(alignment: .center) { |
| 156 | ImageView(withURL: result["img_preview"] as! String) | 184 | ImageView(withURL: result["img_preview"] as! String) |
| 157 | .frame(maxWidth: self.uiscreen.width * 0.15) | 185 | .frame(maxWidth: self.uiscreen.width * 0.15) |
| ... | @@ -165,13 +193,19 @@ extension CouponsView { | ... | @@ -165,13 +193,19 @@ extension CouponsView { |
| 165 | .padding(.bottom, self.uiscreen.height * 0.0075) | 193 | .padding(.bottom, self.uiscreen.height * 0.0075) |
| 166 | Spacer() | 194 | Spacer() |
| 167 | VStack { | 195 | VStack { |
| 168 | - Text(CouponsView.couponView.localizedWithParameter(parameter: result["admin_name"] as? String ?? "")) | 196 | + Text(CouponsView.couponView.localizedWithParameter(parameter: result["name"] as? String ?? "")) |
| 197 | + .fontWeight(.medium) | ||
| 198 | + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | ||
| 169 | .frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading) | 199 | .frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading) |
| 170 | .font(.system(size: 15)) | 200 | .font(.system(size: 15)) |
| 171 | - Text(CouponsView.couponView.localizedWithParameter(parameter: result["discount"] as? String ?? "")) | 201 | + Text(CouponsView.couponView.localizedWithParameter(parameter: couponData["discount"] as? String ?? "")) |
| 202 | + .fontWeight(.bold) | ||
| 203 | + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | ||
| 172 | .frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: self.uiscreen.height * 0.05, alignment: .leading) | 204 | .frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: self.uiscreen.height * 0.05, alignment: .leading) |
| 173 | .font(.system(size: 47)) | 205 | .font(.system(size: 47)) |
| 174 | - Text(CouponsView.couponView.localizedWithParameter(parameter: "Ισχύει εώς " + CouponsView.couponView.convertDateFormat(inputDate: result["expiration"] as? String ?? ""))) | 206 | + Text(CouponsView.couponView.localizedWithParameter(parameter: "Ισχύει εώς " + CouponsView.couponView.convertDateFormat(inputDate: couponData["expiration"] as? String ?? ""))) |
| 207 | + .fontWeight(.medium) | ||
| 208 | + .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) | ||
| 175 | .frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading) | 209 | .frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading) |
| 176 | .font(.system(size: 10)) | 210 | .font(.system(size: 10)) |
| 177 | } | 211 | } |
| ... | @@ -180,6 +214,8 @@ extension CouponsView { | ... | @@ -180,6 +214,8 @@ extension CouponsView { |
| 180 | .padding(.bottom, self.uiscreen.height * 0.03) | 214 | .padding(.bottom, self.uiscreen.height * 0.03) |
| 181 | VStack { | 215 | VStack { |
| 182 | Text(CouponsView.couponView.localizedWithParameter(parameter: result["short_description"] as! String)) | 216 | Text(CouponsView.couponView.localizedWithParameter(parameter: result["short_description"] as! String)) |
| 217 | + .fontWeight(.medium) | ||
| 218 | + .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) | ||
| 183 | .frame(maxWidth: self.uiscreen.width * 0.22, maxHeight: self.uiscreen.height * 0.10) | 219 | .frame(maxWidth: self.uiscreen.width * 0.22, maxHeight: self.uiscreen.height * 0.10) |
| 184 | .font(.system(size: 10)) | 220 | .font(.system(size: 10)) |
| 185 | } | 221 | } |
| ... | @@ -187,6 +223,7 @@ extension CouponsView { | ... | @@ -187,6 +223,7 @@ extension CouponsView { |
| 187 | Spacer() | 223 | Spacer() |
| 188 | } | 224 | } |
| 189 | } | 225 | } |
| 226 | + } | ||
| 190 | .frame(width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.13) | 227 | .frame(width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.13) |
| 191 | .background( | 228 | .background( |
| 192 | Image("coupons_container", bundle: Bundle(for: MyEmptyClass.self)) | 229 | Image("coupons_container", bundle: Bundle(for: MyEmptyClass.self)) |
| ... | @@ -223,7 +260,8 @@ struct CouponsView: View { | ... | @@ -223,7 +260,8 @@ struct CouponsView: View { |
| 223 | VStack { | 260 | VStack { |
| 224 | if (data.count) > 0 { | 261 | if (data.count) > 0 { |
| 225 | ForEach(Array(zip(data.indices, data)), id: \.0) { index, result in | 262 | ForEach(Array(zip(data.indices, data)), id: \.0) { index, result in |
| 226 | - couponView(result: result, index: index) } | 263 | + couponView(result: result, index: index, parentView: parentView) |
| 264 | + } | ||
| 227 | } | 265 | } |
| 228 | } | 266 | } |
| 229 | .padding(.top, self.uiscreen.height * 0.05) | 267 | .padding(.top, self.uiscreen.height * 0.05) | ... | ... |
| ... | @@ -21,6 +21,8 @@ | ... | @@ -21,6 +21,8 @@ |
| 21 | - (UIViewController *) openCoupon:(UIView*) parentView coupon:(NSDictionary*) coupon; | 21 | - (UIViewController *) openCoupon:(UIView*) parentView coupon:(NSDictionary*) coupon; |
| 22 | - (UIViewController *) openCouponBarcode:(UIView*) parentView coupon:(NSDictionary*) coupon; | 22 | - (UIViewController *) openCouponBarcode:(UIView*) parentView coupon:(NSDictionary*) coupon; |
| 23 | - (UIViewController *) openGifts:(UIView*) parentView; | 23 | - (UIViewController *) openGifts:(UIView*) parentView; |
| 24 | +- (UIViewController *) openAllGifts:(UIView*) parentView; | ||
| 25 | +- (UIViewController *) openOldCoupons:(UIView*) parentView; | ||
| 24 | - (UIViewController *) openWallet:(UIView*) parentView; | 26 | - (UIViewController *) openWallet:(UIView*) parentView; |
| 25 | - (UIViewController *) openMoreForYou:(UIView*) parentView; | 27 | - (UIViewController *) openMoreForYou:(UIView*) parentView; |
| 26 | - (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign; | 28 | - (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign; | ... | ... |
| ... | @@ -71,6 +71,18 @@ NSString *LANG; | ... | @@ -71,6 +71,18 @@ NSString *LANG; |
| 71 | return giftsViewController; | 71 | return giftsViewController; |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | +- (UIViewController *) openAllGifts:(UIView*) parentView{ | ||
| 75 | + | ||
| 76 | + UIViewController *allGiftsViewController = [AllGiftsViewInterface allGiftsViewController:parentView]; | ||
| 77 | + return allGiftsViewController; | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +- (UIViewController *) openOldCoupons:(UIView*) parentView{ | ||
| 81 | + | ||
| 82 | + UIViewController *oldCouponsViewController = [OldCouponsViewInterface oldCouponsViewController:parentView]; | ||
| 83 | + return oldCouponsViewController; | ||
| 84 | +} | ||
| 85 | + | ||
| 74 | - (UIViewController *) openWallet:(UIView*) parentView{ | 86 | - (UIViewController *) openWallet:(UIView*) parentView{ |
| 75 | 87 | ||
| 76 | UIViewController *wallletViewController = [WalletViewInterface walletViewController:parentView]; | 88 | UIViewController *wallletViewController = [WalletViewInterface walletViewController:parentView]; | ... | ... |
| 1 | +// | ||
| 2 | +// OldCouponsView.swift | ||
| 3 | +// WarplySDKFrameworkIOS | ||
| 4 | +// | ||
| 5 | +// Created by Manos Chorianopoulos on 28/4/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +#if canImport(SwiftUI) | ||
| 9 | +import SwiftUI | ||
| 10 | +import Combine | ||
| 11 | +import Foundation | ||
| 12 | +import UIKit | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +extension OldCouponsView { | ||
| 16 | + struct headerView: View { | ||
| 17 | + var goBack: () -> () | ||
| 18 | + | ||
| 19 | + var uiscreen = UIScreen.main.bounds | ||
| 20 | + | ||
| 21 | + var body: some View { | ||
| 22 | + HStack(alignment: .center) { | ||
| 23 | + Button { | ||
| 24 | + // Button Action | ||
| 25 | + print("Back Button tapped!") | ||
| 26 | + goBack() | ||
| 27 | + } label: { | ||
| 28 | + Image("ic_back", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 29 | + .resizable() | ||
| 30 | + .aspectRatio(contentMode: .fit) | ||
| 31 | + .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02) | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + Text("Παλαιότερα κουπόνια") | ||
| 35 | + .fontWeight(.medium) | ||
| 36 | + .font(.system(size: 16)) | ||
| 37 | + .foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196)) | ||
| 38 | + .multilineTextAlignment(.center) | ||
| 39 | + .frame(maxWidth: .infinity) | ||
| 40 | + .padding(.horizontal) | ||
| 41 | + | ||
| 42 | + Button { | ||
| 43 | + // Button Action | ||
| 44 | + print("Wallet tapped!") | ||
| 45 | + } label: { | ||
| 46 | + Image("ic_wallet", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 47 | + .resizable() | ||
| 48 | + .aspectRatio(contentMode: .fit) | ||
| 49 | + .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04) | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | + .frame(maxWidth: .infinity) | ||
| 53 | + .padding(.horizontal) | ||
| 54 | + .padding(.vertical, 10) | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + struct ImageView: View { | ||
| 59 | + @ObservedObject var imageLoader:UrlImageModel | ||
| 60 | + @State var width:CGFloat | ||
| 61 | + @State var isFill:Bool | ||
| 62 | + | ||
| 63 | + var uiscreen = UIScreen.main.bounds | ||
| 64 | + | ||
| 65 | + init(withURL url:String , width:CGFloat, isFill:Bool) { | ||
| 66 | + imageLoader = UrlImageModel(urlString:url) | ||
| 67 | + self.width = width | ||
| 68 | + self.isFill = isFill | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + var body: some View { | ||
| 72 | + | ||
| 73 | + Image(uiImage: imageLoader.image ?? UIImage()) | ||
| 74 | + .resizable() | ||
| 75 | + .aspectRatio(contentMode: isFill ? .fill : .fit) | ||
| 76 | + .frame(width: self.width) | ||
| 77 | + .frame(maxHeight: .infinity) | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + struct couponItemView: View { | ||
| 82 | + var item: NSDictionary | ||
| 83 | + var parentView: UIView | ||
| 84 | + | ||
| 85 | + var uiscreen = UIScreen.main.bounds | ||
| 86 | + | ||
| 87 | + var body: some View { | ||
| 88 | + let couponData = item["coupon_data"] as? [String: Any] ?? ["":""] | ||
| 89 | + | ||
| 90 | + Button { | ||
| 91 | + // Coupon Action | ||
| 92 | + print("Coupon tapped!") | ||
| 93 | +// let instanceOfMyApi = MyApi() | ||
| 94 | +// let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: item as! [String : Any])! | ||
| 95 | +// couponBarcodeViewController.view.tag = 7 | ||
| 96 | +//// addChild(couponsViewController) | ||
| 97 | +// couponBarcodeViewController.view.frame = parentView.frame | ||
| 98 | +// parentView.addSubview(couponBarcodeViewController.view) | ||
| 99 | +// couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self)) | ||
| 100 | + } label: { | ||
| 101 | + | ||
| 102 | + HStack(alignment: .center) { | ||
| 103 | + | ||
| 104 | + ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.15, isFill: false) | ||
| 105 | + | ||
| 106 | + VLine() | ||
| 107 | + .stroke(style: StrokeStyle(lineWidth: 1, dash: [5])) | ||
| 108 | + .foregroundColor(Color(red: 0.4392156862745098, green: 0.4392156862745098, blue: 0.4392156862745098)) | ||
| 109 | + .frame(width: 1) | ||
| 110 | + .padding(.leading, 10) | ||
| 111 | + | ||
| 112 | + VStack(alignment: .leading, spacing: 5.0) { | ||
| 113 | + Text(item["name"] as? String ?? "") | ||
| 114 | + .fontWeight(.medium) | ||
| 115 | + .font(.system(size: 16)) | ||
| 116 | + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | ||
| 117 | + .multilineTextAlignment(.leading) | ||
| 118 | +// .lineLimit(1) | ||
| 119 | + | ||
| 120 | + HStack(alignment: .center) { | ||
| 121 | + Text((couponData["discount"] as? String ?? "")+"€") | ||
| 122 | + .fontWeight(.bold) | ||
| 123 | + .font(.system(size: 35)) | ||
| 124 | + .foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4)) | ||
| 125 | + .multilineTextAlignment(.leading) | ||
| 126 | + .lineLimit(1) | ||
| 127 | + | ||
| 128 | +// Text(item["short_description"] as? String ?? "") | ||
| 129 | +// .fontWeight(.medium) | ||
| 130 | +// .font(.system(size: 11)) | ||
| 131 | +// .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) | ||
| 132 | +// .multilineTextAlignment(.leading) | ||
| 133 | +// .lineLimit(3) | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + Text("Εξαργυρώθηκε την " + OldCouponsView.couponsContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? "")) | ||
| 137 | + .fontWeight(.medium) | ||
| 138 | + .font(.system(size: 11)) | ||
| 139 | + .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764)) | ||
| 140 | + .multilineTextAlignment(.leading) | ||
| 141 | + } | ||
| 142 | + .padding(.all, 10) | ||
| 143 | + | ||
| 144 | + Spacer() | ||
| 145 | + | ||
| 146 | + } | ||
| 147 | + .padding(.leading, 28) | ||
| 148 | + .padding(.trailing) | ||
| 149 | + } | ||
| 150 | + .frame(width: self.uiscreen.width * 0.9, height: self.uiscreen.height * 0.14) | ||
| 151 | +// .cornerRadius(5) | ||
| 152 | +// .shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 30, x: 0, y: 3) | ||
| 153 | + .background( | ||
| 154 | + Image("coupon_bg", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 155 | + .resizable(resizingMode: .stretch) | ||
| 156 | + .frame(maxWidth: .infinity, maxHeight: .infinity) | ||
| 157 | + .colorMultiply(Color(red: 0.8901960784313725, green: 0.8901960784313725, blue: 0.8901960784313725)) | ||
| 158 | + ) | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + struct VLine: Shape { | ||
| 163 | + func path(in rect: CGRect) -> Path { | ||
| 164 | + Path { path in | ||
| 165 | + path.move(to: CGPoint(x: rect.midX, y: rect.minY)) | ||
| 166 | + path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY)) | ||
| 167 | + } | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + struct couponsContainer: View { | ||
| 172 | + @State var coupons:Array<NSDictionary> = [] | ||
| 173 | + @State var parentView:UIView | ||
| 174 | + | ||
| 175 | + var uiscreen = UIScreen.main.bounds | ||
| 176 | + | ||
| 177 | + static func convertDateFormat(inputDate: String) -> String { | ||
| 178 | + let dateFormatter = DateFormatter() | ||
| 179 | + dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss" | ||
| 180 | + if let date = dateFormatter.date(from: inputDate) { | ||
| 181 | + dateFormatter.dateFormat = "dd/MM/yyyy" | ||
| 182 | + let resultString = dateFormatter.string(from: date) | ||
| 183 | + return resultString | ||
| 184 | + } else { | ||
| 185 | + return "" | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + var body: some View { | ||
| 190 | + VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) { | ||
| 191 | + | ||
| 192 | + ForEach(Array(coupons.enumerated()), id: \.offset) { index, item in | ||
| 193 | + | ||
| 194 | + couponItemView(item: item, parentView: parentView) | ||
| 195 | + } | ||
| 196 | + } | ||
| 197 | + .frame(maxWidth: .infinity) | ||
| 198 | + .padding(.top, self.uiscreen.height * 0.05) | ||
| 199 | + .padding(.bottom, self.uiscreen.height * 0.1) | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | +} | ||
| 204 | + | ||
| 205 | +@available(iOS 13.0.0, *) | ||
| 206 | +struct OldCouponsView: View { | ||
| 207 | + var parentView: UIView | ||
| 208 | + | ||
| 209 | + var coupons:Array<NSDictionary> = DataModel().getOldCoupons | ||
| 210 | + | ||
| 211 | + var uiscreen = UIScreen.main.bounds | ||
| 212 | + | ||
| 213 | + func goBack(){ | ||
| 214 | + for subview in parentView.subviews { | ||
| 215 | + if(subview.tag == 9) { | ||
| 216 | + subview.removeFromSuperview() | ||
| 217 | + } | ||
| 218 | + } | ||
| 219 | + } | ||
| 220 | + | ||
| 221 | + var body: some View { | ||
| 222 | + VStack { | ||
| 223 | + headerView(goBack: goBack) | ||
| 224 | + | ||
| 225 | + VStack { | ||
| 226 | + ScrollView(showsIndicators: false) { | ||
| 227 | + VStack { | ||
| 228 | + | ||
| 229 | + if (coupons.count) > 0 { | ||
| 230 | + couponsContainer(coupons: coupons, parentView: parentView ) | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + } | ||
| 234 | + .frame(width:self.uiscreen.width) | ||
| 235 | + } | ||
| 236 | + .cornerRadius(30, corners: [.topLeft]) | ||
| 237 | + .frame(width:self.uiscreen.width) | ||
| 238 | + .frame(maxHeight: .infinity) | ||
| 239 | + } | ||
| 240 | + .frame(width:self.uiscreen.width) | ||
| 241 | + .frame(maxHeight: .infinity) | ||
| 242 | + .padding(.top, 5) | ||
| 243 | + .background( | ||
| 244 | + Image("coupons_scrollview", bundle: Bundle(for: MyEmptyClass.self)) | ||
| 245 | + .resizable() | ||
| 246 | + ) | ||
| 247 | + | ||
| 248 | + } | ||
| 249 | + .edgesIgnoringSafeArea([.bottom]) | ||
| 250 | + .frame(width:self.uiscreen.width) | ||
| 251 | + .frame(maxHeight: .infinity) | ||
| 252 | + } | ||
| 253 | +} | ||
| 254 | +#endif | ||
| 255 | + | ||
| 256 | +//struct OldCouponsView_Previews: PreviewProvider { | ||
| 257 | +// static var previews: some View { | ||
| 258 | +// OldCouponsView() | ||
| 259 | +// } | ||
| 260 | +//} |
| 1 | +// | ||
| 2 | +// OldCouponsViewInterface.swift | ||
| 3 | +// WarplySDKFrameworkIOS | ||
| 4 | +// | ||
| 5 | +// Created by Manos Chorianopoulos on 28/4/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | + | ||
| 9 | +import Foundation | ||
| 10 | +import SwiftUI | ||
| 11 | + | ||
| 12 | +@available(iOS 13.0.0, *) | ||
| 13 | +@objc public class OldCouponsViewInterface : NSObject { | ||
| 14 | + | ||
| 15 | + @objc(oldCouponsViewController:) static public func oldCouponsViewController(parentView: UIView?) -> UIViewController { | ||
| 16 | + return UIHostingController(rootView: OldCouponsView(parentView: parentView!)) | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | +} |
-
Please register or login to post a comment