Vasilis

fixes

Showing 25 changed files with 12 additions and 1336 deletions
//
// 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)
}
Spacer().frame(width: 0)
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)
.offset(x: -self.uiscreen.height * 0.0125)
}
.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: swiftApi.CouponItemModel
var parentView: UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
let couponSetData = item.couponset_data
Button {
// GiftItem Action
let instanceOfMySwiftApi = swiftApi()
let couponBarcodeViewController = instanceOfMySwiftApi.openCouponBarcode(parent: parentView, coupon: item)
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: couponSetData?.img_preview ?? "", width: self.uiscreen.width * 0.5, isFill: true)
VStack(alignment: .leading, spacing: 5.0) {
Text(couponSetData?.name ?? "")
.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(couponSetData?.short_description ?? "")
.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<swiftApi.CouponItemModel> = []
@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<swiftApi.CouponItemModel> = []
var uiscreen = UIScreen.main.bounds
init(parentView: UIView) { //initializer method
let instanceOfMySwiftApi = swiftApi()
let couponsData = instanceOfMySwiftApi.getCoupons()
self.coupons = couponsData
self.parentView = parentView
}
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!))
}
}
//
// CampaignWebview.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 20/4/22.
//
#if canImport(SwiftUI)
import SwiftUI
import Combine
import Foundation
import UIKit
import WebKit
extension CampaignWebview {
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)
}
Spacer().frame(width: 0)
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)
.offset(x: -self.uiscreen.height * 0.0125)
}
.frame(maxWidth: .infinity)
.padding(.horizontal)
.padding(.vertical, 10)
}
}
struct WebView: UIViewRepresentable {
var url: String
func makeUIView(context: Context) -> WKWebView {
return WKWebView()
}
func updateUIView(_ webView: WKWebView, context: Context) {
var request = URLRequest(url: URL(string: url)!)
request.cachePolicy = .reloadRevalidatingCacheData
webView.load(request)
}
}
}
@available(iOS 13.0.0, *)
struct CampaignWebview: View {
var parentView: UIView
var campaign: String
var uiscreen = UIScreen.main.bounds
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 6) {
subview.removeFromSuperview()
}
}
}
var body: some View {
VStack {
headerView(goBack: goBack)
VStack {
WebView(url: campaign)
}
.background(
LinearGradient(gradient: Gradient(colors: [Color(red: 0.06, green: 0.67, blue: 0.84), Color(red: 0.47, green: 0.75, blue: 0.43)]), startPoint: .top, endPoint: .bottom)
)
.cornerRadius(30, corners: [.topLeft])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
.edgesIgnoringSafeArea([.bottom])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
}
#endif
//@available(iOS 13.0.0, *)
//struct CampaignWebview_Previews: PreviewProvider {
// static var previews: some View {
//
// CampaignWebview()
//
// }
//}
//
// CampaignWebviewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 20/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class CampaignViewInterface : NSObject {
@objc(campaignViewController::) static public func campaignViewController(parentView: UIView?, campaign: String?) -> UIViewController {
return UIHostingController(rootView: CampaignWebview(parentView: parentView!, campaign: campaign ?? ""))
}
}
//
// CouponBarcodeViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 21/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class CouponBarcodeViewInterface : NSObject {
// @objc(couponBarcodeViewController::) static public func couponBarcodeViewController(parentView: UIView?, coupon: Dictionary<String, Any>) -> UIViewController {
// return UIHostingController(rootView: CouponBarcodeView(parentView: parentView!, coupon: coupon))
// }
}
//
// CouponView.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 21/4/22.
//
#if canImport(SwiftUI)
import SwiftUI
import Combine
import Foundation
import UIKit
extension CouponView {
struct headerView: View {
var goBack: () -> ()
var uiscreen = UIScreen.main.bounds
var body: some View {
HStack(alignment: .center) {
Button {
// Button Action
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)
}
Spacer().frame(width: 0)
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)
.offset(x: -self.uiscreen.height * 0.0125)
}
.frame(maxWidth: .infinity)
.padding(.horizontal)
.padding(.vertical, 10)
}
}
struct couponContainer: View {
@State var coupon: swiftApi.CouponSetItemModel
// @State var couponset:CouponSetItemModel
var uiscreen = UIScreen.main.bounds
var body: some View {
GeometryReader { geometry in
ScrollView(showsIndicators: false) {
VStack(alignment: .leading) {
ImageView(withURL: coupon.img_preview as? String ?? "")
Text(coupon.name as? String ?? "")
.fontWeight(.bold)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
.multilineTextAlignment(.leading)
.padding(.horizontal)
.padding(.top, self.uiscreen.height * 0.04)
Text(coupon.short_description as? String ?? "")
.fontWeight(.regular)
.font(.system(size: 14))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
.multilineTextAlignment(.leading)
.padding(.horizontal)
.padding(.top, self.uiscreen.height * 0.02)
Spacer()
VStack(alignment: .center) {
Button {
// Button Action
print("Back Button tapped!")
} label: {
HStack {
Text("Απόκτησέ το")
.fontWeight(.medium)
.font(.system(size: 16))
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
.padding(.all)
}
}
.frame(width: self.uiscreen.width * 0.8)
.background(Color(red: 0.4745098039215686, green: 0.7490196078431373, blue: 0.0784313725490196))
.cornerRadius(7)
}
.frame(maxWidth: .infinity)
.padding(.top, self.uiscreen.height * 0.06)
Button {
// Button Action
print("Terms Button tapped!")
} label: {
Text("Όροι χρήσης")
.fontWeight(.medium)
.font(.system(size: 14))
.foregroundColor(Color(red: 0.2549019607843137, green: 0.3333333333333333, blue: 0.39215686274509803))
.underline()
.multilineTextAlignment(.center)
.padding(.vertical, self.uiscreen.height * 0.03)
.padding(.horizontal)
.frame(maxWidth: .infinity)
}
.frame(maxWidth: .infinity)
}
.frame(width:self.uiscreen.width)
.frame(minHeight: geometry.size.height)
.padding(.bottom, self.uiscreen.height * 0.03)
}
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
}
struct ImageView: View {
@ObservedObject var imageLoader:UrlImageModel
var uiscreen = UIScreen.main.bounds
init(withURL url:String) {
imageLoader = UrlImageModel(urlString:url)
}
var body: some View {
Image(uiImage: imageLoader.image ?? UIImage())
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: self.uiscreen.width, height: self.uiscreen.height * 0.25)
}
}
}
@available(iOS 13.0.0, *)
struct CouponView: View {
var parentView: UIView
var coupon: swiftApi.CouponSetItemModel
@State var couponset: swiftApi.CouponSetItemModel?
var uiscreen = UIScreen.main.bounds
func goBack() {
for subview in parentView.subviews {
if(subview.tag == 2) {
subview.removeFromSuperview()
}
}
}
var body: some View {
VStack {
headerView(goBack: goBack)
VStack {
couponContainer(coupon: coupon)
}
.background(Color.white)
.cornerRadius(30, corners: [.topLeft])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
}
.edgesIgnoringSafeArea([.bottom])
.frame(width:self.uiscreen.width)
.frame(maxHeight: .infinity)
// .onAppear {
// // If you want to setup data with model
// couponset = CouponSetItemModel(dictionary: coupon)
//
// }
}
}
#endif
//struct CouponView_Previews: PreviewProvider {
// static var previews: some View {
// CouponView()
// }
//}
//
// CouponViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 21/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class CouponViewInterface : NSObject {
// @objc(couponViewController::) static public func couponViewController(parentView: UIView?, coupon: Dictionary<String, Any>) -> UIViewController {
// return UIHostingController(rootView: CouponView(parentView: parentView!, coupon: coupon))
// }
}
//
// ProfileViewController.swift
// warplyFramework
//
// Created by Βασιλης Σκουρας on 14/1/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class CouponsViewInterface : NSObject {
@objc(couponsViewController:) static public func couponsViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: CouponsView(parentView: parentView!))
}
}
//
// DetailsViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 3/5/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class DetailsViewInterface : NSObject {
@objc(detailsViewController:) static public func detailsViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: DetailsView(parentView: parentView!))
}
}
//
// GiftsViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 18/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class GiftsViewInterface : NSObject {
@objc(giftsViewController:) static public func giftsViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: GiftsView(parentView: parentView!))
}
}
//
// MoreForYouView.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 20/4/22.
//
import SwiftUI
import Combine
import Foundation
import UIKit
class DataMFYModel {
var data: Array<NSDictionary> = []
init() { //initializer method
let instanceOfMyApi = MyApi()
let inbox = instanceOfMyApi.getInbox() as! Array<NSDictionary>
data = inbox.filter({ $0["offer_category"] as! String == "more_for_you" })
}
var getData: Array<NSDictionary> {
get { // getter
return data
}
}
}
extension MoreForYouView {
struct headerView: View {
var goBack: () -> ()
var uiscreen = UIScreen.main.bounds
var body: some View {
HStack(alignment: .center) {
Button {
// Button Action
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)
}
Spacer().frame(width: 0)
Text("More for you")
.fontWeight(.medium)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.20784313725490197, green: 0.3176470588235294, blue: 0.40784313725490196))
.multilineTextAlignment(.center)
.frame(maxWidth: .infinity)
.padding(.horizontal)
.offset(x: -self.uiscreen.height * 0.0125)
}
.frame(maxWidth: .infinity)
.padding(.horizontal)
.padding(.vertical, 10)
}
}
struct ImageView: View {
@ObservedObject var imageLoader:UrlImageModel
@State var width:CGFloat
@State var height:CGFloat
@State var isFill:Bool
var uiscreen = UIScreen.main.bounds
init(withURL url:String , width:CGFloat, height: CGFloat, isFill:Bool) {
imageLoader = UrlImageModel(urlString:url)
self.width = width
self.height = height
self.isFill = isFill
}
var body: some View {
Image(uiImage: imageLoader.image ?? UIImage())
.resizable()
.frame(minWidth: self.uiscreen.width * 0.95, idealWidth: self.uiscreen.width * 0.95, maxWidth: self.uiscreen.width * 0.95, minHeight: self.uiscreen.height * 0.2, idealHeight: self.uiscreen.height * 0.2, maxHeight: self.uiscreen.height * 0.2, alignment: .leading)
.scaledToFill()
.aspectRatio(contentMode: isFill ? .fill : .fit)
.cornerRadius(4)
}
}
struct inboxView: View {
var result: NSDictionary
var index: Int
var uiscreen = UIScreen.main.bounds
static func localizedWithParameter(parameter: String) -> LocalizedStringKey {
return "\(parameter)"
}
var body: some View {
HStack {
VStack(alignment: .leading) {
Text(MoreForYouView.inboxView.localizedWithParameter(parameter: result["title"] as? String ?? ""))
.font(.system(size: 17).italic())
.fontWeight(.bold)
.foregroundColor(Color(hex: 0x3A5266))
.frame(maxWidth: self.uiscreen.width * 0.65, alignment: .topLeading)
.padding(.top, self.uiscreen.height * 0.01)
.padding(.leading, self.uiscreen.width * 0.03)
Spacer()
Text(MoreForYouView.inboxView.localizedWithParameter(parameter: result["subtitle"] as? String ?? ""))
.font(.system(size: 16))
.fontWeight(.medium)
.foregroundColor(Color(hex: 0x415564))
.frame(maxWidth: self.uiscreen.width * 0.72, alignment: .topLeading)
.padding(.leading, self.uiscreen.width * 0.03)
.padding(.bottom, self.uiscreen.height * 0.01)
}
.frame(width: self.uiscreen.width * 0.85, height: self.uiscreen.height * 0.2, alignment: .leading)
.background(
Image("MFY_container", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.frame(minWidth: self.uiscreen.width * 0.85, idealWidth: self.uiscreen.width * 0.85, maxWidth: self.uiscreen.width * 0.85, minHeight: self.uiscreen.height * 0.2, idealHeight: self.uiscreen.height * 0.2, maxHeight: self.uiscreen.height * 0.2, alignment: .leading)
.scaledToFill()
.aspectRatio(contentMode: .fill)
)
.cornerRadius(4, corners: [.topLeft, .bottomLeft])
Spacer()
}
.frame(width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.2)
.background(
ImageView(withURL: result["logo_url"] as! String, width: self.uiscreen.width * 0.95, height: self.uiscreen.height * 0.2, isFill: true)
)
.padding(.bottom, self.uiscreen.height * 0.01)
}
}
}
extension Color {
init(hex: Int, opacity: Double = 1.0) {
let red = Double((hex & 0xff0000) >> 16) / 255.0
let green = Double((hex & 0xff00) >> 8) / 255.0
let blue = Double((hex & 0xff) >> 0) / 255.0
self.init(.sRGB, red: red, green: green, blue: blue, opacity: opacity)
}
}
struct MoreForYouView: View {
var data:Array<NSDictionary> = DataMFYModel().getData
var parentView: UIView
var uiscreen = UIScreen.main.bounds
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 4) {
subview.removeFromSuperview()
}
}
}
var body: some View {
VStack {
headerView(goBack: goBack)
ScrollView(showsIndicators: false) {
VStack {
if (data.count) > 0 {
ForEach(Array(zip(data.indices, data)), id: \.0) { index, result in
inboxView(result: result, index: index)
}
}
}
.padding(.top, self.uiscreen.height * 0.04)
.padding(.bottom, self.uiscreen.height * 0.05)
}
.frame(maxWidth: .infinity, maxHeight: .infinity )
.background(
LinearGradient(gradient: Gradient(colors: [Color(hex: 0x1AADCC), Color(hex: 0x83C062)]), startPoint: .top, endPoint: .bottom)
)
.cornerRadius(20, corners: [.topLeft])
}
.frame(maxWidth: .infinity, maxHeight: .infinity )
.edgesIgnoringSafeArea([.bottom])
// .frame(width:self.uiscreen.width, height:self.uiscreen.height )
}
}
//struct MoreForYouView_Previews: PreviewProvider {
// static var previews: some View {
// MoreForYouView()
// }
//}
//
// MoreForYouViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 20/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class MoreForYouViewInterface : NSObject {
@objc(moreForYouViewController:) static public func moreForYouViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: MoreForYouView(parentView: parentView!))
}
}
......@@ -37,18 +37,18 @@ CMPedometer *pedometer;
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
[NSURLCache setSharedURLCache:sharedCache];
date = [NSDate date];
if ([CMPedometer isStepCountingAvailable]) {
pedometer = [[CMPedometer alloc] init];
[NSTimer scheduledTimerWithTimeInterval:0.5f
target:self
selector:@selector(recursiveQuery)
userInfo:nil
repeats:YES];
} else {
NSLog(@"Nothing available");
}
// date = [NSDate date];
// if ([CMPedometer isStepCountingAvailable]) {
// pedometer = [[CMPedometer alloc] init];
// [NSTimer scheduledTimerWithTimeInterval:0.5f
// target:self
// selector:@selector(recursiveQuery)
// userInfo:nil
// repeats:YES];
// } else {
// NSLog(@"Nothing available");
//
// }
}
- (void)queryDataFrom:(NSDate *)startDate toDate:(NSDate *)endDate {
......
//
// OldCouponsView.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 28/4/22.
//
#if canImport(SwiftUI)
import SwiftUI
import Combine
import Foundation
import UIKit
extension OldCouponsView {
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)
Button {
// Button Action
print("Wallet tapped!")
} label: {
Image("ic_wallet", bundle: Bundle(for: MyEmptyClass.self))
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: self.uiscreen.height * 0.04, height: self.uiscreen.height * 0.04)
}
}
.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 couponItemView: View {
var item: swiftApi.CouponItemModel
var parentView: UIView
var uiscreen = UIScreen.main.bounds
var body: some View {
// let couponData = item["coupon_data"] as? [String: Any] ?? ["":""]
let couponSetData = item.couponset_data
Button {
// Coupon Action
print("Coupon tapped!")
// 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) {
ImageView(withURL: couponSetData?.img_preview ?? "", width: self.uiscreen.width * 0.15, isFill: false)
VLine()
.stroke(style: StrokeStyle(lineWidth: 1, dash: [5]))
.foregroundColor(Color(red: 0.4392156862745098, green: 0.4392156862745098, blue: 0.4392156862745098))
.frame(width: 1)
.padding(.leading, 10)
VStack(alignment: .leading, spacing: 5.0) {
Text(couponSetData?.name ?? "")
.fontWeight(.medium)
.font(.system(size: 16))
.foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
.multilineTextAlignment(.leading)
// .lineLimit(1)
HStack(alignment: .center) {
Text((item.discount ?? "")+"€")
.fontWeight(.bold)
.font(.system(size: 35))
.foregroundColor(Color(red: 0.22745098039215686, green: 0.3215686274509804, blue: 0.4))
.multilineTextAlignment(.leading)
.lineLimit(1)
// Text(couponSetData?.short_description ?? "")
// .fontWeight(.medium)
// .font(.system(size: 11))
// .foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
// .multilineTextAlignment(.leading)
// .lineLimit(3)
}
Text("Εξαργυρώθηκε την " + (item.expiration ?? ""))
.fontWeight(.medium)
.font(.system(size: 11))
.foregroundColor(Color(red: 0.3803921568627451, green: 0.44313725490196076, blue: 0.5058823529411764))
.multilineTextAlignment(.leading)
}
.padding(.all, 10)
Spacer()
}
.padding(.leading, 28)
.padding(.trailing)
}
.frame(width: self.uiscreen.width * 0.9, height: self.uiscreen.height * 0.14)
// .cornerRadius(5)
// .shadow(color: Color(red: 0, green: 0, blue: 0, opacity: 0.16), radius: 30, x: 0, y: 3)
.background(
Image("coupon_bg", bundle: Bundle(for: MyEmptyClass.self))
.resizable(resizingMode: .stretch)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.colorMultiply(Color(red: 0.8901960784313725, green: 0.8901960784313725, blue: 0.8901960784313725))
)
}
}
struct VLine: Shape {
func path(in rect: CGRect) -> Path {
Path { path in
path.move(to: CGPoint(x: rect.midX, y: rect.minY))
path.addLine(to: CGPoint(x: rect.midX, y: rect.maxY))
}
}
}
struct couponsContainer: View {
@State var coupons:Array<swiftApi.CouponItemModel> = []
@State var parentView:UIView
var uiscreen = UIScreen.main.bounds
// static func convertDateFormat(inputDate: String) -> String {
// let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
// if let date = dateFormatter.date(from: inputDate) {
// dateFormatter.dateFormat = "dd/MM/yyyy"
// let resultString = dateFormatter.string(from: date)
// return resultString
// } else {
// return ""
// }
// }
var body: some View {
VStack(alignment: .center, spacing: self.uiscreen.height * 0.03) {
ForEach(Array(coupons.enumerated()), id: \.offset) { index, item in
couponItemView(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 OldCouponsView: View {
var parentView: UIView
var coupons:Array<swiftApi.CouponItemModel> = []
var uiscreen = UIScreen.main.bounds
init(parentView: UIView) { //initializer method
let instanceOfMySwiftApi = swiftApi()
let couponsData = instanceOfMySwiftApi.getOldCoupons()
self.coupons = couponsData
self.parentView = parentView
}
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 9) {
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 OldCouponsView_Previews: PreviewProvider {
// static var previews: some View {
// OldCouponsView()
// }
//}
//
// OldCouponsViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Manos Chorianopoulos on 28/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class OldCouponsViewInterface : NSObject {
@objc(oldCouponsViewController:) static public func oldCouponsViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: OldCouponsView(parentView: parentView!))
}
}
//
// StepsView.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 3/5/22.
//
#if canImport(SwiftUI)
import SwiftUI
import Combine
import Foundation
import UIKit
class StepsModel {
var steps: AnyObject
init() async { //initializer method
let instanceOfMyApi = MyApi()
self.steps = await instanceOfMyApi.getSteps { _ in
} as AnyObject
print(steps)
}
var getSteps: AnyObject {
get { // getter
return steps
}
}
}
extension StepsView {
struct headerView: View {
var goBack: () -> ()
var uiscreen = UIScreen.main.bounds
var body: some View {
HStack(alignment: .center) {
Button {
// Button Action
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)
}
Spacer().frame(width: 0)
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)
.offset(x: -self.uiscreen.height * 0.0125)
}
.frame(maxWidth: .infinity)
.padding(.horizontal)
.padding(.vertical, 10)
}
}
}
@available(iOS 13.0.0, *)
struct StepsView: View {
@State private var steps = "Loading"
var parentView: UIView
func getSteps() async -> AnyObject {
return await StepsModel().getSteps
}
var uiscreen = UIScreen.main.bounds
init(parentView: UIView) { //initializer method
self.parentView = parentView
}
func goBack(){
for subview in parentView.subviews {
if(subview.tag == 11) {
subview.removeFromSuperview()
}
}
}
func getSteps() async -> String {
let instanceOfMyApi = MyApi()
let stepsData = await instanceOfMyApi.getSteps { _ in
} as AnyObject
// DispatchQueue.main.async {
// steps = ""
// }
return ""
}
var body: some View {
VStack {
headerView(goBack: goBack)
Text(steps)
.onAppear {
async {
let instanceOfMyApi = MyApi()
let stepsData = try? await instanceOfMyApi.getSteps { _ in
} as AnyObject
self.steps = ""
}
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity )
// .frame(width:self.uiscreen.width, height:self.uiscreen.height )
}
}
#endif
//@available(iOS 13.0.0, *)
//struct Previews_CouponsView_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)
// }
//
// }
//}
//
// StepsViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 3/5/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class StepsViewInterface : NSObject {
@objc(stepsViewController:) static public func stepsViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: StepsView(parentView: parentView!))
}
}
//
// WalletViewInterface.swift
// WarplySDKFrameworkIOS
//
// Created by Βασιλης Σκουρας on 20/4/22.
//
import Foundation
import SwiftUI
@available(iOS 13.0.0, *)
@objc public class WalletViewInterface : NSObject {
@objc(walletViewController:) static public func walletViewController(parentView: UIView?) -> UIViewController {
return UIHostingController(rootView: WalletView(parentView: parentView!))
}
}