Vasilis
......@@ -5,4 +5,191 @@
// Created by Manos Chorianopoulos on 18/4/22.
//
import Foundation
#if canImport(SwiftUI)
import SwiftUI
class CouponDataModel {
var data: Array<NSDictionary> = []
init() { //initializer method
let instanceOfMyApi = MyApi()
let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil)
let coupons = instanceOfMyApi.getCoupons() as AnyObject?
if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] {
let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! Array<NSMutableDictionary>)
if let myCouponsDictionary = coupons as? [String : AnyObject] {
let couponsData = (myCouponsDictionary["result"] as! Array<NSMutableDictionary>)
if let sets = couponSetsData as? NSArray {
for set in sets {
let s = set as! NSDictionary
if let cpns = couponsData as? NSArray {
for coupon in cpns {
var c = coupon as! NSDictionary
// var temp = NSMutableDictionary(dictionary: s);
if c["couponset_uuid"] as! String == s["uuid"] as! String {
var temp = NSMutableDictionary(dictionary: s);
temp.addEntries(from: c as! [AnyHashable : Any])
self.data.append(temp as NSDictionary)
}
}
}
}
}
}
}
}
var getData: Array<NSDictionary> {
get { // getter
return data
}
}
}
class CampaignDataModel {
var data: Array<NSDictionary> = []
init() { //initializer method
let instanceOfMyApi = MyApi()
let products = instanceOfMyApi.getInbox()
print("======== Inbox print =========")
print(products?[0])
print("======== Inbox dump =========")
dump(products?[0])
print("======== Inbox =========")
// let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil)
// let coupons = instanceOfMyApi.getCoupons() as AnyObject?
// if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] {
// let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! Array<NSMutableDictionary>)
// if let myCouponsDictionary = coupons as? [String : AnyObject] {
// let couponsData = (myCouponsDictionary["result"] as! Array<NSMutableDictionary>)
// if let sets = couponSetsData as? NSArray {
// for set in sets {
// let s = set as! NSDictionary
// if let cpns = couponsData as? NSArray {
// for coupon in cpns {
// var c = coupon as! NSDictionary
// // var temp = NSMutableDictionary(dictionary: s);
// if c["couponset_uuid"] as! String == s["uuid"] as! String {
// var temp = NSMutableDictionary(dictionary: s);
// temp.addEntries(from: c as! [AnyHashable : Any])
// self.data.append(temp as NSDictionary)
// }
// }
// }
// }
// }
// }
// }
}
var getData: Array<NSDictionary> {
get { // getter
return data
}
}
}
extension GiftsView {
struct headerView: View {
var uiscreen = UIScreen.main.bounds
var body: some View {
ZStack {
Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
.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.07)
Text("Όλα τα κουπόνια μου")
.frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
.offset( y: self.uiscreen.height * 0.07)
.frame(width: self.uiscreen.width)
}
}
}
struct giftView: View {
// @Binding var result: NSDictionary
var uiscreen = UIScreen.main.bounds
var body: some View {
ZStack {
// URLImage(url: URL(string: result["img_preview"] as! String? ?? ""))
// .resizable()
// .frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04)
// .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(for: MyEmptyClass.self))
// .resizable()
//// .edgesIgnoringSafeArea(.all)
// .frame(width: UIScreen.main.bounds.width * 0.8, height: UIScreen.main.bounds.height * 0.17)
// )
}
}
}
@available(iOS 13.0.0, *)
struct GiftsView: View {
var data:Array<NSDictionary> = CouponDataModel().getData
var campains:Any = CampaignDataModel()
var uiscreen = UIScreen.main.bounds
var body: some View {
VStack {
headerView()
// ScrollView {
// VStack {
// if (data.count) > 0 {
// ForEach(data, id: \.self) { result in
// couponView(result: result)
// }
// }
// }
// .frame(width:self.uiscreen.width, height:self.uiscreen.height )
// }
}
}
}
#endif
//struct ProfileView_Previews: PreviewProvider {
// static var previews: some View {
// ProfileView()
// }
//}
@available(iOS 13.0.0, *)
struct Previews_GiftsView_Previews: PreviewProvider {
static var uiscreen = UIScreen.main.bounds
static var previews: some View {
ZStack {
Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
.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.07)
Text("Όλα τα κουπόνια μου")
.frame(width: self.uiscreen.width * 0.8, height: self.uiscreen.height * 0.025, alignment: .center)
.offset( y: self.uiscreen.height * 0.07)
}
}
}
......
......@@ -6,3 +6,13 @@
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class GiftsViewInterface : NSObject {
@objc static public func giftsViewController() -> UIViewController {
return UIHostingController(rootView: GiftsView())
}
}
......
......@@ -16,6 +16,7 @@
- (void) setToStage;
- (void) setLang:(NSString*) lang;
- (UIViewController *) openCoupons:(UIView*) parentView;
- (UIViewController *) openGifts;
- (void) applicationDidEnterBackground:(UIApplication *)application;
- (void) applicationWillEnterForeground:(UIApplication *)application;
- (void) applicationDidBecomeActive:(UIApplication *)application;
......
......@@ -51,6 +51,15 @@ NSString *LANG;
return couponsViewController;
}
- (UIViewController *) openGifts{
UIViewController *giftsViewController = [GiftsViewInterface giftsViewController];
// controller = [[UINavigationController alloc]initWithRootViewController:profileViewController];
// [window makeKeyAndVisible];
return giftsViewController;
}
//- (UIViewController *) openCoupons {
//// NSString* const frameworkBundleID = @"framework.warp.ly.WarplySDKFrameworkIOS";
//// NSBundle* bundle = [NSBundle bundleWithIdentifier:frameworkBundleID];
......