Vasilis

fix in data in coupons view

......@@ -10,7 +10,7 @@ import SwiftUI
import WarplySDKFrameworkIOS
class DataModel {
var data: AnyObject?
var data: Array<NSDictionary>?
init() { //initializer method
let instanceOfMyApi = MyApi()
......@@ -19,13 +19,13 @@ class DataModel {
if let myDictionary = coupons as? [String : AnyObject] {
self.data = myDictionary["result"] as AnyObject
self.data = (myDictionary["result"] as! Array<NSDictionary>)
}
}
var getData: AnyObject? {
var getData: Array<NSDictionary> {
get { // getter
return data ?? nil
return data ?? []
}
}
}
......@@ -34,14 +34,12 @@ class DataModel {
@available(iOS 13.0.0, *)
struct CouponsView: View {
var data:AnyObject? = DataModel().getData
var data:Array<NSDictionary> = DataModel().getData
var uiscreen = UIScreen.main.bounds
// @State private var bottomRect: CGRect = .zero
var body: some View {
ScrollView {
VStack {
ZStack {
Image("ic_back", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS"))
.resizable()
......@@ -50,11 +48,18 @@ struct CouponsView: View {
Text("Όλα τα κουπόνια μου")
.frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
.offset( y: self.uiscreen.height * 0.04)
}
.frame(width: self.uiscreen.width)
let dataArray:[NSDictionary] = (data as! NSArray).compactMap({ $0 as? NSDictionary })
}
ScrollView {
VStack {
// let dataArray:[NSDictionary] = (data as! NSArray).compactMap({ $0 as? NSDictionary })
// if (data?.count())! > 0 {
// data?.forEach { (language) in
ForEach(data, id: \.self) { result in
ForEach(dataArray, id: \.self) { item in
ZStack {
......@@ -65,23 +70,29 @@ struct CouponsView: View {
.offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07)
}.background(
Image("Background")
Image("coupons_container", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS"))
.resizable()
.edgesIgnoringSafeArea(.all)
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
)
}
Text("Χριστίνα Γεωργίου")
.frame( width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.04, alignment: .leading)
.offset(y: -self.uiscreen.height * 0.03)
.foregroundColor(.white)
// } else {
// VStack {
// Text("No coupons available")
// .frame( width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.04, alignment: .leading)
// .offset(y: -self.uiscreen.height * 0.03)
// .foregroundColor(.white)
// }
// }
}
Text("Ενεργά κουπόνια")
.frame(width: self.uiscreen.width * 0.9, alignment: .leading)
// .offset(x: -self.uiscreen.width / 4 + self.uiscreen.width * 0.0025)
}
.frame(width:self.uiscreen.width, height:self.uiscreen.height )
}
}
}
#endif
......
......@@ -46,7 +46,7 @@ NSString *LANG;
LANG = lang;
}
- (UIViewController *) openCoupons:(UIViewController*)controller :(UIWindow*) window {
- (UIViewController *) openCoupons{
UIViewController *couponsViewController = [CouponsViewInterface couponsViewController];
// controller = [[UINavigationController alloc]initWithRootViewController:profileViewController];
......