Vasilis

fix in data in coupons view

...@@ -10,7 +10,7 @@ import SwiftUI ...@@ -10,7 +10,7 @@ import SwiftUI
10 import WarplySDKFrameworkIOS 10 import WarplySDKFrameworkIOS
11 11
12 class DataModel { 12 class DataModel {
13 - var data: AnyObject? 13 + var data: Array<NSDictionary>?
14 14
15 init() { //initializer method 15 init() { //initializer method
16 let instanceOfMyApi = MyApi() 16 let instanceOfMyApi = MyApi()
...@@ -19,13 +19,13 @@ class DataModel { ...@@ -19,13 +19,13 @@ class DataModel {
19 19
20 20
21 if let myDictionary = coupons as? [String : AnyObject] { 21 if let myDictionary = coupons as? [String : AnyObject] {
22 - self.data = myDictionary["result"] as AnyObject 22 + self.data = (myDictionary["result"] as! Array<NSDictionary>)
23 } 23 }
24 } 24 }
25 25
26 - var getData: AnyObject? { 26 + var getData: Array<NSDictionary> {
27 get { // getter 27 get { // getter
28 - return data ?? nil 28 + return data ?? []
29 } 29 }
30 } 30 }
31 } 31 }
...@@ -34,14 +34,12 @@ class DataModel { ...@@ -34,14 +34,12 @@ class DataModel {
34 @available(iOS 13.0.0, *) 34 @available(iOS 13.0.0, *)
35 struct CouponsView: View { 35 struct CouponsView: View {
36 36
37 - var data:AnyObject? = DataModel().getData 37 + var data:Array<NSDictionary> = DataModel().getData
38 38
39 var uiscreen = UIScreen.main.bounds 39 var uiscreen = UIScreen.main.bounds
40 // @State private var bottomRect: CGRect = .zero 40 // @State private var bottomRect: CGRect = .zero
41 var body: some View { 41 var body: some View {
42 - ScrollView {
43 VStack { 42 VStack {
44 -
45 ZStack { 43 ZStack {
46 Image("ic_back", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS")) 44 Image("ic_back", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS"))
47 .resizable() 45 .resizable()
...@@ -50,11 +48,18 @@ struct CouponsView: View { ...@@ -50,11 +48,18 @@ struct CouponsView: View {
50 Text("Όλα τα κουπόνια μου") 48 Text("Όλα τα κουπόνια μου")
51 .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center) 49 .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
52 .offset( y: self.uiscreen.height * 0.04) 50 .offset( y: self.uiscreen.height * 0.04)
53 - }
54 .frame(width: self.uiscreen.width) 51 .frame(width: self.uiscreen.width)
55 - let dataArray:[NSDictionary] = (data as! NSArray).compactMap({ $0 as? NSDictionary }) 52 + }
53 + ScrollView {
54 + VStack {
55 +
56 +
57 +// let dataArray:[NSDictionary] = (data as! NSArray).compactMap({ $0 as? NSDictionary })
58 +
59 +// if (data?.count())! > 0 {
60 +// data?.forEach { (language) in
61 + ForEach(data, id: \.self) { result in
56 62
57 - ForEach(dataArray, id: \.self) { item in
58 63
59 64
60 ZStack { 65 ZStack {
...@@ -65,23 +70,29 @@ struct CouponsView: View { ...@@ -65,23 +70,29 @@ struct CouponsView: View {
65 .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07) 70 .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07)
66 71
67 }.background( 72 }.background(
68 - Image("Background") 73 + Image("coupons_container", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS"))
69 .resizable() 74 .resizable()
70 .edgesIgnoringSafeArea(.all) 75 .edgesIgnoringSafeArea(.all)
71 .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) 76 .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height)
72 ) 77 )
78 +
73 } 79 }
74 - Text("Χριστίνα Γεωργίου") 80 +// } else {
75 - .frame( width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.04, alignment: .leading) 81 +// VStack {
76 - .offset(y: -self.uiscreen.height * 0.03) 82 +// Text("No coupons available")
77 - .foregroundColor(.white) 83 +// .frame( width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.04, alignment: .leading)
84 +// .offset(y: -self.uiscreen.height * 0.03)
85 +// .foregroundColor(.white)
86 +// }
87 +// }
78 } 88 }
79 - Text("Ενεργά κουπόνια") 89 +
80 - .frame(width: self.uiscreen.width * 0.9, alignment: .leading)
81 -// .offset(x: -self.uiscreen.width / 4 + self.uiscreen.width * 0.0025)
82 90
83 } 91 }
84 .frame(width:self.uiscreen.width, height:self.uiscreen.height ) 92 .frame(width:self.uiscreen.width, height:self.uiscreen.height )
93 +
94 + }
95 +
85 } 96 }
86 } 97 }
87 #endif 98 #endif
......
...@@ -46,7 +46,7 @@ NSString *LANG; ...@@ -46,7 +46,7 @@ NSString *LANG;
46 LANG = lang; 46 LANG = lang;
47 } 47 }
48 48
49 -- (UIViewController *) openCoupons:(UIViewController*)controller :(UIWindow*) window { 49 +- (UIViewController *) openCoupons{
50 50
51 UIViewController *couponsViewController = [CouponsViewInterface couponsViewController]; 51 UIViewController *couponsViewController = [CouponsViewInterface couponsViewController];
52 // controller = [[UINavigationController alloc]initWithRootViewController:profileViewController]; 52 // controller = [[UINavigationController alloc]initWithRootViewController:profileViewController];
......