@@ -25,6 +25,7 @@ @implementation TodayViewController {
2525 BEMSimpleLineGraphView* _bigChart;
2626 UIView* _bigChartContainer;
2727 BOOL _chartOpen;
28+ AccountActionButton* _receiveButton;
2829}
2930
3031- (void )viewDidLoad {
@@ -56,14 +57,14 @@ - (void)viewWillAppear:(BOOL)animated {
5657 UIColor* buttonSelectedColor = [UIColor colorWithWhite: 0.8 alpha: 1.0 ];
5758
5859 NSString * receiveTitle = NSLocalizedString(@" receive" , nil );
59- AccountActionButton* receiveButton = [[AccountActionButton alloc ] initWithTitle: receiveTitle image: [UIImage imageNamed: @" receive" ] selectedImage: [UIImage imageNamed: @" receive_selected" ]];
60- receiveButton .padding = 10 ;
61- [receiveButton setTintColor: buttonTintColor];
62- [receiveButton setSelectedTintColor: buttonSelectedColor];
63- CGSize receiveSize = [receiveTitle sizeWithAttributes: @{NSFontAttributeName :receiveButton .titleLabel .font }];
64- receiveButton .frame = CGRectMake (self.view .bounds .size .width - receiveSize.width , 8 , receiveSize.width , 50 );
65- [receiveButton addTarget: self action: @selector (actionReceive: ) forControlEvents: UIControlEventTouchUpInside];
66- [self .view addSubview: receiveButton ];
60+ _receiveButton = [[AccountActionButton alloc ] initWithTitle: receiveTitle image: [UIImage imageNamed: @" receive" ] selectedImage: [UIImage imageNamed: @" receive_selected" ]];
61+ _receiveButton .padding = 10 ;
62+ [_receiveButton setTintColor: buttonTintColor];
63+ [_receiveButton setSelectedTintColor: buttonSelectedColor];
64+ CGSize receiveSize = [receiveTitle sizeWithAttributes: @{NSFontAttributeName :_receiveButton .titleLabel .font }];
65+ _receiveButton .frame = CGRectMake (self.view .bounds .size .width - receiveSize.width , 8 , receiveSize.width , 50 );
66+ [_receiveButton addTarget: self action: @selector (actionReceive: ) forControlEvents: UIControlEventTouchUpInside];
67+ [self .view addSubview: _receiveButton ];
6768
6869
6970 UIImage* qrImage = [QRHelper qrcode: _user.address withDimension: self .view.bounds.size.width];
@@ -109,9 +110,21 @@ - (void)viewWillAppear:(BOOL)animated {
109110}
110111
111112- (void )actionReceive : (UIButton *)receiveButton {
112- BOOL selected = !receiveButton.selected ;
113- receiveButton.selected = selected;
114- receiveButton.highlighted = selected;
113+ if (_chartOpen) {
114+ [self toggleGraph ];
115+ }
116+ [self toggleReceive ];
117+ if (_receiveButton.selected ) {
118+ self.preferredContentSize = CGSizeMake (0 , self.view .frame .size .width + 64 );
119+ } else {
120+ self.preferredContentSize = CGSizeMake (0 , 64 );
121+ }
122+ }
123+
124+ - (void )toggleReceive {
125+ BOOL selected = !_receiveButton.selected ;
126+ _receiveButton.selected = selected;
127+ _receiveButton.highlighted = selected;
115128
116129 [UIView animateWithDuration: 0.3 animations: ^() {
117130 if (selected) {
@@ -120,22 +133,27 @@ - (void)actionReceive:(UIButton *)receiveButton {
120133 _qrImageView.alpha = 0.0 ;
121134 }
122135 }];
123-
124- if (selected) {
125- self.preferredContentSize = CGSizeMake (0 , self.view .frame .size .width + 64 );
136+ }
137+
138+ - (void )actionGraph : (id )sender {
139+ if (_receiveButton.selected ) {
140+ [self toggleReceive ];
141+ }
142+ [self toggleGraph ];
143+ if (_chartOpen) {
144+ self.preferredContentSize = CGSizeMake (0 , 150 + 64 );
126145 } else {
127146 self.preferredContentSize = CGSizeMake (0 , 64 );
128147 }
129148}
130149
131- - (void )actionGraph : ( id ) sender {
150+ - (void )toggleGraph {
132151 _chartOpen = !_chartOpen;
152+
133153 if (_chartOpen) {
134154 _miniChart.colorBottom = [UIColor colorWithWhite: 1.0 alpha: 0.45 ];
135- self.preferredContentSize = CGSizeMake (0 , 150 + 64 );
136155 } else {
137156 _miniChart.colorBottom = [UIColor colorWithWhite: 1.0 alpha: 0.15 ];
138- self.preferredContentSize = CGSizeMake (0 , 64 );
139157 }
140158
141159 [UIView animateWithDuration: 0.3 animations: ^() {
0 commit comments