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,54 +34,65 @@ 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()
.frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
.offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.04)
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 })
ForEach(dataArray, id: \.self) { item in
VStack {
ZStack {
Image("ic_back", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS"))
.resizable()
.frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
.offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.04)
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)
}
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
ZStack {
Image("logo", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS"))
.resizable()
.frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04, alignment: .topLeading)
.cornerRadius(CGFloat(self.uiscreen.height * 0.02))
.offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07)
}.background(
Image("Background")
.resizable()
.edgesIgnoringSafeArea(.all)
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
)
ZStack {
Image("logo", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS"))
.resizable()
.frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04, alignment: .topLeading)
.cornerRadius(CGFloat(self.uiscreen.height * 0.02))
.offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07)
}.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)
)
}
// } 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.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 )
.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];
......