Skip to content

Commit

Permalink
Working with new EMT API and Swift 5.0.
Browse files Browse the repository at this point in the history
Release Candidate 3.2
  • Loading branch information
alexruperez committed Aug 18, 2019
1 parent fcb6aa4 commit 9c5519b
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 4 deletions.
6 changes: 2 additions & 4 deletions BiciMAD.xcodeproj/project.pbxproj
Expand Up @@ -2015,7 +2015,7 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_SWIFT_FLAGS = "-D DEBUG";
SDKROOT = iphoneos;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = "arm64 x86_64 i386 arm64e";
};
Expand Down Expand Up @@ -2085,7 +2085,7 @@
OTHER_SWIFT_FLAGS = "";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VALID_ARCHS = "arm64 x86_64 i386 arm64e";
Expand Down Expand Up @@ -2160,7 +2160,6 @@
SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand Down Expand Up @@ -2190,7 +2189,6 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "MADBike Notifications App Store";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
Expand Up @@ -6,6 +6,7 @@ import UIKit
import CoreSpotlight
import MobileCoreServices
import MapKit
import Intents

@objc public extension UIResponder {

Expand Down
7 changes: 7 additions & 0 deletions BiciMAD/Source/Classes/Assembly/BMServicesAssembly.m
Expand Up @@ -149,6 +149,7 @@ - (BMServiceTask *)loginEMTTask
[definition injectProperty:@selector(coreDataManager) with:[self.managersAssembly coreDataManager]];
[definition injectProperty:@selector(crashlyticsManager) with:[self.managersAssembly crashlyticsManager]];
[definition injectProperty:@selector(spotlightManager) with:[self.managersAssembly spotlightManager]];
[definition injectProperty:@selector(userDefaultsManager) with:[self.managersAssembly userDefaultsManager]];
definition.scope = TyphoonScopeSingleton;
}];
}
Expand All @@ -163,6 +164,7 @@ - (BMServiceTask *)allStationsEMTTask
[definition injectProperty:@selector(coreDataManager) with:[self.managersAssembly coreDataManager]];
[definition injectProperty:@selector(crashlyticsManager) with:[self.managersAssembly crashlyticsManager]];
[definition injectProperty:@selector(spotlightManager) with:[self.managersAssembly spotlightManager]];
[definition injectProperty:@selector(userDefaultsManager) with:[self.managersAssembly userDefaultsManager]];
definition.scope = TyphoonScopeSingleton;
}];
}
Expand All @@ -177,6 +179,7 @@ - (BMServiceTask *)singleStationEMTTaskWithStationId:(NSString *)stationId
[definition injectProperty:@selector(coreDataManager) with:[self.managersAssembly coreDataManager]];
[definition injectProperty:@selector(crashlyticsManager) with:[self.managersAssembly crashlyticsManager]];
[definition injectProperty:@selector(spotlightManager) with:[self.managersAssembly spotlightManager]];
[definition injectProperty:@selector(userDefaultsManager) with:[self.managersAssembly userDefaultsManager]];
[definition injectProperty:@selector(stationId) with:stationId];
}];
}
Expand All @@ -191,6 +194,7 @@ - (BMServiceTask *)incidencesEMTTaskWithPhonePreferred:(NSNumber *)phonePreferre
[definition injectProperty:@selector(coreDataManager) with:[self.managersAssembly coreDataManager]];
[definition injectProperty:@selector(crashlyticsManager) with:[self.managersAssembly crashlyticsManager]];
[definition injectProperty:@selector(spotlightManager) with:[self.managersAssembly spotlightManager]];
[definition injectProperty:@selector(userDefaultsManager) with:[self.managersAssembly userDefaultsManager]];
[definition injectProperty:@selector(phonePreferred) with:phonePreferred];
[definition injectProperty:@selector(phone) with:phone];
[definition injectProperty:@selector(email) with:email];
Expand All @@ -212,6 +216,7 @@ - (BMPlacesTask *)placesTaskWithInput:(NSString *)input sessionToken:(GMSAutocom
[definition injectProperty:@selector(coreDataManager) with:[self.managersAssembly coreDataManager]];
[definition injectProperty:@selector(crashlyticsManager) with:[self.managersAssembly crashlyticsManager]];
[definition injectProperty:@selector(spotlightManager) with:[self.managersAssembly spotlightManager]];
[definition injectProperty:@selector(userDefaultsManager) with:[self.managersAssembly userDefaultsManager]];
}];
}

Expand All @@ -225,6 +230,7 @@ - (BMServiceTask *)airQualityTaskWithOnlyCurrentValues:(NSNumber *)currentValues
[definition injectProperty:@selector(coreDataManager) with:[self.managersAssembly coreDataManager]];
[definition injectProperty:@selector(crashlyticsManager) with:[self.managersAssembly crashlyticsManager]];
[definition injectProperty:@selector(spotlightManager) with:[self.managersAssembly spotlightManager]];
[definition injectProperty:@selector(userDefaultsManager) with:[self.managersAssembly userDefaultsManager]];
[definition injectProperty:@selector(currentValues) with:currentValues];
[definition injectProperty:@selector(onlyAverage) with:onlyAverage];
[definition injectProperty:@selector(discardAverage) with:discardAverage];
Expand All @@ -241,6 +247,7 @@ - (BMServiceTask *)allPartnersTask
[definition injectProperty:@selector(coreDataManager) with:[self.managersAssembly coreDataManager]];
[definition injectProperty:@selector(crashlyticsManager) with:[self.managersAssembly crashlyticsManager]];
[definition injectProperty:@selector(spotlightManager) with:[self.managersAssembly spotlightManager]];
[definition injectProperty:@selector(userDefaultsManager) with:[self.managersAssembly userDefaultsManager]];
definition.scope = TyphoonScopeSingleton;
}];
}
Expand Down
Expand Up @@ -60,6 +60,7 @@ - (void)awakeFromNib
self.pieChartView.legend.font = [UIFont systemFontOfSize:12.f];
self.pieChartView.legend.horizontalAlignment = ChartLegendHorizontalAlignmentCenter;
self.pieChartView.legend.verticalAlignment = ChartLegendVerticalAlignmentCenter;
self.pieChartView.legend.orientation = ChartLegendOrientationVertical;
self.pieChartView.legend.form = ChartLegendFormCircle;

[self configurePieChartView];
Expand Down
1 change: 1 addition & 0 deletions BiciMAD/Source/Classes/Models/BMStation.h
Expand Up @@ -27,6 +27,7 @@ typedef NS_ENUM(NSUInteger, BMLight) {
@property (nonatomic, copy, readonly) NSString *stationNumber;
@property (nonatomic, copy, readonly) NSString *name;
@property (nonatomic, copy, readonly) NSString *street;
@property (nonatomic, copy, readonly) NSArray *coordinates;
@property (nonatomic, assign, readonly) BOOL active;
@property (nonatomic, assign, readonly) NSUInteger freeStands;
@property (nonatomic, assign, readonly) NSUInteger totalStands;
Expand Down
11 changes: 11 additions & 0 deletions BiciMAD/Source/Classes/Models/BMStation.m
Expand Up @@ -136,6 +136,7 @@ + (NSDictionary *)JSONKeyPathsByPropertyKey
NSStringFromSelector(@selector(street)): @[@"direccion", @"address"],
NSStringFromSelector(@selector(latitude)): @[@"latitud", @"latitude"],
NSStringFromSelector(@selector(longitude)): @[@"longitud", @"longitude"],
NSStringFromSelector(@selector(coordinates)): @[@"geometry.coordinates"],
NSStringFromSelector(@selector(light)): @[@"luz", @"light"],
NSStringFromSelector(@selector(unavailable)): @[@"no_disponible", @"no_available"],
NSStringFromSelector(@selector(percentage)): @[@"porcentaje"]
Expand Down Expand Up @@ -176,6 +177,16 @@ - (NSUInteger)unavailableStands
return self.totalStands - self.freeStands - self.bikesHooked;
}

- (CLLocationDegrees)latitude
{
return [self.coordinates.lastObject doubleValue];
}

- (CLLocationDegrees)longitude
{
return [self.coordinates.firstObject doubleValue];
}

- (CLLocationCoordinate2D)coordinate
{
return CLLocationCoordinate2DMake(self.latitude, self.longitude);
Expand Down
2 changes: 2 additions & 0 deletions BiciMAD/Source/Classes/Services/BMServiceTask.h
Expand Up @@ -14,13 +14,15 @@
@class BMCoreDataManager;
@class Crashlytics;
@class BMSpotlightManager;
@class BMUserDefaultsManager;

@interface BMServiceTask : NSObject

@property (nonatomic, strong) BMFavoritesManager *favoritesManager;
@property (nonatomic, strong) BMCoreDataManager *coreDataManager;
@property (nonatomic, strong) Crashlytics *crashlyticsManager;
@property (nonatomic, strong) BMSpotlightManager *spotlightManager;
@property (nonatomic, strong) BMUserDefaultsManager *userDefaultsManager;

@property (nonatomic, strong) BMHTTPClient *HTTPClient;
@property (nonatomic, copy) void (^successBlock)(id responseObject);
Expand Down
Expand Up @@ -11,6 +11,7 @@
#import "BMServiceTaskProtocol.h"
#import "BMStation.h"
#import "BMAnalyticsManager.h"
#import "BMUserDefaultsManager.h"

@interface BMEMTAllStationsTask () <BMServiceTask>

Expand All @@ -23,6 +24,11 @@ - (NSString *)requestURLString
return kBMRequestAllStationsEMTURLString;
}

- (void)configureRequest:(BMMutableURLRequest *)request
{
[request addValue:[self.userDefaultsManager storedStringForKey:kBMEMTAccessTokenKey] forHTTPHeaderField:kBMEMTAccessTokenKey];
}

- (id)parseResponseObject:(NSDictionary *)responseObject error:(NSError **)error
{
NSArray *stations = nil;
Expand Down
6 changes: 6 additions & 0 deletions BiciMAD/Source/Classes/Services/Stations/BMEMTLoginTask.m
Expand Up @@ -10,6 +10,7 @@

#import "BMServiceTaskProtocol.h"
#import "BMAnalyticsManager.h"
#import "BMUserDefaultsManager.h"

@interface BMEMTLoginTask () <BMServiceTask>

Expand Down Expand Up @@ -51,6 +52,11 @@ - (id)parseResponseObject:(NSDictionary *)responseObject error:(NSError **)error
{
data = data[kBMEMTAccessTokenKey];
}

if ([data isKindOfClass:NSString.class])
{
[self.userDefaultsManager storeString:data forKey:kBMEMTAccessTokenKey];
}

return data;
}
Expand Down
Expand Up @@ -11,6 +11,7 @@
#import "BMServiceTaskProtocol.h"
#import "BMStation.h"
#import "BMAnalyticsManager.h"
#import "BMUserDefaultsManager.h"

@interface BMEMTSingleStationTask () <BMServiceTask>

Expand All @@ -23,6 +24,11 @@ - (NSString *)requestURLString
return [NSString stringWithFormat:@"%@/%@", kBMRequestSingleStationEMTURLString, self.stationId];
}

- (void)configureRequest:(BMMutableURLRequest *)request
{
[request addValue:[self.userDefaultsManager storedStringForKey:kBMEMTAccessTokenKey] forHTTPHeaderField:kBMEMTAccessTokenKey];
}

- (id)parseResponseObject:(NSDictionary *)responseObject error:(NSError **)error
{
NSArray *stations = nil;
Expand Down
1 change: 1 addition & 0 deletions Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c5519b

Please sign in to comment.