Manos Chorianopoulos

CouponsView fixes

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>
......
......@@ -7,7 +7,7 @@
<key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -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,10 @@ class DataModel {
var getData: Array<NSDictionary> {
get { // getter
return data.filter({ $0["status"] as! Int == 1 })
return data.filter({
let couponData = $0["coupon_data"] as? [String: Any] ?? ["":""]
return couponData["status"] as? Int == 1
})
}
}
}
......@@ -118,6 +123,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 +136,7 @@ extension CouponsView {
struct couponView: View {
var result: NSDictionary
var index: Int
var parentView: UIView
var uiscreen = UIScreen.main.bounds
......@@ -149,9 +157,20 @@ extension CouponsView {
}
var body: some View {
let couponData = result["coupon_data"] as? [String: Any] ?? ["":""]
VStack(alignment: .leading) {
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)
......@@ -165,13 +184,19 @@ extension CouponsView {
.padding(.bottom, self.uiscreen.height * 0.0075)
Spacer()
VStack {
Text(CouponsView.couponView.localizedWithParameter(parameter: result["admin_name"] as? String ?? ""))
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: result["discount"] as? String ?? ""))
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: result["expiration"] as? String ?? "")))
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))
}
......@@ -180,6 +205,8 @@ extension CouponsView {
.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))
}
......@@ -187,6 +214,7 @@ extension CouponsView {
Spacer()
}
}
}
.frame(width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.13)
.background(
Image("coupons_container", bundle: Bundle(for: MyEmptyClass.self))
......@@ -223,7 +251,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)
......