Manos Chorianopoulos

update OldCouponsView

......@@ -79,13 +79,14 @@ extension OldCouponsView {
}
struct couponItemView: View {
var item: NSDictionary
var item: swiftApi.CouponItemModel
var parentView: UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
let couponData = item["coupon_data"] as? [String: Any] ?? ["":""]
// let couponData = item["coupon_data"] as? [String: Any] ?? ["":""]
let couponSetData = item.couponset_data
Button {
// Coupon Action
......@@ -101,7 +102,7 @@ extension OldCouponsView {
HStack(alignment: .center) {
ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.15, isFill: false)
ImageView(withURL: couponSetData?.img_preview ?? "", width: self.uiscreen.width * 0.15, isFill: false)
VLine()
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5]))
......@@ -110,7 +111,7 @@ extension OldCouponsView {
.padding(.leading, 10)
VStack(alignment: .leading, spacing: 5.0) {
Text(item["name"] as? String ?? "")
Text(couponSetData?.name ?? "")
.fontWeight(.medium)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
......@@ -118,14 +119,14 @@ extension OldCouponsView {
// .lineLimit(1)
HStack(alignment: .center) {
Text((couponData["discount"] as? String ?? "")+"€")
Text((item.discount ?? "")+"€")
.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 ?? "")
// Text(couponSetData?.short_description ?? "")
// .fontWeight(.medium)
// .font(.system(size: 11))
// .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
......@@ -133,7 +134,7 @@ extension OldCouponsView {
// .lineLimit(3)
}
Text("Εξαργυρώθηκε την " + OldCouponsView.couponsContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? ""))
Text("Εξαργυρώθηκε την " + (item.expiration ?? ""))
.fontWeight(.medium)
.font(.system(size: 11))
.foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
......@@ -169,22 +170,22 @@ extension OldCouponsView {
}
struct couponsContainer: View {
@State var coupons:Array<NSDictionary> = []
@State var coupons:Array<swiftApi.CouponItemModel> = []
@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 ""
}
}
// 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) {
......@@ -206,10 +207,20 @@ extension OldCouponsView {
struct OldCouponsView: View {
var parentView: UIView
var coupons:Array<NSDictionary> = DataModel().getOldCoupons
var coupons:Array<swiftApi.CouponItemModel> = []
var uiscreen = UIScreen.main.bounds
init(parentView: UIView) { //initializer method
let instanceOfMySwiftApi = swiftApi()
let couponsData = instanceOfMySwiftApi.getOldCoupons()
self.coupons = couponsData
self.parentView = parentView
}
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 9) {
......
......@@ -6,7 +6,6 @@
//
import Foundation
import SwiftUI
public class swiftApi {
......@@ -26,22 +25,10 @@ public class swiftApi {
}
public func setCCMSLoyaltyCampaigns(campaigns: Array<LoyaltyContextualOfferModel>) {
public func setCCMSLoyaltyCampaigns(campaigns: Array<Dictionary<String, String>>) {
}
public class LoyaltyContextualOfferModel {
var sessionId: String
var eligibleAssets: Array<String>
var id: String
init(sessionId: String, eligibleAssets: Array<String>, id: String) {
self.sessionId = sessionId
self.eligibleAssets = eligibleAssets
self.id = id
}
}
public class CouponSetItemModel {
let uuid: String?
let admin_name: String?
......@@ -271,6 +258,10 @@ public class swiftApi {
return CouponsDataModel().getData
}
public func getOldCoupons() -> Array<CouponItemModel> {
return CouponsDataModel().getOldCoupons
}
public class CampaignItemModel {
let index_url: String?
let logo_url: String?
......@@ -339,12 +330,4 @@ public class swiftApi {
public func getCampaigns() -> Array<CampaignItemModel> {
return CampaignDataModel().getData
}
public func openCoupon(parent: UIView, coupon: CouponSetItemModel) -> UIViewController {
return UIHostingController(rootView: CouponView(parentView: parent, coupon: coupon))
}
public func openCouponBarcode(parent: UIView, coupon: CouponSetItemModel) -> UIViewController {
return UIHostingController(rootView: CouponBarcodeView(parentView: parent, coupon: coupon))
}
}
......