Manos Chorianopoulos

add OldCouponsView

......@@ -11,6 +11,8 @@
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 */; };
......@@ -149,6 +151,8 @@
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>"; };
......@@ -346,6 +350,8 @@
E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */,
1EBEB02C280D69D800BF802C /* GiftsView.swift */,
1E98EC1328199C4F007524A0 /* AllGiftsView.swift */,
1E879E24281AC96A0089F489 /* OldCouponsView.swift */,
1E879E26281AC99F0089F489 /* OldCouponsViewInterface.swift */,
1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */,
1E735FF1281067320050A298 /* CampaignWebview.swift */,
1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */,
......@@ -753,6 +759,7 @@
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 */,
......@@ -781,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 */,
......
......@@ -56,6 +56,15 @@ class DataModel {
})
}
}
var getOldCoupons: Array<NSDictionary> {
get { // getter
return data.filter({
let couponData = $0["coupon_data"] as? [String: Any] ?? ["":""]
return couponData["status"] as? Int != 1
})
}
}
}
class ImageLoader: ObservableObject {
......
......@@ -22,6 +22,7 @@
- (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;
......
......@@ -77,6 +77,12 @@ NSString *LANG;
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!))
}
}