Vasilis
No preview for this file type
......@@ -7,7 +7,7 @@
<key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -11,6 +11,10 @@
1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */; };
1E735FF2281067320050A298 /* CampaignWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF1281067320050A298 /* CampaignWebview.swift */; };
1E735FF42810681E0050A298 /* CampaignWebviewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */; };
1E879E25281AC96A0089F489 /* OldCouponsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E24281AC96A0089F489 /* OldCouponsView.swift */; };
1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */; };
1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; };
1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */; };
1EBEB02D280D69D800BF802C /* GiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02C280D69D800BF802C /* GiftsView.swift */; };
1EBEB02F280D6AA500BF802C /* GiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */; };
260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1353B8C484CC0649CAC2EB74 /* Pods_WarplySDKFrameworkIOS.framework */; };
......@@ -147,6 +151,10 @@
1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewInterface.swift; sourceTree = "<group>"; };
1E735FF1281067320050A298 /* CampaignWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebview.swift; sourceTree = "<group>"; };
1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebviewInterface.swift; sourceTree = "<group>"; };
1E879E24281AC96A0089F489 /* OldCouponsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsView.swift; sourceTree = "<group>"; };
1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OldCouponsViewInterface.swift; sourceTree = "<group>"; };
1E98EC1328199C4F007524A0 /* AllGiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsView.swift; sourceTree = "<group>"; };
1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsViewInterface.swift; sourceTree = "<group>"; };
1EBEB02C280D69D800BF802C /* GiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsView.swift; sourceTree = "<group>"; };
1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsViewInterface.swift; sourceTree = "<group>"; };
B9413513157AD76ECE896B81 /* Pods-WarplySDKFrameworkIOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WarplySDKFrameworkIOS.release.xcconfig"; path = "Target Support Files/Pods-WarplySDKFrameworkIOS/Pods-WarplySDKFrameworkIOS.release.xcconfig"; sourceTree = "<group>"; };
......@@ -341,6 +349,10 @@
E639EFA0280810E300B9DD94 /* CouponsView.swift */,
E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */,
1EBEB02C280D69D800BF802C /* GiftsView.swift */,
1E98EC1328199C4F007524A0 /* AllGiftsView.swift */,
1E879E24281AC96A0089F489 /* OldCouponsView.swift */,
1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */,
1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */,
1E735FF1281067320050A298 /* CampaignWebview.swift */,
1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */,
1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */,
......@@ -747,12 +759,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1E879E27281AC99F0089F489 /* OldCouponsViewInterface.swift in Sources */,
E6D8DF0B27A942920006A3A9 /* WLEvent.m in Sources */,
E6D8DF1E27A942920006A3A9 /* UIViewController+WLAdditions.m in Sources */,
E6D8DF2E27A942920006A3A9 /* UIRefreshControl+AFNetworking.m in Sources */,
E6D8DF4827A942920006A3A9 /* AFURLRequestSerialization.m in Sources */,
E67D1EC228113EED00940F01 /* CouponView.swift in Sources */,
1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */,
1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */,
E6D8DEF327A942920006A3A9 /* WLNativeVideoTableViewCell.m in Sources */,
E6D8DF2527A942920006A3A9 /* WLSMSActionHanlder.m in Sources */,
E67D1EBE2810573900940F01 /* WalletView.swift in Sources */,
......@@ -774,6 +788,7 @@
E6D8DF1327A942920006A3A9 /* WLBeaconManager.m in Sources */,
E6D8DF0427A942920006A3A9 /* WLInboxItem.m in Sources */,
E6D8DF5127A942920006A3A9 /* FMDatabaseAdditions.m in Sources */,
1E879E25281AC96A0089F489 /* OldCouponsView.swift in Sources */,
E6D8DF2127A942920006A3A9 /* WLAPPActionHandler.m in Sources */,
E6D8DF5627A942920006A3A9 /* FMDatabasePool.m in Sources */,
E6D8DF4527A942920006A3A9 /* AFHTTPSessionManager.m in Sources */,
......@@ -786,6 +801,7 @@
E6D8DF2C27A942920006A3A9 /* UIProgressView+AFNetworking.m in Sources */,
E6D8DF3C27A942920006A3A9 /* UIWebView+AFNetworking.m in Sources */,
E639EFA2280810E300B9DD94 /* CouponsView.swift in Sources */,
1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */,
E6D8DF1427A942920006A3A9 /* WLLocationManager.m in Sources */,
E6D8DF6027A9429E0006A3A9 /* MyApi.m in Sources */,
E6D8DF3F27A942920006A3A9 /* AFImageDownloader.m in Sources */,
......
......@@ -7,7 +7,7 @@
<key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
//
// AllGiftsView.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 27/4/22.
//
#if canImport(SwiftUI)
import SwiftUI
import Combine
import Foundation
import UIKit
extension AllGiftsView {
struct headerView: View {
var goBack: () -> ()
var uiscreen = UIScreen.main.bounds
var body: some View {
HStack(alignment: .center) {
Button {
// Button Action
print("Back Button tapped!")
goBack()
} label: {
Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
}
Text("Όλα τα δώρα μου")
.fontWeight(.medium)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196))
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity)
.padding(.horizontal)
}
.frame(maxWidth: .infinity)
.padding(.horizontal)
.padding(.vertical, 10)
}
}
struct ImageView: View {
@ObservedObject var imageLoader:UrlImageModel
@State var width:CGFloat
@State var isFill:Bool
var uiscreen = UIScreen.main.bounds
init(withURL url:String , width:CGFloat, isFill:Bool) {
imageLoader = UrlImageModel(urlString:url)
self.width = width
self.isFill = isFill
}
var body: some View {
Image(uiImage: imageLoader.image ?? UIImage())
.resizable()
.aspectRatio(contentMode: isFill ? .fill : .fit)
.frame(width: self.width)
.frame(maxHeight: .infinity)
}
}
struct giftItemView: View {
var item: NSDictionary
var parentView: UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
Button {
// GiftItem Action
let instanceOfMyApi = MyApi()
let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: item as! [String : Any])!
couponBarcodeViewController.view.tag = 7
// addChild(couponsViewController)
couponBarcodeViewController.view.frame = parentView.frame
parentView.addSubview(couponBarcodeViewController.view)
couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self))
} label: {
HStack(alignment: .center, spacing: 0.0) {
ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.5, isFill: true)
VStack(alignment: .leading, spacing: 5.0) {
Text(item["name"] as? String ?? "")
.fontWeight(.bold)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
.multilineTextAlignment(.leading)
.padding([.top,.horizontal], 15)
.background(Color.white)
Text(item["short_description"] as? String ?? "")
.fontWeight(.regular)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
.multilineTextAlignment(.leading)
.padding([.bottom,.horizontal], 15)
.background(Color.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.background(Color.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.background(Color.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.frame(width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.17)
.background(Color.white)
.cornerRadius(5)
.shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 6, x: 0, y: 3)
}
}
struct couponsContainer: View {
@State var coupons:Array<NSDictionary> = []
@State var parentView:UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) {
ForEach(Array(coupons.enumerated()), id: \.offset) { index, item in
giftItemView(item: item, parentView: parentView)
}
}
.frame(maxWidth: .infinity)
.padding(.top, self.uiscreen.height * 0.05)
.padding(.bottom, self.uiscreen.height * 0.1)
}
}
}
@available(iOS 13.0.0, *)
struct AllGiftsView: View {
var parentView: UIView
var coupons:Array<NSDictionary> = DataModel().getData
var uiscreen = UIScreen.main.bounds
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 8) {
subview.removeFromSuperview()
}
}
}
var body: some View {
VStack {
headerView(goBack: goBack)
VStack {
ScrollView(showsIndicators: false) {
VStack {
if (coupons.count) > 0 {
couponsContainer(coupons: coupons, parentView: parentView )
}
}
.frame(width:self.uiscreen.width)
}
.cornerRadius(30, corners: [.topLeft])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
.padding(.top, 5)
.background(
Image("coupons_scrollview", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
)
}
.edgesIgnoringSafeArea([.bottom])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
}
#endif
//struct AllGiftsView_Previews: PreviewProvider {
// static var previews: some View {
// AllGiftsView()
// }
//}
//
// AllGiftsViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 27/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class AllGiftsViewInterface : NSObject {
@objc(allGiftsViewController:) static public func allGiftsViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: AllGiftsView(parentView: parentView!))
}
}
......@@ -56,7 +56,7 @@ extension CouponBarcodeView {
static func convertDateFormat(inputDate: String) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd hh:mm"
dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
if let date = dateFormatter.date(from: inputDate) {
dateFormatter.dateFormat = "dd/MM/yyyy"
let resultString = dateFormatter.string(from: date)
......@@ -97,6 +97,8 @@ extension CouponBarcodeView {
var body: some View {
let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""]
GeometryReader { geometry in
ScrollView(showsIndicators: false) {
VStack(alignment: .leading) {
......@@ -111,6 +113,7 @@ extension CouponBarcodeView {
.multilineTextAlignment(.leading)
.padding(.horizontal)
.padding(.top, self.uiscreen.height * 0.04)
.frame(maxHeight: .infinity)
Text(coupon["short_description"] as? String ?? "")
.fontWeight(.regular)
......@@ -131,7 +134,7 @@ extension CouponBarcodeView {
VStack(alignment: .center) {
VStack {
Text("1A2C378")
Text(couponData["coupon"] as? String ?? "")
.fontWeight(.bold)
.font(.system(size: 27))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -146,7 +149,7 @@ extension CouponBarcodeView {
}
.frame(maxWidth: .infinity)
if (CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: coupon["coupon"] as? String ?? ""))) {
if (CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: couponData["coupon"] as? String ?? ""))) {
VStack(alignment: .center) {
VStack {}
.frame(height: 1)
......@@ -194,7 +197,7 @@ extension CouponBarcodeView {
// .aspectRatio(contentMode: .fit)
// .frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.1)
Text(coupon["coupon"] as? String ?? "")
Text(couponData["coupon"] as? String ?? "")
.fontWeight(.regular)
.font(.system(size: 22))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -215,7 +218,7 @@ extension CouponBarcodeView {
Text("Το κουπόνι ισχύει έως " + CouponBarcodeView.couponContainer.convertDateFormat(inputDate: coupon["expiration"] as? String ?? ""))
Text("Το κουπόνι ισχύει έως " + CouponBarcodeView.couponContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? ""))
.fontWeight(.medium)
.font(.system(size: 14))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -296,7 +299,7 @@ extension CouponBarcodeView {
}
.frame(width:self.uiscreen.width)
.frame(minHeight: geometry.size.height)
// .frame(minHeight: geometry.size.height)
.padding(.bottom, self.uiscreen.height * 0.03)
}
.frame(width:self.uiscreen.width)
......
......@@ -32,7 +32,9 @@ class DataModel {
// var temp = NSMutableDictionary(dictionary: s);
if c["couponset_uuid"] as! String == s["uuid"] as! String {
var temp = NSMutableDictionary(dictionary: s);
temp.addEntries(from: c as! [AnyHashable : Any])
// temp.addEntries(from: c as! [AnyHashable : Any])
temp.setValue(c as! [AnyHashable : Any],forKey: "coupon_data")
self.data.append(temp as NSDictionary)
}
......@@ -48,7 +50,19 @@ class DataModel {
var getData: Array<NSDictionary> {
get { // getter
return data.filter({ $0["status"] as! String == "1" })
return data.filter({
let couponData = $0["coupon_data"] as? [String: Any] ?? ["":""]
return couponData["status"] as? Int == 1
})
}
}
var getOldCoupons: Array<NSDictionary> {
get { // getter
return data.filter({
let couponData = $0["coupon_data"] as? [String: Any] ?? ["":""]
return couponData["status"] as? Int != 1
})
}
}
}
......@@ -118,6 +132,8 @@ extension CouponsView {
}
}
Text("Όλα τα κουπόνια μου")
.fontWeight(.medium)
.foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196))
.frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
.offset( y: self.uiscreen.height * 0.02)
.font(.system(size: 15))
......@@ -129,6 +145,7 @@ extension CouponsView {
struct couponView: View {
var result: NSDictionary
var index: Int
var parentView: UIView
var uiscreen = UIScreen.main.bounds
......@@ -149,42 +166,62 @@ extension CouponsView {
}
var body: some View {
let couponData = result["coupon_data"] as? [String: Any] ?? ["":""]
VStack(alignment: .leading) {
HStack(alignment: .center) {
ImageView(withURL: result["img_preview"] as! String)
.frame(maxWidth: self.uiscreen.width * 0.15)
.padding(.leading , self.uiscreen.width * 0.055)
VLine()
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5]))
.foregroundColor(Color(red: 0.4392156862745098, green: 0.4392156862745098, blue: 0.4392156862745098))
.frame(width: 1)
.padding(.leading, self.uiscreen.width * 0.01)
.padding(.top, self.uiscreen.height * 0.01)
.padding(.bottom, self.uiscreen.height * 0.0075)
Spacer()
VStack {
Text(CouponsView.couponView.localizedWithParameter(parameter: result["admin_name"] as? String ?? ""))
.frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading)
.font(.system(size: 15))
Text(CouponsView.couponView.localizedWithParameter(parameter: result["discount"] as? String ?? ""))
.frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: self.uiscreen.height * 0.05, alignment: .leading)
.font(.system(size: 47))
Text(CouponsView.couponView.localizedWithParameter(parameter: "Ισχύει εώς " + CouponsView.couponView.convertDateFormat(inputDate: result["expiration"] as? String ?? "")))
.frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading)
.font(.system(size: 10))
}
.frame(maxHeight: .infinity)
.padding(.top, self.uiscreen.height * 0.03)
.padding(.bottom, self.uiscreen.height * 0.03)
VStack {
Text(CouponsView.couponView.localizedWithParameter(parameter: result["short_description"] as! String))
.frame(maxWidth: self.uiscreen.width * 0.22, maxHeight: self.uiscreen.height * 0.10)
.font(.system(size: 10))
Button {
// GiftItem Action
let instanceOfMyApi = MyApi()
let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: result as! [String : Any])!
couponBarcodeViewController.view.tag = 7
// addChild(couponsViewController)
couponBarcodeViewController.view.frame = parentView.frame
parentView.addSubview(couponBarcodeViewController.view)
couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self))
} label: {
HStack(alignment: .center) {
ImageView(withURL: result["img_preview"] as! String)
.frame(maxWidth: self.uiscreen.width * 0.15)
.padding(.leading , self.uiscreen.width * 0.055)
VLine()
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5]))
.foregroundColor(Color(red: 0.4392156862745098, green: 0.4392156862745098, blue: 0.4392156862745098))
.frame(width: 1)
.padding(.leading, self.uiscreen.width * 0.01)
.padding(.top, self.uiscreen.height * 0.01)
.padding(.bottom, self.uiscreen.height * 0.0075)
Spacer()
VStack {
Text(CouponsView.couponView.localizedWithParameter(parameter: result["name"] as? String ?? ""))
.fontWeight(.medium)
.foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
.frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading)
.font(.system(size: 15))
Text(CouponsView.couponView.localizedWithParameter(parameter: couponData["discount"] as? String ?? ""))
.fontWeight(.bold)
.foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
.frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: self.uiscreen.height * 0.05, alignment: .leading)
.font(.system(size: 47))
Text(CouponsView.couponView.localizedWithParameter(parameter: "Ισχύει εώς " + CouponsView.couponView.convertDateFormat(inputDate: couponData["expiration"] as? String ?? "")))
.fontWeight(.medium)
.foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
.frame(maxWidth: self.uiscreen.width * 0.35, maxHeight: .infinity, alignment: .leading)
.font(.system(size: 10))
}
.frame(maxHeight: .infinity)
.padding(.top, self.uiscreen.height * 0.03)
.padding(.bottom, self.uiscreen.height * 0.03)
VStack {
Text(CouponsView.couponView.localizedWithParameter(parameter: result["short_description"] as! String))
.fontWeight(.medium)
.foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
.frame(maxWidth: self.uiscreen.width * 0.22, maxHeight: self.uiscreen.height * 0.10)
.font(.system(size: 10))
}
.frame(maxWidth: self.uiscreen.width * 0.25, maxHeight: .infinity)
Spacer()
}
.frame(maxWidth: self.uiscreen.width * 0.25, maxHeight: .infinity)
Spacer()
}
}
.frame(width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.13)
......@@ -223,7 +260,8 @@ struct CouponsView: View {
VStack {
if (data.count) > 0 {
ForEach(Array(zip(data.indices, data)), id: \.0) { index, result in
couponView(result: result, index: index) }
couponView(result: result, index: index, parentView: parentView)
}
}
}
.padding(.top, self.uiscreen.height * 0.05)
......
......@@ -21,6 +21,8 @@
- (UIViewController *) openCoupon:(UIView*) parentView coupon:(NSDictionary*) coupon;
- (UIViewController *) openCouponBarcode:(UIView*) parentView coupon:(NSDictionary*) coupon;
- (UIViewController *) openGifts:(UIView*) parentView;
- (UIViewController *) openAllGifts:(UIView*) parentView;
- (UIViewController *) openOldCoupons:(UIView*) parentView;
- (UIViewController *) openWallet:(UIView*) parentView;
- (UIViewController *) openMoreForYou:(UIView*) parentView;
- (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign;
......
......@@ -71,6 +71,18 @@ NSString *LANG;
return giftsViewController;
}
- (UIViewController *) openAllGifts:(UIView*) parentView{
UIViewController *allGiftsViewController = [AllGiftsViewInterface allGiftsViewController:parentView];
return allGiftsViewController;
}
- (UIViewController *) openOldCoupons:(UIView*) parentView{
UIViewController *oldCouponsViewController = [OldCouponsViewInterface oldCouponsViewController:parentView];
return oldCouponsViewController;
}
- (UIViewController *) openWallet:(UIView*) parentView{
UIViewController *wallletViewController = [WalletViewInterface walletViewController:parentView];
......
//
// OldCouponsView.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 28/4/22.
//
#if canImport(SwiftUI)
import SwiftUI
import Combine
import Foundation
import UIKit
extension OldCouponsView {
struct headerView: View {
var goBack: () -> ()
var uiscreen = UIScreen.main.bounds
var body: some View {
HStack(alignment: .center) {
Button {
// Button Action
print("Back Button tapped!")
goBack()
} label: {
Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
}
Text("Παλαιότερα κουπόνια")
.fontWeight(.medium)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196))
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity)
.padding(.horizontal)
Button {
// Button Action
print("Wallet tapped!")
} label: {
Image("ic_wallet", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04)
}
}
.frame(maxWidth: .infinity)
.padding(.horizontal)
.padding(.vertical, 10)
}
}
struct ImageView: View {
@ObservedObject var imageLoader:UrlImageModel
@State var width:CGFloat
@State var isFill:Bool
var uiscreen = UIScreen.main.bounds
init(withURL url:String , width:CGFloat, isFill:Bool) {
imageLoader = UrlImageModel(urlString:url)
self.width = width
self.isFill = isFill
}
var body: some View {
Image(uiImage: imageLoader.image ?? UIImage())
.resizable()
.aspectRatio(contentMode: isFill ? .fill : .fit)
.frame(width: self.width)
.frame(maxHeight: .infinity)
}
}
struct couponItemView: View {
var item: NSDictionary
var parentView: UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
let couponData = item["coupon_data"] as? [String: Any] ?? ["":""]
Button {
// Coupon Action
print("Coupon tapped!")
// let instanceOfMyApi = MyApi()
// let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: item as! [String : Any])!
// couponBarcodeViewController.view.tag = 7
//// addChild(couponsViewController)
// couponBarcodeViewController.view.frame = parentView.frame
// parentView.addSubview(couponBarcodeViewController.view)
// couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self))
} label: {
HStack(alignment: .center) {
ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.15, isFill: false)
VLine()
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5]))
.foregroundColor(Color(red: 0.4392156862745098, green: 0.4392156862745098, blue: 0.4392156862745098))
.frame(width: 1)
.padding(.leading, 10)
VStack(alignment: .leading, spacing: 5.0) {
Text(item["name"] as? String ?? "")
.fontWeight(.medium)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
.multilineTextAlignment(.leading)
// .lineLimit(1)
HStack(alignment: .center) {
Text((couponData["discount"] as? String ?? "")+"€")
.fontWeight(.bold)
.font(.system(size: 35))
.foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
.multilineTextAlignment(.leading)
.lineLimit(1)
// Text(item["short_description"] as? String ?? "")
// .fontWeight(.medium)
// .font(.system(size: 11))
// .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
// .multilineTextAlignment(.leading)
// .lineLimit(3)
}
Text("Εξαργυρώθηκε την " + OldCouponsView.couponsContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? ""))
.fontWeight(.medium)
.font(.system(size: 11))
.foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
.multilineTextAlignment(.leading)
}
.padding(.all, 10)
Spacer()
}
.padding(.leading, 28)
.padding(.trailing)
}
.frame(width: self.uiscreen.width * 0.9, height: self.uiscreen.height * 0.14)
// .cornerRadius(5)
// .shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 30, x: 0, y: 3)
.background(
Image("coupon_bg", bundle: Bundle(for: MyEmptyClass.self))
.resizable(resizingMode: .stretch)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.colorMultiply(Color(red: 0.8901960784313725, green: 0.8901960784313725, blue: 0.8901960784313725))
)
}
}
struct VLine: Shape {
func path(in rect: CGRect) -> Path {
Path { path in
path.move(to: CGPoint(x: rect.midX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY))
}
}
}
struct couponsContainer: View {
@State var coupons:Array<NSDictionary> = []
@State var parentView:UIView
var uiscreen = UIScreen.main.bounds
static func convertDateFormat(inputDate: String) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
if let date = dateFormatter.date(from: inputDate) {
dateFormatter.dateFormat = "dd/MM/yyyy"
let resultString = dateFormatter.string(from: date)
return resultString
} else {
return ""
}
}
var body: some View {
VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) {
ForEach(Array(coupons.enumerated()), id: \.offset) { index, item in
couponItemView(item: item, parentView: parentView)
}
}
.frame(maxWidth: .infinity)
.padding(.top, self.uiscreen.height * 0.05)
.padding(.bottom, self.uiscreen.height * 0.1)
}
}
}
@available(iOS 13.0.0, *)
struct OldCouponsView: View {
var parentView: UIView
var coupons:Array<NSDictionary> = DataModel().getOldCoupons
var uiscreen = UIScreen.main.bounds
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 9) {
subview.removeFromSuperview()
}
}
}
var body: some View {
VStack {
headerView(goBack: goBack)
VStack {
ScrollView(showsIndicators: false) {
VStack {
if (coupons.count) > 0 {
couponsContainer(coupons: coupons, parentView: parentView )
}
}
.frame(width:self.uiscreen.width)
}
.cornerRadius(30, corners: [.topLeft])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
.padding(.top, 5)
.background(
Image("coupons_scrollview", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
)
}
.edgesIgnoringSafeArea([.bottom])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
}
#endif
//struct OldCouponsView_Previews: PreviewProvider {
// static var previews: some View {
// OldCouponsView()
// }
//}
//
// OldCouponsViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 28/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class OldCouponsViewInterface : NSObject {
@objc(oldCouponsViewController:) static public func oldCouponsViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: OldCouponsView(parentView: parentView!))
}
}