Skip to content

Commit e1eb625

Browse files
committed
Started work on the graph for the widget
1 parent e7dec79 commit e1eb625

88 files changed

Lines changed: 14945 additions & 5484 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

BitStore.xcodeproj/project.pbxproj

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
03CC5467197007F7000196ED /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 03CC5453197007F7000196ED /* Localizable.strings */; };
2525
03CC546A197007F7000196ED /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 03CC5459197007F7000196ED /* InfoPlist.strings */; };
2626
03F2E9B1194F0FD7007BE9A6 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03F2E9B0194F0FD7007BE9A6 /* Security.framework */; };
27+
10EF295C7B97C067A5F9AA8E /* libPods-BitStoreToday.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E560198C58F7245C708F984 /* libPods-BitStoreToday.a */; };
2728
3362B7A08C86427D8B01F912 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBA31FE505D94F7097170EA0 /* libPods.a */; };
2829
9A073F3F1996EDCD007E0D0F /* Order.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A073F3E1996EDCD007E0D0F /* Order.m */; };
2930
9A073F421996F044007E0D0F /* PhoneInputViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A073F411996F044007E0D0F /* PhoneInputViewController.m */; };
@@ -182,6 +183,8 @@
182183
03CC545A197007F7000196ED /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
183184
03CC545B197007F7000196ED /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
184185
03F2E9B0194F0FD7007BE9A6 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
186+
4F605E649F9D6F0AE44F3F2A /* Pods-BitStoreToday.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BitStoreToday.release.xcconfig"; path = "Pods/Target Support Files/Pods-BitStoreToday/Pods-BitStoreToday.release.xcconfig"; sourceTree = "<group>"; };
187+
5E560198C58F7245C708F984 /* libPods-BitStoreToday.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-BitStoreToday.a"; sourceTree = BUILT_PRODUCTS_DIR; };
185188
97F78A1D3EDCC16BCB360933 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
186189
9A073F3D1996EDCD007E0D0F /* Order.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Order.h; sourceTree = "<group>"; };
187190
9A073F3E1996EDCD007E0D0F /* Order.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Order.m; sourceTree = "<group>"; };
@@ -364,6 +367,7 @@
364367
9AF0C4F6196B3C3400F62DB5 /* BitStore.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = BitStore.entitlements; sourceTree = "<group>"; };
365368
9AFC4A12197F0F8400EAF46B /* KeysViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeysViewController.h; sourceTree = "<group>"; };
366369
9AFC4A13197F0F8400EAF46B /* KeysViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KeysViewController.m; sourceTree = "<group>"; };
370+
B326FAD56937F7A2BDF389C5 /* Pods-BitStoreToday.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BitStoreToday.debug.xcconfig"; path = "Pods/Target Support Files/Pods-BitStoreToday/Pods-BitStoreToday.debug.xcconfig"; sourceTree = "<group>"; };
367371
DBA31FE505D94F7097170EA0 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
368372
F37D8540456F2C742C2538E9 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
369373
/* End PBXFileReference section */
@@ -404,6 +408,7 @@
404408
buildActionMask = 2147483647;
405409
files = (
406410
9AAAC41E19D092FE00994EB6 /* NotificationCenter.framework in Frameworks */,
411+
10EF295C7B97C067A5F9AA8E /* libPods-BitStoreToday.a in Frameworks */,
407412
);
408413
runOnlyForDeploymentPostprocessing = 0;
409414
};
@@ -458,6 +463,7 @@
458463
03584683194F09A900521709 /* XCTest.framework */,
459464
DBA31FE505D94F7097170EA0 /* libPods.a */,
460465
9AAAC41D19D092FE00994EB6 /* NotificationCenter.framework */,
466+
5E560198C58F7245C708F984 /* libPods-BitStoreToday.a */,
461467
);
462468
name = Frameworks;
463469
sourceTree = "<group>";
@@ -495,6 +501,8 @@
495501
children = (
496502
97F78A1D3EDCC16BCB360933 /* Pods.debug.xcconfig */,
497503
F37D8540456F2C742C2538E9 /* Pods.release.xcconfig */,
504+
B326FAD56937F7A2BDF389C5 /* Pods-BitStoreToday.debug.xcconfig */,
505+
4F605E649F9D6F0AE44F3F2A /* Pods-BitStoreToday.release.xcconfig */,
498506
);
499507
name = Pods;
500508
sourceTree = "<group>";
@@ -919,9 +927,11 @@
919927
isa = PBXNativeTarget;
920928
buildConfigurationList = 9AAAC42E19D092FE00994EB6 /* Build configuration list for PBXNativeTarget "BitStoreToday" */;
921929
buildPhases = (
930+
B16192D7911A779E5FD35FBB /* Check Pods Manifest.lock */,
922931
9AAAC41819D092FD00994EB6 /* Sources */,
923932
9AAAC41919D092FD00994EB6 /* Frameworks */,
924933
9AAAC41A19D092FD00994EB6 /* Resources */,
934+
F14AC00112EC350B20BDC32A /* Copy Pods Resources */,
925935
);
926936
buildRules = (
927937
);
@@ -1039,6 +1049,21 @@
10391049
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
10401050
showEnvVarsInLog = 0;
10411051
};
1052+
B16192D7911A779E5FD35FBB /* Check Pods Manifest.lock */ = {
1053+
isa = PBXShellScriptBuildPhase;
1054+
buildActionMask = 2147483647;
1055+
files = (
1056+
);
1057+
inputPaths = (
1058+
);
1059+
name = "Check Pods Manifest.lock";
1060+
outputPaths = (
1061+
);
1062+
runOnlyForDeploymentPostprocessing = 0;
1063+
shellPath = /bin/sh;
1064+
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
1065+
showEnvVarsInLog = 0;
1066+
};
10421067
B9FE9F63172E4A6EA43BA228 /* Check Pods Manifest.lock */ = {
10431068
isa = PBXShellScriptBuildPhase;
10441069
buildActionMask = 2147483647;
@@ -1084,6 +1109,21 @@
10841109
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n";
10851110
showEnvVarsInLog = 0;
10861111
};
1112+
F14AC00112EC350B20BDC32A /* Copy Pods Resources */ = {
1113+
isa = PBXShellScriptBuildPhase;
1114+
buildActionMask = 2147483647;
1115+
files = (
1116+
);
1117+
inputPaths = (
1118+
);
1119+
name = "Copy Pods Resources";
1120+
outputPaths = (
1121+
);
1122+
runOnlyForDeploymentPostprocessing = 0;
1123+
shellPath = /bin/sh;
1124+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-BitStoreToday/Pods-BitStoreToday-resources.sh\"\n";
1125+
showEnvVarsInLog = 0;
1126+
};
10871127
/* End PBXShellScriptBuildPhase section */
10881128

10891129
/* Begin PBXSourcesBuildPhase section */
@@ -1469,6 +1509,7 @@
14691509
};
14701510
9AAAC42C19D092FE00994EB6 /* Debug */ = {
14711511
isa = XCBuildConfiguration;
1512+
baseConfigurationReference = B326FAD56937F7A2BDF389C5 /* Pods-BitStoreToday.debug.xcconfig */;
14721513
buildSettings = {
14731514
CLANG_WARN_UNREACHABLE_CODE = YES;
14741515
CODE_SIGN_ENTITLEMENTS = BitStoreToday/BitStoreToday.entitlements;
@@ -1491,6 +1532,7 @@
14911532
};
14921533
9AAAC42D19D092FE00994EB6 /* Release */ = {
14931534
isa = XCBuildConfiguration;
1535+
baseConfigurationReference = 4F605E649F9D6F0AE44F3F2A /* Pods-BitStoreToday.release.xcconfig */;
14941536
buildSettings = {
14951537
CLANG_WARN_UNREACHABLE_CODE = YES;
14961538
CODE_SIGN_ENTITLEMENTS = BitStoreToday/BitStoreToday.entitlements;

BitStoreToday/TodayViewController.m

Lines changed: 53 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,75 +10,78 @@
1010
#import <NotificationCenter/NotificationCenter.h>
1111
#import "SharedUser.h"
1212
#import "AccountActionButton.h"
13+
#import "BEMSimpleLineGraphView.h"
1314

14-
@interface TodayViewController () <NCWidgetProviding>
15+
@interface TodayViewController () <NCWidgetProviding, BEMSimpleLineGraphDataSource, BEMSimpleLineGraphDelegate>
1516

1617
@end
1718

1819
@implementation TodayViewController {
1920
SharedUser* _user;
2021
UILabel* _priceLabel;
22+
BEMSimpleLineGraphView* _chart;
23+
NSArray* _data;
2124
}
2225

2326
- (void)viewDidLoad {
2427
[super viewDidLoad];
2528
_user = [[SharedUser alloc] init];
26-
self.preferredContentSize = CGSizeMake(200, 64);
29+
self.preferredContentSize = CGSizeMake(0, 64);
2730
}
2831

2932
- (void)viewWillAppear:(BOOL)animated {
3033
[super viewWillAppear:animated];
3134

32-
UILabel* description = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];
35+
for (UIView* v in self.view.subviews) {
36+
[v removeFromSuperview];
37+
}
38+
39+
UILabel* description = [[UILabel alloc] initWithFrame:CGRectMake(0, 5, 200, 20)];
3340
description.text = NSLocalizedString(@"current_price", nil);
3441
description.font = [UIFont systemFontOfSize:13];
3542
description.textColor = [UIColor colorWithWhite:0.5 alpha:1.0];
3643
[self.view addSubview:description];
3744

38-
_priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 27, 200, 30)];
45+
_priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 200, 20)];
3946
_priceLabel.textColor = [UIColor whiteColor];
4047
_priceLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:24];
41-
[self updatePriceLabel];
4248
[self.view addSubview:_priceLabel];
4349

4450

4551
UIColor* buttonTintColor = [UIColor whiteColor];
4652
UIColor* buttonSelectedColor = [UIColor colorWithWhite:0.8 alpha:1.0];
4753

48-
NSString* sendTitle = NSLocalizedString(@"send", nil);
49-
AccountActionButton* sendButton = [[AccountActionButton alloc] initWithTitle:sendTitle image:[UIImage imageNamed:@"send"] selectedImage:[UIImage imageNamed:@"send_selected"]];
50-
sendButton.padding = 5;
51-
[sendButton setTintColor:buttonTintColor];
52-
[sendButton setSelectedTintColor:buttonSelectedColor];
53-
CGSize sendSize = [sendTitle sizeWithAttributes:@{NSFontAttributeName:sendButton.titleLabel.font}];
54-
[sendButton addTarget:self action:@selector(actionSend:) forControlEvents:UIControlEventTouchUpInside];
55-
[self.view addSubview:sendButton];
56-
57-
5854
NSString* receiveTitle = NSLocalizedString(@"receive", nil);
5955
AccountActionButton* receiveButton = [[AccountActionButton alloc] initWithTitle:receiveTitle image:[UIImage imageNamed:@"receive"] selectedImage:[UIImage imageNamed:@"receive_selected"]];
6056
receiveButton.padding = 10;
6157
[receiveButton setTintColor:buttonTintColor];
6258
[receiveButton setSelectedTintColor:buttonSelectedColor];
6359
CGSize receiveSize = [receiveTitle sizeWithAttributes:@{NSFontAttributeName:receiveButton.titleLabel.font}];
60+
receiveButton.frame = CGRectMake(self.view.bounds.size.width - receiveSize.width, 8, receiveSize.width, 50);
6461
[receiveButton addTarget:self action:@selector(actionReceive:) forControlEvents:UIControlEventTouchUpInside];
6562
[self.view addSubview:receiveButton];
6663

6764

68-
CGFloat width = sendSize.width + receiveSize.width;
69-
CGFloat padding = (180 - width) / 3;
70-
sendButton.frame = CGRectMake(self.view.bounds.size.width - sendSize.width - padding, 7, sendSize.width, 50);
71-
receiveButton.frame = CGRectMake(self.view.bounds.size.width - receiveSize.width - sendSize.width - padding * 2, 12, receiveSize.width, 50);
72-
}
73-
74-
- (void)actionSend:(id)sender {
75-
NSURL* url = [[NSURL alloc] initWithScheme:@"bitstore" host:nil path:@"/send"];
76-
[self.extensionContext openURL:url completionHandler:nil];
65+
_chart = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width - receiveSize.width - 134, 0, 120, 50)];
66+
_chart.dataSource = self;
67+
_chart.delegate = self;
68+
_chart.animationGraphStyle = BEMLineAnimationNone;
69+
_chart.colorTop = [UIColor clearColor];
70+
_chart.colorBottom = [UIColor colorWithWhite:1.0 alpha:0.15];
71+
[self.view addSubview:_chart];
72+
73+
[self updatePriceLabel];
74+
[self updateChart];
7775
}
7876

79-
- (void)actionReceive:(id)sender {
80-
NSURL* url = [[NSURL alloc] initWithScheme:@"bitstore" host:nil path:@"/receive"];
81-
[self.extensionContext openURL:url completionHandler:nil];
77+
- (void)actionReceive:(UIButton *)receiveButton {
78+
receiveButton.selected = !receiveButton.selected;
79+
receiveButton.highlighted = !receiveButton.selected;
80+
if (receiveButton.selected) {
81+
self.preferredContentSize = CGSizeMake(0, 400);
82+
} else {
83+
self.preferredContentSize = CGSizeMake(0, 64);
84+
}
8285
}
8386

8487
- (void)updatePriceLabel {
@@ -89,6 +92,12 @@ - (void)updatePriceLabel {
8992
}
9093
}
9194

95+
- (void)updateChart {
96+
_data = @[@3.5, @3.6, @3.2, @2.3, @2.5, @2.8, @2.5, @2.9, @3.4, @3.8];
97+
[_chart reloadGraph];
98+
}
99+
100+
#pragma mark - Widget
92101
- (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
93102
NSString* url = [NSString stringWithFormat:@"https://api.bitcoinaverage.com/ticker/global/%@", _user.todayCurrency];
94103
NSURLRequest* request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
@@ -97,24 +106,40 @@ - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))compl
97106
NSData *data,
98107
NSError *error) {
99108

109+
100110
if (!error && data) {
101111
NSError* jsonError;
102112
NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
103113
if (!jsonError) {
104114
_user.cachedPrice = [json objectForKey:@"last"];
105115
[self updatePriceLabel];
116+
[self updateChart];
106117
completionHandler(NCUpdateResultNewData);
107118
} else {
108119
completionHandler(NCUpdateResultFailed);
109120
}
110121
}
111122
completionHandler(NCUpdateResultFailed);
112123
}];
124+
125+
113126
}
114127

115128
- (UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMarginInsets {
116-
UIEdgeInsets newInsets = UIEdgeInsetsMake(18, defaultMarginInsets.left - 0, 18, defaultMarginInsets.right);
129+
UIEdgeInsets newInsets = UIEdgeInsetsMake(12, 18, 18, 18);
117130
return newInsets;
118131
}
119132

133+
#pragma mark - BEMSimpleLineGraphDataSource
134+
- (NSInteger)numberOfPointsInLineGraph:(BEMSimpleLineGraphView *)graph {
135+
return _data.count;
136+
}
137+
138+
- (CGFloat)lineGraph:(BEMSimpleLineGraphView *)graph valueForPointAtIndex:(NSInteger)index {
139+
return [[_data objectAtIndex:index] floatValue];
140+
}
141+
142+
#pragma mark - BEMSimpleLineGraphDelegate
143+
144+
120145
@end

Podfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@ pod 'NSDate+TimeAgo', '1.0.3'
1111
pod 'PiwikTracker', '2.5.1'
1212
pod 'SocketRocket', '0.3.1-beta2'
1313
pod 'iRate', '1.10.3'
14-
pod 'SimulatorStatusMagic', '1.2', :configurations => ['Debug']
14+
pod 'SimulatorStatusMagic', '1.2', :configurations => ['Debug']
15+
16+
target :BitStoreToday do
17+
pod 'BEMSimpleLineGraph', '3.2'
18+
end

Podfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
PODS:
22
- AFNetworking (1.3.2)
3+
- BEMSimpleLineGraph (3.2)
34
- CoreBitcoin (0.4.0):
45
- OpenSSL-Universal (= 1.0.1.h)
56
- DMPasscode (1.0.5)
@@ -14,6 +15,7 @@ PODS:
1415
- SocketRocket (0.3.1-beta2)
1516

1617
DEPENDENCIES:
18+
- BEMSimpleLineGraph (= 3.2)
1719
- CoreBitcoin (from `https://raw.github.com/oleganza/CoreBitcoin/master/CoreBitcoin.podspec`)
1820
- DMPasscode (= 1.0.5)
1921
- FXBlurView (= 1.6.2)
@@ -31,6 +33,7 @@ EXTERNAL SOURCES:
3133

3234
SPEC CHECKSUMS:
3335
AFNetworking: 13fd672bb1f6919946d259d97f31000015680dfa
36+
BEMSimpleLineGraph: 68e349eb22320d1a21a29e390d0f67772f6f6f44
3437
CoreBitcoin: 0957e9fa7a31867b91f459f943bd9144d397b624
3538
DMPasscode: 00a648461fa8d1d6bf0098848e3a4be094fcf012
3639
FXBlurView: 47496afc9160097fa34af35fc4b310bd85d65dca

Pods/BEMSimpleLineGraph/Classes/BEMCircle.h

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Pods/BEMSimpleLineGraph/Classes/BEMCircle.m

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)