Showing
3 changed files
with
55 additions
and
44 deletions
No preview for this file type
... | @@ -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,54 +34,65 @@ class DataModel { | ... | @@ -34,54 +34,65 @@ 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 { | 42 | + VStack { |
43 | - VStack { | 43 | + ZStack { |
44 | - | 44 | + Image("ic_back", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS")) |
45 | - ZStack { | 45 | + .resizable() |
46 | - Image("ic_back", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS")) | 46 | + .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02) |
47 | - .resizable() | 47 | + .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.04) |
48 | - .frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02) | 48 | + Text("Όλα τα κουπόνια μου") |
49 | - .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.05, y: self.uiscreen.height * 0.04) | 49 | + .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center) |
50 | - Text("Όλα τα κουπόνια μου") | 50 | + .offset( y: self.uiscreen.height * 0.04) |
51 | - .frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center) | 51 | + .frame(width: self.uiscreen.width) |
52 | - .offset( y: self.uiscreen.height * 0.04) | 52 | + } |
53 | - } | 53 | + ScrollView { |
54 | - .frame(width: self.uiscreen.width) | 54 | + VStack { |
55 | - let dataArray:[NSDictionary] = (data as! NSArray).compactMap({ $0 as? NSDictionary }) | ||
56 | - | ||
57 | - ForEach(dataArray, id: \.self) { item in | ||
58 | 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 | ||
62 | + | ||
59 | 63 | ||
60 | - ZStack { | ||
61 | - Image("logo", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS")) | ||
62 | - .resizable() | ||
63 | - .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04, alignment: .topLeading) | ||
64 | - .cornerRadius(CGFloat(self.uiscreen.height * 0.02)) | ||
65 | - .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07) | ||
66 | 64 | ||
67 | - }.background( | 65 | + ZStack { |
68 | - Image("Background") | 66 | + Image("logo", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS")) |
69 | - .resizable() | 67 | + .resizable() |
70 | - .edgesIgnoringSafeArea(.all) | 68 | + .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04, alignment: .topLeading) |
71 | - .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) | 69 | + .cornerRadius(CGFloat(self.uiscreen.height * 0.02)) |
72 | - ) | 70 | + .offset(x: -self.uiscreen.width / 2 + self.uiscreen.width * 0.14, y: -self.uiscreen.height * 0.07) |
71 | + | ||
72 | + }.background( | ||
73 | + Image("coupons_container", bundle: Bundle(identifier:"framework.warp.ly.warplySDKFrameworkIOS")) | ||
74 | + .resizable() | ||
75 | + .edgesIgnoringSafeArea(.all) | ||
76 | + .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height) | ||
77 | + ) | ||
78 | + | ||
79 | + } | ||
80 | +// } else { | ||
81 | +// VStack { | ||
82 | +// Text("No coupons available") | ||
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 | +// } | ||
73 | } | 88 | } |
74 | - Text("Χριστίνα Γεωργίου") | 89 | + |
75 | - .frame( width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.04, alignment: .leading) | 90 | + |
76 | - .offset(y: -self.uiscreen.height * 0.03) | ||
77 | - .foregroundColor(.white) | ||
78 | } | 91 | } |
79 | - Text("Ενεργά κουπόνια") | 92 | + .frame(width:self.uiscreen.width, height:self.uiscreen.height ) |
80 | - .frame(width: self.uiscreen.width * 0.9, alignment: .leading) | 93 | + |
81 | -// .offset(x: -self.uiscreen.width / 4 + self.uiscreen.width * 0.0025) | 94 | + } |
82 | - | 95 | + |
83 | - } | ||
84 | - .frame(width:self.uiscreen.width, height:self.uiscreen.height ) | ||
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]; | ... | ... |
-
Please register or login to post a comment