Vasilis

steps first try

......@@ -19,6 +19,7 @@
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 */; };
E634A362282151E30069DE27 /* StepsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E634A361282151E30069DE27 /* StepsView.swift */; };
E639EFA2280810E300B9DD94 /* CouponsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E639EFA0280810E300B9DD94 /* CouponsView.swift */; };
E639EFA3280810E300B9DD94 /* CouponsViewInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */; };
E639EFA52808244E00B9DD94 /* MyEmptyClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = E639EFA42808244E00B9DD94 /* MyEmptyClass.swift */; };
......@@ -159,6 +160,7 @@
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>"; };
E634A361282151E30069DE27 /* StepsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsView.swift; sourceTree = "<group>"; };
E639EFA0280810E300B9DD94 /* CouponsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CouponsView.swift; sourceTree = "<group>"; };
E639EFA1280810E300B9DD94 /* CouponsViewInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CouponsViewInterface.swift; sourceTree = "<group>"; };
E639EFA42808244E00B9DD94 /* MyEmptyClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyEmptyClass.swift; sourceTree = "<group>"; };
......@@ -376,6 +378,7 @@
E655D05928058A72004F913C /* WarplySDKFrameworkIOS-Bridging-Header.h */,
E639EFA42808244E00B9DD94 /* MyEmptyClass.swift */,
E67D1EC528117F2400940F01 /* swiftApi.swift */,
E634A361282151E30069DE27 /* StepsView.swift */,
);
path = WarplySDKFrameworkIOS;
sourceTree = "<group>";
......@@ -805,6 +808,7 @@
E67D1EB8281055D900940F01 /* WalletViewInterface.swift in Sources */,
E6D8DF3127A942920006A3A9 /* AFNetworkActivityIndicatorManager.m in Sources */,
E6D8DF3D27A942920006A3A9 /* AFAutoPurgingImageCache.m in Sources */,
E634A362282151E30069DE27 /* StepsView.swift in Sources */,
E6D8DF0A27A942920006A3A9 /* WLAPSItem.m in Sources */,
E6D8DF2C27A942920006A3A9 /* UIProgressView+AFNetworking.m in Sources */,
E6D8DF3C27A942920006A3A9 /* UIWebView+AFNetworking.m in Sources */,
......
......@@ -36,5 +36,37 @@
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "8A4576AC-8F1C-4F2D-A153-7B9F703BDF6D"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "WarplySDKFrameworkIOS/StepsView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "21"
endingLineNumber = "21"
landmarkName = "init()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "89C2FADA-F600-4DE9-A167-666EB874685F"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "WarplySDKFrameworkIOS/StepsView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "96"
endingLineNumber = "96"
landmarkName = "getSteps()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
......
......@@ -8,15 +8,17 @@
#ifndef MyApi_h
#define MyApi_h
#import <UIKit/UIKit.h>
#import <CoreMotion/CoreMotion.h>
@class Warply;
@interface MyApi : NSObject
@property (nonatomic, weak) Warply *warply;
+ (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang;
- (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang;
- (void) setToStage;
- (void) setLang:(NSString*) lang;
- (void) getSteps:(void(^)(CMPedometerData* stepsData)) completion;
- (UIViewController *) openCoupons:(UIView*) parentView;
//- (UIViewController *) openCoupon:(UIView*) parentView coupon:(NSDictionary*) coupon;
//- (UIViewController *) openCouponBarcode:(UIView*) parentView coupon:(NSDictionary*) coupon;
......
......@@ -9,7 +9,6 @@
#import "MyApi.h"
#import "Warply.h"
#import "WLUtils.h"
#import <WarplySDKFrameworkIOS/WarplySDKFrameworkIOS-Swift.h>
......@@ -19,8 +18,10 @@ NSString *WARP_HOST = @"engage.warp.ly";
NSString *WARP_ERROR_DOMAIN = @"engage.warp.ly";
NSString *MERCHANT_ID;
NSString *LANG;
NSDate *date;
CMPedometer *pedometer;
+ (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang{
- (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang{
#if (DEBUG == 1)
[Warply launchWithAppUUID:uuid launchOptions:launchOptions];
#else
......@@ -35,6 +36,51 @@ NSString *LANG;
int cacheSizeDisk = 0; // 0MB
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");
}
}
- (void)queryDataFrom:(NSDate *)startDate toDate:(NSDate *)endDate {
[pedometer queryPedometerDataFromDate:startDate
toDate:endDate
withHandler:
^(CMPedometerData *pedometerData, NSError *error) {
NSLog(@"data:%@, error:%@", pedometerData, error);
dispatch_async(dispatch_get_main_queue(), ^{
if (error) {
NSLog(@"Error = %@",error.userInfo);
} else {
}
});
}];
}
- (void)recursiveQuery {
NSDate *to = [NSDate date];
NSDate *from = [to dateByAddingTimeInterval:-(24. * 3600.)];
[self queryDataFrom:from toDate:to];
}
- (void) getSteps:(void(^)(CMPedometerData* stepsData)) completion {
[pedometer startPedometerUpdatesFromDate:date
withHandler:^(CMPedometerData *pedometerData, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
completion(pedometerData);
});
}];
}
- (void) setToStage {
......
//
// 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 == 1) {
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)
// }
//
// }
//}
......@@ -365,4 +365,8 @@ public class swiftApi {
public func openCouponBarcode(parent: UIView, coupon: CouponItemModel) -> UIViewController {
return UIHostingController(rootView: CouponBarcodeView(parentView: parent, coupon: coupon))
}
public func openSteps(parent: UIView) -> UIViewController {
return UIHostingController(rootView: StepsView(parentView: parent))
}
}
......