Skip to content

Commit c7d53c9

Browse files
committed
First implementation of today widget, removed stripe lib
1 parent 96de25f commit c7d53c9

28 files changed

Lines changed: 564 additions & 9 deletions

BitStore.xcodeproj/project.pbxproj

Lines changed: 195 additions & 2 deletions
Large diffs are not rendered by default.

BitStore/BitStore.entitlements

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5+
<key>com.apple.security.application-groups</key>
6+
<array/>
57
<key>keychain-access-groups</key>
68
<array>
79
<string>$(AppIdentifierPrefix)com.dylanmarriott.BitStore</string>

BitStore/Controller/AppStart.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#import "RequestHelper.h"
1717
#import "MainViewControllerPhone.h"
1818
#import "Keys.h"
19+
#import "SharedUser.h"
1920

2021
@implementation AppStart
2122

@@ -62,6 +63,10 @@ + (void)setupStorage {
6263
if ([UserDefaults instance].userId == nil) {
6364
[UserDefaults instance].userId = [[NSUUID UUID] UUIDString];
6465
}
66+
67+
if ([UserDefaults instance].sharedUser == nil) {
68+
[UserDefaults instance].sharedUser = [[SharedUser alloc] init];
69+
}
6570
}
6671

6772
+ (void)setupKeychain {

BitStore/Controller/Buy/BuyViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ - (void)viewWillAppear:(BOOL)animated {
5050
}
5151

5252
- (void)next:(id)sender {
53-
CreditCardInputViewController* vc = [[CreditCardInputViewController alloc] initWithOrder:[[Order alloc] initWithOrderId:_orderId amount:[self amount] price:_price]];
54-
[self.navigationController pushViewController:vc animated:YES];
53+
// CreditCardInputViewController* vc = [[CreditCardInputViewController alloc] initWithOrder:[[Order alloc] initWithOrderId:_orderId amount:[self amount] price:_price]];
54+
// [self.navigationController pushViewController:vc animated:YES];
5555
}
5656

5757
- (void)cancel:(id)sender {

BitStore/Helper/ExchangeHelper.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import "ExchangeListener.h"
1313
#import "RequestHelper.h"
1414
#import "Listeners.h"
15+
#import "SharedUser.h"
1516

1617
@implementation ExchangeHelper {
1718
Listeners* _listeners;
@@ -49,6 +50,12 @@ - (id)init {
4950
- (void)changeCurreny:(NSString *)currency {
5051
_exchange.currency = currency;
5152
_exchange.complete = NO;
53+
54+
// update shared user
55+
SharedUser* user = [UserDefaults instance].sharedUser;
56+
user.todayCurrency = currency;
57+
[UserDefaults instance].sharedUser = user;
58+
5259
[self storeState];
5360
[self notifyListeners];
5461
}

BitStore/Helper/UserDefaults.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@class Exchange;
1212
@class Address;
1313
@class ContactList;
14+
@class SharedUser;
1415

1516
@interface UserDefaults : NSObject
1617

@@ -28,6 +29,7 @@
2829
@property (nonatomic) BOOL buyShowed;
2930
@property (nonatomic) BOOL buyDismissed;
3031
@property (nonatomic) NSString* customerId;
32+
@property (nonatomic) SharedUser* sharedUser;
3133

3234
+ (UserDefaults *)instance;
3335
- (void)reset;

BitStore/Helper/UserDefaults.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#import "Exchange.h"
1111
#import "Address.h"
1212
#import "ContactList.h"
13+
#import "SharedUser.h"
1314

1415
@implementation UserDefaults {
1516
NSUserDefaults* _defaults;
@@ -170,13 +171,21 @@ - (void)setCustomerId:(NSString *)customerId {
170171
[_defaults synchronize];
171172
}
172173

174+
// SharedUser
175+
- (SharedUser *)sharedUser {
176+
return (SharedUser *)[self codableObjectForKey:@"sharedUser"];
177+
}
178+
179+
- (void)setSharedUser:(SharedUser *)sharedUser {
180+
[self setCodableObject:sharedUser forKey:@"sharedUser"];
181+
}
182+
173183
#pragma mark -
174184
- (void)reset {
175185
NSString* domain = [[NSBundle mainBundle] bundleIdentifier];
176186
[_defaults removePersistentDomainForName:domain];
177187
}
178188

179-
180189
#pragma mark - Private
181190
- (void)setCodableObject:(id<NSCoding>)object forKey:(NSString *)key {
182191
NSData* encoded = [NSKeyedArchiver archivedDataWithRootObject:object];

BitStore/Model/SharedUser.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// SharedUser.h
3+
// BitStore
4+
//
5+
// Created by Dylan Marriott on 23/09/14.
6+
// Copyright (c) 2014 Dylan Marriott. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
11+
@interface SharedUser : NSObject <NSCoding>
12+
13+
@property (nonatomic) NSNumber* todayCurrency;
14+
@property (nonatomic) NSString* cachedPrice;
15+
- (void)save;
16+
17+
@end

BitStore/Model/SharedUser.m

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// SharedUser.m
3+
// BitStore
4+
//
5+
// Created by Dylan Marriott on 23/09/14.
6+
// Copyright (c) 2014 Dylan Marriott. All rights reserved.
7+
//
8+
9+
#import "SharedUser.h"
10+
#import "UserDefaults.h"
11+
12+
@implementation SharedUser
13+
14+
- (id)init {
15+
if (self = [super init]) {
16+
self.todayCurrency = @"USD";
17+
}
18+
return self;
19+
}
20+
21+
- (id)initWithCoder:(NSCoder *)aDecoder {
22+
if (self = [super init]) {
23+
self.todayCurrency = [aDecoder decodeObjectForKey:@"todayCurrency"];
24+
self.cachedPrice = [aDecoder decodeObjectForKey:@"cachedPrice"];
25+
}
26+
return self;
27+
}
28+
29+
- (void)encodeWithCoder:(NSCoder *)encoder {
30+
[encoder encodeObject:self.todayCurrency forKey:@"todayCurrency"];
31+
[encoder encodeObject:self.cachedPrice forKey:@"cachedPrice"];
32+
}
33+
34+
- (NSString *)description {
35+
return [NSString stringWithFormat:@"currency: %@", self.todayCurrency];
36+
}
37+
38+
@end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.application-groups</key>
6+
<array/>
7+
</dict>
8+
</plist>

0 commit comments

Comments
 (0)