Manos Chorianopoulos
......@@ -77,7 +77,7 @@ extension CouponBarcodeView {
}
struct couponContainer: View {
@State var coupon: Dictionary<String, Any>
@State var coupon: swiftApi.CouponItemModel
// @State var couponset:CouponSetItemModel
var uiscreen = UIScreen.main.bounds
......@@ -98,8 +98,8 @@ extension CouponBarcodeView {
func constructBarcode() -> String? {
// EAN 13 barcode construction
let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""]
let couponString = couponData["coupon"] as? String ?? ""
let couponData = coupon.couponset_data
let couponString = coupon.coupon ?? ""
if (!couponString.isEmpty) {
var checkDigit = 0;
......@@ -132,17 +132,17 @@ extension CouponBarcodeView {
var body: some View {
let couponData = coupon["coupon_data"] as? [String: Any] ?? ["":""]
let couponData = coupon.couponset_data
let barcodeString = constructBarcode() ?? ""
GeometryReader { geometry in
ScrollView(showsIndicators: false) {
VStack(alignment: .leading) {
ImageView(withURL: coupon["img_preview"] as? String ?? "")
ImageView(withURL: couponData?.img_preview ?? "")
VStack(alignment: .leading) {
Text(coupon["name"] as? String ?? "")
Text(coupon.name!)
.fontWeight(.bold)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -151,7 +151,7 @@ extension CouponBarcodeView {
.padding(.top, self.uiscreen.height * 0.04)
.frame(maxHeight: .infinity)
Text(coupon["short_description"] as? String ?? "")
Text(couponData?.short_description! ?? "")
.fontWeight(.regular)
.font(.system(size: 14))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -170,7 +170,7 @@ extension CouponBarcodeView {
VStack(alignment: .center) {
VStack {
Text(couponData["coupon"] as? String ?? "")
Text(coupon.coupon!)
.fontWeight(.bold)
.font(.system(size: 27))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -185,7 +185,7 @@ extension CouponBarcodeView {
}
.frame(maxWidth: .infinity)
if (CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: couponData["coupon"] as? String ?? ""))) {
if (CharacterSet.decimalDigits.isSuperset(of: CharacterSet(charactersIn: coupon.coupon ?? ""))) {
VStack(alignment: .center) {
VStack {}
.frame(height: 1)
......@@ -233,7 +233,7 @@ extension CouponBarcodeView {
Text("Το κουπόνι ισχύει έως " + CouponBarcodeView.couponContainer.convertDateFormat(inputDate: couponData["expiration"] as? String ?? ""))
Text("Το κουπόνι ισχύει έως " + CouponBarcodeView.couponContainer.convertDateFormat(inputDate: couponData?.expiration ?? ""))
.fontWeight(.medium)
.font(.system(size: 14))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -348,7 +348,7 @@ extension CouponBarcodeView {
@available(iOS 13.0.0, *)
struct CouponBarcodeView: View {
var parentView: UIView
var coupon: Dictionary<String, Any>
var coupon: swiftApi.CouponItemModel
@State var couponset: CouponSetItemModel?
var uiscreen = UIScreen.main.bounds
......
......@@ -48,7 +48,7 @@ extension CouponView {
}
struct couponContainer: View {
@State var coupon: Dictionary<String, Any>
@State var coupon: swiftApi.CouponSetItemModel
// @State var couponset:CouponSetItemModel
var uiscreen = UIScreen.main.bounds
......@@ -58,9 +58,9 @@ extension CouponView {
ScrollView(showsIndicators: false) {
VStack(alignment: .leading) {
ImageView(withURL: coupon["img_preview"] as? String ?? "")
ImageView(withURL: coupon.img_preview as? String ?? "")
Text(coupon["name"] as? String ?? "")
Text(coupon.name as? String ?? "")
.fontWeight(.bold)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -68,7 +68,7 @@ extension CouponView {
.padding(.horizontal)
.padding(.top, self.uiscreen.height * 0.04)
Text(coupon["short_description"] as? String ?? "")
Text(coupon.short_description as? String ?? "")
.fontWeight(.regular)
.font(.system(size: 14))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
......@@ -152,7 +152,7 @@ extension CouponView {
@available(iOS 13.0.0, *)
struct CouponView: View {
var parentView: UIView
var coupon: Dictionary<String, Any>
var coupon: swiftApi.CouponSetItemModel
@State var couponset: CouponSetItemModel?
var uiscreen = UIScreen.main.bounds
......
......@@ -187,13 +187,13 @@ extension CouponsView {
VStack(alignment: .leading) {
Button {
// GiftItem Action
let instanceOfMyApi = MyApi()
let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: result as! [String : Any])!
let instanceOfMySwiftApi = swiftApi()
let couponBarcodeViewController = instanceOfMySwiftApi.openCouponBarcode(parent: parentView, coupon: result)
couponBarcodeViewController.view.tag = 7
// addChild(couponsViewController)
couponBarcodeViewController.view.frame = parentView.frame
parentView.addSubview(couponBarcodeViewController.view)
couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self))
// couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self))
} label: {
HStack(alignment: .center) {
ImageView(withURL: couponSetData?.img_preview ?? "")
......
......@@ -6,6 +6,7 @@
//
import Foundation
import SwiftUI
public class swiftApi {
......@@ -330,4 +331,12 @@ 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: CouponItemModel) -> UIViewController {
return UIHostingController(rootView: CouponBarcodeView(parentView: parent, coupon: coupon))
}
}
......