Manos Chorianopoulos

delete unnecessary files and code, add openSuperMarketsFlow function

Showing 416 changed files with 155 additions and 16047 deletions
......@@ -7,39 +7,11 @@
objects = {
/* Begin PBXBuildFile section */
1E029A4129E002CF00CC7447 /* UnifiedCouponBCHeaderTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E029A4029E002CF00CC7447 /* UnifiedCouponBCHeaderTableViewCell.swift */; };
1E029A4329E0031600CC7447 /* UnifiedCouponBCFooterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E029A4229E0031600CC7447 /* UnifiedCouponBCFooterTableViewCell.swift */; };
1E108A9228A3F9280008B8E7 /* pf_square_sans_pro_regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A8D28A3F9270008B8E7 /* pf_square_sans_pro_regular.ttf */; };
1E108A9328A3F9280008B8E7 /* pf_square_sans_pro_medium.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A8E28A3F9280008B8E7 /* pf_square_sans_pro_medium.ttf */; };
1E108A9428A3F9280008B8E7 /* pf_square_sans_pro_extra_black.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A8F28A3F9280008B8E7 /* pf_square_sans_pro_extra_black.ttf */; };
1E108A9528A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9028A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf */; };
1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */; };
1E151F1829DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */; };
1E151F1A29DAE4D500951FA0 /* ActiveCodeTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */; };
1E15B9A229DDCF02000A408D /* MarketSharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */; };
1E15B9A429DDD211000A408D /* MarketHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E15B9A329DDD211000A408D /* MarketHistoryViewController.swift */; };
1E2966EA2837A21D00F83FAC /* RSBarcodes_Swift in Frameworks */ = {isa = PBXBuildFile; productRef = 1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */; };
1E36E43D2CBFDD5100A60198 /* PopupInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E36E43C2CBFDD5100A60198 /* PopupInfoViewController.swift */; };
1E4195FB2AE691D20094DADE /* WalletActiveCouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4195FA2AE691D20094DADE /* WalletActiveCouponsTableViewCell.swift */; };
1E4410B128F5855000859F92 /* CampaignCategory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E4410B028F5855000859F92 /* CampaignCategory.swift */; };
1E46B4BF2BEBB68800D5B488 /* WalletActiveCouponsScrollTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E46B4BE2BEBB68800D5B488 /* WalletActiveCouponsScrollTableViewCell.swift */; };
1E46B4C12BEBBDD800D5B488 /* WalletActiveCouponCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E46B4C02BEBBDD800D5B488 /* WalletActiveCouponCollectionViewCell.swift */; };
1E479FB329DD948B00C38193 /* WalletBadgesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E479FB229DD948B00C38193 /* WalletBadgesTableViewCell.swift */; };
1E51678E2AE6934100FE66C3 /* WalletVouchersBannerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E51678D2AE6934100FE66C3 /* WalletVouchersBannerTableViewCell.swift */; };
1E56DF732CC249B300F71882 /* MerchantTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E56DF722CC249B300F71882 /* MerchantTableViewCell.swift */; };
1E56DF752CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E56DF742CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift */; };
1E64E8FD2B8DE457001BA46E /* WalletQuestionnaireBannerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E64E8FC2B8DE457001BA46E /* WalletQuestionnaireBannerTableViewCell.swift */; };
1E64E8FF2B8DE487001BA46E /* WalletHistoryBannerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E64E8FE2B8DE487001BA46E /* WalletHistoryBannerTableViewCell.swift */; };
1E64E9012B8DE4AC001BA46E /* WalletEmptyViewTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E64E9002B8DE4AC001BA46E /* WalletEmptyViewTableViewCell.swift */; };
1E6515D52D36A4C300AD80C6 /* MarketAnalysisItemViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E6515D42D36A4C300AD80C6 /* MarketAnalysisItemViewCell.swift */; };
1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */; };
1E7B9A5829F6ACF400B37E13 /* WalletBannersTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7B9A5729F6ACF400B37E13 /* WalletBannersTableViewCell.swift */; };
1E87A9EF28C2021200C79F90 /* ContextualViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */; };
1EA04EC12AE7FCE800389A84 /* WalletSpinnerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA04EC02AE7FCE700389A84 /* WalletSpinnerTableViewCell.swift */; };
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */; };
1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */; };
1EA771AC290977CA0030924C /* CopyableLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA771AB290977CA0030924C /* CopyableLabel.swift */; };
1EAEFC7A29DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EAEFC7929DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift */; };
1EB15E6C29E45F5100654657 /* PeridotPE-SemiBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1EB15E6329E45F5100654657 /* PeridotPE-SemiBold.ttf */; };
1EB15E6D29E45F5100654657 /* PeridotPE-ExtraBoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1EB15E6429E45F5100654657 /* PeridotPE-ExtraBoldItalic.ttf */; };
1EB15E6E29E45F5100654657 /* PeridotPE-SemiBoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1EB15E6529E45F5100654657 /* PeridotPE-SemiBoldItalic.ttf */; };
......@@ -49,47 +21,16 @@
1EB15E7229E45F5100654657 /* PeridotPE-BoldItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1EB15E6929E45F5100654657 /* PeridotPE-BoldItalic.ttf */; };
1EB15E7329E45F5100654657 /* PeridotPE-ExtraBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1EB15E6A29E45F5100654657 /* PeridotPE-ExtraBold.ttf */; };
1EB15E7429E45F5100654657 /* PeridotPE-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1EB15E6B29E45F5100654657 /* PeridotPE-Regular.ttf */; };
1EB236AB28816B680063777A /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AA28816B680063777A /* ShareViewController.swift */; };
1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AC28816C560063777A /* NumberPopupViewController.swift */; };
1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */; };
1EB5F4C828536FD60016F36E /* StepsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C728536FD60016F36E /* StepsViewController.swift */; };
1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */; };
1EBC75432922829D004FBE75 /* SpinnerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBC75422922829D004FBE75 /* SpinnerViewController.swift */; };
1EBE97212865EE460080EFF7 /* MFYInboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */; };
1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBF5F062840E13F00B8B17F /* SwiftEventBus */; };
1ECA079128D9E3BA00D2BDE0 /* CSMButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */; };
1ECA079428D9E53F00D2BDE0 /* MapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */; };
1ECA079528D9E53F00D2BDE0 /* MapsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */; };
1ECA079728D9E66200D2BDE0 /* MerchantAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */; };
1EDAF23F2D36B59200894144 /* MarketPassViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDAF23E2D36B59200894144 /* MarketPassViewController.swift */; };
1EDAF2412D36B5B100894144 /* MarketPassInfoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDAF2402D36B5B000894144 /* MarketPassInfoViewController.swift */; };
1EDCB47A29DEEC2E00DF218B /* UnifiedCouponBarcodeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDCB47929DEEC2E00DF218B /* UnifiedCouponBarcodeViewController.swift */; };
1EDCDFAC28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */; };
1EDD4F892AE937AA00A6B5A6 /* LoyaltyHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EDD4F882AE937AA00A6B5A6 /* LoyaltyHistoryViewController.swift */; };
1EE67DA32AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EE67DA22AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift */; };
1EEC5C582CC15C4600CF3CAC /* PopupMerchantsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EEC5C572CC15C4600CF3CAC /* PopupMerchantsViewController.swift */; };
1EFBAB942CC65C9B001DFF75 /* PopupMerchantCategoriesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EFBAB932CC65C9B001DFF75 /* PopupMerchantCategoriesViewController.swift */; };
7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; };
A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02F34042882B6E60086465F /* TelcoViewController.swift */; };
A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A04D31DD288FF670000E43B5 /* HistoryViewController.swift */; };
A079366E2885D07700064122 /* AnalysisChildViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079366D2885D07700064122 /* AnalysisChildViewController.swift */; };
A07936702885D95600064122 /* AnalysisItemViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079366F2885D95600064122 /* AnalysisItemViewCell.swift */; };
A07936732885E67400064122 /* AnalysisItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = A07936722885E67400064122 /* AnalysisItem.swift */; };
A07936762885E9CC00064122 /* UIColorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A07936752885E9CC00064122 /* UIColorExtensions.swift */; };
A079367C2885F2F500064122 /* AnalysisHeaderViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */; };
A079367E2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */; };
A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */; };
E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; };
E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; };
E6A778DF282933E60045BBA8 /* WarplyReactMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = E6A7785B282933E40045BBA8 /* WarplyReactMethods.m */; };
E6A778E0282933E60045BBA8 /* WarplyReactMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A7785C282933E40045BBA8 /* WarplyReactMethods.h */; };
E6A778E1282933E60045BBA8 /* CouponViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A7785D282933E40045BBA8 /* CouponViewController.swift */; };
E6A778E2282933E60045BBA8 /* CouponsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A7785E282933E40045BBA8 /* CouponsViewController.swift */; };
E6A778E3282933E60045BBA8 /* WalletViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A7785F282933E40045BBA8 /* WalletViewController.swift */; };
E6A778E4282933E60045BBA8 /* MyApi.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77860282933E40045BBA8 /* MyApi.h */; settings = {ATTRIBUTES = (Public, ); }; };
E6A778E5282933E60045BBA8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E6A77861282933E50045BBA8 /* Main.storyboard */; };
E6A778E6282933E60045BBA8 /* MyEmptyClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A77862282933E50045BBA8 /* MyEmptyClass.swift */; };
E6A778E7282933E60045BBA8 /* DetailsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A77863282933E50045BBA8 /* DetailsViewController.swift */; };
E6A778E9282933E60045BBA8 /* WLNativeAdCollectionViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77867282933E50045BBA8 /* WLNativeAdCollectionViewCell.h */; };
E6A778EA282933E60045BBA8 /* WLNativeVideoTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E6A77868282933E50045BBA8 /* WLNativeVideoTableViewCell.xib */; };
E6A778EB282933E60045BBA8 /* WLNativeAdTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77869282933E50045BBA8 /* WLNativeAdTableViewCell.h */; };
......@@ -196,51 +137,20 @@
E6A77950282933E70045BBA8 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = E6A778D8282933E60045BBA8 /* FMResultSet.m */; };
E6A77951282933E70045BBA8 /* WLEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A778D9282933E60045BBA8 /* WLEvent.h */; };
E6A77952282933E70045BBA8 /* Warply.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A778DA282933E60045BBA8 /* Warply.h */; };
E6A77953282933E70045BBA8 /* MFYViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A778DB282933E60045BBA8 /* MFYViewController.swift */; };
E6A77954282933E70045BBA8 /* MyApi.m in Sources */ = {isa = PBXBuildFile; fileRef = E6A778DC282933E60045BBA8 /* MyApi.m */; };
E6A77955282933E70045BBA8 /* ViewControllerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A778DD282933E60045BBA8 /* ViewControllerExtensions.swift */; };
E6A77956282933E70045BBA8 /* GiftsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A778DE282933E60045BBA8 /* GiftsViewController.swift */; };
E6A7795A28293D390045BBA8 /* swiftApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A77864282933E50045BBA8 /* swiftApi.swift */; };
E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A77A31282BA9C60045BBA8 /* CampaignViewController.swift */; };
E6A77A34282BB3BB0045BBA8 /* ActiveGiftsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A77A33282BB3BB0045BBA8 /* ActiveGiftsViewController.swift */; };
E6A77A36282BB4CB0045BBA8 /* MakeItAPresentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */; };
E6A77A38282BC3530045BBA8 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E6A77A37282BC3530045BBA8 /* Media.xcassets */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
1E029A4029E002CF00CC7447 /* UnifiedCouponBCHeaderTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponBCHeaderTableViewCell.swift; sourceTree = "<group>"; };
1E029A4229E0031600CC7447 /* UnifiedCouponBCFooterTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponBCFooterTableViewCell.swift; sourceTree = "<group>"; };
1E108A8D28A3F9270008B8E7 /* pf_square_sans_pro_regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_regular.ttf; sourceTree = "<group>"; };
1E108A8E28A3F9280008B8E7 /* pf_square_sans_pro_medium.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_medium.ttf; sourceTree = "<group>"; };
1E108A8F28A3F9280008B8E7 /* pf_square_sans_pro_extra_black.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_extra_black.ttf; sourceTree = "<group>"; };
1E108A9028A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_bold_italic.ttf; sourceTree = "<group>"; };
1E108A9128A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = pf_square_sans_pro_bold.ttf; sourceTree = "<group>"; };
1E108A9728A3FA9B0008B8E7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponsTableViewCell.swift; sourceTree = "<group>"; };
1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveCodeTableViewCell.swift; sourceTree = "<group>"; };
1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketSharingHistoryViewController.swift; sourceTree = "<group>"; };
1E15B9A329DDD211000A408D /* MarketHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketHistoryViewController.swift; sourceTree = "<group>"; };
1E36E43C2CBFDD5100A60198 /* PopupInfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopupInfoViewController.swift; sourceTree = "<group>"; };
1E4195FA2AE691D20094DADE /* WalletActiveCouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletActiveCouponsTableViewCell.swift; sourceTree = "<group>"; };
1E4410B028F5855000859F92 /* CampaignCategory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignCategory.swift; sourceTree = "<group>"; };
1E46B4BE2BEBB68800D5B488 /* WalletActiveCouponsScrollTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletActiveCouponsScrollTableViewCell.swift; sourceTree = "<group>"; };
1E46B4C02BEBBDD800D5B488 /* WalletActiveCouponCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletActiveCouponCollectionViewCell.swift; sourceTree = "<group>"; };
1E479FB229DD948B00C38193 /* WalletBadgesTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletBadgesTableViewCell.swift; sourceTree = "<group>"; };
1E51678D2AE6934100FE66C3 /* WalletVouchersBannerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletVouchersBannerTableViewCell.swift; sourceTree = "<group>"; };
1E56DF722CC249B300F71882 /* MerchantTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantTableViewCell.swift; sourceTree = "<group>"; };
1E56DF742CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopupMerchantsFooterTableViewCell.swift; sourceTree = "<group>"; };
1E64E8FC2B8DE457001BA46E /* WalletQuestionnaireBannerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletQuestionnaireBannerTableViewCell.swift; sourceTree = "<group>"; };
1E64E8FE2B8DE487001BA46E /* WalletHistoryBannerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletHistoryBannerTableViewCell.swift; sourceTree = "<group>"; };
1E64E9002B8DE4AC001BA46E /* WalletEmptyViewTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletEmptyViewTableViewCell.swift; sourceTree = "<group>"; };
1E6515D42D36A4C300AD80C6 /* MarketAnalysisItemViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketAnalysisItemViewCell.swift; sourceTree = "<group>"; };
1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewController.swift; sourceTree = "<group>"; };
1E7B9A5729F6ACF400B37E13 /* WalletBannersTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletBannersTableViewCell.swift; sourceTree = "<group>"; };
1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContextualViewController.swift; sourceTree = "<group>"; };
1EA04EC02AE7FCE700389A84 /* WalletSpinnerTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletSpinnerTableViewCell.swift; sourceTree = "<group>"; };
1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponsTableViewCell.swift; sourceTree = "<group>"; };
1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InboxTableViewCell.swift; sourceTree = "<group>"; };
1EA771AB290977CA0030924C /* CopyableLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CopyableLabel.swift; sourceTree = "<group>"; };
1EAEFC7929DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketLoyaltyAnalysisViewController.swift; sourceTree = "<group>"; };
1EB15E6329E45F5100654657 /* PeridotPE-SemiBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "PeridotPE-SemiBold.ttf"; sourceTree = "<group>"; };
1EB15E6429E45F5100654657 /* PeridotPE-ExtraBoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "PeridotPE-ExtraBoldItalic.ttf"; sourceTree = "<group>"; };
1EB15E6529E45F5100654657 /* PeridotPE-SemiBoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "PeridotPE-SemiBoldItalic.ttf"; sourceTree = "<group>"; };
......@@ -250,34 +160,7 @@
1EB15E6929E45F5100654657 /* PeridotPE-BoldItalic.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "PeridotPE-BoldItalic.ttf"; sourceTree = "<group>"; };
1EB15E6A29E45F5100654657 /* PeridotPE-ExtraBold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "PeridotPE-ExtraBold.ttf"; sourceTree = "<group>"; };
1EB15E6B29E45F5100654657 /* PeridotPE-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "PeridotPE-Regular.ttf"; sourceTree = "<group>"; };
1EB236AA28816B680063777A /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };
1EB236AC28816C560063777A /* NumberPopupViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberPopupViewController.swift; sourceTree = "<group>"; };
1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumbersTableViewCell.swift; sourceTree = "<group>"; };
1EB5F4C728536FD60016F36E /* StepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsViewController.swift; sourceTree = "<group>"; };
1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyAnalysisViewController.swift; sourceTree = "<group>"; };
1EBC75422922829D004FBE75 /* SpinnerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpinnerViewController.swift; sourceTree = "<group>"; };
1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFYInboxTableViewCell.swift; sourceTree = "<group>"; };
1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CSMButton.swift; sourceTree = "<group>"; };
1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = "<group>"; };
1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapsViewController.xib; sourceTree = "<group>"; };
1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantAnnotation.swift; sourceTree = "<group>"; };
1EDAF23E2D36B59200894144 /* MarketPassViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketPassViewController.swift; sourceTree = "<group>"; };
1EDAF2402D36B5B000894144 /* MarketPassInfoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarketPassInfoViewController.swift; sourceTree = "<group>"; };
1EDCB47929DEEC2E00DF218B /* UnifiedCouponBarcodeViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponBarcodeViewController.swift; sourceTree = "<group>"; };
1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisMoreViewCell.swift; sourceTree = "<group>"; };
1EDD4F882AE937AA00A6B5A6 /* LoyaltyHistoryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyHistoryViewController.swift; sourceTree = "<group>"; };
1EE67DA22AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedCouponsViewController.swift; sourceTree = "<group>"; };
1EEC5C572CC15C4600CF3CAC /* PopupMerchantsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopupMerchantsViewController.swift; sourceTree = "<group>"; };
1EFBAB932CC65C9B001DFF75 /* PopupMerchantCategoriesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PopupMerchantCategoriesViewController.swift; sourceTree = "<group>"; };
A02F34042882B6E60086465F /* TelcoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelcoViewController.swift; sourceTree = "<group>"; };
A04D31DD288FF670000E43B5 /* HistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = "<group>"; };
A079366D2885D07700064122 /* AnalysisChildViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisChildViewController.swift; sourceTree = "<group>"; };
A079366F2885D95600064122 /* AnalysisItemViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisItemViewCell.swift; sourceTree = "<group>"; };
A07936722885E67400064122 /* AnalysisItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisItem.swift; sourceTree = "<group>"; };
A07936752885E9CC00064122 /* UIColorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtensions.swift; sourceTree = "<group>"; };
A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderViewCell.swift; sourceTree = "<group>"; };
A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderMessageViewCell.swift; sourceTree = "<group>"; };
A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharingHistoryViewController.swift; sourceTree = "<group>"; };
A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; };
B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; };
C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWarplyFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -286,13 +169,9 @@
E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */ = {isa = PBXFileReference; lastKnownFileType = folder.documentationcatalog; path = SwiftWarplyFramework.docc; sourceTree = "<group>"; };
E6A7785B282933E40045BBA8 /* WarplyReactMethods.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WarplyReactMethods.m; sourceTree = "<group>"; };
E6A7785C282933E40045BBA8 /* WarplyReactMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WarplyReactMethods.h; sourceTree = "<group>"; };
E6A7785D282933E40045BBA8 /* CouponViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CouponViewController.swift; sourceTree = "<group>"; };
E6A7785E282933E40045BBA8 /* CouponsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CouponsViewController.swift; sourceTree = "<group>"; };
E6A7785F282933E40045BBA8 /* WalletViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletViewController.swift; sourceTree = "<group>"; };
E6A77860282933E40045BBA8 /* MyApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyApi.h; sourceTree = "<group>"; };
E6A77861282933E50045BBA8 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
E6A77862282933E50045BBA8 /* MyEmptyClass.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyEmptyClass.swift; sourceTree = "<group>"; };
E6A77863282933E50045BBA8 /* DetailsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailsViewController.swift; sourceTree = "<group>"; };
E6A77864282933E50045BBA8 /* swiftApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = swiftApi.swift; sourceTree = "<group>"; };
E6A77867282933E50045BBA8 /* WLNativeAdCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WLNativeAdCollectionViewCell.h; sourceTree = "<group>"; };
E6A77868282933E50045BBA8 /* WLNativeVideoTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = WLNativeVideoTableViewCell.xib; sourceTree = "<group>"; };
......@@ -400,13 +279,9 @@
E6A778D8282933E60045BBA8 /* FMResultSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMResultSet.m; sourceTree = "<group>"; };
E6A778D9282933E60045BBA8 /* WLEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WLEvent.h; sourceTree = "<group>"; };
E6A778DA282933E60045BBA8 /* Warply.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Warply.h; sourceTree = "<group>"; };
E6A778DB282933E60045BBA8 /* MFYViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MFYViewController.swift; sourceTree = "<group>"; };
E6A778DC282933E60045BBA8 /* MyApi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyApi.m; sourceTree = "<group>"; };
E6A778DD282933E60045BBA8 /* ViewControllerExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewControllerExtensions.swift; sourceTree = "<group>"; };
E6A778DE282933E60045BBA8 /* GiftsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GiftsViewController.swift; sourceTree = "<group>"; };
E6A77A31282BA9C60045BBA8 /* CampaignViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignViewController.swift; sourceTree = "<group>"; };
E6A77A33282BB3BB0045BBA8 /* ActiveGiftsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActiveGiftsViewController.swift; sourceTree = "<group>"; };
E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MakeItAPresentViewController.swift; sourceTree = "<group>"; };
E6A77A37282BC3530045BBA8 /* Media.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Media.xcassets; sourceTree = "<group>"; };
/* End PBXFileReference section */
......@@ -415,7 +290,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1E2966EA2837A21D00F83FAC /* RSBarcodes_Swift in Frameworks */,
7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */,
1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */,
);
......@@ -461,26 +335,6 @@
name = Frameworks;
sourceTree = "<group>";
};
A079366A2885CDDC00064122 /* analysis */ = {
isa = PBXGroup;
children = (
A079367A2885F2D100064122 /* cells */,
1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */,
A079366D2885D07700064122 /* AnalysisChildViewController.swift */,
A04D31DD288FF670000E43B5 /* HistoryViewController.swift */,
A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */,
);
name = analysis;
sourceTree = "<group>";
};
A07936712885E65C00064122 /* models */ = {
isa = PBXGroup;
children = (
A07936722885E67400064122 /* AnalysisItem.swift */,
);
name = models;
sourceTree = "<group>";
};
A07936742885E96A00064122 /* utilities */ = {
isa = PBXGroup;
children = (
......@@ -489,16 +343,6 @@
name = utilities;
sourceTree = "<group>";
};
A079367A2885F2D100064122 /* cells */ = {
isa = PBXGroup;
children = (
A079366F2885D95600064122 /* AnalysisItemViewCell.swift */,
A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */,
A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */,
);
name = cells;
sourceTree = "<group>";
};
C049E0423E2B72D796B777A3 /* Pods */ = {
isa = PBXGroup;
children = (
......@@ -529,65 +373,12 @@
E6A77850282933340045BBA8 /* SwiftWarplyFramework */ = {
isa = PBXGroup;
children = (
1EDCB47929DEEC2E00DF218B /* UnifiedCouponBarcodeViewController.swift */,
1E029A4029E002CF00CC7447 /* UnifiedCouponBCHeaderTableViewCell.swift */,
1E029A4229E0031600CC7447 /* UnifiedCouponBCFooterTableViewCell.swift */,
1E15B9A329DDD211000A408D /* MarketHistoryViewController.swift */,
1E6515D42D36A4C300AD80C6 /* MarketAnalysisItemViewCell.swift */,
1EBC75422922829D004FBE75 /* SpinnerViewController.swift */,
1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */,
1E108A9728A3FA9B0008B8E7 /* Info.plist */,
1E108A8B28A3F8FF0008B8E7 /* Resources */,
A02F34042882B6E60086465F /* TelcoViewController.swift */,
A07936712885E65C00064122 /* models */,
A079366A2885CDDC00064122 /* analysis */,
A07936742885E96A00064122 /* utilities */,
E6A7785E282933E40045BBA8 /* CouponsViewController.swift */,
1EE67DA22AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift */,
1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */,
E6A7785D282933E40045BBA8 /* CouponViewController.swift */,
1E151F1729DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift */,
1E151F1929DAE4D500951FA0 /* ActiveCodeTableViewCell.swift */,
1E74838C28378AF40042A589 /* CouponBarcodeViewController.swift */,
E6A77863282933E50045BBA8 /* DetailsViewController.swift */,
E6A778DE282933E60045BBA8 /* GiftsViewController.swift */,
1EA2BB782865BFE8003F2AB0 /* InboxTableViewCell.swift */,
1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */,
E6A778DB282933E60045BBA8 /* MFYViewController.swift */,
E6A7785F282933E40045BBA8 /* WalletViewController.swift */,
1EDAF23E2D36B59200894144 /* MarketPassViewController.swift */,
1EDAF2402D36B5B000894144 /* MarketPassInfoViewController.swift */,
E6A77A31282BA9C60045BBA8 /* CampaignViewController.swift */,
E6A77A33282BB3BB0045BBA8 /* ActiveGiftsViewController.swift */,
E6A77A35282BB4CB0045BBA8 /* MakeItAPresentViewController.swift */,
E6A7785A282933E40045BBA8 /* Helpers */,
E6A77861282933E50045BBA8 /* Main.storyboard */,
1E7B9A5729F6ACF400B37E13 /* WalletBannersTableViewCell.swift */,
1E4195FA2AE691D20094DADE /* WalletActiveCouponsTableViewCell.swift */,
1E46B4BE2BEBB68800D5B488 /* WalletActiveCouponsScrollTableViewCell.swift */,
1E46B4C02BEBBDD800D5B488 /* WalletActiveCouponCollectionViewCell.swift */,
1E51678D2AE6934100FE66C3 /* WalletVouchersBannerTableViewCell.swift */,
1EA04EC02AE7FCE700389A84 /* WalletSpinnerTableViewCell.swift */,
1E64E8FC2B8DE457001BA46E /* WalletQuestionnaireBannerTableViewCell.swift */,
1E64E8FE2B8DE487001BA46E /* WalletHistoryBannerTableViewCell.swift */,
1E64E9002B8DE4AC001BA46E /* WalletEmptyViewTableViewCell.swift */,
1EDD4F882AE937AA00A6B5A6 /* LoyaltyHistoryViewController.swift */,
1E15B9A129DDCF02000A408D /* MarketSharingHistoryViewController.swift */,
1EAEFC7929DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift */,
1E479FB229DD948B00C38193 /* WalletBadgesTableViewCell.swift */,
1EA771AB290977CA0030924C /* CopyableLabel.swift */,
1E4410B028F5855000859F92 /* CampaignCategory.swift */,
1EDCDFAB28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift */,
1E87A9EE28C2021200C79F90 /* ContextualViewController.swift */,
1EB236AA28816B680063777A /* ShareViewController.swift */,
1EB236AC28816C560063777A /* NumberPopupViewController.swift */,
1EB236AE28816CAB0063777A /* NumbersTableViewCell.swift */,
1EB5F4C728536FD60016F36E /* StepsViewController.swift */,
1E36E43C2CBFDD5100A60198 /* PopupInfoViewController.swift */,
1EEC5C572CC15C4600CF3CAC /* PopupMerchantsViewController.swift */,
1E56DF722CC249B300F71882 /* MerchantTableViewCell.swift */,
1E56DF742CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift */,
1EFBAB932CC65C9B001DFF75 /* PopupMerchantCategoriesViewController.swift */,
E6A77860282933E40045BBA8 /* MyApi.h */,
E6A778DC282933E60045BBA8 /* MyApi.m */,
E6A77862282933E50045BBA8 /* MyEmptyClass.swift */,
......@@ -597,9 +388,6 @@
E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */,
E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */,
E6A77A37282BC3530045BBA8 /* Media.xcassets */,
1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */,
1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */,
1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */,
);
path = SwiftWarplyFramework;
sourceTree = "<group>";
......@@ -897,7 +685,6 @@
);
name = SwiftWarplyFramework;
packageProductDependencies = (
1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */,
1EBF5F062840E13F00B8B17F /* SwiftEventBus */,
);
productName = SwiftWarplyFramework;
......@@ -929,7 +716,6 @@
);
mainGroup = E6A77844282933340045BBA8;
packageReferences = (
1E2966E82837A21D00F83FAC /* XCRemoteSwiftPackageReference "RSBarcodes_Swift" */,
1EBF5F052840E13F00B8B17F /* XCRemoteSwiftPackageReference "SwiftEventBus" */,
);
productRefGroup = E6A7784F282933340045BBA8 /* Products */;
......@@ -950,7 +736,6 @@
1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */,
1EB15E6D29E45F5100654657 /* PeridotPE-ExtraBoldItalic.ttf in Resources */,
1E108A9228A3F9280008B8E7 /* pf_square_sans_pro_regular.ttf in Resources */,
1ECA079528D9E53F00D2BDE0 /* MapsViewController.xib in Resources */,
E6A778EA282933E60045BBA8 /* WLNativeVideoTableViewCell.xib in Resources */,
1E108A9528A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf in Resources */,
E6A7790A282933E60045BBA8 /* warp_white_close_button.png in Resources */,
......@@ -1009,119 +794,58 @@
files = (
E6A7791E282933E60045BBA8 /* WLSMSActionHanlder.m in Sources */,
E6A778F5282933E60045BBA8 /* WLCustomNativeAdTableViewCell.m in Sources */,
1EB5F4C828536FD60016F36E /* StepsViewController.swift in Sources */,
A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */,
E6A77901282933E60045BBA8 /* WLBaseItem.m in Sources */,
1EE67DA32AE2AF2B0057C8CC /* UnifiedCouponsViewController.swift in Sources */,
1E74838D28378AF40042A589 /* CouponBarcodeViewController.swift in Sources */,
1E56DF732CC249B300F71882 /* MerchantTableViewCell.swift in Sources */,
1E479FB329DD948B00C38193 /* WalletBadgesTableViewCell.swift in Sources */,
1E151F1829DAE48500951FA0 /* UnifiedCouponsTableViewCell.swift in Sources */,
E6A778F0282933E60045BBA8 /* WLNativeAdsCollectionMode.m in Sources */,
1E6515D52D36A4C300AD80C6 /* MarketAnalysisItemViewCell.swift in Sources */,
E6A7791C282933E60045BBA8 /* WLSMSActionHandlerDeprecated.m in Sources */,
E6A77934282933E70045BBA8 /* UIActivityIndicatorView+AFNetworking.m in Sources */,
E6A77A34282BB3BB0045BBA8 /* ActiveGiftsViewController.swift in Sources */,
1E64E8FF2B8DE487001BA46E /* WalletHistoryBannerTableViewCell.swift in Sources */,
E6A778E6282933E60045BBA8 /* MyEmptyClass.swift in Sources */,
1E46B4C12BEBBDD800D5B488 /* WalletActiveCouponCollectionViewCell.swift in Sources */,
E6A77912282933E60045BBA8 /* WLAnalyticsManager.m in Sources */,
1EDAF2412D36B5B100894144 /* MarketPassInfoViewController.swift in Sources */,
E6A778E2282933E60045BBA8 /* CouponsViewController.swift in Sources */,
E6A77930282933E70045BBA8 /* UIImageView+AFNetworking.m in Sources */,
E6A77900282933E60045BBA8 /* WLInboxItemViewController.m in Sources */,
1E87A9EF28C2021200C79F90 /* ContextualViewController.swift in Sources */,
1EA04EC12AE7FCE800389A84 /* WalletSpinnerTableViewCell.swift in Sources */,
E6A7793E282933E70045BBA8 /* AFHTTPSessionManager.m in Sources */,
E6A77933282933E70045BBA8 /* UIButton+AFNetworking.m in Sources */,
E6A77919282933E60045BBA8 /* Warply.m in Sources */,
1E15B9A429DDD211000A408D /* MarketHistoryViewController.swift in Sources */,
E6A77953282933E70045BBA8 /* MFYViewController.swift in Sources */,
E6A7794B282933E70045BBA8 /* FMDatabase.m in Sources */,
1EDD4F892AE937AA00A6B5A6 /* LoyaltyHistoryViewController.swift in Sources */,
E6A778EC282933E60045BBA8 /* WLNativeVideoTableViewCell.m in Sources */,
E6A77954282933E70045BBA8 /* MyApi.m in Sources */,
A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */,
E6A778F2282933E60045BBA8 /* WLNativeAdCollectionViewCell.m in Sources */,
E6A77904282933E60045BBA8 /* WLEvent.m in Sources */,
E6A77927282933E70045BBA8 /* UIRefreshControl+AFNetworking.m in Sources */,
E6A77955282933E70045BBA8 /* ViewControllerExtensions.swift in Sources */,
A07936762885E9CC00064122 /* UIColorExtensions.swift in Sources */,
A079367C2885F2F500064122 /* AnalysisHeaderViewCell.swift in Sources */,
E6A7795A28293D390045BBA8 /* swiftApi.swift in Sources */,
1E51678E2AE6934100FE66C3 /* WalletVouchersBannerTableViewCell.swift in Sources */,
E6A77935282933E70045BBA8 /* UIWebView+AFNetworking.m in Sources */,
E6A77925282933E70045BBA8 /* UIProgressView+AFNetworking.m in Sources */,
E6A77944282933E70045BBA8 /* AFSecurityPolicy.m in Sources */,
1EA1AF0A2835346A008998AA /* CouponsTableViewCell.swift in Sources */,
1EAEFC7A29DDCAF500114A1C /* MarketLoyaltyAnalysisViewController.swift in Sources */,
E6A77A32282BA9C60045BBA8 /* CampaignViewController.swift in Sources */,
E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */,
1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */,
E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.m in Sources */,
1E4195FB2AE691D20094DADE /* WalletActiveCouponsTableViewCell.swift in Sources */,
1ECA079428D9E53F00D2BDE0 /* MapsViewController.swift in Sources */,
A07936702885D95600064122 /* AnalysisItemViewCell.swift in Sources */,
E6A77956282933E70045BBA8 /* GiftsViewController.swift in Sources */,
1ECA079728D9E66200D2BDE0 /* MerchantAnnotation.swift in Sources */,
1EBC75432922829D004FBE75 /* SpinnerViewController.swift in Sources */,
E6A778F1282933E60045BBA8 /* WLNativeAdTableViewCell.m in Sources */,
E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */,
E6A77938282933E70045BBA8 /* AFImageDownloader.m in Sources */,
E6A778ED282933E60045BBA8 /* WLCustomNativeCollectionViewCell.m in Sources */,
E6A7790D282933E60045BBA8 /* WLLocationManager.m in Sources */,
E6A7793D282933E70045BBA8 /* AFURLResponseSerialization.m in Sources */,
1EBE97212865EE460080EFF7 /* MFYInboxTableViewCell.swift in Sources */,
E6A778FD282933E60045BBA8 /* WLInboxItem.m in Sources */,
E6A778EE282933E60045BBA8 /* WLNativeAdsTableMode.m in Sources */,
A07936732885E67400064122 /* AnalysisItem.swift in Sources */,
1EDCB47A29DEEC2E00DF218B /* UnifiedCouponBarcodeViewController.swift in Sources */,
E6A778DF282933E60045BBA8 /* WarplyReactMethods.m in Sources */,
E6A77941282933E70045BBA8 /* AFURLRequestSerialization.m in Sources */,
E6A77915282933E60045BBA8 /* WLUtils.m in Sources */,
E6A77A36282BB4CB0045BBA8 /* MakeItAPresentViewController.swift in Sources */,
E6A77947282933E70045BBA8 /* FMDatabaseQueue.m in Sources */,
E6A77922282933E60045BBA8 /* NSData+SSToolkitAdditions.m in Sources */,
1EA771AC290977CA0030924C /* CopyableLabel.swift in Sources */,
1E56DF752CC2620000F71882 /* PopupMerchantsFooterTableViewCell.swift in Sources */,
1EB236AB28816B680063777A /* ShareViewController.swift in Sources */,
E6A778E7282933E60045BBA8 /* DetailsViewController.swift in Sources */,
1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */,
E6A7794A282933E70045BBA8 /* FMDatabaseAdditions.m in Sources */,
E6A77903282933E60045BBA8 /* WLAPSItem.m in Sources */,
1E64E9012B8DE4AC001BA46E /* WalletEmptyViewTableViewCell.swift in Sources */,
1E029A4129E002CF00CC7447 /* UnifiedCouponBCHeaderTableViewCell.swift in Sources */,
1EDAF23F2D36B59200894144 /* MarketPassViewController.swift in Sources */,
1ECA079128D9E3BA00D2BDE0 /* CSMButton.swift in Sources */,
1E4410B128F5855000859F92 /* CampaignCategory.swift in Sources */,
1E46B4BF2BEBB68800D5B488 /* WalletActiveCouponsScrollTableViewCell.swift in Sources */,
E6A7790B282933E60045BBA8 /* WLPushManager.m in Sources */,
1E15B9A229DDCF02000A408D /* MarketSharingHistoryViewController.swift in Sources */,
A079366E2885D07700064122 /* AnalysisChildViewController.swift in Sources */,
E6A77950282933E70045BBA8 /* FMResultSet.m in Sources */,
1E36E43D2CBFDD5100A60198 /* PopupInfoViewController.swift in Sources */,
1E151F1A29DAE4D500951FA0 /* ActiveCodeTableViewCell.swift in Sources */,
E6A77936282933E70045BBA8 /* AFAutoPurgingImageCache.m in Sources */,
A079367E2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift in Sources */,
1E64E8FD2B8DE457001BA46E /* WalletQuestionnaireBannerTableViewCell.swift in Sources */,
1E7B9A5829F6ACF400B37E13 /* WalletBannersTableViewCell.swift in Sources */,
E6A778FF282933E60045BBA8 /* WLBeacon.m in Sources */,
1E029A4329E0031600CC7447 /* UnifiedCouponBCFooterTableViewCell.swift in Sources */,
1EFBAB942CC65C9B001DFF75 /* PopupMerchantCategoriesViewController.swift in Sources */,
E6A7791A282933E60045BBA8 /* WLAPPActionHandler.m in Sources */,
E6A778E1282933E60045BBA8 /* CouponViewController.swift in Sources */,
E6A77924282933E70045BBA8 /* NSString+SSToolkitAdditions.m in Sources */,
A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */,
E6A7792A282933E70045BBA8 /* AFNetworkActivityIndicatorManager.m in Sources */,
E6A77914282933E60045BBA8 /* WLUserManager.m in Sources */,
1EEC5C582CC15C4600CF3CAC /* PopupMerchantsViewController.swift in Sources */,
1EB236AF28816CAC0063777A /* NumbersTableViewCell.swift in Sources */,
E6A7794F282933E70045BBA8 /* FMDatabasePool.m in Sources */,
1EB236AD28816C560063777A /* NumberPopupViewController.swift in Sources */,
E6A778E3282933E60045BBA8 /* WalletViewController.swift in Sources */,
E6A7790C282933E60045BBA8 /* WLBeaconManager.m in Sources */,
E6A77940282933E70045BBA8 /* AFURLSessionManager.m in Sources */,
1EDCDFAC28DB29E8002ED8F0 /* AnalysisMoreViewCell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -1347,14 +1071,6 @@
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
1E2966E82837A21D00F83FAC /* XCRemoteSwiftPackageReference "RSBarcodes_Swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/yeahdongcn/RSBarcodes_Swift";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.0.0;
};
};
1EBF5F052840E13F00B8B17F /* XCRemoteSwiftPackageReference "SwiftEventBus" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/cesarferreira/SwiftEventBus";
......@@ -1366,11 +1082,6 @@
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
1E2966E92837A21D00F83FAC /* RSBarcodes_Swift */ = {
isa = XCSwiftPackageProductDependency;
package = 1E2966E82837A21D00F83FAC /* XCRemoteSwiftPackageReference "RSBarcodes_Swift" */;
productName = RSBarcodes_Swift;
};
1EBF5F062840E13F00B8B17F /* SwiftEventBus */ = {
isa = XCSwiftPackageProductDependency;
package = 1EBF5F052840E13F00B8B17F /* XCRemoteSwiftPackageReference "SwiftEventBus" */;
......
{
"originHash" : "a973e37718e3a158b792c38b1b8ebf4fb41961343f7a99be3fa56123caed92c7",
"pins" : [
{
"identity" : "rsbarcodes_swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/yeahdongcn/RSBarcodes_Swift",
"state" : {
"revision" : "86d8b1a1439e7edb19793d17732b15fd784a0a15",
"version" : "5.1.1"
}
},
{
"identity" : "swifteventbus",
"kind" : "remoteSourceControl",
"location" : "https://github.com/cesarferreira/SwiftEventBus",
......@@ -19,5 +11,5 @@
}
}
],
"version" : 2
"version" : 3
}
......
//
// ActiveCodeTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 3/4/23.
//
import UIKit
@objc public class ActiveCodeTableViewCell: UITableViewCell {
@IBOutlet weak var activeCodeView: UIView!
@IBOutlet weak var activeCodeViewHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodesCountLabel: UILabel!
@IBOutlet weak var activeCodeLabel: UILabel!
@IBOutlet weak var activeCodeExpirationLabel: UILabel!
@IBOutlet weak var activeCodeImage: UIImageView!
@IBOutlet weak var activeCodeScrollView: UIScrollView!
@IBOutlet weak var activeCodeScrollViewHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodeContentView: UIView!
@IBOutlet weak var activeCodeContentViewHeight: NSLayoutConstraint!
public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
public override func awakeFromNib() {
super.awakeFromNib()
// TODO: DELETE ===>
// let coupon = swiftApi.ActiveDFYCouponModel()
// coupon._value = "12"
// // coupon._date = "2022-12-05 01:55:01"
// coupon._date = "2022-10-26 23:59:01"
// coupon._code = "123456789"
// let coupon2 = swiftApi.ActiveDFYCouponModel()
// coupon2._value = "23"
// coupon2._date = "2022-11-05 01:55"
// coupon2._code = "234567891"
// let coupon3 = swiftApi.ActiveDFYCouponModel()
// coupon3._value = "34"
// coupon3._date = "2022-07-01 01:55"
// coupon3._code = "345678912"
// let couponsArray: Array<swiftApi.ActiveDFYCouponModel> = [coupon, coupon2, coupon3, coupon3, coupon3]
// swiftApi().setActiveDFYCoupons(dfyCoupons: couponsArray)
// dfyCoupons = swiftApi().getActiveDFYCoupons()
// TODO: DELETE <===
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
activeCodeView.layer.cornerRadius = 16.5
// activeCodeView.layer.borderWidth = 1
// activeCodeView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
activeCodeImage.image = UIImage(named: "active_code_logo_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
if (dfyCoupons.count > 0) {
if (dfyCoupons.count == 1) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
// dateFormatter.dateFormat = "yyyy-MM-dd HH:mm"
// sort dfyCoupons by date
dfyCoupons.sort(by: {
let date1 = dateFormatter.date(from: $0._date)
let date2 = dateFormatter.date(from: $1._date)
if ((date1 != nil) && (date2 != nil)) {
return date1!.compare(date2!) == .orderedAscending
} else {
return false
}
})
// Get days from now of the most recet coupon
var daysFromNow = ""
let calendar = Calendar.current
// Replace the hour (time) of both dates with 00:00
let date1 = calendar.startOfDay(for: Date())
if let date2 = dateFormatter.date(from: dfyCoupons[0]._date) {
let components = calendar.dateComponents([.day], from: date1, to: date2)
daysFromNow = (components.day) != nil ? String((components.day ?? 0) + 1) : ""
}
activeCodesCountLabel.text = "Ενεργός κωδικός:"
// activeCodeLabel.text = dfyCoupons[0]._code
let newLabel = CopyableLabel()
newLabel.text = String(dfyCoupons[0]._code)
newLabel.font = UIFont(name: "PeridotPE-Bold", size: 18)
newLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
newLabel.frame.size.width = newLabel.intrinsicContentSize.width
newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight
activeCodeContentView.addSubview(newLabel)
// set the btn frame origin
newLabel.frame.origin.x = 0
newLabel.frame.origin.y = 0
let scrollHeight = newLabel.intrinsicContentSize.height
activeCodeContentViewHeight.constant = scrollHeight
activeCodeScrollViewHeight.constant = scrollHeight
activeCodeExpirationLabel.isHidden = false
if (daysFromNow == "1") {
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρα"
} else {
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρες"
}
} else {
var tagHeight:CGFloat = 30
let tagPadding: CGFloat = 0
let tagSpacingX: CGFloat = 0
let tagSpacingY: CGFloat = 2
let containerWidth = activeCodeContentView.frame.size.width
var currentOriginX: CGFloat = 0
var currentOriginY: CGFloat = 0
// var couponCodesString = ""
for (index, item) in dfyCoupons.enumerated() {
let newLabel = CopyableLabel()
newLabel.font = UIFont(name: "PeridotPE-Bold", size: 18)
newLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
if (index == (dfyCoupons.endIndex - 1)) {
// couponCodesString += String(item._code)
newLabel.text = String(item._code)
} else {
// couponCodesString += String(item._code) + ", "
newLabel.text = String(item._code) + ", "
}
newLabel.frame.size.width = newLabel.intrinsicContentSize.width + tagPadding
newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight
tagHeight = newLabel.intrinsicContentSize.height
activeCodeContentView.addSubview(newLabel)
// if current X + label width will be greater than container view width
// "move to next row"
if currentOriginX + newLabel.frame.width > containerWidth {
currentOriginX = 0
currentOriginY += tagHeight + tagSpacingY
}
// set the btn frame origin
newLabel.frame.origin.x = currentOriginX
newLabel.frame.origin.y = currentOriginY
// increment current X by btn width + spacing
currentOriginX += newLabel.frame.width + tagSpacingX
}
activeCodesCountLabel.text = String(dfyCoupons.count) + " Ενεργοί κωδικοί:"
// activeCodeLabel.text = couponCodesString
activeCodeExpirationLabel.isHidden = true
// update container view height
activeCodeContentViewHeight.constant = currentOriginY + tagHeight
if ((currentOriginY + tagHeight) <= (2 * tagHeight + tagSpacingY)) {
activeCodeScrollViewHeight.constant = currentOriginY + tagHeight
} else {
activeCodeScrollViewHeight.constant = 2 * tagHeight + tagSpacingY
}
}
} else {
activeCodeLabel.text = "-"
activeCodeExpirationLabel.text = ""
activeCodeView.isHidden = true
activeCodeViewHeight.constant = 0
}
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 2, left: 0, bottom: 4, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
}
//
// ActiveGiftsViewController.swift
// SwiftWarplyFramework
//
// Created by Βασιλης Σκουρας on 11/5/22.
//
import Foundation
import UIKit
@objc public class ActiveGiftsViewController: UIViewController {
@IBOutlet weak var couponButton: UIButton!
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("Ενεργά δώρα")
}
@IBAction func navigateToCoupon(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
self.navigationController?.pushViewController(vc, animated: true)
}
}
//
// AnalysisChildViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisChildViewController: UITableViewController {
public var index: Int = -1
}
//
// AnalysisHeaderMessageViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisHeaderMessageViewCell: UITableViewCell {
// attributes
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var messageLabelView: UIView!
@IBOutlet weak var messageLabel: UILabel!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var emptyLabel: UILabel!
@IBOutlet weak var emptyLabelHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var emptyLabelBottomSpace: NSLayoutConstraint!
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// image
// itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// title
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.text = "Αναλυτικά:"
// message
messageLabel.textColor = UIColor(rgb: 0x212121)
// messageLabelView.layer.borderWidth = 1.0
// messageLabelView.layer.borderColor = UIColor(rgb: 0xE6E6E6).cgColor
messageLabelView.layer.cornerRadius = 16.5
messageLabelView.backgroundColor = .white
// messageLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
}
}
extension AnalysisHeaderMessageViewCell {
func configureCell(isEmpty: Bool, isMarket: Bool) {
if (isEmpty == true) {
emptyLabel.isHidden = false
emptyLabelHeight.constant = 18.5
emptyLabelTopSpace.constant = 30.0
emptyLabelBottomSpace.constant = 10.0
} else {
emptyLabel.isHidden = true
emptyLabelHeight.constant = 0.0
emptyLabelTopSpace.constant = 0.0
emptyLabelBottomSpace.constant = 0.0
}
if (isMarket == true) {
itemImage.image = UIImage(named: "ic_history_market_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
let oldUnifiedCouponList: Array<swiftApi.CouponItemModel> = swiftApi().getOldUnifiedCouponList()
let oldUnifiedCouponListLength = oldUnifiedCouponList.count
var unifiedCouponsDiscount: Float = 0.0
for coupon in oldUnifiedCouponList {
if let discountFloat = Float(coupon.discount ?? "0.0") {
unifiedCouponsDiscount += discountFloat
}
}
let totalCouponDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let coupBoldText = totalCouponDiscountString + "€"
let coupNormalText2 = " σε προσφορές από "
let coupBoldText2 = String(oldUnifiedCouponListLength)
let coupNormalText3 = " κουπόνια!"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 17) ?? UIFont.boldSystemFont(ofSize: 16)]
let coupAttributedString = NSMutableAttributedString(string:coupNormalText1, attributes:attrRegular)
let coupBoldString = NSMutableAttributedString(string: coupBoldText, attributes:attrBold)
let coupNormalString2 = NSMutableAttributedString(string:coupNormalText2, attributes:attrRegular)
let coupBoldString2 = NSMutableAttributedString(string: coupBoldText2, attributes:attrBold)
let coupNormalString3 = NSMutableAttributedString(string:coupNormalText3, attributes:attrRegular)
coupAttributedString.append(coupBoldString)
coupAttributedString.append(coupNormalString2)
coupAttributedString.append(coupBoldString2)
coupAttributedString.append(coupNormalString3)
messageLabel.attributedText = coupAttributedString
} else {
itemImage.image = UIImage(named: "ic_gift_history", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let coupBoldText = totalCouponDiscountString + "€"
let coupNormalText2 = " σε προσφορές από "
let coupBoldText2 = String(loyaltyBadge._couponCount)
let coupNormalText3 = " κουπόνια!"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 17) ?? UIFont.boldSystemFont(ofSize: 16)]
let coupAttributedString = NSMutableAttributedString(string:coupNormalText1, attributes:attrRegular)
let coupBoldString = NSMutableAttributedString(string: coupBoldText, attributes:attrBold)
let coupNormalString2 = NSMutableAttributedString(string:coupNormalText2, attributes:attrRegular)
let coupBoldString2 = NSMutableAttributedString(string: coupBoldText2, attributes:attrBold)
let coupNormalString3 = NSMutableAttributedString(string:coupNormalText3, attributes:attrRegular)
coupAttributedString.append(coupBoldString)
coupAttributedString.append(coupNormalString2)
coupAttributedString.append(coupBoldString2)
coupAttributedString.append(coupNormalString3)
messageLabel.attributedText = coupAttributedString
}
}
}
//
// AnalysisHeaderViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisHeaderViewCell: UITableViewCell {
// attributes
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var emptyLabel: UILabel!
@IBOutlet weak var emptyLabelHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var emptyLabelBottomSpace: NSLayoutConstraint!
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// image
// itemImage.image = UIImage(named: "ic_gift_circle_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// title
// titleLabel.textColor = UIColor(rgb: 0x435563)
// titleLabel.text = "Αναλυτικά:"
}
}
extension AnalysisHeaderViewCell {
func configureCell(isEmpty: Bool, isMarket: Bool) {
if (isEmpty == true) {
emptyLabel.isHidden = false
emptyLabelHeight.constant = 18.5
// emptyLabelTopSpace.constant = 30.0
emptyLabelBottomSpace.constant = 10.0
} else {
emptyLabel.isHidden = true
emptyLabelHeight.constant = 0.0
// emptyLabelTopSpace.constant = 0.0
emptyLabelBottomSpace.constant = 0.0
}
if (isMarket == true) {
itemImage.image = UIImage(named: "ic_history_market_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
} else {
itemImage.image = UIImage(named: "ic_gift_history", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
}
}
//
// AnalysisItem.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
public class AnalysisItem: Codable {
// attributes
public var date: Date
public var image_url: String?
public var title: String?
public let subtitle: String?
public var price: Float
// initialization
public init() {
self.date = Date()
self.image_url = ""
self.title = ""
self.subtitle = ""
self.price = 4.0
}
}
//
// AnalysisItemViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class AnalysisItemViewCell: UITableViewCell {
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var priceLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.itemImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.itemImage.image = image
}
}
}
else {
self.itemImage.image = nil
}
}
}
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// date
dateLabel.textColor = UIColor(rgb: 0x212121)
dateLabel.font = UIFont(name: "PeridotPE-Bold", size: 12.0)
// title
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
// price
priceLabel.textColor = UIColor(rgb: 0x212121)
priceLabel.font = UIFont(name: "PeridotPE-Bold", size: 17.0)
// subtitle
// subtitleLabel.textColor = UIColor(rgb: 0x9D9D9C)
subtitleLabel.textColor = UIColor(rgb: 0x212121)
subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 14.0)
}
}
extension AnalysisItemViewCell {
func configureCell(item: swiftApi.SharingCouponModel) {
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
titleLabel.text = ""
for merchant in merchantList {
if (merchant._uuid == item._merchant_uuid) {
// itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
titleLabel.text = merchant._admin_name
break;
}
}
dateLabel.text = item._date
// titleLabel.text = item._name
let priceFloat = Float(round(100 * (Float(item._final_price) )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
if ("sent" == item._sharing_type) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι προς " + item._receiver_msisdn)
} else if ("received" == item._sharing_type) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι από " + item._sender_msisdn)
}
}
func configureCell(item: swiftApi.SharingCouponModel, isMarket: Bool) {
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let couponSetData: swiftApi.CouponSetItemModel? = item._sm_couponset_data
titleLabel.text = ""
for merchant in merchantList {
if (merchant._uuid == item._merchant_uuid) {
// itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
titleLabel.text = merchant._admin_name
break;
}
}
dateLabel.text = item._date
// titleLabel.text = item._name
// titleLabel.text = couponSetData?.name ?? ""
// let priceFloat = Float(round(100 * (Float(item._final_price) )) / 100)
let priceFloat = Float(round(100 * (Float(couponSetData?.final_price ?? 0.0) )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
if ("sent" == item._sharing_type) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι προς " + item._receiver_msisdn)
} else if ("received" == item._sharing_type) {
subtitleLabel.text = String(format: "Εκπτωτικό κουπόνι από " + item._sender_msisdn)
}
}
func configureCell(item: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data
titleLabel.text = ""
// for merchant in merchantList {
// // if (merchant._uuid == couponSetData?.merchant_uuid) {
// if (merchant._uuid == item.merchant_uuid) {
// // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
// titleLabel.text = merchant._admin_name
// break;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = item.merchant_details
self.postImageURL = merchantDetails?._img_preview
titleLabel.text = merchantDetails?._admin_name
dateLabel.text = item.redeemed ?? "" // expiration
// itemImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// titleLabel.text = couponSetData?.name ?? ""
let priceFloat = Float(round(100 * (Float(couponSetData?.final_price ?? 0.0) )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
subtitleLabel.text = "Έκπτωτικό κουπόνι"
// subtitleLabel.text = couponSetData?.short_description ?? ""
// OR
// let htmlText = couponSetData?.inner_text ?? ""
// subtitleLabel.text = htmlText.htmlToString
}
func configureCell(item: swiftApi.CouponItemModel, isMarket: Bool) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data
titleLabel.text = ""
// for merchant in merchantList {
// if (merchant._uuid == item.merchant_uuid) {
// // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
// titleLabel.text = merchant._admin_name
// break;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = item.merchant_details
self.postImageURL = merchantDetails?._img_preview
titleLabel.text = merchantDetails?._admin_name
// titleLabel.text = item.name
// self.postImageURL = item.image
dateLabel.text = item.redeemed ?? ""
let priceFloat = Float(round(100 * (Float(item.discount ?? "0.0") ?? 0.0 )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
subtitleLabel.text = "Έκπτωτικό κουπόνι"
// subtitleLabel.text = couponSetData?.short_description ?? ""
// OR
// let htmlText = couponSetData?.inner_text ?? ""
// subtitleLabel.text = htmlText.htmlToString
}
}
//
// AnalysisMoreViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 21/9/22.
//
import UIKit
@objc public class AnalysisMoreViewCell: UITableViewCell {
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var arrowImage: UIImageView!
// lifecycle
public override func awakeFromNib() {
super.awakeFromNib()
// title
titleLabel.font = UIFont(name: "PeridotPE-Bold", size: 15)
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.text = "Δες Περισσότερα"
arrowImage.image = UIImage(named: "ic_down_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
}
//
// CSMButton.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 20/9/22.
//
import UIKit
// @IBDesignable
@objc public class CSMButton: UIButton {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
configure()
}
override init(frame: CGRect = .zero) {
super.init(frame: frame)
configure()
}
public override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
configure()
}
}
private extension CSMButton {
func configure() {
setImage(UIImage(named: "ic_directions", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
setTitleColor(.white, for: .normal)
// backgroundColor = UIColor(rgb: 0x79BF14)
backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
layer.cornerRadius = 12.0
imageEdgeInsets = UIEdgeInsets(top:0.0, left:0.0, bottom:0.0, right:5.0);
titleEdgeInsets = UIEdgeInsets(top:0.0, left:5.0, bottom:0.0, right:0.0);
}
}
//
// CampaignCategory.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 11/10/22.
//
import Foundation
public class CampaignCategory: Codable {
// attributes
public var name: String?
public var index: Int
public var items: Array<swiftApi.CampaignItemModel>
// initialization
public init(_ name: String) {
self.name = name == "ΑΛΛΕΣ" ? name : String(name.dropFirst())
self.index = Int(name.prefix(1)) ?? 0
self.items = [swiftApi.CampaignItemModel]()
}
public init(_ name: String, index: Int) {
self.name = name == "ΑΛΛΕΣ" ? name : String(name.dropFirst())
self.index = index
self.items = [swiftApi.CampaignItemModel]()
}
}
enum CampaignCategoryFactory {
static func create(withTitle title: String) -> CampaignCategory {
var index = 100
let indexChr:Character = title[title.index(title.startIndex, offsetBy: 1)]
if indexChr.isNumber {
index = indexChr.wholeNumberValue!
}
return CampaignCategory(title, index: index)
}
}
......@@ -110,9 +110,9 @@ var timer2: DispatchSourceTimer?
self.navigationController?.isNavigationBarHidden = false
}
stopTimer()
saveSteps(startTracking: false)
// stopTimer()
//
// saveSteps(startTracking: false)
removeApplicationObservers()
}
......@@ -154,12 +154,13 @@ var timer2: DispatchSourceTimer?
@objc func applicationDidEnterBackground() {
// Handle code when the application enters the background
saveSteps(startTracking: false)
// saveSteps(startTracking: false)
}
// MARK: - Functions
func sendWebviewDidFocus() {
let scriptSource2 = "webviewDidFocus(\(self.webViewLoaded),\(swiftApi().getTrackingStepsEnabled()));"
// let scriptSource2 = "webviewDidFocus(\(self.webViewLoaded),\(swiftApi().getTrackingStepsEnabled()));"
let scriptSource2 = "webviewDidFocus(\(self.webViewLoaded),false);"
webView.evaluateJavaScript(scriptSource2, completionHandler: { (object, error) in
// print("==== webviewDidFocus object ====")
......@@ -191,75 +192,75 @@ var timer2: DispatchSourceTimer?
NotificationCenter.default.removeObserver(self, name: UIApplication.didEnterBackgroundNotification, object: nil)
}
func saveSteps(startTracking: Bool) {
let persistedSteps = swiftApi().getSteps()
if (persistedSteps > 0) {
let currentDateTime = Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let dateString = dateFormatter.string(from: currentDateTime)
swiftApi().setPacingDetailsAsync(persistedSteps, dateString, setPacingDetailsAsyncCallback, failureCallback: {errorCode in })
}
func setPacingDetailsAsyncCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void {
if (responseData != nil) {
DispatchQueue.main.async {
if (responseData?.getStatus == 1) {
if (startTracking) {
// TODO: DELETE LOGS
// print("===== startTrackingSteps after save persisted steps ====")
self.sendWebviewDidFocus()
swiftApi().startTrackingSteps(self.startTrackingStepsCallback)
}
}
}
} else {
}
}
}
// func saveSteps(startTracking: Bool) {
// let persistedSteps = swiftApi().getSteps()
// if (persistedSteps > 0) {
//
// let currentDateTime = Date()
// let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
// let dateString = dateFormatter.string(from: currentDateTime)
//
// swiftApi().setPacingDetailsAsync(persistedSteps, dateString, setPacingDetailsAsyncCallback, failureCallback: {errorCode in })
// }
//
// func setPacingDetailsAsyncCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void {
// if (responseData != nil) {
// DispatchQueue.main.async {
// if (responseData?.getStatus == 1) {
// if (startTracking) {
// // TODO: DELETE LOGS
// // print("===== startTrackingSteps after save persisted steps ====")
//
// self.sendWebviewDidFocus()
//
// swiftApi().startTrackingSteps(self.startTrackingStepsCallback)
// }
// }
// }
// } else {
// }
// }
// }
func startTimer() {
// print("========= Webview Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".webview.timer")
timer2 = DispatchSource.makeTimerSource(queue: queue)
timer2!.schedule(deadline: .now(), repeating: .seconds(1))
timer2!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
// print("========= Webview interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
let metersParam = swiftApi().getMetersWebview()
let scriptSource = "passMeters(\(metersParam));"
self?.webView.evaluateJavaScript(scriptSource, completionHandler: { (object, error) in
// print("==== object passMeters ====")
// print(object)
// print("==== error passMeters ====")
// print(error)
swiftApi().setSavedStepsWebview(swiftApi().getSavedStepsWebview() + swiftApi().getStepsWebview())
swiftApi().setStepsWebview(0)
swiftApi().setMetersWebview(0.0)
// print("==== SavedStepsWebview ====")
// print(swiftApi().getSavedStepsWebview())
})
}
}
timer2!.resume()
}
func stopTimer() {
// print("========= Webview Timer Stopped! =========")
timer2?.cancel()
timer2 = nil
}
// func startTimer() {
// // print("========= Webview Timer Started! =========")
//
// let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".webview.timer")
// timer2 = DispatchSource.makeTimerSource(queue: queue)
// timer2!.schedule(deadline: .now(), repeating: .seconds(1))
// timer2!.setEventHandler { [weak self] in
// // do whatever stuff you want on the background queue here here
// // print("========= Webview interval! =========")
//
// DispatchQueue.main.async {
// // update your model objects and/or UI here
// let metersParam = swiftApi().getMetersWebview()
// let scriptSource = "passMeters(\(metersParam));"
//
// self?.webView.evaluateJavaScript(scriptSource, completionHandler: { (object, error) in
//// print("==== object passMeters ====")
//// print(object)
//// print("==== error passMeters ====")
//// print(error)
//
// swiftApi().setSavedStepsWebview(swiftApi().getSavedStepsWebview() + swiftApi().getStepsWebview())
// swiftApi().setStepsWebview(0)
// swiftApi().setMetersWebview(0.0)
//
// // print("==== SavedStepsWebview ====")
// // print(swiftApi().getSavedStepsWebview())
// })
// }
// }
// timer2!.resume()
// }
//
// func stopTimer() {
// // print("========= Webview Timer Stopped! =========")
// timer2?.cancel()
// timer2 = nil
// }
// Location Permissions
func locationServicesIsEnabled() -> Bool {
......@@ -405,21 +406,21 @@ var timer2: DispatchSourceTimer?
// <===
// MARK: - API Calls
func startTrackingSteps() {
let persistedSteps = swiftApi().getSteps()
if (persistedSteps > 0) {
saveSteps(startTracking: true)
} else {
swiftApi().startTrackingSteps(startTrackingStepsCallback)
}
// swiftApi().startTrackingSteps(startTrackingStepsCallback)
}
// func startTrackingSteps() {
// let persistedSteps = swiftApi().getSteps()
// if (persistedSteps > 0) {
// saveSteps(startTracking: true)
// } else {
// swiftApi().startTrackingSteps(startTrackingStepsCallback)
// }
//
//// swiftApi().startTrackingSteps(startTrackingStepsCallback)
// }
func startTrackingStepsCallback (_ steps: Int) -> Void {
DispatchQueue.main.async {
}
}
// func startTrackingStepsCallback (_ steps: Int) -> Void {
// DispatchQueue.main.async {
// }
// }
// MARK: - WKNavigationDelegate
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
......@@ -433,9 +434,9 @@ var timer2: DispatchSourceTimer?
// print("==== error ====")
// print(error)
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
self.startTimer()
}
// DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
// self.startTimer()
// }
})
// let scriptSource2 = "webviewDidFocus(\(self.webViewLoaded),\(swiftApi().getTrackingStepsEnabled()));"
......@@ -551,36 +552,36 @@ var timer2: DispatchSourceTimer?
} else if (eventArray[1] == "addUserTag") {
// SwiftEventBus.post("questionnaire", sender: questionnaireEvent)
swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
// swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
// func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
// if (profileData != nil) {
// DispatchQueue.main.async {
// swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
let questionnaireEvent = swiftApi.QuestionnaireEventModel()
questionnaireEvent._name = String(eventArray[1])
if (eventArray.count > 2) {
questionnaireEvent._parameter = String(eventArray[2])
swiftApi().setUserTag(String(eventArray[2]))
} else {
questionnaireEvent._parameter = ""
swiftApi().setUserTag("")
}
SwiftEventBus.post("questionnaire", sender: questionnaireEvent)
SwiftEventBus.post("campaigns_retrieved")
}
} else {
}
}
// func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
// if (campaignsData != nil) {
// DispatchQueue.main.async {
// let questionnaireEvent = swiftApi.QuestionnaireEventModel()
// questionnaireEvent._name = String(eventArray[1])
// if (eventArray.count > 2) {
// questionnaireEvent._parameter = String(eventArray[2])
// swiftApi().setUserTag(String(eventArray[2]))
// } else {
// questionnaireEvent._parameter = ""
// swiftApi().setUserTag("")
// }
// SwiftEventBus.post("questionnaire", sender: questionnaireEvent)
// SwiftEventBus.post("campaigns_retrieved")
// }
// } else {
// }
// }
}
} else {
}
}
// }
// } else {
// }
// }
} else if (eventArray[1] == "couponRetrieved") {
......@@ -618,35 +619,35 @@ var timer2: DispatchSourceTimer?
}
else if (eventArray[1] == "steps" && eventArray[2] == "widgetDisabled") {
let pacingWidget = swiftApi.WarplyPacingCardEventModel()
pacingWidget._isVisible = false
SwiftEventBus.post("pacing_widget", sender: pacingWidget)
// let pacingWidget = swiftApi.WarplyPacingCardEventModel()
// pacingWidget._isVisible = false
// SwiftEventBus.post("pacing_widget", sender: pacingWidget)
} else if (eventArray[1] == "steps" && eventArray[2] == "widgetEnabled") {
let pacingWidget = swiftApi.WarplyPacingCardEventModel()
pacingWidget._isVisible = true
SwiftEventBus.post("pacing_widget", sender: pacingWidget)
// let pacingWidget = swiftApi.WarplyPacingCardEventModel()
// pacingWidget._isVisible = true
// SwiftEventBus.post("pacing_widget", sender: pacingWidget)
}
else if (eventArray[1] == "steps" && eventArray[2] == "shortcutEnabled") {
let pacingEvent = swiftApi.WarplyPacingEventModel()
pacingEvent._isVisible = true
SwiftEventBus.post("pacing", sender: pacingEvent)
if (swiftApi().getTrackingStepsEnabled() == false) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_steps_activation"
firebaseEvent._parameters = nil
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.startTrackingSteps()
}
// let pacingEvent = swiftApi.WarplyPacingEventModel()
// pacingEvent._isVisible = true
// SwiftEventBus.post("pacing", sender: pacingEvent)
//
// if (swiftApi().getTrackingStepsEnabled() == false) {
// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
// firebaseEvent._eventName = "loyalty_steps_activation"
// firebaseEvent._parameters = nil
// SwiftEventBus.post("firebase", sender: firebaseEvent)
//
// self.startTrackingSteps()
// }
} else if (eventArray[1] == "steps" && eventArray[2] == "shortcutDisabled") {
let pacingEvent = swiftApi.WarplyPacingEventModel()
pacingEvent._isVisible = false
SwiftEventBus.post("pacing", sender: pacingEvent)
swiftApi().stopTrackingSteps()
// let pacingEvent = swiftApi.WarplyPacingEventModel()
// pacingEvent._isVisible = false
// SwiftEventBus.post("pacing", sender: pacingEvent)
// swiftApi().stopTrackingSteps()
} else if (eventArray[1] == "request" || eventArray[1] == "response") {
print("**************** WARPLY Webview Log START *****************")
......@@ -800,13 +801,13 @@ var timer2: DispatchSourceTimer?
} else if (eventArray[1] == "loyaltyWallet") {
// event:loyaltyWallet
SwiftEventBus.post("refresh_vouchers")
// SwiftEventBus.post("open_my_rewards")
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController
vc.isFromCampaignVC = true
self.navigationController?.pushViewController(vc, animated: true)
// SwiftEventBus.post("refresh_vouchers")
//// SwiftEventBus.post("open_my_rewards")
//
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController
// vc.isFromCampaignVC = true
// self.navigationController?.pushViewController(vc, animated: true)
// swiftApi().getUnifiedCouponsDeals { unifiedCoupons in
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
......@@ -892,12 +893,12 @@ var timer2: DispatchSourceTimer?
}
}
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: SwiftWarplyFramework.CouponsViewController.self))
if let vc = storyboard.instantiateViewController(withIdentifier: "CouponsViewController") as? SwiftWarplyFramework.CouponsViewController{
self.navigationController?.pushViewController(vc,animated: true)
}
}
// DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: SwiftWarplyFramework.CouponsViewController.self))
// if let vc = storyboard.instantiateViewController(withIdentifier: "CouponsViewController") as? SwiftWarplyFramework.CouponsViewController{
// self.navigationController?.pushViewController(vc,animated: true)
// }
// }
} else if (eventArray[1] == "webviewRefresh") {
self.mWebviewSupermarket = true
......
//
// ContextualViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 2/9/22.
//
import UIKit
import SwiftEventBus
@objc public class ContextualViewController: UIViewController, UIPopoverControllerDelegate {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var scrollContentView: UIView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var redeemButton: UIButton!
@IBOutlet weak var topBorderLine: UIImageView!
@IBOutlet weak var termsButton: UIButton!
@IBOutlet weak var termsTextView: UnselectableTappableTextView!
@IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
public var ccms: swiftApi.LoyaltyContextualOfferModel?
var selectedNumber: String = ""
var termsVisible: Bool = false;
public var numbersList: Array<String> = []
let uiscreen: CGRect = UIScreen.main.bounds
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
// Do any additional setup after loading the view.
// getProfileRequest()
numbersList = ccms?._eligibleAssets ?? []
setBackButton()
// setNavigationTitle("")
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// scrollView.clipsToBounds = true
// scrollView.layer.cornerRadius = 30
// scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
//
// topBorderLine.translatesAutoresizingMaskIntoConstraints = false
// topBorderLine.image = image
// topBorderLine.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
// ])
couponImage.load(link: ccms?._imageUrl ?? "", placeholder: UIImage(), cache: URLCache())
couponImage.contentMode = .scaleAspectFill
couponImageHeight.constant = 222 // 255 //230 // 253 // self.uiscreen.height * 0.25
nameLabel.text = ccms?._titleOffer ?? ""
descriptionLabel.text = ccms?._description ?? ""
redeemButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 17)
redeemButton.setTitle("Ενεργοποίηση", for: .normal)
redeemButton.setTitleColor(.white, for: .normal)
redeemButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
redeemButton.layer.cornerRadius = 16.0
redeemButton.frame = CGRect(x: 0.0, y: 0.0, width: redeemButton.intrinsicContentSize.width, height: 50)
redeemButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
// // iPad
// redeemButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
// } else {
// // not iPad (iPhone, mac, tv, carPlay, unspecified)
// redeemButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
termsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
termsButton.setTitle("Όροι χρήσης", for: .normal)
termsButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
termsButton.semanticContentAttribute = .forceRightToLeft
termsButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
termsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
termsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
termsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
termsTextView.text = ccms?._termsAndConditions ?? ""
termsTextView.font = UIFont(name: "PeridotPE-Regular", size: 14)
termsTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
termsTextView.textAlignment = .left
termsTextView.isScrollEnabled = false
toggleTerms()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "ContextualScreen")
self.navigationController?.hideHairline()
}
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func toggleTerms() {
if (termsVisible) {
termsTextView.isHidden = false
let targetSize = CGSize(width: termsTextView.frame.width, height: CGFloat(MAXFLOAT))
termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height
termsButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
} else {
termsTextView.isHidden = true
termsTextViewHeight.constant = CGFloat(0)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
}
}
func showConfirmDialog(_ numberArg: String) -> Void {
let alert = UIAlertController(title: "Ενεργοποίηση υπηρεσίας", message: "Θέλετε να γίνει ενεργοποίηση στο " + numberArg + ";", preferredStyle: .alert)
let cancelButton = UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
})
// cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in
switch action.style{
case .default:
swiftApi().logTrackersEvent("click", ("ActivateContextual:" + (self.ccms?._sessionId ?? "")))
self.submitOrderRequest()
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showSuccessDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
self.navigationController?.popViewController(animated: true)
// swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
swiftApi().getCouponsAsyncInternal(getCouponsCallback, failureCallback: {errorCode in })
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
}
} else {
}
}
var campaignFound: swiftApi.CampaignItemModel? = nil
if let ccmLoyaltyCampaignId = self.ccms?._loyaltyCampaignId {
let allCampaigns = swiftApi().getAllCampaignList()
for item in allCampaigns {
if (item.session_uuid == ccmLoyaltyCampaignId) {
campaignFound = item
break;
}
}
}
if let tempCampaign = campaignFound {
swiftApi().removeCampaignItem(campaignArg: tempCampaign)
swiftApi().getCampaignsAsyncNewInternal(getCampaignsCallback, failureCallback: {errorCode in})
}
// swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("campaigns_retrieved")
}
} else {
}
}
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
// MARK: - API CALLS
func getProfileRequest() {
swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
}
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
self.numbersList = profileData?._msisdnList ?? []
}
} else {
}
}
func submitOrderRequest() {
self.showSpinner()
swiftApi().submitOrderAsync(campaign_session_uuid: "", user_msisdn: self.selectedNumber, businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""),
OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""),
submitOrderCallback, failureCallback: {errorCode in
self.hideSpinner()
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
})
}
func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
self.hideSpinner()
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "true")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let ccmsEnabled = swiftApi.WarplyCCMSEnabledModel()
ccmsEnabled._isActivated = true
SwiftEventBus.post("ccms_enabled", sender: ccmsEnabled)
self.showSuccessDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.")
// self.postEventRequest()
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
// MARK: - Actions
@IBAction func redeemButtomAction(_ sender: Any) {
if (self.numbersList != nil && self.numbersList.count == 1) {
self.showConfirmDialog(self.numbersList[0])
} else {
self.numbersPopupTapped(sender)
}
}
@IBAction func termsButtonAction(_ sender: Any) {
termsVisible = !termsVisible
toggleTerms()
}
}
// MARK: NumbersPopup
extension ContextualViewController: NumbersPopupDelegate {
@objc func numbersPopupTapped(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let pp = storyboard.instantiateViewController(withIdentifier: "NumberPopupViewController") as! SwiftWarplyFramework.NumberPopupViewController
pp.InitWithController(controller: self,
numbersList: self.numbersList,
sender: sender,
delegate: self,
headerText: "Επιλογή σύνδεσης")
}
func presentedPopup() {
// Code for when popup is presented
}
func dismissedPopup() {
// Code for when popup is dismissed
}
func optionSelected(_ option: String) {
// Code for when option is selected
self.selectedNumber = option
DispatchQueue.main.async {
self.showConfirmDialog(option)
}
}
}
//
// CopyableLabel.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 26/10/22.
//
import Foundation
import UIKit
class CopyableLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
sharedInit()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
sharedInit()
}
func sharedInit() {
isUserInteractionEnabled = true
addGestureRecognizer(UILongPressGestureRecognizer(target: self, action: #selector(showMenu(sender:))))
}
@objc
func showMenu(sender: AnyObject?) {
becomeFirstResponder()
let menu = UIMenuController.shared
if !menu.isMenuVisible {
menu.setTargetRect(bounds, in: self)
menu.setMenuVisible(true, animated: true)
}
}
override var canBecomeFirstResponder: Bool {
return true
}
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
if action == #selector(UIResponderStandardEditActions.copy(_:)) {
return true
}
return false
}
override func copy(_ sender: Any?) {
let board = UIPasteboard.general
if var textToCopy = text {
if (textToCopy.contains(", ")) {
textToCopy = textToCopy.replacingOccurrences(of: ", ", with: "")
}
print(textToCopy)
board.string = textToCopy
}
// board.string = text
let menu = UIMenuController.shared
menu.setMenuVisible(false, animated: true)
}
}
//
// CouponBarcodeViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 20/5/22.
//
import UIKit
import RSBarcodes_Swift
import AVFoundation
// import SwiftEventBus
@objc public class CouponBarcodeViewController: UIViewController, UITextViewDelegate {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var scrollContentView: UIView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var merchantDescrTextView: UnselectableTappableTextView!
@IBOutlet weak var merchantDescrTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var merchantDescrTextViewTopSpace: NSLayoutConstraint!
@IBOutlet weak var couponCodeLabel: UILabel!
@IBOutlet weak var couponCodeLabelHeight: NSLayoutConstraint!
@IBOutlet weak var couponView: UIView!
@IBOutlet weak var couponViewTopSpace: NSLayoutConstraint!
@IBOutlet weak var couponViewHeight: NSLayoutConstraint!
@IBOutlet weak var couponNumberLabel: CopyableLabel!
@IBOutlet weak var barcodeImage: UIImageView!
@IBOutlet weak var barcodeImageHeight: NSLayoutConstraint!
@IBOutlet weak var barcodeLabel: UILabel!
@IBOutlet weak var barcodeLabelHeight: NSLayoutConstraint!
@IBOutlet weak var showBarcodeButton: UIButton!
@IBOutlet weak var expirationLabel: UILabel!
@IBOutlet weak var expirationLabelHeight: NSLayoutConstraint!
@IBOutlet weak var redeemButton: UIButton!
@IBOutlet weak var redeemButtonHeight: NSLayoutConstraint!
@IBOutlet weak var redeemButtonTopSpace: NSLayoutConstraint!
@IBOutlet weak var termsButton: UIButton!
@IBOutlet weak var termsTextView: UnselectableTappableTextView!
@IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var borderViewHeight: NSLayoutConstraint!
@IBOutlet weak var borderView2Height: NSLayoutConstraint!
@IBOutlet weak var border1TopSpace: NSLayoutConstraint!
@IBOutlet weak var barcodeImageTopSpace: NSLayoutConstraint!
@IBOutlet weak var barcodeLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var border2TopSpace: NSLayoutConstraint!
@IBOutlet weak var mapButton: UIButton!
@IBOutlet weak var topBorderLine: UIImageView!
@IBOutlet weak var mapButtonHeight: NSLayoutConstraint!
@IBOutlet weak var mapButtonTopSpace: NSLayoutConstraint!
@IBOutlet weak var showBarcodeButtonHeight: NSLayoutConstraint!
@IBOutlet weak var showBarcodeButtonTopSpace: NSLayoutConstraint!
@IBOutlet weak var couponCodeLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var discountView: UIView!
@IBOutlet weak var discountLabel: UILabel!
@IBOutlet weak var topExpirationView: UIView!
@IBOutlet weak var topExpirationViewHeight: NSLayoutConstraint!
@IBOutlet weak var topExpirationViewTopSpace: NSLayoutConstraint!
@IBOutlet weak var topExpirationLabel: UILabel!
@IBOutlet weak var barcodeTitleLabel: UILabel!
@IBOutlet weak var barcodeTitleLabelHeight: NSLayoutConstraint!
@IBOutlet weak var barcodeTitleLabelTopSpace: NSLayoutConstraint!
let uiscreen: CGRect = UIScreen.main.bounds
var termsVisible: Bool = false;
var barcodeVisible: Bool = false;
var mapBtnVisible: Bool = false;
var eshopBtnVisible: Bool = false;
var eshopWebsite: String = "";
public var coupon: swiftApi.CouponItemModel?
public var isFromWallet: Bool? = false
public var isMarket: Bool? = false
public var isSMCoupon: Bool? = false
let smCouponsetsList = swiftApi().getCouponSetsDealsList()
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
merchantDescrTextView.delegate = self
termsTextView.delegate = self
// Do any additional setup after loading the view.
setBackButton()
setNavigationTitle("Εκπτωτικό κουπόνι")
// backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// scrollView.clipsToBounds = true
// scrollView.layer.cornerRadius = 30
// scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
//
// topBorderLine.translatesAutoresizingMaskIntoConstraints = false
// topBorderLine.image = image
// topBorderLine.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
// ])
// COUPONSET: description, img_preview, name, terms
// COUPON: coupon, expiration, discount, status
// OLD COUPON KEYS: coupon, expiration, discount, status
// NEW COUPON KEYS (from couponset): inner_text, merchant_uuid
// MISSING KEYS (from couponset): img_preview, name, short_description, terms
// let couponSetData: swiftApi.CouponSetItemModel? = coupon?.couponset_data
var couponSetData: swiftApi.CouponSetItemModel?
if (isMarket == true || isSMCoupon == true) {
for item in smCouponsetsList {
if (item.uuid == coupon?.couponset_uuid) {
couponSetData = item
break;
}
}
} else {
couponSetData = coupon?.couponset_data
}
if (isMarket == true || isSMCoupon == true) {
// couponImage.load(link: coupon?.image ?? "", placeholder: UIImage(), cache: URLCache())
couponImage.load(link: couponSetData?.img?[0] ?? "", placeholder: UIImage(), cache: URLCache())
} else {
couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
}
couponImageHeight.constant = 222 // 255 //230 // 253 // self.uiscreen.height * 0.25
discountView.backgroundColor = UIColor(rgb: 0xB8E0EF)
discountView.layer.cornerRadius = 16.0
discountView.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMaxYCorner] // Top left, bottom right corner radius
discountLabel.font = UIFont(name: "BTCosmo-Bold", size: 27)
discountLabel.textColor = UIColor(rgb: 0x004B87)
var discount = ""
if (couponSetData?.discount_type == "value") {
discount = ("-" + (coupon?.discount ?? "") + "€")
} else if (couponSetData?.discount_type == "percentage") {
discount = ("-" + (coupon?.discount ?? "") + "%")
} else if (couponSetData?.discount_type == "plus_one") {
discount = "1+1"
} else {
discount = ("-" + (coupon?.discount ?? "") + "€")
}
discountLabel.text = discount
topExpirationView.backgroundColor = UIColor(rgb: 0xB8E0EF)
topExpirationView.layer.cornerRadius = 13.0
topExpirationLabel.text = "Ισχύει έως " + (coupon?.expiration ?? "")
topExpirationLabel.font = UIFont(name: "PeridotPE-Bold", size: 13)
topExpirationLabel.textColor = UIColor(rgb: 0x004B87)
topExpirationLabel.frame.size.width = topExpirationLabel.intrinsicContentSize.width
barcodeTitleLabel.text = "barcode κουπονιού"
barcodeTitleLabel.font = UIFont(name: "PeridotPE-Bold", size: 16)
barcodeTitleLabel.textColor = UIColor(rgb: 0x212121)
if (isSMCoupon == true) {
discountView.isHidden = false
topExpirationView.isHidden = false
topExpirationViewHeight.constant = topExpirationLabel.intrinsicContentSize.height + 8
topExpirationViewTopSpace.constant = CGFloat(8)
expirationLabel.isHidden = true
expirationLabel.isHidden = true
expirationLabelHeight.constant = CGFloat(0)
barcodeTitleLabel.isHidden = false
barcodeTitleLabelHeight.constant = barcodeTitleLabel.intrinsicContentSize.height
barcodeTitleLabelTopSpace.constant = CGFloat(20)
} else {
if (isMarket == true) {
discountView.isHidden = false
} else {
discountView.isHidden = true
}
topExpirationView.isHidden = true
topExpirationViewHeight.constant = CGFloat(0)
topExpirationViewTopSpace.constant = CGFloat(0)
expirationLabel.isHidden = false
expirationLabelHeight.constant = expirationLabel.intrinsicContentSize.height
barcodeTitleLabel.isHidden = true
barcodeTitleLabelHeight.constant = CGFloat(0)
barcodeTitleLabelTopSpace.constant = CGFloat(0)
}
if (isMarket == true) {
couponImage.contentMode = .scaleAspectFit
// nameLabel.text = coupon?.name ?? ""
nameLabel.text = couponSetData?.name ?? ""
// discriptionLabel.text = coupon?.short_description ?? ""
// let htmlName = coupon?.inner_text ?? ""
let htmlDiscription = coupon?.description ?? ""
// nameLabel.text = htmlName.htmlToString
discriptionLabel.text = htmlDiscription.htmlToString
} else if (isSMCoupon == true) {
couponImage.contentMode = .scaleAspectFit
nameLabel.text = couponSetData?.name ?? ""
let htmlDiscription = couponSetData?.description ?? ""
discriptionLabel.text = htmlDiscription.htmlToString
} else {
couponImage.contentMode = .scaleAspectFill
nameLabel.text = couponSetData?.name ?? ""
discriptionLabel.text = couponSetData?.short_description ?? ""
}
merchantDescrTextView.text = ""
merchantDescrTextViewTopSpace.constant = CGFloat(0)
merchantDescrTextViewHeight.constant = CGFloat(0)
merchantDescrTextView.isHidden = true
couponCodeLabelTopSpace.constant = CGFloat(35)
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
var merchantUuid: String = ""
// if (isMarket == true) {
merchantUuid = coupon?.merchant_uuid ?? ""
// } else {
// merchantUuid = couponSetData?.merchant_uuid ?? ""
// }
// for merchant in merchantList {
// if (merchant._uuid == merchantUuid) {
// let htmlMerchDescrText = merchant._body
let merchantDetails: swiftApi.MerchantModel? = coupon?.merchant_details
let htmlMerchDescrText = merchantDetails?._body ?? ""
if (isMarket != true && htmlMerchDescrText != "") {
merchantDescrTextView.attributedText = htmlMerchDescrText.htmlToAttributedString
merchantDescrTextView.font = UIFont(name: "PeridotPE-Regular", size: 16)
merchantDescrTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
merchantDescrTextView.textAlignment = .center
merchantDescrTextView.isScrollEnabled = false
merchantDescrTextView.isUserInteractionEnabled = true
merchantDescrTextView.isEditable = false
merchantDescrTextView.isSelectable = true
merchantDescrTextView.dataDetectorTypes = [.link]
merchantDescrTextView.isHidden = false
merchantDescrTextViewTopSpace.constant = CGFloat(10)
let targetSize = CGSize(width: merchantDescrTextView.frame.width, height: CGFloat(MAXFLOAT))
merchantDescrTextViewHeight.constant = merchantDescrTextView.sizeThatFits(targetSize).height
couponCodeLabelTopSpace.constant = CGFloat(0)
}
// break;
// }
// }
couponView.layer.cornerRadius = 16
couponNumberLabel.text = coupon?.coupon ?? ""
couponView.frame = CGRect(x: 0.0, y: 0.0, width: couponView.intrinsicContentSize.width, height: 55)
if (isMarket == true) {
couponCodeLabel.isHidden = true
couponCodeLabelHeight.constant = CGFloat(0)
couponCodeLabelTopSpace.constant = CGFloat(0)
couponView.isHidden = true
couponViewHeight.constant = CGFloat(0)
couponViewTopSpace.constant = CGFloat(0)
redeemButton.isHidden = true
redeemButtonHeight.constant = CGFloat(0)
// redeemButtonTopSpace.constant = CGFloat(0)
} else {
couponCodeLabel.isHidden = false
couponCodeLabelHeight.constant = CGFloat(20)
couponCodeLabelTopSpace.constant = CGFloat(35)
couponView.isHidden = false
couponViewHeight.constant = CGFloat(55)
couponViewTopSpace.constant = CGFloat(20)
redeemButton.isHidden = false
redeemButtonHeight.constant = CGFloat(55)
// redeemButtonTopSpace.constant = CGFloat(20)
}
let barcodeString = constructBarcode() ?? ""
barcodeLabel.text = barcodeString
if (isSMCoupon == true) {
// Uncomment if Barcode Section is active again
if let barcodeUIImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.1)) {
barcodeImage.image = barcodeUIImage
barcodeImageHeight.constant = self.uiscreen.height * 0.1
// showBarcodeButton.isHidden = false
// showBarcodeButtonHeight.constant = 50
// showBarcodeButtonTopSpace.constant = 10
} else {
barcodeImageHeight.constant = 0
// showBarcodeButton.isHidden = true
// showBarcodeButtonHeight.constant = 0
// showBarcodeButtonTopSpace.constant = 0
}
// === Hide barcodeLabel
barcodeLabel.isHidden = true
barcodeLabelHeight.constant = CGFloat(0)
barcodeLabelTopSpace.constant = CGFloat(0) // 10
// === Hide Barcode Button
showBarcodeButton.isHidden = true
showBarcodeButtonHeight.constant = 0
showBarcodeButtonTopSpace.constant = 0
// ===
border2TopSpace.constant = CGFloat(10)
} else {
// === Hide Barcode Section
barcodeImage.isHidden = true
barcodeImageHeight.constant = CGFloat(0)
barcodeLabel.isHidden = true
barcodeLabelHeight.constant = CGFloat(0)
borderViewHeight.constant = CGFloat(0)
borderView2Height.constant = CGFloat(0)
border1TopSpace.constant = CGFloat(0) // 20
barcodeImageTopSpace.constant = CGFloat(0) // 10
barcodeLabelTopSpace.constant = CGFloat(0) // 10
border2TopSpace.constant = CGFloat(0) // 15
showBarcodeButton.isHidden = true
showBarcodeButtonHeight.constant = 0
showBarcodeButtonTopSpace.constant = 0
// ===
}
// // Uncomment if Barcode Section is active again
// if let barcodeUIImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.1)) {
// barcodeImage.image = barcodeUIImage
//
// barcodeImageHeight.constant = self.uiscreen.height * 0.1
//
// showBarcodeButton.isHidden = false
// showBarcodeButtonHeight.constant = 50
// showBarcodeButtonTopSpace.constant = 10
//
// } else {
// barcodeImageHeight.constant = 0
//
// showBarcodeButton.isHidden = true
// showBarcodeButtonHeight.constant = 0
// showBarcodeButtonTopSpace.constant = 0
// }
// // === Hide Barcode Section
// barcodeImage.isHidden = true
// barcodeImageHeight.constant = CGFloat(0)
// barcodeLabel.isHidden = true
// barcodeLabelHeight.constant = CGFloat(0)
//
// borderViewHeight.constant = CGFloat(0)
// borderView2Height.constant = CGFloat(0)
//
// border1TopSpace.constant = CGFloat(0) // 20
// barcodeImageTopSpace.constant = CGFloat(0) // 10
// barcodeLabelTopSpace.constant = CGFloat(0) // 10
// border2TopSpace.constant = CGFloat(0) // 15
//
// showBarcodeButton.isHidden = true
// showBarcodeButtonHeight.constant = 0
// showBarcodeButtonTopSpace.constant = 0
// // ===
showBarcodeButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 16)
showBarcodeButton.setTitle("Εμφάνιση barcode", for: .normal)
showBarcodeButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
showBarcodeButton.semanticContentAttribute = .forceRightToLeft
showBarcodeButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
showBarcodeButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
showBarcodeButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
showBarcodeButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
expirationLabel.text = "Το κουπόνι ισχύει έως " + (coupon?.expiration ?? "")
if (isSMCoupon == true) {
redeemButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 17)
redeemButton.setTitle("Βρες το στα supermarket", for: .normal)
redeemButton.setTitleColor(.white, for: .normal)
redeemButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
redeemButton.layer.cornerRadius = 16.0
redeemButton.frame = CGRect(x: 0.0, y: 0.0, width: 260, height: 55)
// redeemButton.frame = CGRect(x: 0.0, y: 0.0, width: redeemButton.intrinsicContentSize.width, height: 55)
// redeemButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
// // iPad
// redeemButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
// } else {
// // not iPad (iPhone, mac, tv, carPlay, unspecified)
// redeemButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
mapButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 17)
mapButton.setTitle("Δώρισέ το", for: .normal)
mapButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal)
mapButton.layer.cornerRadius = 15.0
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: 260, height: 55)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 55)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
mapButton.backgroundColor = .clear
mapButton.layer.borderWidth = 2
mapButton.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
} else {
redeemButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 17)
redeemButton.setTitle("Δώρισέ το", for: .normal)
redeemButton.setTitleColor(.white, for: .normal)
redeemButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
redeemButton.layer.cornerRadius = 16.0
redeemButton.frame = CGRect(x: 0.0, y: 0.0, width: 260, height: 55)
// redeemButton.frame = CGRect(x: 0.0, y: 0.0, width: redeemButton.intrinsicContentSize.width, height: 55)
// redeemButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
// // iPad
// redeemButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
// } else {
// // not iPad (iPhone, mac, tv, carPlay, unspecified)
// redeemButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
mapButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 17)
mapButton.setTitle("Δες τα καταστήματα", for: .normal)
mapButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal)
mapButton.layer.cornerRadius = 15.0
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: 260, height: 55)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 55)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
mapButton.backgroundColor = .clear
mapButton.layer.borderWidth = 2
mapButton.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
}
// mapButton.isHidden = true
// mapButtonHeight.constant = 0
// mapButtonTopSpace.constant = 0
// let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// for merchant in merchantList {
// if (merchant._uuid == couponSetData?.merchant_uuid) {
// if (merchant._show_map == true) {
// mapButton.setTitle("Δες τα καταστήματα", for: .normal)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 1, left: 16, bottom: 0, right: 16)
// mapButton.isHidden = false
// mapBtnVisible = true
// eshopBtnVisible = false
// mapButtonHeight.constant = 44
// mapButtonTopSpace.constant = 10
// } else if (merchant._eshop == true) {
// mapButton.setTitle("Δες το eshop", for: .normal)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 1, left: 16, bottom: 0, right: 16)
// mapButton.isHidden = false
// mapBtnVisible = false
// eshopBtnVisible = true
// mapButtonHeight.constant = 44
// mapButtonTopSpace.constant = 10
// } else {
// mapButton.isHidden = true
// mapBtnVisible = false
// eshopBtnVisible = false
// mapButtonHeight.constant = 0
// mapButtonTopSpace.constant = 0
// }
// eshopWebsite = merchant._website
// break;
// }
// }
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
// // iPad
// mapButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
// } else {
// // not iPad (iPhone, mac, tv, carPlay, unspecified)
// mapButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
termsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
termsButton.setTitle("Όροι χρήσης", for: .normal)
termsButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
termsButton.semanticContentAttribute = .forceRightToLeft
termsButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
termsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
termsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
termsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
var htmlText = ""
if (isMarket == true) {
htmlText = coupon?.terms ?? ""
} else {
htmlText = couponSetData?.terms ?? ""
}
termsTextView.attributedText = htmlText.htmlToAttributedString
termsTextView.font = UIFont(name: "PeridotPE-Regular", size: 14)
termsTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
termsTextView.textAlignment = .left
termsTextView.isScrollEnabled = false
termsTextView.isUserInteractionEnabled = true
termsTextView.isEditable = false
termsTextView.isSelectable = true
termsTextView.dataDetectorTypes = [.link]
toggleTerms()
// Uncomment if Barcode Section is active again
// if (isMarket == false) {
// toggleBarcode()
// }
// Logs
print("Coupon: " + (coupon?.coupon ?? ""))
print("Coupon Name: " + (couponSetData?.name ?? ""))
print("Coupon Description: " + (couponSetData?.short_description ?? ""))
print("Coupon Expiration: " + (coupon?.expiration ?? ""))
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "CouponScreen")
self.navigationController?.hideHairline()
}
public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UIApplication.shared.open(URL)
// Disable `.preview` by 3D Touch and other interactions
return false
}
// MARK: - Functions
func toggleTerms() {
if (termsVisible) {
termsTextView.isHidden = false
let targetSize = CGSize(width: termsTextView.frame.width, height: CGFloat(MAXFLOAT))
termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height
termsButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
} else {
termsTextView.isHidden = true
termsTextViewHeight.constant = CGFloat(0)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
}
}
func toggleBarcode() {
if (barcodeVisible) {
barcodeImage.isHidden = false
if (barcodeImage.image == nil) {
barcodeImageHeight.constant = CGFloat(0)
} else {
barcodeImageHeight.constant = self.uiscreen.height * 0.1
}
barcodeLabel.isHidden = false
let targetSize = CGSize(width: barcodeLabel.frame.width, height: CGFloat(MAXFLOAT))
barcodeLabelHeight.constant = barcodeLabel.sizeThatFits(targetSize).height
borderViewHeight.constant = CGFloat(1)
borderView2Height.constant = CGFloat(1)
border1TopSpace.constant = CGFloat(20) // 20
barcodeImageTopSpace.constant = CGFloat(10) // 10
barcodeLabelTopSpace.constant = CGFloat(10) // 10
border2TopSpace.constant = CGFloat(15) // 15
showBarcodeButton.setTitle("Απόκρυψη barcode", for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
} else {
barcodeImage.isHidden = true
barcodeImageHeight.constant = CGFloat(0)
barcodeLabel.isHidden = true
barcodeLabelHeight.constant = CGFloat(0)
borderViewHeight.constant = CGFloat(0)
borderView2Height.constant = CGFloat(0)
border1TopSpace.constant = CGFloat(0) // 20
barcodeImageTopSpace.constant = CGFloat(0) // 10
barcodeLabelTopSpace.constant = CGFloat(0) // 10
border2TopSpace.constant = CGFloat(0) // 15
showBarcodeButton.setTitle("Εμφάνιση barcode", for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
}
}
func constructBarcode() -> String? {
// EAN 13 barcode construction
let couponData = coupon?.couponset_data
let couponString = coupon?.coupon ?? ""
if (!couponString.isEmpty) {
var checkDigit = 0;
var result = 0;
var fixedCouponCode = couponString;
if (fixedCouponCode.count == 13) {
return fixedCouponCode;
}
if (fixedCouponCode.count < 12) {
let loops = 12 - fixedCouponCode.count;
var zerosStr = "";
for i in 0 ..< loops {
zerosStr += "0"
}
// fixedCouponCode = zerosStr + fixedCouponCode;
fixedCouponCode = fixedCouponCode + zerosStr;
}
var multiplier = 3;
for idx in (0 ... (fixedCouponCode.count - 1)).reversed() {
let curChar = fixedCouponCode[idx];
result += (Int(curChar) ?? 0) * multiplier;
multiplier = multiplier == 3 ? 1 : 3;
}
checkDigit = 10 - (result % 10);
let barcodeStr = fixedCouponCode + String(checkDigit);
return barcodeStr;
}
return ""
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
// MARK: - Actions
@IBAction func redeemButtomAction(_ sender: Any) {
if (isSMCoupon == true) {
var availableShopsList:Array<swiftApi.ShopAvailabilityItemModel> = []
let smCouponsetsList = swiftApi().getCouponSetsDealsList()
let couponsetUuid = coupon?.couponset_uuid
for couponset in smCouponsetsList {
if (couponset.uuid == couponsetUuid) {
availableShopsList = couponset.shop_availability ?? []
break;
}
}
if (availableShopsList.count > 0) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if let popupVC = storyboard.instantiateViewController(withIdentifier: "PopupMerchantsViewController") as? SwiftWarplyFramework.PopupMerchantsViewController {
popupVC.modalPresentationStyle = .overCurrentContext
popupVC.modalTransitionStyle = .crossDissolve
popupVC.availableShopsList = availableShopsList
// popupVC.headerText = "Βρες το προϊον στα supermarket"
// popupVC.buttonTitle = "Βρες το"
popupVC.buttonIcon = "shopping_cart"
// popupVC.footerText = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
self.present(popupVC, animated: true, completion: nil)
}
} else {
self.showDialog("Δεν υπάρχουν διαθέσιμα supermarkets","")
}
} else {
let couponSetData: swiftApi.CouponSetItemModel? = self.coupon?.couponset_data
let couponName = couponSetData?.name ?? ""
swiftApi().logTrackersEvent("click", ("ShareCoupon:" + couponName))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "ShareViewController") as! SwiftWarplyFramework.ShareViewController
vc.coupon = self.coupon
vc.isFromWallet = self.isFromWallet
self.navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func showBarcodeAction(_ sender: Any) {
barcodeVisible = !barcodeVisible
toggleBarcode()
}
@IBAction func termsButtonAction(_ sender: Any) {
termsVisible = !termsVisible
toggleTerms()
}
@IBAction func mapButtonAction(_ sender: Any) {
if (isSMCoupon == true) {
let couponSetData: swiftApi.CouponSetItemModel? = self.coupon?.couponset_data
let couponName = couponSetData?.name ?? ""
swiftApi().logTrackersEvent("click", ("ShareCoupon:" + couponName))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "ShareViewController") as! SwiftWarplyFramework.ShareViewController
vc.coupon = self.coupon
vc.isFromWallet = self.isFromWallet
self.navigationController?.pushViewController(vc, animated: true)
} else {
swiftApi().logTrackersEvent("click", "SeeShops")
let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
if (isMarket == true) {
vc.isMarket = true
} else {
vc.coupon = coupon
}
self.navigationController?.pushViewController(vc, animated: true)
}
// if (mapBtnVisible == true) {
// swiftApi().logTrackersEvent("click", "SeeShops")
// let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
// vc.couponSet = coupon?.couponset_data
// self.navigationController?.pushViewController(vc, animated: true)
// } else if (eshopBtnVisible == true) {
// if (eshopWebsite != "") {
// guard let websiteUrl = URL(string: eshopWebsite) else {
// print("Error creating URL")
// return
// }
// // check if link can be opened.
// guard UIApplication.shared.canOpenURL(websiteUrl) else {
// return
// }
// swiftApi().logTrackersEvent("click", "SeeShopWebsite")
// UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
// }
// }
}
}
//
// CouponViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 5/5/22.
//
import UIKit
import SwiftEventBus
@objc public class CouponViewController: UIViewController, UITextViewDelegate {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var scrollContentView: UIView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var descriptionTextView: UnselectableTappableTextView!
@IBOutlet weak var descriptionTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var redeemButton: UIButton!
@IBOutlet weak var termsButton: UIButton!
@IBOutlet weak var termsTextView: UnselectableTappableTextView!
@IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var topBorderLine: UIImageView!
public var ccms: swiftApi.LoyaltyContextualOfferModel?
public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
let uiscreen: CGRect = UIScreen.main.bounds
var termsVisible: Bool = false;
public var couponset: swiftApi.CouponSetItemModel?
public var campaign: swiftApi.CampaignItemModel?
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
descriptionTextView.delegate = self
termsTextView.delegate = self
// Do any additional setup after loading the view.
setBackButton()
setNavigationTitle("Εκπτωτικό κουπόνι")
// if ((profile != nil) && (profile?._nonTelco == true)) {
if (swiftApi().getUserNonTelco() == true) {
nonTelcoDialog("Αδυναμία ενεργοποίησης", "Πρόσθεσε σύνδεση COSMOTE σταθερής, κινητής ή TV για να έχεις πρόσβαση στις προσφορές.");
}
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// scrollView.clipsToBounds = true
// scrollView.layer.cornerRadius = 30
// scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
//
// topBorderLine.translatesAutoresizingMaskIntoConstraints = false
// topBorderLine.image = image
// topBorderLine.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
// ])
couponImage.load(link: couponset?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
couponImage.contentMode = .scaleAspectFill
couponImageHeight.constant = 222 // 255 //230 // 253 // self.uiscreen.height * 0.25
nameLabel.text = couponset?.name ?? ""
let htmlDescrText = couponset?.description ?? ""
descriptionTextView.attributedText = htmlDescrText.htmlToAttributedString
descriptionTextView.font = UIFont(name: "PeridotPE-Regular", size: 16)
descriptionTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
descriptionTextView.textAlignment = .center
descriptionTextView.isScrollEnabled = false
descriptionTextView.isUserInteractionEnabled = true
descriptionTextView.isEditable = false
descriptionTextView.isSelectable = true
descriptionTextView.dataDetectorTypes = [.link]
let targetSize = CGSize(width: descriptionTextView.frame.width, height: CGFloat(MAXFLOAT))
descriptionTextViewHeight.constant = descriptionTextView.sizeThatFits(targetSize).height
redeemButton.setTitle("Απόκτησέ το δωρεάν", for: .normal)
redeemButton.setTitleColor(.white, for: .normal)
redeemButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
redeemButton.layer.cornerRadius = 16.0
// redeemButton.frame = CGRect(x: 0.0, y: 0.0, width: redeemButton.intrinsicContentSize.width, height: 50)
redeemButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
// Fix width for ipad
if UIDevice.current.userInterfaceIdiom == .pad {
// iPad
redeemButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 19)
// redeemButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
} else {
// not iPad (iPhone, mac, tv, carPlay, unspecified)
redeemButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 17)
// redeemButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
}
termsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
termsButton.setTitle("Όροι χρήσης", for: .normal)
termsButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
termsButton.semanticContentAttribute = .forceRightToLeft
termsButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
termsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
termsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
termsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
let htmlText = couponset?.terms ?? ""
termsTextView.attributedText = htmlText.htmlToAttributedString
termsTextView.font = UIFont(name: "PeridotPE-Regular", size: 14)
termsTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
termsTextView.textAlignment = .left
termsTextView.isScrollEnabled = false
termsTextView.isUserInteractionEnabled = true
termsTextView.isEditable = false
termsTextView.isSelectable = true
termsTextView.dataDetectorTypes = [.link]
toggleTerms()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "CouponsetScreen")
self.navigationController?.hideHairline()
}
public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UIApplication.shared.open(URL)
// Disable `.preview` by 3D Touch and other interactions
return false
}
// MARK: - Functions
func nonTelcoDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
self.navigationController?.popViewController(animated: true)
// self.dismiss(animated: true, completion: {})
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func toggleTerms() {
if (termsVisible) {
termsTextView.isHidden = false
let targetSize = CGSize(width: termsTextView.frame.width, height: CGFloat(MAXFLOAT))
termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height
termsButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
} else {
termsTextView.isHidden = true
termsTextViewHeight.constant = CGFloat(0)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
}
}
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func redeemCouponSetRequest(uuid: String, communication_uuid: String) {
showSpinner()
redeemButton.isEnabled = false
if (ccms == nil) {
// swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in
swiftApi().redeemCouponSetAsyncInternal(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in
self.hideSpinner()
self.redeemButton.isEnabled = true
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
})
} else {
// TODO: MAybe change user_msisdn: profile?._msisdn ?? ""
// swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, user_msisdn: profile?._msisdn ?? "", businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), redeemCouponSetCallback, failureCallback: {errorCode in
swiftApi().redeemCouponSetAsyncInternal(uuid: uuid, communication_uuid: communication_uuid, user_msisdn: profile?._msisdn ?? "", businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), redeemCouponSetCallback, failureCallback: {errorCode in
self.hideSpinner()
self.redeemButton.isEnabled = true
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
})
}
}
// func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
func redeemCouponSetCallback (_ response: swiftApi.RedeemCouponSetResponseModel?) -> Void {
hideSpinner()
self.redeemButton.isEnabled = true
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "true")
SwiftEventBus.post("firebase", sender: firebaseEvent)
if (self.ccms != nil) {
let ccmsEnabled = swiftApi.WarplyCCMSEnabledModel()
ccmsEnabled._isActivated = true
SwiftEventBus.post("ccms_enabled", sender: ccmsEnabled)
}
self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί και βρίσκεται στην ενότητα My Rewards.")
/* OLD Addition start */
// swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
// swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
//
// func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
// if (couponsData != nil) {
//
// DispatchQueue.main.async {
// SwiftEventBus.post("coupons_fetched")
// }
// } else {
// }
// }
//
// func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
// if (campaignsData != nil) {
// DispatchQueue.main.async {
// SwiftEventBus.post("campaigns_retrieved")
// }
// } else {
// }
// }
/* OLD Addition end */
/* New Addition start */
if let newCoupon = response?.getCoupon {
newCoupon.status = 1
if let couponsetData = self.couponset {
newCoupon.setCouponSetData(couponsetData)
for merchant in self.merchantList {
if (merchant._uuid == couponsetData.merchant_uuid) {
newCoupon.merchant_details = merchant
break;
}
}
}
swiftApi().addCouponItem(newCoupon: newCoupon)
SwiftEventBus.post("coupons_fetched")
if let tempCampaign = self.campaign {
swiftApi().removeCampaignItem(campaignArg: tempCampaign)
swiftApi().getCampaignsAsyncNewInternal(getCampaignsCallback, failureCallback: {errorCode in})
}
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("campaigns_retrieved")
}
}
}
}
/* New Addition end */
} else if (response?.getStatus == 3) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Το κουπόνι δεν είναι διαθέσιμο για αγορά")
} else if (response?.getStatus == 5) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Δεν έχεις αρκετούς πόντους")
} else if (response?.getStatus == 6) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Το κουπόνι εξαντλήθηκε","Μείνε συντονισμένος για νέες προσφορές και κουπόνια.")
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
func showSuccessDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
let cancelButton = UIAlertAction(title: "Κλείσιμο", style: .default, handler: { action in
switch action.style{
case .default:
self.navigationController?.popViewController(animated: true)
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
})
// cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(UIAlertAction(title: "Δες το κουπόνι", style: .default, handler: { action in
switch action.style{
case .default:
self.navigationController?.popViewController(animated: true)
// SwiftEventBus.post("open_my_rewards")
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: SwiftWarplyFramework.CouponsViewController.self))
if let vc = storyboard.instantiateViewController(withIdentifier: "CouponsViewController") as? SwiftWarplyFramework.CouponsViewController{
self.navigationController?.pushViewController(vc,animated: true)
}
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
// MARK: - Actions
@IBAction func redeemButtomAction(_ sender: Any) {
// SwiftEventBus.post("couponRedeem", sender: coupon)
swiftApi().logTrackersEvent("click", ("RetrieveCoupon:" + (couponset?.uuid ?? "")))
redeemCouponSetRequest(uuid: couponset?.uuid ?? "", communication_uuid: campaign?.session_uuid ?? "")
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "MakeItAPresentViewController") as! SwiftWarplyFramework.MakeItAPresentViewController
// self.navigationController?.pushViewController(vc, animated: true)
}
@IBAction func termsButtonAction(_ sender: Any) {
termsVisible = !termsVisible
toggleTerms()
}
}
//
// CouponsTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/5/22.
//
import Foundation
import UIKit
@objc public class CouponsTableViewCell: UITableViewCell {
@IBOutlet weak var couponBgImage: UIImageView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var borderView: UIView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var dicountLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var expirationLabel: UILabel!
@IBOutlet weak var expirationRedView: UIView!
@IBOutlet weak var expirationRedImage: UIImageView!
@IBOutlet weak var expirationRedLabel: UILabel!
let smCouponsetsList = swiftApi().getCouponSetsDealsList()
// Variables for the view, image, and button
var selectView: UIView!
var selectImageView: UIImageView!
var selectButton: UIButton!
// Boolean to track if the selectView should be visible
var isSelectViewVisible: Bool = false {
didSet {
selectView.isHidden = !isSelectViewVisible
}
}
// Boolean to track the selection state of the cell
var isSelectedCell: Bool = false {
didSet {
updateSelectionState()
}
}
// Action closure for button tap inside the cell
var selectButtonAction: (() -> Void)?
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.couponImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.couponImage.image = image
}
}
}
else {
self.couponImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
couponBgImage.image = UIImage(named: "coupon_bg_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
borderView.addDashedBorderVertical(color: UIColor(red: 0.62, green: 0.62, blue: 0.61, alpha: 1.00), width: 1.0, height: 110.0)
setupSelectButton()
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 8, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
// Setup Select Button UI and layout
func setupSelectButton() {
// Create the container view (selectView)
selectView = UIView()
selectView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(selectView)
// Set selectView constraints
NSLayoutConstraint.activate([
selectView.widthAnchor.constraint(equalToConstant: 26),
selectView.heightAnchor.constraint(equalToConstant: 26),
selectView.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 6),
selectView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -16)
])
// Create the UIImageView inside selectView
selectImageView = UIImageView()
selectImageView.contentMode = .scaleAspectFit
selectImageView.translatesAutoresizingMaskIntoConstraints = false
selectView.addSubview(selectImageView)
// Set imageView constraints to match the size of the selectView
NSLayoutConstraint.activate([
selectImageView.leadingAnchor.constraint(equalTo: selectView.leadingAnchor),
selectImageView.trailingAnchor.constraint(equalTo: selectView.trailingAnchor),
selectImageView.topAnchor.constraint(equalTo: selectView.topAnchor),
selectImageView.bottomAnchor.constraint(equalTo: selectView.bottomAnchor)
])
// Create the transparent button on top of the imageView
selectButton = UIButton(type: .custom)
selectButton.backgroundColor = .clear // Make the button transparent
selectButton.translatesAutoresizingMaskIntoConstraints = false
selectButton.addTarget(self, action: #selector(selectButtonTapped), for: .touchUpInside)
selectView.addSubview(selectButton)
// Set button constraints to match the size of the selectView
NSLayoutConstraint.activate([
selectButton.leadingAnchor.constraint(equalTo: selectView.leadingAnchor),
selectButton.trailingAnchor.constraint(equalTo: selectView.trailingAnchor),
selectButton.topAnchor.constraint(equalTo: selectView.topAnchor),
selectButton.bottomAnchor.constraint(equalTo: selectView.bottomAnchor)
])
// Initially hide the selectView (selectView)
selectView.isHidden = true
}
// Button action handler
@objc func selectButtonTapped() {
// Trigger the action closure when the button is pressed
selectButtonAction?()
}
// Update the cell's appearance based on selection state
func updateSelectionState() {
// Update the image based on the new state
if (isSelectedCell) {
selectImageView.image = UIImage(named: "circle_checked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Selected image
} else {
selectImageView.image = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Unselected image
}
}
func configureCell(coupon: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data
nameLabel.text = ""
// for merchant in merchantList {
// // if (merchant._uuid == couponSetData?.merchant_uuid) {
// if (merchant._uuid == coupon.merchant_uuid) {
// // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
// nameLabel.text = merchant._admin_name
// break;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = coupon.merchant_details
self.postImageURL = merchantDetails?._img_preview
nameLabel.text = merchantDetails?._admin_name
// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// nameLabel.text = couponSetData?.name ?? ""
let discount = couponSetData?.discount_type == "value" ? ((coupon.discount ?? "") + "€")
: couponSetData?.discount_type == "percentage" ? ((coupon.discount ?? "") + "%")
: couponSetData?.discount_type == "plus_one" ? "1+1"
: ((coupon.discount ?? "") + "€")
dicountLabel.text = discount
// let htmlText = couponSetData?.inner_text ?? ""
// discriptionLabel.text = htmlText.htmlToString
discriptionLabel.text = couponSetData?.inner_text ?? ""
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
}
func configureCell(coupon: swiftApi.CouponItemModel, isMarket: Bool) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
var couponSetData: swiftApi.CouponSetItemModel?
for item in smCouponsetsList {
if (item.uuid == coupon.couponset_uuid) {
couponSetData = item
break;
}
}
// // Add shadow
contentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
contentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
contentView.layer.shadowOpacity = 1.0
contentView.layer.shadowRadius = 1.0
expirationLabel.isHidden = true
expirationRedView.isHidden = true
expirationLabel.text = ""
expirationRedLabel.text = ""
if (coupon.status == 1) { // Active status 1
// Add shadow
// self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
// self.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
// self.layer.shadowOpacity = 1.0
// self.layer.shadowRadius = 6.0
// couponBgImage.image = UIImage(named: "coupon_bg", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponImage.layer.opacity = 1
borderView.layer.opacity = 1
nameLabel.layer.opacity = 1
dicountLabel.layer.opacity = 1
discriptionLabel.layer.opacity = 1
expirationLabel.isHidden = false
expirationRedView.isHidden = true
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
let formatter = DateFormatter()
formatter.dateFormat = "dd/MM/yyyy"
let today = Date()
// let firstDate = formatter.date(from: "01/08/2017")
// let secondDate = formatter.date(from: "22/04/2023")
if let couponExpiration = coupon.expiration, let secondDate = formatter.date(from: couponExpiration) {
let calendar = NSCalendar.current
let date1 = calendar.startOfDay(for: today)
let date2 = calendar.startOfDay(for: secondDate)
let differenceComponents = calendar.dateComponents([.day], from: date1, to: date2)
if let daysDifference = differenceComponents.day {
if ((daysDifference >= 0) && (daysDifference <= 15)) {
expirationLabel.isHidden = true
expirationRedView.isHidden = false
expirationRedView.layer.cornerRadius = 10.0
expirationRedView.backgroundColor = UIColor(red: 0.72, green: 0.88, blue: 0.94, alpha: 1.00)
expirationRedImage.image = UIImage(named: "ic_time_forward_blue", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
let normalText1 = "Ισχύει έως "
let redText = (coupon.expiration ?? "")
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-SBold", size: 12) ?? UIFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attrRed = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-SBold", size: 12) ?? UIFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: UIColor(red: 0.00, green: 0.29, blue: 0.53, alpha: 1.00)]
let attributedString = NSMutableAttributedString(string:normalText1, attributes:attrRegular)
let RedString = NSMutableAttributedString(string: redText, attributes:attrRed)
attributedString.append(RedString)
expirationRedLabel.attributedText = attributedString
} else {
expirationLabel.isHidden = false
expirationRedView.isHidden = true
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
}
}
}
} else if (coupon.status == 0) { // Redeemed status 0
// couponBgImage.image = UIImage(named: "coupon_bg_grey", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
expirationLabel.isHidden = false
expirationRedView.isHidden = true
expirationLabel.text = "Το κουπόνι έληξε"
couponImage.layer.opacity = 0.29
borderView.layer.opacity = 0.29
nameLabel.layer.opacity = 0.29
dicountLabel.layer.opacity = 0.29
discriptionLabel.layer.opacity = 0.29
} else { // Expired status -1
expirationLabel.isHidden = false
expirationRedView.isHidden = true
expirationLabel.text = "Το κουπόνι έληξε"
couponImage.layer.opacity = 0.29
borderView.layer.opacity = 0.29
nameLabel.layer.opacity = 0.29
dicountLabel.layer.opacity = 0.29
discriptionLabel.layer.opacity = 0.29
}
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
nameLabel.text = ""
for merchant in merchantList {
if (merchant._uuid == coupon.merchant_uuid) {
// couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
nameLabel.text = merchant._admin_name
break;
}
}
self.postImageURL = couponSetData?.img_preview
// let priceFloat = Float(round(100 * (Float(coupon.discount ?? "0.0") ?? 0.0 )) / 100)
// var priceString = "0"
// priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
// dicountLabel.text = priceString + "€"
dicountLabel.text = (coupon.discount ?? "").replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) + "€"
let htmlText = coupon.inner_text ?? ""
discriptionLabel.text = htmlText.htmlToString
// discriptionLabel.text = coupon.inner_text ?? ""
}
func configureCell(coupon: swiftApi.CouponItemModel, isSMCoupon: Bool) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data
nameLabel.text = ""
// for merchant in merchantList {
// // if (merchant._uuid == couponSetData?.merchant_uuid) {
// if (merchant._uuid == coupon.merchant_uuid) {
// // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
// nameLabel.text = merchant._admin_name
// break;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = coupon.merchant_details
self.postImageURL = couponSetData?.img_preview
nameLabel.text = merchantDetails?._admin_name
// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// nameLabel.text = couponSetData?.name ?? ""
let discount = couponSetData?.discount_type == "value" ? ((coupon.discount ?? "") + "€")
: couponSetData?.discount_type == "percentage" ? ((coupon.discount ?? "") + "%")
: couponSetData?.discount_type == "plus_one" ? "1+1"
: ((coupon.discount ?? "") + "€")
dicountLabel.text = discount
// let htmlText = couponSetData?.inner_text ?? ""
// discriptionLabel.text = htmlText.htmlToString
discriptionLabel.text = couponSetData?.inner_text ?? ""
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
}
// Configure the cell with visibility of the selectView, a selected state, and select Button Action
func showSelectButton(isSelectViewVisible: Bool, isSelected: Bool, buttonAction: @escaping () -> Void) {
self.isSelectViewVisible = isSelectViewVisible
self.isSelectedCell = isSelected
self.selectButtonAction = buttonAction
if (isSelected) {
couponBgImage.image = UIImage(named: "coupon_bg_2_selected", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
} else {
couponBgImage.image = UIImage(named: "coupon_bg_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
// Set nameLabel constraints to not overlap selectView
NSLayoutConstraint.activate([
nameLabel.trailingAnchor.constraint(equalTo: selectView.leadingAnchor, constant: -5)
])
}
}
//
// CouponsViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 4/5/22.
//
import Foundation
import UIKit
import SwiftEventBus
@objc public class CouponsViewController: UIViewController {
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var emptyView: UIView!
@IBOutlet weak var emptyViewHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabel: UILabel!
public var coupons:Array<swiftApi.CouponItemModel> = []
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in
DispatchQueue.main.async {
self.coupons = swiftApi().getCouponList()
self.tableView.reloadData()
self.handleEmptyView()
}
}
getCouponsRequest()
setBackButton()
// setNavigationTitle("GIFTS FOR YOU")
setNavigationTitle("FREE COUPONS")
// backgroundImage.image = UIImage(named: "coupons_scrollview_dark", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
tableView.delegate = self
tableView.dataSource = self
// tableView.clipsToBounds = true
// tableView.layer.cornerRadius = 30
// tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
tableView.contentInset.top = 30
emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!"
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "ActiveCouponsScreen")
self.coupons = swiftApi().getCouponList()
self.tableView.reloadData()
self.handleEmptyView()
self.navigationController?.hideHairline()
}
// MARK: - Functions
func handleEmptyView() {
if (self.coupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
}
// MARK: - API Functions
func getCouponsRequest() {
swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in
self.coupons = []
})
}
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
let activeCouponData = swiftApi().filterActiveCoupons(couponsData ?? [])
self.coupons = activeCouponData
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
// self.tableView.reloadData()
// self.handleEmptyView()
}
} else {
self.coupons = []
}
}
}
// MARK: - TableView
extension CouponsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.coupons.count
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 130.0 + 8.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
cell.configureCell(coupon: coupons[indexPath.row])
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row])
// Logs
let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? ""))
print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? ""))
swiftApi().logTrackersEvent("click", ("Coupon:" + (couponSetData?.name ?? "")))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController
vc.coupon = coupons[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
}
}
//
// DetailsViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 5/5/22.
//
import Foundation
import UIKit
@objc public class DetailsViewController: UIViewController {
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("Ανάλυση")
}
}
//
// GiftsViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 5/5/22.
//
import Foundation
import UIKit
import SwiftEventBus
@objc public class GiftsViewController: UIViewController {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var topBorderShadow: UIImageView!
public var campaigns:Array<swiftApi.CampaignItemModel> = [] {
didSet {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
public var seasonalList:Array<swiftApi.LoyaltyGiftsForYouPackage> = swiftApi().getSeasonalList()
public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns()
public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
var timerGFY: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("GIFTS FOR YOU", "bold")
tableView.delegate = self
tableView.dataSource = self
SwiftEventBus.onMainThread(self, name: "ccms_retrieved") { result in
print("===== SwiftEventBus ccms_retrieved =====")
self.refreshData()
}
SwiftEventBus.onMainThread(self, name: "campaigns_retrieved") { result in
print("===== SwiftEventBus campaigns_retrieved =====")
self.refreshData()
}
SwiftEventBus.onMainThread(self, name: "seasonals_retrieved") { result in
print("===== SwiftEventBus seasonals_retrieved =====")
self.refreshData()
}
// tableView.clipsToBounds = true
// tableView.layer.cornerRadius = 30
// tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
tableView.contentInset.top = 25
// Add Top left corner radius
// mainView.clipsToBounds = true
// mainView.layer.cornerRadius = 30
// mainView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
mainView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
// let image = UIImage(named: "top_border_shadow", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
//
// topBorderShadow.translatesAutoresizingMaskIntoConstraints = false
// topBorderShadow.image = image
// topBorderShadow.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderShadow.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderShadow.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderShadow.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderShadow.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderShadow.heightAnchor.constraint(equalTo: topBorderShadow.widthAnchor, multiplier: 1/aspectR)
// ])
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "GiftsForYouScreen")
self.refreshData()
self.startTimer()
self.navigationController?.hideHairline()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
func refreshData() -> Void {
var tempCampaigns:Array<swiftApi.CampaignItemModel> = []
self.campaigns = []
self.seasonalList = swiftApi().getSeasonalList()
self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns()
self.loyaltyList = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
if (self.seasonalList.count > 0) {
for seasonalItem in self.seasonalList {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = seasonalItem._title
newCampaign._logo_url = seasonalItem._imageUrl
newCampaign._loyaltyPackageId = seasonalItem._loyaltyPackageId
tempCampaigns.append(newCampaign)
}
}
if (self.ccmsList.count > 0) {
for ccmsItem in self.ccmsList {
if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_GIFTS4U")) {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = ccmsItem._title
newCampaign._logo_url = ccmsItem._imageUrl
newCampaign._ccms = ccmsItem
tempCampaigns.append(newCampaign)
}
}
}
if (self.loyaltyList.count > 0) {
tempCampaigns = tempCampaigns + self.loyaltyList
}
self.campaigns = tempCampaigns
self.tableView.reloadData()
}
func startTimer() {
print("========= GFY Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".gfy.timer")
timerGFY = DispatchSource.makeTimerSource(queue: queue)
timerGFY!.schedule(deadline: .now(), repeating: .seconds(1))
timerGFY!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= GFY interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerGFY!.resume()
}
func stopTimer() {
print("========= GFY Timer Stopped! =========")
timerGFY?.cancel()
timerGFY = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "GiftsForYou")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
}
// MARK: - TableView
extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.campaigns.count
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 140.0 + 10.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "InboxTableViewCellId", for: indexPath) as! InboxTableViewCell
let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
cell.configureCell(ccms: item)
break;
}
}
}
} else if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "" && isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
cell.configureCell(ccms: item)
break;
}
}
}
} else {
cell.configureCell(campaign: campaigns[indexPath.row])
}
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (campaigns[indexPath.row]._ccms != nil) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (campaigns[indexPath.row]._ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("Contextual:" + (campaigns[indexPath.row]._ccms?._sessionId ?? "")))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "ContextualViewController") as! SwiftWarplyFramework.ContextualViewController
vc.ccms = campaigns[indexPath.row]._ccms
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
} else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
swiftApi().logTrackersEvent("click", ("Telco:" + (item._sessionId)))
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (item._title))
firebaseEvent.setParameter = ("type", "gift")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController
vc.ccms = item
vc.campaign = campaigns[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
}
} else if (campaigns[indexPath.row]._campaign_type == "coupon") {
let couponsetUuid = campaigns[indexPath.row]._couponset
if (couponsetUuid != "" && couponsetUuid != nil) {
let couponsetsList = swiftApi().getCouponSetList()
for item in couponsetsList {
if (item.uuid == couponsetUuid) {
swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaigns[indexPath.row].session_uuid ?? "")))
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (item.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
vc.couponset = item
vc.campaign = campaigns[indexPath.row]
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
vc.ccms = item
break;
}
}
}
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
} else if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") {
let status = swiftApi().getNetworkStatus()
if (status == -1 || status == 0) {
self.showDialog("Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.")
} else {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
var params = ""
let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
if (isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
ccmsCampaignFound = item
}
}
swiftApi().logTrackersEvent("click", ("Contextual:" + (ccmsCampaignFound._sessionId)))
url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound)
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
params = swiftApi().constructCampaignParams(campaigns[indexPath.row])
}
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaigns[indexPath.row])
print("CCMS_CLICK " + String(data: data, encoding: .utf8)!)
} else {
swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaigns[indexPath.row].session_uuid ?? "")))
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
params = swiftApi().constructCampaignParams(campaigns[indexPath.row])
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaigns[indexPath.row])
print("GFY_CLICK " + String(data: data, encoding: .utf8)!)
}
print("CampaignUrl url onclick: " + url)
vc.campaignUrl = url
vc.params = params
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
}
} else {
if (campaigns[indexPath.row].session_uuid != nil && campaigns[indexPath.row].session_uuid != "") {
let status = swiftApi().getNetworkStatus()
if (status == -1 || status == 0) {
self.showDialog("Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.")
} else {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
var params = ""
let isCcmsOffer = (campaigns[indexPath.row].ccms_offer != nil) && (campaigns[indexPath.row].ccms_offer != "") && (campaigns[indexPath.row].ccms_offer == "true")
if (isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaigns[indexPath.row].session_uuid) {
ccmsCampaignFound = item
}
}
swiftApi().logTrackersEvent("click", ("Contextual:" + (ccmsCampaignFound._sessionId)))
url = swiftApi().constructCcmsUrl(campaigns[indexPath.row], ccmsCampaignFound)
params = swiftApi().constructCcmsParams(campaigns[indexPath.row], ccmsCampaignFound)
} else {
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
params = swiftApi().constructCampaignParams(campaigns[indexPath.row])
}
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaigns[indexPath.row])
print("CCMS_CLICK " + String(data: data, encoding: .utf8)!)
} else {
swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaigns[indexPath.row].session_uuid ?? "")))
url = swiftApi().constructCampaignUrl(campaigns[indexPath.row])
params = swiftApi().constructCampaignParams(campaigns[indexPath.row])
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaigns[indexPath.row])
print("GFY_CLICK " + String(data: data, encoding: .utf8)!)
}
print("CampaignUrl url onclick: " + url)
vc.campaignUrl = url
vc.params = params
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
} else {
let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
seasonalEvent._title = campaigns[indexPath.row]._title ?? ""
seasonalEvent._imageUrl = campaigns[indexPath.row]._logo_url ?? ""
seasonalEvent._loyaltyPackageId = campaigns[indexPath.row]._loyaltyPackageId ?? ""
SwiftEventBus.post("seasonal", sender: seasonalEvent)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (campaigns[indexPath.row]._title ?? ""))
firebaseEvent.setParameter = ("type", "seasonal")
SwiftEventBus.post("firebase", sender: firebaseEvent)
}
}
}
func getSingleCampaignAsyncRequest(sessionUuid: String) {
swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
}
func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
if (getSingleCampaignData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
}
//
// HistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class HistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldCouponList()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = true
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
// Add shadow
self.tableView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.tableView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.tableView.layer.shadowOpacity = 1.0
self.tableView.layer.shadowRadius = 1.0
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
items = swiftApi().getOldCouponList()
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
self.tableView.reloadData()
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.CouponItemModel>?) -> Void {
self.items = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// if (indexPath.section == 0) {
//// return hasMessage ? (items.count > 0 ? 380.0 : 480.0) : 280
// return hasMessage ? UITableView.automaticDimension : 280
// }
//
//// return 140.0
return UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: false)
return cell
}
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
}
if (self.showMore && indexPath.row == 3) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
cell.configureCell(item: items[indexPath.row])
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if (self.showMore && indexPath.row == 3) {
self.items = swiftApi().getOldCouponList()
self.showMore = false
self.tableView.reloadData()
}
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 1, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: viewInner.frame.width - 40, height: 20))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 20)
titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.text = "Αναλυτικά"
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
viewInner.addSubview(titleLabel)
return view
} else {
return nil
}
} else {
return nil
}
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (self.items.count > 0) {
return 50.0
} else {
return 0.0
}
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
if (section == 1 && self.items.count > 0) {
return 20.0
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 30))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 0, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
return view
} else {
return nil
}
} else {
return nil
}
}
}
//
// InboxTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/6/22.
//
import UIKit
@objc public class InboxTableViewCell: UITableViewCell {
@IBOutlet weak var inboxView: UIView!
@IBOutlet weak var campaignImage: UIImageView!
@IBOutlet weak var newBadgeImage: UIImageView!
@IBOutlet weak var campaignTitleLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.campaignImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.campaignImage.image = image
}
}
}
else {
self.campaignImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
inboxView.layer.cornerRadius = 16.0
inboxView.clipsToBounds = true
newBadgeImage.image = UIImage(named: "new_icon_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
newBadgeImage.isHidden = true
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
func configureCell(campaign: swiftApi.CampaignItemModel) {
// campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
self.postImageURL = campaign.logo_url ?? ""
campaignTitleLabel.text = campaign.title ?? ""
if (campaign.is_new == true) {
newBadgeImage.isHidden = false
} else{
newBadgeImage.isHidden = true
}
}
func configureCell(ccms: swiftApi.LoyaltyContextualOfferModel) {
// campaignImage.load(link: ccms._imageUrl , placeholder: UIImage(), cache: URLCache())
self.postImageURL = ccms._imageUrl
campaignTitleLabel.text = ccms._title
newBadgeImage.isHidden = true
}
}
//
// LoyaltyAnalysisViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
import SwiftEventBus
@objc public class LoyaltyAnalysisViewController: UIViewController {
@IBOutlet weak var leftButton: UIButton!
@IBOutlet weak var rightButton: UIButton!
@IBOutlet weak var leftLineView: UIView!
@IBOutlet weak var rightLineView: UIView!
@IBOutlet weak var contentView: UIView!
var pageController: UIPageViewController!
var tabSelected = 0
var timerHistory: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
// setup view
setBackButton()
setNavigationTitle("Ανάλυση")
// tab
leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
leftButton.setTitle("Εξαργυρωμένα", for:.normal)
leftButton.backgroundColor = . clear
leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
rightButton.setTitle("Μοιρασμένα δώρα", for:.normal)
rightButton.backgroundColor = . clear
rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
// leftLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
// rightLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
leftLineView.isHidden = false
rightLineView.isHidden = true
// pages
pageController = UIPageViewController(transitionStyle:.scroll, navigationOrientation:.horizontal)
pageController.dataSource = self;
pageController.delegate = self;
pageController.view.frame = contentView.bounds;
addChild(pageController)
contentView.addSubview(pageController.view)
pageController .didMove(toParent: self)
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:false)
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "LoyaltyHistoryScreen")
self.startTimer()
self.navigationController?.hideHairline()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
func startTimer() {
print("========= GiftsCalculator Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".history.timer")
timerHistory = DispatchSource.makeTimerSource(queue: queue)
timerHistory!.schedule(deadline: .now(), repeating: .seconds(1))
timerHistory!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= GiftsCalculator interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerHistory!.resume()
}
func stopTimer() {
print("========= GiftsCalculator Timer Stopped! =========")
timerHistory?.cancel()
timerHistory = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "GiftsCalculator")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
////////////////////////////////////////////////////////////////////////////////
private func viewControllerAt(_ index:Int) -> AnalysisChildViewController?
{
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if (index == 1) {
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabShared"))
let analysisVC = storyboard.instantiateViewController(withIdentifier:"SharingHistoryViewController") as! SwiftWarplyFramework.SharingHistoryViewController
analysisVC.index = index;
return analysisVC;
}
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabExpired"))
let analysisVC = storyboard.instantiateViewController(withIdentifier:"HistoryViewController") as! SwiftWarplyFramework.HistoryViewController
analysisVC.index = index;
return analysisVC;
}
// MARK: - Handlers
@IBAction func handleLeft() {
if (tabSelected != 0) {
self.tabSelected = 0
UIView.animate(withDuration: 2.0, delay: 0.0) {
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
}
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.reverse, animated:true)
}
}
@IBAction func handleRight() {
if (tabSelected != 1) {
self.tabSelected = 1
UIView.animate(withDuration: 2.0, delay: 0.0) {
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
}
let analysisVC = self.viewControllerAt(1)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:true)
}
}
}
// MARK: - PageViewController
extension LoyaltyAnalysisViewController: UIPageViewControllerDataSource, UIPageViewControllerDelegate {
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 0) {
return nil;
}
index -= 1;
return viewControllerAt(index);
}
return nil;
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 1) {
return nil;
}
index += 1;
return viewControllerAt(index);
}
return nil;
}
public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
if (!completed) {
return;
}
if let childVCs = pageViewController.viewControllers as? [AnalysisChildViewController] {
let currentIndex = childVCs[0].index
if (currentIndex == 0) {
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
self.tabSelected = 0
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
} else {
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
self.tabSelected = 1
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
}
}
}
}
//
// LoyaltyHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 25/10/23.
//
import Foundation
import UIKit
import SwiftEventBus
@objc public class LoyaltyHistoryViewController: UIViewController {
@IBOutlet weak var sectionTitleLabel: UILabel!
@IBOutlet weak var historySectionView: UIView!
@IBOutlet weak var sumBadgeImage: UIImageView!
@IBOutlet weak var sumBadgeLabel: UILabel!
@IBOutlet weak var sumBannerLabel: UILabel!
@IBOutlet weak var dfyBannerParentView: UIView!
@IBOutlet weak var dfyBannerInnerParentView: UIView!
@IBOutlet weak var dfyBannerInnerView: UIView!
@IBOutlet weak var dfyBadgeImage: UIImageView!
@IBOutlet weak var dfyBadgeLabel: UILabel!
@IBOutlet weak var dfyBannerLabel: UILabel!
@IBOutlet weak var marketBannerParentView: UIView!
@IBOutlet weak var marketBannerInnerView: UIView!
@IBOutlet weak var marketBadgeImage: UIImageView!
@IBOutlet weak var marketBadgeLabel: UILabel!
@IBOutlet weak var marketBannerLabel: UILabel!
@IBOutlet weak var gfyBannerParentView: UIView!
@IBOutlet weak var gfyBannerInnerView: UIView!
@IBOutlet weak var couponBadgeImage: UIImageView!
@IBOutlet weak var couponBadgeLabel: UILabel!
@IBOutlet weak var gfyBannerLabel: UILabel!
@IBOutlet weak var boxBannerParentView: UIView!
@IBOutlet weak var boxBannerInnerParentView: UIView!
@IBOutlet weak var boxBannerInnerView: UIView!
@IBOutlet weak var boxBadgeImage: UIImageView!
@IBOutlet weak var boxBadgeLabel: UILabel!
@IBOutlet weak var boxBannerLabel: UILabel!
public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public var boxCoupons:Array<swiftApi.ActiveBoxCouponModel> = swiftApi().getActiveBoxCoupons()
var totalCouponValue = swiftApi().getDealsCouponsSum()
var totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
var unifiedCouponsDiscount:Float = 0.0
var boxCouponValue = swiftApi().getBoxCouponsSum()
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in
DispatchQueue.main.async {
self.coupons = swiftApi().getCouponList()
self.totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
self.loyaltyBadge = swiftApi().getLoyaltyBadge()
// self.tableView.reloadData()
self.updateUI()
}
}
SwiftEventBus.onBackgroundThread(self, name: "unified_coupons_fetched") { result in
DispatchQueue.main.async {
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.matchOldSMCoupons()
self.updateMarketBadge()
// self.tableView.reloadData()
self.updateUI()
}
}
SwiftEventBus.onBackgroundThread(self, name: "navigation_back") { result in
DispatchQueue.main.async {
self.navigationController?.popViewController(animated: true)
}
}
// setBackButton()
setBackButton("ic_close_3")
setNavigationTitle("Ιστορικό")
// === images === //
sumBadgeImage.image = UIImage(named: "history_heart", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBadgeImage.image = UIImage(named: "history_banner_dfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeImage.image = UIImage(named: "history_banner_sm", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeImage.image = UIImage(named: "history_banner_gfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
boxBadgeImage.image = UIImage(named: "history_banner_box", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
sectionTitleLabel.text = "Εξαργυρωμένα κουπόνια"
historySectionView.backgroundColor = .white
historySectionView.layer.cornerRadius = 16.0
// historySectionView.layer.borderWidth = 1
// historySectionView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// Add shadow
historySectionView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
historySectionView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
historySectionView.layer.shadowOpacity = 1.0
historySectionView.layer.shadowRadius = 2.0
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "LoyaltyHistoryScreen")
// addNavShadow()
self.navigationController?.hideHairline()
self.coupons = swiftApi().getCouponList()
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.dfyCoupons = swiftApi().getActiveDFYCoupons()
self.boxCoupons = swiftApi().getActiveBoxCoupons()
self.matchOldSMCoupons()
self.updateMarketBadge()
// self.tableView.reloadData()
self.updateUI()
}
// public override func viewWillDisappear(_ animated: Bool) {
// super.viewWillDisappear(animated)
//
// self.navigationController?.navigationBar.layer.shadowOpacity = 0.0
//
// }
// MARK: - Functions
func updateMarketBadge() {
unifiedCouponsDiscount = 0.0
// for smCouponSet in swiftApi().getCouponSetsDealsList() {
// for oldCoupon in swiftApi().getAllOldCouponList() {
// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) {
//
// oldCoupon.setCouponSetData(smCouponSet);
//
// if let discountFloat = Float(oldCoupon.discount ?? "0.0") {
// unifiedCouponsDiscount += discountFloat
// }
// break;
// }
// }
// }
for coupon in swiftApi().getOldUnifiedCouponList() {
if let discountFloat = Float(coupon.discount ?? "0.0") {
unifiedCouponsDiscount += discountFloat
}
}
// TODO: UNCOMMENT if emptyView is needed again
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) {
// emptyView.isHidden = false
// emptyViewHeight.constant = emptyView.intrinsicContentSize.height
// } else {
// emptyView.isHidden = true
// emptyViewHeight.constant = 0
// }
}
func matchOldSMCoupons() {
var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = []
// TODO: Check - Old implementation
// for smCouponSet in swiftApi().getCouponSetsDealsList() {
// for oldCoupon in swiftApi().getAllOldCouponList() {
// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) {
//
// oldCoupon.setCouponSetData(smCouponSet);
// oldUnifiedCouponsArray.append(oldCoupon);
//
// break;
// }
// }
// }
// TODO: DELETE - TEST
// oldUnifiedCouponsArray = swiftApi().getAllOldCouponList().filter({ return $0.couponset_data?.couponset_type == "supermarket" })
oldUnifiedCouponsArray = swiftApi().getSMOldCouponList()
oldUnifiedCouponsArray.sort(by: {
let date1 = $0.redeemed_date
let date2 = $1.redeemed_date
if ((date1 != nil) && (date2 != nil)) {
return date1!.compare(date2!) == .orderedDescending
} else {
return false
}
})
swiftApi().setOldUnifiedCouponList(oldUnifiedCouponsArray)
}
func updateUI() {
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 14) ?? UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-SBold", size: 14) ?? UIFont.boldSystemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
// === SUM banner === //
let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount + boxCouponValue
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
sumBadgeLabel.text = sumRewardsString + "€"
sumBannerLabel.text = "Δες αναλυτικά το συνολικό όφελός σου έως τώρα από κουπόνια"
// === DFY banner === //
dfyBannerParentView.backgroundColor = .clear
dfyBannerInnerParentView.backgroundColor = .white
// dfyBannerInnerView.backgroundColor = UIColor(red: 0.46, green: 0.75, blue: 0.45, alpha: 0.05)
dfyBannerInnerView.backgroundColor = .white
dfyBannerInnerParentView.layer.cornerRadius = 16.0
dfyBannerInnerView.layer.cornerRadius = 16.0
// dfyBannerInnerView.layer.borderWidth = 1
// dfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
dfyBannerParentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
dfyBannerParentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
dfyBannerParentView.layer.shadowOpacity = 1.0
dfyBannerParentView.layer.shadowRadius = 2.0
let totalCouponValueFixed = Float(round(100 * totalCouponValue) / 100)
var totalCouponValueString = "0"
totalCouponValueString = String(format: "%.2f", totalCouponValueFixed).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
dfyBadgeLabel.text = totalCouponValueString + "€"
let dfyNormalText1 = "Μέχρι τώρα έχεις όφελος "
let dfyBoldText = totalCouponValueString + "€"
let dfyNormalText2 = " από τα DEALS FOR YOU"
let dfyAttributedString = NSMutableAttributedString(string:dfyNormalText1, attributes:attrRegular)
let dfyBoldString = NSMutableAttributedString(string: dfyBoldText, attributes:attrBold)
let dfyNormalString = NSMutableAttributedString(string:dfyNormalText2, attributes:attrRegular)
dfyAttributedString.append(dfyBoldString)
dfyAttributedString.append(dfyNormalString)
dfyBannerLabel.attributedText = dfyAttributedString
// === MARKET banner === //
marketBannerParentView.backgroundColor = .clear
// marketBannerInnerView.backgroundColor = UIColor(red: 1.00, green: 0.99, blue: 0.97, alpha: 1.00)
marketBannerInnerView.backgroundColor = .white
marketBannerInnerView.layer.cornerRadius = 16.0
// marketBannerInnerView.layer.borderWidth = 1
// marketBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
marketBannerParentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
marketBannerParentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
marketBannerParentView.layer.shadowOpacity = 1.0
marketBannerParentView.layer.shadowRadius = 2.0
let marketDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
var marketDiscountString = "0"
marketDiscountString = String(format: "%.2f", marketDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
self.marketBadgeLabel.text = marketDiscountString + "€"
let marketNormalText1 = "Μέχρι τώρα έχεις όφελος "
let marketBoldText = marketDiscountString + "€"
let marketNormalText2 = " από τα SUPERMARKET DEALS!"
let marketAttributedString = NSMutableAttributedString(string:marketNormalText1, attributes:attrRegular)
let marketBoldString = NSMutableAttributedString(string: marketBoldText, attributes:attrBold)
let marketNormalString = NSMutableAttributedString(string:marketNormalText2, attributes:attrRegular)
marketAttributedString.append(marketBoldString)
marketAttributedString.append(marketNormalString)
marketBannerLabel.attributedText = marketAttributedString
// === GFY banner === //
gfyBannerParentView.backgroundColor = .clear
// gfyBannerInnerView.backgroundColor = UIColor(red: 0.96, green: 0.97, blue: 0.98, alpha: 1.00)
gfyBannerInnerView.backgroundColor = .white
gfyBannerInnerView.layer.cornerRadius = 16.0
// gfyBannerInnerView.layer.borderWidth = 1
// gfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
gfyBannerParentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
gfyBannerParentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
gfyBannerParentView.layer.shadowOpacity = 1.0
gfyBannerParentView.layer.shadowRadius = 2.0
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
couponBadgeLabel.text = totalCouponDiscountString + "€"
let gfyNormalText1 = "Μέχρι τώρα έχεις όφελος "
let gfyBoldText = totalCouponDiscountString + "€"
let gfyNormalText2 = " από τα FREE COUPONS"
// let gfyNormalText2 = " από τα GIFTS FOR YOU"
let gfyAttributedString = NSMutableAttributedString(string:gfyNormalText1, attributes:attrRegular)
let gfyBoldString = NSMutableAttributedString(string: gfyBoldText, attributes:attrBold)
let gfyNormalString = NSMutableAttributedString(string:gfyNormalText2, attributes:attrRegular)
gfyAttributedString.append(gfyBoldString)
gfyAttributedString.append(gfyNormalString)
gfyBannerLabel.attributedText = gfyAttributedString
// === BOX banner === //
boxBannerParentView.backgroundColor = .clear
boxBannerInnerParentView.backgroundColor = .white
// boxBannerInnerView.backgroundColor = UIColor(red: 0.46, green: 0.75, blue: 0.45, alpha: 0.05)
boxBannerInnerView.backgroundColor = .white
boxBannerInnerParentView.layer.cornerRadius = 16.0
boxBannerInnerView.layer.cornerRadius = 16.0
// boxBannerInnerView.layer.borderWidth = 1
// boxBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
boxBannerParentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
boxBannerParentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
boxBannerParentView.layer.shadowOpacity = 1.0
boxBannerParentView.layer.shadowRadius = 2.0
let boxCouponValueFixed = Float(round(100 * boxCouponValue) / 100)
var boxCouponValueString = "0"
boxCouponValueString = String(format: "%.2f", boxCouponValueFixed).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
boxBadgeLabel.text = boxCouponValueString + "€"
let boxNormalText1 = "Μέχρι τώρα έχεις όφελος "
let boxBoldText = boxCouponValueString + "€"
let boxNormalText2 = " από το BOX"
let boxAttributedString = NSMutableAttributedString(string:boxNormalText1, attributes:attrRegular)
let boxBoldString = NSMutableAttributedString(string: boxBoldText, attributes:attrBold)
let boxNormalString = NSMutableAttributedString(string:boxNormalText2, attributes:attrRegular)
boxAttributedString.append(boxBoldString)
boxAttributedString.append(boxNormalString)
boxBannerLabel.attributedText = boxAttributedString
}
// MARK: - Actions
@IBAction func dfyBannerButtonAction(_ sender: Any) {
// var totalCouponValue = swiftApi().getDealsCouponsSum()
// if (totalCouponValue > 0.0) {
print("DFY coupon banner pressed!")
// analysis_pressed event
let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel()
dealsAnalysis._isPressed = true
SwiftEventBus.post("analysis_pressed", sender: dealsAnalysis)
// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
// firebaseEvent._eventName = "did_tap_gifts_for_you_badge"
// firebaseEvent.setParameter = ("screen", "Loyalty History")
// SwiftEventBus.post("firebase", sender: firebaseEvent)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_deals_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty History")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "DealsBanner"))
// }
}
@IBAction func gfyBannerButtonAction(_ sender: Any) {
// if (loyaltyBadge._couponCount > 0) {
// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
// firebaseEvent._eventName = "did_tap_deals_for_you_badge"
// firebaseEvent.setParameter = ("screen", "Loyalty History")
// SwiftEventBus.post("firebase", sender: firebaseEvent)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_gifts_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty History")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "LoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyAnalysisViewController") as! SwiftWarplyFramework.LoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
// }
}
@IBAction func marketBannerButtonAction(_ sender: Any) {
// if (self.unifiedCouponsDiscount > 0.0) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_market_badge"
firebaseEvent.setParameter = ("screen", "Loyalty History")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "MarketBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "MarketLoyaltyAnalysisViewController") as! SwiftWarplyFramework.MarketLoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
// }
}
@IBAction func boxBannerButtonAction(_ sender: Any) {
print("BOX coupon banner pressed!")
// box_analysis_pressed event
let dealsAnalysis = swiftApi.WarplyBoxAnalysisEventModel(self)
dealsAnalysis._isPressed = true
SwiftEventBus.post("box_analysis_pressed", sender: dealsAnalysis)
// SwiftEventBus.post("box_analysis_pressed")
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_box_badge"
firebaseEvent.setParameter = ("screen", "Loyalty History")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "BoxBanner"))
}
}
//
// MFYInboxTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/6/22.
//
import UIKit
@objc public class MFYInboxTableViewCell: UITableViewCell {
@IBOutlet weak var inboxView: UIView!
@IBOutlet weak var campaignImage: UIImageView!
@IBOutlet weak var newBadgeImage: UIImageView!
@IBOutlet weak var campaignTitleLabel: UILabel!
@IBOutlet weak var curvedBgImage: UIImageView!
@IBOutlet weak var subtitleLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.campaignImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.campaignImage.image = image
}
}
}
else {
self.campaignImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
// inboxView.layer.cornerRadius = 5.0
// inboxView.clipsToBounds = true
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
newBadgeImage.image = UIImage(named: "new_icon_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
curvedBgImage.image = UIImage(named: "curved_bg_white_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
newBadgeImage.isHidden = true
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
// Add different corner radius - Do it here, otherwise it won't be applied to all cells
inboxView.roundCorners(topLeft: 20, topRight: 45, bottomLeft: 20, bottomRight: 0)
// // Delete extra borderLayers added
// for layer in (inboxView.layer.sublayers ?? []) {
// if(layer.name == "MFYItemBorderLayer"){
// layer.removeFromSuperlayer()
// }
// }
//
// // Add borderLayer
// let borderLayer = CAShapeLayer()
// borderLayer.path = (inboxView.layer.mask! as! CAShapeLayer).path! // Reuse the Bezier path
// borderLayer.strokeColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// borderLayer.fillColor = UIColor.clear.cgColor
// borderLayer.lineWidth = 1
// borderLayer.frame = inboxView.bounds
// borderLayer.name = "MFYItemBorderLayer"
// inboxView.layer.addSublayer(borderLayer)
}
func configureCell(campaign: swiftApi.CampaignItemModel) {
// campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
self.postImageURL = campaign.logo_url ?? ""
campaignTitleLabel.text = campaign.title ?? ""
campaignTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
subtitleLabel.text = campaign.subtitle ?? ""
subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 15)
descriptionLabel.text = campaign.message ?? ""
descriptionLabel.font = UIFont(name: "PeridotPE-SBold", size: 15)
if (campaign.is_new == true) {
newBadgeImage.isHidden = false
} else{
newBadgeImage.isHidden = true
}
}
func configureCell(ccms: swiftApi.LoyaltyContextualOfferModel) {
// campaignImage.load(link: ccms._imageUrl , placeholder: UIImage(), cache: URLCache())
self.postImageURL = ccms._imageUrl
campaignTitleLabel.text = ccms._title
campaignTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
subtitleLabel.text = ccms._subtitle
subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 15)
descriptionLabel.text = ccms._description
descriptionLabel.font = UIFont(name: "PeridotPE-SBold", size: 15)
newBadgeImage.isHidden = true
}
}
//
// MFYViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 5/5/22.
//
import Foundation
import UIKit
import SwiftEventBus
@objc public class MFYViewController: UIViewController {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var topBorderShadow: UIImageView!
var categories: Array<CampaignCategory> = [CampaignCategory]() {
didSet {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
public var campaigns:Array<swiftApi.CampaignItemModel> = []
public var loyaltyList:Array<swiftApi.CampaignItemModel> = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
public var ccmsList:Array<swiftApi.LoyaltyContextualOfferModel> = swiftApi().getCCMSLoyaltyCampaigns()
var timerMFY: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("MORE FOR YOU", "bold")
tableView.delegate = self
tableView.dataSource = self
SwiftEventBus.onMainThread(self, name: "ccms_retrieved") { result in
print("===== SwiftEventBus ccms_retrieved =====")
self.refreshData()
}
SwiftEventBus.onMainThread(self, name: "campaigns_retrieved") { result in
print("===== SwiftEventBus campaigns_retrieved =====")
self.refreshData()
}
// tableView.clipsToBounds = true
// tableView.layer.cornerRadius = 30
// tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
tableView.contentInset.top = 10
// Add Top left corner radius
// mainView.clipsToBounds = true
// mainView.layer.cornerRadius = 30
// mainView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
mainView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
// let image = UIImage(named: "top_border_shadow", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
//
// topBorderShadow.translatesAutoresizingMaskIntoConstraints = false
// topBorderShadow.image = image
// topBorderShadow.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderShadow.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderShadow.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderShadow.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderShadow.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderShadow.heightAnchor.constraint(equalTo: topBorderShadow.widthAnchor, multiplier: 1/aspectR)
// ])
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "MoreForYouScreen")
self.refreshData()
self.startTimer()
self.navigationController?.hideHairline()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
func refreshData() -> Void {
self.loyaltyList = swiftApi().mergeMFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
self.ccmsList = swiftApi().getCCMSLoyaltyCampaigns()
// var tempCampaigns:Array<swiftApi.CampaignItemModel> = loyaltyList
var newData = [CampaignCategory]()
// parse campaigns
var campaignsDict = [String:CampaignCategory]()
for item in loyaltyList {
guard let title = item._category_title else {
continue
}
if (title.isEmpty) {
continue
}
var category = campaignsDict[title]
if (category == nil) {
category = CampaignCategory(title)
campaignsDict[title] = category
newData.append(category!)
}
category?.items.append(item)
}
newData = newData.sorted(by: { $0.index < $1.index })
// parse ccms
if (self.ccmsList.count > 0) {
let category = CampaignCategory("ΑΛΛΕΣ")
for ccmsItem in self.ccmsList {
if (((ccmsItem._loyaltyCampaignId == "") || (ccmsItem._loyaltyCampaignId == "NA")) && (ccmsItem._zone == "COSMOTE_APP_MORE4U")) {
let newCampaign = swiftApi.CampaignItemModel()
newCampaign._title = ccmsItem._title
newCampaign._logo_url = ccmsItem._imageUrl
newCampaign._subtitle = ccmsItem._subtitle
newCampaign._message = ccmsItem._message
newCampaign._ccms = ccmsItem
// tempCampaigns.append(newCampaign)
category.items.append(newCampaign)
}
}
if (category.items.count > 0) {
newData.append(category)
}
}
// self.campaigns = tempCampaigns
self.categories = newData
self.tableView.reloadData()
}
func startTimer() {
print("========= MFY Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".mfy.timer")
timerMFY = DispatchSource.makeTimerSource(queue: queue)
timerMFY!.schedule(deadline: .now(), repeating: .seconds(1))
timerMFY!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= MFY interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerMFY!.resume()
}
func stopTimer() {
print("========= MFY Timer Stopped! =========")
timerMFY?.cancel()
timerMFY = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "MoreForYou")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
}
// MARK: - TableView
extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
// return 1
return self.categories.count
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// return self.campaigns.count
return self.categories[section].items.count
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 220.0 + 10.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 43))
view.backgroundColor = .clear
let titleLabel = UILabel(frame: CGRect(x: 20, y: 5, width: view.frame.width - 20, height: 43))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 15)
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.text = categories[section].name
view.addSubview(titleLabel)
return view
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 43
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return CGFloat.leastNormalMagnitude
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MFYInboxTableViewCellId", for: indexPath) as! MFYInboxTableViewCell
let campaign = categories[indexPath.section].items[indexPath.row]
let isCcmsOffer = (campaign.ccms_offer != nil) && (campaign.ccms_offer != "") && (campaign.ccms_offer == "true")
if (campaign._type != nil && campaign._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaign.session_uuid) {
cell.configureCell(ccms: item)
break;
}
}
}
} else if (campaign.session_uuid != nil && campaign.session_uuid != "" && isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaign.session_uuid) {
cell.configureCell(ccms: item)
break;
}
}
}
} else {
cell.configureCell(campaign: campaign)
}
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let campaign = categories[indexPath.section].items[indexPath.row]
if (campaign._ccms != nil) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (campaign._ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("Contextual:" + (campaign._ccms?._sessionId ?? "")))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "ContextualViewController") as! SwiftWarplyFramework.ContextualViewController
vc.ccms = campaign._ccms
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
} else if (campaign._type != nil && campaign._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaign.session_uuid) {
swiftApi().logTrackersEvent("click", ("Telco:" + (item._sessionId)))
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (item._title))
firebaseEvent.setParameter = ("type", "gift")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "TelcoViewController") as! SwiftWarplyFramework.TelcoViewController
vc.ccms = item
vc.campaign = campaign
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
}
}
} else if (campaign._campaign_type == "coupon" && campaign._couponset != "" && campaign._couponset != nil) {
let couponsetUuid = campaign._couponset
if (couponsetUuid != "" && couponsetUuid != nil) {
let couponsetsList = swiftApi().getCouponSetList()
for item in couponsetsList {
if (item.uuid == couponsetUuid) {
swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaign.session_uuid ?? "")))
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_sdk_offer_selected"
firebaseEvent.setParameter = ("name", (item.name ?? ""))
firebaseEvent.setParameter = ("type", "coupon")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponViewController") as! SwiftWarplyFramework.CouponViewController
vc.couponset = item
vc.campaign = campaign
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
if (loyaltyCampaignIdExists == true) {
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaign.session_uuid) {
vc.ccms = item
break;
}
}
}
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
}
} else {
let status = swiftApi().getNetworkStatus()
if (status == -1 || status == 0) {
self.showDialog("Δεν υπάρχει σύνδεση","Αυτή τη στιγμή βρίσκεσαι εκτός σύνδεσης. Παρακαλούμε βεβαιώσου ότι είσαι συνδεδεμένος στο διαδίκτυο και προσπάθησε ξανά.")
} else {
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
// let url = swiftApi().constructCampaignUrl(campaign)
// print("CampaignUrl url onclick: " + url)
// vc.campaignUrl = url
// self.navigationController?.pushViewController(vc, animated: true)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CampaignViewController") as! SwiftWarplyFramework.CampaignViewController
var url = ""
var params = ""
let isCcmsOffer = (campaign.ccms_offer != nil) && (campaign.ccms_offer != "") && (campaign.ccms_offer == "true")
if (isCcmsOffer) {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaign.session_uuid }
if (loyaltyCampaignIdExists == true) {
var ccmsCampaignFound:swiftApi.LoyaltyContextualOfferModel = swiftApi.LoyaltyContextualOfferModel()
for item in ccmsCampaigns {
if (item._loyaltyCampaignId == campaign.session_uuid) {
ccmsCampaignFound = item
}
}
swiftApi().logTrackersEvent("click", ("Contextual:" + (ccmsCampaignFound._sessionId)))
url = swiftApi().constructCcmsUrl(campaign, ccmsCampaignFound)
params = swiftApi().constructCcmsParams(campaign, ccmsCampaignFound)
} else {
url = swiftApi().constructCampaignUrl(campaign)
params = swiftApi().constructCampaignParams(campaign)
}
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaign)
print("CCMS_CLICK " + String(data: data, encoding: .utf8)!)
} else {
swiftApi().logTrackersEvent("click", ("Loyalty:" + (campaign.session_uuid ?? "")))
url = swiftApi().constructCampaignUrl(campaign)
params = swiftApi().constructCampaignParams(campaign)
let encoder = JSONEncoder()
encoder.outputFormatting = .prettyPrinted
let data = try! encoder.encode(campaign)
print("GFY_CLICK " + String(data: data, encoding: .utf8)!)
}
print("CampaignUrl url onclick: " + url)
vc.campaignUrl = url
vc.params = params
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
}
}
func getSingleCampaignAsyncRequest(sessionUuid: String) {
swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
}
func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
if (getSingleCampaignData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
}
This diff could not be displayed because it is too large.
//
// MakeItAPresentViewController.swift
// SwiftWarplyFramework
//
// Created by Βασιλης Σκουρας on 11/5/22.
//
import Foundation
import UIKit
@objc public class MakeItAPresentViewController: UIViewController {
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("Κάνε δώρο")
}
}
//
// MapsViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 20/9/22.
//
import UIKit
import MapKit
@objc public class MapsViewController: UIViewController, MKMapViewDelegate {
// ui
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet private var mapView: MKMapView!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet private var titleView: UILabel!
@IBOutlet private var nameImageView: UIImageView!
@IBOutlet private var nameView: UILabel!
@IBOutlet private var hoursView: UILabel!
@IBOutlet private var phoneView: UILabel!
@IBOutlet private var addressView: UILabel!
@IBOutlet private var directionsButton: UIButton!
@IBOutlet private var infoTopConstraint: NSLayoutConstraint!
@IBOutlet weak var topBorderLine: UIImageView!
@IBOutlet weak var phoneImageView: UIImageView!
@IBOutlet weak var addressImageView: UIImageView!
// public
public var coupon: swiftApi.CouponItemModel?
public var isMarket: Bool? = false
var merchantsArray:Array<swiftApi.MerchantModel> = []
var selectedMerchant: swiftApi.MerchantModel?
var annotationGroup = [MKPointAnnotation]()
var parentMerchant: swiftApi.MerchantModel?
var parentMerchantsArray:Array<swiftApi.MerchantModel> = []
//
var loading: Bool = false
let initialLocation = CLLocation(latitude: 37.9641262, longitude: 23.7468592) // greece
//
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
self.infoTopConstraint.constant = 0
setBackButton()
setNavigationTitle("Καταστήματα")
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
phoneImageView.image = UIImage(named: "ic_phone", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
addressImageView.image = UIImage(named: "ic_address", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
mapView.delegate = self
mapView.centerToLocation(initialLocation, regionRadius: 1000000)
// mapView.clipsToBounds = true
// mapView.layer.cornerRadius = 30
// mapView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
// topBorderLine.translatesAutoresizingMaskIntoConstraints = false
// topBorderLine.image = image
// topBorderLine.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
// ])
closeButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
closeButton.setImage(UIImage(named: "ic_close_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
titleView.font = UIFont(name: "PFSquareSansPro-Bold", size: 19)
titleView.textColor = UIColor(rgb: 0x757575)
nameView.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
nameView.textColor = UIColor(rgb: 0x415564)
hoursView.font = UIFont(name: "PFSquareSansPro-Regular", size: 18)
hoursView.textColor = UIColor(rgb: 0xAEAEAE)
hoursView.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
hoursView.textColor = UIColor(rgb: 0x415564)
addressView.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
addressView.textColor = UIColor(rgb: 0x415564)
//directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
directionsButton.setTitle("Οδηγίες", for: .normal)
directionsButton.setImage(UIImage(named: "ic_directions", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
// directionsButton.sizeToFit()
directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
directionsButton.setTitleColor(.white, for: .normal)
directionsButton.tintColor = .white
directionsButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
directionsButton.layer.cornerRadius = 16.0
// directionsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
// directionsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
directionsButton.frame = CGRect(x: 0.0, y: 0.0, width: directionsButton.intrinsicContentSize.width+10, height: 50)
// directionsButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15)
directionsButton.setInsets(forContentPadding: UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 15), imageTitlePadding: 10)
load()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "ShopsScreen")
self.navigationController?.hideHairline()
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
if (coupon != nil) {
if let merchantUuid: String = coupon?.merchant_uuid {
swiftApi().getMultilingualMerchantsAsync([], false, 0.0, [], "", 0, [merchantUuid], getMerchantsCallback)
showContent()
}
} else {
let appUuid = swiftApi().getAppUuid()
// 2a6adade35f1484994a3d4c8f006b909 category is for SM only
var categoryUuids = [""]
if (self.isMarket == true) {
categoryUuids = appUuid == "0086a2088301440792091b9f814c2267" ? ["2a6adade35f1484994a3d4c8f006b909"] : ["adcace6cab6049c7b7271bc85bc2b26d"]
} else {
categoryUuids = appUuid == "0086a2088301440792091b9f814c2267" ? [""] : ["adcace6cab6049c7b7271bc85bc2b26d"]
}
swiftApi().getMultilingualMerchantsAsync(categoryUuids, false, 0.0, [], "", 0, [], getMerchantsCallback)
showContent()
}
}
func getMerchantsCallback (_ merchantsData: Array<swiftApi.MerchantModel>?) -> Void {
if (merchantsData != nil) {
DispatchQueue.main.async {
let filteredMerchants = (merchantsData ?? []).filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
let parentMerchants = (merchantsData ?? []).filter({ return (($0._latitude == 0.0) && ($0._longitude == 0.0)) })
// if (self.isMarket == true) {
self.merchantsArray = filteredMerchants
self.parentMerchantsArray = parentMerchants
// if let parent = (merchantsData ?? []).first(where: {(($0._latitude == 0.0) && ($0._longitude == 0.0))}) {
// self.parentMerchant = parent
// }
// } else {
// self.merchantsArray = merchantsData ?? []
// }
self.loadMapPins()
// let filteredMerchants = self.merchantsArray.filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
if (filteredMerchants.count == 0) {
self.showDialog("Καταστήματα συνεργάτη", "Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.")
}
}
return
}
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
let cancelButton = UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
switch action.style{
case .default:
self.navigationController?.popViewController(animated: true)
// self.dismiss(animated: true, completion: {})
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
})
// cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(UIAlertAction(title: "Δες το eshop", style: .default, handler: { action in
switch action.style{
case .default:
if (self.coupon != nil) {
// if let merchantUuid: String = self.coupon?.merchant_uuid {
// for item in swiftApi().getMerchantList() {
// if (item._uuid == merchantUuid) {
// let eshopWebsite = item._website
// if (eshopWebsite != "") {
// guard let websiteUrl = URL(string: eshopWebsite) else {
// print("Error creating URL")
// return
// }
// // check if link can be opened.
// guard UIApplication.shared.canOpenURL(websiteUrl) else {
// return
// }
// swiftApi().logTrackersEvent("click", "SeeShopWebsite")
// UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
// break;
// }
// }
// }
// }
let merchantDetails: swiftApi.MerchantModel? = self.coupon?.merchant_details
let eshopWebsite = merchantDetails?._website ?? ""
if (eshopWebsite != "") {
guard let websiteUrl = URL(string: eshopWebsite) else {
print("Error creating URL")
return
}
// check if link can be opened.
guard UIApplication.shared.canOpenURL(websiteUrl) else {
return
}
swiftApi().logTrackersEvent("click", "SeeShopWebsite")
UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
break;
}
}
// if (self.merchantsArray.count > 0) {
// for item in self.merchantsArray {
// let eshopWebsite = item._website
//
// if (eshopWebsite != "") {
// guard let websiteUrl = URL(string: eshopWebsite) else {
// print("Error creating URL")
// return
// }
//
// // check if link can be opened.
// guard UIApplication.shared.canOpenURL(websiteUrl) else {
// return
// }
//
// swiftApi().logTrackersEvent("click", "SeeShopWebsite")
// UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
// break;
// }
// }
// }
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
private func showLoading() {
loading = true
}
private func showError() {
}
private func showContent() {
loading = false
}
// private
@IBAction func closeButtonAction(_ sender: Any) {
print("closeButton Pressed!!!")
hidePinDetailsView()
let selectedAnnotations = mapView.selectedAnnotations
for annotation in selectedAnnotations {
mapView.deselectAnnotation(annotation, animated: false)
}
}
@IBAction func directionsButtomAction(_ sender: Any) {
guard let lon = selectedMerchant?._longitude, let lat = selectedMerchant?._latitude else {
return
}
// guard your URL instances
// guard let googleMapsUrl = URL(string: String(format: "https://www.google.com/maps/@%.6f,%.6f,6z", lat, lon)),
// let appleMapsUrl = URL(string: String(format: "http://maps.apple.com/?ll=%.6f,%.6f", lat, lon)) else {
// print("Error creating URLs")
// return
// }
// guard let googleMapsUrl = URL(string: "https://www.google.co.in/maps/dir/?saddr=&daddr=\(lat),\(lon)&directionsmode=driving"),
// let appleMapsUrl = URL(string: "http://maps.apple.com/?daddr=\(lat),\(lon)") else {
// print("Error creating URLs")
// return
// }
//
// // check if link can be opened with google maps.
// guard UIApplication.shared.canOpenURL(googleMapsUrl) else {
// UIApplication.shared.open(appleMapsUrl, options: [:], completionHandler: nil)
// return
// }
//
// UIApplication.shared.open(googleMapsUrl, options: [:], completionHandler: nil)
guard let appleMapsUrl = URL(string: "http://maps.apple.com/?daddr=\(lat),\(lon)") else {
print("Error creating URLs")
return
}
UIApplication.shared.open(appleMapsUrl, options: [:], completionHandler: nil)
}
private func loadMapPins() {
for item in merchantsArray {
let pin = MerchantAnnotation(item)
mapView.addAnnotation(pin)
// self.annotationGroup.append(pin)
// self.mapView.addAnnotations(self.annotationGroup)
// self.mapView.showAnnotations(self.annotationGroup, animated: true)
// let annotation = MKPointAnnotation()
// annotation.coordinate.longitude = item._longitude
// annotation.coordinate.latitude = item._latitude
// annotation.title = item._admin_name //This is the line to remove the optional annotation.title? from.
// annotation.subtitle = item._admin_name
// self.annotationGroup.append(annotation)
// self.mapView.addAnnotations(self.annotationGroup)
// self.mapView.showAnnotations(self.annotationGroup, animated: true)
// let annotation = MKPointAnnotation()
// let centerCoordinate = CLLocationCoordinate2D(latitude: item._latitude, longitude: item._longitude)
// annotation.coordinate = centerCoordinate
// annotation.title = "Pass Title here"
// mapView.addAnnotation(annotation)
}
// mapView.showAnnotations(mapView.annotations, animated: true)
}
private func loadPinDetailsView(_ annotation: MerchantAnnotation) {
self.selectedMerchant = annotation.model
if let parent = self.parentMerchantsArray.first(where: {($0._uuid == self.selectedMerchant?._parent)}) {
self.parentMerchant = parent
}
// self.titleView.text = self.selectedMerchant?._admin_name
self.titleView.text = self.parentMerchant?._admin_name
if (self.isMarket == true) {
self.nameImageView.load(link: self.parentMerchant?._img_preview ?? "", placeholder: UIImage(), cache: URLCache())
} else {
self.nameImageView.load(link: self.selectedMerchant?._img_preview ?? "", placeholder: UIImage(), cache: URLCache())
}
self.nameView.text = self.selectedMerchant?._name
// TODO: Make dynamic
self.hoursView.text = ""
self.phoneView.text = self.selectedMerchant?._telephone
self.addressView.text = self.selectedMerchant?._address
}
private func showPinDetailsView() {
self.infoTopConstraint.constant = -320
UIView.animate(withDuration: 1.0) {
self.view.layoutIfNeeded()
}
}
private func hidePinDetailsView() {
self.selectedMerchant = nil
self.infoTopConstraint.constant = 0
UIView.animate(withDuration: 1.0) {
self.view.layoutIfNeeded()
}
}
// map view delegate
// public func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
//
//// guard !(annotation is MKUserLocation) else {
//// return nil
//// }
//
// var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "warply_custom")
// if (annotationView == nil) {
// print("=== annotationView == nil ===")
//
// annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "warply_custom")
// annotationView?.canShowCallout = false
// } else {
// print("=== annotationView != nil ===")
//
// annotationView?.annotation = annotation
// }
//
// // TODO: add custom pin image?
// //annotationView?.image = UIImage(named: "custom")
//
// print("=== returned annotation ===")
// print(annotation)
//
// return annotationView
// }
// map view delegate
public func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
// guard !(annotation is MKUserLocation) else {
// return nil
// }
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "warply_custom")
if (annotationView == nil) {
annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "warply_custom")
annotationView?.canShowCallout = false
} else {
annotationView?.annotation = annotation
}
// Add custom pin image
annotationView?.frame = CGRect(x: 0, y: 0, width: 45, height: 60)
let pinImageView = UIImageView(frame: CGRect(x: 0, y: 0, width: 45, height: 60))
pinImageView.contentMode = .scaleAspectFit
if let pinImg = UIImage(named: "map_pin", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
pinImageView.image = pinImg
}
let logoImageView = UIImageView(frame: CGRect(x: 5, y: 5, width: 35, height: 35))
logoImageView.contentMode = .scaleAspectFit
let merchant = annotation as? MerchantAnnotation
if let merchantModel = merchant?.model {
let currentMerchant = merchantModel
if (self.isMarket == true) {
if let parent = self.parentMerchantsArray.first(where: {($0._uuid == currentMerchant._parent)}) {
let currentMerchantParent = parent
logoImageView.load(link: currentMerchantParent._img_preview , placeholder: UIImage(), cache: URLCache())
pinImageView.addSubview(logoImageView)
annotationView?.addSubview(pinImageView)
return annotationView
} else {
return nil
}
} else {
logoImageView.load(link: currentMerchant._img_preview , placeholder: UIImage(), cache: URLCache())
pinImageView.addSubview(logoImageView)
annotationView?.addSubview(pinImageView)
return annotationView
}
} else {
return nil
}
}
public func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
let merchant = view.annotation as? MerchantAnnotation
let merchantModel = merchant!.model
swiftApi().logTrackersEvent("click", ("ShopsScreenMarker:" + (merchantModel._uuid)))
loadPinDetailsView(merchant!)
showPinDetailsView()
}
public func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView) {
hidePinDetailsView()
}
}
private extension MKMapView {
func centerToLocation(_ location: CLLocation, regionRadius: CLLocationDistance = 1000) {
let coordinateRegion = MKCoordinateRegion(
center: location.coordinate,
latitudinalMeters: regionRadius,
longitudinalMeters: regionRadius)
setRegion(coordinateRegion, animated: true)
}
}
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="21507" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="21505"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MapsViewController" customModule="SwiftWarplyFramework" customModuleProvider="target">
<connections>
<outlet property="addressImageView" destination="Bic-c4-J9E" id="pOr-y5-qYi"/>
<outlet property="addressView" destination="syP-Hv-OGD" id="LUw-pI-3va"/>
<outlet property="backgroundImage" destination="tVJ-fk-ani" id="ETq-VL-6q7"/>
<outlet property="closeButton" destination="lEb-V2-2FC" id="aEd-fS-pbO"/>
<outlet property="directionsButton" destination="bw3-J9-wHr" id="sSi-OK-KTA"/>
<outlet property="hoursView" destination="u9U-A7-lbO" id="xm5-gQ-zjh"/>
<outlet property="infoTopConstraint" destination="9av-UX-8VL" id="uKX-lw-OTH"/>
<outlet property="mainView" destination="rKl-bF-Zpf" id="ghc-id-sqV"/>
<outlet property="mapView" destination="F1c-ck-cQa" id="cdx-31-BiL"/>
<outlet property="nameImageView" destination="eDV-A1-pOO" id="JYq-eT-kEG"/>
<outlet property="nameView" destination="MsK-eg-pkk" id="60t-lm-O8m"/>
<outlet property="phoneImageView" destination="KhY-nt-uwH" id="1lt-DL-aRN"/>
<outlet property="phoneView" destination="knh-D9-CuM" id="ES2-6e-vRx"/>
<outlet property="titleView" destination="oVh-dv-f7a" id="dst-Ku-EFw"/>
<outlet property="topBorderLine" destination="Z8H-fT-Lo9" id="Vl0-Nb-YhC"/>
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rKl-bF-Zpf" userLabel="Main View">
<rect key="frame" x="0.0" y="48" width="414" height="848"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="coupons_scrollview_white" translatesAutoresizingMaskIntoConstraints="NO" id="tVJ-fk-ani">
<rect key="frame" x="0.0" y="0.0" width="414" height="852"/>
</imageView>
<mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="F1c-ck-cQa">
<rect key="frame" x="0.0" y="0.0" width="414" height="848"/>
</mapView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Z8H-fT-Lo9">
<rect key="frame" x="0.0" y="420" width="414" height="11.5"/>
</imageView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="tVJ-fk-ani" secondAttribute="bottom" id="5cR-5W-AwC"/>
<constraint firstItem="tVJ-fk-ani" firstAttribute="top" secondItem="rKl-bF-Zpf" secondAttribute="top" id="EMb-Ay-M18"/>
<constraint firstItem="Z8H-fT-Lo9" firstAttribute="leading" secondItem="rKl-bF-Zpf" secondAttribute="leading" id="Kwp-fj-9nx"/>
<constraint firstAttribute="trailing" secondItem="tVJ-fk-ani" secondAttribute="trailing" id="LLM-SY-Ejo"/>
<constraint firstItem="F1c-ck-cQa" firstAttribute="leading" secondItem="rKl-bF-Zpf" secondAttribute="leading" id="P7b-Km-FIn"/>
<constraint firstItem="Z8H-fT-Lo9" firstAttribute="top" secondItem="rKl-bF-Zpf" secondAttribute="top" id="VAV-Go-hI2"/>
<constraint firstItem="F1c-ck-cQa" firstAttribute="top" secondItem="rKl-bF-Zpf" secondAttribute="top" id="X2Z-Vc-V9u"/>
<constraint firstAttribute="trailing" secondItem="F1c-ck-cQa" secondAttribute="trailing" id="dcT-Pn-T5v"/>
<constraint firstItem="tVJ-fk-ani" firstAttribute="leading" secondItem="rKl-bF-Zpf" secondAttribute="leading" id="eVM-4A-gJc"/>
<constraint firstAttribute="bottom" secondItem="F1c-ck-cQa" secondAttribute="bottom" id="ipi-oy-9jV"/>
<constraint firstAttribute="trailing" secondItem="Z8H-fT-Lo9" secondAttribute="trailing" id="nUU-tN-OvE"/>
</constraints>
<variation key="default">
<mask key="subviews">
<exclude reference="tVJ-fk-ani"/>
<exclude reference="Z8H-fT-Lo9"/>
</mask>
</variation>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Zc1-ew-qcl">
<rect key="frame" x="0.0" y="576" width="414" height="320"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="INTERSPORT" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oVh-dv-f7a" userLabel="Title">
<rect key="frame" x="30" y="20" width="304" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="Gf2-VN-pNV"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="19"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="right" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="lEb-V2-2FC" userLabel="Close">
<rect key="frame" x="354" y="15" width="40" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="gnd-qn-qo5"/>
<constraint firstAttribute="height" constant="40" id="oeu-zs-b1J"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="B" image="ic_close_3">
<color key="titleColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="closeButtonAction:" destination="-1" eventType="touchUpInside" id="bIB-NN-rUr"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="F55-qj-PDc" userLabel="LineTop">
<rect key="frame" x="10" y="61.5" width="394" height="1"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="18a-J3-UZm"/>
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="eDV-A1-pOO" userLabel="NameLogo">
<rect key="frame" x="30" y="87.5" width="30" height="30"/>
<constraints>
<constraint firstAttribute="width" constant="30" id="IjG-Iw-fIq"/>
<constraint firstAttribute="height" constant="30" id="LnS-gV-hIi"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Intersport Χαλανδρίου" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MsK-eg-pkk" userLabel="NameLabel">
<rect key="frame" x="70" y="82" width="314" height="21.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="SHs-vI-jD7" userLabel="LineMiddle">
<rect key="frame" x="10" y="142.5" width="394" height="1"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="hMo-qH-T2k"/>
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_phone" translatesAutoresizingMaskIntoConstraints="NO" id="KhY-nt-uwH" userLabel="phoneIcon">
<rect key="frame" x="30" y="173.5" width="20" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="1rt-pN-Dld"/>
<constraint firstAttribute="width" constant="20" id="3Rd-ir-r7Q"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="210-6230543" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="knh-D9-CuM" userLabel="phoneLabel">
<rect key="frame" x="60" y="163.5" width="324" height="40"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="sAf-f8-8jc" userLabel="LineBottom">
<rect key="frame" x="10" y="223.5" width="394" height="1"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="vSP-6I-Lz6"/>
</constraints>
</view>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_address" translatesAutoresizingMaskIntoConstraints="NO" id="Bic-c4-J9E" userLabel="AddressIcon">
<rect key="frame" x="30" y="245.5" width="20" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="A8o-MY-I6f"/>
<constraint firstAttribute="width" constant="20" id="Xma-bp-6IZ"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="ΕΘΝΙΚΗΣ ΑΝΤΙΣΤΑΣΕΩΣ 4 41" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="syP-Hv-OGD" userLabel="AddressLabel">
<rect key="frame" x="60" y="244.5" width="246" height="21.5"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" horizontalCompressionResistancePriority="751" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="bw3-J9-wHr" userLabel="Directions">
<rect key="frame" x="340" y="238.5" width="54" height="34"/>
<constraints>
<constraint firstAttribute="height" constant="34" id="9wg-ge-pC0"/>
</constraints>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Button"/>
<connections>
<action selector="directionsButtomAction:" destination="-1" eventType="touchUpInside" id="nMR-Jk-Wm4"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" text="Δευτέρα - Τετάρτη" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u9U-A7-lbO" userLabel="HoursLabel">
<rect key="frame" x="70" y="102" width="314" height="21.5"/>
<fontDescription key="fontDescription" type="system" pointSize="18"/>
<color key="textColor" systemColor="systemGray2Color"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="XS2-AR-3j9"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="u9U-A7-lbO" firstAttribute="leading" secondItem="eDV-A1-pOO" secondAttribute="trailing" constant="10" id="0Z2-uE-kRe"/>
<constraint firstItem="XS2-AR-3j9" firstAttribute="trailing" secondItem="MsK-eg-pkk" secondAttribute="trailing" constant="30" id="1qW-i8-MRk"/>
<constraint firstItem="knh-D9-CuM" firstAttribute="top" secondItem="SHs-vI-jD7" secondAttribute="bottom" constant="20" id="61g-5C-XbI"/>
<constraint firstItem="sAf-f8-8jc" firstAttribute="leading" secondItem="XS2-AR-3j9" secondAttribute="leading" constant="10" id="7W6-cn-WdZ"/>
<constraint firstItem="bw3-J9-wHr" firstAttribute="centerY" secondItem="Bic-c4-J9E" secondAttribute="centerY" id="AHw-0D-gur"/>
<constraint firstItem="SHs-vI-jD7" firstAttribute="top" secondItem="eDV-A1-pOO" secondAttribute="bottom" constant="25" id="D8j-Qh-CHB"/>
<constraint firstItem="KhY-nt-uwH" firstAttribute="leading" secondItem="XS2-AR-3j9" secondAttribute="leading" constant="30" id="Dok-gZ-xf1"/>
<constraint firstItem="SHs-vI-jD7" firstAttribute="leading" secondItem="Zc1-ew-qcl" secondAttribute="leading" constant="10" id="Lj8-XN-HTj"/>
<constraint firstAttribute="trailing" secondItem="F55-qj-PDc" secondAttribute="trailing" constant="10" id="MCj-ek-cnb"/>
<constraint firstAttribute="trailing" secondItem="lEb-V2-2FC" secondAttribute="trailing" constant="20" id="NcX-rr-7OU"/>
<constraint firstItem="syP-Hv-OGD" firstAttribute="leading" secondItem="Bic-c4-J9E" secondAttribute="trailing" constant="10" id="Rl4-cn-VTG"/>
<constraint firstAttribute="trailing" secondItem="SHs-vI-jD7" secondAttribute="trailing" constant="10" id="Smw-Bv-Qlr"/>
<constraint firstItem="lEb-V2-2FC" firstAttribute="leading" secondItem="oVh-dv-f7a" secondAttribute="trailing" constant="20" id="ULP-b9-ToV"/>
<constraint firstItem="bw3-J9-wHr" firstAttribute="centerY" secondItem="syP-Hv-OGD" secondAttribute="centerY" id="VMT-7b-JjS"/>
<constraint firstItem="MsK-eg-pkk" firstAttribute="leading" secondItem="eDV-A1-pOO" secondAttribute="trailing" constant="10" id="Vg7-xl-oA2"/>
<constraint firstItem="oVh-dv-f7a" firstAttribute="leading" secondItem="Zc1-ew-qcl" secondAttribute="leading" constant="30" id="Zd1-SB-SlA"/>
<constraint firstItem="KhY-nt-uwH" firstAttribute="top" secondItem="SHs-vI-jD7" secondAttribute="bottom" constant="30" id="a6s-J0-5rJ"/>
<constraint firstItem="knh-D9-CuM" firstAttribute="leading" secondItem="KhY-nt-uwH" secondAttribute="trailing" constant="10" id="aeR-MK-4WB"/>
<constraint firstItem="eDV-A1-pOO" firstAttribute="leading" secondItem="XS2-AR-3j9" secondAttribute="leading" constant="30" id="bkK-59-wXK"/>
<constraint firstAttribute="height" constant="320" id="eIo-xG-BnE"/>
<constraint firstItem="u9U-A7-lbO" firstAttribute="centerY" secondItem="eDV-A1-pOO" secondAttribute="centerY" constant="10" id="gFw-90-gXL"/>
<constraint firstItem="oVh-dv-f7a" firstAttribute="top" secondItem="Zc1-ew-qcl" secondAttribute="top" constant="20" id="gIA-8o-Pv8"/>
<constraint firstItem="XS2-AR-3j9" firstAttribute="trailing" secondItem="u9U-A7-lbO" secondAttribute="trailing" constant="30" id="hZz-zi-NzM"/>
<constraint firstItem="XS2-AR-3j9" firstAttribute="trailing" secondItem="sAf-f8-8jc" secondAttribute="trailing" constant="10" id="hn5-U5-rvW"/>
<constraint firstItem="sAf-f8-8jc" firstAttribute="top" secondItem="SHs-vI-jD7" secondAttribute="bottom" constant="80" id="htI-gJ-mSm"/>
<constraint firstAttribute="trailing" secondItem="bw3-J9-wHr" secondAttribute="trailing" constant="20" id="hya-Ns-ldi"/>
<constraint firstItem="Bic-c4-J9E" firstAttribute="leading" secondItem="Zc1-ew-qcl" secondAttribute="leading" constant="30" id="iUf-BZ-0kl"/>
<constraint firstItem="F55-qj-PDc" firstAttribute="leading" secondItem="Zc1-ew-qcl" secondAttribute="leading" constant="10" id="jK6-2e-p3v"/>
<constraint firstItem="lEb-V2-2FC" firstAttribute="centerY" secondItem="oVh-dv-f7a" secondAttribute="centerY" id="lnJ-gm-ewM"/>
<constraint firstItem="XS2-AR-3j9" firstAttribute="bottom" secondItem="syP-Hv-OGD" secondAttribute="bottom" constant="20" id="luv-Gm-76K"/>
<constraint firstItem="sAf-f8-8jc" firstAttribute="top" secondItem="knh-D9-CuM" secondAttribute="bottom" constant="20" id="m6I-QE-hbq"/>
<constraint firstItem="eDV-A1-pOO" firstAttribute="top" secondItem="F55-qj-PDc" secondAttribute="bottom" constant="25" id="nAA-6u-CUo"/>
<constraint firstItem="XS2-AR-3j9" firstAttribute="trailing" secondItem="knh-D9-CuM" secondAttribute="trailing" constant="30" id="pFB-4b-xx9"/>
<constraint firstItem="MsK-eg-pkk" firstAttribute="centerY" secondItem="eDV-A1-pOO" secondAttribute="centerY" constant="-10" id="wpA-Xv-RdU"/>
<constraint firstItem="syP-Hv-OGD" firstAttribute="top" secondItem="sAf-f8-8jc" secondAttribute="bottom" constant="20" id="xD6-zI-9Nl"/>
<constraint firstItem="SHs-vI-jD7" firstAttribute="top" secondItem="F55-qj-PDc" secondAttribute="bottom" constant="80" id="xPl-UV-cMd"/>
<constraint firstItem="bw3-J9-wHr" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="syP-Hv-OGD" secondAttribute="trailing" constant="10" id="zAU-89-R2t"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="fnl-2z-Ty3"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="Zc1-ew-qcl" firstAttribute="trailing" secondItem="fnl-2z-Ty3" secondAttribute="trailing" id="0dW-tS-Vxe"/>
<constraint firstItem="Zc1-ew-qcl" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="bottom" constant="-320" id="9av-UX-8VL"/>
<constraint firstItem="Zc1-ew-qcl" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="LKw-N3-e8B"/>
<constraint firstItem="rKl-bF-Zpf" firstAttribute="top" secondItem="fnl-2z-Ty3" secondAttribute="top" id="W3y-NU-vli"/>
<constraint firstItem="rKl-bF-Zpf" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="cMl-Pz-ulj"/>
<constraint firstAttribute="bottom" secondItem="rKl-bF-Zpf" secondAttribute="bottom" id="pOF-9Z-ipf"/>
<constraint firstAttribute="trailing" secondItem="rKl-bF-Zpf" secondAttribute="trailing" id="xaW-C2-dLe"/>
</constraints>
<point key="canvasLocation" x="137.68115942028987" y="120.53571428571428"/>
</view>
</objects>
<resources>
<image name="coupons_scrollview_white" width="214" height="462"/>
<image name="ic_address" width="12.5" height="17"/>
<image name="ic_close_3" width="17" height="17.5"/>
<image name="ic_phone" width="15.5" height="15.5"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
<systemColor name="systemGray2Color">
<color red="0.68235294117647061" green="0.68235294117647061" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</systemColor>
</resources>
</document>
//
// MarketAnalysisItemViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 14/1/25.
//
import UIKit
class MarketAnalysisItemViewCell: UITableViewCell {
@IBOutlet weak var dateLabel: UILabel!
@IBOutlet weak var itemImage: UIImageView!
@IBOutlet weak var titleLabel: UILabel!
@IBOutlet weak var priceLabel: UILabel!
@IBOutlet weak var subtitleLabel: UILabel!
@IBOutlet weak var productTitleLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.itemImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.itemImage.image = image
}
}
}
else {
self.itemImage.image = nil
}
}
}
// lifecycle
override func awakeFromNib() {
super.awakeFromNib()
// date
dateLabel.textColor = UIColor(rgb: 0x212121)
dateLabel.font = UIFont(name: "PeridotPE-Bold", size: 12.0)
// title
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.font = UIFont(name: "PeridotPE-SBold", size: 17.0)
// price
priceLabel.textColor = UIColor(rgb: 0x212121)
priceLabel.font = UIFont(name: "PeridotPE-Bold", size: 17.0)
// subtitle
// subtitleLabel.textColor = UIColor(rgb: 0x9D9D9C)
subtitleLabel.textColor = UIColor(rgb: 0x212121)
subtitleLabel.font = UIFont(name: "PeridotPE-SBold", size: 14.0)
// productTitleLabel
productTitleLabel.textColor = UIColor(rgb: 0x212121)
productTitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 14.0)
}
}
extension MarketAnalysisItemViewCell {
func configureCell(item: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data
titleLabel.text = ""
// for merchant in merchantList {
// // if (merchant._uuid == couponSetData?.merchant_uuid) {
// if (merchant._uuid == item.merchant_uuid) {
// // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
// titleLabel.text = merchant._admin_name
// break;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = item.merchant_details
self.postImageURL = merchantDetails?._img_preview
titleLabel.text = merchantDetails?._admin_name
dateLabel.text = item.redeemed ?? "" // expiration
// itemImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// titleLabel.text = couponSetData?.name ?? ""
let priceFloat = Float(round(100 * (Float(couponSetData?.final_price ?? 0.0) )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
// subtitleLabel.text = "Έκπτωτικό κουπόνι"
subtitleLabel.text = item.redeemed_merchant_details?._name ?? ""
// subtitleLabel.text = couponSetData?.short_description ?? ""
// OR
// let htmlText = couponSetData?.inner_text ?? ""
// subtitleLabel.text = htmlText.htmlToString
let htmlText = couponSetData?.inner_text ?? ""
productTitleLabel.text = htmlText.htmlToString
}
func configureCell(item: swiftApi.CouponItemModel, isMarket: Bool) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data
titleLabel.text = ""
// for merchant in merchantList {
// if (merchant._uuid == item.merchant_uuid) {
// // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
// titleLabel.text = merchant._admin_name
// break;
// }
// }
let merchantDetails: swiftApi.MerchantModel? = item.merchant_details
self.postImageURL = merchantDetails?._img_preview
titleLabel.text = merchantDetails?._admin_name
// titleLabel.text = item.name
// self.postImageURL = item.image
dateLabel.text = item.redeemed ?? ""
let priceFloat = Float(round(100 * (Float(item.discount ?? "0.0") ?? 0.0 )) / 100)
var priceString = "0"
priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
priceLabel.text = priceString + "€"
// subtitleLabel.text = "Έκπτωτικό κουπόνι"
subtitleLabel.text = item.redeemed_merchant_details?._name ?? ""
// subtitleLabel.text = couponSetData?.short_description ?? ""
// OR
// let htmlText = couponSetData?.inner_text ?? ""
// subtitleLabel.text = htmlText.htmlToString
}
}
//
// MarketHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
class MarketHistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.CouponItemModel> = swiftApi().getOldUnifiedCouponList()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = true
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
// Add shadow
self.tableView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.tableView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.tableView.layer.shadowOpacity = 1.0
self.tableView.layer.shadowRadius = 1.0
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
// items = swiftApi().getOldUnifiedCouponList()
items = swiftApi().getOldUnifiedCouponList()
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
self.tableView.reloadData()
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.CouponItemModel>?) -> Void {
self.items = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// if (indexPath.section == 0) {
// return hasMessage ? (items.count > 0 ? 380.0 : 480.0) : 280
// }
//
// return 140.0
return UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: true)
return cell
}
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
}
if (self.showMore && indexPath.row == 3) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "MarketAnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.MarketAnalysisItemViewCell
// cell.configureCell(item: items[indexPath.row], isMarket: true)
cell.configureCell(item: items[indexPath.row])
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if (self.showMore && indexPath.row == 3) {
self.items = swiftApi().getOldUnifiedCouponList()
self.showMore = false
self.tableView.reloadData()
}
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 1, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: viewInner.frame.width - 40, height: 20))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 20)
titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.text = "Αναλυτικά"
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
viewInner.addSubview(titleLabel)
return view
} else {
return nil
}
} else {
return nil
}
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (self.items.count > 0) {
return 50.0
} else {
return 0.0
}
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
if (section == 1 && self.items.count > 0) {
return 20.0
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 30))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 0, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
return view
} else {
return nil
}
} else {
return nil
}
}
}
//
// MarketLoyaltyAnalysisViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
import SwiftEventBus
@objc public class MarketLoyaltyAnalysisViewController: UIViewController {
@IBOutlet weak var leftButton: UIButton!
@IBOutlet weak var rightButton: UIButton!
@IBOutlet weak var leftLineView: UIView!
@IBOutlet weak var rightLineView: UIView!
@IBOutlet weak var contentView: UIView!
@IBOutlet weak var contentViewHeight: NSLayoutConstraint!
var pageController: UIPageViewController!
var tabSelected = 0
var timerHistory: DispatchSourceTimer?
var seconds: Int = 0
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
// setup view
setBackButton()
setNavigationTitle("Ανάλυση")
// TODO: DELETE if tabs needed again
contentViewHeight.constant = 0
// tab
leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
leftButton.setTitle("Εξαργυρωμένα", for:.normal)
leftButton.backgroundColor = . clear
leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
rightButton.setTitle("Μοιρασμένα δώρα", for:.normal)
rightButton.backgroundColor = . clear
rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
// leftLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
// rightLineView.applyGradient(colours: [UIColor(rgb: 0x1DA6B9), UIColor(rgb: 0xB2CE69)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
leftLineView.isHidden = false
rightLineView.isHidden = true
// TODO: UNCOMMENT if tabs needed again
// pages
// pageController = UIPageViewController(transitionStyle:.scroll, navigationOrientation:.horizontal)
// pageController.dataSource = self;
// pageController.delegate = self;
//
// pageController.view.frame = contentView.bounds;
// addChild(pageController)
// contentView.addSubview(pageController.view)
// pageController .didMove(toParent: self)
//
// let analysisVC = self.viewControllerAt(0)
// pageController.setViewControllers([analysisVC!], direction:.forward, animated:false)
// <==
// TODO: DELETE if tabs needed again ==>
// Instantiate the child view controller
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let childVC = storyboard.instantiateViewController(withIdentifier:"MarketHistoryViewController") as! SwiftWarplyFramework.MarketHistoryViewController
// Add the child view controller
addChild(childVC)
// Add the child view controller's view to the container
contentView.addSubview(childVC.view)
// Set up constraints for the child view to match the container view
childVC.view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
childVC.view.topAnchor.constraint(equalTo: contentView.topAnchor),
childVC.view.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
childVC.view.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
childVC.view.trailingAnchor.constraint(equalTo: contentView.trailingAnchor),
])
// Notify the child view controller that it has been moved to the parent
childVC.didMove(toParent: self)
// <==
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "LoyaltyHistoryScreen")
self.startTimer()
self.navigationController?.hideHairline()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
}
// MARK: - Functions
func startTimer() {
print("========= GiftsCalculator Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".history.timer")
timerHistory = DispatchSource.makeTimerSource(queue: queue)
timerHistory!.schedule(deadline: .now(), repeating: .seconds(1))
timerHistory!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= GiftsCalculator interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerHistory!.resume()
}
func stopTimer() {
print("========= GiftsCalculator Timer Stopped! =========")
timerHistory?.cancel()
timerHistory = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "GiftsCalculator")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
////////////////////////////////////////////////////////////////////////////////
private func viewControllerAt(_ index:Int) -> AnalysisChildViewController?
{
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if (index == 1) {
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabShared"))
let analysisVC = storyboard.instantiateViewController(withIdentifier:"MarketSharingHistoryViewController") as! SwiftWarplyFramework.MarketSharingHistoryViewController
analysisVC.index = index;
return analysisVC;
}
swiftApi().logTrackersEvent("click", ("LoyaltyHistoryScreen:" + "TabExpired"))
let analysisVC = storyboard.instantiateViewController(withIdentifier:"MarketHistoryViewController") as! SwiftWarplyFramework.MarketHistoryViewController
analysisVC.index = index;
return analysisVC;
}
// MARK: - Handlers
@IBAction func handleLeft() {
if (tabSelected != 0) {
self.tabSelected = 0
UIView.animate(withDuration: 2.0, delay: 0.0) {
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
}
let analysisVC = self.viewControllerAt(0)
pageController.setViewControllers([analysisVC!], direction:.reverse, animated:true)
}
}
@IBAction func handleRight() {
if (tabSelected != 1) {
self.tabSelected = 1
UIView.animate(withDuration: 2.0, delay: 0.0) {
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
}
let analysisVC = self.viewControllerAt(1)
pageController.setViewControllers([analysisVC!], direction:.forward, animated:true)
}
}
}
// MARK: - PageViewController
extension MarketLoyaltyAnalysisViewController: UIPageViewControllerDataSource, UIPageViewControllerDelegate {
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 0) {
return nil;
}
index -= 1;
return viewControllerAt(index);
}
return nil;
}
public func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
if let analysisVC = viewController as? AnalysisChildViewController {
var index = analysisVC.index
if (index == 1) {
return nil;
}
index += 1;
return viewControllerAt(index);
}
return nil;
}
public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
if (!completed) {
return;
}
if let childVCs = pageViewController.viewControllers as? [AnalysisChildViewController] {
let currentIndex = childVCs[0].index
if (currentIndex == 0) {
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.leftButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.rightButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
self.tabSelected = 0
self.leftLineView.isHidden = false
self.rightLineView.isHidden = true
} else {
self.leftButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 15)
self.rightButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
self.rightButton.setTitleColor(UIColor(rgb: 0x212121), for:.normal)
self.leftButton.setTitleColor(UIColor(rgb: 0x848484), for:.normal)
self.tabSelected = 1
self.leftLineView.isHidden = true
self.rightLineView.isHidden = false
}
}
}
}
//
// MarketPassInfoViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 14/1/25.
//
import UIKit
@objc public class MarketPassInfoViewController: UIViewController {
@IBOutlet weak var heroImage: UIImageView!
@IBOutlet weak var heroTitleLabel: UILabel!
@IBOutlet weak var storeInfoImage: UIImageView!
@IBOutlet weak var storeInfoTitleLabel: UILabel!
@IBOutlet weak var storeInfoSubtitleLabel: UILabel!
@IBOutlet weak var eshopInfoImage: UIImageView!
@IBOutlet weak var eshopInfoTitleLabel: UILabel!
@IBOutlet weak var eshopInfoSubtitleLabel: UILabel!
@IBOutlet weak var abInfoImage: UIImageView!
@IBOutlet weak var abInfoTitleLabel: UILabel!
@IBOutlet weak var abInfoSubtitleLabel: UILabel!
@IBOutlet weak var okButton: UIButton!
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
setBackButton()
setNavigationTitle("Οδηγίες χρήσης")
setupUI()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "MarketPassInfoScreen")
self.navigationController?.hideHairline()
}
// MARK: - Functions
func setupUI() {
heroImage.image = UIImage(named: "pass_info_hero", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
storeInfoImage.image = UIImage(named: "pass_info_cart", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
eshopInfoImage.image = UIImage(named: "pass_info_globe", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
abInfoImage.image = UIImage(named: "pass_info_ab", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
heroTitleLabel.text = "Πως λειτουργεί:"
heroTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 24)
heroTitleLabel.textColor = UIColor(rgb: 0x212121)
// StoreInfoView
storeInfoTitleLabel.text = "Εξαργύρωση σε φυσικά καταστήματα"
storeInfoTitleLabel.font = UIFont(name: "PeridotPE-Bold", size: 19.0)
storeInfoTitleLabel.textColor = UIColor(rgb: 0x212121)
storeInfoSubtitleLabel.text = "Σκάναρε το barcode από το κινητό σου στο ταμείο του καταστήματος και κέρδισε απευθείας έκπτωση από τα διαθέσιμα κουπόνια."
storeInfoSubtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
storeInfoSubtitleLabel.textColor = UIColor(rgb: 0x212121)
// EshopInfoView
eshopInfoTitleLabel.text = "Εξαργύρωση στο eshop"
eshopInfoTitleLabel.font = UIFont(name: "PeridotPE-Bold", size: 19.0)
eshopInfoTitleLabel.textColor = UIColor(rgb: 0x212121)
eshopInfoSubtitleLabel.text = "Πληκτρολόγησε τον κωδικό σου στο αντίστοιχο πεδίο κατά το checkout στο eshop και κέρδισε απευθείας έκπτωση από τα διαθέσιμα κουπόνια."
eshopInfoSubtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
eshopInfoSubtitleLabel.textColor = UIColor(rgb: 0x212121)
// ABInfoView
abInfoTitleLabel.text = "Ειδικά για τον ΑΒ"
abInfoTitleLabel.font = UIFont(name: "PeridotPE-Bold", size: 19.0)
abInfoTitleLabel.textColor = UIColor(rgb: 0x212121)
abInfoSubtitleLabel.text = "1. Eνεργοποίησε τον κωδικό στην κάρτα ΑΒ PLUS στο kiosk του καταστήματος ή μέσω eshop / app στην ενοτητα στην ενότητα Συνεργασίες – SUPERMARKET DEALS.\n\n2. Κάνε τις αγορές σου και κέρδισε απευθείας έκπτωση με χρήση της AB PLUS από τα διαθέσιμα κουπόνια."
abInfoSubtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
abInfoSubtitleLabel.textColor = UIColor(rgb: 0x212121)
// okButton
okButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
okButton.setTitle("Επιστροφή στο Supermarket Deals", for: .normal)
okButton.setTitleColor(.white, for: .normal)
okButton.backgroundColor = UIColor(rgb: 0x0EA600)
okButton.layer.cornerRadius = 10.0
}
// MARK: - Actions
@IBAction func okButtonAction(_ sender: Any) {
self.navigationController?.popViewController(animated: true)
}
}
//
// MarketPassViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 14/1/25.
//
import UIKit
import RSBarcodes_Swift
import AVFoundation
import SwiftEventBus
@objc public class MarketPassViewController: UIViewController {
@IBOutlet weak var passContainerView: UIView!
@IBOutlet weak var passTitleLabel: UILabel!
@IBOutlet weak var passSubtitleLabel: UILabel!
@IBOutlet weak var barcodeView: UIView!
@IBOutlet weak var barcodeImage: UIImageView!
@IBOutlet weak var barcodeImageHeight: NSLayoutConstraint!
@IBOutlet weak var barcodeLabel: UILabel!
@IBOutlet weak var couponsValueLabel: UILabel!
@IBOutlet weak var smLogosView: UIView!
@IBOutlet weak var mapButton: UIButton!
var marketPassDetails:swiftApi.MarketPassDetailsModel? = swiftApi().getMarketPassDetails()
// let spinner = SpinnerViewController()
let uiscreen: CGRect = UIScreen.main.bounds
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
passContainerView.isHidden = true
// getMarketPassDetailsRequest()
SwiftEventBus.onBackgroundThread(self, name: "market_pass_details_fetched") { result in
DispatchQueue.main.async {
if let tempMarketPassDetails = swiftApi().getMarketPassDetails() {
self.marketPassDetails = tempMarketPassDetails
self.updateUI()
} else {
// self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
}
setBackButton()
setNavigationTitle("SUPERMARKET DEALS")
// Setup the info button with an action
setNavBarRightInfoButton() {
// This closure is the action that will be executed when the info button is tapped
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "MarketPassInfoViewController") as! SwiftWarplyFramework.MarketPassInfoViewController
self.navigationController?.pushViewController(vc, animated: true)
}
setupUI()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "MarketPassScreen")
self.navigationController?.hideHairline()
}
// MARK: - Functions
func setupUI() {
passContainerView.backgroundColor = UIColor(rgb: 0x36B32B)
passContainerView.layer.cornerRadius = 16.0
// Add shadow
passContainerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.31).cgColor
passContainerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
passContainerView.layer.shadowOpacity = 1.0
passContainerView.layer.shadowRadius = 3.0
passTitleLabel.text = "SUPERMARKET DEALS CARD"
// passTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 23)
passTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 22)
passTitleLabel.textColor = .white
passSubtitleLabel.text = "Χρησιμοποίησε τον κωδικό σου και κέρδισε έκπτωση στις αγορές σου!"
passSubtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 17.0)
passSubtitleLabel.textColor = .white
barcodeView.backgroundColor = .white
barcodeView.layer.cornerRadius = 16.0
barcodeView.layer.borderWidth = 2
barcodeView.layer.borderColor = UIColor(rgb: 0xDADDE4).cgColor
let barcodeString = ""
barcodeLabel.text = barcodeString
barcodeLabel.font = UIFont(name: "PeridotPE-Regular", size: 19.0)
barcodeLabel.textColor = UIColor(rgb: 0x212121)
// if let barcodeUIImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.12)) {
// // if let barcodeUIImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: 110, height: 83)) {
// barcodeImage.image = barcodeUIImage
// barcodeImageHeight.constant = self.uiscreen.height * 0.12
// // barcodeImageHeight.constant = 83
// } else {
// barcodeImageHeight.constant = 0
// }
let couponsValueString = "0.00"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor: UIColor.white]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 17) ?? UIFont.boldSystemFont(ofSize: 16), NSAttributedString.Key.foregroundColor: UIColor.white]
let couponsValueNormalText1 = "Έχεις κουπόνια συνολικής αξίας "
let couponsValueBoldText = couponsValueString + "€"
let couponsValueAttributedString = NSMutableAttributedString(string:couponsValueNormalText1, attributes:attrRegular)
let couponsValueBoldString = NSMutableAttributedString(string: couponsValueBoldText, attributes:attrBold)
couponsValueAttributedString.append(couponsValueBoldString)
couponsValueLabel.attributedText = couponsValueAttributedString
mapButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 16)
mapButton.setTitle("Δες στο χάρτη", for: .normal)
mapButton.setTitleColor(UIColor(rgb: 0x006D26), for: .normal)
mapButton.layer.cornerRadius = 10.0
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: 148, height: 48)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 55)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
mapButton.backgroundColor = .clear
mapButton.layer.borderWidth = 2
mapButton.layer.borderColor = UIColor(rgb: 0x006D26).cgColor
smLogosView.layer.cornerRadius = 16.0
smLogosView.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // Bottom left, right corner radius
// TODO: FIX - Replace with dynamic images
// let imageNames = ["active_code_logo_2", "active_code_logo_2", "active_code_logo_2"]
// // let images = imageNames.compactMap { UIImage(named: $0) }
// let images = imageNames.compactMap { UIImage(named: $0, in: MyEmptyClass.resourceBundle(), compatibleWith: nil) }
// // Create a horizontal stack view
// let stackView = UIStackView()
// stackView.axis = .horizontal
// stackView.spacing = 15 // Spacing between images
// stackView.alignment = .center
// stackView.distribution = .equalSpacing
// // Add UIImageViews to the stack view
// for image in images {
// let imageView = UIImageView(image: image)
// imageView.contentMode = .scaleAspectFit
// imageView.widthAnchor.constraint(equalToConstant: 40).isActive = true // Set a width
// imageView.heightAnchor.constraint(equalToConstant: 40).isActive = true // Set a height
// stackView.addArrangedSubview(imageView)
// }
// // Add the stack view to your main view
// smLogosView.addSubview(stackView)
// // Set up constraints for the stack view
// stackView.translatesAutoresizingMaskIntoConstraints = false
// NSLayoutConstraint.activate([
// stackView.leadingAnchor.constraint(equalTo: smLogosView.leadingAnchor, constant: 25),
// stackView.centerYAnchor.constraint(equalTo: smLogosView.centerYAnchor),
// ])
if let tempMarketPassDetails = swiftApi().getMarketPassDetails() {
self.marketPassDetails = tempMarketPassDetails
self.updateUI()
} else {
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
func updateUI() {
// let barcodeString = constructBarcode(coupon: marketPassDetails?._barcode) ?? ""
let barcodeString = marketPassDetails?._barcode ?? ""
barcodeLabel.text = barcodeString
barcodeLabel.frame.size.width = barcodeLabel.intrinsicContentSize.width
barcodeLabel.frame.size.height = barcodeLabel.intrinsicContentSize.height
if let barcodeUIImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.12)) {
// if let barcodeUIImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: 110, height: 83)) {
barcodeImage.image = barcodeUIImage
barcodeImageHeight.constant = self.uiscreen.height * 0.12
// barcodeImageHeight.constant = 83
} else {
barcodeImageHeight.constant = 0
}
let couponsValueFloat = marketPassDetails?._total_available_discount ?? 0.0
let couponsValueString = String(format: "%.2f", couponsValueFloat)
// let couponsValueString = String(marketPassDetails?._total_available_discount ?? 0.0)
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 17) ?? UIFont.systemFont(ofSize: 16), NSAttributedString.Key.foregroundColor: UIColor.white]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 17) ?? UIFont.boldSystemFont(ofSize: 16), NSAttributedString.Key.foregroundColor: UIColor.white]
let couponsValueNormalText1 = "Έχεις κουπόνια συνολικής αξίας "
let couponsValueBoldText = couponsValueString + "€"
let couponsValueAttributedString = NSMutableAttributedString(string:couponsValueNormalText1, attributes:attrRegular)
let couponsValueBoldString = NSMutableAttributedString(string: couponsValueBoldText, attributes:attrBold)
couponsValueAttributedString.append(couponsValueBoldString)
couponsValueLabel.attributedText = couponsValueAttributedString
let supermarkets: Array<swiftApi.SupermarketModel> = marketPassDetails?._supermarkets ?? []
// Create a horizontal stack view
let stackView = UIStackView()
stackView.axis = .horizontal
stackView.spacing = 5 // Spacing between images
stackView.alignment = .center
stackView.distribution = .equalSpacing
// Load images dynamically
for sm in supermarkets {
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit
imageView.widthAnchor.constraint(equalToConstant: 50).isActive = true
imageView.heightAnchor.constraint(equalToConstant: 50).isActive = true
imageView.load(link: sm._logo, placeholder: UIImage(), cache: URLCache())
// Add image view to the stack view
stackView.addArrangedSubview(imageView)
}
// Add the stack view to your main view
smLogosView.addSubview(stackView)
// Set up constraints for the stack view
stackView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
stackView.leadingAnchor.constraint(equalTo: smLogosView.leadingAnchor, constant: 25),
stackView.centerYAnchor.constraint(equalTo: smLogosView.centerYAnchor),
])
passContainerView.isHidden = false
self.view.layoutIfNeeded()
}
// func showSpinner() {
// // add the spinner view controller
// // addChild(spinner)
// // spinner.view.frame = view.frame
// // view.addSubview(spinner.view)
// // spinner.didMove(toParent: self)
// addChild(spinner)
// spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
// self.view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
// }
// func hideSpinner() {
// // remove the spinner view controller
// spinner.willMove(toParent: nil)
// spinner.view.removeFromSuperview()
// spinner.removeFromParent()
// }
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func constructBarcode() -> String? {
// EAN 13 barcode construction
//TODO: FIX
// let couponString = coupon?._barcode ?? ""
let couponString = "123456789101112"
if (!couponString.isEmpty) {
var checkDigit = 0;
var result = 0;
var fixedCouponCode = couponString;
if (fixedCouponCode.count < 12) {
let loops = 12 - fixedCouponCode.count;
var zerosStr = "";
for i in 0 ..< loops {
zerosStr += "0"
}
// fixedCouponCode = zerosStr + fixedCouponCode;
fixedCouponCode = fixedCouponCode + zerosStr;
}
var multiplier = 3;
for idx in (0 ... (fixedCouponCode.count - 1)).reversed() {
let curChar = fixedCouponCode[idx];
result += (Int(curChar) ?? 0) * multiplier;
multiplier = multiplier == 3 ? 1 : 3;
}
checkDigit = 10 - (result % 10);
let barcodeStr = fixedCouponCode + String(checkDigit);
return barcodeStr;
}
return ""
}
// MARK: - API Functions
// func getMarketPassDetailsRequest() {
// showSpinner()
// swiftApi().getMarketPassDetailsAsync(getMarketPassDetailsCallback, failureCallback: {errorCode in
// print("========= getMarketPassDetailsRequest ERROR CODE =========", errorCode)
// self.hideSpinner()
// self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
// })
// }
// func getMarketPassDetailsCallback (_ marketPassDetailsData: swiftApi.MarketPassDetailsModel?) -> Void {
// self.hideSpinner()
// if (marketPassDetailsData != nil) {
// DispatchQueue.main.async {
// if let tempMarketPassDetailsData = marketPassDetailsData {
// self.marketPassDetails = tempMarketPassDetailsData
// self.updateUI()
// }
// }
// } else {
// self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
// }
// }
// MARK: - Actions
@IBAction func mapButtonAction(_ sender: Any) {
swiftApi().openSupermarketMap(self)
}
}
//
// MarketSharingHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
class MarketSharingHistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.SharingCouponModel> = Array()
var allItems: Array<swiftApi.SharingCouponModel> = Array()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = false
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
// Add shadow
self.tableView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.tableView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.tableView.layer.shadowOpacity = 1.0
self.tableView.layer.shadowRadius = 1.0
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
swiftApi().getSharingHistoryAsync(isMarketHistory: true, getSharingHistoryCallback: responseCallback, failureCallback: {errorCode in })
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.SharingCouponModel>?) -> Void {
self.items = data!
self.allItems = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1;
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// if (indexPath.section == 0) {
// return hasMessage ? 380.0 : (items.count > 0 ? 280 : 380)
// }
//
// return 140.0
return UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: true)
return cell
}
if ((self.showMore == true) && (indexPath.row == 3)) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
cell.configureCell(item: items[indexPath.row], isMarket: true)
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if ((self.showMore == true) && (indexPath.row == 3)) {
self.items = self.allItems
self.showMore = false
self.tableView.reloadData()
}
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 1, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: viewInner.frame.width - 40, height: 20))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 20)
titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.text = "Αναλυτικά"
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
viewInner.addSubview(titleLabel)
return view
} else {
return nil
}
} else {
return nil
}
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (self.items.count > 0) {
return 50.0
} else {
return 0.0
}
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
if (section == 1 && self.items.count > 0) {
return 20.0
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 30))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 0, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
return view
} else {
return nil
}
} else {
return nil
}
}
}
{
"images" : [
{
"filename" : "active_code_logo.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "active_code_logo-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "active_code_logo-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "active_code_logo_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "active_code_logo_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "active_code_logo_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "arrow_right_black.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "arrow_right_black 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "arrow_right_black 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "circle_checked.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "circle_checked 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "circle_checked 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "circle_unchecked.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "circle_unchecked 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "circle_unchecked 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_2_selected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_2_selected 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_2_selected 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_grey.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_grey 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_grey 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_shadow.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_shadow 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_shadow 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_bg_shadow_grey.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_bg_shadow_grey 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_bg_shadow_grey 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_market.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_market 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_market 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupon_market_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupon_market_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupon_market_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupons_scrollview_dark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupons_scrollview_dark-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupons_scrollview_dark-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "coupons_scrollview_white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "coupons_scrollview_white-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "coupons_scrollview_white-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "curved_bg_white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "curved_bg_white-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "curved_bg_white-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "curved_bg_white_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "curved_bg_white_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "curved_bg_white_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "default_profile_image.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "default_profile_image-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "default_profile_image-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "default_profile_image_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "default_profile_image_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "default_profile_image_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dfy_logo_colored.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dfy_logo_colored 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dfy_logo_colored 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "dfy_logo_white.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "dfy_logo_white-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "dfy_logo_white-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "eshop_ab.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "eshop_ab 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "eshop_ab 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "eshop_masoutis.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "eshop_masoutis 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "eshop_masoutis 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "heart.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "heart-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "heart-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "history_banner_box.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "history_banner_box 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "history_banner_box 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "history_banner_dfy.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "history_banner_dfy 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "history_banner_dfy 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "history_banner_gfy.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "history_banner_gfy 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "history_banner_gfy 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "history_banner_sm.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "history_banner_sm 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "history_banner_sm 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "history_heart.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "history_heart 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "history_heart 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_pin_location.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_pin_location-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_pin_location-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_background_circle.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_background_circle-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_background_circle-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_background_straight.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_background_straight 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_background_straight 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_pin_compass.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_pin_compass-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_pin_compass-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_down_dark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_down_dark-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_down_dark-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_down_dark_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_down_dark_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_down_dark_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_empty_wallet.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_empty_wallet-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_empty_wallet-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_empty_wallet_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_empty_wallet_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_empty_wallet_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_empty_wallet_3.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_empty_wallet_3 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_empty_wallet_3 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_gift_circle.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_gift_circle-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_gift_circle-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_gift_circle_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_gift_circle_2-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_gift_circle_2-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_gift_history.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_gift_history 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_gift_history 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_history_market.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_history_market 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_history_market 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_history_market_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_history_market_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_history_market_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_pin_tel.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_pin_tel-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_pin_tel-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_time_forward.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_time_forward 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_time_forward 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_time_forward_blue.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_time_forward_blue 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_time_forward_blue 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_up_dark.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_up_dark-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_up_dark-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_up_dark_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_up_dark_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_up_dark_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "map_pin.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "map_pin 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "map_pin 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "market_bg.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "market_bg 1.jpg",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "market_bg 2.jpg",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "new_icon.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "new_icon-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "new_icon-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "new_icon_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "new_icon_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "new_icon_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "pass_info_ab.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pass_info_ab 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pass_info_ab 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "pass_info_cart.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pass_info_cart 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pass_info_cart 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "pass_info_globe.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pass_info_globe 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pass_info_globe 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "pass_info_hero.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pass_info_hero 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pass_info_hero 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "shopping_cart.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "shopping_cart 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "shopping_cart 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sm_ab.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sm_ab 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sm_ab 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sm_masoutis.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sm_masoutis 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sm_masoutis 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "sm_sklavenitis.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "sm_sklavenitis 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "sm_sklavenitis 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "top_border_line.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "top_border_line-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "top_border_line-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "top_border_shadow.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "top_border_shadow-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "top_border_shadow-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_badge_lines.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_badge_lines 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_badge_lines 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_banner_box.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_banner_box 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_banner_box 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_banner_dfy.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_banner_dfy 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_banner_dfy 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_banner_gfy.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_banner_gfy 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_banner_gfy 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_banner_sm.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_banner_sm 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_banner_sm 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_coupons.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_coupons-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_coupons-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_coupons_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_coupons_2-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_coupons_2-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_coupons_3.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_coupons_3 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_coupons_3 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_coupons_4.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_coupons_4 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_coupons_4 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_coupons_empty.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_coupons_empty 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_coupons_empty 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_dfy_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_dfy_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_dfy_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_dfy_3.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_dfy_3 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_dfy_3 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_dfy_earn.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_dfy_earn-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_dfy_earn-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_dfy_empty.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_dfy_empty 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_dfy_empty 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_history.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_history 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_history 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_history_blue.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_history_blue 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_history_blue 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_market.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_market 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_market 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_market_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_market_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_market_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_market_empty.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_market_empty 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_market_empty 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_plus.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_plus 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_plus 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_plus_blue.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_plus_blue 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_plus_blue 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_summary.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_summary 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_summary 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_summary_2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_summary_2 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_summary_2 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wallet_voucher.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wallet_voucher 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wallet_voucher 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
//
// MerchantAnnotation.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 20/9/22.
//
import Foundation
import MapKit
@objc public class MerchantAnnotation: NSObject, MKAnnotation {
let model: swiftApi.MerchantModel
public let coordinate: CLLocationCoordinate2D
init(_ model: swiftApi.MerchantModel) {
self.model = model
self.coordinate = CLLocationCoordinate2D(latitude: model._latitude, longitude: model._longitude)
super.init()
}
}
//
// MerchantTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/10/24.
//
import UIKit
// Define a protocol (if using delegation)
protocol MerchantTableViewCellDelegate: AnyObject {
func didTapButton(in cell: MerchantTableViewCell)
}
class MerchantTableViewCell: UITableViewCell {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var merchantImage: UIImageView!
@IBOutlet weak var buttonView: UIView!
@IBOutlet weak var buttonTitleLable: UILabel!
@IBOutlet weak var buttonIconImage: UIImageView!
@IBOutlet weak var actionButton: UIButton!
// Delegate variable
weak var delegate: MerchantTableViewCellDelegate?
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.merchantImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.merchantImage.image = image
}
}
}
else {
self.merchantImage.image = nil
}
}
}
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
mainView.backgroundColor = UIColor(rgb: 0xF2F2F3)
mainView.layer.cornerRadius = 20.0
buttonTitleLable.font = UIFont(name: "PeridotPE-SBold", size: 13)
buttonTitleLable.textColor = UIColor(rgb: 0xFFFFFF)
buttonView.backgroundColor = UIColor(rgb: 0x0EA600)
buttonView.layer.cornerRadius = 12.0
// Add action for button tap
actionButton.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
// public override func layoutSubviews() {
// super.layoutSubviews()
// //set the values for top,left,bottom,right margins
// let margins = UIEdgeInsets(top: 0, left: 0, bottom: 32, right: 0)
// contentView.frame = contentView.frame.inset(by: margins)
// }
func configureCell(shop: swiftApi.ShopAvailabilityItemModel, buttonTitle: String, iconImage: String?, showEshops: Bool?) {
if (showEshops == true) {
if (shop._merchant_uuid == "ab") {
self.merchantImage.image = UIImage(named: "eshop_ab", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
} else if (shop._merchant_uuid == "masoutis") {
self.merchantImage.image = UIImage(named: "eshop_masoutis", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
} else {
for merchant in merchantList {
if (merchant._uuid == shop._merchant_uuid) {
self.postImageURL = merchant._img_preview
break;
}
}
}
buttonTitleLable.text = buttonTitle
if let iconImage {
self.buttonIconImage.image = UIImage(named: iconImage, in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
self.buttonIconImage.isHidden = false
} else {
self.buttonIconImage.isHidden = true
}
}
@objc private func buttonTapped() {
// Notify the delegate when button is tapped
delegate?.didTapButton(in: self)
}
}
......@@ -80,33 +80,14 @@
- (NSDictionary*)redeemCouponWithCoupon:(NSString*)coupon :(NSString*)communication_uuid;
- (NSDictionary*)validateCouponWithCoupon:(NSString*)coupon;
- (NSDictionary*)loginCosmoteWithGuid:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket;
- (void)getCouponsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCouponsUniversalAsync:(NSString*)language :(NSString*)couponsetType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) createUnifiedCouponAsync:(NSArray*)couponCodes :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getUnifiedCouponsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) getAvailableCouponsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCouponsetsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCouponsetsDealsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) cancelUnifiedCouponAsync:(NSString*) transactionId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure;
- (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMarketPassDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)setPacingDetailsAsync:(NSNumber*)steps :(NSString*)date :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)cosmoteSharingAsync:(NSString*)sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)cosmoteRetrieveSharingAsync:(NSString*)sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCosmoteUserAsync:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)cosmoteCouponSharingAsync:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)submitOrderAsync:(NSString*) campaign_session_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(NSString*)notificationMessage :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)postEventAsync:(NSString*)Session_ID :(NSString*)OfferAudienceLevel :(NSString*)msisdn :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCampaignsAsyncNew:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getCampaignsPersonalizedAsync:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getMarketSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getMultilingualMerchantsAsync:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
// - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state;
- (void)didReceiveNotification:(NSDictionary *)payload;
......@@ -118,9 +99,7 @@
// - (BOOL)checkforLoyaltySDKNotification:(NSDictionary *)payload :(void(^)(NSNumber *successResponse))success failureBlock:(void(^)(NSNumber *failureResponse))failure;
- (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken;
- (BOOL)sdkInitialised;
- (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMapDataAsync:(NSString*)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority;
- (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token;
- (NSString*)getAccessTokenM;
......
......@@ -1449,20 +1449,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
return resp;
}
- (void)getCouponsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getCouponsWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getCouponsUniversalAsync:(NSString*)language :(NSString*)couponsetType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
......@@ -1477,34 +1463,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void) createUnifiedCouponAsync:(NSArray*)couponCodes :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] createUnifiedCouponWithSuccessBlock:couponCodes :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getUnifiedCouponsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getUnifiedCouponsWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void) getAvailableCouponsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getAvailableCouponsWithSuccessBlock:^(NSDictionary *response) {
......@@ -1531,45 +1489,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void) getCouponsetsDealsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getCouponSetsDealsWithSuccessBlock:active andVisible:visible andUuids:uuids :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void) cancelUnifiedCouponAsync:(NSString*) transactionId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] cancelUnifiedCouponWithSuccessBlock:transactionId :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure
{
[[Warply sharedService] getInbox2WithSuccessBlock :^(NSArray *inbox) {
if (success) {
success(inbox);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] verifyTicketWithSuccessBlock:guid :ticket :^(NSDictionary *response) {
......@@ -1583,17 +1502,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getProfileWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
failure(error);
}];
}
- (void)getMarketPassDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getMarketPassDetailsWithSuccessBlock:^(NSDictionary *response) {
......@@ -1607,93 +1515,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] consumerIntegrationWithSuccessBlock:nonTelco :acceptedConsent :msisdnList :guid :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] redeemCouponSetsWithSuccessBlock:uuid :communication_uuid :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] redeemCouponSetsWithSuccessBlock:uuid :communication_uuid :user_msisdn :businessService :offerName :productType :provDuration :noOfRecurrance :price :discount :voiceCategory :dataCategory :minsValue :dataValue :provStepValueMins :OfferAudienceLevel :UACIOfferTrackingCode :OFFERCODE1 :SCORE :ZONE :WAVE :VALIDITY :TREATMENT_CODE :ccms_session_id :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getPacingDetailsWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
failure(error);
}];
}
- (void)setPacingDetailsAsync:(NSNumber*)steps :(NSString*)date :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] setPacingDetailsWithSuccessBlock:steps :date :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
failure(error);
}];
}
- (void)cosmoteSharingAsync:(NSString*)sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] cosmoteSharingWithSuccessBlock:sharingId :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)cosmoteRetrieveSharingAsync:(NSString*)sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] cosmoteRetrieveSharingWithSuccessBlock:sharingId :accept :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getCosmoteUserAsync:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getCosmoteUserWithSuccessBlock:guid :^(NSDictionary *response) {
......@@ -1707,43 +1528,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)cosmoteCouponSharingAsync:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] cosmoteCouponSharingWithSuccessBlock:coupon :sender :receiver :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)submitOrderAsync:(NSString*) campaign_session_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(NSString*)notificationMessage :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] submitOrderWithSuccessBlock:campaign_session_uuid :user_msisdn :businessService :offerName :productType :provDuration :noOfRecurrance :price :discount :voiceCategory :dataCategory :minsValue :dataValue :provStepValueMins :OfferAudienceLevel :UACIOfferTrackingCode :OFFERCODE1 :SCORE :ZONE :WAVE :VALIDITY :TREATMENT_CODE :ccms_session_id :notificationMessage :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)postEventAsync:(NSString*)Session_ID :(NSString*)OfferAudienceLevel :(NSString*)msisdn :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] postEventWithSuccessBlock:Session_ID :OfferAudienceLevel :msisdn :UACIOfferTrackingCode :OFFERCODE1 :SCORE :ZONE :WAVE :VALIDITY :TREATMENT_CODE :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
failure(error);
}];
}
- (void)getCampaignsAsyncNew:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure
{
[[Warply sharedService] getCampaignsWithSuccessBlock:language :filters :^(NSDictionary *response) {
......@@ -1770,32 +1554,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure
{
[[Warply sharedService] getSharingHistoryWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getMarketSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure
{
[[Warply sharedService] getMarketSharingHistoryWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getMultilingualMerchantsAsync:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure {
[[Warply sharedService] retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:categories andDefaultShown:defaultShown andCenter:center andTags:tags andUuid:uuid andDistance:distance parent_uuids:parent_uuids :^(NSDictionary *response) {
......@@ -1876,18 +1634,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}
- (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure {
[[Warply sharedService] editProfileWithSuccessBlock:firstname andLastName:lastname andEmail:email andSalutation:salutation andMsisdn:msisdn andNickname:nickname andGender:gender andBirthday:birthday andNameDay:nameday andTaxID:taxid andProfileMetadata:profileMetadata optin:optin newsLetter:newsletter andSMS:sms andSegmentation:segmentation andSMSSegmentation:smsSegmentation :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure {
[[Warply sharedService] getSingleCampaignWithSuccessBlock:sessionUuid :^(NSDictionary *response) {
if (success) {
......@@ -1900,18 +1646,6 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getMapDataAsync:(NSString*)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure {
[[Warply sharedService] getMapDataWithSuccessBlock:language :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority {
NSString *event_Name = eventName;
NSNumber *time_submitted = [NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]];
......
//
// NumberPopupViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 15/7/22.
//
import UIKit
protocol NumbersPopupDelegate {
func numbersPopupTapped(_ sender: Any)
func presentedPopup()
func dismissedPopup()
func optionSelected(_ option: String)
}
@objc public class NumberPopupViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var tableView: UITableView!
let uiscreen: CGRect = UIScreen.main.bounds
var delegateBallon: NumbersPopupDelegate?
var numbersList: Array<String> = []
var headerText: String = "Αποστολέας"
var widthPopup: Int = 0
var heightPopup: Int = 0
func InitWithController(controller: UIViewController, numbersList: Array<String>, sender: Any, delegate: NumbersPopupDelegate, headerText: String){
//print("Ok InitWithController sender ")
delegateBallon = delegate
// set the presentation style
self.modalPresentationStyle = UIModalPresentationStyle.overFullScreen
// set up the popover presentation controller
// self.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up
self.popoverPresentationController?.delegate = self
self.popoverPresentationController?.sourceView = (sender as! UIView ) // button
//--- Better center of the arrow
// let rect: CGRect = (sender as AnyObject).bounds
// let rectFixed: CGRect = CGRect(x: rect.origin.x, y: rect.origin.y, width: rect.size.width-10, height: rect.size.height)
// self.popoverPresentationController?.sourceRect = rectFixed
self.popoverPresentationController?.backgroundColor = UIColor.clear
// self.popoverPresentationController?.backgroundColor = UIColor(red: 0.22, green: 0.32, blue: 0.40, alpha: 0.58)
DispatchQueue.main.async {
// present the popover
controller.present(self, animated: true, completion: nil)
}
self.numbersList = numbersList
self.headerText = headerText
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
}
public override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
// setupScreens()
tableView.delegate = self
tableView.dataSource = self
popupView.clipsToBounds = true
popupView.layer.cornerRadius = 12
popupView.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, right corner radius
self.preferredContentSize = CGSize(width: widthPopup, height: heightPopup)
closeButton.setImage(UIImage(named: "ic_close_3.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
closeButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
// self.tableView.reloadData()
self.tableView.invalidateIntrinsicContentSize()
self.headerLabel.text = self.headerText
}
func setupScreens() {
// if UIDevice.current.userInterfaceIdiom == .pad {
// // Do what you want
// widthPopup = 450
// heightPopup = 550
// textView.font = UIFont(name: Fonts.ProximaNova.semibold, size: 20)
// } else if UIDevice.current.userInterfaceIdiom == .phone {
// // Do what you want
// widthPopup = 250
// heightPopup = 360
// textView.font = UIFont(name: Fonts.ProximaNova.semibold, size: 14)
// }
}
public override func viewDidAppear(_ animated: Bool) {
delegateBallon?.presentedPopup()
}
public override func viewDidDisappear(_ animated: Bool) {
delegateBallon?.dismissedPopup()
}
public override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
public override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
//print("In prepare")
}
public func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return UIModalPresentationStyle.overFullScreen
}
public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
return UIModalPresentationStyle.overFullScreen
// return UIModalPresentationStyle.none
}
// MARK: - UIButton Action
@IBAction func closeButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {
})
}
}
// MARK: - TableView
extension NumberPopupViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.numbersList.count
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 50 //+ 30.0
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "NumbersTableViewCellId", for: indexPath) as! NumbersTableViewCell
let isLast = indexPath.row == (self.numbersList.count - 1)
cell.configureCell(number: numbersList[indexPath.row], isLast: isLast)
return cell
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
delegateBallon?.optionSelected(self.numbersList[indexPath.row])
self.dismiss(animated: true, completion: {})
// Logs
// let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
// print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? ""))
// print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
// print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
// print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? ""))
//
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! CouponBarcodeViewController
// vc.coupon = coupons[indexPath.row]
// self.navigationController?.pushViewController(vc, animated: true)
}
}
// Class for dynamic height table view
@objc public class DynamicSizeTableView: UITableView
{
override public func layoutSubviews() {
super.layoutSubviews()
if bounds.size != intrinsicContentSize {
invalidateIntrinsicContentSize()
}
}
// override public var intrinsicContentSize: CGSize {
// return contentSize
// }
override public var intrinsicContentSize: CGSize {
return CGSize(width: UIView.noIntrinsicMetric, height: contentSize.height + contentInset.top + contentInset.bottom)
}
}
//
// NumbersTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 15/7/22.
//
import UIKit
@objc public class NumbersTableViewCell: UITableViewCell {
@IBOutlet weak var numberLabel: UILabel!
@IBOutlet weak var borderView: UIView!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
// override func layoutSubviews() {
// super.layoutSubviews()
//
// //set the values for top,left,bottom,right margins
// let margins = UIEdgeInsets(top: 0, left: 0, bottom: 30, right: 0)
// contentView.frame = contentView.frame.inset(by: margins)
// }
func configureCell(number: String, isLast: Bool) {
numberLabel.text = number
if (isLast) {
borderView.isHidden = true
} else {
borderView.isHidden = false
}
}
}
//
// PopupInfoViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 16/10/24.
//
import UIKit
class PopupInfoViewController: UIViewController {
@IBOutlet weak var containerView: UIView!
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var headerCloseButton: UIButton!
@IBOutlet weak var infoLabel: UILabel!
@IBOutlet weak var submitButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Add arrow programmatically
let arrowSize = CGSize(width: 15, height: 7.5) // Width and height of the arrow
let arrowView = ArrowView(frame: CGRect(
x: (popupView.frame.width - arrowSize.width - 35),
y: popupView.frame.minY - arrowSize.height,
width: arrowSize.width,
height: arrowSize.height))
containerView.addSubview(arrowView)
// containerView.bringSubviewToFront(popupView)
// Add shadow
containerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.57).cgColor
containerView.layer.shadowOffset = CGSize(width: 0.0, height: 3.0)
containerView.layer.shadowOpacity = 1.0
containerView.layer.shadowRadius = 20.0
containerView.layer.masksToBounds = false
containerView.backgroundColor = .clear
popupView.backgroundColor = UIColor(rgb: 0xE6E6E6)
popupView.layer.cornerRadius = 14
headerLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
headerLabel.textColor = UIColor(rgb: 0x212121)
headerLabel.text = "SUPERMARKET DEALS"
headerCloseButton.setImage(UIImage(named: "ic_close_3.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
headerCloseButton.imageView?.layer.transform = CATransform3DMakeScale(1.3, 1.3, 1.3)
infoLabel.font = UIFont(name: "PeridotPE-Regular", size: 16.0)
infoLabel.textColor = UIColor(rgb: 0x212121)
infoLabel.text = "Δημιούργησε το δικό σου ενιαίο κουπόνι προσφορών, και εξαργύρωσέ το στα supermarket της επιλογής σου γρήγορα και εύκολα με ένα μόνο κωδικό κουπονιού!"
submitButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 14)
submitButton.setTitle("Τέλος", for: .normal)
submitButton.setTitleColor(UIColor(rgb: 0x212121), for: .normal)
submitButton.frame.size.width = submitButton.intrinsicContentSize.width
}
// MARK: - Actions
@IBAction func headerCloseButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
}
@IBAction func submitButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
}
}
class ArrowView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.backgroundColor = .clear
}
required init?(coder: NSCoder) {
super.init(coder: coder)
self.backgroundColor = .clear
}
override func draw(_ rect: CGRect) {
// Set up the context
guard let context = UIGraphicsGetCurrentContext() else { return }
// Set the arrow color (can adjust as needed)
context.setFillColor(UIColor(rgb: 0xE6E6E6).cgColor)
// Create the arrow's path (a triangle)
let path = UIBezierPath()
path.move(to: CGPoint(x: rect.width / 2, y: 0)) // Arrow top
path.addLine(to: CGPoint(x: rect.width, y: rect.height)) // Bottom right
path.addLine(to: CGPoint(x: 0, y: rect.height)) // Bottom left
path.close() // Close the triangle
// Fill the arrow shape
context.addPath(path.cgPath)
context.fillPath()
}
}
//
// PopupMerchantCategoriesViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 21/10/24.
//
import UIKit
// Define a protocol
protocol PopupMerchantCategoriesViewControllerDelegate: AnyObject {
func didTapMapButton()
func didTapEshopsButton()
}
class PopupMerchantCategoriesViewController: UIViewController {
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var mapButton: UIButton!
@IBOutlet weak var eshopsButton: UIButton!
public var headerText: String? = ""
// Delegate variable
weak var delegate: PopupMerchantCategoriesViewControllerDelegate?
override func viewDidLoad() {
super.viewDidLoad()
popupView.clipsToBounds = true
popupView.layer.cornerRadius = 16
popupView.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, right corner radius
closeButton.setImage(UIImage(named: "ic_close_3.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
closeButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
headerLabel.text = self.headerText
headerLabel.font = UIFont(name: "BTCosmo-Bold", size: 18)
headerLabel.textColor = UIColor(rgb: 0x000000)
headerLabel.isHidden = true
mapButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 17)
mapButton.setTitle("Δες τα καταστήματα στο χάρτη", for: .normal)
mapButton.setTitleColor(.white, for: .normal)
mapButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
mapButton.layer.cornerRadius = 16.0
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: 312, height: 55)
eshopsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 17)
eshopsButton.setTitle("Δες τα eshop", for: .normal)
eshopsButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal)
eshopsButton.layer.cornerRadius = 15.0
eshopsButton.frame = CGRect(x: 0.0, y: 0.0, width: 312, height: 55)
eshopsButton.backgroundColor = .clear
eshopsButton.layer.borderWidth = 2
eshopsButton.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
}
@objc private func mapButtonTapped() {
// Notify the delegate when map button is tapped
delegate?.didTapMapButton()
}
@objc private func eshopsButtonTapped() {
// Notify the delegate when eshops button is tapped
delegate?.didTapEshopsButton()
}
// MARK: - UIButton Actions
@IBAction func closeButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
}
@IBAction func mapButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
mapButtonTapped()
}
@IBAction func eshopsButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
eshopsButtonTapped()
}
}
//
// PopupMerchantsFooterTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/10/24.
//
import UIKit
class PopupMerchantsFooterTableViewCell: UITableViewCell {
@IBOutlet weak var footerLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
footerLabel.font = UIFont(name: "PeridotPE-Regular", size: 13)
footerLabel.textColor = UIColor(rgb: 0x000000)
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(title: String) {
footerLabel.text = title
}
}
//
// PopupSMMerchantsViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 17/10/24.
//
import UIKit
class PopupMerchantsViewController: UIViewController {
@IBOutlet weak var popupView: UIView!
@IBOutlet weak var headerLabel: UILabel!
@IBOutlet weak var closeButton: UIButton!
@IBOutlet weak var tableView: DynamicSizeMerchantsTableView!
public var availableShopsList:Array<swiftApi.ShopAvailabilityItemModel> = []
// public var coupon: swiftApi.CouponItemModel?
public var headerText: String? = "Βρες το προϊον στα supermarket"
public var buttonTitle: String? = "Βρες το"
public var buttonIcon: String?
public var footerText: String? = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
public var showEshops: Bool? = false
override func viewDidLoad() {
super.viewDidLoad()
if (showEshops == true) {
setupEshopsData()
}
tableView.delegate = self
tableView.dataSource = self
tableView.contentInset.top = 40
popupView.clipsToBounds = true
popupView.layer.cornerRadius = 16
popupView.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, right corner radius
closeButton.setImage(UIImage(named: "ic_close_3.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
closeButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
// self.tableView.reloadData()
self.tableView.invalidateIntrinsicContentSize()
self.headerLabel.text = self.headerText
headerLabel.font = UIFont(name: "BTCosmo-Bold", size: 18)
headerLabel.textColor = UIColor(rgb: 0x000000)
// setupFooterView()
}
// MARK: - Functions
func setupEshopsData() {
let tempShop1: swiftApi.ShopAvailabilityItemModel = swiftApi.ShopAvailabilityItemModel()
tempShop1._merchant_uuid = "ab"
tempShop1._product_url = "https://www.ab.gr"
availableShopsList.append(tempShop1)
let tempShop2: swiftApi.ShopAvailabilityItemModel = swiftApi.ShopAvailabilityItemModel()
tempShop2._merchant_uuid = "masoutis"
tempShop2._product_url = "https://www.masoutis.gr"
availableShopsList.append(tempShop2)
}
// private func setupFooterView() {
// // Create a footer view container
// let footerView = UIView()
// footerView.backgroundColor = .clear
//
// // Create a label for the footer
// let footerLabel = UILabel()
// footerLabel.text = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
// footerLabel.textAlignment = .center
// footerLabel.font = UIFont(name: "PeridotPE-Regular", size: 13)
// footerLabel.textColor = UIColor(rgb: 0x000000)
// footerLabel.numberOfLines = 0 // Allow for multiline text
//
// // Add label to the footer view
// footerView.addSubview(footerLabel)
// footerLabel.translatesAutoresizingMaskIntoConstraints = false
//
// // Set constraints for the label inside the footer view
// NSLayoutConstraint.activate([
// footerLabel.leadingAnchor.constraint(equalTo: footerView.leadingAnchor, constant: 16),
// footerLabel.trailingAnchor.constraint(equalTo: footerView.trailingAnchor, constant: -16),
// footerLabel.topAnchor.constraint(equalTo: footerView.topAnchor, constant: 10),
// footerLabel.bottomAnchor.constraint(equalTo: footerView.bottomAnchor, constant: -10)
// ])
//
// // Set the footer view's frame size to fit the content
// footerView.frame = CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50)
//
// // Assign the footer view to the table view's footer
// tableView.tableFooterView = footerView
// }
// MARK: - UIButton Actions
@IBAction func closeButtonAction(_ sender: Any) {
self.dismiss(animated: true, completion: {})
}
}
// MARK: - TableView
extension PopupMerchantsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return self.availableShopsList.count
} else if (section == 1) {
return 1
} else {
return 0
}
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if (indexPath.section == 0) {
return 56.0 + 32.0
// return UITableViewAutomaticDimension
} else if (indexPath.section == 1) {
return 50.0
} else {
return 0.0
}
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "MerchantTableViewCellId", for: indexPath) as! MerchantTableViewCell
cell.configureCell(shop: availableShopsList[indexPath.row], buttonTitle: self.buttonTitle ?? "Βρες το", iconImage: self.buttonIcon, showEshops: self.showEshops)
// Set the delegate to self
cell.delegate = self
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "PopupMerchantsFooterTableViewCellId", for: indexPath) as! PopupMerchantsFooterTableViewCell
cell.configureCell(title: self.footerText ?? "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία.")
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// Do nothing - tap handled with protocol
// print(" didSelectRowAt Button tapped in row \(indexPath.row)")
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0.0
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
return 0.0
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
}
// MARK: - MerchantTableViewCellDelegate
extension PopupMerchantsViewController: MerchantTableViewCellDelegate {
func didTapButton(in cell: MerchantTableViewCell) {
// Find the index path of the cell where the button was tapped
if let indexPath = tableView.indexPath(for: cell) {
let urlString = availableShopsList[indexPath.row]._product_url
if let url = URL(string: urlString){
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
}
}
}
}
// Class for dynamic height table view
@objc public class DynamicSizeMerchantsTableView: UITableView
{
override public func layoutSubviews() {
super.layoutSubviews()
if bounds.size != intrinsicContentSize {
invalidateIntrinsicContentSize()
}
}
// override public var intrinsicContentSize: CGSize {
// return contentSize
// }
override public var intrinsicContentSize: CGSize {
return CGSize(width: UIView.noIntrinsicMetric, height: contentSize.height + contentInset.top + contentInset.bottom + 30)
}
}
//
// ShareViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 15/7/22.
//
import UIKit
import SwiftEventBus
@objc public class ShareViewController: UIViewController, UITextFieldDelegate, UIPopoverControllerDelegate {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var mainViewBottom: NSLayoutConstraint!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var scrollContentView: UIView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var senderLabel: UILabel!
@IBOutlet weak var senderArrowImage: UIImageView!
@IBOutlet weak var senderButton: UIButton!
@IBOutlet weak var numberTextField: UITextField!
@IBOutlet weak var redeemButton: UIButton!
@IBOutlet weak var topBorderLine: UIImageView!
let uiscreen: CGRect = UIScreen.main.bounds
public var coupon: swiftApi.CouponItemModel?
public var isFromWallet: Bool? = false
var selectedNumber: String = ""
var numbersList: Array<String> = []
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
NotificationCenter.default.addObserver(self,
selector: #selector(self.keyboardNotification(notification:)),
name: UIResponder.keyboardWillChangeFrameNotification,
object: nil)
self.setupToHideKeyboardOnTapOnView()
numberTextField.delegate = self
getProfileRequest()
// Do any additional setup after loading the view.
setBackButton()
setNavigationTitle("Δώρισέ το")
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// scrollView.clipsToBounds = true
// scrollView.layer.cornerRadius = 30
// scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
//
// topBorderLine.translatesAutoresizingMaskIntoConstraints = false
// topBorderLine.image = image
// topBorderLine.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
// ])
// COUPONSET: desc, img_preview, name, terms
// COUPON: coupon, expiration, discount, status
let couponSetData: swiftApi.CouponSetItemModel? = coupon?.couponset_data
couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
couponImage.contentMode = .scaleAspectFill
couponImageHeight.constant = 222 // 255 //230 // 253 // self.uiscreen.height * 0.25
nameLabel.text = couponSetData?.name ?? ""
// descriptionLabel.text = couponSetData?.short_description ?? ""
descriptionLabel.text = "Επίλεξε το κινητό από το οποίο θα γίνει η αποστολή και συμπλήρωσε το COSMOTE κινητό που θα λάβει το δώρο."
senderLabel.text = "Αποστολέας"
senderLabel.textColor = UIColor(red: 0.52, green: 0.52, blue: 0.52, alpha: 1.00)
senderArrowImage.image = UIImage(named: "ic_down_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
senderButton.addTarget(self, action: #selector(self.numbersPopupTapped(_:)), for: .touchUpInside)
numberTextField.font = UIFont(name: "PeridotPE-Regular", size: 16)
numberTextField.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
numberTextField.attributedPlaceholder = NSAttributedString(string: "Καταχώρηση τηλεφώνου", attributes: [NSAttributedString.Key.foregroundColor: UIColor(red: 0.52, green: 0.52, blue: 0.52, alpha: 1.00)])
numberTextField.keyboardType = .asciiCapableNumberPad
numberTextField.addDoneButtonOnKeyboard()
redeemButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 17)
redeemButton.setTitle("Αποστολή με SMS", for: .normal)
redeemButton.setTitleColor(.white, for: .normal)
redeemButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
redeemButton.layer.cornerRadius = 16.0
redeemButton.frame = CGRect(x: 0.0, y: 0.0, width: redeemButton.intrinsicContentSize.width, height: 50)
redeemButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
// // iPad
// redeemButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
// } else {
// // not iPad (iPhone, mac, tv, carPlay, unspecified)
// redeemButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "CouponShareScreen")
self.navigationController?.hideHairline()
}
deinit {
NotificationCenter.default.removeObserver(self)
}
@objc func keyboardNotification(notification: NSNotification) {
guard let userInfo = notification.userInfo else { return }
let endFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue
let endFrameY = endFrame?.origin.y ?? 0
let duration:TimeInterval = (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber)?.doubleValue ?? 0
let animationCurveRawNSN = userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber
let animationCurveRaw = animationCurveRawNSN?.uintValue ?? UIView.AnimationOptions.curveEaseInOut.rawValue
let animationCurve:UIView.AnimationOptions = UIView.AnimationOptions(rawValue: animationCurveRaw)
if endFrameY >= UIScreen.main.bounds.size.height {
self.mainViewBottom?.constant = 0.0
} else {
self.mainViewBottom?.constant = endFrame?.size.height ?? 0.0
}
UIView.animate(
withDuration: duration,
delay: TimeInterval(0),
options: animationCurve,
animations: { self.view.layoutIfNeeded() },
completion: nil)
}
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func showSendDialog() -> Void {
let alert = UIAlertController(title: "Δώρισέ το", message: "Είσαι σίγουρος /-ή ότι θέλεις να κάνεις δώρο το κουπόνι σου;", preferredStyle: .alert)
let cancelButton = UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
})
// cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(UIAlertAction(title: "Αποστολή", style: .default, handler: { action in
switch action.style{
case .default:
let couponSetData: swiftApi.CouponSetItemModel? = self.coupon?.couponset_data
let couponName = couponSetData?.name ?? ""
swiftApi().logTrackersEvent("click", ("ShareCoupon:" + couponName))
self.cosmoteCouponSharingRequest()
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showDialogWithBack(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
self.navigationController?.popViewController(animated: true)
// self.dismiss(animated: true, completion: {})
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showSuccessDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
// if (self.isFromWallet == true) {
self.popBack(3)
// } else {
// print("default")
// }
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
// MARK: - API Calls
func getProfileRequest() {
swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in
print("========= getProfileRequest ERROR =========")
})
}
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
self.numbersList = profileData?._msisdnList ?? []
print("========= getProfileRequest SUCCESSSS =========")
}
} else {
print("========= getProfileRequest ERROR =========")
}
}
func cosmoteCouponSharingRequest() {
self.showSpinner()
swiftApi().cosmoteCouponSharingAsync(coupon: coupon?.coupon ?? "", sender: selectedNumber, receiver: numberTextField.text ?? "", couponSharingCallback, failureCallback: {errorCode in
self.hideSpinner()
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
})
}
func couponSharingCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
self.hideSpinner()
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
self.showSuccessDialog("Συγχαρητήρια!","Μόλις έκανες δώρο ένα κουπόνι!")
if let tempCoupon = self.coupon {
swiftApi().removeCouponItem(couponArg: tempCoupon)
SwiftEventBus.post("coupons_fetched")
}
// swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
// func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
// if (couponsData != nil) {
// DispatchQueue.main.async {
// SwiftEventBus.post("coupons_fetched")
// }
// } else {
// }
// }
} else if (response?.getStatus == 4) {
self.showDialog("Αποτυχία", response?.getMsg ?? "")
} else {
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
} else {
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
// MARK: - Actions
@IBAction func redeemButtomAction(_ sender: Any) {
if (selectedNumber == "" || numberTextField.text == "") {
self.showDialog("Αποτυχία αποστολής","Παρακαλούμε συμπλήρωσε σωστά τα πεδία.")
} else {
self.showSendDialog()
}
}
}
// MARK: NumbersPopup
extension ShareViewController: NumbersPopupDelegate {
@objc func numbersPopupTapped(_ sender: Any) {
if (self.numbersList.count == 0) {
self.showDialogWithBack("Δώρισέ το","Για την αποστολή του δώρου σου χρειάζεται να έχεις κινητό COSMOTE.")
} else {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// self.storyboard?
let pp = storyboard.instantiateViewController(withIdentifier: "NumberPopupViewController") as! SwiftWarplyFramework.NumberPopupViewController
pp.InitWithController(controller: self,
numbersList: self.numbersList,
sender: sender,
delegate: self,
headerText: "Αποστολέας")
}
}
func presentedPopup() {
// Code for when popup is presented
}
func dismissedPopup() {
// Code for when popup is dismissed
}
func optionSelected(_ option: String) {
// Code for when option is selected
selectedNumber = option
senderLabel.text = option
senderLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
}
}
//
// SharingHistoryViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 18/7/22.
//
import UIKit
class SharingHistoryViewController: AnalysisChildViewController {
var loading: Bool = false
var items: Array<swiftApi.SharingCouponModel> = Array()
var allItems: Array<swiftApi.SharingCouponModel> = Array()
var showMore = false
// TODO: remove this when configuring model
let hasMessage = false
// lifecycle
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.delegate = self
self.tableView.dataSource = self
// Add shadow
self.tableView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.tableView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.tableView.layer.shadowOpacity = 1.0
self.tableView.layer.shadowRadius = 1.0
self.refreshControl = UIRefreshControl()
self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
handleRefresh(self.refreshControl!)
}
// mvp
@objc func load() {
if (loading) {
return;
}
showLoading()
swiftApi().getSharingHistoryAsync(isMarketHistory: false, getSharingHistoryCallback: responseCallback, failureCallback: {errorCode in })
}
private func showLoading() {
loading = true
if (self.refreshControl!.isRefreshing) {
return;
}
self.refreshControl!.beginRefreshing()
}
private func showError() {
}
private func showContent() {
loading = false
self.refreshControl!.endRefreshing()
}
// private
func responseCallback (_ data: Array<swiftApi.SharingCouponModel>?) -> Void {
self.items = data!
self.allItems = data!
self.showMore = (self.items.count > 3)
if (self.showMore == true) {
self.items = Array(self.items[0...2])
}
showContent()
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
@objc func handleRefresh(_ refreshControl: UIRefreshControl) {
self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
}
// MARK: - Table view data source
override func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1;
}
if (self.showMore == true) {
return 4
}
return items.count
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// if (indexPath.section == 0) {
// return hasMessage ? 380.0 : (items.count > 0 ? 280 : 380)
// }
//
// return 140.0
return UITableView.automaticDimension
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// header
if (indexPath.section == 0) {
if (hasMessage) {
return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderMessageViewCell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisHeaderViewCell
cell.configureCell(isEmpty: items.count == 0, isMarket: false)
return cell
}
if ((self.showMore == true) && (indexPath.row == 3)) {
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisMoreViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisMoreViewCell
return cell
}
let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! SwiftWarplyFramework.AnalysisItemViewCell
cell.configureCell(item: items[indexPath.row])
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
return
}
if ((self.showMore == true) && (indexPath.row == 3)) {
self.items = self.allItems
self.showMore = false
self.tableView.reloadData()
}
}
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 50))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 1, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMinYCorner] // Top left, bottom right corner radius
let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: viewInner.frame.width - 40, height: 20))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 20)
titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.text = "Αναλυτικά"
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
viewInner.addSubview(titleLabel)
return view
} else {
return nil
}
} else {
return nil
}
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (self.items.count > 0) {
return 50.0
} else {
return 0.0
}
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
if (section == 1 && self.items.count > 0) {
return 20.0
} else {
return 0.0
}
}
override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 1) {
if (self.items.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 30))
let viewBorder = UIView(frame: CGRect(x: 10, y: 0, width: view.frame.width-20, height: view.frame.height))
viewBorder.backgroundColor = .white
// viewBorder.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
viewBorder.layer.cornerRadius = 16.5
viewBorder.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
let viewInner = UIView(frame: CGRect(x: 1, y: 0, width: viewBorder.frame.width-2, height: viewBorder.frame.height-1))
viewInner.backgroundColor = .white
viewInner.layer.cornerRadius = 16.5
viewInner.layer.maskedCorners = [ .layerMinXMaxYCorner, .layerMaxXMaxYCorner] // bottom left, bottom right corner radius
view.addSubview(viewBorder)
viewBorder.addSubview(viewInner)
return view
} else {
return nil
}
} else {
return nil
}
}
}
//
// SpinnerViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 14/11/22.
//
import UIKit
@objc public class SpinnerViewController: UIViewController {
var spinner = UIActivityIndicatorView()
public override func loadView() {
if #available(iOS 13.0, *) {
spinner = UIActivityIndicatorView(style: .large)
spinner.color = .white
} else {
spinner = UIActivityIndicatorView(style: .whiteLarge)
}
view = UIView()
view.backgroundColor = UIColor(white: 0, alpha: 0.7)
spinner.translatesAutoresizingMaskIntoConstraints = false
spinner.startAnimating()
view.addSubview(spinner)
spinner.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
spinner.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
}
public override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}
//
// StepsViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 10/6/22.
//
import UIKit
@objc public class StepsViewController: UIViewController {
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
//
// TelcoViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 16/7/22.
//
import UIKit
import SwiftEventBus
@objc public class TelcoViewController: UIViewController, UIPopoverControllerDelegate {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var scrollContentView: UIView!
@IBOutlet weak var heroImage: UIImageView!
@IBOutlet weak var heroImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
@IBOutlet weak var activateButton: UIButton!
@IBOutlet weak var valueView: UIView!
@IBOutlet weak var valueLabel: UILabel!
@IBOutlet weak var giftTypeLabel: UILabel!
@IBOutlet weak var giftDurationView: UIView!
@IBOutlet weak var giftDurationLabel: UILabel!
@IBOutlet weak var borderLineView: UIView!
@IBOutlet weak var moreButton: UIButton!
@IBOutlet weak var moreTextView: UITextView!
@IBOutlet weak var moreTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var topBorderLine: UIImageView!
let uiscreen: CGRect = UIScreen.main.bounds
public var ccms: swiftApi.LoyaltyContextualOfferModel?
public var campaign: swiftApi.CampaignItemModel?
var selectedNumber: String = ""
public var numbersList: Array<String> = []
var moreVisible: Bool = false;
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
// Do any additional setup after loading the view.
// getProfileRequest()
numbersList = ccms?._eligibleAssets ?? []
setBackButton("ic_close_3")
setNavigationTitle(ccms?._titleOffer ?? "")
backgroundImage.image = UIImage(named: "coupons_scrollview_white", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
//
// topBorderLine.translatesAutoresizingMaskIntoConstraints = false
// topBorderLine.image = image
// topBorderLine.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
// ])
// scrollView.clipsToBounds = true
// scrollView.layer.cornerRadius = 30
// scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
heroImage.load(link: ccms?._imageOfferUrl ?? "", placeholder: UIImage(), cache: URLCache())
heroImage.contentMode = .scaleAspectFill
heroImageHeight.constant = 222 // 255 //230 // 253 // self.uiscreen.height * 0.25
nameLabel.text = ccms?._description ?? ""
// descriptionLabel.text = ccms?._subtitle ?? ""
valueView.gradientBorder(width: 1, colors: [UIColor(rgb: 0x07A2D1), UIColor(rgb: 0x73CA34)], startPoint: .unitCoordinate(.bottomLeft), endPoint: .unitCoordinate(.topRight), andRoundCornersWithRadius: 35)
valueLabel.text = ccms?._giftValue ?? ""
giftTypeLabel.text = ccms?._giftType ?? ""
giftDurationLabel.text = ccms?._duration ?? ""
giftDurationView.frame = CGRect(x: 0.0, y: 0.0, width: giftDurationLabel.intrinsicContentSize.width + 20, height: giftDurationView.frame.height)
giftDurationView.gradientBorder(width: 2, colors: [UIColor(rgb: 0x65DD6B), UIColor(rgb: 0x0D81B8)], startPoint: .unitCoordinate(.left), endPoint: .unitCoordinate(.right), andRoundCornersWithRadius: 35)
borderLineView.applyGradient(colours: [UIColor(rgb: 0x0AA3CD), UIColor(rgb: 0x6ECA43)], gradient: GradientOrientation.horizontal, cornerRadius: 0.0)
activateButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 17)
activateButton.setTitle("Ενεργοποίηση", for: .normal)
activateButton.setTitleColor(.white, for: .normal)
activateButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
activateButton.layer.cornerRadius = 16.0
activateButton.frame = CGRect(x: 0.0, y: 0.0, width: activateButton.intrinsicContentSize.width, height: 50)
activateButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
// // iPad
// activateButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
// } else {
// // not iPad (iPhone, mac, tv, carPlay, unspecified)
// activateButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
moreButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
moreButton.setTitle("Δες Περισσότερα", for: .normal)
moreButton.setTitleColor(UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00), for: .normal)
moreButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
moreButton.semanticContentAttribute = .forceRightToLeft
moreButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
moreButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
moreButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
moreButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
// let htmlText = ccms?._description ?? ""
// moreTextView.attributedText = htmlText.htmlToAttributedString
moreTextView.text = ccms?._termsAndConditions ?? ""
moreTextView.font = UIFont(name: "PeridotPE-Regular", size: 14)
moreTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
moreTextView.textAlignment = .left
moreTextView.isScrollEnabled = false
toggleMore()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "TelcoScreen")
self.navigationController?.hideHairline()
}
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func toggleMore() {
if (moreVisible) {
moreTextView.isHidden = false
let targetSize = CGSize(width: moreTextView.frame.width, height: CGFloat(MAXFLOAT))
moreTextViewHeight.constant = moreTextView.sizeThatFits(targetSize).height
moreButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
} else {
moreTextView.isHidden = true
moreTextViewHeight.constant = CGFloat(0)
moreButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
}
}
func showConfirmDialog() -> Void {
let alert = UIAlertController(title: "Ενεργοποίηση υπηρεσίας", message: "Θέλετε να γίνει ενεργοποίηση στο Κινητό μου;", preferredStyle: .alert)
let cancelButton = UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
})
// cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(UIAlertAction(title: "Ενεργοποίηση", style: .default, handler: { action in
switch action.style{
case .default:
swiftApi().logTrackersEvent("click", ("ActivateTelco:" + (self.ccms?._sessionId ?? "")))
self.submitOrderRequest()
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
// MARK: - API CALLS
func getProfileRequest() {
swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
}
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
self.numbersList = profileData?._msisdnList ?? []
}
} else {
}
}
func submitOrderRequest() {
showSpinner()
swiftApi().submitOrderAsync(campaign_session_uuid: (campaign?.session_uuid ?? ""), user_msisdn: self.selectedNumber, businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""),
OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""),
submitOrderCallback, failureCallback: {errorCode in
self.hideSpinner()
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
})
}
func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
self.hideSpinner()
if (response != nil) {
DispatchQueue.main.async {
if (response?.getStatus == 1) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "true")
SwiftEventBus.post("firebase", sender: firebaseEvent)
let ccmsEnabled = swiftApi.WarplyCCMSEnabledModel()
ccmsEnabled._isActivated = true
SwiftEventBus.post("ccms_enabled", sender: ccmsEnabled)
self.showDialog("Το αίτημά σου ολοκληρώθηκε επιτυχώς!","Θα ενημερωθείς άμεσα για την ενεργοποίηση του πακέτου σου.")
// self.postEventRequest()
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
} else {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "loyalty_offer_activated"
firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
firebaseEvent.setParameter = ("type", "gift")
firebaseEvent.setParameter = ("successful", "false")
SwiftEventBus.post("firebase", sender: firebaseEvent)
self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
}
}
// func postEventRequest() {
// swiftApi().postEventAsync(Session_ID: (campaign?.session_uuid ?? ""), OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), msisdn: self.selectedNumber, UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), postEventCallback)
// }
// func postEventCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
// if (response != nil) {
// DispatchQueue.main.async {
// if (response?.getStatus == 1) {
// } else {
// }
// }
// } else {
// }
// }
// MARK: - Actions
@IBAction func activateButtomAction(_ sender: Any) {
self.numbersPopupTapped(sender)
}
@IBAction func moreButtonAction(_ sender: Any) {
moreVisible = !moreVisible
toggleMore()
}
}
// MARK: NumbersPopup
extension TelcoViewController: NumbersPopupDelegate {
@objc func numbersPopupTapped(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let pp = storyboard.instantiateViewController(withIdentifier: "NumberPopupViewController") as! SwiftWarplyFramework.NumberPopupViewController
pp.InitWithController(controller: self,
numbersList: self.numbersList,
sender: sender,
delegate: self,
headerText: "Επιλογή σύνδεσης")
}
func presentedPopup() {
// Code for when popup is presented
}
func dismissedPopup() {
// Code for when popup is dismissed
}
func optionSelected(_ option: String) {
// Code for when option is selected
self.selectedNumber = option
DispatchQueue.main.async {
self.showConfirmDialog()
}
}
}
//
// UnifiedCouponBCFooterTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 7/4/23.
//
import UIKit
//import RSBarcodes_Swift
import AVFoundation
// import SwiftEventBus
@objc public class UnifiedCouponBCFooterTableViewCell: UITableViewCell, UITextViewDelegate {
@IBOutlet weak var termsButton: UIButton!
@IBOutlet weak var termsTextView: UnselectableTappableTextView!
@IBOutlet weak var termsTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var mapButton: UIButton!
@IBOutlet weak var mapButtonHeight: NSLayoutConstraint!
@IBOutlet weak var mapButtonTopSpace: NSLayoutConstraint!
@IBOutlet weak var cancelButton: UIButton!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
termsTextView.delegate = self
mapButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 17)
mapButton.setTitle("Δες τα supermarket", for: .normal)
mapButton.setTitleColor(UIColor(red: 1.00, green: 1.00, blue: 1.00, alpha: 1.00), for: .normal)
mapButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
mapButton.layer.cornerRadius = 15.0
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: 260, height: 55)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 50)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
cancelButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 17)
cancelButton.setTitle("Ακυρωση κουπονιού", for: .normal) // Ακύρωση ενιαίου κουπονιού
cancelButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal)
cancelButton.layer.cornerRadius = 15.0
cancelButton.frame = CGRect(x: 0.0, y: 0.0, width: 260, height: 55)
// cancelButton.frame = CGRect(x: 0.0, y: 0.0, width: cancelButton.intrinsicContentSize.width, height: 50)
// cancelButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
cancelButton.backgroundColor = .clear
cancelButton.layer.borderWidth = 2
cancelButton.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
// mapButton.isHidden = true
// mapButtonHeight.constant = 0
// mapButtonTopSpace.constant = 0
// let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// for merchant in merchantList {
// if (merchant._uuid == couponSetData?.merchant_uuid) {
// if (merchant._show_map == true) {
// mapButton.setTitle("Δες τα καταστήματα", for: .normal)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 1, left: 16, bottom: 0, right: 16)
// mapButton.isHidden = false
// mapBtnVisible = true
// eshopBtnVisible = false
// mapButtonHeight.constant = 44
// mapButtonTopSpace.constant = 10
// } else if (merchant._eshop == true) {
// mapButton.setTitle("Δες το eshop", for: .normal)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 1, left: 16, bottom: 0, right: 16)
// mapButton.isHidden = false
// mapBtnVisible = false
// eshopBtnVisible = true
// mapButtonHeight.constant = 44
// mapButtonTopSpace.constant = 10
// } else {
// mapButton.isHidden = true
// mapBtnVisible = false
// eshopBtnVisible = false
// mapButtonHeight.constant = 0
// mapButtonTopSpace.constant = 0
// }
// eshopWebsite = merchant._website
// break;
// }
// }
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
// // iPad
// mapButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
// } else {
// // not iPad (iPhone, mac, tv, carPlay, unspecified)
// mapButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
termsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
termsButton.setTitle("Όροι χρήσης", for: .normal)
termsButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
termsButton.semanticContentAttribute = .forceRightToLeft
termsButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
termsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
termsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
termsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
let termsText = "1. Το εκπτωτικό κουπόνι ισχύει έως την ημερομηνία που αναφέρεται παραπάνω.\n2. To εκπτωτικό κουπόνι αφορά στα ενεργά κουπόνια προσφορών όπως αναφέρονται παραπάνω.\n3. Το εκπτωτικό κουπόνι μπορεί να χρησιμοποιηθεί σε μια μόνο συναλλαγή.\n4. Εάν δεν γίνει χρήση ενός επιμέρους κουπονιού προσφοράς από το εκπτωτικό κουπόνι, το κουπόνι προσφοράς επιστρέφει στο καλάθι στην ενότητα COSMOTE SUPERMARKET DEALS."
termsTextView.attributedText = NSAttributedString(string: termsText)
termsTextView.font = UIFont(name: "PeridotPE-Regular", size: 14)
termsTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
termsTextView.textAlignment = .left
termsTextView.isScrollEnabled = false
termsTextView.isUserInteractionEnabled = true
termsTextView.isEditable = false
termsTextView.isSelectable = true
termsTextView.dataDetectorTypes = [.link]
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UIApplication.shared.open(URL)
// Disable `.preview` by 3D Touch and other interactions
return false
}
func configureCell(termsVisible: Bool) {
toggleTerms(termsVisible: termsVisible)
}
func toggleTerms(termsVisible: Bool) {
if (termsVisible) {
termsTextView.isHidden = false
let targetSize = CGSize(width: termsTextView.frame.width, height: CGFloat(MAXFLOAT))
termsTextViewHeight.constant = termsTextView.sizeThatFits(targetSize).height
termsButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
} else {
termsTextView.isHidden = true
termsTextViewHeight.constant = CGFloat(0)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
}
}
}
//
// UnifiedCouponBCHeaderTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 7/4/23.
//
import UIKit
import RSBarcodes_Swift
import AVFoundation
// import SwiftEventBus
@objc public class UnifiedCouponBCHeaderTableViewCell: UITableViewCell, UITextViewDelegate {
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var couponImageHeight: NSLayoutConstraint!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var merchantDescrTextView: UnselectableTappableTextView!
@IBOutlet weak var merchantDescrTextViewHeight: NSLayoutConstraint!
@IBOutlet weak var merchantDescrTextViewTopSpace: NSLayoutConstraint!
@IBOutlet weak var couponView: UIView!
@IBOutlet weak var couponNumberLabel: CopyableLabel!
@IBOutlet weak var barcodeImage: UIImageView!
@IBOutlet weak var barcodeImageHeight: NSLayoutConstraint!
@IBOutlet weak var barcodeLabel: UILabel!
@IBOutlet weak var barcodeLabelHeight: NSLayoutConstraint!
@IBOutlet weak var showBarcodeButton: UIButton!
@IBOutlet weak var expirationLabel: UILabel!
@IBOutlet weak var expirationLabelHeight: NSLayoutConstraint!
@IBOutlet weak var expirationLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var borderViewHeight: NSLayoutConstraint!
@IBOutlet weak var borderView2Height: NSLayoutConstraint!
@IBOutlet weak var border1TopSpace: NSLayoutConstraint!
@IBOutlet weak var barcodeImageTopSpace: NSLayoutConstraint!
@IBOutlet weak var barcodeLabelTopSpace: NSLayoutConstraint!
@IBOutlet weak var border2TopSpace: NSLayoutConstraint!
@IBOutlet weak var showBarcodeButtonHeight: NSLayoutConstraint!
@IBOutlet weak var showBarcodeButtonTopSpace: NSLayoutConstraint!
@IBOutlet weak var showCouponsButton: UIButton!
@IBOutlet weak var topExpirationView: UIView!
@IBOutlet weak var topExpirationLabel: UILabel!
@IBOutlet weak var barcodeTitleLabel: UILabel!
let uiscreen: CGRect = UIScreen.main.bounds
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
merchantDescrTextView.delegate = self
// COUPONSET: desc, img_preview, name, terms
// COUPON: coupon, expiration, discount, status
// let couponSetData: swiftApi.CouponSetItemModel? = coupon?.couponset_data
// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
couponImage.image = UIImage(named: "market_bg", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponImage.contentMode = .scaleAspectFill
couponImageHeight.constant = 222 // 255 //230 // 253 // self.uiscreen.height * 0.25
nameLabel.text = "Εκπτωτικό κουπόνι COSMOTE SUPERMARKET DEALS!"
topExpirationView.backgroundColor = UIColor(rgb: 0xB8E0EF)
topExpirationView.layer.cornerRadius = 13.0
topExpirationLabel.font = UIFont(name: "PeridotPE-Bold", size: 13)
topExpirationLabel.textColor = UIColor(rgb: 0x004B87)
// Hide bottom expirationLabel ==>
expirationLabel.isHidden = true
expirationLabelHeight.constant = CGFloat(0)
expirationLabelTopSpace.constant = CGFloat(0)
// ===
barcodeTitleLabel.text = "barcode κουπονιού"
barcodeTitleLabel.font = UIFont(name: "PeridotPE-Bold", size: 16)
barcodeTitleLabel.textColor = UIColor(rgb: 0x212121)
discriptionLabel.text = "Χρησιμοποίησε τον παρακάτω κωδικό και πάρε έκπτωση στα ενεργά κουπόνια προσφορών."
merchantDescrTextView.text = ""
merchantDescrTextViewTopSpace.constant = CGFloat(0)
merchantDescrTextViewHeight.constant = CGFloat(0)
merchantDescrTextView.isHidden = true
// let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// for merchant in merchantList {
// if (merchant._uuid == couponSetData?.merchant_uuid) {
// let htmlMerchDescrText = merchant._body
//
// if (htmlMerchDescrText != "") {
// merchantDescrTextView.attributedText = htmlMerchDescrText.htmlToAttributedString
// merchantDescrTextView.font = UIFont(name: "PFSquareSansPro-Regular", size: 17)
// merchantDescrTextView.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
// merchantDescrTextView.textAlignment = .center
// merchantDescrTextView.isScrollEnabled = false
// merchantDescrTextView.isUserInteractionEnabled = true
// merchantDescrTextView.isEditable = false
// merchantDescrTextView.isSelectable = true
// merchantDescrTextView.dataDetectorTypes = [.link]
//
// merchantDescrTextView.isHidden = false
// merchantDescrTextViewTopSpace.constant = CGFloat(15)
// let targetSize = CGSize(width: merchantDescrTextView.frame.width, height: CGFloat(MAXFLOAT))
// merchantDescrTextViewHeight.constant = merchantDescrTextView.sizeThatFits(targetSize).height
// }
//
// break;
// }
// }
showBarcodeButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
showBarcodeButton.setTitle("Εμφάνιση barcode", for: .normal)
showBarcodeButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
showBarcodeButton.semanticContentAttribute = .forceRightToLeft
showBarcodeButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
showBarcodeButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
showBarcodeButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
showBarcodeButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
showCouponsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
showCouponsButton.setTitle("Εμφάνιση προσφορών", for: .normal)
showCouponsButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
showCouponsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
showCouponsButton.semanticContentAttribute = .forceRightToLeft
showCouponsButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
showCouponsButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0);
showCouponsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: -10, bottom: 0, right: 10);
showCouponsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
showCouponsButton.frame = CGRect(x: 0.0, y: 0.0, width: showCouponsButton.intrinsicContentSize.width+10, height: 40)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(coupon: swiftApi.UnifiedCouponModel?, couponsVisible: Bool) {
couponView.layer.cornerRadius = 16
// couponNumberLabel.text = ((coupon?._code != 0) ? String(coupon?._code ?? 0) : "")
couponNumberLabel.text = coupon?._barcode ?? ""
couponView.frame = CGRect(x: 0.0, y: 0.0, width: couponView.intrinsicContentSize.width, height: 55)
// let activeCoupons = coupon?._coupons.filter { $0.status == 1 }
// let activeCouponsDiscount = (activeCoupons?.reduce(0) { $0 + (Float($1.discount ?? "0") ?? 0) }) ?? 0
// // discriptionLabel.text = "Χρησιμοποίησε τον παρακάτω κωδικό και πάρε έκπτωση στα ενεργά κουπόνια προσφορών αξίας " + String(activeCouponsDiscount) + "€."
// // ========
// let discrNormalText1 = "Χρησιμοποίησε τον παρακάτω κωδικό και πάρε έκπτωση στα ενεργά κουπόνια προσφορών αξίας "
// let discrBoldText = String(activeCouponsDiscount) + "€."
// let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 16) ?? UIFont.systemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
// let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 16) ?? UIFont.boldSystemFont(ofSize: 15), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
// let sumAttributedString = NSMutableAttributedString(string:discrNormalText1, attributes:attrRegular)
// let sumBoldString = NSMutableAttributedString(string: discrBoldText, attributes:attrBold)
// sumAttributedString.append(sumBoldString)
// discriptionLabel.attributedText = sumAttributedString
// // ========
// let barcodeString = constructBarcode(coupon: coupon) ?? ""
let barcodeString = coupon?._barcode ?? ""
barcodeLabel.text = barcodeString
// Uncomment if Barcode Section is active again
if let barcodeUIImage = RSUnifiedCodeGenerator.shared.generateCode(barcodeString, machineReadableCodeObjectType: AVMetadataObject.ObjectType.ean13.rawValue, targetSize: CGSize(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.1)) {
barcodeImage.image = barcodeUIImage
barcodeImageHeight.constant = self.uiscreen.height * 0.1
showBarcodeButton.isHidden = false
showBarcodeButtonHeight.constant = 50
showBarcodeButtonTopSpace.constant = 10
} else {
barcodeImageHeight.constant = 0
showBarcodeButton.isHidden = true
showBarcodeButtonHeight.constant = 0
showBarcodeButtonTopSpace.constant = 0
borderViewHeight.constant = CGFloat(0)
borderView2Height.constant = CGFloat(0)
border1TopSpace.constant = CGFloat(0) // 20
barcodeImageTopSpace.constant = CGFloat(0) // 10
barcodeLabelTopSpace.constant = CGFloat(0) // 10
border2TopSpace.constant = CGFloat(0) // 15
}
// ===
// === Hide Barcode Section
// barcodeImage.isHidden = true
// barcodeImageHeight.constant = CGFloat(0)
barcodeLabel.isHidden = true
barcodeLabelHeight.constant = CGFloat(0)
//
// borderViewHeight.constant = CGFloat(0)
// borderView2Height.constant = CGFloat(0)
//
// border1TopSpace.constant = CGFloat(0) // 20
// barcodeImageTopSpace.constant = CGFloat(0) // 10
barcodeLabelTopSpace.constant = CGFloat(0) // 10
// border2TopSpace.constant = CGFloat(0) // 15
//
showBarcodeButton.isHidden = true
showBarcodeButtonHeight.constant = 0
showBarcodeButtonTopSpace.constant = 0
// ===
// if let earliestExpiration = coupon?._coupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
if let latestExpiration = coupon?._coupons.max(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
expirationLabel.text = "Το κουπόνι ισχύει έως " + (latestExpiration.expiration ?? "")
topExpirationLabel.text = "Ισχύει έως " + (latestExpiration.expiration ?? "")
topExpirationLabel.frame.size.width = topExpirationLabel.intrinsicContentSize.width
} else {
expirationLabel.text = ""
topExpirationLabel.text = ""
}
toggleCoupons(couponsVisible: couponsVisible)
}
func constructBarcode(coupon: swiftApi.UnifiedCouponModel?) -> String? {
// EAN 13 barcode construction
// let couponData = coupon?.couponset_data
let couponString = coupon?._barcode ?? ""
if (!couponString.isEmpty) {
var checkDigit = 0;
var result = 0;
var fixedCouponCode = couponString;
if (fixedCouponCode.count < 12) {
let loops = 12 - fixedCouponCode.count;
var zerosStr = "";
for i in 0 ..< loops {
zerosStr += "0"
}
// fixedCouponCode = zerosStr + fixedCouponCode;
fixedCouponCode = fixedCouponCode + zerosStr;
}
var multiplier = 3;
for idx in (0 ... (fixedCouponCode.count - 1)).reversed() {
let curChar = fixedCouponCode[idx];
result += (Int(curChar) ?? 0) * multiplier;
multiplier = multiplier == 3 ? 1 : 3;
}
checkDigit = 10 - (result % 10);
let barcodeStr = fixedCouponCode + String(checkDigit);
return barcodeStr;
}
return ""
}
public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
UIApplication.shared.open(URL)
// Disable `.preview` by 3D Touch and other interactions
return false
}
func toggleBarcode(barcodeVisible: Bool) {
if (barcodeVisible) {
barcodeImage.isHidden = false
if (barcodeImage.image == nil) {
barcodeImageHeight.constant = CGFloat(0)
} else {
barcodeImageHeight.constant = self.uiscreen.height * 0.1
}
barcodeLabel.isHidden = false
let targetSize = CGSize(width: barcodeLabel.frame.width, height: CGFloat(MAXFLOAT))
barcodeLabelHeight.constant = barcodeLabel.sizeThatFits(targetSize).height
borderViewHeight.constant = CGFloat(1)
borderView2Height.constant = CGFloat(1)
border1TopSpace.constant = CGFloat(20) // 20
barcodeImageTopSpace.constant = CGFloat(10) // 10
barcodeLabelTopSpace.constant = CGFloat(10) // 10
border2TopSpace.constant = CGFloat(15) // 15
showBarcodeButton.setTitle("Απόκρυψη barcode", for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
} else {
barcodeImage.isHidden = true
barcodeImageHeight.constant = CGFloat(0)
barcodeLabel.isHidden = true
barcodeLabelHeight.constant = CGFloat(0)
borderViewHeight.constant = CGFloat(0)
borderView2Height.constant = CGFloat(0)
border1TopSpace.constant = CGFloat(0) // 20
barcodeImageTopSpace.constant = CGFloat(0) // 10
barcodeLabelTopSpace.constant = CGFloat(0) // 10
border2TopSpace.constant = CGFloat(0) // 15
showBarcodeButton.setTitle("Εμφάνιση barcode", for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
}
}
func toggleCoupons(couponsVisible: Bool) {
if (couponsVisible) {
showCouponsButton.setTitle("Απόκρυψη προσφορών", for: .normal)
showCouponsButton.setImage(UIImage(named: "ic_up_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
showCouponsButton.frame = CGRect(x: 0.0, y: 0.0, width: showCouponsButton.intrinsicContentSize.width+10, height: 40)
} else {
showCouponsButton.setTitle("Εμφάνιση προσφορών", for: .normal)
showCouponsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
showCouponsButton.frame = CGRect(x: 0.0, y: 0.0, width: showCouponsButton.intrinsicContentSize.width+10, height: 40)
}
}
}
//
// UnifiedCouponBarcodeViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 6/4/23.
//
import UIKit
import RSBarcodes_Swift
import AVFoundation
import SwiftEventBus
@objc public class UnifiedCouponBarcodeViewController: UIViewController {
@IBOutlet weak var mainView: UIView!
@IBOutlet weak var tableView: UITableView!
let uiscreen: CGRect = UIScreen.main.bounds
var termsVisible: Bool = false;
var barcodeVisible: Bool = false;
var couponsVisible: Bool = false;
var mapBtnVisible: Bool = false;
var eshopBtnVisible: Bool = false;
var eshopWebsite: String = "";
public var coupon: swiftApi.UnifiedCouponModel?
public var isFromWallet: Bool? = false
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
tableView.delegate = self
tableView.dataSource = self
// Do any additional setup after loading the view.
setBackButton()
setNavigationTitle("Εκπτωτικό κουπόνι")
// Logs
// print("Coupon: " + (coupon?.coupon ?? ""))
// print("Coupon Name: " + (couponSetData?.name ?? ""))
// print("Coupon Description: " + (couponSetData?.short_description ?? ""))
// print("Coupon Expiration: " + (coupon?.expiration ?? ""))
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "UnifiedCouponScreen")
self.navigationController?.hideHairline()
}
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
func showConfirmDialog() -> Void {
let alert = UIAlertController(title: "Ακύρωση Κουπονιού", message: "Είσαι σίγουρος ότι θέλεις να ακυρώσεις το κουπόνι σου;", preferredStyle: .alert)
let cancelButton = UIAlertAction(title: "Όχι", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
})
// cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(UIAlertAction(title: "Ναι", style: .default, handler: { action in
switch action.style{
case .default:
self.cancelUnifiedCouponRequest()
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showSuccessDialog() -> Void {
let alert = UIAlertController(title: "Ακύρωση Κουπονιού", message: "Το ενιαίο κουπόνι σου ακυρώθηκε επιτυχώς. Βρες τα μεμονωμένα κουπόνια στο My Rewards.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
SwiftEventBus.post("refresh_unified_coupons")
self.navigationController?.popViewController(animated: true)
// self.dismiss(animated: true, completion: {})
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func cancelUnifiedCouponRequest () -> Void {
self.showSpinner()
var tranIdFound = "";
for coupon in self.coupon?._coupons ?? [] {
if ((coupon.transaction_uuid != nil) && coupon.transaction_uuid != "") {
tranIdFound = coupon.transaction_uuid ?? "";
break;
}
}
if (tranIdFound != "") {
swiftApi().cancelUnifiedCouponAsync(transactionId: tranIdFound, self.cancelUnifiedCouponCallback, failureCallback: { errorCode in
self.hideSpinner()
})
} else {
self.hideSpinner()
}
}
func cancelUnifiedCouponCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void {
self.hideSpinner()
if (responseData != nil) {
DispatchQueue.main.async {
if (responseData?.getStatus == 1) {
self.showSuccessDialog()
swiftApi().getUnifiedCouponsDeals { unifiedCoupons in
} failureCallback: { errorCode in
}
}
}
}
}
// MARK: - Actions
@IBAction func showCouponsButtonAction(_ sender: Any) {
couponsVisible = !couponsVisible
// self.tableView.reloadSections(IndexSet(0..<2), with: .none)
self.tableView.reloadData()
}
@IBAction func showBarcodeAction(_ sender: Any) {
barcodeVisible = !barcodeVisible
// self.tableView.reloadSections(IndexSet(integer: 0), with: .none)
self.tableView.reloadData()
}
@IBAction func termsButtonAction(_ sender: Any) {
termsVisible = !termsVisible
// self.tableView.reloadSections(IndexSet(integer: 2), with: .none)
self.tableView.reloadData()
}
@IBAction func mapButtonAction(_ sender: Any) {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if let popupVC = storyboard.instantiateViewController(withIdentifier: "PopupMerchantCategoriesViewController") as? SwiftWarplyFramework.PopupMerchantCategoriesViewController {
popupVC.modalPresentationStyle = .overCurrentContext
popupVC.modalTransitionStyle = .crossDissolve
// popupVC.coupon = coupon
popupVC.delegate = self
self.present(popupVC, animated: true, completion: nil)
}
// =======
// swiftApi().logTrackersEvent("click", "SeeShops")
//
// let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
//// vc.couponSet = coupon?.couponset_data
// vc.isMarket = true
// self.navigationController?.pushViewController(vc, animated: true)
// =======
// if (mapBtnVisible == true) {
// swiftApi().logTrackersEvent("click", "SeeShops")
// let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
// vc.couponSet = coupon?.couponset_data
// self.navigationController?.pushViewController(vc, animated: true)
// } else if (eshopBtnVisible == true) {
// if (eshopWebsite != "") {
// guard let websiteUrl = URL(string: eshopWebsite) else {
// print("Error creating URL")
// return
// }
// // check if link can be opened.
// guard UIApplication.shared.canOpenURL(websiteUrl) else {
// return
// }
// swiftApi().logTrackersEvent("click", "SeeShopWebsite")
// UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
// }
// }
}
@IBAction func cancelButtonAction(_ sender: Any) {
self.showConfirmDialog()
}
}
// MARK: - TableView
extension UnifiedCouponBarcodeViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 3
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return 1
} else if (section == 1) {
if (couponsVisible == true) {
return self.coupon?._coupons.count ?? 0
} else {
return 0
}
} else if (section == 2) {
return 1
} else {
return 0
}
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if (indexPath.section == 0) {
return UITableView.automaticDimension
} else if (indexPath.section == 1) {
if (couponsVisible == true) {
return 130.0 + 8.0
} else {
return 0.0
}
} else if (indexPath.section == 2) {
return UITableView.automaticDimension
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponBCHeaderTableViewCell", for: indexPath) as! UnifiedCouponBCHeaderTableViewCell
cell.configureCell(coupon: self.coupon, couponsVisible: couponsVisible)
return cell
} else if (indexPath.section == 1) {
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
cell.configureCell(coupon: (self.coupon?._coupons[indexPath.row])!, isMarket: true)
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponBCFooterTableViewCell", for: indexPath) as! UnifiedCouponBCFooterTableViewCell
cell.configureCell(termsVisible: termsVisible)
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row])
// Logs
// let couponSetData: swiftApi.CouponSetItemModel? = self.coupon?._coupons[indexPath.row].couponset_data
// print("Coupon clicked: " + (self.coupon?._coupons[indexPath.row].coupon ?? ""))
// print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
// print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
// print("Coupon Expiration clicked: " + (self.coupon?._coupons[indexPath.row].expiration ?? ""))
if (indexPath.section == 1) {
swiftApi().logTrackersEvent("click", ("Coupon:" + (self.coupon?._coupons[indexPath.row].name ?? "")))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController
vc.coupon = self.coupon?._coupons[indexPath.row]
vc.isMarket = true
self.navigationController?.pushViewController(vc, animated: true)
}
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (couponsVisible == true) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 12))
view.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
return view
} else {
return nil
}
} else {
return nil
}
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (couponsVisible == true) {
return 12.0
} else {
return 0.0
}
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (couponsVisible == true) {
return 2.0
} else {
return 0.0
}
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (couponsVisible == true) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 2))
view.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
return view
} else {
return nil
}
} else {
return nil
}
}
}
// MARK: - MerchantTableViewCellDelegate
extension UnifiedCouponBarcodeViewController: PopupMerchantCategoriesViewControllerDelegate {
func didTapMapButton() {
swiftApi().logTrackersEvent("click", "SeeShops")
let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
// vc.couponSet = coupon?.couponset_data
vc.isMarket = true
self.navigationController?.pushViewController(vc, animated: true)
}
func didTapEshopsButton() {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if let popupVC = storyboard.instantiateViewController(withIdentifier: "PopupMerchantsViewController") as? SwiftWarplyFramework.PopupMerchantsViewController {
popupVC.modalPresentationStyle = .overCurrentContext
popupVC.modalTransitionStyle = .crossDissolve
popupVC.availableShopsList = []
popupVC.headerText = "Δες τα eshop"
popupVC.buttonTitle = "Δες το eshop"
// popupVC.buttonIcon = "shopping_cart"
popupVC.footerText = "Η διαθεσιμότητα ενδέχεται να διαφέρει ανάλογα με την τοποθεσία."
popupVC.showEshops = true
self.present(popupVC, animated: true, completion: nil)
}
}
}
//
// UnifiedCouponsTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 3/4/23.
//
import Foundation
import UIKit
@objc public class UnifiedCouponsTableViewCell: UITableViewCell {
@IBOutlet weak var couponBgImage: UIImageView!
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var borderView: UIView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var expirationLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
couponBgImage.image = UIImage(named: "coupon_bg_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponImage.image = UIImage(named: "coupon_market_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
borderView.addDashedBorderVertical(color: UIColor(red: 0.62, green: 0.62, blue: 0.61, alpha: 1.00), width: 1.0, height: 110.0)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 8, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
}
func configureCell(coupon: swiftApi.UnifiedCouponModel) {
let activeCoupons = coupon._coupons.filter { $0.status == 1 }
let activeCouponsCount = activeCoupons.count
// let activeCouponsDiscount = activeCoupons.reduce(0) { $0 + (Float($1.discount ?? "0") ?? 0) }
// var activeCouponsCount:Int = 0
// for coupon in coupon._coupons {
// if (coupon.status == 1) {
// activeCouponsCount += 1
// }
// }
nameLabel.text = "COSMOTE SUPERMARKET DEALS"
discriptionLabel.text =
"έχεις " + String(activeCouponsCount) +
(
activeCouponsCount == 1 ? " ενεργό κουπόνι" : " ενεργά κουπόνια"
)
// + " αξίας " + String(activeCouponsDiscount) + "€"
// if let earliestExpiration = activeCoupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
if let latestExpiration = activeCoupons.max(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
expirationLabel.text = "Ισχύει έως " + (latestExpiration.expiration ?? "")
} else {
expirationLabel.text = ""
}
}
}
//
// UnifiedCouponsViewController.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 20/10/23.
//
import Foundation
import UIKit
import SwiftEventBus
@objc public class UnifiedCouponsViewController: UIViewController {
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var emptyView: UIView!
@IBOutlet weak var emptyViewHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabel: UILabel!
@IBOutlet weak var submitButton: UIButton!
@IBOutlet weak var submitButtonHeight: NSLayoutConstraint!
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
public var smCoupons:Array<swiftApi.CouponItemModel> = []
public var smCouponsSelected:Array<swiftApi.CouponItemModel> = []
public var isFromCampaignVC: Bool = false
// A reference to the Select All image view for later use
var circleImageView: UIImageView!
// Track the selection state
var isSelectAllActive: Bool = false
let spinner = SpinnerViewController()
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
SwiftEventBus.onBackgroundThread(self, name: "unified_coupons_fetched") { result in
DispatchQueue.main.async {
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
// self.tableView.reloadData()
// Reload the Unified Coupons section only
self.tableView.reloadSections(IndexSet(integer: 0), with: .automatic)
if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
}
}
SwiftEventBus.onBackgroundThread(self, name: "sm_coupons_fetched") { result in
DispatchQueue.main.async {
self.smCoupons = swiftApi().getSMCouponList()
// self.tableView.reloadData()
// Reload the SM Coupons section only
self.tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
self.handleSubmitButtonVisible()
if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
}
}
setBackButton()
setNavigationTitle("SUPERMARKET DEALS")
// Setup the info button with an action
setNavBarRightInfoButton() {
// This closure is the action that will be executed when the info button is tapped
self.presentInfoPopup()
}
// backgroundImage.image = UIImage(named: "coupons_scrollview_dark", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
tableView.delegate = self
tableView.dataSource = self
// tableView.clipsToBounds = true
// tableView.layer.cornerRadius = 30
// tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// tableView.contentInset.top = 30
tableView.contentInset.bottom = 115
emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!"
submitButton.setTitle("Συνδύασε τις προσφορές σε ένα κουπόνι", for: .normal)
submitButton.setTitleColor(.white, for: .normal)
submitButton.layer.cornerRadius = 16.0
// submitButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
submitButton.backgroundColor = UIColor(rgb: 0x9D9D9C)
submitButton.isEnabled = false
// submitButton.frame = CGRect(x: 0.0, y: 0.0, width: submitButton.intrinsicContentSize.width, height: 50)
// submitButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
// Fix width for ipad
if UIDevice.current.userInterfaceIdiom == .pad {
// iPad
submitButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 18)
// submitButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
} else {
// not iPad (iPhone, mac, tv, carPlay, unspecified)
submitButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 16)
// submitButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
}
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "ActiveUnifiedCouponsScreen")
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.smCoupons = swiftApi().getSMCouponList()
self.tableView.reloadData()
self.handleSubmitButtonVisible()
if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
self.navigationController?.hideHairline()
if (self.isFromCampaignVC == true) {
swiftApi().getUnifiedCouponsDeals { unifiedCoupons in
} failureCallback: { errorCode in
}
}
}
// MARK: - Functions
func showSpinner() {
// add the spinner view controller
// addChild(spinner)
// spinner.view.frame = view.frame
// view.addSubview(spinner.view)
// spinner.didMove(toParent: self)
addChild(spinner)
spinner.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)
self.view.addSubview(spinner.view)
spinner.didMove(toParent: self)
}
func hideSpinner() {
// remove the spinner view controller
spinner.willMove(toParent: nil)
spinner.view.removeFromSuperview()
spinner.removeFromParent()
}
// Button action for "select all"
@objc func selectAllTapped() {
// Toggle the selection state
isSelectAllActive.toggle()
// Update the image based on the new state
if (isSelectAllActive) {
circleImageView.image = UIImage(named: "circle_checked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Selected image
smCouponsSelected = smCoupons
} else {
circleImageView.image = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Unselected image
smCouponsSelected = []
}
handleSubmitButtonUI()
// Reload the SM Coupons section only
tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
}
func handleSelectCouponAction(indexPath: IndexPath) {
let currentCoupon = self.smCoupons[indexPath.row]
let isCouponSelected = self.smCouponsSelected.contains { $0.coupon == currentCoupon.coupon }
if (isCouponSelected) {
self.smCouponsSelected = self.smCouponsSelected.filter({ return $0.coupon != currentCoupon.coupon })
if (isSelectAllActive) {
isSelectAllActive = false
// Reload the SM Coupons section only
tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
} else {
tableView.reloadRows(at: [indexPath], with: .automatic) // Reload the specific row
}
} else {
self.smCouponsSelected.append(currentCoupon)
if (self.smCouponsSelected.count == self.smCoupons.count) {
isSelectAllActive = true
// Reload the SM Coupons section only
tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
} else {
tableView.reloadRows(at: [indexPath], with: .automatic) // Reload the specific row
}
}
handleSubmitButtonUI()
}
private func presentInfoPopup() {
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
if let popupVC = storyboard.instantiateViewController(withIdentifier: "PopupInfoViewController") as? SwiftWarplyFramework.PopupInfoViewController {
popupVC.modalPresentationStyle = .overCurrentContext
popupVC.modalTransitionStyle = .crossDissolve
self.present(popupVC, animated: true, completion: nil)
}
}
func handleSubmitButtonUI() {
if (self.smCouponsSelected.count > 0) {
submitButton.backgroundColor = UIColor(rgb: 0x0EA600)
submitButton.isEnabled = true
} else {
submitButton.backgroundColor = UIColor(rgb: 0x9D9D9C)
submitButton.isEnabled = false
}
}
func handleSubmitButtonVisible() {
if (self.smCoupons.count > 0) {
submitButton.isHidden = false
submitButtonHeight.constant = 55
} else {
submitButton.isEnabled = false
submitButton.isHidden = true
submitButtonHeight.constant = 0
}
}
func showSuccessDialog() -> Void {
let alert = UIAlertController(title: "Δημιουργία Κουπονιού", message: "Το ενιαίο κουπόνι σου δημιουργήθηκε επιτυχώς.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
// self.navigationController?.popViewController(animated: true)
// self.dismiss(animated: true, completion: {})
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showFailureDialog() -> Void {
let alert = UIAlertController(title: "Αποτυχία Δημιουργίας Κουπονιού", message: "Το ενιαίο κουπόνι σου δεν δημιουργήθηκε. Προσπάθησε ξανά.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
// MARK: - Actions
@IBAction func submitButtonAction(_ sender: Any) {
// let smCouponsString = self.smCouponsSelected.map { $0.coupon ?? "" }.joined(separator: ",")
// swiftApi().logTrackersEvent("click", ("UnifySMCoupons:" + (smCouponsString)))
self.showSpinner()
let smCouponCodes = self.smCouponsSelected.map { $0.coupon ?? "" }
swiftApi().createUnifiedCouponAsync(couponCodes: smCouponCodes) { responseData in
self.hideSpinner()
if (responseData != nil) {
DispatchQueue.main.async {
if (responseData?.getStatus == 1) {
self.smCouponsSelected = []
self.circleImageView.image = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Unselected image
self.handleSubmitButtonUI()
// Reload the SM Coupons section only
self.tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
self.showSuccessDialog()
}
}
}
} failureCallback: { errorCode in
self.hideSpinner()
self.showFailureDialog()
}
}
}
// MARK: - TableView
extension UnifiedCouponsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 2
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if (section == 0) {
return self.unifiedCoupons.count
} else if (section == 1) {
return self.smCoupons.count
} else {
return 0
}
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
if (indexPath.section == 0) {
return 130.0 + 8.0
// return UITableViewAutomaticDimension
} else if (indexPath.section == 1) {
return 130.0 + 8.0
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponsTableViewCellId", for: indexPath) as! UnifiedCouponsTableViewCell
cell.configureCell(coupon: unifiedCoupons[indexPath.row])
return cell
} else {
let currentCoupon = self.smCoupons[indexPath.row]
let isCouponSelected = self.smCouponsSelected.contains { $0.coupon == currentCoupon.coupon }
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
cell.configureCell(coupon: smCoupons[indexPath.row], isSMCoupon: true)
cell.showSelectButton(isSelectViewVisible: true, isSelected: isCouponSelected) {
self.handleSelectCouponAction(indexPath: indexPath)
}
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
let couponBarcode = unifiedCoupons[indexPath.row]._barcode
swiftApi().logTrackersEvent("click", ("UnifiedCoupon:" + couponBarcode))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponBarcodeViewController") as! SwiftWarplyFramework.UnifiedCouponBarcodeViewController
vc.coupon = unifiedCoupons[indexPath.row]
vc.isFromWallet = true
self.navigationController?.pushViewController(vc, animated: true)
} else if (indexPath.section == 1) {
let couponSetData: swiftApi.CouponSetItemModel? = smCoupons[indexPath.row].couponset_data
let couponName = couponSetData?.name ?? ""
swiftApi().logTrackersEvent("click", ("Coupon:" + couponName))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController
vc.coupon = smCoupons[indexPath.row]
vc.isFromWallet = true
vc.isSMCoupon = true
self.navigationController?.pushViewController(vc, animated: true)
} else {
// Do nothing
}
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0) {
if (self.unifiedCoupons.count > 0) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 70))
view.backgroundColor = .clear
let titleLabel = UILabel(frame: CGRect(x: 16, y: 25, width: view.frame.width - 32, height: 25))
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
// titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
titleLabel.textColor = UIColor(rgb: 0x212121)
titleLabel.text = "Ενιαία κουπόνια"
view.addSubview(titleLabel)
return view
} else {
return nil
}
} else if (section == 1) {
if (self.smCoupons.count > 0) {
let headerView = UIView()
headerView.backgroundColor = .clear
// Create the title label (Κουπόνια)
let titleLabel = UILabel()
titleLabel.text = "Κουπόνια"
titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
// Create the select-all label (Επιλογή όλων)
let selectAllLabel = UILabel()
selectAllLabel.text = "Επιλογή όλων"
selectAllLabel.font = UIFont(name: "PeridotPE-SBold", size: 17)
// Create a UIImageView for the circle image
circleImageView = UIImageView()
// let circleImage = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// Update the image based on the new state
if (isSelectAllActive) {
circleImageView.image = UIImage(named: "circle_checked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Selected image
} else {
circleImageView.image = UIImage(named: "circle_unchecked", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) // Unselected image
}
// circleImageView.image = circleImage
circleImageView.contentMode = .scaleAspectFit
circleImageView.translatesAutoresizingMaskIntoConstraints = false
// Set size for the imageView
circleImageView.widthAnchor.constraint(equalToConstant: 30).isActive = true
circleImageView.heightAnchor.constraint(equalToConstant: 30).isActive = true
// Create a transparent UIButton on top of the image
let selectAllButton = UIButton(type: .custom)
selectAllButton.backgroundColor = .clear // Keep it transparent
selectAllButton.addTarget(self, action: #selector(selectAllTapped), for: .touchUpInside)
selectAllButton.translatesAutoresizingMaskIntoConstraints = false
// Set the button size to match the image size
selectAllButton.widthAnchor.constraint(equalToConstant: 30).isActive = true
selectAllButton.heightAnchor.constraint(equalToConstant: 30).isActive = true
// Create a horizontal stack view to align the title, label, and image
let mainStackView = UIStackView(arrangedSubviews: [titleLabel, selectAllLabel, circleImageView])
mainStackView.axis = .horizontal
mainStackView.alignment = .center // Centers them vertically
mainStackView.spacing = 10
// Add the stack view to the header view
headerView.addSubview(mainStackView)
headerView.addSubview(selectAllButton) // Add the button separately on top of the image view
// Set constraints for stack view
mainStackView.translatesAutoresizingMaskIntoConstraints = false
mainStackView.leadingAnchor.constraint(equalTo: headerView.leadingAnchor, constant: 16).isActive = true
mainStackView.trailingAnchor.constraint(equalTo: headerView.trailingAnchor, constant: -16).isActive = true
mainStackView.topAnchor.constraint(equalTo: headerView.topAnchor, constant: 8).isActive = true
mainStackView.bottomAnchor.constraint(equalTo: headerView.bottomAnchor, constant: -8).isActive = true
// Set button position on top of the imageView
selectAllButton.centerXAnchor.constraint(equalTo: circleImageView.centerXAnchor).isActive = true
selectAllButton.centerYAnchor.constraint(equalTo: circleImageView.centerYAnchor).isActive = true
return headerView
} else {
return nil
}
} else {
return nil
}
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
if (self.unifiedCoupons.count > 0) {
return 70.0
} else {
return 0.0
}
} else if (section == 1) {
if (self.smCoupons.count > 0) {
return 70.0
} else {
return 0.0
}
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
return 0.0
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
}
//
// WalletActiveCouponCollectionViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 8/5/24.
//
import UIKit
@objc public class WalletActiveCouponCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var badgeViewParent: UIView!
@IBOutlet weak var badgeView: UIView!
@IBOutlet weak var badgeImage: UIImageView!
@IBOutlet weak var badgeLabel: UILabel!
@IBOutlet weak var badgeCountView: UIView!
@IBOutlet weak var badgeCountLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
// Badge Banner
// badgeViewParent.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
badgeViewParent.backgroundColor = .white
badgeViewParent.layer.cornerRadius = 16.0
badgeViewParent.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
badgeViewParent.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
badgeViewParent.layer.shadowOpacity = 1.0
badgeViewParent.layer.shadowRadius = 2.0
// badgeView.backgroundColor = UIColor(red: 0.46, green: 0.75, blue: 0.45, alpha: 0.05)
badgeView.backgroundColor = .white
badgeView.layer.cornerRadius = 16.0
badgeCountView.layer.cornerRadius = 4.0
badgeCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
}
func configureCell(badgeId: String, badgeCount: Int) {
if (badgeId == "dfy") {
badgeImage.image = UIImage(named: "wallet_banner_dfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
badgeLabel.text = "DEALS FOR YOU"
badgeCountView.isHidden = false
} else if (badgeId == "sm") {
badgeImage.image = UIImage(named: "wallet_banner_sm", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
badgeLabel.text = "SUPERMARKET DEALS"
badgeCountView.isHidden = false
} else if (badgeId == "gfy") {
badgeImage.image = UIImage(named: "wallet_banner_gfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
badgeLabel.text = "FREE COUPONS"
badgeCountView.isHidden = false
} else if (badgeId == "box") {
badgeImage.image = UIImage(named: "wallet_banner_box", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
badgeLabel.text = "BOX"
badgeCountView.isHidden = true
}
badgeCountLabel.text = String(badgeCount)
}
}
//
// WalletActiveCouponsScrollTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 8/5/24.
//
import UIKit
import SwiftEventBus
@objc public class WalletActiveCouponsScrollTableViewCell: UITableViewCell {
@IBOutlet weak var sectionTitleLabel: UILabel!
@IBOutlet weak var historyButtonImage: UIImageView!
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var dotLeft: UIView!
@IBOutlet weak var dotLeftWidth: NSLayoutConstraint!
@IBOutlet weak var dotLeftHeight: NSLayoutConstraint!
@IBOutlet weak var dotRight: UIView!
@IBOutlet weak var dotRightWidth: NSLayoutConstraint!
@IBOutlet weak var dotRightHeight: NSLayoutConstraint!
var parent: UIViewController?
public var activeCouponBadges:Array<swiftApi.WalletActiveCouponBadgeModel> = []
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
// Section Header
sectionTitleLabel.text = "Κουπόνια"
historyButtonImage.image = UIImage(named: "wallet_history_blue", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
historyButtonImage.image = historyButtonImage.image?.withRenderingMode(.alwaysTemplate)
historyButtonImage.tintColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
collectionView.contentInset.left = 17
collectionView.contentInset.right = 17
dotLeftWidth.constant = 12
dotLeftHeight.constant = 12
dotLeft.layer.cornerRadius = 6
dotRightWidth.constant = 8
dotRightHeight.constant = 8
dotRight.layer.cornerRadius = 4
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(dfyCount: Int, smCount: Int, gfyCount: Int, boxCount: Int) {
sortBadges(dfyCount, smCount, gfyCount, boxCount)
}
func sortBadges(_ dfyCount: Int, _ smCount: Int, _ gfyCount: Int, _ boxCount: Int) {
// deals weight 3
// sm weight 2
// free weight 1
// box weight 0
let DFYBadge = swiftApi.WalletActiveCouponBadgeModel()
DFYBadge._id = "dfy"
DFYBadge._count = dfyCount
DFYBadge._weight = 3
let SMBadge = swiftApi.WalletActiveCouponBadgeModel()
SMBadge._id = "sm"
SMBadge._count = smCount
SMBadge._weight = 2
let GFYBadge = swiftApi.WalletActiveCouponBadgeModel()
GFYBadge._id = "gfy"
GFYBadge._count = gfyCount
GFYBadge._weight = 1
let BOXBadge = swiftApi.WalletActiveCouponBadgeModel()
BOXBadge._id = "box"
BOXBadge._count = boxCount
BOXBadge._weight = 0
let tempActiveCouponBadges:Array<swiftApi.WalletActiveCouponBadgeModel> = [DFYBadge, SMBadge, GFYBadge, BOXBadge]
// var tempActiveCouponBadges:Array<swiftApi.WalletActiveCouponBadgeModel> = []
// tempActiveCouponBadges.append(DFYBadge)
// tempActiveCouponBadges.append(SMBadge)
// tempActiveCouponBadges.append(GFYBadge)
// tempActiveCouponBadges.append(BOXBadge)
let sortedActiveCouponBadges = tempActiveCouponBadges.sorted {
($0._weight) > ($1._weight)
}
.sorted {
($0._count) > ($1._count)
}
activeCouponBadges = sortedActiveCouponBadges
collectionView.reloadData();
}
}
extension WalletActiveCouponsScrollTableViewCell: UIScrollViewDelegate {
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
let contentOffsetX = scrollView.contentOffset.x
if contentOffsetX >= (scrollView.contentSize.width - scrollView.bounds.width) - 20 {
dotLeftWidth.constant = 8
dotLeftHeight.constant = 8
dotLeft.layer.cornerRadius = 4
dotRightWidth.constant = 12
dotRightHeight.constant = 12
dotRight.layer.cornerRadius = 6
} else {
dotLeftWidth.constant = 12
dotLeftHeight.constant = 12
dotLeft.layer.cornerRadius = 6
dotRightWidth.constant = 8
dotRightHeight.constant = 8
dotRight.layer.cornerRadius = 4
}
}
}
extension WalletActiveCouponsScrollTableViewCell: UICollectionViewDataSource,UICollectionViewDelegate {
public func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return activeCouponBadges.count
}
public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let badgeId = activeCouponBadges[indexPath.row]._id;
let badgeCount = activeCouponBadges[indexPath.row]._count;
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "WalletActiveCouponCollectionViewCellId", for: indexPath) as! WalletActiveCouponCollectionViewCell
cell.configureCell(badgeId: badgeId, badgeCount: badgeCount)
return cell;
}
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let badgeId = activeCouponBadges[indexPath.row]._id
if (badgeId == "dfy") {
print("Active DFY coupon banner Tapped!")
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveDealsBanner"))
let couponDetails = swiftApi.ActiveDFYCouponEventModel()
couponDetails._isPressed = true
SwiftEventBus.post("dfy_coupon_details", sender: couponDetails)
} else if (badgeId == "sm") {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_market_active_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveMarketBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController
let vc = storyboard.instantiateViewController(withIdentifier: "MarketPassViewController") as! SwiftWarplyFramework.MarketPassViewController
parent?.navigationController?.pushViewController(vc, animated: true)
} else if (badgeId == "gfy") {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_gifts_for_you_active_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveLoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: SwiftWarplyFramework.CouponsViewController.self))
if let vc = storyboard.instantiateViewController(withIdentifier: "CouponsViewController") as? SwiftWarplyFramework.CouponsViewController{
parent?.navigationController?.pushViewController(vc,animated: true)
}
} else if (badgeId == "box") {
print("Active BOX coupon banner Tapped!")
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_box_active_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveBoxBanner"))
// SwiftEventBus.post("box_coupon_details")
let couponDetails = swiftApi.ActiveBoxCouponEventModel()
couponDetails._isPressed = true
SwiftEventBus.post("box_coupon_details", sender: couponDetails)
}
}
// Distance Between Item Cells
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 5
}
// Cell Margin
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0)
}
}
//
// WalletActiveCouponsTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 23/10/23.
//
import UIKit
@objc public class WalletActiveCouponsTableViewCell: UITableViewCell {
@IBOutlet weak var sectionTitleLabel: UILabel!
@IBOutlet weak var historyButtonImage: UIImageView!
@IBOutlet weak var dfyViewParent: UIView!
@IBOutlet weak var dfyView: UIView!
@IBOutlet weak var dfyImage: UIImageView!
@IBOutlet weak var dfyLabel: UILabel!
@IBOutlet weak var dfyCountView: UIView!
@IBOutlet weak var dfyCountLabel: UILabel!
@IBOutlet weak var smView: UIView!
@IBOutlet weak var smImage: UIImageView!
@IBOutlet weak var smLabel: UILabel!
@IBOutlet weak var smCountView: UIView!
@IBOutlet weak var smCountLabel: UILabel!
@IBOutlet weak var gfyView: UIView!
@IBOutlet weak var gfyImage: UIImageView!
@IBOutlet weak var gfyLabel: UILabel!
@IBOutlet weak var gfyCountView: UIView!
@IBOutlet weak var gfyCountLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
// Section Header
sectionTitleLabel.text = "Κουπόνια"
historyButtonImage.image = UIImage(named: "wallet_history_blue", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
historyButtonImage.image = historyButtonImage.image?.withRenderingMode(.alwaysTemplate)
historyButtonImage.tintColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
// DFY Banner
// dfyViewParent.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
dfyViewParent.backgroundColor = .white
dfyViewParent.layer.cornerRadius = 16.0
dfyViewParent.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
dfyViewParent.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
dfyViewParent.layer.shadowOpacity = 1.0
dfyViewParent.layer.shadowRadius = 2.0
// dfyView.backgroundColor = UIColor(red: 0.46, green: 0.75, blue: 0.45, alpha: 0.05)
dfyView.backgroundColor = .white
dfyView.layer.cornerRadius = 16.0
dfyImage.image = UIImage(named: "wallet_banner_dfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyLabel.text = "DEALS FOR YOU"
dfyCountView.layer.cornerRadius = 4.0
dfyCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
// SM Banner
// smView.backgroundColor = UIColor(red: 1.00, green: 0.99, blue: 0.97, alpha: 1.00)
smView.backgroundColor = .white
smView.layer.cornerRadius = 16.0
smView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
smView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
smView.layer.shadowOpacity = 1.0
smView.layer.shadowRadius = 2.0
smImage.image = UIImage(named: "wallet_banner_sm", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
smLabel.text = "SUPERMARKET DEALS"
smCountView.layer.cornerRadius = 4.0
smCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
// GFY Banner
// gfyView.backgroundColor = UIColor(red: 0.96, green: 0.97, blue: 0.98, alpha: 1.00)
gfyView.backgroundColor = .white
gfyView.layer.cornerRadius = 16.0
gfyView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
gfyView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
gfyView.layer.shadowOpacity = 1.0
gfyView.layer.shadowRadius = 2.0
gfyImage.image = UIImage(named: "wallet_banner_gfy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// gfyLabel.text = "GIFTS FOR YOU"
// gfyLabel.text = "Free coupons"
gfyLabel.text = "FREE COUPONS"
gfyCountView.layer.cornerRadius = 4.0
gfyCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(dfyCount: Int, smCount: Int, gfyCount: Int) {
dfyCountLabel.text = String(dfyCount)
smCountLabel.text = String(smCount)
gfyCountLabel.text = String(gfyCount)
}
}
//
// WalletBadgesTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 5/4/23.
//
import UIKit
@objc public class WalletBadgesTableViewCell: UITableViewCell {
@IBOutlet weak var rewardsLabel: UILabel!
@IBOutlet weak var badgeLinesImage: UIImageView!
@IBOutlet weak var sumBadgeImage: UIImageView!
@IBOutlet weak var sumBadgeLabel: UILabel!
@IBOutlet weak var dfyBadgeImage: UIImageView!
@IBOutlet weak var dfyBadgeLabel: UILabel!
@IBOutlet weak var couponBadgeImage: UIImageView!
@IBOutlet weak var couponBadgeLabel: UILabel!
@IBOutlet weak var marketBadgeImage: UIImageView!
@IBOutlet weak var marketBadgeLabel: UILabel!
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
sumBadgeImage.image = UIImage(named: "wallet_summary", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
badgeLinesImage.image = UIImage(named: "wallet_badge_lines", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
rewardsLabel.text = "COSMOTE Επιβράβευση"
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(totalCouponValue: Float, totalCouponDiscount: Float, unifiedCouponsDiscount: Float) {
let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
sumBadgeLabel.text = sumRewardsString + "€"
// ===
if (totalCouponValue == 0.0) {
dfyBadgeImage.image = UIImage(named: "wallet_dfy_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBadgeLabel.isHidden = true
} else {
dfyBadgeImage.image = UIImage(named: "wallet_dfy_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBadgeLabel.isHidden = false
}
let totalCouponValueFixed = Float(round(100 * totalCouponValue) / 100)
var totalCouponValueString = "0"
totalCouponValueString = String(format: "%.2f", totalCouponValueFixed).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
dfyBadgeLabel.text = totalCouponValueString + "€"
// ===
if (loyaltyBadge._couponCount == 0) {
couponBadgeImage.image = UIImage(named: "wallet_coupons_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeLabel.isHidden = true
} else {
couponBadgeImage.image = UIImage(named: "wallet_coupons_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeLabel.isHidden = false
}
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
couponBadgeLabel.text = totalCouponDiscountString + "€"
// ===
let marketDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
var marketDiscountString = "0"
marketDiscountString = String(format: "%.2f", marketDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
self.marketBadgeLabel.text = marketDiscountString + "€"
if (unifiedCouponsDiscount == 0.0) {
marketBadgeImage.image = UIImage(named: "wallet_market_empty", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeLabel.isHidden = true
} else {
marketBadgeImage.image = UIImage(named: "wallet_market", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeLabel.isHidden = false
}
}
}
//
// WalletBannersTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/4/23.
//
import UIKit
@objc public class WalletBannersTableViewCell: UITableViewCell {
@IBOutlet weak var sumBannerArrowImage: UIImageView!
@IBOutlet weak var sumBannerInnerView: UIView!
@IBOutlet weak var sumBadgeImage: UIImageView!
@IBOutlet weak var sumBadgeLabel: UILabel!
@IBOutlet weak var sumBannerLabel: UILabel!
@IBOutlet weak var dfyBannerView: UIView!
@IBOutlet weak var dfyBannerHeight: NSLayoutConstraint!
@IBOutlet weak var dfyBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var dfyBannerInnerView: UIView!
@IBOutlet weak var dfyBadgeImage: UIImageView!
@IBOutlet weak var dfyBadgeLabel: UILabel!
@IBOutlet weak var dfyBannerLabel: UILabel!
@IBOutlet weak var gfyBannerView: UIView!
@IBOutlet weak var gfyBannerHeight: NSLayoutConstraint!
@IBOutlet weak var gfyBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var gfyBannerInnerView: UIView!
@IBOutlet weak var couponBadgeImage: UIImageView!
@IBOutlet weak var couponBadgeLabel: UILabel!
@IBOutlet weak var gfyBannerLabel: UILabel!
@IBOutlet weak var marketBannerView: UIView!
@IBOutlet weak var marketBannerHeight: NSLayoutConstraint!
@IBOutlet weak var marketBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var marketBannerInnerView: UIView!
@IBOutlet weak var marketBadgeImage: UIImageView!
@IBOutlet weak var marketBadgeLabel: UILabel!
@IBOutlet weak var marketBannerLabel: UILabel!
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
sumBadgeImage.image = UIImage(named: "wallet_summary_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBadgeImage.image = UIImage(named: "wallet_dfy_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponBadgeImage.image = UIImage(named: "wallet_coupons_4", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
marketBadgeImage.image = UIImage(named: "wallet_market_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
sumBannerInnerView.layer.cornerRadius = 16.5
// sumBannerInnerView.layer.borderWidth = 1
// sumBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
dfyBannerInnerView.layer.cornerRadius = 16.5
// dfyBannerInnerView.layer.borderWidth = 1
// dfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
gfyBannerInnerView.layer.cornerRadius = 16.5
// gfyBannerInnerView.layer.borderWidth = 1
// gfyBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
marketBannerInnerView.layer.cornerRadius = 16.5
// marketBannerInnerView.layer.borderWidth = 1
// marketBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// Add shadow
sumBannerInnerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
sumBannerInnerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
sumBannerInnerView.layer.shadowOpacity = 1.0
sumBannerInnerView.layer.shadowRadius = 1.0
dfyBannerInnerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
dfyBannerInnerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
dfyBannerInnerView.layer.shadowOpacity = 1.0
dfyBannerInnerView.layer.shadowRadius = 1.0
gfyBannerInnerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
gfyBannerInnerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
gfyBannerInnerView.layer.shadowOpacity = 1.0
gfyBannerInnerView.layer.shadowRadius = 1.0
marketBannerInnerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
marketBannerInnerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
marketBannerInnerView.layer.shadowOpacity = 1.0
marketBannerInnerView.layer.shadowRadius = 1.0
dfyBannerView.isHidden = true
dfyBannerHeight.constant = 0.0
dfyBannerTopSpace.constant = 0.0
gfyBannerView.isHidden = true
gfyBannerHeight.constant = 0.0
gfyBannerTopSpace.constant = 0.0
marketBannerView.isHidden = true
marketBannerHeight.constant = 0.0
marketBannerTopSpace.constant = 0.0
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
// public override func layoutSubviews() {
// super.layoutSubviews()
// //set the values for top,left,bottom,right margins
// let margins = UIEdgeInsets(top: 0, left: 0, bottom: 4, right: 0)
// contentView.frame = contentView.frame.inset(by: margins)
// }
func configureCell(totalCouponValue: Float, totalCouponDiscount: Float, unifiedCouponsDiscount: Float, forYouExpanded: Bool) {
loyaltyBadge = swiftApi().getLoyaltyBadge()
if (forYouExpanded == false) {
sumBannerArrowImage.image = UIImage(named: "ic_down_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBannerView.isHidden = true
dfyBannerHeight.constant = 0.0
dfyBannerTopSpace.constant = 0.0
gfyBannerView.isHidden = true
gfyBannerHeight.constant = 0.0
gfyBannerTopSpace.constant = 0.0
marketBannerView.isHidden = true
marketBannerHeight.constant = 0.0
marketBannerTopSpace.constant = 0.0
} else {
sumBannerArrowImage.image = UIImage(named: "ic_up_dark_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyBannerView.isHidden = false
dfyBannerHeight.constant = 80.0
dfyBannerTopSpace.constant = 8.0
gfyBannerView.isHidden = false
gfyBannerHeight.constant = 80.0
gfyBannerTopSpace.constant = 8.0
marketBannerView.isHidden = false
marketBannerHeight.constant = 80.0
marketBannerTopSpace.constant = 8.0
}
if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && unifiedCouponsDiscount == 0.0) {
sumBannerArrowImage.isHidden = true
} else {
sumBannerArrowImage.isHidden = false
}
// ===
let sumRewards = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// if (sumRewards == 0.0) {
// sumBannerArrowImage.isHidden = true
// } else {
// sumBannerArrowImage.isHidden = false
// }
// sumRewards = Float(round(100 * sumRewards) / 100)
var sumRewardsString = "0"
sumRewardsString = String(format: "%.2f", sumRewards).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
sumBadgeLabel.text = sumRewardsString + "€"
let sumRewardsIntCount = String(Int(sumRewards)).count
if (sumRewardsIntCount >= 3) {
sumBadgeLabel.font = UIFont(name: "PeridotPE-Bold", size: 11)
} else {
sumBadgeLabel.font = UIFont(name: "PeridotPE-Bold", size: 13)
}
let sumNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let sumBoldText = sumRewardsString + "€"
let sumNormalText2 = " στο For You!"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 14) ?? UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 14) ?? UIFont.boldSystemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let sumAttributedString = NSMutableAttributedString(string:sumNormalText1, attributes:attrRegular)
let sumBoldString = NSMutableAttributedString(string: sumBoldText, attributes:attrBold)
let sumNormalString = NSMutableAttributedString(string:sumNormalText2, attributes:attrRegular)
sumAttributedString.append(sumBoldString)
sumAttributedString.append(sumNormalString)
sumBannerLabel.attributedText = sumAttributedString
// ===
let totalCouponValueFixed = Float(round(100 * totalCouponValue) / 100)
var totalCouponValueString = "0"
totalCouponValueString = String(format: "%.2f", totalCouponValueFixed).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
dfyBadgeLabel.text = totalCouponValueString + "€"
// let totalCouponValueIntCount = String(Int(totalCouponValueFixed)).count
// if (totalCouponValueIntCount >= 3) {
// dfyBadgeLabel.font = UIFont(name: "PeridotPE-Bold", size: 9)
// } else {
// dfyBadgeLabel.font = UIFont(name: "PeridotPE-Bold", size: 11)
// }
let dfyNormalText1 = "Έχεις κερδίσει "
let dfyBoldText = totalCouponValueString + "€"
let dfyNormalText2 = " με το DEALS for YOU!"
let dfyAttributedString = NSMutableAttributedString(string:dfyNormalText1, attributes:attrRegular)
let dfyBoldString = NSMutableAttributedString(string: dfyBoldText, attributes:attrBold)
let dfyNormalString = NSMutableAttributedString(string:dfyNormalText2, attributes:attrRegular)
dfyAttributedString.append(dfyBoldString)
dfyAttributedString.append(dfyNormalString)
dfyBannerLabel.attributedText = dfyAttributedString
// ===
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
couponBadgeLabel.text = totalCouponDiscountString + "€"
let gfyNormalText1 = "Έχεις κερδίσει "
let gfyBoldText = totalCouponDiscountString + "€"
let gfyNormalText2 = " με το GIFTS for YOU!"
let gfyAttributedString = NSMutableAttributedString(string:gfyNormalText1, attributes:attrRegular)
let gfyBoldString = NSMutableAttributedString(string: gfyBoldText, attributes:attrBold)
let gfyNormalString = NSMutableAttributedString(string:gfyNormalText2, attributes:attrRegular)
gfyAttributedString.append(gfyBoldString)
gfyAttributedString.append(gfyNormalString)
gfyBannerLabel.attributedText = gfyAttributedString
// ===
let marketDiscount = Float(round(100 * unifiedCouponsDiscount) / 100)
var marketDiscountString = "0"
marketDiscountString = String(format: "%.2f", marketDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
self.marketBadgeLabel.text = marketDiscountString + "€"
let marketNormalText1 = "Έχεις κερδίσει "
let marketBoldText = marketDiscountString + "€"
let marketNormalText2 = " με τα SUPERMARKET DEALS!"
let marketAttributedString = NSMutableAttributedString(string:marketNormalText1, attributes:attrRegular)
let marketBoldString = NSMutableAttributedString(string: marketBoldText, attributes:attrBold)
let marketNormalString = NSMutableAttributedString(string:marketNormalText2, attributes:attrRegular)
marketAttributedString.append(marketBoldString)
marketAttributedString.append(marketNormalString)
marketBannerLabel.attributedText = marketAttributedString
}
}
//
// WalletEmptyViewTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 27/2/24.
//
import UIKit
@objc public class WalletEmptyViewTableViewCell: UITableViewCell {
@IBOutlet weak var emptyImage: UIImageView!
@IBOutlet weak var emptyLabel: UILabel!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
emptyImage.image = UIImage(named: "ic_empty_wallet_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!"
emptyLabel.text = "Δεν έχεις ενεργό κωδικό ή κουπόνι!\nΜπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές"
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// WalletHistoryBannerTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 27/2/24.
//
import UIKit
@objc public class WalletHistoryBannerTableViewCell: UITableViewCell {
@IBOutlet weak var bannerView: UIView!
@IBOutlet weak var bannerIconImage: UIImageView!
@IBOutlet weak var bannerLabel: UILabel!
@IBOutlet weak var bannerArrowImage: UIImageView!
let language = swiftApi().getLanguage()
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
bannerView.layer.cornerRadius = 16.0
bannerView.layer.borderWidth = 1
bannerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// Add shadow
bannerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
bannerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
bannerView.layer.shadowOpacity = 1.0
bannerView.layer.shadowRadius = 1.0
bannerIconImage.image = UIImage(named: "wallet_history_blue", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
bannerArrowImage.image = UIImage(named: "arrow_right_black", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
bannerLabel.text = "Δες το ιστορικό σου"
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
//
// WalletQuestionnaireBannerTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 27/2/24.
//
import UIKit
@objc public class WalletQuestionnaireBannerTableViewCell: UITableViewCell {
@IBOutlet weak var bannerView: UIView!
@IBOutlet weak var bannerIconImage: UIImageView!
@IBOutlet weak var bannerIconImageWidth: NSLayoutConstraint!
@IBOutlet weak var bannerLabel: UILabel!
@IBOutlet weak var bannerLabelLeftSpace: NSLayoutConstraint!
// @IBOutlet weak var bannerArrowImage: UIImageView!
@IBOutlet weak var bannerCenteredView: UIView!
@IBOutlet weak var bannerCenteredIconImage: UIImageView!
@IBOutlet weak var bannerCenteredIconImageWidth: NSLayoutConstraint!
@IBOutlet weak var bannerCenteredLabel: UILabel!
@IBOutlet weak var bannerCenteredLabelLeftSpace: NSLayoutConstraint!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
bannerView.layer.cornerRadius = 12.0
bannerView.layer.borderWidth = 1
bannerView.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
// bannerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
bannerCenteredView.layer.cornerRadius = 12.0
bannerCenteredView.layer.borderWidth = 1
bannerCenteredView.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
// Add shadow
// bannerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
// bannerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
// bannerView.layer.shadowOpacity = 1.0
// bannerView.layer.shadowRadius = 1.0
bannerIconImage.image = UIImage(named: "wallet_plus", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
bannerCenteredIconImage.image = UIImage(named: "wallet_plus", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// bannerArrowImage.image = UIImage(named: "arrow_right_black", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
bannerLabel.font = UIFont(name: "PeridotPE-Bold", size: 12)
bannerCenteredLabel.font = UIFont(name: "PeridotPE-Bold", size: 12)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(isCentered: Bool) {
let userTag = swiftApi().getUserTag()
// print("User tag: " + userTag)
if (userTag != "" && userTag != "undefined") {
bannerLabel.text = userTag
bannerLabel.frame.size.width = bannerLabel.intrinsicContentSize.width
bannerIconImage.isHidden = true
bannerIconImageWidth.constant = CGFloat(0.0)
bannerLabelLeftSpace.constant = CGFloat(0.0)
bannerView.frame.size.width = bannerView.intrinsicContentSize.width
bannerCenteredLabel.text = userTag
bannerCenteredLabel.frame.size.width = bannerCenteredLabel.intrinsicContentSize.width
bannerCenteredIconImage.isHidden = true
bannerCenteredIconImageWidth.constant = CGFloat(0.0)
bannerCenteredLabelLeftSpace.constant = CGFloat(0.0)
bannerCenteredView.frame.size.width = bannerLabel.intrinsicContentSize.width
} else {
bannerLabel.text = "Πρόσθεσε τις προτιμήσεις σου"
bannerLabel.frame.size.width = bannerLabel.intrinsicContentSize.width
bannerIconImage.isHidden = false
bannerIconImageWidth.constant = CGFloat(16.0)
bannerLabelLeftSpace.constant = CGFloat(5.0)
bannerView.frame.size.width = bannerView.intrinsicContentSize.width
bannerCenteredLabel.text = "Πρόσθεσε τις προτιμήσεις σου"
bannerCenteredLabel.frame.size.width = bannerCenteredLabel.intrinsicContentSize.width
bannerCenteredIconImage.isHidden = false
bannerCenteredIconImageWidth.constant = CGFloat(16.0)
bannerCenteredLabelLeftSpace.constant = CGFloat(5.0)
bannerCenteredView.frame.size.width = bannerCenteredView.intrinsicContentSize.width
}
if (isCentered) {
bannerView.isHidden = true
bannerCenteredView.isHidden = false
} else {
bannerView.isHidden = false
bannerCenteredView.isHidden = true
}
}
}
//
// WalletSpinnerTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/10/23.
//
import UIKit
@objc public class WalletSpinnerTableViewCell: UITableViewCell {
@IBOutlet weak var spinner: UIActivityIndicatorView!
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
// spinner.color = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
spinner.color = UIColor(red: 0.00, green: 0.65, blue: 0.89, alpha: 1.00)
spinner.translatesAutoresizingMaskIntoConstraints = false
spinner.startAnimating()
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
// This is a fix for spinner stopping its animation when reusing cells
public override func prepareForReuse() {
super.prepareForReuse()
if let spinner = self.spinner {
spinner.startAnimating()
}
}
}
//
// WalletViewController.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 5/5/22.
//
import Foundation
import UIKit
import SwiftEventBus
@objc public class WalletViewController: UIViewController {
@IBOutlet weak var headerImage: UIImageView!
@IBOutlet weak var profileImage: UIImageView!
@IBOutlet weak var profileNameLabel: UILabel!
@IBOutlet weak var questionnaireButton: UIButton!
@IBOutlet weak var historyButtonView: UIView!
@IBOutlet weak var historyButtonImage: UIImageView!
@IBOutlet weak var dfyEarnBannerView: UIView!
@IBOutlet weak var dfyEarnBannerHeight: NSLayoutConstraint!
@IBOutlet weak var dfyEarnBannerTopSpace: NSLayoutConstraint!
@IBOutlet weak var dfyEarnBannerInnerView: UIView!
@IBOutlet weak var dfyEarnLabel: UILabel!
@IBOutlet weak var dfyEarnAmountLabel: UILabel!
@IBOutlet weak var dfyEarnImage: UIImageView!
@IBOutlet weak var couponEarnView: UIView!
@IBOutlet weak var couponEarnViewHeight: NSLayoutConstraint!
@IBOutlet weak var couponEarnViewTopSpace: NSLayoutConstraint!
@IBOutlet weak var couponEarnInnerView: UIView!
@IBOutlet weak var couponEarnLabel: UILabel!
@IBOutlet weak var couponEarnAmountLabel: UILabel!
@IBOutlet weak var couponEarnImage: UIImageView!
@IBOutlet weak var dfyLogoImage: UIImageView!
@IBOutlet weak var dfyLogoImageTopSpace: NSLayoutConstraint!
@IBOutlet weak var dfyLogoImageHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodeView: UIView!
@IBOutlet weak var activeCodeViewHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodesCountLabel: UILabel!
@IBOutlet weak var activeCodeLabel: UILabel!
@IBOutlet weak var activeCodeExpirationLabel: UILabel!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var activeCodeImage: UIImageView!
@IBOutlet weak var myPresentsLabel: UILabel!
@IBOutlet weak var emptyView: UIView!
@IBOutlet weak var emptyViewHeight: NSLayoutConstraint!
@IBOutlet weak var emptyImage: UIImageView!
@IBOutlet weak var emptyLabel: UILabel!
@IBOutlet weak var activeCodeScrollView: UIScrollView!
@IBOutlet weak var activeCodeScrollViewHeight: NSLayoutConstraint!
@IBOutlet weak var activeCodeContentView: UIView!
@IBOutlet weak var activeCodeContentViewHeight: NSLayoutConstraint!
@IBOutlet weak var rewardsView: UIView!
@IBOutlet weak var rewardsViewHeight: NSLayoutConstraint!
@IBOutlet weak var rewardsLabel: UILabel!
@IBOutlet weak var sumBadgeImage: UIImageView!
@IBOutlet weak var sumBadgeLabel: UILabel!
@IBOutlet weak var dfyBadgeImage: UIImageView!
@IBOutlet weak var dfyBadgeLabel: UILabel!
@IBOutlet weak var couponBadgeImage: UIImageView!
@IBOutlet weak var couponBadgeLabel: UILabel!
@IBOutlet weak var marketBadgeImage: UIImageView!
@IBOutlet weak var marketBadgeLabel: UILabel!
@IBOutlet weak var badgeLinesImage: UIImageView!
public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
public var smCoupons:Array<swiftApi.CouponItemModel> = [] // swiftApi().getSMCouponList()
public var boxCoupons:Array<swiftApi.ActiveBoxCouponModel> = swiftApi().getActiveBoxCoupons()
var timerWallet: DispatchSourceTimer?
var seconds: Int = 0
var totalCouponValue = swiftApi().getDealsCouponsSum()
var totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
var unifiedCouponsDiscount:Float = 0.0
var forYouExpanded: Bool = false;
var showSpinner: Bool = false;
// TODO: UNCOMMENT if ActiveCouponsBanners needs to be hidden again
// var showActiveCouponsBanners: Bool = false;
var showActiveCouponsBanners: Bool = true;
var showEmptyView: Bool = false;
public override func viewDidLoad() {
super.viewDidLoad()
self.hidesBottomBarWhenPushed = true
SwiftEventBus.onBackgroundThread(self, name: "coupons_fetched") { result in
DispatchQueue.main.async {
self.coupons = swiftApi().getCouponList()
self.totalCouponDiscount = Float(round(100 * swiftApi().getLoyaltyBadge()._value) / 100)
self.loyaltyBadge = swiftApi().getLoyaltyBadge()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
}
}
SwiftEventBus.onBackgroundThread(self, name: "unified_coupons_fetched") { result in
DispatchQueue.main.async {
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
// TODO: Maybe add this
// TODO: Uncomment if discounts are shown again in wallet
self.matchOldSMCoupons()
self.updateMarketBadge()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
}
}
SwiftEventBus.onBackgroundThread(self, name: "sm_coupons_fetched") { result in
DispatchQueue.main.async {
self.smCoupons = swiftApi().getSMCouponList()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
}
}
SwiftEventBus.onBackgroundThread(self, name: "vouchers_fetched") { result in
DispatchQueue.main.async {
print("=== vouchers_fetched event ===")
self.handleSpinnerAndEmptyView()
// self.showSpinner = false
self.tableView.reloadData()
}
}
SwiftEventBus.onBackgroundThread(self, name: "vouchers_service_unavailable") { result in
DispatchQueue.main.async {
print("=== vouchers_service_unavailable event ===")
self.showVouchersFailureDialog()
}
}
// TODO: DELETE ===>
// let coupon = swiftApi.ActiveDFYCouponModel()
// coupon._value = "12"
// // coupon._date = "2022-12-05 01:55:01"
// coupon._date = "2022-10-26 23:59:01"
// coupon._code = "123456789"
//
// let coupon2 = swiftApi.ActiveDFYCouponModel()
// coupon2._value = "23"
// coupon2._date = "2022-11-05 01:55"
// coupon2._code = "234567891"
//
// let coupon3 = swiftApi.ActiveDFYCouponModel()
// coupon3._value = "34"
// coupon3._date = "2022-07-01 01:55"
// coupon3._code = "345678912"
//
// let couponsArray: Array<swiftApi.ActiveDFYCouponModel> = [coupon, coupon2, coupon3, coupon3, coupon3]
//
// swiftApi().setActiveDFYCoupons(dfyCoupons: couponsArray)
//
// dfyCoupons = swiftApi().getActiveDFYCoupons()
// TODO: DELETE <===
// TODO: Uncomment when UnifiedCoupons will be shown again
// getCouponsSetsDealsRequest()
// setBackButton("ic_close_3")
// setNavigationTitle("My Rewards")
tableView.delegate = self
tableView.dataSource = self
print("Active Gifts Count: " + String(coupons.count))
// if ((profile != nil) && (profile?._nonTelco == true)) {
if (swiftApi().getUserNonTelco() == true) {
showDialog("Αδυναμία ενεργοποίησης", "Πρόσθεσε σύνδεση COSMOTE σταθερής, κινητής ή TV για να έχεις πρόσβαση στις προσφορές.");
}
headerImage.image = UIImage(named: "ic_background_straight", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
historyButtonImage.image = UIImage(named: "wallet_history", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyEarnImage.image = UIImage(named: "wallet_dfy_3", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponEarnImage.image = UIImage(named: "wallet_coupons_4", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
dfyLogoImage.image = UIImage(named: "dfy_logo_colored", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
activeCodeImage.image = UIImage(named: "active_code_logo_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
if (profile != nil && !(profile?._image_url is NSNull) && profile?._image_url != nil && profile?._image_url != "") {
profileImage.load(link: profile?._image_url ?? "", placeholder: UIImage(), cache: URLCache())
} else {
profileImage.image = UIImage(named: "default_profile_image_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
}
profileImage.layer.cornerRadius = 19
profileImage.layer.maskedCorners = [ .layerMinXMinYCorner, .layerMaxXMaxYCorner] // Top left, bottom right corner radius
profileImage.layer.borderWidth = 1
profileImage.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
print("Profile Name: " + (profile?._firstname ?? "") + " " + (profile?._lastname ?? ""))
profileNameLabel.text = (profile?._firstname ?? "") + " " + (profile?._lastname ?? "")
let userTag = swiftApi().getUserTag()
print("User tag: " + userTag)
if (userTag != "" && userTag != "undefined") {
questionnaireButton.setTitle(userTag, for: .normal)
// questionnaireButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// questionnaireButton.setTitleColor(.white, for: .normal)
// // questionnaireButton.sizeToFit()
// questionnaireButton.frame = CGRect(x: 0.0, y: 0.0, width: questionnaireButton.intrinsicContentSize.width, height: 26)
// questionnaireButton.applyGradient(colours: [UIColor(red: 0.40, green: 0.77, blue: 0.28, alpha: 1.00), UIColor(red: 0.10, green: 0.66, blue: 0.72, alpha: 1.00)], gradient: GradientOrientation.horizontal, cornerRadius: 7.0)
// // Shadow Color
// questionnaireButton.layer.shadowColor = UIColor(red: 0.33, green: 0.38, blue: 0.43, alpha: 1.00).cgColor
// questionnaireButton.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
// questionnaireButton.layer.shadowOpacity = 1.0
// questionnaireButton.layer.shadowRadius = 0.0
// questionnaireButton.layer.masksToBounds = false
// questionnaireButton.contentEdgeInsets = UIEdgeInsets(top: 7, left: 10, bottom: 3, right: 10)
} else {
questionnaireButton.setTitle("+Προτιμήσεις", for: .normal)
// questionnaireButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// questionnaireButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal)
// questionnaireButton.backgroundColor = .clear
// questionnaireButton.frame = CGRect(x: 0.0, y: 0.0, width: questionnaireButton.intrinsicContentSize.width, height: 26)
// questionnaireButton.contentEdgeInsets = UIEdgeInsets(top: 5, left: 10, bottom: 5, right: 10)
}
questionnaireButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
questionnaireButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal)
questionnaireButton.backgroundColor = .clear
questionnaireButton.frame = CGRect(x: 0.0, y: 0.0, width: questionnaireButton.intrinsicContentSize.width, height: 42)
questionnaireButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 20, bottom: 12, right: 20)
questionnaireButton.layer.cornerRadius = 16.0
questionnaireButton.layer.borderWidth = 1
questionnaireButton.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
historyButtonView.backgroundColor = .clear
historyButtonView.layer.cornerRadius = 16.0
historyButtonView.layer.borderWidth = 1
historyButtonView.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
dfyEarnBannerInnerView.layer.cornerRadius = 16.5
// dfyEarnBannerInnerView.layer.borderWidth = 1
// dfyEarnBannerInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// Add shadow
dfyEarnBannerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
dfyEarnBannerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
dfyEarnBannerView.layer.shadowOpacity = 1.0
dfyEarnBannerView.layer.shadowRadius = 1.0
// var totalCouponValue = swiftApi().getDealsCouponsSum()
if (totalCouponValue == 0.0) {
dfyEarnBannerView.isHidden = true
dfyEarnBannerHeight.constant = 0
// dfyEarnBannerTopSpace.constant = 0
} else {
dfyEarnBannerView.isHidden = false
dfyEarnBannerHeight.constant = 75
// dfyEarnBannerTopSpace.constant = 30
}
totalCouponValue = Float(round(100 * totalCouponValue) / 100)
var totalCouponValueString = "0"
totalCouponValueString = String(format: "%.2f", totalCouponValue).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
// dfyEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponValueString + "€ με το DEALS for YOU!"
let normalText1 = "Μέχρι τώρα έχεις κερδίσει "
let boldText = totalCouponValueString + "€"
let normalText2 = " με το DEALS for YOU!"
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Regular", size: 14) ?? UIFont.systemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attrBold = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-Bold", size: 14) ?? UIFont.boldSystemFont(ofSize: 13), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attributedString = NSMutableAttributedString(string:normalText1, attributes:attrRegular)
let boldString = NSMutableAttributedString(string: boldText, attributes:attrBold)
let normalString = NSMutableAttributedString(string:normalText2, attributes:attrRegular)
attributedString.append(boldString)
attributedString.append(normalString)
dfyEarnLabel.attributedText = attributedString
dfyEarnAmountLabel.text = totalCouponValueString + "€"
// dfyEarnAmountLabel.font = UIFont(name: "PeridotPE-Bold", size: 14)
let totalCouponValueIntCount = String(Int(totalCouponValue)).count
if (totalCouponValueIntCount >= 3) {
dfyEarnAmountLabel.font = UIFont(name: "PeridotPE-Bold", size: 11)
} else {
dfyEarnAmountLabel.font = UIFont(name: "PeridotPE-Bold", size: 13)
}
if (loyaltyBadge._couponCount == 0) {
couponEarnView.isHidden = true
couponEarnViewHeight.constant = 0
couponEarnViewTopSpace.constant = 0
} else {
couponEarnView.isHidden = false
couponEarnViewHeight.constant = 75
if (totalCouponValue == 0.0) {
couponEarnViewTopSpace.constant = 30
} else {
couponEarnViewTopSpace.constant = 15
}
}
couponEarnInnerView.layer.cornerRadius = 16.5
// couponEarnInnerView.layer.borderWidth = 1
// couponEarnInnerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// Add shadow
couponEarnView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
couponEarnView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
couponEarnView.layer.shadowOpacity = 1.0
couponEarnView.layer.shadowRadius = 1.0
// let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
// couponEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
let coupNormalText1 = "Μέχρι τώρα έχεις κερδίσει "
let coupBoldText = totalCouponDiscountString + "€"
let coupNormalText2 = " σε προσφορές από "
let coupBoldText2 = String(loyaltyBadge._couponCount)
let coupNormalText3 = " κουπόνια!"
let coupAttributedString = NSMutableAttributedString(string:coupNormalText1, attributes:attrRegular)
let coupBoldString = NSMutableAttributedString(string: coupBoldText, attributes:attrBold)
let coupNormalString2 = NSMutableAttributedString(string:coupNormalText2, attributes:attrRegular)
let coupBoldString2 = NSMutableAttributedString(string: coupBoldText2, attributes:attrBold)
let coupNormalString3 = NSMutableAttributedString(string:coupNormalText3, attributes:attrRegular)
coupAttributedString.append(coupBoldString)
coupAttributedString.append(coupNormalString2)
coupAttributedString.append(coupBoldString2)
coupAttributedString.append(coupNormalString3)
couponEarnLabel.attributedText = coupAttributedString
couponEarnAmountLabel.text = totalCouponDiscountString + "€"
let totalCouponDiscountIntCount = String(Int(totalCouponDiscount)).count
if (totalCouponDiscountIntCount >= 3) {
couponEarnAmountLabel.font = UIFont(name: "PeridotPE-Bold", size: 11)
} else {
couponEarnAmountLabel.font = UIFont(name: "PeridotPE-Bold", size: 13)
}
print("Loyalty Badge Value: " + totalCouponDiscountString)
print("Loyalty Badge Count: " + String(loyaltyBadge._couponCount))
// activeCodeView
activeCodeView.layer.cornerRadius = 5.0
activeCodeView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
activeCodeView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
activeCodeView.layer.shadowOpacity = 1.0
activeCodeView.layer.shadowRadius = 6.0
if (dfyCoupons.count > 0) {
if (dfyCoupons.count == 1) {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
// dateFormatter.dateFormat = "yyyy-MM-dd HH:mm"
// sort dfyCoupons by date
dfyCoupons.sort(by: {
let date1 = dateFormatter.date(from: $0._date)
let date2 = dateFormatter.date(from: $1._date)
if ((date1 != nil) && (date2 != nil)) {
return date1!.compare(date2!) == .orderedAscending
} else {
return false
}
})
// Get days from now of the most recet coupon
var daysFromNow = ""
let calendar = Calendar.current
// Replace the hour (time) of both dates with 00:00
let date1 = calendar.startOfDay(for: Date())
if let date2 = dateFormatter.date(from: dfyCoupons[0]._date) {
let components = calendar.dateComponents([.day], from: date1, to: date2)
daysFromNow = (components.day) != nil ? String((components.day ?? 0) + 1) : ""
}
activeCodesCountLabel.text = "Ενεργός κωδικός:"
// activeCodeLabel.text = dfyCoupons[0]._code
let newLabel = CopyableLabel()
newLabel.text = String(dfyCoupons[0]._code)
newLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 19)
newLabel.textColor = UIColor(rgb: 0x3C5365)
newLabel.frame.size.width = newLabel.intrinsicContentSize.width
newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight
activeCodeContentView.addSubview(newLabel)
// set the btn frame origin
newLabel.frame.origin.x = 0
newLabel.frame.origin.y = 0
let scrollHeight = newLabel.intrinsicContentSize.height
activeCodeContentViewHeight.constant = scrollHeight
activeCodeScrollViewHeight.constant = scrollHeight
activeCodeExpirationLabel.isHidden = false
if (daysFromNow == "1") {
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρα"
} else {
activeCodeExpirationLabel.text = "Λήγει σε " + daysFromNow + " ημέρες"
}
} else {
var tagHeight:CGFloat = 30
let tagPadding: CGFloat = 0
let tagSpacingX: CGFloat = 0
let tagSpacingY: CGFloat = 2
let containerWidth = activeCodeContentView.frame.size.width
var currentOriginX: CGFloat = 0
var currentOriginY: CGFloat = 0
// var couponCodesString = ""
for (index, item) in dfyCoupons.enumerated() {
let newLabel = CopyableLabel()
newLabel.font = UIFont(name: "PFSquareSansPro-Bold", size: 19)
newLabel.textColor = UIColor(rgb: 0x3C5365)
if (index == (dfyCoupons.endIndex - 1)) {
// couponCodesString += String(item._code)
newLabel.text = String(item._code)
} else {
// couponCodesString += String(item._code) + ", "
newLabel.text = String(item._code) + ", "
}
newLabel.frame.size.width = newLabel.intrinsicContentSize.width + tagPadding
newLabel.frame.size.height = newLabel.intrinsicContentSize.height // tagHeight
tagHeight = newLabel.intrinsicContentSize.height
activeCodeContentView.addSubview(newLabel)
// if current X + label width will be greater than container view width
// "move to next row"
if currentOriginX + newLabel.frame.width > containerWidth {
currentOriginX = 0
currentOriginY += tagHeight + tagSpacingY
}
// set the btn frame origin
newLabel.frame.origin.x = currentOriginX
newLabel.frame.origin.y = currentOriginY
// increment current X by btn width + spacing
currentOriginX += newLabel.frame.width + tagSpacingX
}
activeCodesCountLabel.text = String(dfyCoupons.count) + " Ενεργοί κωδικοί:"
// activeCodeLabel.text = couponCodesString
activeCodeExpirationLabel.isHidden = true
// update container view height
activeCodeContentViewHeight.constant = currentOriginY + tagHeight
if ((currentOriginY + tagHeight) <= (2 * tagHeight + tagSpacingY)) {
activeCodeScrollViewHeight.constant = currentOriginY + tagHeight
} else {
activeCodeScrollViewHeight.constant = 2 * tagHeight + tagSpacingY
}
}
} else {
activeCodeLabel.text = "-"
activeCodeExpirationLabel.text = ""
dfyLogoImage.isHidden = true
activeCodeView.isHidden = true
dfyLogoImageHeight.constant = 0
activeCodeViewHeight.constant = 0
// dfyLogoImageTopSpace.constant = 0
}
myPresentsLabel.text = "Τα δώρα μου"
if (coupons.count > 0) {
myPresentsLabel.isHidden = false
} else {
myPresentsLabel.isHidden = true
}
emptyImage.image = UIImage(named: "ic_empty_wallet_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
emptyLabel.text = "Δεν έχεις κάποιον ενεργό κωδικό ή κουπόνι! Μπες τώρα στην ενότητα COSMOTE For You και βρες αποκλειστικές προσφορές!"
// TODO: Uncomment if discounts are shown again in wallet
matchOldSMCoupons()
updateMarketBadge()
// TODO: DELETE if emptyView is needed again
// emptyView.isHidden = true
// emptyViewHeight.constant = 0
self.handleSpinnerAndEmptyView()
}
public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
swiftApi().logTrackersEvent("screen", "LoyaltyWalletScreen")
// addNavShadow()
self.navigationController?.hideHairline()
let userTag = swiftApi().getUserTag()
if (questionnaireButton.currentTitle != userTag) {
if (userTag != "" && userTag != "undefined") {
questionnaireButton.setTitle(userTag, for: .normal)
// questionnaireButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 14)
// questionnaireButton.setTitleColor(.white, for: .normal)
// // questionnaireButton.sizeToFit()
// questionnaireButton.frame = CGRect(x: 0.0, y: 0.0, width: questionnaireButton.intrinsicContentSize.width, height: 26)
// questionnaireButton.applyGradient(colours: [UIColor(red: 0.40, green: 0.77, blue: 0.28, alpha: 1.00), UIColor(red: 0.10, green: 0.66, blue: 0.72, alpha: 1.00)], gradient: GradientOrientation.horizontal, cornerRadius: 7.0)
// // Shadow Color
// questionnaireButton.layer.shadowColor = UIColor(red: 0.33, green: 0.38, blue: 0.43, alpha: 1.00).cgColor
// questionnaireButton.layer.shadowOffset = CGSize(width: 0.0, height: 2.0)
// questionnaireButton.layer.shadowOpacity = 1.0
// questionnaireButton.layer.shadowRadius = 0.0
// questionnaireButton.layer.masksToBounds = false
// questionnaireButton.contentEdgeInsets = UIEdgeInsets(top: 7, left: 10, bottom: 3, right: 10)
} else {
for layer in (questionnaireButton.layer.sublayers ?? []) {
if(layer.name == "linearGradientLayer"){
layer.removeFromSuperlayer()
}
}
questionnaireButton.layer.shadowOpacity = 0.0;
questionnaireButton.setTitle("+Προτιμήσεις", for: .normal)
// questionnaireButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 14)
// questionnaireButton.setTitleColor(UIColor(red: 0.31, green: 0.62, blue: 0.18, alpha: 1.00), for: .normal)
// questionnaireButton.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
// questionnaireButton.frame = CGRect(x: 0.0, y: 0.0, width: questionnaireButton.intrinsicContentSize.width, height: 26)
// questionnaireButton.contentEdgeInsets = UIEdgeInsets(top: 5, left: 10, bottom: 5, right: 10)
}
questionnaireButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
questionnaireButton.setTitleColor(UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00), for: .normal)
questionnaireButton.backgroundColor = .clear
questionnaireButton.frame = CGRect(x: 0.0, y: 0.0, width: questionnaireButton.intrinsicContentSize.width, height: 42)
questionnaireButton.contentEdgeInsets = UIEdgeInsets(top: 12, left: 20, bottom: 12, right: 20)
questionnaireButton.layer.cornerRadius = 16.0
questionnaireButton.layer.borderWidth = 1
questionnaireButton.layer.borderColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00).cgColor
}
self.coupons = swiftApi().getCouponList()
// TODO: Uncomment when UnifiedCoupons will be shown again
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.smCoupons = swiftApi().getSMCouponList()
// TODO: Maybe add this
self.matchOldSMCoupons()
// <===
// TODO: Uncomment if discounts are shown again in wallet
self.updateMarketBadge()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
self.startTimer()
}
public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
self.stopTimer()
self.navigationController?.navigationBar.layer.shadowOpacity = 0.0
if self.isMovingFromParent {
// Clear ShowVouchersBanner state
swiftApi().clearShowVouchersBanner();
}
}
public override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// TODO: Uncomment if header is needed again
// if let headerView = tableView.tableHeaderView {
//
// let height = headerView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).height
// var headerFrame = headerView.frame
//// let height = 0.0
//// var headerFrame = CGRect(x: 0,y: 0,width: 0,height: 0)
//
// //Comparison necessary to avoid infinite loop
// if height != headerFrame.size.height {
// headerFrame.size.height = height
// headerView.frame = headerFrame
// tableView.tableHeaderView = headerView
// }
// }
// TODO: DELETE if header is needed again
self.tableView.tableHeaderView = UIView(frame: CGRect(x: 0.0, y: 0.0, width: self.tableView.bounds.size.width, height: 0.01))
}
// MARK: - Functions
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
self.navigationController?.popViewController(animated: true)
// self.dismiss(animated: true, completion: {})
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func showVouchersFailureDialog() -> Void {
let alert = UIAlertController(title: "Προσπάθησε ξανά αργότερα", message: "Προσωρινά μη διαθέσιμη πληροφορία.\nΠαρακαλούμε δοκίμασε ξανά σε λίγο.", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
// self.handleSpinnerAndEmptyView()
// self.tableView.reloadData()
self.navigationController?.popViewController(animated: true)
// self.dismiss(animated: true, completion: {})
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
func startTimer() {
print("========= MyRewards Timer Started! =========")
let queue = DispatchQueue(label: Bundle.main.bundleIdentifier! + ".wallet.timer")
timerWallet = DispatchSource.makeTimerSource(queue: queue)
timerWallet!.schedule(deadline: .now(), repeating: .seconds(1))
timerWallet!.setEventHandler { [weak self] in
// do whatever stuff you want on the background queue here here
print("========= MyRewards interval! =========")
DispatchQueue.main.async {
// update your model objects and/or UI here
self?.seconds = (self?.seconds ?? 0) + 1
}
}
timerWallet!.resume()
}
func stopTimer() {
print("========= MyRewards Timer Stopped! =========")
timerWallet?.cancel()
timerWallet = nil
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "time_spent_on_loyalty_sdk"
firebaseEvent.setParameter = ("name", "MyRewards")
firebaseEvent.setParameter = ("seconds", String(seconds))
SwiftEventBus.post("firebase", sender: firebaseEvent)
seconds = 0
}
func updateMarketBadge() {
unifiedCouponsDiscount = 0.0
// for smCouponSet in swiftApi().getCouponSetsDealsList() {
// for oldCoupon in swiftApi().getAllOldCouponList() {
// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) {
//
// oldCoupon.setCouponSetData(smCouponSet);
//
// if let discountFloat = Float(oldCoupon.discount ?? "0.0") {
// unifiedCouponsDiscount += discountFloat
// }
// break;
// }
// }
// }
for coupon in swiftApi().getOldUnifiedCouponList() {
if let discountFloat = Float(coupon.discount ?? "0.0") {
unifiedCouponsDiscount += discountFloat
}
}
// TODO: UNCOMMENT if emptyView is needed again
// if (totalCouponValue == 0.0 && loyaltyBadge._couponCount == 0 && dfyCoupons.count == 0 && coupons.count == 0 && unifiedCoupons.count == 0 && unifiedCouponsDiscount == 0.0) {
// emptyView.isHidden = false
// emptyViewHeight.constant = emptyView.intrinsicContentSize.height
// } else {
// emptyView.isHidden = true
// emptyViewHeight.constant = 0
// }
}
func matchOldSMCoupons() {
var oldUnifiedCouponsArray:Array<swiftApi.CouponItemModel> = []
// TODO: Check - Old implementation
// for smCouponSet in swiftApi().getCouponSetsDealsList() {
// for oldCoupon in swiftApi().getAllOldCouponList() {
// if (smCouponSet.uuid != "" && oldCoupon.couponset_uuid != "" && smCouponSet.uuid == oldCoupon.couponset_uuid) {
//
// oldCoupon.setCouponSetData(smCouponSet);
// oldUnifiedCouponsArray.append(oldCoupon);
//
// break;
// }
// }
// }
// TODO: DELETE - TEST
// oldUnifiedCouponsArray = swiftApi().getAllOldCouponList().filter({ return $0.couponset_data?.couponset_type == "supermarket" })
oldUnifiedCouponsArray = swiftApi().getSMOldCouponList()
oldUnifiedCouponsArray.sort(by: {
let date1 = $0.redeemed_date
let date2 = $1.redeemed_date
if ((date1 != nil) && (date2 != nil)) {
return date1!.compare(date2!) == .orderedDescending
} else {
return false
}
})
swiftApi().setOldUnifiedCouponList(oldUnifiedCouponsArray)
}
func handleSpinnerAndEmptyView() {
if (swiftApi().getShowVouchersBanner() == "") {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
self.showEmptyView = false
self.showSpinner = true
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.smCoupons.count == 0 && self.coupons.count == 0) {
// TODO: UNCOMMENT if ActiveCouponsBanners needs to be hidden again
// self.showActiveCouponsBanners = false
} else {
self.showActiveCouponsBanners = true
}
} else {
self.showSpinner = false
if (self.dfyCoupons.count == 0 && self.unifiedCoupons.count == 0 && self.smCoupons.count == 0 && self.coupons.count == 0) {
// TODO: UNCOMMENT if ActiveCouponsBanners needs to be hidden again
// self.showActiveCouponsBanners = false
if (swiftApi().getShowVouchersBanner() == "null") {
// TODO: UNCOMMENT if emptyView is needed again
// self.emptyView.isHidden = false
// self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
let sumRedeemed = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
if (sumRedeemed == 0.0) {
self.showEmptyView = true
} else {
self.showEmptyView = false
}
// self.showEmptyView = true
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
self.showEmptyView = false
}
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
self.showEmptyView = false
self.showActiveCouponsBanners = true
}
}
}
// MARK: - API Functions
func getCouponsSetsDealsRequest() {
swiftApi().getCouponSetsDealsAsync(getCouponsSetsDealsCallback, failureCallback: {errorCode in
})
}
func getCouponsSetsDealsCallback (_ couponsData: Array<swiftApi.CouponSetItemModel>?) -> Void {
if (couponsData != nil) {
DispatchQueue.main.async {
self.getUnifiedCouponsRequest()
}
} else {
}
}
func getUnifiedCouponsRequest() {
swiftApi().getUnifiedCouponsAsync(getUnifiedCouponsCallback, failureCallback: {errorCode in
self.unifiedCoupons = []
})
}
func getUnifiedCouponsCallback (_ couponsData: Array<swiftApi.UnifiedCouponModel>?) -> Void {
if (couponsData != nil) {
self.unifiedCoupons = couponsData ?? []
DispatchQueue.main.async {
self.matchOldSMCoupons()
self.updateMarketBadge()
self.handleSpinnerAndEmptyView()
self.tableView.reloadData()
}
} else {
self.unifiedCoupons = []
}
}
// MARK: - Actions
@IBAction func qustionnaireButtonAction(_ sender: Any) {
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "Questionnaire"))
swiftApi().openQuestionnaire(self);
}
@IBAction func historyButtonAction(_ sender: Any) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_history_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyHistoryBadge"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyHistoryViewController") as! SwiftWarplyFramework.LoyaltyHistoryViewController
self.navigationController?.pushViewController(vc, animated: true)
}
@IBAction func dfyEarnButtonAction(_ sender: Any) {
print("DFY coupon banner pressed!")
// analysis_pressed event
let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel()
dealsAnalysis._isPressed = true
SwiftEventBus.post("analysis_pressed", sender: dealsAnalysis)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_gifts_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "DealsBanner"))
}
@IBAction func couponEarnButtonAction(_ sender: Any) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_deals_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyAnalysisViewController") as! SwiftWarplyFramework.LoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
}
@IBAction func activeCodeButtonAction(_ sender: Any) {
print("Active DFY coupon banner Tapped!")
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveDealsBanner"))
let couponDetails = swiftApi.ActiveDFYCouponEventModel()
couponDetails._isPressed = true
SwiftEventBus.post("dfy_coupon_details", sender: couponDetails)
}
@IBAction func dfyBadgeButtonAction(_ sender: Any) {
var totalCouponValue = swiftApi().getDealsCouponsSum()
if (totalCouponValue > 0.0) {
print("DFY coupon banner pressed!")
// analysis_pressed event
let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel()
dealsAnalysis._isPressed = true
SwiftEventBus.post("analysis_pressed", sender: dealsAnalysis)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_gifts_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "DealsBanner"))
}
}
@IBAction func couponBadgeButtonAction(_ sender: Any) {
if (loyaltyBadge._couponCount > 0) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_deals_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyAnalysisViewController") as! SwiftWarplyFramework.LoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func marketBadgeButtonAction(_ sender: Any) {
print("Market Badge pressed!")
// TODO: add action - open marketHistory after check
if (self.unifiedCouponsDiscount > 0.0) {
// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
// firebaseEvent._eventName = "did_tap_deals_for_you_badge"
// firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
// SwiftEventBus.post("firebase", sender: firebaseEvent)
// swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "MarketLoyaltyAnalysisViewController") as! SwiftWarplyFramework.MarketLoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func sumBannerButtonAction(_ sender: Any) {
if (!(self.totalCouponValue == 0.0 && self.loyaltyBadge._couponCount == 0 && self.unifiedCouponsDiscount == 0.0)) {
self.forYouExpanded = !self.forYouExpanded
self.tableView.reloadData()
}
}
@IBAction func dfyBannerButtonAction(_ sender: Any) {
var totalCouponValue = swiftApi().getDealsCouponsSum()
if (totalCouponValue > 0.0) {
print("DFY coupon banner pressed!")
// analysis_pressed event
let dealsAnalysis = swiftApi.WarplyDealsAnalysisEventModel()
dealsAnalysis._isPressed = true
SwiftEventBus.post("analysis_pressed", sender: dealsAnalysis)
// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
// firebaseEvent._eventName = "did_tap_gifts_for_you_badge"
// firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
// SwiftEventBus.post("firebase", sender: firebaseEvent)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_deals_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "DealsBanner"))
}
}
@IBAction func gfyBannerButtonAction(_ sender: Any) {
if (loyaltyBadge._couponCount > 0) {
// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
// firebaseEvent._eventName = "did_tap_deals_for_you_badge"
// firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
// SwiftEventBus.post("firebase", sender: firebaseEvent)
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_gifts_for_you_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyAnalysisViewController") as! SwiftWarplyFramework.LoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func marketBannerButtonAction(_ sender: Any) {
if (self.unifiedCouponsDiscount > 0.0) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_market_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "MarketBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "MarketLoyaltyAnalysisViewController") as! SwiftWarplyFramework.MarketLoyaltyAnalysisViewController
self.navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func dfyActiveCouponsBannerButtonAction(_ sender: Any) {
print("Active DFY coupon banner Tapped!")
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveDealsBanner"))
let couponDetails = swiftApi.ActiveDFYCouponEventModel()
couponDetails._isPressed = true
SwiftEventBus.post("dfy_coupon_details", sender: couponDetails)
}
@IBAction func smActiveCouponsBannerButtonAction(_ sender: Any) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_market_active_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveMarketBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponsViewController") as! SwiftWarplyFramework.UnifiedCouponsViewController
self.navigationController?.pushViewController(vc, animated: true)
}
@IBAction func gfyActiveCouponsBannerButtonAction(_ sender: Any) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_gifts_for_you_active_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveLoyaltyBanner"))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: SwiftWarplyFramework.CouponsViewController.self))
if let vc = storyboard.instantiateViewController(withIdentifier: "CouponsViewController") as? SwiftWarplyFramework.CouponsViewController{
self.navigationController?.pushViewController(vc,animated: true)
}
}
}
// MARK: - TableView
extension WalletViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
// return 4
return 5
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// if (section == 0) {
// // TODO: Uncomment when UnifiedCoupons will be shown again
//// if (self.totalCouponValue == 0.0 && self.loyaltyBadge._couponCount == 0 && self.unifiedCouponsDiscount == 0.0) {
//// return 0
//// } else {
// return 1
//// }
// } else if (section == 1) {
// return self.unifiedCoupons.count
// } else if (section == 2) {
// if (self.dfyCoupons.count > 0) {
// return 1
// } else {
// return 0
// }
// } else if (section == 3) {
// return self.coupons.count
// } else {
// return 0
// }
if (section == 0) {
// TODO: Uncomment if we want to hide empty tiles again
// let sumRedeemed = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// if (self.dfyCoupons.count > 0 || self.unifiedCoupons.count > 0 || self.coupons.count > 0 || sumRedeemed > 0.0) {
return 1
// } else {
// return 0
// }
} else if (section == 1) {
// TODO: Uncomment if we want to show emptyView again
// if (self.showEmptyView == true) {
// return 1
// } else {
return 0
// }
} else if (section == 2) {
return 1
}
// else if (section == 2) {
// let sumRedeemed = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// if (sumRedeemed > 0.0) {
// return 1
// } else {
// return 0
// }
// }
else if (section == 3) {
if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
return 1
} else {
return 0
}
} else if (section == 4) {
if (self.showSpinner == true) {
return 1
} else {
return 0
}
} else {
return 0
}
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
// if (indexPath.section == 0) {
// // TODO: Uncomment when UnifiedCoupons will be shown again
//// if (self.totalCouponValue == 0.0 && self.loyaltyBadge._couponCount == 0 && self.unifiedCouponsDiscount == 0.0) {
//// return 0.0
//// } else {
// return UITableView.automaticDimension
//// }
// } else if (indexPath.section == 1) {
// if (self.unifiedCoupons.count > 0) {
// return 130.0 + 8.0
// } else {
// return 0.0
// }
// } else if (indexPath.section == 2) {
// if (self.dfyCoupons.count > 0) {
// return UITableView.automaticDimension
// } else {
// return 0.0
// }
//
// } else if (indexPath.section == 3) {
// if (self.coupons.count > 0) {
// return 130.0 + 8.0
// } else {
// return 0.0
// }
// } else {
// return 0.0
// }
if (indexPath.section == 0) {
// TODO: Uncomment if we want to hide empty tiles again
// let sumRedeemed = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// if (self.dfyCoupons.count > 0 || self.unifiedCoupons.count > 0 || self.coupons.count > 0 || sumRedeemed > 0.0) {
return UITableView.automaticDimension
// } else {
// return 0.0
// }
} else if (indexPath.section == 1) {
// TODO: Uncomment if we want to show emptyView again
// if (self.showEmptyView == true) {
// return UITableView.automaticDimension
// } else {
return 0.0
// }
} else if (indexPath.section == 2) {
return UITableView.automaticDimension
}
// else if (indexPath.section == 2) {
// let sumRedeemed = totalCouponValue + totalCouponDiscount + unifiedCouponsDiscount
// if (sumRedeemed > 0.0) {
// return UITableView.automaticDimension
// } else {
// return 0.0
// }
// }
else if (indexPath.section == 3) {
if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
return UITableView.automaticDimension
} else {
return 0.0
}
} else if (indexPath.section == 4) {
if (self.showSpinner == true) {
return UITableView.automaticDimension
} else {
return 0.0
}
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
// if (section == 0){
// return nil
//
// } else if (section == 1) {
// if (self.unifiedCoupons.count > 0) {
// let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 75))
// view.backgroundColor = .clear
//
// let titleLabel = UILabel(frame: CGRect(x: 20, y: 40, width: view.frame.width - 40, height: 20))
// titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 19)
// titleLabel.textColor = UIColor(red: 0.00, green: 0.65, blue: 0.89, alpha: 1.00)
// titleLabel.text = "SUPERMARKET DEALS"
//
// view.addSubview(titleLabel)
// return view
// } else {
// return nil
// }
//
//
// } else if (section == 2) {
// if (self.dfyCoupons.count > 0) {
// let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 65))
// view.backgroundColor = .clear
//
// let imageView = UIImageView(frame: CGRect(x: 20, y: 30, width: view.frame.width / 2, height: 25))
// imageView.contentMode = .scaleAspectFit
//// imageView.backgroundColor = .red
//
// if let dfyHeaderImage = UIImage(named: "dfy_logo_colored", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) {
// imageView.image = dfyHeaderImage
// }
// view.addSubview(imageView)
//
// return view
//
// } else {
// return nil
// }
//
//
// } else if (section == 3) {
// if (self.coupons.count > 0) {
// // let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 71))
// let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 65))
// view.backgroundColor = .clear
//
// // let titleLabel = UILabel(frame: CGRect(x: 20, y: 40, width: view.frame.width - 40, height: 21))
// let titleLabel = UILabel(frame: CGRect(x: 20, y: 30, width: view.frame.width - 40, height: 20))
// titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 19)
// titleLabel.textColor = UIColor(red: 0.00, green: 0.65, blue: 0.89, alpha: 1.00)
// titleLabel.text = "GIFTS FOR YOU"
//
// view.addSubview(titleLabel)
// return view
// } else {
// return nil
// }
//
// } else {
// return nil
// }
if (section == 0) {
// if (self.dfyCoupons.count > 0 || self.unifiedCoupons.count > 0 || self.coupons.count > 0) {
// let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 70))
// view.backgroundColor = .clear
//
// let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: view.frame.width - 40, height: 25))
//// titleLabel.font = UIFont(name: "PeridotPE-SBold", size: 21)
// titleLabel.font = UIFont(name: "BTCosmo-Bold", size: 19)
// titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
// titleLabel.text = "Κουπόνια"
//
// view.addSubview(titleLabel)
// return view
// } else {
return nil
// }
} else if (section == 1) {
return nil
} else if (section == 2) {
return nil
} else if (section == 3) {
// if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
// let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 70))
// view.backgroundColor = .clear
// let separatorView = UIView(frame: CGRect(x: 20, y: 25, width: tableView.frame.width - 40, height: 1))
// separatorView.backgroundColor = UIColor(red: 0.62, green: 0.62, blue: 0.61, alpha: 1.00)
//
// let titleLabel = UILabel(frame: CGRect(x: 20, y: 20, width: view.frame.width - 40, height: 25))
// titleLabel.font = UIFont(name: "PeridotPE-SBold", size: 21)
// titleLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
// titleLabel.text = "Υπόλοιπο επιδότησης"
//
// view.addSubview(titleLabel)
// return view
// } else {
return nil
// }
} else if (section == 4) {
return nil
} else {
return nil
}
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
// if (section == 0) {
// return 0.0
//
// } else if (section == 1) {
// if (self.unifiedCoupons.count > 0) {
// return 75.0
// } else {
// return 0.0
// }
//
// } else if (section == 2) {
// if (self.dfyCoupons.count > 0) {
// return 68.0
// } else {
// return 0.0
// }
//
// } else if (section == 3) {
// if (self.coupons.count > 0) {
// return 65.0
// } else {
// return 0.0
// }
// } else {
// return 0.0
// }
if (section == 0) {
// if (self.dfyCoupons.count > 0 || self.unifiedCoupons.count > 0 || self.coupons.count > 0) {
// return 70.0
// } else {
return 0.0
// }
} else if (section == 1) {
return 0.0
} else if (section == 2) {
return 0.0
} else if (section == 3) {
// if (swiftApi().getShowVouchersBanner() == "true" || swiftApi().getShowVouchersBanner() == "false") {
// return 70.0
// } else {
return 0.0
// }
} else if (section == 4) {
return 0.0
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
// return CGFloat.leastNormalMagnitude
return 0.0
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return nil
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// if (indexPath.section == 0) {
// let cell = tableView.dequeueReusableCell(withIdentifier: "WalletBannersTableViewCellId", for: indexPath) as! WalletBannersTableViewCell
// cell.configureCell(totalCouponValue: self.totalCouponValue, totalCouponDiscount: self.totalCouponDiscount, unifiedCouponsDiscount: self.unifiedCouponsDiscount, forYouExpanded: self.forYouExpanded)
// return cell
//// let cell = tableView.dequeueReusableCell(withIdentifier: "WalletBadgesTableViewCellId", for: indexPath) as! WalletBadgesTableViewCell
//// cell.configureCell(totalCouponValue: self.totalCouponValue, totalCouponDiscount: self.totalCouponDiscount, unifiedCouponsDiscount: self.unifiedCouponsDiscount)
//// return cell
// } else if (indexPath.section == 1) {
// let cell = tableView.dequeueReusableCell(withIdentifier: "UnifiedCouponsTableViewCellId", for: indexPath) as! UnifiedCouponsTableViewCell
// cell.configureCell(coupon: unifiedCoupons[indexPath.row])
// return cell
//
// } else if (indexPath.section == 2) {
// let cell = tableView.dequeueReusableCell(withIdentifier: "ActiveCodeTableViewCellId", for: indexPath) as! ActiveCodeTableViewCell
//// cell.configureCell(coupon: coupons[indexPath.row])
// return cell
//
// } else {
// let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
// cell.configureCell(coupon: coupons[indexPath.row])
// return cell
// }
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletActiveCouponsScrollTableViewCellId", for: indexPath) as! WalletActiveCouponsScrollTableViewCell
// cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: self.unifiedCoupons.count, gfyCount: self.coupons.count, boxCount: self.boxCoupons.count)
// let smCount = self.unifiedCoupons.count + self.smCoupons.count
let smCount = 1
cell.configureCell(dfyCount: self.dfyCoupons.count, smCount: smCount, gfyCount: self.coupons.count, boxCount: 0)
cell.parent = self
return cell
} else if (indexPath.section == 1) {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletEmptyViewTableViewCellId", for: indexPath) as! WalletEmptyViewTableViewCell
return cell
} else if (indexPath.section == 2) {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletQuestionnaireBannerTableViewCellId", for: indexPath) as! WalletQuestionnaireBannerTableViewCell
cell.configureCell(isCentered: self.showEmptyView)
return cell
}
// else if (indexPath.section == 2) {
// let cell = tableView.dequeueReusableCell(withIdentifier: "WalletHistoryBannerTableViewCellId", for: indexPath) as! WalletHistoryBannerTableViewCell
// return cell
// }
else if (indexPath.section == 3) {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletVouchersBannerTableViewCellId", for: indexPath) as! WalletVouchersBannerTableViewCell
cell.configureCell(showSeparator: self.showActiveCouponsBanners, active: swiftApi().getShowVouchersBanner() == "true")
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "WalletSpinnerTableViewCellId", for: indexPath) as! WalletSpinnerTableViewCell
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
// if (indexPath.section == 0) {
// // Do nothing
//
// } else if (indexPath.section == 1) {
// // TODO: Add trackers
//// let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
//// let couponName = couponSetData?.name ?? ""
//// swiftApi().logTrackersEvent("click", ("Coupon:" + couponName))
//
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "UnifiedCouponBarcodeViewController") as! SwiftWarplyFramework.UnifiedCouponBarcodeViewController
// vc.coupon = unifiedCoupons[indexPath.row]
// vc.isFromWallet = true
// self.navigationController?.pushViewController(vc, animated: true)
//
// } else if (indexPath.section == 2) {
// print("Active DFY coupon banner Tapped!")
//
// swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "ActiveDealsBanner"))
//
// let couponDetails = swiftApi.ActiveDFYCouponEventModel()
// couponDetails._isPressed = true
// SwiftEventBus.post("dfy_coupon_details", sender: couponDetails)
//
// } else if (indexPath.section == 3) {
// let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
// let couponName = couponSetData?.name ?? ""
// swiftApi().logTrackersEvent("click", ("Coupon:" + couponName))
//
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController
// vc.coupon = coupons[indexPath.row]
// vc.isFromWallet = true
// self.navigationController?.pushViewController(vc, animated: true)
// } else {
// // Do nothing
// }
if (indexPath.section == 0) {
// Do nothing - Each button is handled differently
} else if (indexPath.section == 1) {
// Do nothing
} else if (indexPath.section == 2) {
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "Questionnaire"))
swiftApi().openQuestionnaire(self);
}
// else if (indexPath.section == 2) {
// let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
// firebaseEvent._eventName = "did_tap_history_badge"
// firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
// SwiftEventBus.post("firebase", sender: firebaseEvent)
//
// swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "LoyaltyHistoryBadge"))
//
// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
// let vc = storyboard.instantiateViewController(withIdentifier: "LoyaltyHistoryViewController") as! SwiftWarplyFramework.LoyaltyHistoryViewController
// self.navigationController?.pushViewController(vc, animated: true)
//
// }
else if (indexPath.section == 3) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
firebaseEvent._eventName = "did_tap_vouchers_badge"
firebaseEvent.setParameter = ("screen", "Loyalty Wallet")
SwiftEventBus.post("firebase", sender: firebaseEvent)
swiftApi().logTrackersEvent("click", ("LoyaltyWalletScreen:" + "VouchersBadge"))
SwiftEventBus.post("vouchers_banner_pressed")
} else if (indexPath.section == 4) {
// Do nothing
} else {
// Do nothing
}
}
}
//
// WalletVouchersBannerTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 23/10/23.
//
import UIKit
@objc public class WalletVouchersBannerTableViewCell: UITableViewCell {
@IBOutlet weak var separatorView: UIView!
@IBOutlet weak var separatorTopSpace: NSLayoutConstraint!
@IBOutlet weak var sectionTitleLabel: UILabel!
@IBOutlet weak var voucherBannerView: UIView!
@IBOutlet weak var voucherBannerIconImage: UIImageView!
@IBOutlet weak var voucherBannerLabel: UILabel!
@IBOutlet weak var voucherBannerArrowImage: UIImageView!
@IBOutlet weak var voucherCountView: UIView!
let language = swiftApi().getLanguage()
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
sectionTitleLabel.text = language == "en" ? "Subsidy balance" : "Υπόλοιπο επιδότησης"
voucherBannerView.layer.cornerRadius = 16.0
voucherBannerView.layer.borderWidth = 1
voucherBannerView.layer.borderColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// Add shadow
voucherBannerView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
voucherBannerView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
voucherBannerView.layer.shadowOpacity = 1.0
voucherBannerView.layer.shadowRadius = 1.0
voucherBannerIconImage.image = UIImage(named: "wallet_voucher", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
voucherBannerArrowImage.image = UIImage(named: "arrow_right_black", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// voucherBannerLabel.text = "Ενημερώσου για το υπόλοιπο επιδότησης"
voucherCountView.layer.cornerRadius = 4.0
voucherCountView.backgroundColor = UIColor(red: 0.92, green: 0.75, blue: 0.41, alpha: 1.00)
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
func configureCell(showSeparator: Bool, active: Bool) {
if (showSeparator == true) {
separatorView.isHidden = false
separatorTopSpace.constant = 25
} else {
separatorView.isHidden = true
separatorTopSpace.constant = 0
}
if (active == true) {
voucherBannerView.backgroundColor = .white
voucherBannerIconImage.image = voucherBannerIconImage.image?.withRenderingMode(.alwaysTemplate)
voucherBannerIconImage.tintColor = UIColor(red: 0.00, green: 0.65, blue: 0.89, alpha: 1.00)
voucherBannerLabel.text = language == "en" ? "Check the available balance" : "Δες το διαθέσιμο υπόλοιπο"
voucherBannerLabel.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
voucherBannerLabel.frame.size.width = voucherBannerLabel.intrinsicContentSize.width
voucherCountView.isHidden = true
} else {
voucherBannerView.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
voucherBannerIconImage.image = voucherBannerIconImage.image?.withRenderingMode(.alwaysTemplate)
voucherBannerIconImage.tintColor = UIColor(red: 0.52, green: 0.52, blue: 0.52, alpha: 1.00)
voucherBannerLabel.text = language == "en" ? "Available balance" : "Διαθέσιμο υπόλοιπο"
voucherBannerLabel.textColor = UIColor(red: 0.52, green: 0.52, blue: 0.52, alpha: 1.00)
voucherBannerLabel.frame.size.width = voucherBannerLabel.intrinsicContentSize.width
voucherCountView.isHidden = false
}
}
}
......@@ -303,8 +303,6 @@ WL_VERSION_INTERFACE()
- (BOOL)getInboxWithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure;
- (BOOL)getInbox2WithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure;
- (BOOL)getCampaignsWithSuccessBlock:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getCampaignsPersonalizedWithSuccessBlock:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
......@@ -345,23 +343,8 @@ WL_VERSION_INTERFACE()
- (void)changePasswordWithSuccessBlock:(NSString*)oldPassword andNewPassword:(NSString*)newPassword :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMarketPassDetailsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)postEventWithSuccessBlock :(NSString*)Session_ID :(NSString*)OfferAudienceLevel :(NSString*)msisdn :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getPacingDetailsWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)setPacingDetailsWithSuccessBlock:(NSNumber*)steps :(NSString*)date :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)editProfileWithSuccessBlock:(NSString*)firstName andLastName:(NSString*)lastName andEmail:(NSString*)email andSalutation:(NSString*)salutation andMsisdn:(NSString*)msisdn
andNickname:(NSString*)nickname andGender:(NSString*)gender andBirthday:(NSString*)birthday andNameDay:(NSString*)nameday andTaxID:(NSString*)taxID andProfileMetadata:(NSDictionary*)profileMetadata optin:(NSNumber*) optin newsLetter:(NSNumber*)newsletter
andSMS:(NSNumber*)sms andSegmentation:(NSNumber*)segmentation andSMSSegmentation:(NSNumber*)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)consumerIntegrationWithSuccessBlock:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)changeProfileImageWithSuccessBlock:(NSString*)image andUserId:(NSString*)userId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......@@ -371,22 +354,12 @@ WL_VERSION_INTERFACE()
- (void)deleteCardWithSuccessBlock:(NSString*)token :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCouponsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCouponsUniversalWithSuccessBlock:(NSString*)language :(NSString*)couponsetType :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)createUnifiedCouponWithSuccessBlock:(NSArray*)couponCodes :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getUnifiedCouponsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getTransactionHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getPointsHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMarketSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)verifyTicketWithSuccessBlock:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCosmoteUserWithSuccessBlock:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......@@ -413,30 +386,12 @@ WL_VERSION_INTERFACE()
- (void) getAvailableCouponsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) getCouponSetsDealsWithSuccessBlock:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) cancelUnifiedCouponWithSuccessBlock:(NSString*) transactionId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(NSString*)communication_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) cosmoteCouponSharingWithSuccessBlock:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) cosmoteSharingWithSuccessBlock:(NSString*) sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) cosmoteRetrieveSharingWithSuccessBlock:(NSString*) sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) submitOrderWithSuccessBlock:(NSString*) campaign_session_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(NSString*)notificationMessage :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getSingleCampaignWithSuccessBlock:(NSString *)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMapDataWithSuccessBlock:(NSString *)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
/*!
@abstract Get the full page add accordint to the display_type of a campaign.
@attributeblock successBlock This block is called when getInbox is sucessful and allOffers is empty or nil and returns an array with the available WLInboxItem items. Otherwise, the allOffers array is filtered.
......
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.