Manos Chorianopoulos

add AllGiftsView

......@@ -11,6 +11,8 @@
1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */; };
1E735FF2281067320050A298 /* CampaignWebview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF1281067320050A298 /* CampaignWebview.swift */; };
1E735FF42810681E0050A298 /* CampaignWebviewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */; };
1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1328199C4F007524A0 /* AllGiftsView.swift */; };
1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */; };
1EBEB02D280D69D800BF802C /* GiftsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02C280D69D800BF802C /* GiftsView.swift */; };
1EBEB02F280D6AA500BF802C /* GiftsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */; };
260C6A1AFF7560C32E212F20 /* Pods_WarplySDKFrameworkIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1353B8C484CC0649CAC2EB74 /* Pods_WarplySDKFrameworkIOS.framework */; };
......@@ -147,6 +149,8 @@
1E7086662811A96E00704CA8 /* CouponBarcodeViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CouponBarcodeViewInterface.swift; sourceTree = "<group>"; };
1E735FF1281067320050A298 /* CampaignWebview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebview.swift; sourceTree = "<group>"; };
1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CampaignWebviewInterface.swift; sourceTree = "<group>"; };
1E98EC1328199C4F007524A0 /* AllGiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsView.swift; sourceTree = "<group>"; };
1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AllGiftsViewInterface.swift; sourceTree = "<group>"; };
1EBEB02C280D69D800BF802C /* GiftsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsView.swift; sourceTree = "<group>"; };
1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GiftsViewInterface.swift; sourceTree = "<group>"; };
B9413513157AD76ECE896B81 /* Pods-WarplySDKFrameworkIOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-WarplySDKFrameworkIOS.release.xcconfig"; path = "Target Support Files/Pods-WarplySDKFrameworkIOS/Pods-WarplySDKFrameworkIOS.release.xcconfig"; sourceTree = "<group>"; };
......@@ -341,6 +345,8 @@
E639EFA0280810E300B9DD94 /* CouponsView.swift */,
E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */,
1EBEB02C280D69D800BF802C /* GiftsView.swift */,
1E98EC1328199C4F007524A0 /* AllGiftsView.swift */,
1E98EC1528199C86007524A0 /* AllGiftsViewInterface.swift */,
1E735FF1281067320050A298 /* CampaignWebview.swift */,
1E735FF32810681E0050A298 /* CampaignWebviewInterface.swift */,
1EBEB02E280D6AA500BF802C /* GiftsViewInterface.swift */,
......@@ -753,6 +759,7 @@
E6D8DF4827A942920006A3A9 /* AFURLRequestSerialization.m in Sources */,
E67D1EC228113EED00940F01 /* CouponView.swift in Sources */,
1E7086672811A96E00704CA8 /* CouponBarcodeViewInterface.swift in Sources */,
1E98EC1428199C4F007524A0 /* AllGiftsView.swift in Sources */,
E6D8DEF327A942920006A3A9 /* WLNativeVideoTableViewCell.m in Sources */,
E6D8DF2527A942920006A3A9 /* WLSMSActionHanlder.m in Sources */,
E67D1EBE2810573900940F01 /* WalletView.swift in Sources */,
......@@ -786,6 +793,7 @@
E6D8DF2C27A942920006A3A9 /* UIProgressView+AFNetworking.m in Sources */,
E6D8DF3C27A942920006A3A9 /* UIWebView+AFNetworking.m in Sources */,
E639EFA2280810E300B9DD94 /* CouponsView.swift in Sources */,
1E98EC1628199C86007524A0 /* AllGiftsViewInterface.swift in Sources */,
E6D8DF1427A942920006A3A9 /* WLLocationManager.m in Sources */,
E6D8DF6027A9429E0006A3A9 /* MyApi.m in Sources */,
E6D8DF3F27A942920006A3A9 /* AFImageDownloader.m in Sources */,
......
//
// AllGiftsView.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 27/4/22.
//
#if canImport(SwiftUI)
import SwiftUI
import Combine
import Foundation
import UIKit
extension AllGiftsView {
struct headerView: View {
var goBack: () -> ()
var uiscreen = UIScreen.main.bounds
var body: some View {
HStack(alignment: .center) {
Button {
// Button Action
print("Back Button tapped!")
goBack()
} label: {
Image("ic_back", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: self.uiscreen.height * 0.025, height: self.uiscreen.height * 0.02)
}
Text("Όλα τα δώρα μου")
.fontWeight(.medium)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196))
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity)
.padding(.horizontal)
}
.frame(maxWidth: .infinity)
.padding(.horizontal)
.padding(.vertical, 10)
}
}
struct ImageView: View {
@ObservedObject var imageLoader:UrlImageModel
@State var width:CGFloat
@State var isFill:Bool
var uiscreen = UIScreen.main.bounds
init(withURL url:String , width:CGFloat, isFill:Bool) {
imageLoader = UrlImageModel(urlString:url)
self.width = width
self.isFill = isFill
}
var body: some View {
Image(uiImage: imageLoader.image ?? UIImage())
.resizable()
.aspectRatio(contentMode: isFill ? .fill : .fit)
.frame(width: self.width)
.frame(maxHeight: .infinity)
}
}
struct giftItemView: View {
var item: NSDictionary
var parentView: UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
Button {
// GiftItem Action
let instanceOfMyApi = MyApi()
let couponBarcodeViewController = instanceOfMyApi.openCouponBarcode(parentView, coupon: item as! [String : Any])!
couponBarcodeViewController.view.tag = 7
// addChild(couponsViewController)
couponBarcodeViewController.view.frame = parentView.frame
parentView.addSubview(couponBarcodeViewController.view)
couponBarcodeViewController.didMove(toParent: UIHostingController(rootView: self))
} label: {
HStack(alignment: .center, spacing: 0.0) {
ImageView(withURL: item["img_preview"] as? String ?? "", width: self.uiscreen.width * 0.5, isFill: true)
VStack(alignment: .leading, spacing: 5.0) {
// TODO: Change to name
Text(item["name"] as? String ?? "")
.fontWeight(.bold)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
.multilineTextAlignment(.leading)
.padding([.top,.horizontal], 15)
.background(Color.white)
Text(item["short_description"] as? String ?? "")
.fontWeight(.regular)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
.multilineTextAlignment(.leading)
.padding([.bottom,.horizontal], 15)
.background(Color.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.background(Color.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.background(Color.white)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.frame(width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.17)
.background(Color.white)
.cornerRadius(5)
.shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 6, x: 0, y: 3)
}
}
struct couponsContainer: View {
@State var coupons:Array<NSDictionary> = []
@State var parentView:UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) {
ForEach(Array(coupons.enumerated()), id: \.offset) { index, item in
giftItemView(item: item, parentView: parentView)
}
}
.frame(maxWidth: .infinity)
.padding(.top, self.uiscreen.height * 0.05)
.padding(.bottom, self.uiscreen.height * 0.1)
}
}
}
@available(iOS 13.0.0, *)
struct AllGiftsView: View {
var parentView: UIView
var coupons:Array<NSDictionary> = DataModel().getData
var uiscreen = UIScreen.main.bounds
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 8) {
subview.removeFromSuperview()
}
}
}
var body: some View {
VStack {
headerView(goBack: goBack)
VStack {
ScrollView(showsIndicators: false) {
VStack {
if (coupons.count) > 0 {
couponsContainer(coupons: coupons, parentView: parentView )
}
}
.frame(width:self.uiscreen.width)
}
.cornerRadius(30, corners: [.topLeft])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
.padding(.top, 5)
.background(
Image("coupons_scrollview", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
)
}
.edgesIgnoringSafeArea([.bottom])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
}
#endif
//struct AllGiftsView_Previews: PreviewProvider {
// static var previews: some View {
// AllGiftsView()
// }
//}
//
// AllGiftsViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 27/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class AllGiftsViewInterface : NSObject {
@objc(allGiftsViewController:) static public func allGiftsViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: AllGiftsView(parentView: parentView!))
}
}
......@@ -48,7 +48,7 @@ class DataModel {
var getData: Array<NSDictionary> {
get { // getter
return data.filter({ $0["status"] as! String == "1" })
return data.filter({ $0["status"] as! Int == 1 })
}
}
}
......
......@@ -21,6 +21,7 @@
- (UIViewController *) openCoupon:(UIView*) parentView coupon:(NSDictionary*) coupon;
- (UIViewController *) openCouponBarcode:(UIView*) parentView coupon:(NSDictionary*) coupon;
- (UIViewController *) openGifts:(UIView*) parentView;
- (UIViewController *) openAllGifts:(UIView*) parentView;
- (UIViewController *) openWallet:(UIView*) parentView;
- (UIViewController *) openMoreForYou:(UIView*) parentView;
- (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign;
......
......@@ -71,6 +71,12 @@ NSString *LANG;
return giftsViewController;
}
- (UIViewController *) openAllGifts:(UIView*) parentView{
UIViewController *allGiftsViewController = [AllGiftsViewInterface allGiftsViewController:parentView];
return allGiftsViewController;
}
- (UIViewController *) openWallet:(UIView*) parentView{
UIViewController *wallletViewController = [WalletViewInterface walletViewController:parentView];
......