Skip to content

Commit 9445259

Browse files
committed
Added QR code to widget
1 parent d4ecefb commit 9445259

8 files changed

Lines changed: 70 additions & 10 deletions

File tree

BitStore.xcodeproj/project.pbxproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@
112112
9ABC07311983191E00EC87A3 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9ABC07301983191E00EC87A3 /* MobileCoreServices.framework */; };
113113
9ABC073419831C8900EC87A3 /* ReceiveAmountViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9ABC073319831C8900EC87A3 /* ReceiveAmountViewController.m */; };
114114
9ADFAD57194F8116009427DF /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9ADFAD56194F8116009427DF /* AVFoundation.framework */; };
115+
9AE335BC1A268FBD00021269 /* bitstream.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A7311950D70A001FCE32 /* bitstream.c */; };
116+
9AE335BD1A268FC200021269 /* mask.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A7341950D70A001FCE32 /* mask.c */; };
117+
9AE335BE1A268FC500021269 /* qrenc.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A7361950D70A001FCE32 /* qrenc.c */; settings = {COMPILER_FLAGS = "-w"; }; };
118+
9AE335BF1A268FC800021269 /* qrencode.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A7371950D70A001FCE32 /* qrencode.c */; settings = {COMPILER_FLAGS = "-w"; }; };
119+
9AE335C01A268FCC00021269 /* qrinput.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A73A1950D70A001FCE32 /* qrinput.c */; };
120+
9AE335C11A268FCF00021269 /* qrspec.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A73C1950D70A001FCE32 /* qrspec.c */; };
121+
9AE335C21A268FD200021269 /* rscode.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A73E1950D70A001FCE32 /* rscode.c */; };
122+
9AE335C31A268FD500021269 /* split.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A7401950D70A001FCE32 /* split.c */; settings = {COMPILER_FLAGS = "-w"; }; };
123+
9AE335C41A268FED00021269 /* QRHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A67A7181950D70A001FCE32 /* QRHelper.m */; };
115124
9AFC4A14197F0F8400EAF46B /* KeysViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AFC4A13197F0F8400EAF46B /* KeysViewController.m */; };
116125
A423E0B434094809ABF9EF1D /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DBA31FE505D94F7097170EA0 /* libPods.a */; };
117126
/* End PBXBuildFile section */
@@ -1201,8 +1210,17 @@
12011210
isa = PBXSourcesBuildPhase;
12021211
buildActionMask = 2147483647;
12031212
files = (
1213+
9AE335C31A268FD500021269 /* split.c in Sources */,
12041214
9A9D588019D1F63200EA940A /* Keys.m in Sources */,
1215+
9AE335BE1A268FC500021269 /* qrenc.c in Sources */,
1216+
9AE335BC1A268FBD00021269 /* bitstream.c in Sources */,
1217+
9AE335C21A268FD200021269 /* rscode.c in Sources */,
1218+
9AE335C11A268FCF00021269 /* qrspec.c in Sources */,
12051219
9AAAC42419D092FE00994EB6 /* TodayViewController.m in Sources */,
1220+
9AE335BF1A268FC800021269 /* qrencode.c in Sources */,
1221+
9AE335C01A268FCC00021269 /* qrinput.c in Sources */,
1222+
9AE335C41A268FED00021269 /* QRHelper.m in Sources */,
1223+
9AE335BD1A268FC200021269 /* mask.c in Sources */,
12061224
9A9D588419D1F8F200EA940A /* SharedUser.m in Sources */,
12071225
9A9D588F19D4867700EA940A /* AccountActionButton.m in Sources */,
12081226
);

BitStore/Config/Keys.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111
@implementation Keys
1212

1313
+ (NSString *)chainKey {
14-
return @"";
14+
return @"fd231d38cbc484a9ca05005d5c9477c2";
1515
}
1616

1717
+ (NSString *)ringCaptchaAppKey {
18-
return @"";
18+
return @"i1ohi2o3o6uja2iqoqiq";
1919
}
2020

2121
+ (NSString *)ringCaptchaAPIKey {
22-
return @"";
22+
return @"75dc2a6ce4668f08fbae3482bdf6b9582d7f378d";
2323
}
2424

2525
+ (NSString *)analyticsKey {
26-
return @"";
26+
return @"6ad579d388160736086a9190cc5ff133";
2727
}
2828

2929
+ (NSString *)stripeTestKey {
30-
return @"";
30+
return @"pk_test_4SpT6lRqwpbCMhV1nMinAUaC";
3131
}
3232

3333
+ (NSString *)stripeProductionKey {
34-
return @"";
34+
return @"pk_live_4SpTDVMx4YrqpZKvP8mF6Seq";
3535
}
3636

3737
@end

BitStore/Controller/AppStart.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ + (void)setupKeychain {
9898
address.address = publicKey;
9999
[[AddressHelper instance] addAddress:address];
100100
}
101+
102+
103+
// for today widget
104+
SharedUser* sharedUser = [[SharedUser alloc] init];
105+
if (sharedUser.address == nil) {
106+
sharedUser.address = [AddressHelper instance].defaultAddress.address;
107+
}
101108
}
102109

103110
+ (void)setupRate {

BitStore/Helper/QRHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import <Foundation/Foundation.h>
10+
#import <UIKit/UIKit.h>
1011

1112
@interface QRHelper : NSObject
1213

BitStore/Helper/QRHelper.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ void freeRawData(void *info, const void *data, size_t size) {
1919

2020
+ (UIImage *)qrcode:(NSString *)dataString withDimension:(int)imageWidth {
2121

22+
if (dataString == nil) {
23+
return nil;
24+
}
25+
2226
QRcode *resultCode = QRcode_encodeString([dataString UTF8String], 0, QR_ECLEVEL_L, QR_MODE_8, 1);
2327

2428
unsigned char *pixels = (*resultCode).data;

BitStore/Model/SharedUser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212

1313
@property (nonatomic) NSString* todayCurrency;
1414
@property (nonatomic) NSNumber* cachedPrice;
15+
@property (nonatomic) NSString* address;
1516

1617
@end

BitStore/Model/SharedUser.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,13 @@ - (void)setCachedPrice:(NSNumber *)cachedPrice {
4343
[_defaults synchronize];
4444
}
4545

46+
- (NSString *)address {
47+
return [_defaults objectForKey:@"address"];
48+
}
49+
50+
- (void)setAddress:(NSString *)address {
51+
[_defaults setObject:address forKey:@"address"];
52+
[_defaults synchronize];
53+
}
54+
4655
@end

BitStoreToday/TodayViewController.m

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "SharedUser.h"
1212
#import "AccountActionButton.h"
1313
#import "BEMSimpleLineGraphView.h"
14+
#import "QRHelper.h"
1415

1516
@interface TodayViewController () <NCWidgetProviding, BEMSimpleLineGraphDataSource, BEMSimpleLineGraphDelegate>
1617

@@ -19,6 +20,7 @@ @interface TodayViewController () <NCWidgetProviding, BEMSimpleLineGraphDataSour
1920
@implementation TodayViewController {
2021
SharedUser* _user;
2122
UILabel* _priceLabel;
23+
UIImageView* _qrImageView;
2224
BEMSimpleLineGraphView* _chart;
2325
NSArray* _data;
2426
}
@@ -62,6 +64,14 @@ - (void)viewWillAppear:(BOOL)animated {
6264
[self.view addSubview:receiveButton];
6365

6466

67+
UIImage* qrImage = [QRHelper qrcode:_user.address withDimension:self.view.bounds.size.width];
68+
_qrImageView = [[UIImageView alloc] initWithImage:qrImage];
69+
_qrImageView.frame = CGRectMake(0, 64, qrImage.size.width, qrImage.size.height);
70+
_qrImageView.backgroundColor = [UIColor yellowColor];
71+
_qrImageView.alpha = 0.0;
72+
[self.view addSubview:_qrImageView];
73+
74+
6575
_chart = [[BEMSimpleLineGraphView alloc] initWithFrame:CGRectMake(self.view.bounds.size.width - receiveSize.width - 134, 0, 120, 50)];
6676
_chart.dataSource = self;
6777
_chart.delegate = self;
@@ -75,10 +85,20 @@ - (void)viewWillAppear:(BOOL)animated {
7585
}
7686

7787
- (void)actionReceive:(UIButton *)receiveButton {
78-
receiveButton.selected = !receiveButton.selected;
79-
receiveButton.highlighted = !receiveButton.selected;
80-
if (receiveButton.selected) {
81-
self.preferredContentSize = CGSizeMake(0, 400);
88+
BOOL selected = !receiveButton.selected;
89+
receiveButton.selected = selected;
90+
receiveButton.highlighted = selected;
91+
92+
[UIView animateWithDuration:0.3 animations:^() {
93+
if (selected) {
94+
_qrImageView.alpha = 1.0;
95+
} else {
96+
_qrImageView.alpha = 0.0;
97+
}
98+
}];
99+
100+
if (selected) {
101+
self.preferredContentSize = CGSizeMake(0, self.view.frame.size.width + 64);
82102
} else {
83103
self.preferredContentSize = CGSizeMake(0, 64);
84104
}

0 commit comments

Comments
 (0)