Commit b0ce6aa26a53bc19895976c0c36de4825d1015d4

Authored by phong
1 parent c3656cafff
Exists in master

fix bug gui iphone x

Showing 10 changed files with 25 additions and 14 deletions Inline Diff

LifeLog/LifeLog/HistoryViewController.m
1 // 1 //
2 // HistoryViewController.m 2 // HistoryViewController.m
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by Nguyen Van Phong on 7/25/17. 5 // Created by Nguyen Van Phong on 7/25/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import "HistoryViewController.h" 9 #import "HistoryViewController.h"
10 #import "Utilities.h" 10 #import "Utilities.h"
11 #import "ServerAPI.h" 11 #import "ServerAPI.h"
12 12
13 #import "HistoryListTableViewCell.h" 13 #import "HistoryListTableViewCell.h"
14 14
15 @interface HistoryViewController () 15 @interface HistoryViewController ()
16 16
17 @end 17 @end
18 18
19 @implementation HistoryViewController 19 @implementation HistoryViewController
20 20
21 - (void)viewDidLoad { 21 - (void)viewDidLoad {
22 [super viewDidLoad]; 22 [super viewDidLoad];
23 [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.bottomLayoutGuide attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.viewCollectionMode attribute:NSLayoutAttributeBottom multiplier:1 constant:0]];
23 // Do any additional setup after loading the view from its nib. 24 // Do any additional setup after loading the view from its nib.
24 self.title = NSLocalizedString(@"lifelog.history.title", nil); 25 self.title = NSLocalizedString(@"lifelog.history.title", nil);
25 26
26 _isDisableLoadMore = true; 27 _isDisableLoadMore = true;
27 28
28 [self setupView]; 29 [self setupView];
29 [self setupChartView]; 30 [self setupChartView];
30 31
31 _startDate = [NSDate date]; 32 _startDate = [NSDate date];
32 _endDate = _startDate; 33 _endDate = _startDate;
33 34
34 self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"]; 35 self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"];
35 36
36 //register nib for table view 37 //register nib for table view
37 [self.tableBase registerNib:[UINib nibWithNibName:@"HistoryListTableViewCell" bundle:nil] forCellReuseIdentifier:@"HistoryListCell"]; 38 [self.tableBase registerNib:[UINib nibWithNibName:@"HistoryListTableViewCell" bundle:nil] forCellReuseIdentifier:@"HistoryListCell"];
38 } 39 }
39 40
40 - (void)viewDidAppear:(BOOL) animated 41 - (void)viewDidAppear:(BOOL) animated
41 { 42 {
42 [super viewDidAppear:animated]; 43 [super viewDidAppear:animated];
43 self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 400); 44 self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 400);
44 [self.scrollView setNeedsLayout]; 45 [self.scrollView setNeedsLayout];
45 [self.scrollView setNeedsUpdateConstraints]; 46 [self.scrollView setNeedsUpdateConstraints];
46 [self checkRequestData]; 47 [self checkRequestData];
47 } 48 }
48 49
49 - (void)didReceiveMemoryWarning { 50 - (void)didReceiveMemoryWarning {
50 [super didReceiveMemoryWarning]; 51 [super didReceiveMemoryWarning];
51 // Dispose of any resources that can be recreated. 52 // Dispose of any resources that can be recreated.
52 } 53 }
53 54
54 - (void)setupView { 55 - (void)setupView {
55 NSArray *typeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.history.type.1", nil), NSLocalizedString(@"lifelog.history.type.2", nil), NSLocalizedString(@"lifelog.history.type.3", nil), NSLocalizedString(@"lifelog.history.type.4", nil), NSLocalizedString(@"lifelog.history.type.5", nil), nil]; 56 NSArray *typeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.history.type.1", nil), NSLocalizedString(@"lifelog.history.type.2", nil), NSLocalizedString(@"lifelog.history.type.3", nil), NSLocalizedString(@"lifelog.history.type.4", nil), NSLocalizedString(@"lifelog.history.type.5", nil), nil];
56 [self.viewCollectionType setButtonNumber:typeTitle.count]; 57 [self.viewCollectionType setButtonNumber:typeTitle.count];
57 [self.viewCollectionType setSpacing:2]; 58 [self.viewCollectionType setSpacing:2];
58 [self.viewCollectionType setArrayTitle:typeTitle]; 59 [self.viewCollectionType setArrayTitle:typeTitle];
59 self.viewCollectionType.changeCurrentIndex = ^(int index){ 60 self.viewCollectionType.changeCurrentIndex = ^(int index){
60 [self changeDate]; 61 [self changeDate];
61 }; 62 };
62 63
63 NSArray *modeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.history.mode.1", nil), NSLocalizedString(@"lifelog.history.mode.2", nil), NSLocalizedString(@"lifelog.history.mode.3", nil), nil]; 64 NSArray *modeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.history.mode.1", nil), NSLocalizedString(@"lifelog.history.mode.2", nil), NSLocalizedString(@"lifelog.history.mode.3", nil), nil];
64 [self.viewCollectionMode setButtonNumber:modeTitle.count]; 65 [self.viewCollectionMode setButtonNumber:modeTitle.count];
65 [self.viewCollectionMode setSpacing:0]; 66 [self.viewCollectionMode setSpacing:0];
66 [self.viewCollectionMode setSelectedIndex:1]; 67 [self.viewCollectionMode setSelectedIndex:1];
67 [self.viewCollectionMode setCornerRadius:0]; 68 [self.viewCollectionMode setCornerRadius:0];
68 [self.viewCollectionMode setNormalColor:[Utilities convertHecToColor:0x191919] highlightColor:[Utilities convertHecToColor:0x474747] textColor:[UIColor whiteColor]]; 69 [self.viewCollectionMode setNormalColor:[Utilities convertHecToColor:0x191919] highlightColor:[Utilities convertHecToColor:0x474747] textColor:[UIColor whiteColor]];
69 [self.viewCollectionMode setArrayTitle:modeTitle]; 70 [self.viewCollectionMode setArrayTitle:modeTitle];
70 self.viewCollectionMode.changeCurrentIndex = ^(int index){ 71 self.viewCollectionMode.changeCurrentIndex = ^(int index){
71 if(self.tableBase.alpha == 0.0) { 72 if(self.tableBase.alpha == 0.0) {
72 [self updateView]; 73 [self updateView];
73 } 74 }
74 else { 75 else {
75 NSArray * list = [_curListArray objectAtIndex:index]; 76 NSArray * list = [_curListArray objectAtIndex:index];
76 [self updateTableData:list error:nil]; 77 [self updateTableData:list error:nil];
77 } 78 }
78 }; 79 };
79 80
80 NSArray *shareTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.history.share.1", nil), NSLocalizedString(@"lifelog.history.share.2", nil), NSLocalizedString(@"lifelog.history.share.3", nil), NSLocalizedString(@"lifelog.history.share.4", nil), NSLocalizedString(@"lifelog.history.share.5", nil), nil]; 81 NSArray *shareTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.history.share.1", nil), NSLocalizedString(@"lifelog.history.share.2", nil), NSLocalizedString(@"lifelog.history.share.3", nil), NSLocalizedString(@"lifelog.history.share.4", nil), NSLocalizedString(@"lifelog.history.share.5", nil), nil];
81 [self.viewCollectionShare setButtonNumber:typeTitle.count]; 82 [self.viewCollectionShare setButtonNumber:typeTitle.count];
82 [self.viewCollectionShare setSpacing:3]; 83 [self.viewCollectionShare setSpacing:3];
83 [self.viewCollectionShare setArrayTitle:shareTitle]; 84 [self.viewCollectionShare setArrayTitle:shareTitle];
84 [self.viewCollectionShare disableSelection]; 85 [self.viewCollectionShare disableSelection];
85 86
86 //add tap gesture for enable tap on gesture on CollectionView in ScrollView 87 //add tap gesture for enable tap on gesture on CollectionView in ScrollView
87 UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gestureAction:)]; 88 UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gestureAction:)];
88 [recognizer setNumberOfTapsRequired:1]; 89 [recognizer setNumberOfTapsRequired:1];
89 self.scrollView.userInteractionEnabled = YES; 90 self.scrollView.userInteractionEnabled = YES;
90 [self.scrollView addGestureRecognizer:recognizer]; 91 [self.scrollView addGestureRecognizer:recognizer];
91 } 92 }
92 93
93 - (void)setupChartView { 94 - (void)setupChartView {
94 self.viewBarChart.chartDescription.enabled = NO; 95 self.viewBarChart.chartDescription.enabled = NO;
95 self.viewBarChart.leftAxis.drawGridLinesEnabled = NO; 96 self.viewBarChart.leftAxis.drawGridLinesEnabled = NO;
96 self.viewBarChart.rightAxis.drawGridLinesEnabled = NO; 97 self.viewBarChart.rightAxis.drawGridLinesEnabled = NO;
97 self.viewBarChart.legend.enabled = NO; 98 self.viewBarChart.legend.enabled = NO;
98 99
99 ChartXAxis *xAxis = self.viewBarChart.xAxis; 100 ChartXAxis *xAxis = self.viewBarChart.xAxis;
100 xAxis.labelPosition = XAxisLabelPositionBottom; 101 xAxis.labelPosition = XAxisLabelPositionBottom;
101 xAxis.drawGridLinesEnabled = NO; 102 xAxis.drawGridLinesEnabled = NO;
102 xAxis.drawAxisLineEnabled = NO; 103 xAxis.drawAxisLineEnabled = NO;
103 xAxis.drawLabelsEnabled = YES; 104 xAxis.drawLabelsEnabled = YES;
104 xAxis.labelPosition = XAxisLabelPositionBottom; 105 xAxis.labelPosition = XAxisLabelPositionBottom;
105 xAxis.labelFont = [UIFont systemFontOfSize:10.f]; 106 xAxis.labelFont = [UIFont systemFontOfSize:10.f];
106 xAxis.labelTextColor = [UIColor whiteColor]; 107 xAxis.labelTextColor = [UIColor whiteColor];
107 xAxis.granularity = 1.0; // only intervals of 1 day 108 xAxis.granularity = 1.0; // only intervals of 1 day
108 xAxis.labelCount = 8; 109 xAxis.labelCount = 8;
109 110
110 self.viewBarChart.leftAxis.drawAxisLineEnabled = NO; 111 self.viewBarChart.leftAxis.drawAxisLineEnabled = NO;
111 self.viewBarChart.rightAxis.drawAxisLineEnabled = NO; 112 self.viewBarChart.rightAxis.drawAxisLineEnabled = NO;
112 } 113 }
113 114
114 -(void) updateView { 115 -(void) updateView {
115 HistoryObject * obj = [_curHisArray objectAtIndex:self.viewCollectionMode.getCurrentIndex]; 116 HistoryObject * obj = [_curHisArray objectAtIndex:self.viewCollectionMode.getCurrentIndex];
116 self.lblStep.text = [NSString stringWithFormat:@"%d step", obj.target]; 117 self.lblStep.text = [NSString stringWithFormat:@"%d step", obj.target];
117 self.lblCircleStep.text = [NSString stringWithFormat:@"%d step", obj.step]; 118 self.lblCircleStep.text = [NSString stringWithFormat:@"%d step", obj.step];
118 self.lblRemaining.text = [NSString stringWithFormat:@"%d step", obj.missing]; 119 self.lblRemaining.text = [NSString stringWithFormat:@"%d step", obj.missing];
119 self.lblCircleRemain.text = [NSString stringWithFormat:@"目標まであと\n%d stepです", obj.missing]; 120 self.lblCircleRemain.text = [NSString stringWithFormat:@"目標まであと\n%d stepです", obj.missing];
120 self.lblPercent.text = [NSString stringWithFormat:@"%0.2f%%", obj.percent]; 121 self.lblPercent.text = [NSString stringWithFormat:@"%0.2f%%", obj.percent];
121 self.lblCalories.text = [NSString stringWithFormat:@"%0.2f kcal", obj.calories]; 122 self.lblCalories.text = [NSString stringWithFormat:@"%0.2f kcal", obj.calories];
122 self.lblDistance.text = [NSString stringWithFormat:@"%0.1f KM", obj.distance]; 123 self.lblDistance.text = [NSString stringWithFormat:@"%0.1f KM", obj.distance];
123 self.lblTime.text = [Utilities convertSecondToShortTime:obj.time]; 124 self.lblTime.text = [Utilities convertSecondToShortTime:obj.time];
124 [self updateGraphView]; 125 [self updateGraphView];
125 } 126 }
126 127
127 -(void) updateGraphView { 128 -(void) updateGraphView {
128 HistoryObject * obj = [_curHisArray objectAtIndex:self.viewCollectionMode.getCurrentIndex]; 129 HistoryObject * obj = [_curHisArray objectAtIndex:self.viewCollectionMode.getCurrentIndex];
129 130
130 NSMutableArray *yVals = [[NSMutableArray alloc] init]; 131 NSMutableArray *yVals = [[NSMutableArray alloc] init];
131 for (int i = 0; i < obj.dataGraph.count; i++) 132 for (int i = 0; i < obj.dataGraph.count; i++)
132 { 133 {
133 [yVals addObject:[[BarChartDataEntry alloc] initWithX:i y:[[obj.dataGraph objectAtIndex:i] doubleValue]]]; 134 [yVals addObject:[[BarChartDataEntry alloc] initWithX:i y:[[obj.dataGraph objectAtIndex:i] doubleValue]]];
134 } 135 }
135 136
136 BarChartDataSet *set1 = nil; 137 BarChartDataSet *set1 = nil;
137 if (self.viewBarChart.data.dataSetCount > 0) 138 if (self.viewBarChart.data.dataSetCount > 0)
138 { 139 {
139 set1 = (BarChartDataSet *)self.viewBarChart.data.dataSets[0]; 140 set1 = (BarChartDataSet *)self.viewBarChart.data.dataSets[0];
140 set1.values = yVals; 141 set1.values = yVals;
141 142
142 NSMutableArray *color = [[NSMutableArray alloc] init]; 143 NSMutableArray *color = [[NSMutableArray alloc] init];
143 for(int i = 0; i < yVals.count; i++) { 144 for(int i = 0; i < yVals.count; i++) {
144 BarChartDataEntry *en = yVals[i]; 145 BarChartDataEntry *en = yVals[i];
145 if(obj.step != 0) { 146 if(obj.step != 0) {
146 double percent = en.y / obj.step * 100; 147 double percent = en.y / obj.step * 100;
147 if(percent > 80) { 148 if(percent > 80) {
148 [color addObject:[UIColor redColor]]; 149 [color addObject:[UIColor redColor]];
149 } 150 }
150 else if(percent > 60) { 151 else if(percent > 60) {
151 [color addObject:[UIColor yellowColor]]; 152 [color addObject:[UIColor yellowColor]];
152 } 153 }
153 else { 154 else {
154 [color addObject:[UIColor whiteColor]]; 155 [color addObject:[UIColor whiteColor]];
155 } 156 }
156 } 157 }
157 else { 158 else {
158 [color addObject:[UIColor whiteColor]]; 159 [color addObject:[UIColor whiteColor]];
159 } 160 }
160 } 161 }
161 [set1 setColors:color]; 162 [set1 setColors:color];
162 163
163 [self.viewBarChart.data notifyDataChanged]; 164 [self.viewBarChart.data notifyDataChanged];
164 [self.viewBarChart notifyDataSetChanged]; 165 [self.viewBarChart notifyDataSetChanged];
165 } 166 }
166 else 167 else
167 { 168 {
168 set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@""]; 169 set1 = [[BarChartDataSet alloc] initWithValues:yVals label:@""];
169 170
170 NSMutableArray *color = [[NSMutableArray alloc] init]; 171 NSMutableArray *color = [[NSMutableArray alloc] init];
171 for(int i = 0; i < yVals.count; i++) { 172 for(int i = 0; i < yVals.count; i++) {
172 BarChartDataEntry *en = yVals[i]; 173 BarChartDataEntry *en = yVals[i];
173 if(obj.step != 0) { 174 if(obj.step != 0) {
174 double percent = en.y / obj.step * 100; 175 double percent = en.y / obj.step * 100;
175 if(percent > 80) { 176 if(percent > 80) {
176 [color addObject:[UIColor redColor]]; 177 [color addObject:[UIColor redColor]];
177 } 178 }
178 else if(percent > 60) { 179 else if(percent > 60) {
179 [color addObject:[UIColor yellowColor]]; 180 [color addObject:[UIColor yellowColor]];
180 } 181 }
181 else { 182 else {
182 [color addObject:[UIColor whiteColor]]; 183 [color addObject:[UIColor whiteColor]];
183 } 184 }
184 } 185 }
185 else { 186 else {
186 [color addObject:[UIColor whiteColor]]; 187 [color addObject:[UIColor whiteColor]];
187 } 188 }
188 } 189 }
189 [set1 setColors:color]; 190 [set1 setColors:color];
190 NSMutableArray *dataSets = [[NSMutableArray alloc] init]; 191 NSMutableArray *dataSets = [[NSMutableArray alloc] init];
191 [dataSets addObject:set1]; 192 [dataSets addObject:set1];
192 193
193 BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets]; 194 BarChartData *data = [[BarChartData alloc] initWithDataSets:dataSets];
194 data.barWidth = 0.5f; 195 data.barWidth = 0.5f;
195 196
196 self.viewBarChart.data = data; 197 self.viewBarChart.data = data;
197 } 198 }
198 } 199 }
199 200
200 -(void) checkRequestData { 201 -(void) checkRequestData {
201 if(self.tableBase.alpha == 0.0) { 202 if(self.tableBase.alpha == 0.0) {
202 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 203 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
203 MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; 204 MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
204 [[ServerAPI server] requestHistory:token startDate:_startDate endDate:_endDate CompletionHandler:^(NSArray *array, NSError *error) { 205 [[ServerAPI server] requestHistory:token startDate:_startDate endDate:_endDate CompletionHandler:^(NSArray *array, NSError *error) {
205 HistoryViewController __weak *weakSelf = self; 206 HistoryViewController __weak *weakSelf = self;
206 dispatch_async(dispatch_get_main_queue(), ^{ 207 dispatch_async(dispatch_get_main_queue(), ^{
207 if(hudView != nil) { 208 if(hudView != nil) {
208 [hudView hideAnimated:true]; 209 [hudView hideAnimated:true];
209 } 210 }
210 }); 211 });
211 if(error == nil) { 212 if(error == nil) {
212 _curHisArray = array; 213 _curHisArray = array;
213 dispatch_async(dispatch_get_main_queue(), ^{ 214 dispatch_async(dispatch_get_main_queue(), ^{
214 [weakSelf updateView]; 215 [weakSelf updateView];
215 }); 216 });
216 } 217 }
217 else { 218 else {
218 dispatch_async(dispatch_get_main_queue(), ^{ 219 dispatch_async(dispatch_get_main_queue(), ^{
219 NSString *message = [error.userInfo objectForKey:@"message"]; 220 NSString *message = [error.userInfo objectForKey:@"message"];
220 [Utilities showErrorMessage:message withViewController:weakSelf]; 221 [Utilities showErrorMessage:message withViewController:weakSelf];
221 }); 222 });
222 } 223 }
223 }]; 224 }];
224 } 225 }
225 else { 226 else {
226 [self resetData]; 227 [self resetData];
227 } 228 }
228 } 229 }
229 230
230 -(void) callRequestToUpdateData { 231 -(void) callRequestToUpdateData {
231 [super callRequestToUpdateData]; 232 [super callRequestToUpdateData];
232 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 233 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
233 234
234 MBProgressHUD *hudView = nil; 235 MBProgressHUD *hudView = nil;
235 if(_curPage == 1 && !self.refreshControl.isRefreshing) { 236 if(_curPage == 1 && !self.refreshControl.isRefreshing) {
236 hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; 237 hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
237 } 238 }
238 [[ServerAPI server] requestHistoryList:token startDate:_startDate endDate:_endDate CompletionHandler:^(NSArray *array, NSError *error) { 239 [[ServerAPI server] requestHistoryList:token startDate:_startDate endDate:_endDate CompletionHandler:^(NSArray *array, NSError *error) {
239 dispatch_async(dispatch_get_main_queue(), ^{ 240 dispatch_async(dispatch_get_main_queue(), ^{
240 if(hudView != nil) { 241 if(hudView != nil) {
241 [hudView hideAnimated:true]; 242 [hudView hideAnimated:true];
242 } 243 }
243 }); 244 });
244 HistoryViewController __weak *weakSelf = self; 245 HistoryViewController __weak *weakSelf = self;
245 if(error == nil) { 246 if(error == nil) {
246 _curListArray = array; 247 _curListArray = array;
247 NSArray * list = [array objectAtIndex:weakSelf.viewCollectionMode.getCurrentIndex]; 248 NSArray * list = [array objectAtIndex:weakSelf.viewCollectionMode.getCurrentIndex];
248 [weakSelf updateTableData:list error:error]; 249 [weakSelf updateTableData:list error:error];
249 } 250 }
250 else { 251 else {
251 [weakSelf updateTableData:array error:error]; 252 [weakSelf updateTableData:array error:error];
252 } 253 }
253 }]; 254 }];
254 } 255 }
255 256
256 - (void) changeDate { 257 - (void) changeDate {
257 switch (self.viewCollectionType.getCurrentIndex) { 258 switch (self.viewCollectionType.getCurrentIndex) {
258 case 1: 259 case 1:
259 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 7]; 260 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 7];
260 break; 261 break;
261 case 2: 262 case 2:
262 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 30]; 263 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 30];
263 break; 264 break;
264 case 3: 265 case 3:
265 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 30 * 3]; 266 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 30 * 3];
266 break; 267 break;
267 case 4: 268 case 4:
268 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 30 * 6]; 269 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 30 * 6];
269 break; 270 break;
270 default: 271 default:
271 _startDate = _endDate; 272 _startDate = _endDate;
272 break; 273 break;
273 } 274 }
274 if(_startDate == _endDate) { 275 if(_startDate == _endDate) {
275 self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"]; 276 self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"];
276 } 277 }
277 else { 278 else {
278 NSString * startDateString = [Utilities stringFromDate:_startDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"]; 279 NSString * startDateString = [Utilities stringFromDate:_startDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"];
279 NSString * endDateString = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"]; 280 NSString * endDateString = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"];
280 self.lblDatetime.text = [NSString stringWithFormat:@"%@-%@", startDateString, endDateString]; 281 self.lblDatetime.text = [NSString stringWithFormat:@"%@-%@", startDateString, endDateString];
281 } 282 }
282 [self checkRequestData]; 283 [self checkRequestData];
283 } 284 }
284 285
285 #pragma mark IBAction 286 #pragma mark IBAction
286 -(void) swipeAction:(UISwipeGestureRecognizer *)sender { 287 -(void) swipeAction:(UISwipeGestureRecognizer *)sender {
287 bool alphaValue = self.scrollView.alpha == 1.0 ? 1.0 : 0.0; 288 bool alphaValue = self.scrollView.alpha == 1.0 ? 1.0 : 0.0;
288 [UIView animateWithDuration:0.5 animations:^{ 289 [UIView animateWithDuration:0.5 animations:^{
289 self.tableBase.alpha = alphaValue; 290 self.tableBase.alpha = alphaValue;
290 self.scrollView.alpha = 1.0 - alphaValue; 291 self.scrollView.alpha = 1.0 - alphaValue;
291 } completion:^(BOOL completed) { 292 } completion:^(BOOL completed) {
292 [self checkRequestData]; 293 [self checkRequestData];
293 }]; 294 }];
294 } 295 }
295 296
296 - (IBAction)clickBackward:(UIButton *)sender { 297 - (IBAction)clickBackward:(UIButton *)sender {
297 _endDate = [_endDate dateByAddingTimeInterval:-86400]; 298 _endDate = [_endDate dateByAddingTimeInterval:-86400];
298 [self changeDate]; 299 [self changeDate];
299 } 300 }
300 301
301 - (IBAction)clickForward:(UIButton *)sender { 302 - (IBAction)clickForward:(UIButton *)sender {
302 _endDate = [_endDate dateByAddingTimeInterval:86400]; 303 _endDate = [_endDate dateByAddingTimeInterval:86400];
303 [self changeDate]; 304 [self changeDate];
304 } 305 }
305 306
306 -(void)gestureAction:(UITapGestureRecognizer *) sender 307 -(void)gestureAction:(UITapGestureRecognizer *) sender
307 { 308 {
308 CGPoint touchLocation = [sender locationOfTouch:0 inView:self.viewCollectionShare]; 309 CGPoint touchLocation = [sender locationOfTouch:0 inView:self.viewCollectionShare];
309 NSIndexPath *indexPath = [self.viewCollectionShare.collectionView indexPathForItemAtPoint:touchLocation]; 310 NSIndexPath *indexPath = [self.viewCollectionShare.collectionView indexPathForItemAtPoint:touchLocation];
310 NSString * content = @"Finish 500 steps"; 311 NSString * content = @"Finish 500 steps";
311 HistoryViewController __weak *weakSelf = self; 312 HistoryViewController __weak *weakSelf = self;
312 if(indexPath != NULL) { 313 if(indexPath != NULL) {
313 switch (indexPath.row) { 314 switch (indexPath.row) {
314 case 0: //share facebook 315 case 0: //share facebook
315 [Utilities shareFacebook:content withViewController:weakSelf]; 316 [Utilities shareFacebook:content withViewController:weakSelf];
316 break; 317 break;
317 case 1: //share twitter 318 case 1: //share twitter
318 [Utilities shareTwitter:content withViewController:weakSelf]; 319 [Utilities shareTwitter:content withViewController:weakSelf];
319 break; 320 break;
320 case 2 : //share line 321 case 2 : //share line
321 [Utilities shareLine:content withViewController:weakSelf]; 322 [Utilities shareLine:content withViewController:weakSelf];
322 break; 323 break;
323 case 3: // share email 324 case 3: // share email
324 [Utilities shareEmail:content withViewController:weakSelf]; 325 [Utilities shareEmail:content withViewController:weakSelf];
325 break; 326 break;
326 default: //share other 327 default: //share other
327 [Utilities shareOther:content withViewController:weakSelf]; 328 [Utilities shareOther:content withViewController:weakSelf];
328 break; 329 break;
329 } 330 }
330 } 331 }
331 } 332 }
332 333
333 #pragma mark UITableView Delegate 334 #pragma mark UITableView Delegate
334 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 335 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
335 HistoryListTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HistoryListCell"]; 336 HistoryListTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HistoryListCell"];
336 HistoryObject * obj = [_curDataList objectAtIndex:indexPath.row]; 337 HistoryObject * obj = [_curDataList objectAtIndex:indexPath.row];
337 cell.lblTitle.text = [Utilities stringFromDate:obj.date withFormat:@"dd日 (EEEE)" locale:@"ja_JP"]; 338 cell.lblTitle.text = [Utilities stringFromDate:obj.date withFormat:@"dd日 (EEEE)" locale:@"ja_JP"];
338 cell.lblStep.text = [NSString stringWithFormat:@"%d", obj.step]; 339 cell.lblStep.text = [NSString stringWithFormat:@"%d", obj.step];
339 cell.lblDiff.text = [NSString stringWithFormat:@"%d", obj.step_diff]; 340 cell.lblDiff.text = [NSString stringWithFormat:@"%d", obj.step_diff];
340 cell.imgArrow.image = (obj.step_diff > 0) ? [UIImage imageNamed:@"arrow_incre"] : [UIImage imageNamed:@"arrow_decre"]; 341 cell.imgArrow.image = (obj.step_diff > 0) ? [UIImage imageNamed:@"arrow_incre"] : [UIImage imageNamed:@"arrow_decre"];
341 cell.lblPower.text = [NSString stringWithFormat:@"%0.2f", obj.calories]; 342 cell.lblPower.text = [NSString stringWithFormat:@"%0.2f", obj.calories];
342 cell.lblDistance.text = [NSString stringWithFormat:@"%0.1f", obj.distance]; 343 cell.lblDistance.text = [NSString stringWithFormat:@"%0.1f", obj.distance];
343 cell.lblDuration.text = [Utilities convertSecondToShortTime:obj.time]; 344 cell.lblDuration.text = [Utilities convertSecondToShortTime:obj.time];
344 return cell; 345 return cell;
345 } 346 }
346 347
347 @end 348 @end
348 349
LifeLog/LifeLog/HistoryViewController.xib
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> 2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3 <device id="retina4_7" orientation="portrait"> 3 <device id="retina4_7" orientation="portrait">
4 <adaptation id="fullscreen"/> 4 <adaptation id="fullscreen"/>
5 </device> 5 </device>
6 <dependencies> 6 <dependencies>
7 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> 7 <deployment identifier="iOS"/>
8 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
8 <capability name="Aspect ratio constraints" minToolsVersion="5.1"/> 9 <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
9 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> 10 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10 </dependencies> 11 </dependencies>
11 <objects> 12 <objects>
12 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HistoryViewController"> 13 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HistoryViewController">
13 <connections> 14 <connections>
14 <outlet property="lblCalories" destination="dAE-C8-QLr" id="WaS-S3-Qxh"/> 15 <outlet property="lblCalories" destination="dAE-C8-QLr" id="WaS-S3-Qxh"/>
15 <outlet property="lblCircleRemain" destination="Kr7-S0-Fpl" id="UQe-Bt-i0X"/> 16 <outlet property="lblCircleRemain" destination="Kr7-S0-Fpl" id="UQe-Bt-i0X"/>
16 <outlet property="lblCircleStep" destination="oWg-A8-aCr" id="Q9g-UY-hyv"/> 17 <outlet property="lblCircleStep" destination="oWg-A8-aCr" id="Q9g-UY-hyv"/>
17 <outlet property="lblDatetime" destination="EM7-vA-s1e" id="0fK-4u-TaK"/> 18 <outlet property="lblDatetime" destination="EM7-vA-s1e" id="0fK-4u-TaK"/>
18 <outlet property="lblDistance" destination="1tR-JC-pyw" id="q4s-Ru-vLO"/> 19 <outlet property="lblDistance" destination="1tR-JC-pyw" id="q4s-Ru-vLO"/>
19 <outlet property="lblPercent" destination="8Ru-Jc-Ouv" id="ZHn-Kt-0Qk"/> 20 <outlet property="lblPercent" destination="8Ru-Jc-Ouv" id="ZHn-Kt-0Qk"/>
20 <outlet property="lblRemaining" destination="1NH-b3-ST8" id="hFc-q9-b0h"/> 21 <outlet property="lblRemaining" destination="1NH-b3-ST8" id="hFc-q9-b0h"/>
21 <outlet property="lblStep" destination="0pf-fX-QXT" id="jK4-9Y-89Q"/> 22 <outlet property="lblStep" destination="0pf-fX-QXT" id="jK4-9Y-89Q"/>
22 <outlet property="lblTime" destination="PfZ-7x-LAR" id="NQv-fs-rl7"/> 23 <outlet property="lblTime" destination="PfZ-7x-LAR" id="NQv-fs-rl7"/>
23 <outlet property="scrollView" destination="rey-N3-l8b" id="s3w-fi-n5l"/> 24 <outlet property="scrollView" destination="rey-N3-l8b" id="s3w-fi-n5l"/>
24 <outlet property="tableBase" destination="FXQ-4O-sRc" id="UHy-Nk-f7u"/> 25 <outlet property="tableBase" destination="FXQ-4O-sRc" id="UHy-Nk-f7u"/>
25 <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> 26 <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
26 <outlet property="viewBarChart" destination="VqD-Y3-cYQ" id="RdJ-G5-pPy"/> 27 <outlet property="viewBarChart" destination="VqD-Y3-cYQ" id="RdJ-G5-pPy"/>
27 <outlet property="viewCollectionMode" destination="BVv-qD-EHM" id="A6n-32-oxg"/> 28 <outlet property="viewCollectionMode" destination="BVv-qD-EHM" id="A6n-32-oxg"/>
28 <outlet property="viewCollectionShare" destination="Iw2-nW-e7g" id="LW3-j0-yEY"/> 29 <outlet property="viewCollectionShare" destination="Iw2-nW-e7g" id="LW3-j0-yEY"/>
29 <outlet property="viewCollectionType" destination="yxY-4d-tB6" id="K1D-Gc-kWV"/> 30 <outlet property="viewCollectionType" destination="yxY-4d-tB6" id="K1D-Gc-kWV"/>
30 </connections> 31 </connections>
31 </placeholder> 32 </placeholder>
32 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> 33 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
33 <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> 34 <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
34 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> 35 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
35 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 36 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
36 <subviews> 37 <subviews>
37 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="clL-JG-rbd" userLabel="ViewHeader"> 38 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="clL-JG-rbd" userLabel="ViewHeader">
38 <rect key="frame" x="0.0" y="0.0" width="375" height="46"/> 39 <rect key="frame" x="0.0" y="0.0" width="375" height="46"/>
39 <subviews> 40 <subviews>
40 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="履歴" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ht6-rd-JXF" customClass="AutoTransLabel"> 41 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="履歴" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ht6-rd-JXF" customClass="AutoTransLabel">
41 <rect key="frame" x="0.0" y="0.0" width="375" height="46"/> 42 <rect key="frame" x="0.0" y="0.0" width="375" height="46"/>
42 <fontDescription key="fontDescription" type="system" pointSize="17"/> 43 <fontDescription key="fontDescription" type="system" pointSize="17"/>
43 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 44 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
44 <nil key="highlightedColor"/> 45 <nil key="highlightedColor"/>
45 <userDefinedRuntimeAttributes> 46 <userDefinedRuntimeAttributes>
46 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title"/> 47 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title"/>
47 </userDefinedRuntimeAttributes> 48 </userDefinedRuntimeAttributes>
48 </label> 49 </label>
49 <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ytc-zM-ZGC"> 50 <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ytc-zM-ZGC">
50 <rect key="frame" x="0.0" y="5" width="70" height="36"/> 51 <rect key="frame" x="0.0" y="5" width="70" height="36"/>
51 <constraints> 52 <constraints>
52 <constraint firstAttribute="width" constant="70" id="xAE-oP-WEf"/> 53 <constraint firstAttribute="width" constant="70" id="xAE-oP-WEf"/>
53 </constraints> 54 </constraints>
54 <state key="normal" image="today_back_button"/> 55 <state key="normal" image="today_back_button"/>
55 </button> 56 </button>
56 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CFx-sO-MAH"> 57 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CFx-sO-MAH">
57 <rect key="frame" x="330" y="0.0" width="45" height="46"/> 58 <rect key="frame" x="330" y="0.0" width="45" height="46"/>
58 <constraints> 59 <constraints>
59 <constraint firstAttribute="width" constant="45" id="V0g-Ii-pNQ"/> 60 <constraint firstAttribute="width" constant="45" id="V0g-Ii-pNQ"/>
60 </constraints> 61 </constraints>
61 <state key="normal" image="icon_menu"/> 62 <state key="normal" image="icon_menu"/>
62 </button> 63 </button>
63 </subviews> 64 </subviews>
64 <color key="backgroundColor" red="0.098039215686274508" green="0.098039215686274508" blue="0.098039215686274508" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 65 <color key="backgroundColor" red="0.098039215686274508" green="0.098039215686274508" blue="0.098039215686274508" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
65 <constraints> 66 <constraints>
66 <constraint firstAttribute="trailing" secondItem="Ht6-rd-JXF" secondAttribute="trailing" id="Fr9-Yj-q5e"/> 67 <constraint firstAttribute="trailing" secondItem="Ht6-rd-JXF" secondAttribute="trailing" id="Fr9-Yj-q5e"/>
67 <constraint firstItem="ytc-zM-ZGC" firstAttribute="leading" secondItem="clL-JG-rbd" secondAttribute="leading" id="LDb-Pq-Z5k"/> 68 <constraint firstItem="ytc-zM-ZGC" firstAttribute="leading" secondItem="clL-JG-rbd" secondAttribute="leading" id="LDb-Pq-Z5k"/>
68 <constraint firstAttribute="trailing" secondItem="CFx-sO-MAH" secondAttribute="trailing" id="PTh-vI-2DI"/> 69 <constraint firstAttribute="trailing" secondItem="CFx-sO-MAH" secondAttribute="trailing" id="PTh-vI-2DI"/>
69 <constraint firstItem="Ht6-rd-JXF" firstAttribute="top" secondItem="clL-JG-rbd" secondAttribute="top" id="URG-nj-C2r"/> 70 <constraint firstItem="Ht6-rd-JXF" firstAttribute="top" secondItem="clL-JG-rbd" secondAttribute="top" id="URG-nj-C2r"/>
70 <constraint firstItem="CFx-sO-MAH" firstAttribute="top" secondItem="clL-JG-rbd" secondAttribute="top" id="Uxg-Wl-DlF"/> 71 <constraint firstItem="CFx-sO-MAH" firstAttribute="top" secondItem="clL-JG-rbd" secondAttribute="top" id="Uxg-Wl-DlF"/>
71 <constraint firstAttribute="bottom" secondItem="CFx-sO-MAH" secondAttribute="bottom" id="X9D-m3-QXF"/> 72 <constraint firstAttribute="bottom" secondItem="CFx-sO-MAH" secondAttribute="bottom" id="X9D-m3-QXF"/>
72 <constraint firstAttribute="bottom" secondItem="ytc-zM-ZGC" secondAttribute="bottom" constant="5" id="hWb-ga-1wm"/> 73 <constraint firstAttribute="bottom" secondItem="ytc-zM-ZGC" secondAttribute="bottom" constant="5" id="hWb-ga-1wm"/>
73 <constraint firstAttribute="bottom" secondItem="Ht6-rd-JXF" secondAttribute="bottom" id="iqI-Bi-QI1"/> 74 <constraint firstAttribute="bottom" secondItem="Ht6-rd-JXF" secondAttribute="bottom" id="iqI-Bi-QI1"/>
74 <constraint firstItem="Ht6-rd-JXF" firstAttribute="leading" secondItem="clL-JG-rbd" secondAttribute="leading" id="uzc-SO-7mw"/> 75 <constraint firstItem="Ht6-rd-JXF" firstAttribute="leading" secondItem="clL-JG-rbd" secondAttribute="leading" id="uzc-SO-7mw"/>
75 <constraint firstItem="ytc-zM-ZGC" firstAttribute="top" secondItem="clL-JG-rbd" secondAttribute="top" constant="5" id="vFt-FE-klC"/> 76 <constraint firstItem="ytc-zM-ZGC" firstAttribute="top" secondItem="clL-JG-rbd" secondAttribute="top" constant="5" id="vFt-FE-klC"/>
76 <constraint firstAttribute="height" constant="46" id="xGd-BD-bgs"/> 77 <constraint firstAttribute="height" constant="46" id="xGd-BD-bgs"/>
77 </constraints> 78 </constraints>
78 </view> 79 </view>
79 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cf1-lP-zbB" userLabel="ViewTime"> 80 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cf1-lP-zbB" userLabel="ViewTime">
80 <rect key="frame" x="10" y="46" width="355" height="35"/> 81 <rect key="frame" x="10" y="46" width="355" height="35"/>
81 <subviews> 82 <subviews>
82 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6T2-M9-9wV"> 83 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6T2-M9-9wV">
83 <rect key="frame" x="0.0" y="0.0" width="35" height="35"/> 84 <rect key="frame" x="0.0" y="0.0" width="35" height="35"/>
84 <constraints> 85 <constraints>
85 <constraint firstAttribute="width" secondItem="6T2-M9-9wV" secondAttribute="height" multiplier="1:1" id="RlM-6u-eer"/> 86 <constraint firstAttribute="width" secondItem="6T2-M9-9wV" secondAttribute="height" multiplier="1:1" id="RlM-6u-eer"/>
86 </constraints> 87 </constraints>
87 <state key="normal" backgroundImage="arrow_back"/> 88 <state key="normal" backgroundImage="arrow_back"/>
88 <connections> 89 <connections>
89 <action selector="clickBackward:" destination="-1" eventType="touchUpInside" id="pwN-yT-qyp"/> 90 <action selector="clickBackward:" destination="-1" eventType="touchUpInside" id="pwN-yT-qyp"/>
90 </connections> 91 </connections>
91 </button> 92 </button>
92 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Cwb-8M-pDi"> 93 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Cwb-8M-pDi">
93 <rect key="frame" x="320" y="0.0" width="35" height="35"/> 94 <rect key="frame" x="320" y="0.0" width="35" height="35"/>
94 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 95 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
95 <state key="normal" backgroundImage="arrow_next"/> 96 <state key="normal" backgroundImage="arrow_next"/>
96 <connections> 97 <connections>
97 <action selector="clickForward:" destination="-1" eventType="touchUpInside" id="1NC-km-Lfe"/> 98 <action selector="clickForward:" destination="-1" eventType="touchUpInside" id="1NC-km-Lfe"/>
98 </connections> 99 </connections>
99 </button> 100 </button>
100 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2017年1月1日 日曜日" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EM7-vA-s1e"> 101 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2017年1月1日 日曜日" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EM7-vA-s1e">
101 <rect key="frame" x="40" y="2" width="275" height="31"/> 102 <rect key="frame" x="40" y="2" width="275" height="31"/>
102 <fontDescription key="fontDescription" type="system" pointSize="15"/> 103 <fontDescription key="fontDescription" type="system" pointSize="15"/>
103 <nil key="textColor"/> 104 <nil key="textColor"/>
104 <nil key="highlightedColor"/> 105 <nil key="highlightedColor"/>
105 </label> 106 </label>
106 </subviews> 107 </subviews>
107 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 108 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
108 <constraints> 109 <constraints>
109 <constraint firstItem="Cwb-8M-pDi" firstAttribute="top" secondItem="Cf1-lP-zbB" secondAttribute="top" id="4Jr-r7-y6d"/> 110 <constraint firstItem="Cwb-8M-pDi" firstAttribute="top" secondItem="Cf1-lP-zbB" secondAttribute="top" id="4Jr-r7-y6d"/>
110 <constraint firstAttribute="bottom" secondItem="6T2-M9-9wV" secondAttribute="bottom" id="8bU-NI-m32"/> 111 <constraint firstAttribute="bottom" secondItem="6T2-M9-9wV" secondAttribute="bottom" id="8bU-NI-m32"/>
111 <constraint firstItem="EM7-vA-s1e" firstAttribute="leading" secondItem="6T2-M9-9wV" secondAttribute="trailing" constant="5" id="9G1-I6-nSV"/> 112 <constraint firstItem="EM7-vA-s1e" firstAttribute="leading" secondItem="6T2-M9-9wV" secondAttribute="trailing" constant="5" id="9G1-I6-nSV"/>
112 <constraint firstItem="EM7-vA-s1e" firstAttribute="top" secondItem="Cf1-lP-zbB" secondAttribute="top" constant="2" id="9Yk-sv-gkx"/> 113 <constraint firstItem="EM7-vA-s1e" firstAttribute="top" secondItem="Cf1-lP-zbB" secondAttribute="top" constant="2" id="9Yk-sv-gkx"/>
113 <constraint firstItem="Cwb-8M-pDi" firstAttribute="leading" secondItem="EM7-vA-s1e" secondAttribute="trailing" constant="5" id="JQI-18-cWP"/> 114 <constraint firstItem="Cwb-8M-pDi" firstAttribute="leading" secondItem="EM7-vA-s1e" secondAttribute="trailing" constant="5" id="JQI-18-cWP"/>
114 <constraint firstAttribute="height" constant="35" id="Pdg-IR-g8y"/> 115 <constraint firstAttribute="height" constant="35" id="Pdg-IR-g8y"/>
115 <constraint firstItem="6T2-M9-9wV" firstAttribute="leading" secondItem="Cf1-lP-zbB" secondAttribute="leading" id="Pgh-zZ-vrG"/> 116 <constraint firstItem="6T2-M9-9wV" firstAttribute="leading" secondItem="Cf1-lP-zbB" secondAttribute="leading" id="Pgh-zZ-vrG"/>
116 <constraint firstAttribute="bottom" secondItem="Cwb-8M-pDi" secondAttribute="bottom" id="WWs-Ey-osm"/> 117 <constraint firstAttribute="bottom" secondItem="Cwb-8M-pDi" secondAttribute="bottom" id="WWs-Ey-osm"/>
117 <constraint firstItem="Cwb-8M-pDi" firstAttribute="width" secondItem="Cwb-8M-pDi" secondAttribute="height" multiplier="1:1" id="YHa-MU-GKi"/> 118 <constraint firstItem="Cwb-8M-pDi" firstAttribute="width" secondItem="Cwb-8M-pDi" secondAttribute="height" multiplier="1:1" id="YHa-MU-GKi"/>
118 <constraint firstItem="6T2-M9-9wV" firstAttribute="top" secondItem="Cf1-lP-zbB" secondAttribute="top" id="fiM-o3-Us0"/> 119 <constraint firstItem="6T2-M9-9wV" firstAttribute="top" secondItem="Cf1-lP-zbB" secondAttribute="top" id="fiM-o3-Us0"/>
119 <constraint firstAttribute="trailing" secondItem="Cwb-8M-pDi" secondAttribute="trailing" id="oCE-RP-EmX"/> 120 <constraint firstAttribute="trailing" secondItem="Cwb-8M-pDi" secondAttribute="trailing" id="oCE-RP-EmX"/>
120 <constraint firstAttribute="bottom" secondItem="EM7-vA-s1e" secondAttribute="bottom" constant="2" id="oOd-ip-MZy"/> 121 <constraint firstAttribute="bottom" secondItem="EM7-vA-s1e" secondAttribute="bottom" constant="2" id="oOd-ip-MZy"/>
121 </constraints> 122 </constraints>
122 </view> 123 </view>
123 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yxY-4d-tB6" customClass="CollectionView"> 124 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yxY-4d-tB6" customClass="CollectionView">
124 <rect key="frame" x="2" y="96" width="371" height="40"/> 125 <rect key="frame" x="2" y="96" width="371" height="40"/>
125 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 126 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
126 <constraints> 127 <constraints>
127 <constraint firstAttribute="height" constant="40" id="U7Q-wa-CDi"/> 128 <constraint firstAttribute="height" constant="40" id="U7Q-wa-CDi"/>
128 </constraints> 129 </constraints>
129 </view> 130 </view>
130 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BVv-qD-EHM" customClass="CollectionView"> 131 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BVv-qD-EHM" customClass="CollectionView">
131 <rect key="frame" x="0.0" y="577" width="375" height="40"/> 132 <rect key="frame" x="0.0" y="577" width="375" height="40"/>
132 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 133 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
133 <constraints> 134 <constraints>
134 <constraint firstAttribute="height" constant="40" id="6wc-NQ-UAH"/> 135 <constraint firstAttribute="height" constant="40" id="6wc-NQ-UAH"/>
135 </constraints> 136 </constraints>
136 </view> 137 </view>
137 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FLa-rV-Aas" userLabel="ViewContent"> 138 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FLa-rV-Aas" userLabel="ViewContent">
138 <rect key="frame" x="0.0" y="151" width="375" height="421"/> 139 <rect key="frame" x="0.0" y="151" width="375" height="421"/>
139 <subviews> 140 <subviews>
140 <tableView clipsSubviews="YES" alpha="0.0" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="100" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="FXQ-4O-sRc"> 141 <tableView clipsSubviews="YES" alpha="0.0" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="100" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="FXQ-4O-sRc">
141 <rect key="frame" x="5" y="0.0" width="365" height="421"/> 142 <rect key="frame" x="5" y="0.0" width="365" height="421"/>
142 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 143 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
143 <connections> 144 <connections>
144 <outlet property="dataSource" destination="-1" id="GQy-lg-1Af"/> 145 <outlet property="dataSource" destination="-1" id="GQy-lg-1Af"/>
145 <outlet property="delegate" destination="-1" id="Jka-Ij-zNq"/> 146 <outlet property="delegate" destination="-1" id="Jka-Ij-zNq"/>
146 </connections> 147 </connections>
147 </tableView> 148 </tableView>
148 <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rey-N3-l8b"> 149 <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="rey-N3-l8b">
149 <rect key="frame" x="0.0" y="0.0" width="375" height="421"/> 150 <rect key="frame" x="0.0" y="0.0" width="375" height="421"/>
150 <subviews> 151 <subviews>
151 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cam-ML-IEO"> 152 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cam-ML-IEO">
152 <rect key="frame" x="0.0" y="0.0" width="375" height="421"/> 153 <rect key="frame" x="0.0" y="0.0" width="375" height="421"/>
153 <subviews> 154 <subviews>
154 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kzk-mN-AOf"> 155 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Kzk-mN-AOf">
155 <rect key="frame" x="20" y="30" width="120" height="120"/> 156 <rect key="frame" x="20" y="30" width="120" height="120"/>
156 <subviews> 157 <subviews>
157 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 step" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oWg-A8-aCr"> 158 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 step" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oWg-A8-aCr">
158 <rect key="frame" x="18" y="35" width="82" height="21"/> 159 <rect key="frame" x="18" y="35" width="82" height="21"/>
159 <constraints> 160 <constraints>
160 <constraint firstAttribute="height" constant="21" id="zOX-0d-IVv"/> 161 <constraint firstAttribute="height" constant="21" id="zOX-0d-IVv"/>
161 </constraints> 162 </constraints>
162 <fontDescription key="fontDescription" type="system" pointSize="17"/> 163 <fontDescription key="fontDescription" type="system" pointSize="17"/>
163 <nil key="textColor"/> 164 <nil key="textColor"/>
164 <nil key="highlightedColor"/> 165 <nil key="highlightedColor"/>
165 </label> 166 </label>
166 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kr7-S0-Fpl"> 167 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Kr7-S0-Fpl">
167 <rect key="frame" x="20" y="61" width="80" height="42"/> 168 <rect key="frame" x="20" y="61" width="80" height="42"/>
168 <constraints> 169 <constraints>
169 <constraint firstAttribute="width" constant="80" id="IOc-sB-dA2"/> 170 <constraint firstAttribute="width" constant="80" id="IOc-sB-dA2"/>
170 <constraint firstAttribute="height" constant="42" id="zRP-Fu-qZ9"/> 171 <constraint firstAttribute="height" constant="42" id="zRP-Fu-qZ9"/>
171 </constraints> 172 </constraints>
172 <string key="text">目標まであと 173 <string key="text">目標まであと
173 0 stepです</string> 174 0 stepです</string>
174 <fontDescription key="fontDescription" type="system" pointSize="11"/> 175 <fontDescription key="fontDescription" type="system" pointSize="11"/>
175 <nil key="textColor"/> 176 <nil key="textColor"/>
176 <nil key="highlightedColor"/> 177 <nil key="highlightedColor"/>
177 </label> 178 </label>
178 </subviews> 179 </subviews>
179 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 180 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
180 <constraints> 181 <constraints>
181 <constraint firstItem="Kr7-S0-Fpl" firstAttribute="top" secondItem="oWg-A8-aCr" secondAttribute="bottom" constant="5" id="2KK-Lm-h74"/> 182 <constraint firstItem="Kr7-S0-Fpl" firstAttribute="top" secondItem="oWg-A8-aCr" secondAttribute="bottom" constant="5" id="2KK-Lm-h74"/>
182 <constraint firstItem="oWg-A8-aCr" firstAttribute="leading" secondItem="Kzk-mN-AOf" secondAttribute="leading" constant="18" id="CdG-qa-ud5"/> 183 <constraint firstItem="oWg-A8-aCr" firstAttribute="leading" secondItem="Kzk-mN-AOf" secondAttribute="leading" constant="18" id="CdG-qa-ud5"/>
183 <constraint firstAttribute="width" constant="120" id="E48-cC-dsc"/> 184 <constraint firstAttribute="width" constant="120" id="E48-cC-dsc"/>
184 <constraint firstAttribute="height" constant="120" id="SlY-sr-tR9"/> 185 <constraint firstAttribute="height" constant="120" id="SlY-sr-tR9"/>
185 <constraint firstItem="Kr7-S0-Fpl" firstAttribute="centerX" secondItem="Kzk-mN-AOf" secondAttribute="centerX" id="jJV-RH-pk1"/> 186 <constraint firstItem="Kr7-S0-Fpl" firstAttribute="centerX" secondItem="Kzk-mN-AOf" secondAttribute="centerX" id="jJV-RH-pk1"/>
186 <constraint firstItem="oWg-A8-aCr" firstAttribute="top" secondItem="Kzk-mN-AOf" secondAttribute="top" constant="35" id="oBl-zo-td5"/> 187 <constraint firstItem="oWg-A8-aCr" firstAttribute="top" secondItem="Kzk-mN-AOf" secondAttribute="top" constant="35" id="oBl-zo-td5"/>
187 <constraint firstAttribute="trailing" secondItem="oWg-A8-aCr" secondAttribute="trailing" constant="20" id="xgh-d4-jOF"/> 188 <constraint firstAttribute="trailing" secondItem="oWg-A8-aCr" secondAttribute="trailing" constant="20" id="xgh-d4-jOF"/>
188 </constraints> 189 </constraints>
189 <userDefinedRuntimeAttributes> 190 <userDefinedRuntimeAttributes>
190 <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius"> 191 <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
191 <integer key="value" value="60"/> 192 <integer key="value" value="60"/>
192 </userDefinedRuntimeAttribute> 193 </userDefinedRuntimeAttribute>
193 </userDefinedRuntimeAttributes> 194 </userDefinedRuntimeAttributes>
194 </view> 195 </view>
195 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4ix-HE-d9T"> 196 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="4ix-HE-d9T">
196 <rect key="frame" x="148" y="30" width="219" height="120"/> 197 <rect key="frame" x="148" y="30" width="219" height="120"/>
197 <subviews> 198 <subviews>
198 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="目標" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YE6-wh-77T" customClass="AutoTransLabel"> 199 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="目標" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YE6-wh-77T" customClass="AutoTransLabel">
199 <rect key="frame" x="10" y="38" width="45" height="15"/> 200 <rect key="frame" x="10" y="38" width="45" height="15"/>
200 <constraints> 201 <constraints>
201 <constraint firstAttribute="width" constant="45" id="6Ce-YE-wbx"/> 202 <constraint firstAttribute="width" constant="45" id="6Ce-YE-wbx"/>
202 <constraint firstAttribute="height" constant="15" id="eFR-Ao-75U"/> 203 <constraint firstAttribute="height" constant="15" id="eFR-Ao-75U"/>
203 </constraints> 204 </constraints>
204 <fontDescription key="fontDescription" type="system" pointSize="12"/> 205 <fontDescription key="fontDescription" type="system" pointSize="12"/>
205 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 206 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
206 <nil key="highlightedColor"/> 207 <nil key="highlightedColor"/>
207 <userDefinedRuntimeAttributes> 208 <userDefinedRuntimeAttributes>
208 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.total"/> 209 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.total"/>
209 </userDefinedRuntimeAttributes> 210 </userDefinedRuntimeAttributes>
210 </label> 211 </label>
211 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="残歩数" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HOl-Tj-xiT" customClass="AutoTransLabel"> 212 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="残歩数" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="HOl-Tj-xiT" customClass="AutoTransLabel">
212 <rect key="frame" x="10" y="53" width="45" height="15"/> 213 <rect key="frame" x="10" y="53" width="45" height="15"/>
213 <fontDescription key="fontDescription" type="system" pointSize="12"/> 214 <fontDescription key="fontDescription" type="system" pointSize="12"/>
214 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 215 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
215 <nil key="highlightedColor"/> 216 <nil key="highlightedColor"/>
216 <userDefinedRuntimeAttributes> 217 <userDefinedRuntimeAttributes>
217 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.remaining"/> 218 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.remaining"/>
218 </userDefinedRuntimeAttributes> 219 </userDefinedRuntimeAttributes>
219 </label> 220 </label>
220 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="達成率" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l0h-qA-2Ai" customClass="AutoTransLabel"> 221 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="達成率" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="l0h-qA-2Ai" customClass="AutoTransLabel">
221 <rect key="frame" x="10" y="68" width="45" height="15"/> 222 <rect key="frame" x="10" y="68" width="45" height="15"/>
222 <fontDescription key="fontDescription" type="system" pointSize="12"/> 223 <fontDescription key="fontDescription" type="system" pointSize="12"/>
223 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 224 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
224 <nil key="highlightedColor"/> 225 <nil key="highlightedColor"/>
225 <userDefinedRuntimeAttributes> 226 <userDefinedRuntimeAttributes>
226 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.percent"/> 227 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.percent"/>
227 </userDefinedRuntimeAttributes> 228 </userDefinedRuntimeAttributes>
228 </label> 229 </label>
229 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0pf-fX-QXT"> 230 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0pf-fX-QXT">
230 <rect key="frame" x="63" y="38" width="118" height="15"/> 231 <rect key="frame" x="63" y="38" width="118" height="15"/>
231 <constraints> 232 <constraints>
232 <constraint firstAttribute="height" constant="15" id="Z6o-LI-Eu9"/> 233 <constraint firstAttribute="height" constant="15" id="Z6o-LI-Eu9"/>
233 </constraints> 234 </constraints>
234 <fontDescription key="fontDescription" type="system" pointSize="12"/> 235 <fontDescription key="fontDescription" type="system" pointSize="12"/>
235 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 236 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
236 <nil key="highlightedColor"/> 237 <nil key="highlightedColor"/>
237 </label> 238 </label>
238 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1NH-b3-ST8"> 239 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1NH-b3-ST8">
239 <rect key="frame" x="63" y="53" width="118" height="15"/> 240 <rect key="frame" x="63" y="53" width="118" height="15"/>
240 <fontDescription key="fontDescription" type="system" pointSize="12"/> 241 <fontDescription key="fontDescription" type="system" pointSize="12"/>
241 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 242 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
242 <nil key="highlightedColor"/> 243 <nil key="highlightedColor"/>
243 </label> 244 </label>
244 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 %" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8Ru-Jc-Ouv"> 245 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 %" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8Ru-Jc-Ouv">
245 <rect key="frame" x="63" y="68" width="118" height="15"/> 246 <rect key="frame" x="63" y="68" width="118" height="15"/>
246 <fontDescription key="fontDescription" type="system" pointSize="12"/> 247 <fontDescription key="fontDescription" type="system" pointSize="12"/>
247 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 248 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
248 <nil key="highlightedColor"/> 249 <nil key="highlightedColor"/>
249 </label> 250 </label>
250 </subviews> 251 </subviews>
251 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 252 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
252 <constraints> 253 <constraints>
253 <constraint firstItem="l0h-qA-2Ai" firstAttribute="top" secondItem="HOl-Tj-xiT" secondAttribute="bottom" id="0dv-3h-eHs"/> 254 <constraint firstItem="l0h-qA-2Ai" firstAttribute="top" secondItem="HOl-Tj-xiT" secondAttribute="bottom" id="0dv-3h-eHs"/>
254 <constraint firstItem="l0h-qA-2Ai" firstAttribute="leading" secondItem="YE6-wh-77T" secondAttribute="leading" id="7z3-ph-BM4"/> 255 <constraint firstItem="l0h-qA-2Ai" firstAttribute="leading" secondItem="YE6-wh-77T" secondAttribute="leading" id="7z3-ph-BM4"/>
255 <constraint firstItem="1NH-b3-ST8" firstAttribute="leading" secondItem="0pf-fX-QXT" secondAttribute="leading" id="ACu-BV-ieg"/> 256 <constraint firstItem="1NH-b3-ST8" firstAttribute="leading" secondItem="0pf-fX-QXT" secondAttribute="leading" id="ACu-BV-ieg"/>
256 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="top" secondItem="1NH-b3-ST8" secondAttribute="bottom" id="Abh-FK-4X7"/> 257 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="top" secondItem="1NH-b3-ST8" secondAttribute="bottom" id="Abh-FK-4X7"/>
257 <constraint firstItem="1NH-b3-ST8" firstAttribute="top" secondItem="0pf-fX-QXT" secondAttribute="bottom" id="B3I-n2-Oks"/> 258 <constraint firstItem="1NH-b3-ST8" firstAttribute="top" secondItem="0pf-fX-QXT" secondAttribute="bottom" id="B3I-n2-Oks"/>
258 <constraint firstItem="1NH-b3-ST8" firstAttribute="height" secondItem="0pf-fX-QXT" secondAttribute="height" id="BAn-7O-jBX"/> 259 <constraint firstItem="1NH-b3-ST8" firstAttribute="height" secondItem="0pf-fX-QXT" secondAttribute="height" id="BAn-7O-jBX"/>
259 <constraint firstItem="0pf-fX-QXT" firstAttribute="leading" secondItem="YE6-wh-77T" secondAttribute="trailing" constant="8" id="G20-xx-HEH"/> 260 <constraint firstItem="0pf-fX-QXT" firstAttribute="leading" secondItem="YE6-wh-77T" secondAttribute="trailing" constant="8" id="G20-xx-HEH"/>
260 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="leading" secondItem="0pf-fX-QXT" secondAttribute="leading" id="NIm-Zw-fnf"/> 261 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="leading" secondItem="0pf-fX-QXT" secondAttribute="leading" id="NIm-Zw-fnf"/>
261 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="height" secondItem="0pf-fX-QXT" secondAttribute="height" id="PdQ-qd-Sqc"/> 262 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="height" secondItem="0pf-fX-QXT" secondAttribute="height" id="PdQ-qd-Sqc"/>
262 <constraint firstItem="HOl-Tj-xiT" firstAttribute="width" secondItem="YE6-wh-77T" secondAttribute="width" id="WpC-o9-bDa"/> 263 <constraint firstItem="HOl-Tj-xiT" firstAttribute="width" secondItem="YE6-wh-77T" secondAttribute="width" id="WpC-o9-bDa"/>
263 <constraint firstItem="l0h-qA-2Ai" firstAttribute="height" secondItem="YE6-wh-77T" secondAttribute="height" id="bR8-Ki-lS1"/> 264 <constraint firstItem="l0h-qA-2Ai" firstAttribute="height" secondItem="YE6-wh-77T" secondAttribute="height" id="bR8-Ki-lS1"/>
264 <constraint firstItem="HOl-Tj-xiT" firstAttribute="height" secondItem="YE6-wh-77T" secondAttribute="height" id="c0u-hz-5O9"/> 265 <constraint firstItem="HOl-Tj-xiT" firstAttribute="height" secondItem="YE6-wh-77T" secondAttribute="height" id="c0u-hz-5O9"/>
265 <constraint firstItem="1NH-b3-ST8" firstAttribute="leading" secondItem="0pf-fX-QXT" secondAttribute="leading" id="chf-kb-ClX"/> 266 <constraint firstItem="1NH-b3-ST8" firstAttribute="leading" secondItem="0pf-fX-QXT" secondAttribute="leading" id="chf-kb-ClX"/>
266 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="leading" secondItem="0pf-fX-QXT" secondAttribute="leading" id="din-4T-V5w"/> 267 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="leading" secondItem="0pf-fX-QXT" secondAttribute="leading" id="din-4T-V5w"/>
267 <constraint firstItem="l0h-qA-2Ai" firstAttribute="width" secondItem="YE6-wh-77T" secondAttribute="width" id="eo0-xw-d1f"/> 268 <constraint firstItem="l0h-qA-2Ai" firstAttribute="width" secondItem="YE6-wh-77T" secondAttribute="width" id="eo0-xw-d1f"/>
268 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="width" secondItem="0pf-fX-QXT" secondAttribute="width" id="gjt-3e-Pkx"/> 269 <constraint firstItem="8Ru-Jc-Ouv" firstAttribute="width" secondItem="0pf-fX-QXT" secondAttribute="width" id="gjt-3e-Pkx"/>
269 <constraint firstItem="1NH-b3-ST8" firstAttribute="width" secondItem="0pf-fX-QXT" secondAttribute="width" id="kOM-6S-Amv"/> 270 <constraint firstItem="1NH-b3-ST8" firstAttribute="width" secondItem="0pf-fX-QXT" secondAttribute="width" id="kOM-6S-Amv"/>
270 <constraint firstItem="HOl-Tj-xiT" firstAttribute="leading" secondItem="YE6-wh-77T" secondAttribute="leading" id="oOc-TB-k4j"/> 271 <constraint firstItem="HOl-Tj-xiT" firstAttribute="leading" secondItem="YE6-wh-77T" secondAttribute="leading" id="oOc-TB-k4j"/>
271 <constraint firstItem="1NH-b3-ST8" firstAttribute="centerY" secondItem="HOl-Tj-xiT" secondAttribute="centerY" id="pGW-dw-56G"/> 272 <constraint firstItem="1NH-b3-ST8" firstAttribute="centerY" secondItem="HOl-Tj-xiT" secondAttribute="centerY" id="pGW-dw-56G"/>
272 <constraint firstItem="HOl-Tj-xiT" firstAttribute="top" secondItem="YE6-wh-77T" secondAttribute="bottom" id="s6n-mU-Sp6"/> 273 <constraint firstItem="HOl-Tj-xiT" firstAttribute="top" secondItem="YE6-wh-77T" secondAttribute="bottom" id="s6n-mU-Sp6"/>
273 <constraint firstItem="HOl-Tj-xiT" firstAttribute="centerY" secondItem="4ix-HE-d9T" secondAttribute="centerY" id="vB9-RR-pao"/> 274 <constraint firstItem="HOl-Tj-xiT" firstAttribute="centerY" secondItem="4ix-HE-d9T" secondAttribute="centerY" id="vB9-RR-pao"/>
274 <constraint firstAttribute="trailing" secondItem="0pf-fX-QXT" secondAttribute="trailing" constant="38" id="xiP-fg-Ozi"/> 275 <constraint firstAttribute="trailing" secondItem="0pf-fX-QXT" secondAttribute="trailing" constant="38" id="xiP-fg-Ozi"/>
275 <constraint firstItem="YE6-wh-77T" firstAttribute="leading" secondItem="4ix-HE-d9T" secondAttribute="leading" constant="10" id="xj6-In-ihz"/> 276 <constraint firstItem="YE6-wh-77T" firstAttribute="leading" secondItem="4ix-HE-d9T" secondAttribute="leading" constant="10" id="xj6-In-ihz"/>
276 </constraints> 277 </constraints>
277 </view> 278 </view>
278 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iEh-Ze-suq"> 279 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="iEh-Ze-suq">
279 <rect key="frame" x="20" y="158" width="335" height="35"/> 280 <rect key="frame" x="20" y="158" width="335" height="35"/>
280 <subviews> 281 <subviews>
281 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UwA-5Q-gdv"> 282 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UwA-5Q-gdv">
282 <rect key="frame" x="0.0" y="0.0" width="111.5" height="35"/> 283 <rect key="frame" x="0.0" y="0.0" width="111.5" height="35"/>
283 <subviews> 284 <subviews>
284 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="消費カロリー" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zRU-L6-Ed4" customClass="AutoTransLabel"> 285 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="消費カロリー" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zRU-L6-Ed4" customClass="AutoTransLabel">
285 <rect key="frame" x="0.0" y="0.0" width="111.5" height="18"/> 286 <rect key="frame" x="0.0" y="0.0" width="111.5" height="18"/>
286 <constraints> 287 <constraints>
287 <constraint firstAttribute="height" constant="18" id="Ywp-RA-6am"/> 288 <constraint firstAttribute="height" constant="18" id="Ywp-RA-6am"/>
288 </constraints> 289 </constraints>
289 <fontDescription key="fontDescription" type="system" pointSize="12"/> 290 <fontDescription key="fontDescription" type="system" pointSize="12"/>
290 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 291 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
291 <nil key="highlightedColor"/> 292 <nil key="highlightedColor"/>
292 <userDefinedRuntimeAttributes> 293 <userDefinedRuntimeAttributes>
293 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.calories"/> 294 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.calories"/>
294 </userDefinedRuntimeAttributes> 295 </userDefinedRuntimeAttributes>
295 </label> 296 </label>
296 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 kcal" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dAE-C8-QLr"> 297 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0 kcal" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="dAE-C8-QLr">
297 <rect key="frame" x="0.0" y="17" width="111.5" height="18"/> 298 <rect key="frame" x="0.0" y="17" width="111.5" height="18"/>
298 <constraints> 299 <constraints>
299 <constraint firstAttribute="height" constant="18" id="r0d-xi-3u7"/> 300 <constraint firstAttribute="height" constant="18" id="r0d-xi-3u7"/>
300 </constraints> 301 </constraints>
301 <fontDescription key="fontDescription" type="system" pointSize="12"/> 302 <fontDescription key="fontDescription" type="system" pointSize="12"/>
302 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 303 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
303 <nil key="highlightedColor"/> 304 <nil key="highlightedColor"/>
304 </label> 305 </label>
305 </subviews> 306 </subviews>
306 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 307 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
307 <constraints> 308 <constraints>
308 <constraint firstItem="zRU-L6-Ed4" firstAttribute="leading" secondItem="UwA-5Q-gdv" secondAttribute="leading" id="Zbe-7f-cuR"/> 309 <constraint firstItem="zRU-L6-Ed4" firstAttribute="leading" secondItem="UwA-5Q-gdv" secondAttribute="leading" id="Zbe-7f-cuR"/>
309 <constraint firstAttribute="bottom" secondItem="dAE-C8-QLr" secondAttribute="bottom" id="aZH-zh-M1V"/> 310 <constraint firstAttribute="bottom" secondItem="dAE-C8-QLr" secondAttribute="bottom" id="aZH-zh-M1V"/>
310 <constraint firstItem="zRU-L6-Ed4" firstAttribute="top" secondItem="UwA-5Q-gdv" secondAttribute="top" id="bsw-KU-Tcu"/> 311 <constraint firstItem="zRU-L6-Ed4" firstAttribute="top" secondItem="UwA-5Q-gdv" secondAttribute="top" id="bsw-KU-Tcu"/>
311 <constraint firstAttribute="trailing" secondItem="zRU-L6-Ed4" secondAttribute="trailing" id="iMB-ch-u4B"/> 312 <constraint firstAttribute="trailing" secondItem="zRU-L6-Ed4" secondAttribute="trailing" id="iMB-ch-u4B"/>
312 <constraint firstItem="dAE-C8-QLr" firstAttribute="leading" secondItem="UwA-5Q-gdv" secondAttribute="leading" id="qNu-WH-Jjj"/> 313 <constraint firstItem="dAE-C8-QLr" firstAttribute="leading" secondItem="UwA-5Q-gdv" secondAttribute="leading" id="qNu-WH-Jjj"/>
313 <constraint firstAttribute="trailing" secondItem="dAE-C8-QLr" secondAttribute="trailing" id="wRF-1x-XC1"/> 314 <constraint firstAttribute="trailing" secondItem="dAE-C8-QLr" secondAttribute="trailing" id="wRF-1x-XC1"/>
314 </constraints> 315 </constraints>
315 </view> 316 </view>
316 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BVs-KG-fDF"> 317 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="BVs-KG-fDF">
317 <rect key="frame" x="111.5" y="0.0" width="112" height="35"/> 318 <rect key="frame" x="111.5" y="0.0" width="112" height="35"/>
318 <subviews> 319 <subviews>
319 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="距離" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XGt-pc-sd7" customClass="AutoTransLabel"> 320 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="距離" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XGt-pc-sd7" customClass="AutoTransLabel">
320 <rect key="frame" x="0.0" y="0.0" width="112" height="18"/> 321 <rect key="frame" x="0.0" y="0.0" width="112" height="18"/>
321 <constraints> 322 <constraints>
322 <constraint firstAttribute="height" constant="18" id="tct-pY-7wo"/> 323 <constraint firstAttribute="height" constant="18" id="tct-pY-7wo"/>
323 </constraints> 324 </constraints>
324 <fontDescription key="fontDescription" type="system" pointSize="12"/> 325 <fontDescription key="fontDescription" type="system" pointSize="12"/>
325 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 326 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
326 <nil key="highlightedColor"/> 327 <nil key="highlightedColor"/>
327 <userDefinedRuntimeAttributes> 328 <userDefinedRuntimeAttributes>
328 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.distance"/> 329 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.distance"/>
329 </userDefinedRuntimeAttributes> 330 </userDefinedRuntimeAttributes>
330 </label> 331 </label>
331 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0.0 KM" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1tR-JC-pyw"> 332 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0.0 KM" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1tR-JC-pyw">
332 <rect key="frame" x="0.0" y="17" width="112" height="18"/> 333 <rect key="frame" x="0.0" y="17" width="112" height="18"/>
333 <constraints> 334 <constraints>
334 <constraint firstAttribute="height" constant="18" id="sNT-xl-BKH"/> 335 <constraint firstAttribute="height" constant="18" id="sNT-xl-BKH"/>
335 </constraints> 336 </constraints>
336 <fontDescription key="fontDescription" type="system" pointSize="12"/> 337 <fontDescription key="fontDescription" type="system" pointSize="12"/>
337 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 338 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
338 <nil key="highlightedColor"/> 339 <nil key="highlightedColor"/>
339 </label> 340 </label>
340 </subviews> 341 </subviews>
341 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 342 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
342 <constraints> 343 <constraints>
343 <constraint firstItem="XGt-pc-sd7" firstAttribute="leading" secondItem="BVs-KG-fDF" secondAttribute="leading" id="Bd8-ZX-shc"/> 344 <constraint firstItem="XGt-pc-sd7" firstAttribute="leading" secondItem="BVs-KG-fDF" secondAttribute="leading" id="Bd8-ZX-shc"/>
344 <constraint firstAttribute="trailing" secondItem="1tR-JC-pyw" secondAttribute="trailing" id="Mrw-gb-r3n"/> 345 <constraint firstAttribute="trailing" secondItem="1tR-JC-pyw" secondAttribute="trailing" id="Mrw-gb-r3n"/>
345 <constraint firstAttribute="trailing" secondItem="XGt-pc-sd7" secondAttribute="trailing" id="cTc-te-Pc1"/> 346 <constraint firstAttribute="trailing" secondItem="XGt-pc-sd7" secondAttribute="trailing" id="cTc-te-Pc1"/>
346 <constraint firstItem="XGt-pc-sd7" firstAttribute="top" secondItem="BVs-KG-fDF" secondAttribute="top" id="cs1-A7-e5C"/> 347 <constraint firstItem="XGt-pc-sd7" firstAttribute="top" secondItem="BVs-KG-fDF" secondAttribute="top" id="cs1-A7-e5C"/>
347 <constraint firstAttribute="bottom" secondItem="1tR-JC-pyw" secondAttribute="bottom" id="vsZ-FE-X5m"/> 348 <constraint firstAttribute="bottom" secondItem="1tR-JC-pyw" secondAttribute="bottom" id="vsZ-FE-X5m"/>
348 <constraint firstItem="1tR-JC-pyw" firstAttribute="leading" secondItem="BVs-KG-fDF" secondAttribute="leading" id="xOd-ZK-rZn"/> 349 <constraint firstItem="1tR-JC-pyw" firstAttribute="leading" secondItem="BVs-KG-fDF" secondAttribute="leading" id="xOd-ZK-rZn"/>
349 </constraints> 350 </constraints>
350 </view> 351 </view>
351 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="j5h-QD-Igf"> 352 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="j5h-QD-Igf">
352 <rect key="frame" x="223.5" y="0.0" width="111.5" height="35"/> 353 <rect key="frame" x="223.5" y="0.0" width="111.5" height="35"/>
353 <subviews> 354 <subviews>
354 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="時間" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OEO-l8-Ibg" customClass="AutoTransLabel"> 355 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="時間" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="OEO-l8-Ibg" customClass="AutoTransLabel">
355 <rect key="frame" x="0.0" y="0.0" width="111.5" height="18"/> 356 <rect key="frame" x="0.0" y="0.0" width="111.5" height="18"/>
356 <constraints> 357 <constraints>
357 <constraint firstAttribute="height" constant="18" id="EVe-qW-qqp"/> 358 <constraint firstAttribute="height" constant="18" id="EVe-qW-qqp"/>
358 </constraints> 359 </constraints>
359 <fontDescription key="fontDescription" type="system" pointSize="12"/> 360 <fontDescription key="fontDescription" type="system" pointSize="12"/>
360 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 361 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
361 <nil key="highlightedColor"/> 362 <nil key="highlightedColor"/>
362 <userDefinedRuntimeAttributes> 363 <userDefinedRuntimeAttributes>
363 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.time"/> 364 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title.time"/>
364 </userDefinedRuntimeAttributes> 365 </userDefinedRuntimeAttributes>
365 </label> 366 </label>
366 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PfZ-7x-LAR"> 367 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="00:00" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PfZ-7x-LAR">
367 <rect key="frame" x="0.0" y="17" width="111.5" height="18"/> 368 <rect key="frame" x="0.0" y="17" width="111.5" height="18"/>
368 <constraints> 369 <constraints>
369 <constraint firstAttribute="height" constant="18" id="lno-Dx-ZNm"/> 370 <constraint firstAttribute="height" constant="18" id="lno-Dx-ZNm"/>
370 </constraints> 371 </constraints>
371 <fontDescription key="fontDescription" type="system" pointSize="12"/> 372 <fontDescription key="fontDescription" type="system" pointSize="12"/>
372 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 373 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
373 <nil key="highlightedColor"/> 374 <nil key="highlightedColor"/>
374 </label> 375 </label>
375 </subviews> 376 </subviews>
376 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 377 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
377 <constraints> 378 <constraints>
378 <constraint firstAttribute="trailing" secondItem="PfZ-7x-LAR" secondAttribute="trailing" id="3Ir-mZ-xmI"/> 379 <constraint firstAttribute="trailing" secondItem="PfZ-7x-LAR" secondAttribute="trailing" id="3Ir-mZ-xmI"/>
379 <constraint firstItem="OEO-l8-Ibg" firstAttribute="leading" secondItem="j5h-QD-Igf" secondAttribute="leading" id="5oW-CQ-vWi"/> 380 <constraint firstItem="OEO-l8-Ibg" firstAttribute="leading" secondItem="j5h-QD-Igf" secondAttribute="leading" id="5oW-CQ-vWi"/>
380 <constraint firstItem="PfZ-7x-LAR" firstAttribute="leading" secondItem="j5h-QD-Igf" secondAttribute="leading" id="Qur-SO-10d"/> 381 <constraint firstItem="PfZ-7x-LAR" firstAttribute="leading" secondItem="j5h-QD-Igf" secondAttribute="leading" id="Qur-SO-10d"/>
381 <constraint firstAttribute="trailing" secondItem="OEO-l8-Ibg" secondAttribute="trailing" id="WQn-Gv-plQ"/> 382 <constraint firstAttribute="trailing" secondItem="OEO-l8-Ibg" secondAttribute="trailing" id="WQn-Gv-plQ"/>
382 <constraint firstItem="OEO-l8-Ibg" firstAttribute="top" secondItem="j5h-QD-Igf" secondAttribute="top" id="lt7-Qt-rBM"/> 383 <constraint firstItem="OEO-l8-Ibg" firstAttribute="top" secondItem="j5h-QD-Igf" secondAttribute="top" id="lt7-Qt-rBM"/>
383 <constraint firstAttribute="bottom" secondItem="PfZ-7x-LAR" secondAttribute="bottom" id="qcA-M9-NYS"/> 384 <constraint firstAttribute="bottom" secondItem="PfZ-7x-LAR" secondAttribute="bottom" id="qcA-M9-NYS"/>
384 </constraints> 385 </constraints>
385 </view> 386 </view>
386 </subviews> 387 </subviews>
387 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 388 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
388 <constraints> 389 <constraints>
389 <constraint firstAttribute="bottom" secondItem="j5h-QD-Igf" secondAttribute="bottom" id="IsO-UX-w9t"/> 390 <constraint firstAttribute="bottom" secondItem="j5h-QD-Igf" secondAttribute="bottom" id="IsO-UX-w9t"/>
390 <constraint firstItem="j5h-QD-Igf" firstAttribute="top" secondItem="iEh-Ze-suq" secondAttribute="top" id="Msr-oS-nFH"/> 391 <constraint firstItem="j5h-QD-Igf" firstAttribute="top" secondItem="iEh-Ze-suq" secondAttribute="top" id="Msr-oS-nFH"/>
391 <constraint firstItem="BVs-KG-fDF" firstAttribute="top" secondItem="iEh-Ze-suq" secondAttribute="top" id="Ohk-mJ-oCK"/> 392 <constraint firstItem="BVs-KG-fDF" firstAttribute="top" secondItem="iEh-Ze-suq" secondAttribute="top" id="Ohk-mJ-oCK"/>
392 <constraint firstItem="UwA-5Q-gdv" firstAttribute="top" secondItem="iEh-Ze-suq" secondAttribute="top" id="Pue-sC-wfB"/> 393 <constraint firstItem="UwA-5Q-gdv" firstAttribute="top" secondItem="iEh-Ze-suq" secondAttribute="top" id="Pue-sC-wfB"/>
393 <constraint firstAttribute="height" constant="35" id="WDe-uC-4Qb"/> 394 <constraint firstAttribute="height" constant="35" id="WDe-uC-4Qb"/>
394 <constraint firstItem="BVs-KG-fDF" firstAttribute="leading" secondItem="UwA-5Q-gdv" secondAttribute="trailing" id="f8Q-F0-hjc"/> 395 <constraint firstItem="BVs-KG-fDF" firstAttribute="leading" secondItem="UwA-5Q-gdv" secondAttribute="trailing" id="f8Q-F0-hjc"/>
395 <constraint firstItem="BVs-KG-fDF" firstAttribute="width" secondItem="UwA-5Q-gdv" secondAttribute="width" id="fdz-YH-1kJ"/> 396 <constraint firstItem="BVs-KG-fDF" firstAttribute="width" secondItem="UwA-5Q-gdv" secondAttribute="width" id="fdz-YH-1kJ"/>
396 <constraint firstAttribute="bottom" secondItem="UwA-5Q-gdv" secondAttribute="bottom" id="gxD-wy-TgL"/> 397 <constraint firstAttribute="bottom" secondItem="UwA-5Q-gdv" secondAttribute="bottom" id="gxD-wy-TgL"/>
397 <constraint firstItem="j5h-QD-Igf" firstAttribute="width" secondItem="UwA-5Q-gdv" secondAttribute="width" id="i3o-n4-fZN"/> 398 <constraint firstItem="j5h-QD-Igf" firstAttribute="width" secondItem="UwA-5Q-gdv" secondAttribute="width" id="i3o-n4-fZN"/>
398 <constraint firstAttribute="trailing" secondItem="j5h-QD-Igf" secondAttribute="trailing" id="nT6-nS-H9z"/> 399 <constraint firstAttribute="trailing" secondItem="j5h-QD-Igf" secondAttribute="trailing" id="nT6-nS-H9z"/>
399 <constraint firstAttribute="bottom" secondItem="BVs-KG-fDF" secondAttribute="bottom" id="nqB-N3-F3F"/> 400 <constraint firstAttribute="bottom" secondItem="BVs-KG-fDF" secondAttribute="bottom" id="nqB-N3-F3F"/>
400 <constraint firstItem="UwA-5Q-gdv" firstAttribute="leading" secondItem="iEh-Ze-suq" secondAttribute="leading" id="oV9-IH-tYC"/> 401 <constraint firstItem="UwA-5Q-gdv" firstAttribute="leading" secondItem="iEh-Ze-suq" secondAttribute="leading" id="oV9-IH-tYC"/>
401 <constraint firstItem="j5h-QD-Igf" firstAttribute="leading" secondItem="BVs-KG-fDF" secondAttribute="trailing" id="zOb-WE-3CI"/> 402 <constraint firstItem="j5h-QD-Igf" firstAttribute="leading" secondItem="BVs-KG-fDF" secondAttribute="trailing" id="zOb-WE-3CI"/>
402 </constraints> 403 </constraints>
403 </view> 404 </view>
404 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VqD-Y3-cYQ" customClass="BarChartView" customModule="Charts"> 405 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VqD-Y3-cYQ" customClass="BarChartView" customModule="Charts">
405 <rect key="frame" x="0.0" y="201" width="375" height="100"/> 406 <rect key="frame" x="0.0" y="201" width="375" height="100"/>
406 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 407 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
407 <constraints> 408 <constraints>
408 <constraint firstAttribute="height" constant="100" id="aQR-hf-MhR"/> 409 <constraint firstAttribute="height" constant="100" id="aQR-hf-MhR"/>
409 </constraints> 410 </constraints>
410 </view> 411 </view>
411 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Iw2-nW-e7g" customClass="CollectionView"> 412 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Iw2-nW-e7g" customClass="CollectionView">
412 <rect key="frame" x="20" y="316" width="335" height="50"/> 413 <rect key="frame" x="20" y="316" width="335" height="50"/>
413 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 414 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
414 <constraints> 415 <constraints>
415 <constraint firstAttribute="height" constant="50" id="Yzh-hD-r0n"/> 416 <constraint firstAttribute="height" constant="50" id="Yzh-hD-r0n"/>
416 </constraints> 417 </constraints>
417 </view> 418 </view>
418 </subviews> 419 </subviews>
419 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 420 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
420 <constraints> 421 <constraints>
421 <constraint firstItem="VqD-Y3-cYQ" firstAttribute="top" secondItem="iEh-Ze-suq" secondAttribute="bottom" constant="8" id="0BA-6p-JLT"/> 422 <constraint firstItem="VqD-Y3-cYQ" firstAttribute="top" secondItem="iEh-Ze-suq" secondAttribute="bottom" constant="8" id="0BA-6p-JLT"/>
422 <constraint firstItem="Iw2-nW-e7g" firstAttribute="leading" secondItem="Cam-ML-IEO" secondAttribute="leading" constant="20" id="2lH-sF-Mp0"/> 423 <constraint firstItem="Iw2-nW-e7g" firstAttribute="leading" secondItem="Cam-ML-IEO" secondAttribute="leading" constant="20" id="2lH-sF-Mp0"/>
423 <constraint firstItem="iEh-Ze-suq" firstAttribute="top" secondItem="4ix-HE-d9T" secondAttribute="bottom" constant="8" id="9Sm-IQ-feL"/> 424 <constraint firstItem="iEh-Ze-suq" firstAttribute="top" secondItem="4ix-HE-d9T" secondAttribute="bottom" constant="8" id="9Sm-IQ-feL"/>
424 <constraint firstItem="VqD-Y3-cYQ" firstAttribute="leading" secondItem="Cam-ML-IEO" secondAttribute="leading" id="Gbd-bD-rFf"/> 425 <constraint firstItem="VqD-Y3-cYQ" firstAttribute="leading" secondItem="Cam-ML-IEO" secondAttribute="leading" id="Gbd-bD-rFf"/>
425 <constraint firstItem="4ix-HE-d9T" firstAttribute="top" secondItem="Cam-ML-IEO" secondAttribute="top" constant="30" id="JyQ-KD-MhR"/> 426 <constraint firstItem="4ix-HE-d9T" firstAttribute="top" secondItem="Cam-ML-IEO" secondAttribute="top" constant="30" id="JyQ-KD-MhR"/>
426 <constraint firstAttribute="trailing" secondItem="iEh-Ze-suq" secondAttribute="trailing" constant="20" id="RcZ-yN-56e"/> 427 <constraint firstAttribute="trailing" secondItem="iEh-Ze-suq" secondAttribute="trailing" constant="20" id="RcZ-yN-56e"/>
427 <constraint firstAttribute="trailing" secondItem="Iw2-nW-e7g" secondAttribute="trailing" constant="20" id="Xso-Or-Fgf"/> 428 <constraint firstAttribute="trailing" secondItem="Iw2-nW-e7g" secondAttribute="trailing" constant="20" id="Xso-Or-Fgf"/>
428 <constraint firstItem="Kzk-mN-AOf" firstAttribute="top" secondItem="Cam-ML-IEO" secondAttribute="top" constant="30" id="YzU-Mb-veC"/> 429 <constraint firstItem="Kzk-mN-AOf" firstAttribute="top" secondItem="Cam-ML-IEO" secondAttribute="top" constant="30" id="YzU-Mb-veC"/>
429 <constraint firstAttribute="trailing" secondItem="4ix-HE-d9T" secondAttribute="trailing" constant="8" id="del-xz-Tos"/> 430 <constraint firstAttribute="trailing" secondItem="4ix-HE-d9T" secondAttribute="trailing" constant="8" id="del-xz-Tos"/>
430 <constraint firstItem="4ix-HE-d9T" firstAttribute="height" secondItem="Kzk-mN-AOf" secondAttribute="height" id="duV-wT-9wp"/> 431 <constraint firstItem="4ix-HE-d9T" firstAttribute="height" secondItem="Kzk-mN-AOf" secondAttribute="height" id="duV-wT-9wp"/>
431 <constraint firstItem="Iw2-nW-e7g" firstAttribute="top" secondItem="VqD-Y3-cYQ" secondAttribute="bottom" constant="15" id="ekR-kS-L5v"/> 432 <constraint firstItem="Iw2-nW-e7g" firstAttribute="top" secondItem="VqD-Y3-cYQ" secondAttribute="bottom" constant="15" id="ekR-kS-L5v"/>
432 <constraint firstItem="Kzk-mN-AOf" firstAttribute="leading" secondItem="Cam-ML-IEO" secondAttribute="leading" constant="20" id="hFq-WM-gLq"/> 433 <constraint firstItem="Kzk-mN-AOf" firstAttribute="leading" secondItem="Cam-ML-IEO" secondAttribute="leading" constant="20" id="hFq-WM-gLq"/>
433 <constraint firstItem="4ix-HE-d9T" firstAttribute="leading" secondItem="Kzk-mN-AOf" secondAttribute="trailing" constant="8" id="hzO-hA-cNG"/> 434 <constraint firstItem="4ix-HE-d9T" firstAttribute="leading" secondItem="Kzk-mN-AOf" secondAttribute="trailing" constant="8" id="hzO-hA-cNG"/>
434 <constraint firstAttribute="trailing" secondItem="VqD-Y3-cYQ" secondAttribute="trailing" id="ptF-2O-CNR"/> 435 <constraint firstAttribute="trailing" secondItem="VqD-Y3-cYQ" secondAttribute="trailing" id="ptF-2O-CNR"/>
435 <constraint firstItem="iEh-Ze-suq" firstAttribute="leading" secondItem="Cam-ML-IEO" secondAttribute="leading" constant="20" id="u5o-P4-qkL"/> 436 <constraint firstItem="iEh-Ze-suq" firstAttribute="leading" secondItem="Cam-ML-IEO" secondAttribute="leading" constant="20" id="u5o-P4-qkL"/>
436 </constraints> 437 </constraints>
437 </view> 438 </view>
438 </subviews> 439 </subviews>
439 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 440 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
440 <constraints> 441 <constraints>
441 <constraint firstItem="Cam-ML-IEO" firstAttribute="centerY" secondItem="rey-N3-l8b" secondAttribute="centerY" id="0WD-1q-SWm"/> 442 <constraint firstItem="Cam-ML-IEO" firstAttribute="centerY" secondItem="rey-N3-l8b" secondAttribute="centerY" id="0WD-1q-SWm"/>
442 <constraint firstItem="Cam-ML-IEO" firstAttribute="width" secondItem="rey-N3-l8b" secondAttribute="width" id="LbF-3h-cxa"/> 443 <constraint firstItem="Cam-ML-IEO" firstAttribute="width" secondItem="rey-N3-l8b" secondAttribute="width" id="LbF-3h-cxa"/>
443 <constraint firstAttribute="trailing" secondItem="Cam-ML-IEO" secondAttribute="trailing" id="UHb-6d-wF8"/> 444 <constraint firstAttribute="trailing" secondItem="Cam-ML-IEO" secondAttribute="trailing" id="UHb-6d-wF8"/>
444 <constraint firstItem="Cam-ML-IEO" firstAttribute="leading" secondItem="rey-N3-l8b" secondAttribute="leading" id="Y4U-kD-V28"/> 445 <constraint firstItem="Cam-ML-IEO" firstAttribute="leading" secondItem="rey-N3-l8b" secondAttribute="leading" id="Y4U-kD-V28"/>
445 <constraint firstItem="Cam-ML-IEO" firstAttribute="top" secondItem="rey-N3-l8b" secondAttribute="top" id="ohS-iH-IIM"/> 446 <constraint firstItem="Cam-ML-IEO" firstAttribute="top" secondItem="rey-N3-l8b" secondAttribute="top" id="ohS-iH-IIM"/>
446 <constraint firstAttribute="bottom" secondItem="Cam-ML-IEO" secondAttribute="bottom" id="th8-dH-zv1"/> 447 <constraint firstAttribute="bottom" secondItem="Cam-ML-IEO" secondAttribute="bottom" id="th8-dH-zv1"/>
447 </constraints> 448 </constraints>
448 <connections> 449 <connections>
449 <outlet property="delegate" destination="-1" id="3Fl-Qy-gjm"/> 450 <outlet property="delegate" destination="-1" id="3Fl-Qy-gjm"/>
450 </connections> 451 </connections>
451 </scrollView> 452 </scrollView>
452 </subviews> 453 </subviews>
453 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 454 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
454 <constraints> 455 <constraints>
455 <constraint firstAttribute="trailing" secondItem="FXQ-4O-sRc" secondAttribute="trailing" constant="5" id="5y0-NC-rHp"/> 456 <constraint firstAttribute="trailing" secondItem="FXQ-4O-sRc" secondAttribute="trailing" constant="5" id="5y0-NC-rHp"/>
456 <constraint firstItem="FXQ-4O-sRc" firstAttribute="leading" secondItem="FLa-rV-Aas" secondAttribute="leading" constant="5" id="C0U-21-SKl"/> 457 <constraint firstItem="FXQ-4O-sRc" firstAttribute="leading" secondItem="FLa-rV-Aas" secondAttribute="leading" constant="5" id="C0U-21-SKl"/>
457 <constraint firstItem="FXQ-4O-sRc" firstAttribute="top" secondItem="FLa-rV-Aas" secondAttribute="top" id="CB0-VD-h5m"/> 458 <constraint firstItem="FXQ-4O-sRc" firstAttribute="top" secondItem="FLa-rV-Aas" secondAttribute="top" id="CB0-VD-h5m"/>
458 <constraint firstAttribute="bottom" secondItem="FXQ-4O-sRc" secondAttribute="bottom" id="FbP-FY-h1E"/> 459 <constraint firstAttribute="bottom" secondItem="FXQ-4O-sRc" secondAttribute="bottom" id="FbP-FY-h1E"/>
459 <constraint firstAttribute="trailing" secondItem="rey-N3-l8b" secondAttribute="trailing" id="KFD-f5-xci"/> 460 <constraint firstAttribute="trailing" secondItem="rey-N3-l8b" secondAttribute="trailing" id="KFD-f5-xci"/>
460 <constraint firstItem="rey-N3-l8b" firstAttribute="top" secondItem="FLa-rV-Aas" secondAttribute="top" id="SpB-31-H3a"/> 461 <constraint firstItem="rey-N3-l8b" firstAttribute="top" secondItem="FLa-rV-Aas" secondAttribute="top" id="SpB-31-H3a"/>
461 <constraint firstItem="rey-N3-l8b" firstAttribute="leading" secondItem="FLa-rV-Aas" secondAttribute="leading" id="YvS-I2-8Dg"/> 462 <constraint firstItem="rey-N3-l8b" firstAttribute="leading" secondItem="FLa-rV-Aas" secondAttribute="leading" id="YvS-I2-8Dg"/>
462 <constraint firstAttribute="bottom" secondItem="rey-N3-l8b" secondAttribute="bottom" id="enX-7g-Eib"/> 463 <constraint firstAttribute="bottom" secondItem="rey-N3-l8b" secondAttribute="bottom" id="enX-7g-Eib"/>
463 </constraints> 464 </constraints>
464 <connections> 465 <connections>
465 <outletCollection property="gestureRecognizers" destination="Qjg-St-rCc" appends="YES" id="egt-sX-aBC"/> 466 <outletCollection property="gestureRecognizers" destination="Qjg-St-rCc" appends="YES" id="egt-sX-aBC"/>
466 <outletCollection property="gestureRecognizers" destination="VSZ-i0-Jhb" appends="YES" id="UKr-c3-9pp"/> 467 <outletCollection property="gestureRecognizers" destination="VSZ-i0-Jhb" appends="YES" id="UKr-c3-9pp"/>
467 </connections> 468 </connections>
468 </view> 469 </view>
469 </subviews> 470 </subviews>
470 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 471 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
471 <gestureRecognizers/> 472 <gestureRecognizers/>
472 <constraints> 473 <constraints>
473 <constraint firstAttribute="trailing" secondItem="Cf1-lP-zbB" secondAttribute="trailing" constant="10" id="20C-UL-MCu"/> 474 <constraint firstAttribute="trailing" secondItem="Cf1-lP-zbB" secondAttribute="trailing" constant="10" id="20C-UL-MCu"/>
474 <constraint firstItem="clL-JG-rbd" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="3tf-ab-v41"/> 475 <constraint firstItem="clL-JG-rbd" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="3tf-ab-v41"/>
475 <constraint firstItem="Cf1-lP-zbB" firstAttribute="top" secondItem="clL-JG-rbd" secondAttribute="bottom" id="5vy-x5-G38"/> 476 <constraint firstItem="Cf1-lP-zbB" firstAttribute="top" secondItem="clL-JG-rbd" secondAttribute="bottom" id="5vy-x5-G38"/>
476 <constraint firstItem="Cf1-lP-zbB" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="10" id="974-wJ-aRb"/> 477 <constraint firstItem="Cf1-lP-zbB" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="10" id="974-wJ-aRb"/>
477 <constraint firstItem="yxY-4d-tB6" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="2" id="Jqg-nE-6dv"/> 478 <constraint firstItem="yxY-4d-tB6" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="2" id="Jqg-nE-6dv"/>
478 <constraint firstAttribute="trailing" secondItem="BVv-qD-EHM" secondAttribute="trailing" id="MCi-Tl-hSp"/> 479 <constraint firstAttribute="trailing" secondItem="BVv-qD-EHM" secondAttribute="trailing" id="MCi-Tl-hSp"/>
479 <constraint firstAttribute="trailing" secondItem="yxY-4d-tB6" secondAttribute="trailing" constant="2" id="Qs5-ky-nmB"/> 480 <constraint firstAttribute="trailing" secondItem="yxY-4d-tB6" secondAttribute="trailing" constant="2" id="Qs5-ky-nmB"/>
480 <constraint firstAttribute="bottom" secondItem="BVv-qD-EHM" secondAttribute="bottom" constant="50" id="SbT-PG-8MJ"/> 481 <constraint firstAttribute="bottom" secondItem="BVv-qD-EHM" secondAttribute="bottom" constant="50" placeholder="YES" id="SbT-PG-8MJ"/>
481 <constraint firstItem="BVv-qD-EHM" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="SqH-AA-Z2K"/> 482 <constraint firstItem="BVv-qD-EHM" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="SqH-AA-Z2K"/>
482 <constraint firstItem="FLa-rV-Aas" firstAttribute="top" secondItem="yxY-4d-tB6" secondAttribute="bottom" constant="15" id="cWw-RX-1Kp"/> 483 <constraint firstItem="FLa-rV-Aas" firstAttribute="top" secondItem="yxY-4d-tB6" secondAttribute="bottom" constant="15" id="cWw-RX-1Kp"/>
483 <constraint firstItem="yxY-4d-tB6" firstAttribute="top" secondItem="Cf1-lP-zbB" secondAttribute="bottom" constant="15" id="dSN-ey-gQ7"/> 484 <constraint firstItem="yxY-4d-tB6" firstAttribute="top" secondItem="Cf1-lP-zbB" secondAttribute="bottom" constant="15" id="dSN-ey-gQ7"/>
484 <constraint firstItem="clL-JG-rbd" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="i5Z-XR-Msb"/> 485 <constraint firstItem="clL-JG-rbd" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="i5Z-XR-Msb"/>
485 <constraint firstItem="FLa-rV-Aas" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="iiN-Zj-1uu"/> 486 <constraint firstItem="FLa-rV-Aas" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="iiN-Zj-1uu"/>
486 <constraint firstAttribute="trailing" secondItem="FLa-rV-Aas" secondAttribute="trailing" id="jme-cz-cFt"/> 487 <constraint firstAttribute="trailing" secondItem="FLa-rV-Aas" secondAttribute="trailing" id="jme-cz-cFt"/>
487 <constraint firstItem="BVv-qD-EHM" firstAttribute="top" secondItem="FLa-rV-Aas" secondAttribute="bottom" constant="5" id="qbT-yT-phN"/> 488 <constraint firstItem="BVv-qD-EHM" firstAttribute="top" secondItem="FLa-rV-Aas" secondAttribute="bottom" constant="5" id="qbT-yT-phN"/>
488 <constraint firstAttribute="trailing" secondItem="clL-JG-rbd" secondAttribute="trailing" id="ri5-LG-xJH"/> 489 <constraint firstAttribute="trailing" secondItem="clL-JG-rbd" secondAttribute="trailing" id="ri5-LG-xJH"/>
489 </constraints> 490 </constraints>
490 <point key="canvasLocation" x="26.5" y="52.5"/> 491 <point key="canvasLocation" x="26.5" y="52.5"/>
491 </view> 492 </view>
492 <swipeGestureRecognizer cancelsTouchesInView="NO" direction="left" id="Qjg-St-rCc"> 493 <swipeGestureRecognizer cancelsTouchesInView="NO" direction="left" id="Qjg-St-rCc">
493 <connections> 494 <connections>
494 <action selector="swipeAction:" destination="-1" id="2Vl-bM-Ta7"/> 495 <action selector="swipeAction:" destination="-1" id="2Vl-bM-Ta7"/>
495 </connections> 496 </connections>
496 </swipeGestureRecognizer> 497 </swipeGestureRecognizer>
497 <swipeGestureRecognizer cancelsTouchesInView="NO" direction="right" id="VSZ-i0-Jhb"> 498 <swipeGestureRecognizer cancelsTouchesInView="NO" direction="right" id="VSZ-i0-Jhb">
498 <connections> 499 <connections>
499 <action selector="swipeAction:" destination="-1" id="hoY-6M-DoS"/> 500 <action selector="swipeAction:" destination="-1" id="hoY-6M-DoS"/>
500 </connections> 501 </connections>
501 </swipeGestureRecognizer> 502 </swipeGestureRecognizer>
502 </objects> 503 </objects>
503 <resources> 504 <resources>
504 <image name="arrow_back" width="22" height="22"/> 505 <image name="arrow_back" width="22" height="22"/>
505 <image name="arrow_next" width="22" height="22"/> 506 <image name="arrow_next" width="22" height="22"/>
506 <image name="icon_menu" width="30" height="30"/> 507 <image name="icon_menu" width="30" height="30"/>
507 <image name="today_back_button" width="73" height="37"/> 508 <image name="today_back_button" width="73" height="37"/>
508 </resources> 509 </resources>
509 </document> 510 </document>
510 511
LifeLog/LifeLog/HomeViewConb troller.m
1 // 1 //
2 // HomeViewController.m 2 // HomeViewController.m
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by Nguyen Van Phong on 7/25/17. 5 // Created by Nguyen Van Phong on 7/25/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import "HomeViewController.h" 9 #import "HomeViewController.h"
10 #import "NSDate+helper.h" 10 #import "NSDate+helper.h"
11 #import <CoreMotion/CoreMotion.h> 11 #import <CoreMotion/CoreMotion.h>
12 #import "CMMotionActivityExtra.h" 12 #import "CMMotionActivityExtra.h"
13 #import "TodayViewController.h" 13 #import "TodayViewController.h"
14 #import "Utilities.h" 14 #import "Utilities.h"
15 #import <MBProgressHUD/MBProgressHUD.h> 15 #import <MBProgressHUD/MBProgressHUD.h>
16 #import "ServerAPI.h" 16 #import "ServerAPI.h"
17 17
18 static NSInteger maxRequest = 20; 18 static NSInteger maxRequest = 20;
19 static NSInteger numberTotal = 10000; 19 static NSInteger numberTotal = 10000;
20 20
21 @interface HomeViewController () 21 @interface HomeViewController ()
22 { 22 {
23 MBProgressHUD *progressHud; 23 MBProgressHUD *progressHud;
24 NSInteger targetStep; 24 NSInteger targetStep;
25 } 25 }
26 @property (nonatomic, weak) IBOutlet UILabel *lblTitle; 26 @property (nonatomic, weak) IBOutlet UILabel *lblTitle;
27 @property (nonatomic, weak) IBOutlet UIImageView *avatar; 27 @property (nonatomic, weak) IBOutlet UIImageView *avatar;
28 @property (nonatomic, weak) IBOutlet UILabel *lblDateCurrent; 28 @property (nonatomic, weak) IBOutlet UILabel *lblDateCurrent;
29 @property (nonatomic, weak) IBOutlet UILabel *lblValueStep; 29 @property (nonatomic, weak) IBOutlet UILabel *lblValueStep;
30 @property (nonatomic, weak) IBOutlet UILabel *lblUnitStep; 30 @property (nonatomic, weak) IBOutlet UILabel *lblUnitStep;
31 @property (nonatomic, weak) IBOutlet UILabel *lblValueStepOther; 31 @property (nonatomic, weak) IBOutlet UILabel *lblValueStepOther;
32 @property (nonatomic, weak) IBOutlet UILabel *lblPercent; 32 @property (nonatomic, weak) IBOutlet UILabel *lblPercent;
33 @property (nonatomic, weak) IBOutlet UILabel *lblNotice; 33 @property (nonatomic, weak) IBOutlet UILabel *lblNotice;
34 @property (weak, nonatomic) IBOutlet UISegmentedControl *segmentHome; 34 @property (weak, nonatomic) IBOutlet UISegmentedControl *segmentHome;
35 @property (weak, nonatomic) IBOutlet UITextView *tvNotice; 35 @property (weak, nonatomic) IBOutlet UITextView *tvNotice;
36 36
37 @property (nonatomic, strong) CMPedometer *pedometer; 37 @property (nonatomic, strong) CMPedometer *pedometer;
38 @property (nonatomic, strong) CMMotionActivityManager *motionActivityManager; 38 @property (nonatomic, strong) CMMotionActivityManager *motionActivityManager;
39 @property (nonatomic, strong) NSOperationQueue *operationQueue; 39 @property (nonatomic, strong) NSOperationQueue *operationQueue;
40 @property (nonatomic, strong) NSTimer *timer; 40 @property (nonatomic, strong) NSTimer *timer;
41 @property (nonatomic, assign) NSInteger bike; 41 @property (nonatomic, assign) NSInteger bike;
42 @property (nonatomic, assign) NSInteger walking; 42 @property (nonatomic, assign) NSInteger walking;
43 @property (nonatomic, assign) NSInteger running; 43 @property (nonatomic, assign) NSInteger running;
44 @property (nonatomic, strong) NSDate *dateCurrent; 44 @property (nonatomic, strong) NSDate *dateCurrent;
45 45
46 @property (nonatomic, assign) int totalRequest; 46 @property (nonatomic, assign) int totalRequest;
47 @property (nonatomic, assign) int countComplete; 47 @property (nonatomic, assign) int countComplete;
48 @property (nonatomic, assign) int currentIndex; 48 @property (nonatomic, assign) int currentIndex;
49 49
50 @end 50 @end
51 51
52 @implementation HomeViewController 52 @implementation HomeViewController
53 53
54 - (void)viewDidLoad { 54 - (void)viewDidLoad {
55 [super viewDidLoad]; 55 [super viewDidLoad];
56 56
57 self.lblTitle.text = NSLocalizedString(@"lifelog.home.title", nil); 57 self.lblTitle.text = NSLocalizedString(@"lifelog.home.title", nil);
58 58
59 [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.lblTitle attribute:NSLayoutAttributeTop multiplier:1 constant:0]]; 59 [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.lblTitle attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
60 [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.bottomLayoutGuide attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.segmentHome attribute:NSLayoutAttributeBottom multiplier:1 constant:20]];
60 61
61 self.avatar.backgroundColor = [UIColor whiteColor]; 62 self.avatar.backgroundColor = [UIColor whiteColor];
62 self.avatar.layer.borderWidth = 2.0f; 63 self.avatar.layer.borderWidth = 2.0f;
63 self.avatar.layer.borderColor = [[UIColor whiteColor] CGColor]; 64 self.avatar.layer.borderColor = [[UIColor whiteColor] CGColor];
64 self.avatar.layer.cornerRadius = self.avatar.frame.size.width/2.0f; 65 self.avatar.layer.cornerRadius = self.avatar.frame.size.width/2.0f;
65 self.avatar.layer.masksToBounds = YES; 66 self.avatar.layer.masksToBounds = YES;
66 NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:kUser]; 67 NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:kUser];
67 User *user = (User *)[NSKeyedUnarchiver unarchiveObjectWithData:data]; 68 User *user = (User *)[NSKeyedUnarchiver unarchiveObjectWithData:data];
68 if (user != nil) { 69 if (user != nil) {
69 NSString *linkImage = [NSString stringWithFormat:@"%@%@", kServerAddress, user.profile_image]; 70 NSString *linkImage = [NSString stringWithFormat:@"%@%@", kServerAddress, user.profile_image];
70 NSURL *urlImage = [NSURL URLWithString:linkImage]; 71 NSURL *urlImage = [NSURL URLWithString:linkImage];
71 NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; 72 NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
72 sessionConfig.timeoutIntervalForRequest = 30.0; 73 sessionConfig.timeoutIntervalForRequest = 30.0;
73 sessionConfig.timeoutIntervalForResource = 60.0; 74 sessionConfig.timeoutIntervalForResource = 60.0;
74 sessionConfig.HTTPMaximumConnectionsPerHost = 20; 75 sessionConfig.HTTPMaximumConnectionsPerHost = 20;
75 sessionConfig.allowsCellularAccess = YES; 76 sessionConfig.allowsCellularAccess = YES;
76 HomeViewController __weak *weakSelf = self; 77 HomeViewController __weak *weakSelf = self;
77 NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig]; 78 NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig];
78 NSURLSessionDataTask *downloadPhotoTask = [session 79 NSURLSessionDataTask *downloadPhotoTask = [session
79 dataTaskWithURL:urlImage completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { 80 dataTaskWithURL:urlImage completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
80 if (weakSelf == nil) 81 if (weakSelf == nil)
81 { 82 {
82 return; 83 return;
83 } 84 }
84 if (error == nil) { 85 if (error == nil) {
85 UIImage *image = [[UIImage alloc] initWithData:data]; 86 UIImage *image = [[UIImage alloc] initWithData:data];
86 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 87 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
87 weakSelf.avatar.image = image; 88 weakSelf.avatar.image = image;
88 }]; 89 }];
89 } 90 }
90 }]; 91 }];
91 [downloadPhotoTask resume]; 92 [downloadPhotoTask resume];
92 } 93 }
93 94
94 self.lblNotice.text = NSLocalizedString(@"lifelog.home.notice", nil); 95 self.lblNotice.text = NSLocalizedString(@"lifelog.home.notice", nil);
95 96
96 _dateCurrent = [NSDate date]; 97 _dateCurrent = [NSDate date];
97 self.lblDateCurrent.text = [NSString stringWithFormat:@"%ld%@%ld%@%ld%@", (long)[_dateCurrent getYear], NSLocalizedString(@"lifelog.common.year", nil), (long)[_dateCurrent getMonth], NSLocalizedString(@"lifelog.common.month", nil), (long)[_dateCurrent getDay], NSLocalizedString(@"lifelog.common.day", nil)]; 98 self.lblDateCurrent.text = [NSString stringWithFormat:@"%ld%@%ld%@%ld%@", (long)[_dateCurrent getYear], NSLocalizedString(@"lifelog.common.year", nil), (long)[_dateCurrent getMonth], NSLocalizedString(@"lifelog.common.month", nil), (long)[_dateCurrent getDay], NSLocalizedString(@"lifelog.common.day", nil)];
98 99
99 self.lblUnitStep.text = NSLocalizedString(@"lifelog.home.unit.step", nil); 100 self.lblUnitStep.text = NSLocalizedString(@"lifelog.home.unit.step", nil);
100 101
101 if ([CMPedometer isStepCountingAvailable]) { 102 if ([CMPedometer isStepCountingAvailable]) {
102 _pedometer = [[CMPedometer alloc] init]; 103 _pedometer = [[CMPedometer alloc] init];
103 } 104 }
104 if ([CMMotionActivityManager isActivityAvailable]) { 105 if ([CMMotionActivityManager isActivityAvailable]) {
105 _motionActivityManager = [[CMMotionActivityManager alloc] init]; 106 _motionActivityManager = [[CMMotionActivityManager alloc] init];
106 } 107 }
107 _operationQueue = [[NSOperationQueue alloc] init]; 108 _operationQueue = [[NSOperationQueue alloc] init];
108 _bike = 0; 109 _bike = 0;
109 _walking = 0; 110 _walking = 0;
110 _running = 0; 111 _running = 0;
111 _segmentHome.selectedSegmentIndex = 1; 112 _segmentHome.selectedSegmentIndex = 1;
112 _totalRequest = 0; 113 _totalRequest = 0;
113 _countComplete = 0; 114 _countComplete = 0;
114 115
115 progressHud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 116 progressHud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
116 progressHud.mode = MBProgressHUDModeIndeterminate; 117 progressHud.mode = MBProgressHUDModeIndeterminate;
117 progressHud.detailsLabel.text = NSLocalizedString(@"lifelog.home.progressHud.title", nil); 118 progressHud.detailsLabel.text = NSLocalizedString(@"lifelog.home.progressHud.title", nil);
118 // [self saveDataStep7LastDay]; 119 // [self saveDataStep7LastDay];
119 targetStep = numberTotal; 120 targetStep = numberTotal;
120 [self requestNotice]; 121 [self requestNotice];
121 } 122 }
122 123
123 - (void)requestNotice 124 - (void)requestNotice
124 { 125 {
125 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 126 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
126 [dateFormatter setDateFormat:@"yyyy-MM-dd"]; 127 [dateFormatter setDateFormat:@"yyyy-MM-dd"];
127 NSString *dateString = [dateFormatter stringFromDate:_dateCurrent]; 128 NSString *dateString = [dateFormatter stringFromDate:_dateCurrent];
128 HomeViewController __weak *weakSelf = self; 129 HomeViewController __weak *weakSelf = self;
129 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 130 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
130 //Do background work 131 //Do background work
131 [[ServerAPI server] getNoticeByDate:dateString CompletionHandler:^(NSArray *arrResults, NSError *error) { 132 [[ServerAPI server] getNoticeByDate:dateString CompletionHandler:^(NSArray *arrResults, NSError *error) {
132 if(weakSelf == nil) { 133 if(weakSelf == nil) {
133 return ; 134 return ;
134 } 135 }
135 if (error == nil) { 136 if (error == nil) {
136 // NSLog(@"List Notices: %@", arrResults); 137 // NSLog(@"List Notices: %@", arrResults);
137 dispatch_async(dispatch_get_main_queue(), ^{ 138 dispatch_async(dispatch_get_main_queue(), ^{
138 NSString *stringNotice = @""; 139 NSString *stringNotice = @"";
139 for (NSString *noticeInfor in arrResults) { 140 for (NSString *noticeInfor in arrResults) {
140 NSString *noticeString = [NSString stringWithFormat:@"%@\n", noticeInfor]; 141 NSString *noticeString = [NSString stringWithFormat:@"%@\n", noticeInfor];
141 stringNotice = [stringNotice stringByAppendingString:noticeString]; 142 stringNotice = [stringNotice stringByAppendingString:noticeString];
142 } 143 }
143 weakSelf.tvNotice.text = stringNotice; 144 weakSelf.tvNotice.text = stringNotice;
144 }); 145 });
145 } 146 }
146 else { 147 else {
147 dispatch_async(dispatch_get_main_queue(), ^{ 148 dispatch_async(dispatch_get_main_queue(), ^{
148 weakSelf.tvNotice.text = @""; 149 weakSelf.tvNotice.text = @"";
149 /* 150 /*
150 NSString *message = [error.userInfo objectForKey:@"message"]; 151 NSString *message = [error.userInfo objectForKey:@"message"];
151 [Utilities showErrorMessage:message withViewController:weakSelf]; 152 [Utilities showErrorMessage:message withViewController:weakSelf];
152 */ 153 */
153 }); 154 });
154 } 155 }
155 }]; 156 }];
156 }); 157 });
157 } 158 }
158 159
159 - (void)viewWillAppear:(BOOL)animated { 160 - (void)viewWillAppear:(BOOL)animated {
160 [super viewWillAppear:animated]; 161 [super viewWillAppear:animated];
161 NSDate *dateNow = [NSDate date]; 162 NSDate *dateNow = [NSDate date];
162 [self saveStepForDay:dateNow]; 163 [self saveStepForDay:dateNow];
163 } 164 }
164 165
165 - (void)requestTopByDate:(NSDate *)date { 166 - (void)requestTopByDate:(NSDate *)date {
166 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 167 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
167 [dateFormatter setDateFormat:@"yyyy-MM-dd"]; 168 [dateFormatter setDateFormat:@"yyyy-MM-dd"];
168 NSString *dateString = [dateFormatter stringFromDate:date]; 169 NSString *dateString = [dateFormatter stringFromDate:date];
169 [progressHud showAnimated:YES]; 170 [progressHud showAnimated:YES];
170 [progressHud setHidden:NO]; 171 [progressHud setHidden:NO];
171 HomeViewController __weak *weakSelf = self; 172 HomeViewController __weak *weakSelf = self;
172 int mode = 1; 173 int mode = 1;
173 switch (_segmentHome.selectedSegmentIndex) { 174 switch (_segmentHome.selectedSegmentIndex) {
174 case 0: 175 case 0:
175 mode = 3; 176 mode = 3;
176 break; 177 break;
177 178
178 case 1: 179 case 1:
179 mode = 1; 180 mode = 1;
180 break; 181 break;
181 182
182 case 2: 183 case 2:
183 mode = 2; 184 mode = 2;
184 break; 185 break;
185 186
186 default: 187 default:
187 break; 188 break;
188 } 189 }
189 [[ServerAPI server] requestTopWithMode:mode andDate:dateString CompletionHandler:^(TopObject *topObject, NSError *error) { 190 [[ServerAPI server] requestTopWithMode:mode andDate:dateString CompletionHandler:^(TopObject *topObject, NSError *error) {
190 if(weakSelf == nil) { 191 if(weakSelf == nil) {
191 return ; 192 return ;
192 } 193 }
193 if (error == nil) { 194 if (error == nil) {
194 NSLog(@"TopObject: %@", topObject); 195 NSLog(@"TopObject: %@", topObject);
195 dispatch_async(dispatch_get_main_queue(), ^{ 196 dispatch_async(dispatch_get_main_queue(), ^{
196 [weakSelf updateStepUI:topObject.targetInfor]; 197 [weakSelf updateStepUI:topObject.targetInfor];
197 }); 198 });
198 } 199 }
199 else { 200 else {
200 dispatch_async(dispatch_get_main_queue(), ^{ 201 dispatch_async(dispatch_get_main_queue(), ^{
201 NSString *message = [error.userInfo objectForKey:@"message"]; 202 NSString *message = [error.userInfo objectForKey:@"message"];
202 [Utilities showErrorMessage:message withViewController:weakSelf]; 203 [Utilities showErrorMessage:message withViewController:weakSelf];
203 }); 204 });
204 } 205 }
205 dispatch_async(dispatch_get_main_queue(), ^{ 206 dispatch_async(dispatch_get_main_queue(), ^{
206 [progressHud setHidden:YES]; 207 [progressHud setHidden:YES];
207 }); 208 });
208 }]; 209 }];
209 /* 210 /*
210 [[ServerAPI server] requestHomeWithMode:mode andDate:dateString CompletionHandler:^(HomeObject *homeObject, NSError *error) { 211 [[ServerAPI server] requestHomeWithMode:mode andDate:dateString CompletionHandler:^(HomeObject *homeObject, NSError *error) {
211 if(weakSelf == nil) { 212 if(weakSelf == nil) {
212 return ; 213 return ;
213 } 214 }
214 if (error == nil) { 215 if (error == nil) {
215 NSLog(@"List Notices: %@", homeObject.listNotice); 216 NSLog(@"List Notices: %@", homeObject.listNotice);
216 for (NoticeInfor *noticeInfor in homeObject.listNotice) { 217 for (NoticeInfor *noticeInfor in homeObject.listNotice) {
217 NSLog(@"noticeInfor: %@", noticeInfor.notice_content); 218 NSLog(@"noticeInfor: %@", noticeInfor.notice_content);
218 } 219 }
219 dispatch_async(dispatch_get_main_queue(), ^{ 220 dispatch_async(dispatch_get_main_queue(), ^{
220 [weakSelf updateNoticeUI:homeObject]; 221 [weakSelf updateNoticeUI:homeObject];
221 }); 222 });
222 } 223 }
223 else { 224 else {
224 dispatch_async(dispatch_get_main_queue(), ^{ 225 dispatch_async(dispatch_get_main_queue(), ^{
225 NSString *message = [error.userInfo objectForKey:@"message"]; 226 NSString *message = [error.userInfo objectForKey:@"message"];
226 [Utilities showErrorMessage:message withViewController:weakSelf]; 227 [Utilities showErrorMessage:message withViewController:weakSelf];
227 }); 228 });
228 } 229 }
229 dispatch_async(dispatch_get_main_queue(), ^{ 230 dispatch_async(dispatch_get_main_queue(), ^{
230 [progressHud setHidden:YES]; 231 [progressHud setHidden:YES];
231 }); 232 });
232 }]; 233 }];
233 */ 234 */
234 } 235 }
235 236
236 - (void)viewWillDisappear:(BOOL)animated { 237 - (void)viewWillDisappear:(BOOL)animated {
237 [super viewWillDisappear:animated]; 238 [super viewWillDisappear:animated];
238 } 239 }
239 240
240 - (void)didReceiveMemoryWarning { 241 - (void)didReceiveMemoryWarning {
241 [super didReceiveMemoryWarning]; 242 [super didReceiveMemoryWarning];
242 // Dispose of any resources that can be recreated. 243 // Dispose of any resources that can be recreated.
243 } 244 }
244 245
245 #pragma mark - IBAction 246 #pragma mark - IBAction
246 - (IBAction)menuButtonTouchUpInside:(id)sender 247 - (IBAction)menuButtonTouchUpInside:(id)sender
247 { 248 {
248 249
249 } 250 }
250 251
251 - (IBAction)todayButtonTouchUpInside:(id)sender 252 - (IBAction)todayButtonTouchUpInside:(id)sender
252 { 253 {
253 TodayViewController *todayVC = [[TodayViewController alloc] initWithNibName:@"TodayViewController" bundle:nil]; 254 TodayViewController *todayVC = [[TodayViewController alloc] initWithNibName:@"TodayViewController" bundle:nil];
254 todayVC.targetStep = targetStep; 255 todayVC.targetStep = targetStep;
255 [self.navigationController pushViewController:todayVC animated:YES]; 256 [self.navigationController pushViewController:todayVC animated:YES];
256 } 257 }
257 258
258 - (IBAction)leftButtonTouchUpInside:(id)sender 259 - (IBAction)leftButtonTouchUpInside:(id)sender
259 { 260 {
260 self.dateCurrent = [self.dateCurrent dateByAddingTimeInterval:-(24*60*60)]; 261 self.dateCurrent = [self.dateCurrent dateByAddingTimeInterval:-(24*60*60)];
261 self.lblDateCurrent.text = [NSString stringWithFormat:@"%ld%@%ld%@%ld%@", (long)[_dateCurrent getYear], NSLocalizedString(@"lifelog.common.year", nil), (long)[_dateCurrent getMonth], NSLocalizedString(@"lifelog.common.month", nil), (long)[_dateCurrent getDay], NSLocalizedString(@"lifelog.common.day", nil)]; 262 self.lblDateCurrent.text = [NSString stringWithFormat:@"%ld%@%ld%@%ld%@", (long)[_dateCurrent getYear], NSLocalizedString(@"lifelog.common.year", nil), (long)[_dateCurrent getMonth], NSLocalizedString(@"lifelog.common.month", nil), (long)[_dateCurrent getDay], NSLocalizedString(@"lifelog.common.day", nil)];
262 [self resetStepUI]; 263 [self resetStepUI];
263 [self saveStepForDay:self.dateCurrent]; 264 [self saveStepForDay:self.dateCurrent];
264 [self requestNotice]; 265 [self requestNotice];
265 } 266 }
266 267
267 - (IBAction)rightButtonTouchUpInside:(id)sender 268 - (IBAction)rightButtonTouchUpInside:(id)sender
268 { 269 {
269 self.dateCurrent = [self.dateCurrent dateByAddingTimeInterval:24*60*60]; 270 self.dateCurrent = [self.dateCurrent dateByAddingTimeInterval:24*60*60];
270 self.lblDateCurrent.text = [NSString stringWithFormat:@"%ld%@%ld%@%ld%@", (long)[_dateCurrent getYear], NSLocalizedString(@"lifelog.common.year", nil), (long)[_dateCurrent getMonth], NSLocalizedString(@"lifelog.common.month", nil), (long)[_dateCurrent getDay], NSLocalizedString(@"lifelog.common.day", nil)]; 271 self.lblDateCurrent.text = [NSString stringWithFormat:@"%ld%@%ld%@%ld%@", (long)[_dateCurrent getYear], NSLocalizedString(@"lifelog.common.year", nil), (long)[_dateCurrent getMonth], NSLocalizedString(@"lifelog.common.month", nil), (long)[_dateCurrent getDay], NSLocalizedString(@"lifelog.common.day", nil)];
271 [self resetStepUI]; 272 [self resetStepUI];
272 //[self saveStepForDay:self.dateCurrent]; 273 //[self saveStepForDay:self.dateCurrent];
273 [self requestTopByDate:self.dateCurrent]; 274 [self requestTopByDate:self.dateCurrent];
274 [self requestNotice]; 275 [self requestNotice];
275 } 276 }
276 277
277 - (IBAction)segmentValueChange:(id)sender { 278 - (IBAction)segmentValueChange:(id)sender {
278 [self resetStepUI]; 279 [self resetStepUI];
279 [self requestTopByDate:self.dateCurrent]; 280 [self requestTopByDate:self.dateCurrent];
280 } 281 }
281 282
282 #pragma mark - Functions Private 283 #pragma mark - Functions Private
283 - (void)saveStepForDay:(NSDate *)date 284 - (void)saveStepForDay:(NSDate *)date
284 { 285 {
285 if ([CMMotionActivityManager isActivityAvailable]) { 286 if ([CMMotionActivityManager isActivityAvailable] == YES) {
286 [progressHud showAnimated:YES]; 287 [progressHud showAnimated:YES];
287 [progressHud setHidden:NO]; 288 [progressHud setHidden:NO];
288 self.bike = 0; 289 self.bike = 0;
289 self.walking = 0; 290 self.walking = 0;
290 self.running = 0; 291 self.running = 0;
291 NSDate *startDate = [date beginningAtMidnightOfDay]; 292 NSDate *startDate = [date beginningAtMidnightOfDay];
292 NSDate *endDate = [startDate dateByAddingTimeInterval:(24*60*60 - 1)]; 293 NSDate *endDate = [startDate dateByAddingTimeInterval:(24*60*60 - 1)];
293 294
294 HomeViewController __weak *weakSelf = self; 295 HomeViewController __weak *weakSelf = self;
295 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog.forDay", NULL); 296 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog.forDay", NULL);
296 dispatch_async(myQueue, ^{ 297 dispatch_async(myQueue, ^{
297 if (weakSelf == nil) { 298 if (weakSelf == nil) {
298 return ; 299 return ;
299 } 300 }
300 301
301 [weakSelf.motionActivityManager queryActivityStartingFromDate:startDate toDate:endDate toQueue:_operationQueue withHandler:^(NSArray<CMMotionActivity *> * _Nullable activities, NSError * _Nullable error) { 302 [weakSelf.motionActivityManager queryActivityStartingFromDate:startDate toDate:endDate toQueue:_operationQueue withHandler:^(NSArray<CMMotionActivity *> * _Nullable activities, NSError * _Nullable error) {
302 if (error || activities.count <= 0) { 303 if (error || activities.count <= 0) {
303 dispatch_async(dispatch_get_main_queue(), ^{ 304 dispatch_async(dispatch_get_main_queue(), ^{
304 [weakSelf updateStepUI]; 305 [weakSelf updateStepUI];
305 }); 306 });
306 return ; 307 return ;
307 } 308 }
308 // set EndDate 309 // set EndDate
309 NSMutableArray *arrayActivities = [[NSMutableArray alloc] init]; 310 NSMutableArray *arrayActivities = [[NSMutableArray alloc] init];
310 for (int i = 0; i < activities.count; i++) { 311 for (int i = 0; i < activities.count; i++) {
311 CMMotionActivity *activity = [activities objectAtIndex:i]; 312 CMMotionActivity *activity = [activities objectAtIndex:i];
312 CMMotionActivityExtra *activityExtra = [[CMMotionActivityExtra alloc] init]; 313 CMMotionActivityExtra *activityExtra = [[CMMotionActivityExtra alloc] init];
313 activityExtra.activity = activity; 314 activityExtra.activity = activity;
314 if (i == activities.count - 1) { 315 if (i == activities.count - 1) {
315 activityExtra.endDate = endDate; 316 activityExtra.endDate = endDate;
316 } 317 }
317 else { 318 else {
318 CMMotionActivity *activityNext = [activities objectAtIndex:i+1]; 319 CMMotionActivity *activityNext = [activities objectAtIndex:i+1];
319 // activityExtra.endDate = [activityNext.startDate dateByAddingTimeInterval:-1]; 320 // activityExtra.endDate = [activityNext.startDate dateByAddingTimeInterval:-1];
320 activityExtra.endDate = activityNext.startDate; 321 activityExtra.endDate = activityNext.startDate;
321 } 322 }
322 [arrayActivities addObject:activityExtra]; 323 [arrayActivities addObject:activityExtra];
323 } 324 }
324 // PhongNV 325 // PhongNV
325 weakSelf.currentIndex = 0; 326 weakSelf.currentIndex = 0;
326 [weakSelf save20objectOfActivityExtras:arrayActivities]; 327 [weakSelf save20objectOfActivityExtras:arrayActivities];
327 }]; 328 }];
328 }); 329 });
330 }
331 else {
332 [self updateStepUI];
329 } 333 }
330 } 334 }
331 335
332 - (void)complete20Request:(NSArray *)activities { 336 - (void)complete20Request:(NSArray *)activities {
333 if (self.totalRequest == self.countComplete) { 337 if (self.totalRequest == self.countComplete) {
334 self.totalRequest = 0; 338 self.totalRequest = 0;
335 self.countComplete = 0; 339 self.countComplete = 0;
336 self.currentIndex++; 340 self.currentIndex++;
337 [self save20objectOfActivityExtras:activities]; 341 [self save20objectOfActivityExtras:activities];
338 } 342 }
339 } 343 }
340 - (void)save20objectOfActivityExtras:(NSArray *)activities 344 - (void)save20objectOfActivityExtras:(NSArray *)activities
341 { 345 {
342 int result = floor(activities.count / maxRequest); 346 int result = floor(activities.count / maxRequest);
343 if (activities.count <= 0 || self.currentIndex > result) { 347 if (activities.count <= 0 || self.currentIndex > result) {
344 self.totalRequest = 0; 348 self.totalRequest = 0;
345 self.countComplete = 0; 349 self.countComplete = 0;
346 self.currentIndex = 0; 350 self.currentIndex = 0;
347 dispatch_async(dispatch_get_main_queue(), ^{ 351 dispatch_async(dispatch_get_main_queue(), ^{
348 [self updateStepUI]; 352 [self updateStepUI];
349 }); 353 });
350 return; 354 return;
351 } 355 }
352 356
353 HomeViewController __weak *weakSelf = self; 357 HomeViewController __weak *weakSelf = self;
354 for (NSInteger index = self.currentIndex*maxRequest; index < self.currentIndex*maxRequest + maxRequest; index++) { 358 for (NSInteger index = self.currentIndex*maxRequest; index < self.currentIndex*maxRequest + maxRequest; index++) {
355 if ((self.currentIndex*maxRequest + maxRequest) >= activities.count) { 359 if ((self.currentIndex*maxRequest + maxRequest) >= activities.count) {
356 self.totalRequest = (int)(activities.count - self.currentIndex*maxRequest); 360 self.totalRequest = (int)(activities.count - self.currentIndex*maxRequest);
357 if (self.totalRequest <= 0) { 361 if (self.totalRequest <= 0) {
358 [weakSelf complete20Request:activities]; 362 [weakSelf complete20Request:activities];
359 } 363 }
360 } 364 }
361 else { 365 else {
362 self.totalRequest = (int)maxRequest; 366 self.totalRequest = (int)maxRequest;
363 } 367 }
364 if (index < activities.count) { 368 if (index < activities.count) {
365 CMMotionActivityExtra *activityExtra = [activities objectAtIndex:index]; 369 CMMotionActivityExtra *activityExtra = [activities objectAtIndex:index];
366 [self.pedometer queryPedometerDataFromDate:activityExtra.activity.startDate toDate:activityExtra.endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) { 370 [self.pedometer queryPedometerDataFromDate:activityExtra.activity.startDate toDate:activityExtra.endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) {
367 if (weakSelf == nil) { 371 if (weakSelf == nil) {
368 return ; 372 return ;
369 } 373 }
370 NSInteger numberStep = [pedometerData.numberOfSteps integerValue]; 374 NSInteger numberStep = [pedometerData.numberOfSteps integerValue];
371 int mode = 1; 375 int mode = 1;
372 if (activityExtra.activity.cycling) { 376 if (activityExtra.activity.cycling) {
373 mode = 3; 377 mode = 3;
374 } 378 }
375 else if (activityExtra.activity.walking) { 379 else if (activityExtra.activity.walking) {
376 mode = 1; 380 mode = 1;
377 } 381 }
378 else if (activityExtra.activity.running) { 382 else if (activityExtra.activity.running) {
379 mode = 2; 383 mode = 2;
380 } 384 }
381 else { 385 else {
382 // unknown 386 // unknown
383 } 387 }
384 // save step to server 388 // save step to server
385 if (numberStep > 0) { 389 if (numberStep > 0) {
386 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 390 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
387 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; 391 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
388 NSString *dateBegin = [dateFormatter stringFromDate:activityExtra.activity.startDate]; 392 NSString *dateBegin = [dateFormatter stringFromDate:activityExtra.activity.startDate];
389 NSString *dateEnd = [dateFormatter stringFromDate:activityExtra.endDate]; 393 NSString *dateEnd = [dateFormatter stringFromDate:activityExtra.endDate];
390 // NSLog(@"dateBegin: %@ | dateEnd: %@ | numberStep: %li", dateBegin, dateEnd, numberStep); 394 // NSLog(@"dateBegin: %@ | dateEnd: %@ | numberStep: %li", dateBegin, dateEnd, numberStep);
391 [[ServerAPI server] requestCreateLog:mode withStep:(int)numberStep startDate:dateBegin endDate:dateEnd CompletionHandler:^(NSError *error) { 395 [[ServerAPI server] requestCreateLog:mode withStep:(int)numberStep startDate:dateBegin endDate:dateEnd CompletionHandler:^(NSError *error) {
392 if (error) { 396 if (error) {
393 NSLog(@"Error: %@", error); 397 NSLog(@"Error: %@", error);
394 } 398 }
395 weakSelf.countComplete++; 399 weakSelf.countComplete++;
396 [weakSelf complete20Request:activities]; 400 [weakSelf complete20Request:activities];
397 }]; 401 }];
398 } 402 }
399 else { 403 else {
400 weakSelf.countComplete++; 404 weakSelf.countComplete++;
401 [weakSelf complete20Request:activities]; 405 [weakSelf complete20Request:activities];
402 } 406 }
403 }]; 407 }];
404 } 408 }
405 } 409 }
406 } 410 }
407 411
408 - (void)updateStepUI 412 - (void)updateStepUI
409 { 413 {
410 [self requestTopByDate:self.dateCurrent]; 414 [self requestTopByDate:self.dateCurrent];
411 } 415 }
412 416
413 - (void)saveDataStep7LastDay 417 - (void)saveDataStep7LastDay
414 { 418 {
415 NSDate *dateNow = [NSDate date]; 419 NSDate *dateNow = [NSDate date];
416 for (int index = 0; index < 7; index++) { 420 for (int index = 0; index < 7; index++) {
417 dateNow = [dateNow dateByAddingTimeInterval:-(24*60*60)]; 421 dateNow = [dateNow dateByAddingTimeInterval:-(24*60*60)];
418 [self saveStepByDate:dateNow]; 422 [self saveStepByDate:dateNow];
419 } 423 }
420 } 424 }
421 425
422 - (void)saveStepByDate:(NSDate *)date 426 - (void)saveStepByDate:(NSDate *)date
423 { 427 {
424 if ([CMMotionActivityManager isActivityAvailable]) { 428 if ([CMMotionActivityManager isActivityAvailable]) {
425 NSDate *startDate = [date beginningAtMidnightOfDay]; 429 NSDate *startDate = [date beginningAtMidnightOfDay];
426 NSDate *endDate = [startDate dateByAddingTimeInterval:(24*60*60 - 1)]; 430 NSDate *endDate = [startDate dateByAddingTimeInterval:(24*60*60 - 1)];
427 431
428 HomeViewController __weak *weakSelf = self; 432 HomeViewController __weak *weakSelf = self;
429 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog.7lastday", NULL); 433 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog.7lastday", NULL);
430 dispatch_async(myQueue, ^{ 434 dispatch_async(myQueue, ^{
431 if (weakSelf == nil) { 435 if (weakSelf == nil) {
432 return ; 436 return ;
433 } 437 }
434 438
435 [weakSelf.motionActivityManager queryActivityStartingFromDate:startDate toDate:endDate toQueue:_operationQueue withHandler:^(NSArray<CMMotionActivity *> * _Nullable activities, NSError * _Nullable error) { 439 [weakSelf.motionActivityManager queryActivityStartingFromDate:startDate toDate:endDate toQueue:_operationQueue withHandler:^(NSArray<CMMotionActivity *> * _Nullable activities, NSError * _Nullable error) {
436 if (error || activities.count <= 0) { 440 if (error || activities.count <= 0) {
437 return ; 441 return ;
438 } 442 }
439 // set EndDate 443 // set EndDate
440 NSMutableArray *arrayActivities = [[NSMutableArray alloc] init]; 444 NSMutableArray *arrayActivities = [[NSMutableArray alloc] init];
441 for (int i = 0; i < activities.count; i++) { 445 for (int i = 0; i < activities.count; i++) {
442 CMMotionActivity *activity = [activities objectAtIndex:i]; 446 CMMotionActivity *activity = [activities objectAtIndex:i];
443 CMMotionActivityExtra *activityExtra = [[CMMotionActivityExtra alloc] init]; 447 CMMotionActivityExtra *activityExtra = [[CMMotionActivityExtra alloc] init];
444 activityExtra.activity = activity; 448 activityExtra.activity = activity;
445 if (i == activities.count - 1) { 449 if (i == activities.count - 1) {
446 activityExtra.endDate = endDate; 450 activityExtra.endDate = endDate;
447 } 451 }
448 else { 452 else {
449 CMMotionActivity *activityNext = [activities objectAtIndex:i+1]; 453 CMMotionActivity *activityNext = [activities objectAtIndex:i+1];
450 activityExtra.endDate = [activityNext.startDate dateByAddingTimeInterval:-1]; 454 activityExtra.endDate = [activityNext.startDate dateByAddingTimeInterval:-1];
451 } 455 }
452 [arrayActivities addObject:activityExtra]; 456 [arrayActivities addObject:activityExtra];
453 } 457 }
454 458
455 for (CMMotionActivityExtra *activityExtra in arrayActivities) { 459 for (CMMotionActivityExtra *activityExtra in arrayActivities) {
456 [weakSelf.pedometer queryPedometerDataFromDate:activityExtra.activity.startDate toDate:activityExtra.endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) { 460 [weakSelf.pedometer queryPedometerDataFromDate:activityExtra.activity.startDate toDate:activityExtra.endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) {
457 NSInteger numberStep = [pedometerData.numberOfSteps integerValue]; 461 NSInteger numberStep = [pedometerData.numberOfSteps integerValue];
458 int mode = 1; 462 int mode = 1;
459 if (activityExtra.activity.cycling) { 463 if (activityExtra.activity.cycling) {
460 mode = 3; 464 mode = 3;
461 } 465 }
462 else if (activityExtra.activity.walking) { 466 else if (activityExtra.activity.walking) {
463 mode = 1; 467 mode = 1;
464 } 468 }
465 else if (activityExtra.activity.running) { 469 else if (activityExtra.activity.running) {
466 mode = 2; 470 mode = 2;
467 } 471 }
468 else { 472 else {
469 // unknown 473 // unknown
470 } 474 }
471 475
472 // save step to server 476 // save step to server
473 if (numberStep > 0) { 477 if (numberStep > 0) {
474 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 478 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
475 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; 479 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
476 NSString *dateBegin = [dateFormatter stringFromDate:activityExtra.activity.startDate]; 480 NSString *dateBegin = [dateFormatter stringFromDate:activityExtra.activity.startDate];
477 NSString *dateEnd = [dateFormatter stringFromDate:activityExtra.endDate]; 481 NSString *dateEnd = [dateFormatter stringFromDate:activityExtra.endDate];
478 [[ServerAPI server] requestCreateLog:mode withStep:(int)numberStep startDate:dateBegin endDate:dateEnd CompletionHandler:^(NSError *error) { 482 [[ServerAPI server] requestCreateLog:mode withStep:(int)numberStep startDate:dateBegin endDate:dateEnd CompletionHandler:^(NSError *error) {
479 if (error) { 483 if (error) {
480 NSLog(@"Error: %@", error); 484 NSLog(@"Error: %@", error);
481 } 485 }
482 }]; 486 }];
483 } 487 }
484 }]; 488 }];
485 } 489 }
486 }]; 490 }];
487 }); 491 });
488 } 492 }
489 } 493 }
490 494
491 - (void)updateStepUI:(TargetInfor *)targetInfor 495 - (void)updateStepUI:(TargetInfor *)targetInfor
492 { 496 {
493 NSString *stringTargetStep = [targetInfor.target_step stringByReplacingOccurrencesOfString:@"," withString:@""]; 497 NSString *stringTargetStep = [targetInfor.target_step stringByReplacingOccurrencesOfString:@"," withString:@""];
494 targetStep = [stringTargetStep integerValue]; 498 targetStep = [stringTargetStep integerValue];
495 self.lblValueStep.text = targetInfor.num_step; 499 self.lblValueStep.text = targetInfor.num_step;
496 self.lblValueStepOther.text = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"lifelog.today.remaining.other", nil), targetInfor.remaining_step]; 500 self.lblValueStepOther.text = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"lifelog.today.remaining.other", nil), targetInfor.remaining_step];
497 self.lblPercent.text = [NSString stringWithFormat:@"%@ %i%@", NSLocalizedString(@"lifelog.today.text.percent", nil), [targetInfor.complete_percent intValue], NSLocalizedString(@"lifelog.today.percent", nil)]; 501 self.lblPercent.text = [NSString stringWithFormat:@"%@ %i%@", NSLocalizedString(@"lifelog.today.text.percent", nil), [targetInfor.complete_percent intValue], NSLocalizedString(@"lifelog.today.percent", nil)];
498 } 502 }
499 503
500 - (void)updateNoticeUI:(HomeObject *)homeObject 504 - (void)updateNoticeUI:(HomeObject *)homeObject
501 { 505 {
502 NSString *stringNotice = @""; 506 NSString *stringNotice = @"";
503 for (NoticeInfor *notice in homeObject.listNotice) { 507 for (NoticeInfor *notice in homeObject.listNotice) {
504 NSString *noticeString = [NSString stringWithFormat:@"%@\n", notice.notice_content]; 508 NSString *noticeString = [NSString stringWithFormat:@"%@\n", notice.notice_content];
505 stringNotice = [stringNotice stringByAppendingString:noticeString]; 509 stringNotice = [stringNotice stringByAppendingString:noticeString];
506 } 510 }
507 _tvNotice.text = stringNotice; 511 _tvNotice.text = stringNotice;
508 } 512 }
509 513
510 - (void)resetStepUI 514 - (void)resetStepUI
511 { 515 {
512 self.lblValueStep.text = @""; 516 self.lblValueStep.text = @"";
513 self.lblValueStepOther.text = @""; 517 self.lblValueStepOther.text = @"";
514 self.lblPercent.text = @""; 518 self.lblPercent.text = @"";
515 } 519 }
516 520
517 @end 521 @end
518 522
LifeLog/LifeLog/HomeViewController.xib
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> 2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3 <device id="retina4_7" orientation="portrait"> 3 <device id="retina4_7" orientation="portrait">
4 <adaptation id="fullscreen"/> 4 <adaptation id="fullscreen"/>
5 </device> 5 </device>
6 <dependencies> 6 <dependencies>
7 <deployment identifier="iOS"/> 7 <deployment identifier="iOS"/>
8 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/> 8 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
9 <capability name="Aspect ratio constraints" minToolsVersion="5.1"/> 9 <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
10 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> 10 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
11 </dependencies> 11 </dependencies>
12 <objects> 12 <objects>
13 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HomeViewController"> 13 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HomeViewController">
14 <connections> 14 <connections>
15 <outlet property="avatar" destination="J2A-tf-wH0" id="FdR-Zg-4ye"/> 15 <outlet property="avatar" destination="J2A-tf-wH0" id="FdR-Zg-4ye"/>
16 <outlet property="lblDateCurrent" destination="IaR-IO-4RA" id="nVS-KW-X4d"/> 16 <outlet property="lblDateCurrent" destination="IaR-IO-4RA" id="nVS-KW-X4d"/>
17 <outlet property="lblNotice" destination="lnt-4H-Ao8" id="aoM-JS-VHg"/> 17 <outlet property="lblNotice" destination="lnt-4H-Ao8" id="aoM-JS-VHg"/>
18 <outlet property="lblPercent" destination="DuE-Dh-nEe" id="Yz4-VO-P2h"/> 18 <outlet property="lblPercent" destination="DuE-Dh-nEe" id="Yz4-VO-P2h"/>
19 <outlet property="lblTitle" destination="u3S-9u-GMZ" id="7C6-gv-vPu"/> 19 <outlet property="lblTitle" destination="u3S-9u-GMZ" id="7C6-gv-vPu"/>
20 <outlet property="lblUnitStep" destination="wfu-aB-xXm" id="4Ms-pS-D2m"/> 20 <outlet property="lblUnitStep" destination="wfu-aB-xXm" id="4Ms-pS-D2m"/>
21 <outlet property="lblValueStep" destination="TUf-Tp-93t" id="qAh-fl-oW4"/> 21 <outlet property="lblValueStep" destination="TUf-Tp-93t" id="qAh-fl-oW4"/>
22 <outlet property="lblValueStepOther" destination="3Xj-IB-96h" id="yXj-HA-fDR"/> 22 <outlet property="lblValueStepOther" destination="3Xj-IB-96h" id="yXj-HA-fDR"/>
23 <outlet property="segmentHome" destination="ibb-Yl-iqu" id="lE6-pr-GgT"/> 23 <outlet property="segmentHome" destination="ibb-Yl-iqu" id="lE6-pr-GgT"/>
24 <outlet property="tvNotice" destination="kdD-rj-BtX" id="t6k-l8-l2N"/> 24 <outlet property="tvNotice" destination="kdD-rj-BtX" id="t6k-l8-l2N"/>
25 <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> 25 <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
26 </connections> 26 </connections>
27 </placeholder> 27 </placeholder>
28 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> 28 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
29 <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> 29 <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
30 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> 30 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
31 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 31 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
32 <subviews> 32 <subviews>
33 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="HOME" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u3S-9u-GMZ" userLabel="LabelTitle"> 33 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="HOME" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u3S-9u-GMZ" userLabel="LabelTitle">
34 <rect key="frame" x="0.0" y="0.0" width="375" height="44"/> 34 <rect key="frame" x="0.0" y="0.0" width="375" height="44"/>
35 <color key="backgroundColor" red="0.098039215686274508" green="0.098039215686274508" blue="0.098039215686274508" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 35 <color key="backgroundColor" red="0.098039215686274508" green="0.098039215686274508" blue="0.098039215686274508" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
36 <constraints> 36 <constraints>
37 <constraint firstAttribute="height" constant="44" id="8z2-GM-1iE"/> 37 <constraint firstAttribute="height" constant="44" id="8z2-GM-1iE"/>
38 </constraints> 38 </constraints>
39 <fontDescription key="fontDescription" type="system" pointSize="23"/> 39 <fontDescription key="fontDescription" type="system" pointSize="23"/>
40 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 40 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
41 <nil key="highlightedColor"/> 41 <nil key="highlightedColor"/>
42 </label> 42 </label>
43 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LPY-Zl-cOp" userLabel="ButtonMenu"> 43 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LPY-Zl-cOp" userLabel="ButtonMenu">
44 <rect key="frame" x="335" y="7" width="30" height="30"/> 44 <rect key="frame" x="335" y="7" width="30" height="30"/>
45 <constraints> 45 <constraints>
46 <constraint firstAttribute="width" constant="30" id="5Ve-P6-6G7"/> 46 <constraint firstAttribute="width" constant="30" id="5Ve-P6-6G7"/>
47 <constraint firstAttribute="width" secondItem="LPY-Zl-cOp" secondAttribute="height" multiplier="1:1" id="6V0-0o-71r"/> 47 <constraint firstAttribute="width" secondItem="LPY-Zl-cOp" secondAttribute="height" multiplier="1:1" id="6V0-0o-71r"/>
48 </constraints> 48 </constraints>
49 <state key="normal" image="icon_menu"/> 49 <state key="normal" image="icon_menu"/>
50 <connections> 50 <connections>
51 <action selector="menuButtonTouchUpInside:" destination="-1" eventType="touchUpInside" id="HrU-er-jwh"/> 51 <action selector="menuButtonTouchUpInside:" destination="-1" eventType="touchUpInside" id="HrU-er-jwh"/>
52 </connections> 52 </connections>
53 </button> 53 </button>
54 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar_default" translatesAutoresizingMaskIntoConstraints="NO" id="J2A-tf-wH0" userLabel="avatar"> 54 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar_default" translatesAutoresizingMaskIntoConstraints="NO" id="J2A-tf-wH0" userLabel="avatar">
55 <rect key="frame" x="8" y="54" width="80" height="80"/> 55 <rect key="frame" x="8" y="54" width="80" height="80"/>
56 <constraints> 56 <constraints>
57 <constraint firstAttribute="width" secondItem="J2A-tf-wH0" secondAttribute="height" multiplier="1:1" id="TVn-eB-Jhs"/> 57 <constraint firstAttribute="width" secondItem="J2A-tf-wH0" secondAttribute="height" multiplier="1:1" id="TVn-eB-Jhs"/>
58 <constraint firstAttribute="width" constant="80" id="YGa-LO-1Mu"/> 58 <constraint firstAttribute="width" constant="80" id="YGa-LO-1Mu"/>
59 </constraints> 59 </constraints>
60 </imageView> 60 </imageView>
61 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_left" translatesAutoresizingMaskIntoConstraints="NO" id="vRa-cr-YTe" userLabel="icon_left"> 61 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_left" translatesAutoresizingMaskIntoConstraints="NO" id="vRa-cr-YTe" userLabel="icon_left">
62 <rect key="frame" x="98" y="79" width="30" height="30"/> 62 <rect key="frame" x="98" y="79" width="30" height="30"/>
63 <constraints> 63 <constraints>
64 <constraint firstAttribute="width" constant="30" id="UZi-wZ-The"/> 64 <constraint firstAttribute="width" constant="30" id="UZi-wZ-The"/>
65 <constraint firstAttribute="width" secondItem="vRa-cr-YTe" secondAttribute="height" multiplier="1:1" id="itE-d2-PsT"/> 65 <constraint firstAttribute="width" secondItem="vRa-cr-YTe" secondAttribute="height" multiplier="1:1" id="itE-d2-PsT"/>
66 </constraints> 66 </constraints>
67 </imageView> 67 </imageView>
68 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="b6V-Bi-4oz" userLabel="ButtonLeft"> 68 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="b6V-Bi-4oz" userLabel="ButtonLeft">
69 <rect key="frame" x="88" y="69" width="50" height="50"/> 69 <rect key="frame" x="88" y="69" width="50" height="50"/>
70 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 70 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
71 <constraints> 71 <constraints>
72 <constraint firstAttribute="width" secondItem="b6V-Bi-4oz" secondAttribute="height" multiplier="1:1" id="GYG-2B-e1R"/> 72 <constraint firstAttribute="width" secondItem="b6V-Bi-4oz" secondAttribute="height" multiplier="1:1" id="GYG-2B-e1R"/>
73 <constraint firstAttribute="width" constant="50" id="bgQ-rD-KZD"/> 73 <constraint firstAttribute="width" constant="50" id="bgQ-rD-KZD"/>
74 </constraints> 74 </constraints>
75 <connections> 75 <connections>
76 <action selector="leftButtonTouchUpInside:" destination="-1" eventType="touchUpInside" id="Bzk-y5-Lre"/> 76 <action selector="leftButtonTouchUpInside:" destination="-1" eventType="touchUpInside" id="Bzk-y5-Lre"/>
77 </connections> 77 </connections>
78 </button> 78 </button>
79 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_right" translatesAutoresizingMaskIntoConstraints="NO" id="Low-8n-pqa" userLabel="icon_right"> 79 <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_right" translatesAutoresizingMaskIntoConstraints="NO" id="Low-8n-pqa" userLabel="icon_right">
80 <rect key="frame" x="335" y="79" width="30" height="30"/> 80 <rect key="frame" x="335" y="79" width="30" height="30"/>
81 <constraints> 81 <constraints>
82 <constraint firstAttribute="width" constant="30" id="jTd-Xb-RdV"/> 82 <constraint firstAttribute="width" constant="30" id="jTd-Xb-RdV"/>
83 <constraint firstAttribute="width" secondItem="Low-8n-pqa" secondAttribute="height" multiplier="1:1" id="pft-kU-wDw"/> 83 <constraint firstAttribute="width" secondItem="Low-8n-pqa" secondAttribute="height" multiplier="1:1" id="pft-kU-wDw"/>
84 </constraints> 84 </constraints>
85 </imageView> 85 </imageView>
86 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="at8-co-gC4" userLabel="ButtonRight"> 86 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="at8-co-gC4" userLabel="ButtonRight">
87 <rect key="frame" x="325" y="69" width="50" height="50"/> 87 <rect key="frame" x="325" y="69" width="50" height="50"/>
88 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 88 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
89 <constraints> 89 <constraints>
90 <constraint firstAttribute="width" constant="50" id="dpm-ie-7c4"/> 90 <constraint firstAttribute="width" constant="50" id="dpm-ie-7c4"/>
91 <constraint firstAttribute="width" secondItem="at8-co-gC4" secondAttribute="height" multiplier="1:1" id="wDO-Tw-aYK"/> 91 <constraint firstAttribute="width" secondItem="at8-co-gC4" secondAttribute="height" multiplier="1:1" id="wDO-Tw-aYK"/>
92 </constraints> 92 </constraints>
93 <connections> 93 <connections>
94 <action selector="rightButtonTouchUpInside:" destination="-1" eventType="touchUpInside" id="0jR-UP-2ia"/> 94 <action selector="rightButtonTouchUpInside:" destination="-1" eventType="touchUpInside" id="0jR-UP-2ia"/>
95 </connections> 95 </connections>
96 </button> 96 </button>
97 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2017年1月1日" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IaR-IO-4RA"> 97 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2017年1月1日" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="IaR-IO-4RA">
98 <rect key="frame" x="136" y="79" width="191" height="30"/> 98 <rect key="frame" x="136" y="79" width="191" height="30"/>
99 <constraints> 99 <constraints>
100 <constraint firstAttribute="height" constant="30" id="MsO-aD-MZ3"/> 100 <constraint firstAttribute="height" constant="30" id="MsO-aD-MZ3"/>
101 </constraints> 101 </constraints>
102 <fontDescription key="fontDescription" type="system" pointSize="22"/> 102 <fontDescription key="fontDescription" type="system" pointSize="22"/>
103 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 103 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
104 <nil key="highlightedColor"/> 104 <nil key="highlightedColor"/>
105 </label> 105 </label>
106 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TUf-Tp-93t" userLabel="valueStep"> 106 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="TUf-Tp-93t" userLabel="valueStep">
107 <rect key="frame" x="20" y="139" width="275" height="40"/> 107 <rect key="frame" x="20" y="139" width="275" height="40"/>
108 <constraints> 108 <constraints>
109 <constraint firstAttribute="height" constant="40" id="6Wd-CK-kPs"/> 109 <constraint firstAttribute="height" constant="40" id="6Wd-CK-kPs"/>
110 </constraints> 110 </constraints>
111 <fontDescription key="fontDescription" type="system" pointSize="45"/> 111 <fontDescription key="fontDescription" type="system" pointSize="45"/>
112 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 112 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
113 <nil key="highlightedColor"/> 113 <nil key="highlightedColor"/>
114 </label> 114 </label>
115 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wfu-aB-xXm" userLabel="unitStep"> 115 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wfu-aB-xXm" userLabel="unitStep">
116 <rect key="frame" x="305" y="149" width="50" height="30"/> 116 <rect key="frame" x="305" y="149" width="50" height="30"/>
117 <constraints> 117 <constraints>
118 <constraint firstAttribute="width" constant="50" id="oQw-JM-dmo"/> 118 <constraint firstAttribute="width" constant="50" id="oQw-JM-dmo"/>
119 <constraint firstAttribute="height" constant="30" id="pV2-7i-dZB"/> 119 <constraint firstAttribute="height" constant="30" id="pV2-7i-dZB"/>
120 </constraints> 120 </constraints>
121 <fontDescription key="fontDescription" type="system" pointSize="25"/> 121 <fontDescription key="fontDescription" type="system" pointSize="25"/>
122 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 122 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
123 <nil key="highlightedColor"/> 123 <nil key="highlightedColor"/>
124 </label> 124 </label>
125 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VAz-hq-dvR"> 125 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="VAz-hq-dvR">
126 <rect key="frame" x="157" y="525" width="60" height="30"/> 126 <rect key="frame" x="157" y="525" width="60" height="30"/>
127 <constraints> 127 <constraints>
128 <constraint firstAttribute="width" constant="60" id="KzL-jP-qZn"/> 128 <constraint firstAttribute="width" constant="60" id="KzL-jP-qZn"/>
129 <constraint firstAttribute="height" constant="30" id="kdw-th-wDS"/> 129 <constraint firstAttribute="height" constant="30" id="kdw-th-wDS"/>
130 </constraints> 130 </constraints>
131 <state key="normal" title="TODAY"> 131 <state key="normal" title="TODAY">
132 <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 132 <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
133 </state> 133 </state>
134 <connections> 134 <connections>
135 <action selector="todayButtonTouchUpInside:" destination="-1" eventType="touchUpInside" id="KoT-el-kxw"/> 135 <action selector="todayButtonTouchUpInside:" destination="-1" eventType="touchUpInside" id="KoT-el-kxw"/>
136 </connections> 136 </connections>
137 </button> 137 </button>
138 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Xj-IB-96h"> 138 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3Xj-IB-96h">
139 <rect key="frame" x="8" y="187" width="359" height="30"/> 139 <rect key="frame" x="8" y="187" width="359" height="30"/>
140 <constraints> 140 <constraints>
141 <constraint firstAttribute="height" constant="30" id="B7Z-yO-b6M"/> 141 <constraint firstAttribute="height" constant="30" id="B7Z-yO-b6M"/>
142 </constraints> 142 </constraints>
143 <fontDescription key="fontDescription" type="system" pointSize="20"/> 143 <fontDescription key="fontDescription" type="system" pointSize="20"/>
144 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 144 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
145 <nil key="highlightedColor"/> 145 <nil key="highlightedColor"/>
146 </label> 146 </label>
147 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DuE-Dh-nEe"> 147 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="DuE-Dh-nEe">
148 <rect key="frame" x="8" y="225" width="359" height="30"/> 148 <rect key="frame" x="8" y="225" width="359" height="30"/>
149 <constraints> 149 <constraints>
150 <constraint firstAttribute="height" constant="30" id="6YJ-rf-mz3"/> 150 <constraint firstAttribute="height" constant="30" id="6YJ-rf-mz3"/>
151 </constraints> 151 </constraints>
152 <fontDescription key="fontDescription" type="system" pointSize="20"/> 152 <fontDescription key="fontDescription" type="system" pointSize="20"/>
153 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 153 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
154 <nil key="highlightedColor"/> 154 <nil key="highlightedColor"/>
155 </label> 155 </label>
156 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="お知らせ" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lnt-4H-Ao8"> 156 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="お知らせ" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lnt-4H-Ao8">
157 <rect key="frame" x="8" y="275" width="359" height="30"/> 157 <rect key="frame" x="8" y="275" width="359" height="30"/>
158 <constraints> 158 <constraints>
159 <constraint firstAttribute="height" constant="30" id="isj-iQ-BcF"/> 159 <constraint firstAttribute="height" constant="30" id="isj-iQ-BcF"/>
160 </constraints> 160 </constraints>
161 <fontDescription key="fontDescription" type="system" pointSize="25"/> 161 <fontDescription key="fontDescription" type="system" pointSize="25"/>
162 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 162 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
163 <nil key="highlightedColor"/> 163 <nil key="highlightedColor"/>
164 </label> 164 </label>
165 <segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="ibb-Yl-iqu"> 165 <segmentedControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="top" segmentControlStyle="plain" selectedSegmentIndex="0" translatesAutoresizingMaskIntoConstraints="NO" id="ibb-Yl-iqu">
166 <rect key="frame" x="75" y="575" width="224" height="29"/> 166 <rect key="frame" x="75" y="575" width="224" height="29"/>
167 <segments> 167 <segments>
168 <segment title="BIKE"/> 168 <segment title="BIKE"/>
169 <segment title="WALKING"/> 169 <segment title="WALKING"/>
170 <segment title="RUNNING"/> 170 <segment title="RUNNING"/>
171 </segments> 171 </segments>
172 <color key="tintColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> 172 <color key="tintColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
173 <connections> 173 <connections>
174 <action selector="segmentValueChange:" destination="-1" eventType="valueChanged" id="kL2-mI-baG"/> 174 <action selector="segmentValueChange:" destination="-1" eventType="valueChanged" id="kL2-mI-baG"/>
175 </connections> 175 </connections>
176 </segmentedControl> 176 </segmentedControl>
177 <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kdD-rj-BtX" userLabel="tvNotice"> 177 <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" editable="NO" textAlignment="natural" selectable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="kdD-rj-BtX" userLabel="tvNotice">
178 <rect key="frame" x="8" y="313" width="359" height="204"/> 178 <rect key="frame" x="8" y="313" width="359" height="204"/>
179 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 179 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
180 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 180 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
181 <fontDescription key="fontDescription" type="system" pointSize="17"/> 181 <fontDescription key="fontDescription" type="system" pointSize="17"/>
182 <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> 182 <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
183 </textView> 183 </textView>
184 </subviews> 184 </subviews>
185 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 185 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
186 <constraints> 186 <constraints>
187 <constraint firstItem="IaR-IO-4RA" firstAttribute="leading" secondItem="vRa-cr-YTe" secondAttribute="trailing" constant="8" id="010-mM-SLU"/> 187 <constraint firstItem="IaR-IO-4RA" firstAttribute="leading" secondItem="vRa-cr-YTe" secondAttribute="trailing" constant="8" id="010-mM-SLU"/>
188 <constraint firstAttribute="trailing" secondItem="Low-8n-pqa" secondAttribute="trailing" constant="10" id="0OY-h0-Rgg"/> 188 <constraint firstAttribute="trailing" secondItem="Low-8n-pqa" secondAttribute="trailing" constant="10" id="0OY-h0-Rgg"/>
189 <constraint firstAttribute="trailing" secondItem="kdD-rj-BtX" secondAttribute="trailing" constant="8" id="3bP-sY-1pI"/> 189 <constraint firstAttribute="trailing" secondItem="kdD-rj-BtX" secondAttribute="trailing" constant="8" id="3bP-sY-1pI"/>
190 <constraint firstItem="u3S-9u-GMZ" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="4TN-aJ-vQh"/> 190 <constraint firstItem="u3S-9u-GMZ" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="4TN-aJ-vQh"/>
191 <constraint firstAttribute="trailing" secondItem="u3S-9u-GMZ" secondAttribute="trailing" id="8KH-Mn-IUf"/> 191 <constraint firstAttribute="trailing" secondItem="u3S-9u-GMZ" secondAttribute="trailing" id="8KH-Mn-IUf"/>
192 <constraint firstItem="DuE-Dh-nEe" firstAttribute="top" secondItem="3Xj-IB-96h" secondAttribute="bottom" constant="8" id="9h2-XH-Dd7"/> 192 <constraint firstItem="DuE-Dh-nEe" firstAttribute="top" secondItem="3Xj-IB-96h" secondAttribute="bottom" constant="8" id="9h2-XH-Dd7"/>
193 <constraint firstItem="kdD-rj-BtX" firstAttribute="top" secondItem="lnt-4H-Ao8" secondAttribute="bottom" constant="8" id="BCi-jo-C0A"/> 193 <constraint firstItem="kdD-rj-BtX" firstAttribute="top" secondItem="lnt-4H-Ao8" secondAttribute="bottom" constant="8" id="BCi-jo-C0A"/>
194 <constraint firstAttribute="trailing" secondItem="LPY-Zl-cOp" secondAttribute="trailing" constant="10" id="CX3-BL-hNh"/> 194 <constraint firstAttribute="trailing" secondItem="LPY-Zl-cOp" secondAttribute="trailing" constant="10" id="CX3-BL-hNh"/>
195 <constraint firstItem="vRa-cr-YTe" firstAttribute="leading" secondItem="J2A-tf-wH0" secondAttribute="trailing" constant="10" id="Cax-pu-Kp7"/> 195 <constraint firstItem="vRa-cr-YTe" firstAttribute="leading" secondItem="J2A-tf-wH0" secondAttribute="trailing" constant="10" id="Cax-pu-Kp7"/>
196 <constraint firstItem="3Xj-IB-96h" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="E8R-qO-PtJ"/> 196 <constraint firstItem="3Xj-IB-96h" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="E8R-qO-PtJ"/>
197 <constraint firstItem="b6V-Bi-4oz" firstAttribute="centerX" secondItem="vRa-cr-YTe" secondAttribute="centerX" id="EEt-Ct-vxb"/> 197 <constraint firstItem="b6V-Bi-4oz" firstAttribute="centerX" secondItem="vRa-cr-YTe" secondAttribute="centerX" id="EEt-Ct-vxb"/>
198 <constraint firstItem="u3S-9u-GMZ" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" placeholder="YES" id="GbN-me-UEd"/> 198 <constraint firstItem="u3S-9u-GMZ" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" placeholder="YES" id="GbN-me-UEd"/>
199 <constraint firstItem="b6V-Bi-4oz" firstAttribute="centerY" secondItem="vRa-cr-YTe" secondAttribute="centerY" id="HXS-oH-EPB"/> 199 <constraint firstItem="b6V-Bi-4oz" firstAttribute="centerY" secondItem="vRa-cr-YTe" secondAttribute="centerY" id="HXS-oH-EPB"/>
200 <constraint firstItem="vRa-cr-YTe" firstAttribute="centerY" secondItem="J2A-tf-wH0" secondAttribute="centerY" id="IDF-HZ-fqt"/> 200 <constraint firstItem="vRa-cr-YTe" firstAttribute="centerY" secondItem="J2A-tf-wH0" secondAttribute="centerY" id="IDF-HZ-fqt"/>
201 <constraint firstAttribute="trailing" secondItem="lnt-4H-Ao8" secondAttribute="trailing" constant="8" id="IEA-1V-AZx"/> 201 <constraint firstAttribute="trailing" secondItem="lnt-4H-Ao8" secondAttribute="trailing" constant="8" id="IEA-1V-AZx"/>
202 <constraint firstItem="ibb-Yl-iqu" firstAttribute="top" secondItem="VAz-hq-dvR" secondAttribute="bottom" constant="20" id="Ib2-KY-3A7"/> 202 <constraint firstItem="ibb-Yl-iqu" firstAttribute="top" secondItem="VAz-hq-dvR" secondAttribute="bottom" constant="20" id="Ib2-KY-3A7"/>
203 <constraint firstAttribute="bottom" secondItem="ibb-Yl-iqu" secondAttribute="bottom" constant="64" id="Iv8-Al-1Ff"/> 203 <constraint firstAttribute="bottom" secondItem="ibb-Yl-iqu" secondAttribute="bottom" constant="64" placeholder="YES" id="Iv8-Al-1Ff"/>
204 <constraint firstItem="DuE-Dh-nEe" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="Rum-yc-3Ym"/> 204 <constraint firstItem="DuE-Dh-nEe" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="Rum-yc-3Ym"/>
205 <constraint firstItem="Low-8n-pqa" firstAttribute="centerY" secondItem="J2A-tf-wH0" secondAttribute="centerY" id="W7b-Hb-9ME"/> 205 <constraint firstItem="Low-8n-pqa" firstAttribute="centerY" secondItem="J2A-tf-wH0" secondAttribute="centerY" id="W7b-Hb-9ME"/>
206 <constraint firstItem="IaR-IO-4RA" firstAttribute="centerY" secondItem="J2A-tf-wH0" secondAttribute="centerY" id="b4I-Me-4xZ"/> 206 <constraint firstItem="IaR-IO-4RA" firstAttribute="centerY" secondItem="J2A-tf-wH0" secondAttribute="centerY" id="b4I-Me-4xZ"/>
207 <constraint firstItem="wfu-aB-xXm" firstAttribute="top" secondItem="IaR-IO-4RA" secondAttribute="bottom" constant="40" id="bH1-l5-YRA"/> 207 <constraint firstItem="wfu-aB-xXm" firstAttribute="top" secondItem="IaR-IO-4RA" secondAttribute="bottom" constant="40" id="bH1-l5-YRA"/>
208 <constraint firstItem="lnt-4H-Ao8" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="ea3-Dx-s4s"/> 208 <constraint firstItem="lnt-4H-Ao8" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="ea3-Dx-s4s"/>
209 <constraint firstItem="at8-co-gC4" firstAttribute="centerX" secondItem="Low-8n-pqa" secondAttribute="centerX" id="h5o-Cj-Z7s"/> 209 <constraint firstItem="at8-co-gC4" firstAttribute="centerX" secondItem="Low-8n-pqa" secondAttribute="centerX" id="h5o-Cj-Z7s"/>
210 <constraint firstAttribute="trailing" secondItem="DuE-Dh-nEe" secondAttribute="trailing" constant="8" id="iyi-TY-Wfe"/> 210 <constraint firstAttribute="trailing" secondItem="DuE-Dh-nEe" secondAttribute="trailing" constant="8" id="iyi-TY-Wfe"/>
211 <constraint firstItem="LPY-Zl-cOp" firstAttribute="centerY" secondItem="u3S-9u-GMZ" secondAttribute="centerY" id="jBf-Ck-YYj"/> 211 <constraint firstItem="LPY-Zl-cOp" firstAttribute="centerY" secondItem="u3S-9u-GMZ" secondAttribute="centerY" id="jBf-Ck-YYj"/>
212 <constraint firstItem="TUf-Tp-93t" firstAttribute="centerY" secondItem="wfu-aB-xXm" secondAttribute="centerY" constant="-5" id="k3n-lY-8K1"/> 212 <constraint firstItem="TUf-Tp-93t" firstAttribute="centerY" secondItem="wfu-aB-xXm" secondAttribute="centerY" constant="-5" id="k3n-lY-8K1"/>
213 <constraint firstItem="J2A-tf-wH0" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="mVQ-bZ-JBW"/> 213 <constraint firstItem="J2A-tf-wH0" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="mVQ-bZ-JBW"/>
214 <constraint firstAttribute="trailing" secondItem="wfu-aB-xXm" secondAttribute="trailing" constant="20" id="mtA-2Q-ssH"/> 214 <constraint firstAttribute="trailing" secondItem="wfu-aB-xXm" secondAttribute="trailing" constant="20" id="mtA-2Q-ssH"/>
215 <constraint firstItem="ibb-Yl-iqu" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="nOT-Ic-JU1"/> 215 <constraint firstItem="ibb-Yl-iqu" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="nOT-Ic-JU1"/>
216 <constraint firstItem="J2A-tf-wH0" firstAttribute="top" secondItem="u3S-9u-GMZ" secondAttribute="bottom" constant="10" id="nu9-Lj-5xz"/> 216 <constraint firstItem="J2A-tf-wH0" firstAttribute="top" secondItem="u3S-9u-GMZ" secondAttribute="bottom" constant="10" id="nu9-Lj-5xz"/>
217 <constraint firstAttribute="trailing" secondItem="3Xj-IB-96h" secondAttribute="trailing" constant="8" id="pF6-db-UUi"/> 217 <constraint firstAttribute="trailing" secondItem="3Xj-IB-96h" secondAttribute="trailing" constant="8" id="pF6-db-UUi"/>
218 <constraint firstItem="3Xj-IB-96h" firstAttribute="top" secondItem="wfu-aB-xXm" secondAttribute="bottom" constant="8" id="psY-0r-fPJ"/> 218 <constraint firstItem="3Xj-IB-96h" firstAttribute="top" secondItem="wfu-aB-xXm" secondAttribute="bottom" constant="8" id="psY-0r-fPJ"/>
219 <constraint firstItem="kdD-rj-BtX" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="q4Z-No-KmH"/> 219 <constraint firstItem="kdD-rj-BtX" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="8" id="q4Z-No-KmH"/>
220 <constraint firstItem="TUf-Tp-93t" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="20" id="sC4-Kr-3bN"/> 220 <constraint firstItem="TUf-Tp-93t" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="20" id="sC4-Kr-3bN"/>
221 <constraint firstItem="at8-co-gC4" firstAttribute="centerY" secondItem="Low-8n-pqa" secondAttribute="centerY" id="tav-ge-tCT"/> 221 <constraint firstItem="at8-co-gC4" firstAttribute="centerY" secondItem="Low-8n-pqa" secondAttribute="centerY" id="tav-ge-tCT"/>
222 <constraint firstItem="VAz-hq-dvR" firstAttribute="top" secondItem="kdD-rj-BtX" secondAttribute="bottom" constant="8" id="ujL-1z-cUf"/> 222 <constraint firstItem="VAz-hq-dvR" firstAttribute="top" secondItem="kdD-rj-BtX" secondAttribute="bottom" constant="8" id="ujL-1z-cUf"/>
223 <constraint firstItem="lnt-4H-Ao8" firstAttribute="top" secondItem="DuE-Dh-nEe" secondAttribute="bottom" constant="20" id="w4w-Z4-Jzk"/> 223 <constraint firstItem="lnt-4H-Ao8" firstAttribute="top" secondItem="DuE-Dh-nEe" secondAttribute="bottom" constant="20" id="w4w-Z4-Jzk"/>
224 <constraint firstItem="wfu-aB-xXm" firstAttribute="leading" secondItem="TUf-Tp-93t" secondAttribute="trailing" constant="10" id="x51-DA-4Le"/> 224 <constraint firstItem="wfu-aB-xXm" firstAttribute="leading" secondItem="TUf-Tp-93t" secondAttribute="trailing" constant="10" id="x51-DA-4Le"/>
225 <constraint firstItem="VAz-hq-dvR" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="xE7-ro-k8m"/> 225 <constraint firstItem="VAz-hq-dvR" firstAttribute="centerX" secondItem="i5M-Pr-FkT" secondAttribute="centerX" id="xE7-ro-k8m"/>
226 <constraint firstItem="Low-8n-pqa" firstAttribute="leading" secondItem="IaR-IO-4RA" secondAttribute="trailing" constant="8" id="y6e-6A-hjn"/> 226 <constraint firstItem="Low-8n-pqa" firstAttribute="leading" secondItem="IaR-IO-4RA" secondAttribute="trailing" constant="8" id="y6e-6A-hjn"/>
227 </constraints> 227 </constraints>
228 <point key="canvasLocation" x="33.5" y="97.5"/> 228 <point key="canvasLocation" x="33.5" y="97.5"/>
229 </view> 229 </view>
230 </objects> 230 </objects>
231 <resources> 231 <resources>
232 <image name="avatar_default" width="80" height="80"/> 232 <image name="avatar_default" width="80" height="80"/>
233 <image name="icon_left" width="30" height="30"/> 233 <image name="icon_left" width="30" height="30"/>
234 <image name="icon_menu" width="30" height="30"/> 234 <image name="icon_menu" width="30" height="30"/>
235 <image name="icon_right" width="30" height="30"/> 235 <image name="icon_right" width="30" height="30"/>
236 </resources> 236 </resources>
237 </document> 237 </document>
238 238
LifeLog/LifeLog/Info.plist
1 <?xml version="1.0" encoding="UTF-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"> 2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0"> 3 <plist version="1.0">
4 <dict> 4 <dict>
5 <key>CFBundleDevelopmentRegion</key> 5 <key>CFBundleDevelopmentRegion</key>
6 <string>en</string> 6 <string>en</string>
7 <key>CFBundleDisplayName</key> 7 <key>CFBundleDisplayName</key>
8 <string>LIFE_LOG</string> 8 <string>LIFE_LOG</string>
9 <key>CFBundleExecutable</key> 9 <key>CFBundleExecutable</key>
10 <string>$(EXECUTABLE_NAME)</string> 10 <string>$(EXECUTABLE_NAME)</string>
11 <key>CFBundleIdentifier</key> 11 <key>CFBundleIdentifier</key>
12 <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> 12 <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13 <key>CFBundleInfoDictionaryVersion</key> 13 <key>CFBundleInfoDictionaryVersion</key>
14 <string>6.0</string> 14 <string>6.0</string>
15 <key>CFBundleName</key> 15 <key>CFBundleName</key>
16 <string>$(PRODUCT_NAME)</string> 16 <string>$(PRODUCT_NAME)</string>
17 <key>CFBundlePackageType</key> 17 <key>CFBundlePackageType</key>
18 <string>APPL</string> 18 <string>APPL</string>
19 <key>CFBundleShortVersionString</key> 19 <key>CFBundleShortVersionString</key>
20 <string>1.0</string> 20 <string>1.0</string>
21 <key>CFBundleURLTypes</key> 21 <key>CFBundleURLTypes</key>
22 <array> 22 <array>
23 <dict/> 23 <dict/>
24 </array> 24 </array>
25 <key>CFBundleVersion</key> 25 <key>CFBundleVersion</key>
26 <string>5</string> 26 <string>7</string>
27 <key>LSApplicationQueriesSchemes</key> 27 <key>LSApplicationQueriesSchemes</key>
28 <array> 28 <array>
29 <string>line</string> 29 <string>line</string>
30 </array> 30 </array>
31 <key>LSRequiresIPhoneOS</key> 31 <key>LSRequiresIPhoneOS</key>
32 <true/> 32 <true/>
33 <key>NSAppTransportSecurity</key> 33 <key>NSAppTransportSecurity</key>
34 <dict> 34 <dict>
35 <key>NSAllowsArbitraryLoads</key> 35 <key>NSAllowsArbitraryLoads</key>
36 <true/> 36 <true/>
37 </dict> 37 </dict>
38 <key>NSCameraUsageDescription</key> 38 <key>NSCameraUsageDescription</key>
39 <string>to take photos and video</string> 39 <string>to take photos and video</string>
40 <key>NSLocationAlwaysUsageDescription</key> 40 <key>NSLocationAlwaysUsageDescription</key>
41 <string>This application requires location services to work</string> 41 <string>This application requires location services to work</string>
42 <key>NSLocationWhenInUseUsageDescription</key> 42 <key>NSLocationWhenInUseUsageDescription</key>
43 <string>This application requires location services to work</string> 43 <string>This application requires location services to work</string>
44 <key>NSMotionUsageDescription</key> 44 <key>NSMotionUsageDescription</key>
45 <string>$(PRODUCT_NAME) motion use</string> 45 <string>$(PRODUCT_NAME) motion use</string>
46 <key>NSPhotoLibraryUsageDescription</key> 46 <key>NSPhotoLibraryUsageDescription</key>
47 <string>to save photos and videos</string> 47 <string>to save photos and videos</string>
48 <key>UILaunchStoryboardName</key> 48 <key>UILaunchStoryboardName</key>
49 <string>LaunchScreen</string> 49 <string>LaunchScreen</string>
50 <key>UIRequiredDeviceCapabilities</key> 50 <key>UIRequiredDeviceCapabilities</key>
51 <array> 51 <array>
52 <string>armv7</string> 52 <string>armv7</string>
53 </array> 53 </array>
54 <key>UIStatusBarHidden</key> 54 <key>UIStatusBarHidden</key>
55 <true/> 55 <true/>
56 <key>UISupportedInterfaceOrientations</key> 56 <key>UISupportedInterfaceOrientations</key>
57 <array> 57 <array>
58 <string>UIInterfaceOrientationPortrait</string> 58 <string>UIInterfaceOrientationPortrait</string>
59 </array> 59 </array>
60 <key>UISupportedInterfaceOrientations~ipad</key> 60 <key>UISupportedInterfaceOrientations~ipad</key>
61 <array> 61 <array>
62 <string>UIInterfaceOrientationPortrait</string> 62 <string>UIInterfaceOrientationPortrait</string>
63 <string>UIInterfaceOrientationPortraitUpsideDown</string> 63 <string>UIInterfaceOrientationPortraitUpsideDown</string>
64 <string>UIInterfaceOrientationLandscapeLeft</string> 64 <string>UIInterfaceOrientationLandscapeLeft</string>
65 <string>UIInterfaceOrientationLandscapeRight</string> 65 <string>UIInterfaceOrientationLandscapeRight</string>
66 </array> 66 </array>
67 <key>UIViewControllerBasedStatusBarAppearance</key> 67 <key>UIViewControllerBasedStatusBarAppearance</key>
68 <false/> 68 <false/>
69 </dict> 69 </dict>
70 </plist> 70 </plist>
71 71
LifeLog/LifeLog/MapViewController.m
1 // 1 //
2 // MapViewController.m 2 // MapViewController.m
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by Nguyen Van Phong on 7/25/17. 5 // Created by Nguyen Van Phong on 7/25/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import "MapViewController.h" 9 #import "MapViewController.h"
10 #import <MapKit/MapKit.h> 10 #import <MapKit/MapKit.h>
11 #import<CoreLocation/CoreLocation.h> 11 #import<CoreLocation/CoreLocation.h>
12 #import <CoreMotion/CoreMotion.h> 12 #import <CoreMotion/CoreMotion.h>
13 #import "NSDate+helper.h" 13 #import "NSDate+helper.h"
14 #import "Utilities.h" 14 #import "Utilities.h"
15 15
16 @interface MapViewController ()<CLLocationManagerDelegate, MKMapViewDelegate> 16 @interface MapViewController ()<CLLocationManagerDelegate, MKMapViewDelegate>
17 { 17 {
18 CLGeocoder *geocoder; 18 CLGeocoder *geocoder;
19 CLPlacemark *placemark; 19 CLPlacemark *placemark;
20 CLLocation *previousLocation; 20 CLLocation *previousLocation;
21 } 21 }
22 @property (weak, nonatomic) IBOutlet MKMapView *mapView; 22 @property (weak, nonatomic) IBOutlet MKMapView *mapView;
23 @property (weak, nonatomic) IBOutlet UILabel *lblTime; 23 @property (weak, nonatomic) IBOutlet UILabel *lblTime;
24 @property (weak, nonatomic) IBOutlet UISlider *slider; 24 @property (weak, nonatomic) IBOutlet UISlider *slider;
25 25
26 @property (nonatomic, weak) IBOutlet UILabel *lblValueStep; 26 @property (nonatomic, weak) IBOutlet UILabel *lblValueStep;
27 @property (nonatomic, weak) IBOutlet UILabel *lblUnitStep; 27 @property (nonatomic, weak) IBOutlet UILabel *lblUnitStep;
28 @property (weak, nonatomic) IBOutlet UIView *viewOther;
28 29
29 @property (strong, nonatomic) CLLocationManager *locationManager; 30 @property (strong, nonatomic) CLLocationManager *locationManager;
30 31
31 @property (nonatomic, strong) CMPedometer *pedometer; 32 @property (nonatomic, strong) CMPedometer *pedometer;
32 @property (nonatomic, strong) CMMotionActivityManager *motionActivityManager; 33 @property (nonatomic, strong) CMMotionActivityManager *motionActivityManager;
33 @property (nonatomic, strong) NSOperationQueue *operationQueue; 34 @property (nonatomic, strong) NSOperationQueue *operationQueue;
34 @property (nonatomic, strong) NSTimer *timer; 35 @property (nonatomic, strong) NSTimer *timer;
35 @property (nonatomic) int countTime; 36 @property (nonatomic) int countTime;
36 @property (nonatomic, assign) BOOL isRequesting; 37 @property (nonatomic, assign) BOOL isRequesting;
37 @end 38 @end
38 39
39 @implementation MapViewController 40 @implementation MapViewController
40 41
41 - (void)viewDidLoad { 42 - (void)viewDidLoad {
42 [super viewDidLoad]; 43 [super viewDidLoad];
43 // Do any additional setup after loading the view from its nib. 44 // Do any additional setup after loading the view from its nib.
44 self.title = NSLocalizedString(@"lifelog.tapbar.map", nil); 45 self.title = NSLocalizedString(@"lifelog.tapbar.map", nil);
45 [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.mapView attribute:NSLayoutAttributeTop multiplier:1 constant:0]]; 46 [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.topLayoutGuide attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.mapView attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
47 [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.bottomLayoutGuide attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.mapView attribute:NSLayoutAttributeBottom multiplier:1 constant:44]];
46 geocoder = [[CLGeocoder alloc] init]; 48 geocoder = [[CLGeocoder alloc] init];
47 [self setupLocation]; 49 [self setupLocation];
48 [self setupMapView]; 50 [self setupMapView];
49 previousLocation = nil; 51 previousLocation = nil;
50 52
51 if ([CMPedometer isStepCountingAvailable]) { 53 if ([CMPedometer isStepCountingAvailable]) {
52 _pedometer = [[CMPedometer alloc] init]; 54 _pedometer = [[CMPedometer alloc] init];
53 } 55 }
54 if ([CMMotionActivityManager isActivityAvailable]) { 56 if ([CMMotionActivityManager isActivityAvailable]) {
55 _motionActivityManager = [[CMMotionActivityManager alloc] init]; 57 _motionActivityManager = [[CMMotionActivityManager alloc] init];
56 } 58 }
57 self.isRequesting = NO; 59 self.isRequesting = NO;
58 _countTime = 0; 60 _countTime = 0;
59 self.lblUnitStep.text = NSLocalizedString(@"lifelog.home.unit.step", nil); 61 self.lblUnitStep.text = NSLocalizedString(@"lifelog.home.unit.step", nil);
60 } 62 }
61 63
62 - (void)didReceiveMemoryWarning { 64 - (void)didReceiveMemoryWarning {
63 [super didReceiveMemoryWarning]; 65 [super didReceiveMemoryWarning];
64 // Dispose of any resources that can be recreated. 66 // Dispose of any resources that can be recreated.
65 } 67 }
66 68
67 - (void)viewWillAppear:(BOOL)animated { 69 - (void)viewWillAppear:(BOOL)animated {
68 [super viewWillAppear:animated]; 70 [super viewWillAppear:animated];
69 _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(countStep) userInfo:nil repeats:YES]; 71 _timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(countStep) userInfo:nil repeats:YES];
70 [_timer fire]; 72 [_timer fire];
71 } 73 }
72 74
73 //- (void)viewWillDisappear:(BOOL)animated { 75 //- (void)viewWillDisappear:(BOOL)animated {
74 // [super viewWillDisappear:animated]; 76 // [super viewWillDisappear:animated];
75 // [_timer invalidate]; 77 // [_timer invalidate];
76 //} 78 //}
77 79
78 #pragma mark - CLLocationManagerDelegate 80 #pragma mark - CLLocationManagerDelegate
79 -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations { 81 -(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
80 82
81 CLLocation *newLocation = [locations lastObject]; 83 CLLocation *newLocation = [locations lastObject];
82 if (previousLocation == nil) { 84 if (previousLocation == nil) {
83 [self addAnnotationsOnMap:newLocation]; 85 [self addAnnotationsOnMap:newLocation];
84 } 86 }
85 else { 87 else {
86 CLLocationCoordinate2D area[2]; 88 CLLocationCoordinate2D area[2];
87 area[0] = previousLocation.coordinate; 89 area[0] = previousLocation.coordinate;
88 area[1] = newLocation.coordinate; 90 area[1] = newLocation.coordinate;
89 MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:area count:2]; 91 MKPolyline *polyLine = [MKPolyline polylineWithCoordinates:area count:2];
90 [_mapView addOverlay:polyLine]; 92 [_mapView addOverlay:polyLine];
91 } 93 }
92 94
93 previousLocation = newLocation; 95 previousLocation = newLocation;
94 } 96 }
95 97
96 - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 98 - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
97 { 99 {
98 NSLog(@"Cannot find the location."); 100 NSLog(@"Cannot find the location.");
99 } 101 }
100 102
101 #pragma mark - MKMapViewDelegate 103 #pragma mark - MKMapViewDelegate
102 - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay 104 - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id <MKOverlay>)overlay
103 { 105 {
104 if ([overlay isKindOfClass:[MKPolyline class]]) { 106 if ([overlay isKindOfClass:[MKPolyline class]]) {
105 MKPolylineRenderer *pr = [[MKPolylineRenderer alloc] initWithOverlay:overlay]; 107 MKPolylineRenderer *pr = [[MKPolylineRenderer alloc] initWithOverlay:overlay];
106 pr.strokeColor = [UIColor redColor]; 108 pr.strokeColor = [UIColor redColor];
107 pr.lineWidth = 5; 109 pr.lineWidth = 5;
108 return pr; 110 return pr;
109 } 111 }
110 return nil; 112 return nil;
111 } 113 }
112 114
113 #pragma mark - Functions Private 115 #pragma mark - Functions Private
114 116
115 - (void)addAnnotationsOnMap:(CLLocation *)locationToPoint { 117 - (void)addAnnotationsOnMap:(CLLocation *)locationToPoint {
116 MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init]; 118 MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
117 annotation.coordinate = locationToPoint.coordinate; 119 annotation.coordinate = locationToPoint.coordinate;
118 [geocoder reverseGeocodeLocation:locationToPoint completionHandler:^(NSArray *placemarks, NSError *error) { 120 [geocoder reverseGeocodeLocation:locationToPoint completionHandler:^(NSArray *placemarks, NSError *error) {
119 if (error == nil && [placemarks count] >0) { 121 if (error == nil && [placemarks count] >0) {
120 placemark = [placemarks firstObject]; 122 placemark = [placemarks firstObject];
121 NSDictionary *addressDict = placemark.addressDictionary; 123 NSDictionary *addressDict = placemark.addressDictionary;
122 annotation.title = [NSString stringWithFormat:@"%@", addressDict[@"Name"]]; 124 annotation.title = [NSString stringWithFormat:@"%@", addressDict[@"Name"]];
123 [_mapView addAnnotation:annotation]; 125 [_mapView addAnnotation:annotation];
124 } 126 }
125 }]; 127 }];
126 } 128 }
127 129
128 - (void)setupLocation { 130 - (void)setupLocation {
129 _locationManager = [[CLLocationManager alloc] init]; 131 _locationManager = [[CLLocationManager alloc] init];
130 _locationManager.desiredAccuracy = kCLLocationAccuracyBest; 132 _locationManager.desiredAccuracy = kCLLocationAccuracyBest;
131 _locationManager.delegate = self; 133 _locationManager.delegate = self;
132 CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; 134 CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
133 if (status == kCLAuthorizationStatusNotDetermined || status == kCLAuthorizationStatusDenied || status == kCLAuthorizationStatusAuthorizedWhenInUse) { 135 if (status == kCLAuthorizationStatusNotDetermined || status == kCLAuthorizationStatusDenied || status == kCLAuthorizationStatusAuthorizedWhenInUse) {
134 [_locationManager requestWhenInUseAuthorization]; 136 [_locationManager requestWhenInUseAuthorization];
135 [_locationManager requestAlwaysAuthorization]; 137 [_locationManager requestAlwaysAuthorization];
136 } 138 }
137 [_locationManager startUpdatingLocation]; 139 [_locationManager startUpdatingLocation];
138 [_locationManager startUpdatingHeading]; 140 [_locationManager startUpdatingHeading];
139 } 141 }
140 142
141 - (void)setupMapView { 143 - (void)setupMapView {
142 _mapView.delegate = self; 144 _mapView.delegate = self;
143 _mapView.showsUserLocation = YES; 145 _mapView.showsUserLocation = YES;
144 _mapView.mapType = MKMapTypeStandard; 146 _mapView.mapType = MKMapTypeStandard;
145 _mapView.userTrackingMode = MKUserTrackingModeFollowWithHeading; 147 _mapView.userTrackingMode = MKUserTrackingModeFollowWithHeading;
146 } 148 }
147 149
148 #pragma mark - Functions Private 150 #pragma mark - Functions Private
149 - (void)countStep 151 - (void)countStep
150 { 152 {
151 _countTime++; 153 _countTime++;
152 _lblTime.text = [self convertTime:_countTime]; 154 _lblTime.text = [self convertTime:_countTime];
153 _slider.value = _countTime; 155 _slider.value = _countTime;
154 if (self.isRequesting == YES) { 156 if (self.isRequesting == YES) {
155 return; 157 return;
156 } 158 }
157 if ([CMMotionActivityManager isActivityAvailable]) { 159 if ([CMMotionActivityManager isActivityAvailable]) {
158 self.isRequesting = YES; 160 self.isRequesting = YES;
159 NSDate *endDate = [NSDate date]; 161 NSDate *endDate = [NSDate date];
160 NSDate *startDate = [endDate beginningAtMidnightOfDay]; 162 NSDate *startDate = [endDate beginningAtMidnightOfDay];
161 MapViewController __weak *weakSelf = self; 163 MapViewController __weak *weakSelf = self;
162 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog", NULL); 164 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog", NULL);
163 dispatch_async(myQueue, ^{ 165 dispatch_async(myQueue, ^{
164 if (weakSelf == nil) { 166 if (weakSelf == nil) {
165 return ; 167 return ;
166 } 168 }
167 [weakSelf.pedometer queryPedometerDataFromDate:startDate toDate:endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) { 169 [weakSelf.pedometer queryPedometerDataFromDate:startDate toDate:endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) {
168 NSInteger numberStep = [pedometerData.numberOfSteps integerValue]; 170 NSInteger numberStep = [pedometerData.numberOfSteps integerValue];
169 dispatch_async(dispatch_get_main_queue(), ^{ 171 dispatch_async(dispatch_get_main_queue(), ^{
170 [weakSelf updateStepUI:numberStep]; 172 [weakSelf updateStepUI:numberStep];
171 }); 173 });
172 }]; 174 }];
173 }); 175 });
174 } 176 }
175 } 177 }
176 178
177 - (NSString *)convertTime:(int)time 179 - (NSString *)convertTime:(int)time
178 { 180 {
179 NSString *result = @""; 181 NSString *result = @"";
180 int hour = time/3600; 182 int hour = time/3600;
181 int minute = time/60; 183 int minute = time/60;
182 int second = time % 60; 184 int second = time % 60;
183 result = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, minute, second]; 185 result = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, minute, second];
184 return result; 186 return result;
185 } 187 }
186 188
187 - (void)updateStepUI:(NSInteger)numberStep 189 - (void)updateStepUI:(NSInteger)numberStep
188 { 190 {
189 // NSLog(@"Number of step: %ld", numberStep); 191 // NSLog(@"Number of step: %ld", numberStep);
190 self.isRequesting = NO; 192 self.isRequesting = NO;
191 self.lblValueStep.text = [Utilities addCommaFromNumber:numberStep]; 193 self.lblValueStep.text = [Utilities addCommaFromNumber:numberStep];
192 } 194 }
193 195
194 @end 196 @end
195 197
LifeLog/LifeLog/MapViewController.xib
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16G29" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> 2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3 <device id="retina4_7" orientation="portrait"> 3 <device id="retina4_7" orientation="portrait">
4 <adaptation id="fullscreen"/> 4 <adaptation id="fullscreen"/>
5 </device> 5 </device>
6 <dependencies> 6 <dependencies>
7 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/> 7 <deployment identifier="iOS"/>
8 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
8 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> 9 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9 </dependencies> 10 </dependencies>
10 <objects> 11 <objects>
11 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MapViewController"> 12 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MapViewController">
12 <connections> 13 <connections>
13 <outlet property="lblTime" destination="EMF-vR-v3k" id="nRs-ga-YjW"/> 14 <outlet property="lblTime" destination="EMF-vR-v3k" id="nRs-ga-YjW"/>
14 <outlet property="lblUnitStep" destination="bSt-HN-qcq" id="opK-5F-PG8"/> 15 <outlet property="lblUnitStep" destination="bSt-HN-qcq" id="opK-5F-PG8"/>
15 <outlet property="lblValueStep" destination="qLg-XF-Dyf" id="lvl-yi-U7d"/> 16 <outlet property="lblValueStep" destination="qLg-XF-Dyf" id="lvl-yi-U7d"/>
16 <outlet property="mapView" destination="GCl-mf-CD8" id="SpU-ML-EIf"/> 17 <outlet property="mapView" destination="GCl-mf-CD8" id="SpU-ML-EIf"/>
17 <outlet property="slider" destination="79Q-XB-cW2" id="NXm-rp-Ycy"/> 18 <outlet property="slider" destination="79Q-XB-cW2" id="NXm-rp-Ycy"/>
18 <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> 19 <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
20 <outlet property="viewOther" destination="ayh-Y4-2QM" id="rpM-WE-7du"/>
19 </connections> 21 </connections>
20 </placeholder> 22 </placeholder>
21 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> 23 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
22 <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> 24 <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
23 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> 25 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
24 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 26 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
25 <subviews> 27 <subviews>
26 <mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="GCl-mf-CD8"> 28 <mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="GCl-mf-CD8">
27 <rect key="frame" x="0.0" y="0.0" width="375" height="579"/> 29 <rect key="frame" x="0.0" y="0.0" width="375" height="579"/>
28 <connections> 30 <connections>
29 <outlet property="delegate" destination="-1" id="fjQ-MR-pO8"/> 31 <outlet property="delegate" destination="-1" id="fjQ-MR-pO8"/>
30 </connections> 32 </connections>
31 </mapView> 33 </mapView>
32 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qLg-XF-Dyf" userLabel="valueStep"> 34 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qLg-XF-Dyf" userLabel="valueStep">
33 <rect key="frame" x="20" y="531" width="275" height="40"/> 35 <rect key="frame" x="20" y="531" width="275" height="40"/>
34 <constraints> 36 <constraints>
35 <constraint firstAttribute="height" constant="40" id="uDh-v6-rG3"/> 37 <constraint firstAttribute="height" constant="40" id="uDh-v6-rG3"/>
36 </constraints> 38 </constraints>
37 <fontDescription key="fontDescription" type="system" pointSize="45"/> 39 <fontDescription key="fontDescription" type="system" pointSize="45"/>
38 <color key="textColor" red="0.047200520830000002" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> 40 <color key="textColor" red="0.047200520830000002" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
39 <nil key="highlightedColor"/> 41 <nil key="highlightedColor"/>
40 </label> 42 </label>
41 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bSt-HN-qcq" userLabel="unitStep"> 43 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="step" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bSt-HN-qcq" userLabel="unitStep">
42 <rect key="frame" x="305" y="541" width="50" height="30"/> 44 <rect key="frame" x="305" y="541" width="50" height="30"/>
43 <constraints> 45 <constraints>
44 <constraint firstAttribute="height" constant="30" id="CNj-tm-yOG"/> 46 <constraint firstAttribute="height" constant="30" id="CNj-tm-yOG"/>
45 <constraint firstAttribute="width" constant="50" id="fac-mE-Hfh"/> 47 <constraint firstAttribute="width" constant="50" id="fac-mE-Hfh"/>
46 </constraints> 48 </constraints>
47 <fontDescription key="fontDescription" type="system" pointSize="25"/> 49 <fontDescription key="fontDescription" type="system" pointSize="25"/>
48 <color key="textColor" red="0.047200520830000002" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> 50 <color key="textColor" red="0.047200520830000002" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
49 <nil key="highlightedColor"/> 51 <nil key="highlightedColor"/>
50 </label> 52 </label>
51 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ayh-Y4-2QM" userLabel="ViewOther"> 53 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ayh-Y4-2QM" userLabel="ViewOther">
52 <rect key="frame" x="0.0" y="579" width="375" height="44"/> 54 <rect key="frame" x="0.0" y="579" width="375" height="44"/>
53 <subviews> 55 <subviews>
54 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TIME LINE" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ibI-Db-Rc6"> 56 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="TIME LINE" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ibI-Db-Rc6">
55 <rect key="frame" x="8" y="0.0" width="90" height="44"/> 57 <rect key="frame" x="8" y="0.0" width="90" height="44"/>
56 <constraints> 58 <constraints>
57 <constraint firstAttribute="width" constant="90" id="Lof-Td-i7Y"/> 59 <constraint firstAttribute="width" constant="90" id="Lof-Td-i7Y"/>
58 </constraints> 60 </constraints>
59 <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/> 61 <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
60 <nil key="textColor"/> 62 <nil key="textColor"/>
61 <nil key="highlightedColor"/> 63 <nil key="highlightedColor"/>
62 </label> 64 </label>
63 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="12:05:01" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EMF-vR-v3k"> 65 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="12:05:01" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EMF-vR-v3k">
64 <rect key="frame" x="106" y="0.0" width="80" height="44"/> 66 <rect key="frame" x="106" y="0.0" width="80" height="44"/>
65 <constraints> 67 <constraints>
66 <constraint firstAttribute="width" constant="80" id="57B-fF-bdc"/> 68 <constraint firstAttribute="width" constant="80" id="57B-fF-bdc"/>
67 </constraints> 69 </constraints>
68 <fontDescription key="fontDescription" type="system" pointSize="17"/> 70 <fontDescription key="fontDescription" type="system" pointSize="17"/>
69 <nil key="textColor"/> 71 <nil key="textColor"/>
70 <nil key="highlightedColor"/> 72 <nil key="highlightedColor"/>
71 </label> 73 </label>
72 <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="86400" translatesAutoresizingMaskIntoConstraints="NO" id="79Q-XB-cW2"> 74 <slider opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" minValue="0.0" maxValue="86400" translatesAutoresizingMaskIntoConstraints="NO" id="79Q-XB-cW2">
73 <rect key="frame" x="192" y="7" width="177" height="31"/> 75 <rect key="frame" x="192" y="7" width="177" height="31"/>
74 </slider> 76 </slider>
75 </subviews> 77 </subviews>
76 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 78 <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
77 <constraints> 79 <constraints>
78 <constraint firstItem="79Q-XB-cW2" firstAttribute="leading" secondItem="EMF-vR-v3k" secondAttribute="trailing" constant="8" id="0a0-t9-1tR"/> 80 <constraint firstItem="79Q-XB-cW2" firstAttribute="leading" secondItem="EMF-vR-v3k" secondAttribute="trailing" constant="8" id="0a0-t9-1tR"/>
79 <constraint firstItem="EMF-vR-v3k" firstAttribute="leading" secondItem="ibI-Db-Rc6" secondAttribute="trailing" constant="8" id="1a3-pA-ato"/> 81 <constraint firstItem="EMF-vR-v3k" firstAttribute="leading" secondItem="ibI-Db-Rc6" secondAttribute="trailing" constant="8" id="1a3-pA-ato"/>
80 <constraint firstAttribute="bottom" secondItem="79Q-XB-cW2" secondAttribute="bottom" constant="7" id="3l2-mK-se7"/> 82 <constraint firstAttribute="bottom" secondItem="79Q-XB-cW2" secondAttribute="bottom" constant="7" id="3l2-mK-se7"/>
81 <constraint firstItem="79Q-XB-cW2" firstAttribute="top" secondItem="ayh-Y4-2QM" secondAttribute="top" constant="7" id="6uV-xl-zpg"/> 83 <constraint firstItem="79Q-XB-cW2" firstAttribute="top" secondItem="ayh-Y4-2QM" secondAttribute="top" constant="7" id="6uV-xl-zpg"/>
82 <constraint firstAttribute="bottom" secondItem="EMF-vR-v3k" secondAttribute="bottom" id="7AD-qZ-VE4"/> 84 <constraint firstAttribute="bottom" secondItem="EMF-vR-v3k" secondAttribute="bottom" id="7AD-qZ-VE4"/>
83 <constraint firstItem="EMF-vR-v3k" firstAttribute="top" secondItem="ayh-Y4-2QM" secondAttribute="top" id="B8d-wr-H0p"/> 85 <constraint firstItem="EMF-vR-v3k" firstAttribute="top" secondItem="ayh-Y4-2QM" secondAttribute="top" id="B8d-wr-H0p"/>
84 <constraint firstAttribute="height" constant="44" id="G4K-Ic-5xS"/> 86 <constraint firstAttribute="height" constant="44" id="G4K-Ic-5xS"/>
85 <constraint firstItem="ibI-Db-Rc6" firstAttribute="leading" secondItem="ayh-Y4-2QM" secondAttribute="leading" constant="8" id="NC8-xC-nBM"/> 87 <constraint firstItem="ibI-Db-Rc6" firstAttribute="leading" secondItem="ayh-Y4-2QM" secondAttribute="leading" constant="8" id="NC8-xC-nBM"/>
86 <constraint firstAttribute="bottom" secondItem="ibI-Db-Rc6" secondAttribute="bottom" id="TKv-6Y-DHi"/> 88 <constraint firstAttribute="bottom" secondItem="ibI-Db-Rc6" secondAttribute="bottom" id="TKv-6Y-DHi"/>
87 <constraint firstAttribute="trailing" secondItem="79Q-XB-cW2" secondAttribute="trailing" constant="8" id="bzZ-US-1Hm"/> 89 <constraint firstAttribute="trailing" secondItem="79Q-XB-cW2" secondAttribute="trailing" constant="8" id="bzZ-US-1Hm"/>
88 <constraint firstItem="ibI-Db-Rc6" firstAttribute="top" secondItem="ayh-Y4-2QM" secondAttribute="top" id="lyI-MR-Y5S"/> 90 <constraint firstItem="ibI-Db-Rc6" firstAttribute="top" secondItem="ayh-Y4-2QM" secondAttribute="top" id="lyI-MR-Y5S"/>
89 </constraints> 91 </constraints>
90 </view> 92 </view>
91 </subviews> 93 </subviews>
92 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 94 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
93 <constraints> 95 <constraints>
94 <constraint firstAttribute="bottom" secondItem="GCl-mf-CD8" secondAttribute="bottom" constant="88" id="8R5-IL-ZOZ"/> 96 <constraint firstAttribute="bottom" secondItem="GCl-mf-CD8" secondAttribute="bottom" constant="88" placeholder="YES" id="8R5-IL-ZOZ"/>
95 <constraint firstItem="ayh-Y4-2QM" firstAttribute="top" secondItem="qLg-XF-Dyf" secondAttribute="bottom" constant="8" id="CCW-El-IlM"/> 97 <constraint firstItem="ayh-Y4-2QM" firstAttribute="top" secondItem="qLg-XF-Dyf" secondAttribute="bottom" constant="8" id="CCW-El-IlM"/>
96 <constraint firstAttribute="trailing" secondItem="bSt-HN-qcq" secondAttribute="trailing" constant="20" id="GmG-Qy-kpO"/> 98 <constraint firstAttribute="trailing" secondItem="bSt-HN-qcq" secondAttribute="trailing" constant="20" id="GmG-Qy-kpO"/>
97 <constraint firstAttribute="trailing" secondItem="ayh-Y4-2QM" secondAttribute="trailing" id="Mwo-O6-jk0"/> 99 <constraint firstAttribute="trailing" secondItem="ayh-Y4-2QM" secondAttribute="trailing" id="Mwo-O6-jk0"/>
98 <constraint firstAttribute="trailing" secondItem="GCl-mf-CD8" secondAttribute="trailing" id="PwQ-mm-AeM"/> 100 <constraint firstAttribute="trailing" secondItem="GCl-mf-CD8" secondAttribute="trailing" id="PwQ-mm-AeM"/>
99 <constraint firstItem="GCl-mf-CD8" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" placeholder="YES" id="TRc-4D-tbT"/> 101 <constraint firstItem="GCl-mf-CD8" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" placeholder="YES" id="TRc-4D-tbT"/>
100 <constraint firstItem="ayh-Y4-2QM" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="Zc1-Ki-ENV"/> 102 <constraint firstItem="ayh-Y4-2QM" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="Zc1-Ki-ENV"/>
101 <constraint firstItem="GCl-mf-CD8" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="aM7-E7-p41"/> 103 <constraint firstItem="GCl-mf-CD8" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="aM7-E7-p41"/>
102 <constraint firstItem="bSt-HN-qcq" firstAttribute="leading" secondItem="qLg-XF-Dyf" secondAttribute="trailing" constant="10" id="hlg-b5-9sd"/> 104 <constraint firstItem="bSt-HN-qcq" firstAttribute="leading" secondItem="qLg-XF-Dyf" secondAttribute="trailing" constant="10" id="hlg-b5-9sd"/>
103 <constraint firstItem="qLg-XF-Dyf" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="20" id="nAo-mi-AuL"/> 105 <constraint firstItem="qLg-XF-Dyf" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="20" id="nAo-mi-AuL"/>
104 <constraint firstItem="ayh-Y4-2QM" firstAttribute="top" secondItem="GCl-mf-CD8" secondAttribute="bottom" id="qaI-c1-69r"/> 106 <constraint firstItem="ayh-Y4-2QM" firstAttribute="top" secondItem="GCl-mf-CD8" secondAttribute="bottom" id="qaI-c1-69r"/>
105 <constraint firstItem="qLg-XF-Dyf" firstAttribute="centerY" secondItem="bSt-HN-qcq" secondAttribute="centerY" constant="-5" id="tA8-lE-abe"/> 107 <constraint firstItem="qLg-XF-Dyf" firstAttribute="centerY" secondItem="bSt-HN-qcq" secondAttribute="centerY" constant="-5" id="tA8-lE-abe"/>
106 </constraints> 108 </constraints>
107 <point key="canvasLocation" x="32.5" y="70.5"/> 109 <point key="canvasLocation" x="32.5" y="70.5"/>
108 </view> 110 </view>
109 </objects> 111 </objects>
110 </document> 112 </document>
111 113
LifeLog/LifeLog/RankingViewController.m
1 // 1 //
2 // RankingViewController.m 2 // RankingViewController.m
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by Nguyen Van Phong on 7/25/17. 5 // Created by Nguyen Van Phong on 7/25/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import "RankingViewController.h" 9 #import "RankingViewController.h"
10 #import "RankingTableViewCell.h" 10 #import "RankingTableViewCell.h"
11 11
12 #import "ServerAPI.h" 12 #import "ServerAPI.h"
13 #import "Utilities.h" 13 #import "Utilities.h"
14 14
15 @interface RankingViewController () 15 @interface RankingViewController ()
16 16
17 @end 17 @end
18 18
19 @implementation RankingViewController 19 @implementation RankingViewController
20 20
21 - (void)viewDidLoad { 21 - (void)viewDidLoad {
22 [super viewDidLoad]; 22 [super viewDidLoad];
23 [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.bottomLayoutGuide attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.viewCollectionType attribute:NSLayoutAttributeBottom multiplier:1 constant:5]];
23 // Do any additional setup after loading the view from its nib. 24 // Do any additional setup after loading the view from its nib.
24 self.title = NSLocalizedString(@"lifelog.rank.title", nil); 25 self.title = NSLocalizedString(@"lifelog.rank.title", nil);
25 26
26 [self setupView]; 27 [self setupView];
27 28
28 _startDate = [NSDate date]; 29 _startDate = [NSDate date];
29 _endDate = _startDate; 30 _endDate = _startDate;
30 self.lblDateTime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"]; 31 self.lblDateTime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"];
31 32
32 //register nib for table view 33 //register nib for table view
33 [self.tableBase registerNib:[UINib nibWithNibName:@"RankingTableViewCell" bundle:nil] forCellReuseIdentifier:@"RankCell"]; 34 [self.tableBase registerNib:[UINib nibWithNibName:@"RankingTableViewCell" bundle:nil] forCellReuseIdentifier:@"RankCell"];
34 35
35 [self callRequestToUpdateData]; 36 [self callRequestToUpdateData];
36 } 37 }
37 38
38 - (void)didReceiveMemoryWarning { 39 - (void)didReceiveMemoryWarning {
39 [super didReceiveMemoryWarning]; 40 [super didReceiveMemoryWarning];
40 // Dispose of any resources that can be recreated. 41 // Dispose of any resources that can be recreated.
41 } 42 }
42 43
43 #pragma mark Setup and Update View 44 #pragma mark Setup and Update View
44 45
45 - (void)setupView { 46 - (void)setupView {
46 NSArray *timeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.rank.time.1", nil), NSLocalizedString(@"lifelog.rank.time.2", nil), NSLocalizedString(@"lifelog.rank.time.3", nil), NSLocalizedString(@"lifelog.rank.time.4", nil), nil]; 47 NSArray *timeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.rank.time.1", nil), NSLocalizedString(@"lifelog.rank.time.2", nil), NSLocalizedString(@"lifelog.rank.time.3", nil), NSLocalizedString(@"lifelog.rank.time.4", nil), nil];
47 [self.viewCollectionTime setButtonNumber:timeTitle.count]; 48 [self.viewCollectionTime setButtonNumber:timeTitle.count];
48 [self.viewCollectionTime setSpacing:1]; 49 [self.viewCollectionTime setSpacing:1];
49 [self.viewCollectionTime setArrayTitle:timeTitle]; 50 [self.viewCollectionTime setArrayTitle:timeTitle];
50 self.viewCollectionTime.changeCurrentIndex = ^(int index){ 51 self.viewCollectionTime.changeCurrentIndex = ^(int index){
51 [self changeDate]; 52 [self changeDate];
52 }; 53 };
53 54
54 NSArray *modeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.rank.mode.1", nil), NSLocalizedString(@"lifelog.rank.mode.2", nil), NSLocalizedString(@"lifelog.rank.mode.3", nil), NSLocalizedString(@"lifelog.rank.mode.4", nil), nil]; 55 NSArray *modeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.rank.mode.1", nil), NSLocalizedString(@"lifelog.rank.mode.2", nil), NSLocalizedString(@"lifelog.rank.mode.3", nil), NSLocalizedString(@"lifelog.rank.mode.4", nil), nil];
55 [self.viewCollectionMode setButtonNumber:modeTitle.count]; 56 [self.viewCollectionMode setButtonNumber:modeTitle.count];
56 [self.viewCollectionMode setSpacing:1]; 57 [self.viewCollectionMode setSpacing:1];
57 [self.viewCollectionMode setArrayTitle:modeTitle]; 58 [self.viewCollectionMode setArrayTitle:modeTitle];
58 self.viewCollectionMode.changeCurrentIndex = ^(int index){ 59 self.viewCollectionMode.changeCurrentIndex = ^(int index){
59 [self callRequestToUpdateData]; 60 [self callRequestToUpdateData];
60 }; 61 };
61 62
62 NSArray *typeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.rank.type.1", nil), NSLocalizedString(@"lifelog.rank.type.2", nil), NSLocalizedString(@"lifelog.rank.type.3", nil), NSLocalizedString(@"lifelog.rank.type.4", nil), nil]; 63 NSArray *typeTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.rank.type.1", nil), NSLocalizedString(@"lifelog.rank.type.2", nil), NSLocalizedString(@"lifelog.rank.type.3", nil), NSLocalizedString(@"lifelog.rank.type.4", nil), nil];
63 [self.viewCollectionType setButtonNumber:typeTitle.count]; 64 [self.viewCollectionType setButtonNumber:typeTitle.count];
64 [self.viewCollectionType setSpacing:1]; 65 [self.viewCollectionType setSpacing:1];
65 [self.viewCollectionType setArrayTitle:typeTitle]; 66 [self.viewCollectionType setArrayTitle:typeTitle];
66 self.viewCollectionMode.changeCurrentIndex = ^(int index){ 67 self.viewCollectionMode.changeCurrentIndex = ^(int index){
67 [self callRequestToUpdateData]; 68 [self callRequestToUpdateData];
68 }; 69 };
69 } 70 }
70 71
71 72
72 #pragma mark IBAction function 73 #pragma mark IBAction function
73 - (IBAction)clickBackward:(UIButton *)sender { 74 - (IBAction)clickBackward:(UIButton *)sender {
74 _endDate = [_endDate dateByAddingTimeInterval:-86400]; 75 _endDate = [_endDate dateByAddingTimeInterval:-86400];
75 [self changeDate]; 76 [self changeDate];
76 } 77 }
77 78
78 - (IBAction)clickForward:(UIButton *)sender { 79 - (IBAction)clickForward:(UIButton *)sender {
79 _endDate = [_endDate dateByAddingTimeInterval:86400]; 80 _endDate = [_endDate dateByAddingTimeInterval:86400];
80 [self changeDate]; 81 [self changeDate];
81 } 82 }
82 83
83 #pragma mark UITableView Delegate 84 #pragma mark UITableView Delegate
84 85
85 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 86 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
86 RankingTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RankCell"]; 87 RankingTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RankCell"];
87 [cell setRankingData:[_curDataList objectAtIndex:indexPath.row]]; 88 [cell setRankingData:[_curDataList objectAtIndex:indexPath.row]];
88 return cell; 89 return cell;
89 } 90 }
90 91
91 #pragma mark Private function 92 #pragma mark Private function
92 - (void)callRequestToUpdateData { 93 - (void)callRequestToUpdateData {
93 [super callRequestToUpdateData]; 94 [super callRequestToUpdateData];
94 95
95 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 96 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
96 MBProgressHUD *hudView = nil; 97 MBProgressHUD *hudView = nil;
97 int mode = self.viewCollectionMode.getCurrentIndex + 1; 98 int mode = self.viewCollectionMode.getCurrentIndex + 1;
98 //dont have all 99 //dont have all
99 mode = fmin(mode, 3); 100 mode = fmin(mode, 3);
100 101
101 if(_curPage == 1 && !self.refreshControl.isRefreshing) { 102 if(_curPage == 1 && !self.refreshControl.isRefreshing) {
102 hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; 103 hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
103 } 104 }
104 [[ServerAPI server] requestRankingList:token startDate:_startDate endDate:_endDate mode:mode page:_curPage CompletionHandler:^(NSArray *array, NSError *error){ 105 [[ServerAPI server] requestRankingList:token startDate:_startDate endDate:_endDate mode:mode page:_curPage CompletionHandler:^(NSArray *array, NSError *error){
105 dispatch_async(dispatch_get_main_queue(), ^{ 106 dispatch_async(dispatch_get_main_queue(), ^{
106 if(hudView != nil) { 107 if(hudView != nil) {
107 [hudView hideAnimated:true]; 108 [hudView hideAnimated:true];
108 } 109 }
109 }); 110 });
110 RankingViewController __weak *weakSelf = self; 111 RankingViewController __weak *weakSelf = self;
111 [weakSelf updateTableData:array error:error]; 112 [weakSelf updateTableData:array error:error];
112 }]; 113 }];
113 } 114 }
114 115
115 - (void) changeDate { 116 - (void) changeDate {
116 switch (self.viewCollectionTime.getCurrentIndex) { 117 switch (self.viewCollectionTime.getCurrentIndex) {
117 case 1: 118 case 1:
118 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 7]; 119 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 7];
119 break; 120 break;
120 case 2: 121 case 2:
121 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 30]; 122 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 30];
122 break; 123 break;
123 case 3: 124 case 3:
124 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 365]; 125 _startDate = [_endDate dateByAddingTimeInterval:-86400 * 365];
125 break; 126 break;
126 default: 127 default:
127 _startDate = _endDate; 128 _startDate = _endDate;
128 break; 129 break;
129 } 130 }
130 if(_startDate == _endDate) { 131 if(_startDate == _endDate) {
131 self.lblDateTime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"]; 132 self.lblDateTime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"];
132 } 133 }
133 else { 134 else {
134 NSString * startDateString = [Utilities stringFromDate:_startDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"]; 135 NSString * startDateString = [Utilities stringFromDate:_startDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"];
135 NSString * endDateString = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"]; 136 NSString * endDateString = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"];
136 self.lblDateTime.text = [NSString stringWithFormat:@"%@-%@", startDateString, endDateString]; 137 self.lblDateTime.text = [NSString stringWithFormat:@"%@-%@", startDateString, endDateString];
137 } 138 }
138 [self callRequestToUpdateData]; 139 [self callRequestToUpdateData];
139 } 140 }
140 @end 141 @end
141 142
LifeLog/LifeLog/RankingViewController.xib
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> 2 <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
3 <device id="retina4_7" orientation="portrait"> 3 <device id="retina4_7" orientation="portrait">
4 <adaptation id="fullscreen"/> 4 <adaptation id="fullscreen"/>
5 </device> 5 </device>
6 <dependencies> 6 <dependencies>
7 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/> 7 <deployment identifier="iOS"/>
8 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13527"/>
8 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> 9 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9 </dependencies> 10 </dependencies>
10 <objects> 11 <objects>
11 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RankingViewController"> 12 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RankingViewController">
12 <connections> 13 <connections>
13 <outlet property="lblDateTime" destination="5Ro-k6-fvT" id="5uO-ff-Pmc"/> 14 <outlet property="lblDateTime" destination="5Ro-k6-fvT" id="5uO-ff-Pmc"/>
14 <outlet property="tableBase" destination="R3A-K9-MFe" id="Tf9-Rg-PEW"/> 15 <outlet property="tableBase" destination="R3A-K9-MFe" id="Tf9-Rg-PEW"/>
15 <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/> 16 <outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
16 <outlet property="viewCollectionMode" destination="B33-xX-Jro" id="HP4-Xb-LJm"/> 17 <outlet property="viewCollectionMode" destination="B33-xX-Jro" id="HP4-Xb-LJm"/>
17 <outlet property="viewCollectionTime" destination="syA-uK-pbr" id="WdA-Cq-Flj"/> 18 <outlet property="viewCollectionTime" destination="syA-uK-pbr" id="WdA-Cq-Flj"/>
18 <outlet property="viewCollectionType" destination="oUo-Eo-tz5" id="bjw-El-34G"/> 19 <outlet property="viewCollectionType" destination="oUo-Eo-tz5" id="bjw-El-34G"/>
19 </connections> 20 </connections>
20 </placeholder> 21 </placeholder>
21 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> 22 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
22 <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT"> 23 <view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
23 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> 24 <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
24 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> 25 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
25 <subviews> 26 <subviews>
26 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GBx-lY-9YI" userLabel="ViewHeader"> 27 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GBx-lY-9YI" userLabel="ViewHeader">
27 <rect key="frame" x="0.0" y="0.0" width="375" height="46"/> 28 <rect key="frame" x="0.0" y="0.0" width="375" height="46"/>
28 <subviews> 29 <subviews>
29 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ランキング" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p97-40-8m9" customClass="AutoTransLabel"> 30 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="ランキング" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="p97-40-8m9" customClass="AutoTransLabel">
30 <rect key="frame" x="0.0" y="0.0" width="375" height="46"/> 31 <rect key="frame" x="0.0" y="0.0" width="375" height="46"/>
31 <fontDescription key="fontDescription" type="system" pointSize="17"/> 32 <fontDescription key="fontDescription" type="system" pointSize="17"/>
32 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 33 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
33 <nil key="highlightedColor"/> 34 <nil key="highlightedColor"/>
34 <userDefinedRuntimeAttributes> 35 <userDefinedRuntimeAttributes>
35 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.rank.title"/> 36 <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.rank.title"/>
36 </userDefinedRuntimeAttributes> 37 </userDefinedRuntimeAttributes>
37 </label> 38 </label>
38 <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qPe-ff-jRp"> 39 <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qPe-ff-jRp">
39 <rect key="frame" x="0.0" y="5" width="70" height="36"/> 40 <rect key="frame" x="0.0" y="5" width="70" height="36"/>
40 <constraints> 41 <constraints>
41 <constraint firstAttribute="width" constant="70" id="bEy-jt-69Q"/> 42 <constraint firstAttribute="width" constant="70" id="bEy-jt-69Q"/>
42 </constraints> 43 </constraints>
43 <state key="normal" image="today_back_button"/> 44 <state key="normal" image="today_back_button"/>
44 </button> 45 </button>
45 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WGc-2i-Swk"> 46 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WGc-2i-Swk">
46 <rect key="frame" x="330" y="0.0" width="45" height="46"/> 47 <rect key="frame" x="330" y="0.0" width="45" height="46"/>
47 <constraints> 48 <constraints>
48 <constraint firstAttribute="width" constant="45" id="nJ2-jH-Z45"/> 49 <constraint firstAttribute="width" constant="45" id="nJ2-jH-Z45"/>
49 </constraints> 50 </constraints>
50 <state key="normal" image="icon_menu"/> 51 <state key="normal" image="icon_menu"/>
51 </button> 52 </button>
52 </subviews> 53 </subviews>
53 <color key="backgroundColor" red="0.098039215690000001" green="0.098039215690000001" blue="0.098039215690000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> 54 <color key="backgroundColor" red="0.098039215690000001" green="0.098039215690000001" blue="0.098039215690000001" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
54 <constraints> 55 <constraints>
55 <constraint firstAttribute="bottom" secondItem="WGc-2i-Swk" secondAttribute="bottom" id="0hd-fk-kJG"/> 56 <constraint firstAttribute="bottom" secondItem="WGc-2i-Swk" secondAttribute="bottom" id="0hd-fk-kJG"/>
56 <constraint firstAttribute="bottom" secondItem="p97-40-8m9" secondAttribute="bottom" id="78G-b2-wAu"/> 57 <constraint firstAttribute="bottom" secondItem="p97-40-8m9" secondAttribute="bottom" id="78G-b2-wAu"/>
57 <constraint firstItem="qPe-ff-jRp" firstAttribute="leading" secondItem="GBx-lY-9YI" secondAttribute="leading" id="9ND-Te-qX9"/> 58 <constraint firstItem="qPe-ff-jRp" firstAttribute="leading" secondItem="GBx-lY-9YI" secondAttribute="leading" id="9ND-Te-qX9"/>
58 <constraint firstItem="qPe-ff-jRp" firstAttribute="top" secondItem="GBx-lY-9YI" secondAttribute="top" constant="5" id="9ZX-A3-Bnp"/> 59 <constraint firstItem="qPe-ff-jRp" firstAttribute="top" secondItem="GBx-lY-9YI" secondAttribute="top" constant="5" id="9ZX-A3-Bnp"/>
59 <constraint firstItem="p97-40-8m9" firstAttribute="top" secondItem="GBx-lY-9YI" secondAttribute="top" id="CVN-ke-5KK"/> 60 <constraint firstItem="p97-40-8m9" firstAttribute="top" secondItem="GBx-lY-9YI" secondAttribute="top" id="CVN-ke-5KK"/>
60 <constraint firstAttribute="height" constant="46" id="SDI-ij-KbH"/> 61 <constraint firstAttribute="height" constant="46" id="SDI-ij-KbH"/>
61 <constraint firstItem="p97-40-8m9" firstAttribute="leading" secondItem="GBx-lY-9YI" secondAttribute="leading" id="U19-fM-q7G"/> 62 <constraint firstItem="p97-40-8m9" firstAttribute="leading" secondItem="GBx-lY-9YI" secondAttribute="leading" id="U19-fM-q7G"/>
62 <constraint firstAttribute="bottom" secondItem="qPe-ff-jRp" secondAttribute="bottom" constant="5" id="jU7-xM-YKX"/> 63 <constraint firstAttribute="bottom" secondItem="qPe-ff-jRp" secondAttribute="bottom" constant="5" id="jU7-xM-YKX"/>
63 <constraint firstItem="WGc-2i-Swk" firstAttribute="top" secondItem="GBx-lY-9YI" secondAttribute="top" id="knL-Yf-VTN"/> 64 <constraint firstItem="WGc-2i-Swk" firstAttribute="top" secondItem="GBx-lY-9YI" secondAttribute="top" id="knL-Yf-VTN"/>
64 <constraint firstAttribute="trailing" secondItem="p97-40-8m9" secondAttribute="trailing" id="sLL-ca-92S"/> 65 <constraint firstAttribute="trailing" secondItem="p97-40-8m9" secondAttribute="trailing" id="sLL-ca-92S"/>
65 <constraint firstAttribute="trailing" secondItem="WGc-2i-Swk" secondAttribute="trailing" id="v0h-pb-83W"/> 66 <constraint firstAttribute="trailing" secondItem="WGc-2i-Swk" secondAttribute="trailing" id="v0h-pb-83W"/>
66 </constraints> 67 </constraints>
67 </view> 68 </view>
68 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="syA-uK-pbr" customClass="CollectionView"> 69 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="syA-uK-pbr" customClass="CollectionView">
69 <rect key="frame" x="0.0" y="46" width="375" height="30"/> 70 <rect key="frame" x="0.0" y="46" width="375" height="30"/>
70 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 71 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
71 <constraints> 72 <constraints>
72 <constraint firstAttribute="height" constant="30" id="ezW-Qs-M7K"/> 73 <constraint firstAttribute="height" constant="30" id="ezW-Qs-M7K"/>
73 </constraints> 74 </constraints>
74 </view> 75 </view>
75 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="B33-xX-Jro" customClass="CollectionView"> 76 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="B33-xX-Jro" customClass="CollectionView">
76 <rect key="frame" x="0.0" y="116" width="375" height="30"/> 77 <rect key="frame" x="0.0" y="116" width="375" height="30"/>
77 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 78 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
78 <constraints> 79 <constraints>
79 <constraint firstAttribute="height" constant="30" id="snn-FM-11r"/> 80 <constraint firstAttribute="height" constant="30" id="snn-FM-11r"/>
80 </constraints> 81 </constraints>
81 </view> 82 </view>
82 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="u5D-xz-8dK"> 83 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="u5D-xz-8dK">
83 <rect key="frame" x="0.0" y="76" width="375" height="40"/> 84 <rect key="frame" x="0.0" y="76" width="375" height="40"/>
84 <subviews> 85 <subviews>
85 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Ro-k6-fvT"> 86 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5Ro-k6-fvT">
86 <rect key="frame" x="0.0" y="0.0" width="375" height="40"/> 87 <rect key="frame" x="0.0" y="0.0" width="375" height="40"/>
87 <string key="text" base64-UTF8="YES"> 88 <string key="text" base64-UTF8="YES">
88 MjAxNuW5tCAx5pyIMjLml6XjgIDvvI3jgIAyMDE35bm0IDHmnIgyMeaXpQ0KAA 89 MjAxNuW5tCAx5pyIMjLml6XjgIDvvI3jgIAyMDE35bm0IDHmnIgyMeaXpQ0KAA
89 </string> 90 </string>
90 <fontDescription key="fontDescription" type="system" pointSize="13"/> 91 <fontDescription key="fontDescription" type="system" pointSize="13"/>
91 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 92 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
92 <nil key="highlightedColor"/> 93 <nil key="highlightedColor"/>
93 </label> 94 </label>
94 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eiH-Sk-3VV"> 95 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eiH-Sk-3VV">
95 <rect key="frame" x="15" y="5" width="30" height="30"/> 96 <rect key="frame" x="15" y="5" width="30" height="30"/>
96 <constraints> 97 <constraints>
97 <constraint firstAttribute="height" constant="30" id="kEd-sQ-0ub"/> 98 <constraint firstAttribute="height" constant="30" id="kEd-sQ-0ub"/>
98 <constraint firstAttribute="width" constant="30" id="sFT-sr-7pL"/> 99 <constraint firstAttribute="width" constant="30" id="sFT-sr-7pL"/>
99 </constraints> 100 </constraints>
100 <state key="normal" image="icon_left"/> 101 <state key="normal" image="icon_left"/>
101 <connections> 102 <connections>
102 <action selector="clickBackward:" destination="-1" eventType="touchUpInside" id="8KB-3G-h6v"/> 103 <action selector="clickBackward:" destination="-1" eventType="touchUpInside" id="8KB-3G-h6v"/>
103 </connections> 104 </connections>
104 </button> 105 </button>
105 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Usl-Cl-d9d"> 106 <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Usl-Cl-d9d">
106 <rect key="frame" x="330" y="5" width="30" height="30"/> 107 <rect key="frame" x="330" y="5" width="30" height="30"/>
107 <constraints> 108 <constraints>
108 <constraint firstAttribute="width" constant="30" id="uFf-AY-LsL"/> 109 <constraint firstAttribute="width" constant="30" id="uFf-AY-LsL"/>
109 <constraint firstAttribute="height" constant="30" id="v8w-hV-CY1"/> 110 <constraint firstAttribute="height" constant="30" id="v8w-hV-CY1"/>
110 </constraints> 111 </constraints>
111 <state key="normal" image="icon_right"/> 112 <state key="normal" image="icon_right"/>
112 <connections> 113 <connections>
113 <action selector="clickForward:" destination="-1" eventType="touchUpInside" id="sgL-89-hXv"/> 114 <action selector="clickForward:" destination="-1" eventType="touchUpInside" id="sgL-89-hXv"/>
114 </connections> 115 </connections>
115 </button> 116 </button>
116 </subviews> 117 </subviews>
117 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 118 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
118 <constraints> 119 <constraints>
119 <constraint firstAttribute="height" constant="40" id="C5o-Zd-KjG"/> 120 <constraint firstAttribute="height" constant="40" id="C5o-Zd-KjG"/>
120 <constraint firstAttribute="bottom" secondItem="5Ro-k6-fvT" secondAttribute="bottom" id="DQQ-wh-s1Q"/> 121 <constraint firstAttribute="bottom" secondItem="5Ro-k6-fvT" secondAttribute="bottom" id="DQQ-wh-s1Q"/>
121 <constraint firstAttribute="trailing" secondItem="5Ro-k6-fvT" secondAttribute="trailing" id="E0c-bJ-AIi"/> 122 <constraint firstAttribute="trailing" secondItem="5Ro-k6-fvT" secondAttribute="trailing" id="E0c-bJ-AIi"/>
122 <constraint firstItem="5Ro-k6-fvT" firstAttribute="top" secondItem="u5D-xz-8dK" secondAttribute="top" id="Mrk-FC-rqh"/> 123 <constraint firstItem="5Ro-k6-fvT" firstAttribute="top" secondItem="u5D-xz-8dK" secondAttribute="top" id="Mrk-FC-rqh"/>
123 <constraint firstItem="eiH-Sk-3VV" firstAttribute="centerY" secondItem="u5D-xz-8dK" secondAttribute="centerY" id="k2J-Lc-ZDI"/> 124 <constraint firstItem="eiH-Sk-3VV" firstAttribute="centerY" secondItem="u5D-xz-8dK" secondAttribute="centerY" id="k2J-Lc-ZDI"/>
124 <constraint firstItem="5Ro-k6-fvT" firstAttribute="leading" secondItem="u5D-xz-8dK" secondAttribute="leading" id="rj5-0J-xs3"/> 125 <constraint firstItem="5Ro-k6-fvT" firstAttribute="leading" secondItem="u5D-xz-8dK" secondAttribute="leading" id="rj5-0J-xs3"/>
125 <constraint firstItem="Usl-Cl-d9d" firstAttribute="centerY" secondItem="u5D-xz-8dK" secondAttribute="centerY" id="sJX-n3-1pz"/> 126 <constraint firstItem="Usl-Cl-d9d" firstAttribute="centerY" secondItem="u5D-xz-8dK" secondAttribute="centerY" id="sJX-n3-1pz"/>
126 <constraint firstItem="eiH-Sk-3VV" firstAttribute="leading" secondItem="u5D-xz-8dK" secondAttribute="leading" constant="15" id="to7-WU-7xo"/> 127 <constraint firstItem="eiH-Sk-3VV" firstAttribute="leading" secondItem="u5D-xz-8dK" secondAttribute="leading" constant="15" id="to7-WU-7xo"/>
127 <constraint firstAttribute="trailing" secondItem="Usl-Cl-d9d" secondAttribute="trailing" constant="15" id="yDF-9k-XlW"/> 128 <constraint firstAttribute="trailing" secondItem="Usl-Cl-d9d" secondAttribute="trailing" constant="15" id="yDF-9k-XlW"/>
128 </constraints> 129 </constraints>
129 </view> 130 </view>
130 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oUo-Eo-tz5" customClass="CollectionView"> 131 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="oUo-Eo-tz5" customClass="CollectionView">
131 <rect key="frame" x="0.0" y="577" width="375" height="40"/> 132 <rect key="frame" x="0.0" y="577" width="375" height="40"/>
132 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 133 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
133 <constraints> 134 <constraints>
134 <constraint firstAttribute="height" constant="40" id="Trr-Ku-Ssy"/> 135 <constraint firstAttribute="height" constant="40" id="Trr-Ku-Ssy"/>
135 </constraints> 136 </constraints>
136 </view> 137 </view>
137 <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" rowHeight="80" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="R3A-K9-MFe"> 138 <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" rowHeight="80" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="R3A-K9-MFe">
138 <rect key="frame" x="0.0" y="147" width="375" height="429"/> 139 <rect key="frame" x="0.0" y="147" width="375" height="429"/>
139 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 140 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
140 <color key="separatorColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 141 <color key="separatorColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
141 <connections> 142 <connections>
142 <outlet property="dataSource" destination="-1" id="JJX-cg-LPL"/> 143 <outlet property="dataSource" destination="-1" id="JJX-cg-LPL"/>
143 <outlet property="delegate" destination="-1" id="u0m-93-lsi"/> 144 <outlet property="delegate" destination="-1" id="u0m-93-lsi"/>
144 </connections> 145 </connections>
145 </tableView> 146 </tableView>
146 </subviews> 147 </subviews>
147 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 148 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
148 <constraints> 149 <constraints>
149 <constraint firstItem="B33-xX-Jro" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="2Mu-hy-FVU"/> 150 <constraint firstItem="B33-xX-Jro" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="2Mu-hy-FVU"/>
150 <constraint firstItem="GBx-lY-9YI" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="5CL-wT-MBg"/> 151 <constraint firstItem="GBx-lY-9YI" firstAttribute="top" secondItem="i5M-Pr-FkT" secondAttribute="top" id="5CL-wT-MBg"/>
151 <constraint firstItem="u5D-xz-8dK" firstAttribute="top" secondItem="syA-uK-pbr" secondAttribute="bottom" id="5uu-dZ-oXI"/> 152 <constraint firstItem="u5D-xz-8dK" firstAttribute="top" secondItem="syA-uK-pbr" secondAttribute="bottom" id="5uu-dZ-oXI"/>
152 <constraint firstItem="syA-uK-pbr" firstAttribute="top" secondItem="GBx-lY-9YI" secondAttribute="bottom" id="6FQ-vy-d4N"/> 153 <constraint firstItem="syA-uK-pbr" firstAttribute="top" secondItem="GBx-lY-9YI" secondAttribute="bottom" id="6FQ-vy-d4N"/>
153 <constraint firstItem="u5D-xz-8dK" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="75z-RN-ObF"/> 154 <constraint firstItem="u5D-xz-8dK" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="75z-RN-ObF"/>
154 <constraint firstItem="R3A-K9-MFe" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="LyL-9p-qcd"/> 155 <constraint firstItem="R3A-K9-MFe" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="LyL-9p-qcd"/>
155 <constraint firstItem="oUo-Eo-tz5" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="M7I-ue-lip"/> 156 <constraint firstItem="oUo-Eo-tz5" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="M7I-ue-lip"/>
156 <constraint firstAttribute="trailing" secondItem="B33-xX-Jro" secondAttribute="trailing" id="Pjd-Ay-GaV"/> 157 <constraint firstAttribute="trailing" secondItem="B33-xX-Jro" secondAttribute="trailing" id="Pjd-Ay-GaV"/>
157 <constraint firstItem="oUo-Eo-tz5" firstAttribute="top" secondItem="R3A-K9-MFe" secondAttribute="bottom" constant="1" id="QMu-aq-2Zt"/> 158 <constraint firstItem="oUo-Eo-tz5" firstAttribute="top" secondItem="R3A-K9-MFe" secondAttribute="bottom" constant="1" id="QMu-aq-2Zt"/>
158 <constraint firstAttribute="trailing" secondItem="syA-uK-pbr" secondAttribute="trailing" id="Qnl-Pp-y2G"/> 159 <constraint firstAttribute="trailing" secondItem="syA-uK-pbr" secondAttribute="trailing" id="Qnl-Pp-y2G"/>
159 <constraint firstItem="B33-xX-Jro" firstAttribute="top" secondItem="u5D-xz-8dK" secondAttribute="bottom" id="VOl-jo-wU3"/> 160 <constraint firstItem="B33-xX-Jro" firstAttribute="top" secondItem="u5D-xz-8dK" secondAttribute="bottom" id="VOl-jo-wU3"/>
160 <constraint firstItem="GBx-lY-9YI" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="YjB-ef-xTt"/> 161 <constraint firstItem="GBx-lY-9YI" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="YjB-ef-xTt"/>
161 <constraint firstItem="syA-uK-pbr" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="aTf-mb-wlT"/> 162 <constraint firstItem="syA-uK-pbr" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" id="aTf-mb-wlT"/>
162 <constraint firstAttribute="bottom" secondItem="oUo-Eo-tz5" secondAttribute="bottom" constant="50" id="cux-Vm-qq7"/> 163 <constraint firstAttribute="bottom" secondItem="oUo-Eo-tz5" secondAttribute="bottom" constant="50" placeholder="YES" id="cux-Vm-qq7"/>
163 <constraint firstAttribute="trailing" secondItem="R3A-K9-MFe" secondAttribute="trailing" id="jBn-JI-SQP"/> 164 <constraint firstAttribute="trailing" secondItem="R3A-K9-MFe" secondAttribute="trailing" id="jBn-JI-SQP"/>
164 <constraint firstItem="R3A-K9-MFe" firstAttribute="top" secondItem="B33-xX-Jro" secondAttribute="bottom" constant="1" id="jTi-59-XsZ"/> 165 <constraint firstItem="R3A-K9-MFe" firstAttribute="top" secondItem="B33-xX-Jro" secondAttribute="bottom" constant="1" id="jTi-59-XsZ"/>
165 <constraint firstAttribute="trailing" secondItem="u5D-xz-8dK" secondAttribute="trailing" id="mDB-o3-gtA"/> 166 <constraint firstAttribute="trailing" secondItem="u5D-xz-8dK" secondAttribute="trailing" id="mDB-o3-gtA"/>
166 <constraint firstAttribute="trailing" secondItem="GBx-lY-9YI" secondAttribute="trailing" id="yaf-8r-ySL"/> 167 <constraint firstAttribute="trailing" secondItem="GBx-lY-9YI" secondAttribute="trailing" id="yaf-8r-ySL"/>
167 <constraint firstAttribute="trailing" secondItem="oUo-Eo-tz5" secondAttribute="trailing" id="zkl-by-qMp"/> 168 <constraint firstAttribute="trailing" secondItem="oUo-Eo-tz5" secondAttribute="trailing" id="zkl-by-qMp"/>
168 </constraints> 169 </constraints>
169 <point key="canvasLocation" x="26.5" y="52.5"/> 170 <point key="canvasLocation" x="26.5" y="52.5"/>
170 </view> 171 </view>
171 </objects> 172 </objects>
172 <resources> 173 <resources>
173 <image name="icon_left" width="30" height="30"/> 174 <image name="icon_left" width="30" height="30"/>
174 <image name="icon_menu" width="30" height="30"/> 175 <image name="icon_menu" width="30" height="30"/>
175 <image name="icon_right" width="30" height="30"/> 176 <image name="icon_right" width="30" height="30"/>
176 <image name="today_back_button" width="73" height="37"/> 177 <image name="today_back_button" width="73" height="37"/>
177 </resources> 178 </resources>
178 </document> 179 </document>
179 180
LifeLog/LifeLog/ServerAPI.m
1 // 1 //
2 // ServerAPI.m 2 // ServerAPI.m
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by Nguyen Van Phong on 7/30/17. 5 // Created by Nguyen Van Phong on 7/30/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import "ServerAPI.h" 9 #import "ServerAPI.h"
10 #import "Utilities.h" 10 #import "Utilities.h"
11 11
12 NSString *const kServerAddress = @"http://clover.timesfun.jp:9001/"; 12 NSString *const kServerAddress = @"http://clover.timesfun.jp:9001/";
13 NSString *const kUser = @"KEY_USER"; 13 NSString *const kUser = @"KEY_USER";
14 NSString *const kToken = @"KEY_TOKEN"; 14 NSString *const kToken = @"KEY_TOKEN";
15 NSString *const kNotificationToken = @"TOKEN_INVALID"; 15 NSString *const kNotificationToken = @"TOKEN_INVALID";
16 16
17 @implementation NSString (NSString_Extended) 17 @implementation NSString (NSString_Extended)
18 - (NSString *)urlencode { 18 - (NSString *)urlencode {
19 NSMutableString *output = [NSMutableString string]; 19 NSMutableString *output = [NSMutableString string];
20 const unsigned char *source = (const unsigned char *)[self UTF8String]; 20 const unsigned char *source = (const unsigned char *)[self UTF8String];
21 int sourceLen = (int)strlen((const char *)source); 21 int sourceLen = (int)strlen((const char *)source);
22 for (int i = 0; i < sourceLen; ++i) { 22 for (int i = 0; i < sourceLen; ++i) {
23 const unsigned char thisChar = source[i]; 23 const unsigned char thisChar = source[i];
24 if (thisChar == ' '){ 24 if (thisChar == ' '){
25 [output appendString:@"+"]; 25 [output appendString:@"+"];
26 } else if (thisChar == '.' || thisChar == '-' || thisChar == '_' || thisChar == '~' || 26 } else if (thisChar == '.' || thisChar == '-' || thisChar == '_' || thisChar == '~' ||
27 (thisChar >= 'a' && thisChar <= 'z') || 27 (thisChar >= 'a' && thisChar <= 'z') ||
28 (thisChar >= 'A' && thisChar <= 'Z') || 28 (thisChar >= 'A' && thisChar <= 'Z') ||
29 (thisChar >= '0' && thisChar <= '9')) { 29 (thisChar >= '0' && thisChar <= '9')) {
30 [output appendFormat:@"%c", thisChar]; 30 [output appendFormat:@"%c", thisChar];
31 } else { 31 } else {
32 [output appendFormat:@"%%%02X", thisChar]; 32 [output appendFormat:@"%%%02X", thisChar];
33 } 33 }
34 } 34 }
35 return output; 35 return output;
36 } 36 }
37 @end 37 @end
38 38
39 @implementation ServerAPI 39 @implementation ServerAPI
40 static ServerAPI *_server = nil; 40 static ServerAPI *_server = nil;
41 41
42 NSURLSessionDataTask * searchTask; 42 NSURLSessionDataTask * searchTask;
43 43
44 @synthesize timeOutInterval = _timeOutInterval; 44 @synthesize timeOutInterval = _timeOutInterval;
45 45
46 + (instancetype)server 46 + (instancetype)server
47 { 47 {
48 @synchronized(self) { 48 @synchronized(self) {
49 if (_server == nil) { 49 if (_server == nil) {
50 _server = [[ServerAPI alloc] init]; 50 _server = [[ServerAPI alloc] init];
51 } 51 }
52 } 52 }
53 return _server; 53 return _server;
54 } 54 }
55 55
56 - (instancetype)init 56 - (instancetype)init
57 { 57 {
58 self = [super init]; 58 self = [super init];
59 if (self != nil) { 59 if (self != nil) {
60 self.timeOutInterval = 60; 60 self.timeOutInterval = 60;
61 } 61 }
62 return self; 62 return self;
63 } 63 }
64 64
65 #pragma mark - Login and Register 65 #pragma mark - Login and Register
66 // Login 66 // Login
67 - (void)loginWithEmail:(NSString *)email Password:(NSString *)password CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion 67 - (void)loginWithEmail:(NSString *)email Password:(NSString *)password CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion
68 { 68 {
69 [self _request:[kServerAddress stringByAppendingFormat: @"login"] method:@"POST" token:@"" paras:@{@"email":email, @"password": password} completion:^(NSData *data, NSError *error) { 69 [self _request:[kServerAddress stringByAppendingFormat: @"login"] method:@"POST" token:@"" paras:@{@"email":email, @"password": password} completion:^(NSData *data, NSError *error) {
70 70
71 if (completion == NULL) { 71 if (completion == NULL) {
72 return ; 72 return ;
73 } 73 }
74 74
75 if (error == nil) 75 if (error == nil)
76 { 76 {
77 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 77 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
78 78
79 int status = [dataResult[@"status"] intValue]; 79 int status = [dataResult[@"status"] intValue];
80 if (status == 1) { // status = 1 success 80 if (status == 1) { // status = 1 success
81 NSString *token = dataResult[@"result"][@"token"]; 81 NSString *token = dataResult[@"result"][@"token"];
82 NSDictionary *dictUser = dataResult[@"result"][@"user"]; 82 NSDictionary *dictUser = dataResult[@"result"][@"user"];
83 User *user = [[User alloc] init]; 83 User *user = [[User alloc] init];
84 user.user_id = [NSString stringWithFormat:@"%@",dictUser[@"id"]]; 84 user.user_id = [NSString stringWithFormat:@"%@",dictUser[@"id"]];
85 user.username = [NSString stringWithFormat:@"%@",dictUser[@"username"]]; 85 user.username = [NSString stringWithFormat:@"%@",dictUser[@"username"]];
86 user.full_name = [NSString stringWithFormat:@"%@",dictUser[@"full_name"]]; 86 user.full_name = [NSString stringWithFormat:@"%@",dictUser[@"full_name"]];
87 user.nickname = [NSString stringWithFormat:@"%@",dictUser[@"nickname"]]; 87 user.nickname = [NSString stringWithFormat:@"%@",dictUser[@"nickname"]];
88 user.email = [NSString stringWithFormat:@"%@",dictUser[@"email"]]; 88 user.email = [NSString stringWithFormat:@"%@",dictUser[@"email"]];
89 user.password = [NSString stringWithFormat:@"%@",dictUser[@"password"]]; 89 user.password = [NSString stringWithFormat:@"%@",dictUser[@"password"]];
90 user.birthday = [NSString stringWithFormat:@"%@",dictUser[@"birthday"]]; 90 user.birthday = [NSString stringWithFormat:@"%@",dictUser[@"birthday"]];
91 user.address = [NSString stringWithFormat:@"%@",dictUser[@"address"]]; 91 user.address = [NSString stringWithFormat:@"%@",dictUser[@"address"]];
92 user.gender = [[NSString stringWithFormat:@"%@",dictUser[@"gender"]] intValue]; 92 user.gender = [[NSString stringWithFormat:@"%@",dictUser[@"gender"]] intValue];
93 user.height = [[NSString stringWithFormat:@"%@",dictUser[@"height"]] floatValue]; 93 user.height = [[NSString stringWithFormat:@"%@",dictUser[@"height"]] floatValue];
94 user.weight = [[NSString stringWithFormat:@"%@",dictUser[@"weight"]] floatValue]; 94 user.weight = [[NSString stringWithFormat:@"%@",dictUser[@"weight"]] floatValue];
95 user.user_description = [NSString stringWithFormat:@"%@",dictUser[@"description"]]; 95 user.user_description = [NSString stringWithFormat:@"%@",dictUser[@"description"]];
96 user.created_at = [NSString stringWithFormat:@"%@",dictUser[@"created_at"]]; 96 user.created_at = [NSString stringWithFormat:@"%@",dictUser[@"created_at"]];
97 user.physical_activity = [NSString stringWithFormat:@"%@",dictUser[@"physical_activity"]]; 97 user.physical_activity = [NSString stringWithFormat:@"%@",dictUser[@"physical_activity"]];
98 user.profile_image = [NSString stringWithFormat:@"%@",dictUser[@"profile_image"]]; 98 user.profile_image = [NSString stringWithFormat:@"%@",dictUser[@"profile_image"]];
99 user.updated_at = [NSString stringWithFormat:@"%@",dictUser[@"updated_at"]]; 99 user.updated_at = [NSString stringWithFormat:@"%@",dictUser[@"updated_at"]];
100 user.delete_flag = [[NSString stringWithFormat:@"%@",dictUser[@"delete_flag"]] intValue]; 100 user.delete_flag = [[NSString stringWithFormat:@"%@",dictUser[@"delete_flag"]] intValue];
101 user.fat_rate = [[NSString stringWithFormat:@"%@",dictUser[@"fat_rate"]] intValue]; 101 user.fat_rate = [[NSString stringWithFormat:@"%@",dictUser[@"fat_rate"]] intValue];
102 user.profiles_share = [[NSString stringWithFormat:@"%@",dictUser[@"profiles_share"]] intValue]; 102 user.profiles_share = [[NSString stringWithFormat:@"%@",dictUser[@"profiles_share"]] intValue];
103 user.remember_me = [[NSString stringWithFormat:@"%@",dictUser[@"remember_me"]] intValue]; 103 user.remember_me = [[NSString stringWithFormat:@"%@",dictUser[@"remember_me"]] intValue];
104 user.sound_notifications_share = [[NSString stringWithFormat:@"%@",dictUser[@"sound_notifications_share"]] intValue]; 104 user.sound_notifications_share = [[NSString stringWithFormat:@"%@",dictUser[@"sound_notifications_share"]] intValue];
105 user.spend_calo_in_day = [[NSString stringWithFormat:@"%@",dictUser[@"spend_calo_in_day"]] intValue]; 105 user.spend_calo_in_day = [[NSString stringWithFormat:@"%@",dictUser[@"spend_calo_in_day"]] intValue];
106 user.target = [[NSString stringWithFormat:@"%@",dictUser[@"target"]] intValue]; 106 user.target = [[NSString stringWithFormat:@"%@",dictUser[@"target"]] intValue];
107 completion(user, token, nil); 107 completion(user, token, nil);
108 } 108 }
109 else { // status = 0 error 109 else { // status = 0 error
110 NSString *message = dataResult[@"message"]; 110 NSString *message = dataResult[@"message"];
111 if (message == nil) { 111 if (message == nil) {
112 message = @"Unknown error"; 112 message = @"Unknown error";
113 } 113 }
114 NSError *loginFaild = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 114 NSError *loginFaild = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
115 completion(nil, nil, loginFaild); 115 completion(nil, nil, loginFaild);
116 } 116 }
117 } 117 }
118 else 118 else
119 { 119 {
120 completion(nil, nil, error); 120 completion(nil, nil, error);
121 } 121 }
122 }]; 122 }];
123 } 123 }
124 124
125 // Register 125 // Register
126 - (void)registerUserWithParams:(NSDictionary *)params CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion { 126 - (void)registerUserWithParams:(NSDictionary *)params CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion {
127 [self _request:[kServerAddress stringByAppendingFormat: @"register"] method:@"POST" token:@"" paras:params completion:^(NSData *data, NSError *error) { 127 [self _request:[kServerAddress stringByAppendingFormat: @"register"] method:@"POST" token:@"" paras:params completion:^(NSData *data, NSError *error) {
128 128
129 if (completion == NULL) { 129 if (completion == NULL) {
130 return ; 130 return ;
131 } 131 }
132 132
133 if (error == nil) 133 if (error == nil)
134 { 134 {
135 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 135 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
136 136
137 int status = [dataResult[@"status"] intValue]; 137 int status = [dataResult[@"status"] intValue];
138 if (status == 1) { // status = 1 success 138 if (status == 1) { // status = 1 success
139 NSString *token = dataResult[@"result"][@"token"]; 139 NSString *token = dataResult[@"result"][@"token"];
140 NSDictionary *dictUser = dataResult[@"result"][@"user"]; 140 NSDictionary *dictUser = dataResult[@"result"][@"user"];
141 User *user = [[User alloc] init]; 141 User *user = [[User alloc] init];
142 user.user_id = [NSString stringWithFormat:@"%@",dictUser[@"id"]]; 142 user.user_id = [NSString stringWithFormat:@"%@",dictUser[@"id"]];
143 user.username = [NSString stringWithFormat:@"%@",dictUser[@"username"]]; 143 user.username = [NSString stringWithFormat:@"%@",dictUser[@"username"]];
144 user.full_name = [NSString stringWithFormat:@"%@",dictUser[@"full_name"]]; 144 user.full_name = [NSString stringWithFormat:@"%@",dictUser[@"full_name"]];
145 user.nickname = [NSString stringWithFormat:@"%@",dictUser[@"nickname"]]; 145 user.nickname = [NSString stringWithFormat:@"%@",dictUser[@"nickname"]];
146 user.email = [NSString stringWithFormat:@"%@",dictUser[@"email"]]; 146 user.email = [NSString stringWithFormat:@"%@",dictUser[@"email"]];
147 user.password = [NSString stringWithFormat:@"%@",dictUser[@"password"]]; 147 user.password = [NSString stringWithFormat:@"%@",dictUser[@"password"]];
148 user.birthday = [NSString stringWithFormat:@"%@",dictUser[@"birthday"]]; 148 user.birthday = [NSString stringWithFormat:@"%@",dictUser[@"birthday"]];
149 user.address = [NSString stringWithFormat:@"%@",dictUser[@"address"]]; 149 user.address = [NSString stringWithFormat:@"%@",dictUser[@"address"]];
150 user.gender = [[NSString stringWithFormat:@"%@",dictUser[@"gender"]] intValue]; 150 user.gender = [[NSString stringWithFormat:@"%@",dictUser[@"gender"]] intValue];
151 user.height = [[NSString stringWithFormat:@"%@",dictUser[@"height"]] floatValue]; 151 user.height = [[NSString stringWithFormat:@"%@",dictUser[@"height"]] floatValue];
152 user.weight = [[NSString stringWithFormat:@"%@",dictUser[@"weight"]] floatValue]; 152 user.weight = [[NSString stringWithFormat:@"%@",dictUser[@"weight"]] floatValue];
153 user.user_description = [NSString stringWithFormat:@"%@",dictUser[@"description"]]; 153 user.user_description = [NSString stringWithFormat:@"%@",dictUser[@"description"]];
154 user.created_at = [NSString stringWithFormat:@"%@",dictUser[@"created_at"]]; 154 user.created_at = [NSString stringWithFormat:@"%@",dictUser[@"created_at"]];
155 user.physical_activity = [NSString stringWithFormat:@"%@",dictUser[@"physical_activity"]]; 155 user.physical_activity = [NSString stringWithFormat:@"%@",dictUser[@"physical_activity"]];
156 user.profile_image = [NSString stringWithFormat:@"%@",dictUser[@"profile_image"]]; 156 user.profile_image = [NSString stringWithFormat:@"%@",dictUser[@"profile_image"]];
157 user.updated_at = [NSString stringWithFormat:@"%@",dictUser[@"updated_at"]]; 157 user.updated_at = [NSString stringWithFormat:@"%@",dictUser[@"updated_at"]];
158 user.delete_flag = [[NSString stringWithFormat:@"%@",dictUser[@"delete_flag"]] intValue]; 158 user.delete_flag = [[NSString stringWithFormat:@"%@",dictUser[@"delete_flag"]] intValue];
159 user.fat_rate = [[NSString stringWithFormat:@"%@",dictUser[@"fat_rate"]] intValue]; 159 user.fat_rate = [[NSString stringWithFormat:@"%@",dictUser[@"fat_rate"]] intValue];
160 user.profiles_share = [[NSString stringWithFormat:@"%@",dictUser[@"profiles_share"]] intValue]; 160 user.profiles_share = [[NSString stringWithFormat:@"%@",dictUser[@"profiles_share"]] intValue];
161 user.remember_me = [[NSString stringWithFormat:@"%@",dictUser[@"remember_me"]] intValue]; 161 user.remember_me = [[NSString stringWithFormat:@"%@",dictUser[@"remember_me"]] intValue];
162 user.sound_notifications_share = [[NSString stringWithFormat:@"%@",dictUser[@"sound_notifications_share"]] intValue]; 162 user.sound_notifications_share = [[NSString stringWithFormat:@"%@",dictUser[@"sound_notifications_share"]] intValue];
163 user.spend_calo_in_day = [[NSString stringWithFormat:@"%@",dictUser[@"spend_calo_in_day"]] intValue]; 163 user.spend_calo_in_day = [[NSString stringWithFormat:@"%@",dictUser[@"spend_calo_in_day"]] intValue];
164 user.target = [[NSString stringWithFormat:@"%@",dictUser[@"target"]] intValue]; 164 user.target = [[NSString stringWithFormat:@"%@",dictUser[@"target"]] intValue];
165 completion(user, token, nil); 165 completion(user, token, nil);
166 } 166 }
167 else { // status = 0 error 167 else { // status = 0 error
168 NSString *message = dataResult[@"message"]; 168 NSString *message = dataResult[@"message"];
169 if (message == nil) { 169 if (message == nil) {
170 message = @"Unknown error"; 170 message = @"Unknown error";
171 } 171 }
172 NSError *loginFaild = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 172 NSError *loginFaild = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
173 completion(nil, nil, loginFaild); 173 completion(nil, nil, loginFaild);
174 } 174 }
175 } 175 }
176 else 176 else
177 { 177 {
178 completion(nil, nil, error); 178 completion(nil, nil, error);
179 } 179 }
180 }]; 180 }];
181 } 181 }
182 182
183 - (void)forgetPass:(NSString *)email CompletionHandler:(void (^)(NSError *)) completion { 183 - (void)forgetPass:(NSString *)email CompletionHandler:(void (^)(NSError *)) completion {
184 [self _request:[kServerAddress stringByAppendingFormat: @"forgetPass"] method:@"POST" token:@"" paras:@{@"email":email} completion:^(NSData *data, NSError *error) { 184 [self _request:[kServerAddress stringByAppendingFormat: @"forgetPass"] method:@"POST" token:@"" paras:@{@"email":email} completion:^(NSData *data, NSError *error) {
185 185
186 if (completion == NULL) { 186 if (completion == NULL) {
187 return ; 187 return ;
188 } 188 }
189 189
190 if (error == nil) 190 if (error == nil)
191 { 191 {
192 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 192 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
193 193
194 int status = [dataResult[@"status"] intValue]; 194 int status = [dataResult[@"status"] intValue];
195 if (status == 1) { // status = 1 success 195 if (status == 1) { // status = 1 success
196 completion(nil); 196 completion(nil);
197 } 197 }
198 else { // status = 0 error 198 else { // status = 0 error
199 NSString *message = dataResult[@"message"]; 199 NSString *message = dataResult[@"message"];
200 if (message == nil) { 200 if (message == nil) {
201 message = @"Unknown error"; 201 message = @"Unknown error";
202 } 202 }
203 NSError *forgetPass = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 203 NSError *forgetPass = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
204 completion(forgetPass); 204 completion(forgetPass);
205 } 205 }
206 } 206 }
207 else 207 else
208 { 208 {
209 completion(error); 209 completion(error);
210 } 210 }
211 }]; 211 }];
212 } 212 }
213 - (void)confirmForgetPass:(NSString *)email withConfirm:(NSString *)confirm CompletionHandler:(void (^)(NSError *)) completion { 213 - (void)confirmForgetPass:(NSString *)email withConfirm:(NSString *)confirm CompletionHandler:(void (^)(NSError *)) completion {
214 [self _request:[kServerAddress stringByAppendingFormat: @"forgetPass/confirm"] method:@"POST" token:@"" paras:@{@"email":email, @"code_confirm": confirm} completion:^(NSData *data, NSError *error) { 214 [self _request:[kServerAddress stringByAppendingFormat: @"forgetPass/confirm"] method:@"POST" token:@"" paras:@{@"email":email, @"code_confirm": confirm} completion:^(NSData *data, NSError *error) {
215 215
216 if (completion == NULL) { 216 if (completion == NULL) {
217 return ; 217 return ;
218 } 218 }
219 219
220 if (error == nil) 220 if (error == nil)
221 { 221 {
222 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 222 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
223 223
224 int status = [dataResult[@"status"] intValue]; 224 int status = [dataResult[@"status"] intValue];
225 if (status == 1) { // status = 1 success 225 if (status == 1) { // status = 1 success
226 completion(nil); 226 completion(nil);
227 } 227 }
228 else { // status = 0 error 228 else { // status = 0 error
229 NSString *message = dataResult[@"message"]; 229 NSString *message = dataResult[@"message"];
230 NSError *confirmForgetPass = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 230 NSError *confirmForgetPass = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
231 completion(confirmForgetPass); 231 completion(confirmForgetPass);
232 } 232 }
233 } 233 }
234 else 234 else
235 { 235 {
236 completion(error); 236 completion(error);
237 } 237 }
238 }]; 238 }];
239 } 239 }
240 240
241 - (void)uploadImage:(NSString *)token andImageData:(NSData *)data CompletionHandler:(void (^)(NSString *, NSError *)) completion { 241 - (void)uploadImage:(NSString *)token andImageData:(NSData *)data CompletionHandler:(void (^)(NSString *, NSError *)) completion {
242 NSDictionary *dict = nil; 242 NSDictionary *dict = nil;
243 NSString *base64Encoded = [data base64EncodedStringWithOptions:0]; 243 NSString *base64Encoded = [data base64EncodedStringWithOptions:0];
244 if (token != nil) { 244 if (token != nil) {
245 dict = @{@"token":token, @"img": base64Encoded}; 245 dict = @{@"token":token, @"img": base64Encoded};
246 } 246 }
247 else { 247 else {
248 dict = @{@"img": base64Encoded}; 248 dict = @{@"img": base64Encoded};
249 } 249 }
250 [self _request:[kServerAddress stringByAppendingFormat: @"upload-image"] method:@"POST" token:token paras:dict completion:^(NSData *data, NSError *error) { 250 [self _request:[kServerAddress stringByAppendingFormat: @"upload-image"] method:@"POST" token:token paras:dict completion:^(NSData *data, NSError *error) {
251 251
252 if (completion == NULL) { 252 if (completion == NULL) {
253 return ; 253 return ;
254 } 254 }
255 255
256 if (error == nil) 256 if (error == nil)
257 { 257 {
258 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 258 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
259 NSString *image_profile = [NSString stringWithFormat:@"%@", dataResult[@"message"]]; 259 NSString *image_profile = [NSString stringWithFormat:@"%@", dataResult[@"message"]];
260 completion(image_profile, nil); 260 completion(image_profile, nil);
261 } 261 }
262 else 262 else
263 { 263 {
264 completion(nil, error); 264 completion(nil, error);
265 } 265 }
266 }]; 266 }];
267 } 267 }
268 268
269 -(NSString *) convertIntToString : (int) type { 269 -(NSString *) convertIntToString : (int) type {
270 switch (type) { 270 switch (type) {
271 case 1: 271 case 1:
272 return @"week"; 272 return @"week";
273 break; 273 break;
274 case 2: 274 case 2:
275 return @"oneMonth"; 275 return @"oneMonth";
276 break; 276 break;
277 case 3: 277 case 3:
278 return @"threeMonth"; 278 return @"threeMonth";
279 break; 279 break;
280 case 4: 280 case 4:
281 return @"sixMonth"; 281 return @"sixMonth";
282 break; 282 break;
283 default: 283 default:
284 return @"today"; 284 return @"today";
285 break; 285 break;
286 } 286 }
287 } 287 }
288 288
289 #pragma mark - Home Screen Function 289 #pragma mark - Home Screen Function
290 - (void)requestTopWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(TopObject *, NSError *)) completion 290 - (void)requestTopWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(TopObject *, NSError *)) completion
291 { 291 {
292 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 292 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
293 NSString *url = [kServerAddress stringByAppendingFormat:@"api/top/%d/%@", mode, date]; 293 NSString *url = [kServerAddress stringByAppendingFormat:@"api/top/%d/%@", mode, date];
294 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 294 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
295 295
296 if (completion == NULL) { 296 if (completion == NULL) {
297 return ; 297 return ;
298 } 298 }
299 299
300 if (error == nil) 300 if (error == nil)
301 { 301 {
302 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 302 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
303 int status = [dataResult[@"status"] intValue]; 303 int status = [dataResult[@"status"] intValue];
304 if (status == 1) { // status = 1 success 304 if (status == 1) { // status = 1 success
305 if(dataResult[@"result"] != nil) { 305 if(dataResult[@"result"] != nil) {
306 NSDictionary * dictResult = dataResult[@"result"]; 306 NSDictionary * dictResult = dataResult[@"result"];
307 TopObject *topObject = [[TopObject alloc] init]; 307 TopObject *topObject = [[TopObject alloc] init];
308 TargetInfor *targetInfor = [[TargetInfor alloc] initWithData:dictResult[@"targetInf"]]; 308 TargetInfor *targetInfor = [[TargetInfor alloc] initWithData:dictResult[@"targetInf"]];
309 topObject.targetInfor = targetInfor; 309 topObject.targetInfor = targetInfor;
310 topObject.kcal = [[NSString stringWithFormat:@"%@", dictResult[@"kcal"]] intValue]; 310 topObject.kcal = [[NSString stringWithFormat:@"%@", dictResult[@"kcal"]] intValue];
311 topObject.distance = [[NSString stringWithFormat:@"%@", dictResult[@"distance"]] floatValue]; 311 topObject.distance = [[NSString stringWithFormat:@"%@", dictResult[@"distance"]] floatValue];
312 topObject.time = [NSString stringWithFormat:@"%@", dictResult[@"time"]]; 312 topObject.time = [NSString stringWithFormat:@"%@", dictResult[@"time"]];
313 NSMutableArray *arrayStep = [[NSMutableArray alloc] init]; 313 NSMutableArray *arrayStep = [[NSMutableArray alloc] init];
314 NSArray *array = dictResult[@"dataChart"]; 314 NSArray *array = dictResult[@"dataChart"];
315 for(NSDictionary *dict in array) { 315 for(NSDictionary *dict in array) {
316 StepObject *object = [[StepObject alloc] init]; 316 StepObject *object = [[StepObject alloc] init];
317 if([dict objectForKey:@"numStep"] != nil) { 317 if([dict objectForKey:@"numStep"] != nil) {
318 object.step = [dict[@"numStep"] intValue]; 318 object.step = [dict[@"numStep"] intValue];
319 } 319 }
320 if([dict objectForKey:@"hour"] != nil) { 320 if([dict objectForKey:@"hour"] != nil) {
321 object.hour = [dict[@"hour"] intValue]; 321 object.hour = [dict[@"hour"] intValue];
322 } 322 }
323 switch (mode) { 323 switch (mode) {
324 case 1: 324 case 1:
325 object.typeStep = @"walking"; 325 object.typeStep = @"walking";
326 break; 326 break;
327 case 2: 327 case 2:
328 object.typeStep = @"running"; 328 object.typeStep = @"running";
329 break; 329 break;
330 case 3: 330 case 3:
331 object.typeStep = @"bike"; 331 object.typeStep = @"bike";
332 break; 332 break;
333 default: 333 default:
334 break; 334 break;
335 } 335 }
336 [arrayStep addObject:object]; 336 [arrayStep addObject:object];
337 } 337 }
338 topObject.dataChart = [[NSMutableArray alloc] initWithArray:arrayStep]; 338 topObject.dataChart = [[NSMutableArray alloc] initWithArray:arrayStep];
339 completion(topObject, nil); 339 completion(topObject, nil);
340 } 340 }
341 else { 341 else {
342 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 342 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
343 completion(nil, errorObject); 343 completion(nil, errorObject);
344 } 344 }
345 } 345 }
346 else { 346 else {
347 NSString *message = dataResult[@"message"]; 347 NSString *message = dataResult[@"message"];
348 if (message == nil) { 348 if (message == nil) {
349 message = @"Unknown error"; 349 message = @"Unknown error";
350 } 350 }
351 351
352 if ([message isEqualToString:@"Token is invalid"]) { 352 if ([message isEqualToString:@"Token is invalid"]) {
353 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 353 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
354 if (error == nil) { 354 if (error == nil) {
355 [self requestTopWithMode:mode andDate:date CompletionHandler:completion]; 355 [self requestTopWithMode:mode andDate:date CompletionHandler:completion];
356 } 356 }
357 else { 357 else {
358 completion(nil, error); 358 completion(nil, error);
359 } 359 }
360 }]; 360 }];
361 } 361 }
362 else { 362 else {
363 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 363 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
364 completion(nil, errorObject); 364 completion(nil, errorObject);
365 } 365 }
366 } 366 }
367 } 367 }
368 else 368 else
369 { 369 {
370 completion(nil, error); 370 completion(nil, error);
371 } 371 }
372 }]; 372 }];
373 } 373 }
374 374
375 - (void)requestHomeWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(HomeObject *, NSError *)) completion 375 - (void)requestHomeWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(HomeObject *, NSError *)) completion
376 { 376 {
377 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 377 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
378 NSString *url = [kServerAddress stringByAppendingFormat:@"api/home/%d/%@", mode, date]; 378 NSString *url = [kServerAddress stringByAppendingFormat:@"api/home/%d/%@", mode, date];
379 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 379 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
380 380
381 if (completion == NULL) { 381 if (completion == NULL) {
382 return ; 382 return ;
383 } 383 }
384 384
385 if (error == nil) 385 if (error == nil)
386 { 386 {
387 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 387 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
388 int status = [dataResult[@"status"] intValue]; 388 int status = [dataResult[@"status"] intValue];
389 if (status == 1) { // status = 1 success 389 if (status == 1) { // status = 1 success
390 if(dataResult[@"result"] != nil) { 390 if(dataResult[@"result"] != nil) {
391 NSDictionary * dictResult = dataResult[@"result"]; 391 NSDictionary * dictResult = dataResult[@"result"];
392 HomeObject *homeObject = [[HomeObject alloc] init]; 392 HomeObject *homeObject = [[HomeObject alloc] init];
393 TargetInfor *targetInfor = [[TargetInfor alloc] initWithData:dictResult[@"targetInf"]]; 393 TargetInfor *targetInfor = [[TargetInfor alloc] initWithData:dictResult[@"targetInf"]];
394 homeObject.targetInfor = targetInfor; 394 homeObject.targetInfor = targetInfor;
395 NSMutableArray *arrayNotice = [[NSMutableArray alloc] init]; 395 NSMutableArray *arrayNotice = [[NSMutableArray alloc] init];
396 NSArray *array = dictResult[@"listNotice"]; 396 NSArray *array = dictResult[@"listNotice"];
397 for(NSDictionary *dict in array) { 397 for(NSDictionary *dict in array) {
398 NoticeInfor *object = [[NoticeInfor alloc] initWithData:dict]; 398 NoticeInfor *object = [[NoticeInfor alloc] initWithData:dict];
399 [arrayNotice addObject:object]; 399 [arrayNotice addObject:object];
400 } 400 }
401 homeObject.listNotice = [[NSMutableArray alloc] initWithArray:arrayNotice]; 401 homeObject.listNotice = [[NSMutableArray alloc] initWithArray:arrayNotice];
402 completion(homeObject, nil); 402 completion(homeObject, nil);
403 } 403 }
404 else { 404 else {
405 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 405 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
406 completion(nil, errorObject); 406 completion(nil, errorObject);
407 } 407 }
408 } 408 }
409 else { 409 else {
410 NSString *message = dataResult[@"message"]; 410 NSString *message = dataResult[@"message"];
411 if (message == nil) { 411 if (message == nil) {
412 message = @"Unknown error"; 412 message = @"Unknown error";
413 } 413 }
414 414
415 if ([message isEqualToString:@"Token is invalid"]) { 415 if ([message isEqualToString:@"Token is invalid"]) {
416 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 416 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
417 if (error == nil) { 417 if (error == nil) {
418 [self requestHomeWithMode:mode andDate:date CompletionHandler:completion]; 418 [self requestHomeWithMode:mode andDate:date CompletionHandler:completion];
419 } 419 }
420 else { 420 else {
421 completion(nil, error); 421 completion(nil, error);
422 } 422 }
423 }]; 423 }];
424 } 424 }
425 else { 425 else {
426 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 426 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
427 completion(nil, errorObject); 427 completion(nil, errorObject);
428 } 428 }
429 } 429 }
430 } 430 }
431 else 431 else
432 { 432 {
433 completion(nil, error); 433 completion(nil, error);
434 } 434 }
435 }]; 435 }];
436 } 436 }
437 437
438 - (void)requestCreateLog:(int)mode withStep:(int)numStep startDate:(NSString *)startDate endDate:(NSString *)endDate CompletionHandler:(void (^)(NSError *))completion { 438 - (void)requestCreateLog:(int)mode withStep:(int)numStep startDate:(NSString *)startDate endDate:(NSString *)endDate CompletionHandler:(void (^)(NSError *))completion {
439 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 439 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
440 NSString *url = [kServerAddress stringByAppendingFormat:@"api/createLog"]; 440 NSString *url = [kServerAddress stringByAppendingFormat:@"api/createLog"];
441 NSDictionary *dict = @{@"mode": [NSNumber numberWithInt:mode], @"numStep": [NSNumber numberWithInt:numStep], @"startTime": startDate, @"endTime": endDate}; 441 NSDictionary *dict = @{@"mode": [NSNumber numberWithInt:mode], @"numStep": [NSNumber numberWithInt:numStep], @"startTime": startDate, @"endTime": endDate};
442 [self _request:url method:@"POST" token:token paras:dict completion:^(NSData *data, NSError *error) { 442 [self _request:url method:@"POST" token:token paras:dict completion:^(NSData *data, NSError *error) {
443 443
444 if (completion == NULL) { 444 if (completion == NULL) {
445 return ; 445 return ;
446 } 446 }
447 447
448 if (error == nil) 448 if (error == nil)
449 { 449 {
450 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 450 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
451 int status = [dataResult[@"status"] intValue]; 451 int status = [dataResult[@"status"] intValue];
452 if (status == 1) { // status = 1 success 452 if (status == 1) { // status = 1 success
453 completion(nil); 453 completion(nil);
454 } 454 }
455 else { 455 else {
456 NSString *message = dataResult[@"message"]; 456 NSString *message = dataResult[@"message"];
457 if (message == nil) { 457 if (message == nil) {
458 message = @"Unknown error"; 458 message = @"Unknown error";
459 } 459 }
460 460
461 if ([message isEqualToString:@"Token is invalid"]) { 461 if ([message isEqualToString:@"Token is invalid"]) {
462 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 462 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
463 if (error == nil) { 463 if (error == nil) {
464 [self requestCreateLog:mode withStep:numStep startDate:startDate endDate:endDate CompletionHandler:completion]; 464 [self requestCreateLog:mode withStep:numStep startDate:startDate endDate:endDate CompletionHandler:completion];
465 } 465 }
466 else { 466 else {
467 completion(error); 467 completion(error);
468 } 468 }
469 }]; 469 }];
470 } 470 }
471 else { 471 else {
472 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 472 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
473 completion(errorObject); 473 completion(errorObject);
474 } 474 }
475 } 475 }
476 } 476 }
477 else 477 else
478 { 478 {
479 completion(error); 479 completion(error);
480 } 480 }
481 }]; 481 }];
482 } 482 }
483 483
484 #pragma mark - History Screen Function 484 #pragma mark - History Screen Function
485 - (void) requestHistory:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion { 485 - (void) requestHistory:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion {
486 NSString *url = [kServerAddress stringByAppendingFormat:@"api/history/%@/%@", [Utilities stringFromDate:startDate withFormat:@"YYYYMMdd" locale:@""], [Utilities stringFromDate:endDate withFormat:@"YYYYMMdd" locale:@""]]; 486 NSString *url = [kServerAddress stringByAppendingFormat:@"api/history/%@/%@", [Utilities stringFromDate:startDate withFormat:@"YYYYMMdd" locale:@""], [Utilities stringFromDate:endDate withFormat:@"YYYYMMdd" locale:@""]];
487 NSLog(@"requestHistory link %@", url); 487 NSLog(@"requestHistory link %@", url);
488 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 488 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
489 489
490 if (completion == NULL) { 490 if (completion == NULL) {
491 return ; 491 return ;
492 } 492 }
493 493
494 if (error == nil) 494 if (error == nil)
495 { 495 {
496 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 496 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
497 NSLog(@"%@", dataResult); 497 NSLog(@"%@", dataResult);
498 int status = [dataResult[@"status"] intValue]; 498 int status = [dataResult[@"status"] intValue];
499 if (status == 1) { // status = 1 success 499 if (status == 1) { // status = 1 success
500 NSMutableArray * arrayHistory = [[NSMutableArray alloc] init]; 500 NSMutableArray * arrayHistory = [[NSMutableArray alloc] init];
501 NSDictionary * arrResult = dataResult[@"result"]; 501 NSDictionary * arrResult = dataResult[@"result"];
502 if(arrResult != nil) { 502 if(arrResult != nil) {
503 /* mode_1: Data for mode walking 503 /* mode_1: Data for mode walking
504 mode_2: Data for mode running 504 mode_2: Data for mode running
505 mode_3: Data for mode bike */ 505 mode_3: Data for mode bike */
506 NSArray *arrayKey = [NSArray arrayWithObjects:@"mode_3", @"mode_1", @"mode_2", nil]; 506 NSArray *arrayKey = [NSArray arrayWithObjects:@"mode_3", @"mode_1", @"mode_2", nil];
507 for(NSString * key in arrayKey) { 507 for(NSString * key in arrayKey) {
508 NSDictionary *mode = [arrResult objectForKey:key]; 508 NSDictionary *mode = [arrResult objectForKey:key];
509 if(![[arrResult objectForKey:key] isKindOfClass:[NSNull class]]) { 509 if(![[arrResult objectForKey:key] isKindOfClass:[NSNull class]]) {
510 HistoryObject * objectMode = [[HistoryObject alloc] initWithData:mode]; 510 HistoryObject * objectMode = [[HistoryObject alloc] initWithData:mode];
511 [arrayHistory addObject:objectMode]; 511 [arrayHistory addObject:objectMode];
512 } 512 }
513 else { 513 else {
514 [arrayHistory addObject:[[HistoryObject alloc] init]]; 514 [arrayHistory addObject:[[HistoryObject alloc] init]];
515 } 515 }
516 } 516 }
517 } 517 }
518 completion(arrayHistory, nil); 518 completion(arrayHistory, nil);
519 } 519 }
520 else { 520 else {
521 NSString *message = dataResult[@"message"]; 521 NSString *message = dataResult[@"message"];
522 if (message == nil) { 522 if (message == nil) {
523 message = @"Unknown error"; 523 message = @"Unknown error";
524 } 524 }
525 525
526 if ([message isEqualToString:@"Token is invalid"]) { 526 if ([message isEqualToString:@"Token is invalid"]) {
527 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 527 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
528 if (error == nil) { 528 if (error == nil) {
529 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 529 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
530 [self requestHistory:tokenNew startDate:startDate endDate:endDate CompletionHandler:completion]; 530 [self requestHistory:tokenNew startDate:startDate endDate:endDate CompletionHandler:completion];
531 } 531 }
532 else { 532 else {
533 completion(nil, error); 533 completion(nil, error);
534 } 534 }
535 }]; 535 }];
536 } 536 }
537 else { 537 else {
538 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 538 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
539 completion(nil, errorObject); 539 completion(nil, errorObject);
540 } 540 }
541 } 541 }
542 } 542 }
543 else 543 else
544 { 544 {
545 completion(nil, error); 545 completion(nil, error);
546 } 546 }
547 }]; 547 }];
548 } 548 }
549 549
550 - (void) requestHistoryList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion { 550 - (void) requestHistoryList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion {
551 NSString *url = [kServerAddress stringByAppendingFormat:@"api/history/detail/%@/%@", [Utilities stringFromDate:startDate withFormat:@"YYYYMMdd" locale:@""], [Utilities stringFromDate:endDate withFormat:@"YYYYMMdd" locale:@""]]; 551 NSString *url = [kServerAddress stringByAppendingFormat:@"api/history/detail/%@/%@", [Utilities stringFromDate:startDate withFormat:@"YYYYMMdd" locale:@""], [Utilities stringFromDate:endDate withFormat:@"YYYYMMdd" locale:@""]];
552 NSLog(@"requestHistoryList link %@", url); 552 NSLog(@"requestHistoryList link %@", url);
553 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 553 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
554 554
555 if (completion == NULL) { 555 if (completion == NULL) {
556 return ; 556 return ;
557 } 557 }
558 558
559 if (error == nil) 559 if (error == nil)
560 { 560 {
561 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 561 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
562 NSLog(@"%@", dataResult); 562 NSLog(@"%@", dataResult);
563 int status = [dataResult[@"status"] intValue]; 563 int status = [dataResult[@"status"] intValue];
564 if (status == 1) { // status = 1 success 564 if (status == 1) { // status = 1 success
565 if(dataResult[@"result"] != nil) { 565 if(dataResult[@"result"] != nil) {
566 NSMutableArray * arrayHistory = [[NSMutableArray alloc] init]; 566 NSMutableArray * arrayHistory = [[NSMutableArray alloc] init];
567 NSDictionary * arrResult = dataResult[@"result"]; 567 NSDictionary * arrResult = dataResult[@"result"];
568 if(arrResult != nil) { 568 if(arrResult != nil) {
569 /* mode_1: Data for mode walking 569 /* mode_1: Data for mode walking
570 mode_2: Data for mode running 570 mode_2: Data for mode running
571 mode_3: Data for mode bike */ 571 mode_3: Data for mode bike */
572 NSArray *arrayKey = [NSArray arrayWithObjects:@"mode_3", @"mode_1", @"mode_2", nil]; 572 NSArray *arrayKey = [NSArray arrayWithObjects:@"mode_3", @"mode_1", @"mode_2", nil];
573 for(NSString * key in arrayKey) { 573 for(NSString * key in arrayKey) {
574 NSDictionary *mode = [arrResult objectForKey:key]; 574 NSDictionary *mode = [arrResult objectForKey:key];
575 if(![[arrResult objectForKey:key] isKindOfClass:[NSNull class]]) { 575 if(![[arrResult objectForKey:key] isKindOfClass:[NSNull class]]) {
576 NSMutableArray *array = [[NSMutableArray alloc] init]; 576 NSMutableArray *array = [[NSMutableArray alloc] init];
577 for(NSString *key in mode.allKeys) { 577 for(NSString *key in mode.allKeys) {
578 HistoryObject * objectMode = [[HistoryObject alloc] initWithData:mode[key]]; 578 HistoryObject * objectMode = [[HistoryObject alloc] initWithData:mode[key]];
579 objectMode.date = [Utilities dateFromString:key withFormat:@"yyyy-MM-dd"]; 579 objectMode.date = [Utilities dateFromString:key withFormat:@"yyyy-MM-dd"];
580 [array addObject:objectMode]; 580 [array addObject:objectMode];
581 } 581 }
582 [arrayHistory addObject:array]; 582 [arrayHistory addObject:array];
583 } 583 }
584 else { 584 else {
585 [arrayHistory addObject:[[NSArray alloc] init]]; 585 [arrayHistory addObject:[[NSArray alloc] init]];
586 } 586 }
587 } 587 }
588 } 588 }
589 completion(arrayHistory, nil); 589 completion(arrayHistory, nil);
590 } 590 }
591 else { 591 else {
592 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 592 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
593 completion(nil, errorObject); 593 completion(nil, errorObject);
594 } 594 }
595 } 595 }
596 else { 596 else {
597 NSString *message = dataResult[@"message"]; 597 NSString *message = dataResult[@"message"];
598 if (message == nil) { 598 if (message == nil) {
599 message = @"Unknown error"; 599 message = @"Unknown error";
600 } 600 }
601 601
602 if ([message isEqualToString:@"Token is invalid"]) { 602 if ([message isEqualToString:@"Token is invalid"]) {
603 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 603 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
604 if (error == nil) { 604 if (error == nil) {
605 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 605 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
606 [self requestHistoryList:tokenNew startDate:startDate endDate:endDate CompletionHandler:completion]; 606 [self requestHistoryList:tokenNew startDate:startDate endDate:endDate CompletionHandler:completion];
607 } 607 }
608 else { 608 else {
609 completion(nil, error); 609 completion(nil, error);
610 } 610 }
611 }]; 611 }];
612 } 612 }
613 else { 613 else {
614 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 614 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
615 completion(nil, errorObject); 615 completion(nil, errorObject);
616 } 616 }
617 } 617 }
618 } 618 }
619 else 619 else
620 { 620 {
621 completion(nil, error); 621 completion(nil, error);
622 } 622 }
623 }]; 623 }];
624 } 624 }
625 625
626 #pragma mark - SNS Screen Function 626 #pragma mark - SNS Screen Function
627 - (void) requestTweetsList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion { 627 - (void) requestTweetsList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion {
628 NSString *url = [kServerAddress stringByAppendingFormat:@"api/tweet/list?page=%d&record=10", page]; 628 NSString *url = [kServerAddress stringByAppendingFormat:@"api/tweet/list?page=%d&record=10", page];
629 if(groupID > -1) { 629 if(groupID > -1) {
630 url = [kServerAddress stringByAppendingFormat:@"api/tweet/list?group_id=%d&page=%d&record=10", groupID, page]; 630 url = [kServerAddress stringByAppendingFormat:@"api/tweet/list?group_id=%d&page=%d&record=10", groupID, page];
631 } 631 }
632 NSLog(@"requestTweetsList link %@", url); 632 NSLog(@"requestTweetsList link %@", url);
633 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 633 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
634 634
635 if (completion == NULL) { 635 if (completion == NULL) {
636 return ; 636 return ;
637 } 637 }
638 638
639 if (error == nil) 639 if (error == nil)
640 { 640 {
641 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 641 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
642 NSLog(@"%@", dataResult); 642 NSLog(@"%@", dataResult);
643 int status = [dataResult[@"status"] intValue]; 643 int status = [dataResult[@"status"] intValue];
644 if (status == 1) { // status = 1 success 644 if (status == 1) { // status = 1 success
645 if(dataResult[@"result"] != nil) { 645 if(dataResult[@"result"] != nil) {
646 NSArray * array = dataResult[@"result"]; 646 NSArray * array = dataResult[@"result"];
647 NSMutableArray * arrayTweets = [[NSMutableArray alloc] init]; 647 NSMutableArray * arrayTweets = [[NSMutableArray alloc] init];
648 for(NSDictionary * dict in array) { 648 for(NSDictionary * dict in array) {
649 TweetObject * object = [[TweetObject alloc] initWithData:dict]; 649 TweetObject * object = [[TweetObject alloc] initWithData:dict];
650 [arrayTweets addObject:object]; 650 [arrayTweets addObject:object];
651 } 651 }
652 completion(arrayTweets, nil); 652 completion(arrayTweets, nil);
653 } 653 }
654 else { 654 else {
655 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 655 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
656 completion(nil, errorObject); 656 completion(nil, errorObject);
657 } 657 }
658 } 658 }
659 else { 659 else {
660 NSString *message = dataResult[@"message"]; 660 NSString *message = dataResult[@"message"];
661 if (message == nil) { 661 if (message == nil) {
662 message = @"Unknown error"; 662 message = @"Unknown error";
663 } 663 }
664 664
665 if ([message isEqualToString:@"Token is invalid"]) { 665 if ([message isEqualToString:@"Token is invalid"]) {
666 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 666 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
667 if (error == nil) { 667 if (error == nil) {
668 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 668 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
669 [self requestTweetsList:tokenNew groupID:groupID withPage:page CompletionHandler:completion]; 669 [self requestTweetsList:tokenNew groupID:groupID withPage:page CompletionHandler:completion];
670 } 670 }
671 else { 671 else {
672 completion(nil, error); 672 completion(nil, error);
673 } 673 }
674 }]; 674 }];
675 } 675 }
676 else { 676 else {
677 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 677 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
678 completion(nil, errorObject); 678 completion(nil, errorObject);
679 } 679 }
680 } 680 }
681 } 681 }
682 else 682 else
683 { 683 {
684 completion(nil, error); 684 completion(nil, error);
685 } 685 }
686 }]; 686 }];
687 } 687 }
688 688
689 - (void) searchGroup:(NSString *)token withKey:(NSString *)key andPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion { 689 - (void) searchGroup:(NSString *)token withKey:(NSString *)key andPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion {
690 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/search"]; 690 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/search"];
691 NSLog(@"searchGroup link %@ page %d", url, page); 691 NSLog(@"searchGroup link %@ page %d", url, page);
692 if(searchTask != nil) { 692 if(searchTask != nil) {
693 [searchTask cancel]; 693 [searchTask cancel];
694 } 694 }
695 695
696 searchTask = [self _request:url method:@"POST" token:token paras:@{@"keyword":key, @"page": [NSNumber numberWithInt:page]} completion:^(NSData *data, NSError *error) { 696 searchTask = [self _request:url method:@"POST" token:token paras:@{@"keyword":key, @"page": [NSNumber numberWithInt:page]} completion:^(NSData *data, NSError *error) {
697 searchTask = nil; 697 searchTask = nil;
698 if (completion == NULL) { 698 if (completion == NULL) {
699 return ; 699 return ;
700 } 700 }
701 701
702 if (error == nil) 702 if (error == nil)
703 { 703 {
704 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 704 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
705 NSLog(@"%@", dataResult); 705 NSLog(@"%@", dataResult);
706 int status = [dataResult[@"status"] intValue]; 706 int status = [dataResult[@"status"] intValue];
707 if (status == 1) { // status = 1 success 707 if (status == 1) { // status = 1 success
708 if(dataResult[@"result"] != nil) { 708 if(dataResult[@"result"] != nil) {
709 NSArray * array = dataResult[@"result"]; 709 NSArray * array = dataResult[@"result"];
710 NSMutableArray * arrayTweets = [[NSMutableArray alloc] init]; 710 NSMutableArray * arrayTweets = [[NSMutableArray alloc] init];
711 for(NSDictionary * dict in array) { 711 for(NSDictionary * dict in array) {
712 GroupObject * object = [[GroupObject alloc] initWithData:dict]; 712 GroupObject * object = [[GroupObject alloc] initWithData:dict];
713 [arrayTweets addObject:object]; 713 [arrayTweets addObject:object];
714 } 714 }
715 completion(arrayTweets, nil); 715 completion(arrayTweets, nil);
716 } 716 }
717 else { 717 else {
718 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 718 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
719 completion(nil, errorObject); 719 completion(nil, errorObject);
720 } 720 }
721 } 721 }
722 else { 722 else {
723 NSString *message = dataResult[@"message"]; 723 NSString *message = dataResult[@"message"];
724 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 724 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
725 completion(nil, errorObject); 725 completion(nil, errorObject);
726 } 726 }
727 } 727 }
728 else 728 else
729 { 729 {
730 completion(nil, error); 730 completion(nil, error);
731 } 731 }
732 }]; 732 }];
733 } 733 }
734 734
735 #pragma mark - Group Function 735 #pragma mark - Group Function
736 -(void) requestCreateGroup:(NSString *)token withGroup:(GroupObject *)group CompletionHandler:(void (^)(GroupObject *, NSError *)) completion { 736 -(void) requestCreateGroup:(NSString *)token withGroup:(GroupObject *)group CompletionHandler:(void (^)(GroupObject *, NSError *)) completion {
737 NSString *url = [kServerAddress stringByAppendingFormat:@"api/groups/newGroup"]; 737 NSString *url = [kServerAddress stringByAppendingFormat:@"api/groups/newGroup"];
738 NSLog(@"requestCreateGroup link %@", url); 738 NSLog(@"requestCreateGroup link %@", url);
739 NSDictionary * dict = @{@"group_name":group.name, 739 NSDictionary * dict = @{@"group_name":group.name,
740 @"goal":group.goal, 740 @"goal":group.goal,
741 @"walk_mode_active":[NSNumber numberWithBool:group.walkMode], 741 @"walk_mode_active":[NSNumber numberWithBool:group.walkMode],
742 @"run_mode_active":[NSNumber numberWithBool:group.runMode], 742 @"run_mode_active":[NSNumber numberWithBool:group.runMode],
743 @"bike_mode_active":[NSNumber numberWithBool:group.bikeMode], 743 @"bike_mode_active":[NSNumber numberWithBool:group.bikeMode],
744 @"step_mode_active":[NSNumber numberWithBool:group.stepMode], 744 @"step_mode_active":[NSNumber numberWithBool:group.stepMode],
745 @"gym_mode_active":[NSNumber numberWithBool:group.gymMode], 745 @"gym_mode_active":[NSNumber numberWithBool:group.gymMode],
746 @"beginer_mode_active":[NSNumber numberWithBool:group.beginMode], 746 @"beginer_mode_active":[NSNumber numberWithBool:group.beginMode],
747 @"walk_mode_goal":[NSNumber numberWithBool:group.walkGoal], 747 @"walk_mode_goal":[NSNumber numberWithBool:group.walkGoal],
748 @"run_mode_goal":[NSNumber numberWithBool:group.runGoal], 748 @"run_mode_goal":[NSNumber numberWithBool:group.runGoal],
749 @"bike_mode_goal":[NSNumber numberWithBool:group.bikeGoal]}; 749 @"bike_mode_goal":[NSNumber numberWithBool:group.bikeGoal]};
750 750
751 [self _request:url method:@"POST" token:token paras:dict completion:^(NSData *data, NSError *error) { 751 [self _request:url method:@"POST" token:token paras:dict completion:^(NSData *data, NSError *error) {
752 752
753 if (completion == NULL) { 753 if (completion == NULL) {
754 return ; 754 return ;
755 } 755 }
756 756
757 if (error == nil) 757 if (error == nil)
758 { 758 {
759 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 759 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
760 NSLog(@"%@", dataResult); 760 NSLog(@"%@", dataResult);
761 int status = [dataResult[@"status"] intValue]; 761 int status = [dataResult[@"status"] intValue];
762 if (status == 1) { // status = 1 success 762 if (status == 1) { // status = 1 success
763 if(dataResult[@"result"] != nil) { 763 if(dataResult[@"result"] != nil) {
764 NSDictionary * dict = dataResult[@"result"]; 764 NSDictionary * dict = dataResult[@"result"];
765 group.groupID = [dict[@"group_id"] intValue]; 765 group.groupID = [dict[@"group_id"] intValue];
766 completion(group, nil); 766 completion(group, nil);
767 } 767 }
768 else { 768 else {
769 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 769 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
770 completion(nil, errorObject); 770 completion(nil, errorObject);
771 } 771 }
772 } 772 }
773 else { 773 else {
774 NSString *message = dataResult[@"message"]; 774 NSString *message = dataResult[@"message"];
775 if (message == nil) { 775 if (message == nil) {
776 message = @"Unknown error"; 776 message = @"Unknown error";
777 } 777 }
778 778
779 if ([message isEqualToString:@"Token is invalid"]) { 779 if ([message isEqualToString:@"Token is invalid"]) {
780 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 780 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
781 if (error == nil) { 781 if (error == nil) {
782 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 782 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
783 [self requestCreateGroup:tokenNew withGroup:group CompletionHandler:completion]; 783 [self requestCreateGroup:tokenNew withGroup:group CompletionHandler:completion];
784 } 784 }
785 else { 785 else {
786 completion(nil, error); 786 completion(nil, error);
787 } 787 }
788 }]; 788 }];
789 } 789 }
790 else { 790 else {
791 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 791 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
792 completion(nil, errorObject); 792 completion(nil, errorObject);
793 } 793 }
794 } 794 }
795 } 795 }
796 else 796 else
797 { 797 {
798 completion(nil, error); 798 completion(nil, error);
799 } 799 }
800 }]; 800 }];
801 } 801 }
802 802
803 - (void) getGroupDetail:(NSString *)token withGroupID:(int)groupID CompletionHandler:(void (^)(GroupObject *, NSError *)) completion { 803 - (void) getGroupDetail:(NSString *)token withGroupID:(int)groupID CompletionHandler:(void (^)(GroupObject *, NSError *)) completion {
804 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/detail/%d", groupID]; 804 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/detail/%d", groupID];
805 NSLog(@"getGroupDetail link %@", url); 805 NSLog(@"getGroupDetail link %@", url);
806 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 806 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
807 807
808 if (completion == NULL) { 808 if (completion == NULL) {
809 return ; 809 return ;
810 } 810 }
811 811
812 if (error == nil) 812 if (error == nil)
813 { 813 {
814 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 814 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
815 NSLog(@"%@", dataResult); 815 NSLog(@"%@", dataResult);
816 int status = [dataResult[@"status"] intValue]; 816 int status = [dataResult[@"status"] intValue];
817 if (status == 1) { // status = 1 success 817 if (status == 1) { // status = 1 success
818 if(dataResult[@"result"] != nil) { 818 if(dataResult[@"result"] != nil) {
819 NSArray * array = dataResult[@"result"]; 819 NSArray * array = dataResult[@"result"];
820 GroupObject * object = [[GroupObject alloc] initWithData:array[0] andGroupID:groupID]; 820 GroupObject * object = [[GroupObject alloc] initWithData:array[0] andGroupID:groupID];
821 completion(object, nil); 821 completion(object, nil);
822 } 822 }
823 else { 823 else {
824 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 824 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
825 completion(nil, errorObject); 825 completion(nil, errorObject);
826 } 826 }
827 } 827 }
828 else { 828 else {
829 NSString *message = dataResult[@"message"]; 829 NSString *message = dataResult[@"message"];
830 if (message == nil) { 830 if (message == nil) {
831 message = @"Unknown error"; 831 message = @"Unknown error";
832 } 832 }
833 833
834 if ([message isEqualToString:@"Token is invalid"]) { 834 if ([message isEqualToString:@"Token is invalid"]) {
835 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 835 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
836 if (error == nil) { 836 if (error == nil) {
837 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 837 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
838 [self getGroupDetail:tokenNew withGroupID:groupID CompletionHandler:completion]; 838 [self getGroupDetail:tokenNew withGroupID:groupID CompletionHandler:completion];
839 } 839 }
840 else { 840 else {
841 completion(nil, error); 841 completion(nil, error);
842 } 842 }
843 }]; 843 }];
844 } 844 }
845 else { 845 else {
846 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 846 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
847 completion(nil, errorObject); 847 completion(nil, errorObject);
848 } 848 }
849 } 849 }
850 } 850 }
851 else 851 else
852 { 852 {
853 completion(nil, error); 853 completion(nil, error);
854 } 854 }
855 }]; 855 }];
856 } 856 }
857 857
858 - (void) requestMemberList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion { 858 - (void) requestMemberList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion {
859 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/member/%d/%d", groupID, page]; 859 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/member/%d/%d", groupID, page];
860 NSLog(@"requestMemberList link %@ page %d", url, page); 860 NSLog(@"requestMemberList link %@ page %d", url, page);
861 861
862 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 862 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
863 if (completion == NULL) { 863 if (completion == NULL) {
864 return ; 864 return ;
865 } 865 }
866 866
867 if (error == nil) 867 if (error == nil)
868 { 868 {
869 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 869 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
870 NSLog(@"%@", dataResult); 870 NSLog(@"%@", dataResult);
871 int status = [dataResult[@"status"] intValue]; 871 int status = [dataResult[@"status"] intValue];
872 if (status == 1) { // status = 1 success 872 if (status == 1) { // status = 1 success
873 if(dataResult[@"result"] != nil) { 873 if(dataResult[@"result"] != nil) {
874 NSArray * array = dataResult[@"result"]; 874 NSArray * array = dataResult[@"result"];
875 NSMutableArray * arrayTweets = [[NSMutableArray alloc] init]; 875 NSMutableArray * arrayTweets = [[NSMutableArray alloc] init];
876 for(NSDictionary * dict in array) { 876 for(NSDictionary * dict in array) {
877 MemberObject * object = [[MemberObject alloc] initWithData:dict]; 877 MemberObject * object = [[MemberObject alloc] initWithData:dict];
878 [arrayTweets addObject:object]; 878 [arrayTweets addObject:object];
879 } 879 }
880 completion(arrayTweets, nil); 880 completion(arrayTweets, nil);
881 } 881 }
882 else { 882 else {
883 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 883 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
884 completion(nil, errorObject); 884 completion(nil, errorObject);
885 } 885 }
886 } 886 }
887 else { 887 else {
888 NSString *message = dataResult[@"message"]; 888 NSString *message = dataResult[@"message"];
889 if (message == nil) { 889 if (message == nil) {
890 message = @"Unknown error"; 890 message = @"Unknown error";
891 } 891 }
892 892
893 if ([message isEqualToString:@"Token is invalid"]) { 893 if ([message isEqualToString:@"Token is invalid"]) {
894 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 894 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
895 if (error == nil) { 895 if (error == nil) {
896 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 896 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
897 [self requestMemberList:tokenNew groupID:groupID withPage:page CompletionHandler:completion]; 897 [self requestMemberList:tokenNew groupID:groupID withPage:page CompletionHandler:completion];
898 } 898 }
899 else { 899 else {
900 completion(nil, error); 900 completion(nil, error);
901 } 901 }
902 }]; 902 }];
903 } 903 }
904 else { 904 else {
905 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 905 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
906 completion(nil, errorObject); 906 completion(nil, errorObject);
907 } 907 }
908 } 908 }
909 } 909 }
910 else 910 else
911 { 911 {
912 completion(nil, error); 912 completion(nil, error);
913 } 913 }
914 }]; 914 }];
915 } 915 }
916 916
917 - (void) requestJoinGroup:(NSString *)token groupID: (int) groupID CompletionHandler:(void (^)(NSError *)) completion { 917 - (void) requestJoinGroup:(NSString *)token groupID: (int) groupID CompletionHandler:(void (^)(NSError *)) completion {
918 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/join"]; 918 NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/join"];
919 NSLog(@"requestJoinGroup link %@", url); 919 NSLog(@"requestJoinGroup link %@", url);
920 920
921 [self _request:url method:@"POST" token:token paras:@{@"group_id": [NSNumber numberWithInt:groupID]} completion:^(NSData *data, NSError *error) { 921 [self _request:url method:@"POST" token:token paras:@{@"group_id": [NSNumber numberWithInt:groupID]} completion:^(NSData *data, NSError *error) {
922 if (completion == NULL) { 922 if (completion == NULL) {
923 return ; 923 return ;
924 } 924 }
925 925
926 if (error == nil) 926 if (error == nil)
927 { 927 {
928 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 928 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
929 NSLog(@"%@", dataResult); 929 NSLog(@"%@", dataResult);
930 int status = [dataResult[@"status"] intValue]; 930 int status = [dataResult[@"status"] intValue];
931 if (status == 1) { // status = 1 success 931 if (status == 1) { // status = 1 success
932 if(dataResult[@"result"] != nil) { 932 if(dataResult[@"result"] != nil) {
933 completion(nil); 933 completion(nil);
934 } 934 }
935 else { 935 else {
936 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 936 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
937 completion(errorObject); 937 completion(errorObject);
938 } 938 }
939 } 939 }
940 else { 940 else {
941 NSString *message = dataResult[@"message"]; 941 NSString *message = dataResult[@"message"];
942 if ([message isEqualToString:@"Token is invalid"]) { 942 if ([message isEqualToString:@"Token is invalid"]) {
943 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 943 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
944 if (error == nil) { 944 if (error == nil) {
945 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 945 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
946 [self requestJoinGroup:tokenNew groupID:groupID CompletionHandler:completion]; 946 [self requestJoinGroup:tokenNew groupID:groupID CompletionHandler:completion];
947 } 947 }
948 else { 948 else {
949 completion(error); 949 completion(error);
950 } 950 }
951 }]; 951 }];
952 } 952 }
953 else { 953 else {
954 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 954 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
955 completion(errorObject); 955 completion(errorObject);
956 } 956 }
957 } 957 }
958 } 958 }
959 else 959 else
960 { 960 {
961 completion(error); 961 completion(error);
962 } 962 }
963 }]; 963 }];
964 } 964 }
965 965
966 - (void) requestGroupList:(NSString *)token CompletionHandler:(void (^)(NSArray *, NSError *)) completion { 966 - (void) requestGroupList:(NSString *)token CompletionHandler:(void (^)(NSArray *, NSError *)) completion {
967 NSString *url = [kServerAddress stringByAppendingFormat:@"api/groups/list"]; 967 NSString *url = [kServerAddress stringByAppendingFormat:@"api/groups/list"];
968 NSLog(@"requestGroupList link %@", url); 968 NSLog(@"requestGroupList link %@", url);
969 969
970 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 970 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
971 if (completion == NULL) { 971 if (completion == NULL) {
972 return ; 972 return ;
973 } 973 }
974 974
975 if (error == nil) 975 if (error == nil)
976 { 976 {
977 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 977 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
978 NSLog(@"%@", dataResult); 978 NSLog(@"%@", dataResult);
979 int status = [dataResult[@"status"] intValue]; 979 int status = [dataResult[@"status"] intValue];
980 if (status == 1) { // status = 1 success 980 if (status == 1) { // status = 1 success
981 if(dataResult[@"result"] != nil) { 981 if(dataResult[@"result"] != nil) {
982 NSArray * array = dataResult[@"result"]; 982 NSArray * array = dataResult[@"result"];
983 NSMutableArray * arrayGroup = [[NSMutableArray alloc] init]; 983 NSMutableArray * arrayGroup = [[NSMutableArray alloc] init];
984 for(NSDictionary * dict in array) { 984 for(NSDictionary * dict in array) {
985 GroupObject * object = [[GroupObject alloc] initWithShortData:dict]; 985 GroupObject * object = [[GroupObject alloc] initWithShortData:dict];
986 [arrayGroup addObject:object]; 986 [arrayGroup addObject:object];
987 } 987 }
988 completion(arrayGroup, nil); 988 completion(arrayGroup, nil);
989 } 989 }
990 else { 990 else {
991 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; 991 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}];
992 completion(nil, errorObject); 992 completion(nil, errorObject);
993 } 993 }
994 } 994 }
995 else { 995 else {
996 NSString *message = dataResult[@"message"]; 996 NSString *message = dataResult[@"message"];
997 if (message == nil) { 997 if (message == nil) {
998 message = @"Unknown error"; 998 message = @"Unknown error";
999 } 999 }
1000 1000
1001 if ([message isEqualToString:@"Token is invalid"]) { 1001 if ([message isEqualToString:@"Token is invalid"]) {
1002 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 1002 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
1003 if (error == nil) { 1003 if (error == nil) {
1004 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 1004 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
1005 [self requestGroupList:tokenNew CompletionHandler:completion]; 1005 [self requestGroupList:tokenNew CompletionHandler:completion];
1006 } 1006 }
1007 else { 1007 else {
1008 completion(nil, error); 1008 completion(nil, error);
1009 } 1009 }
1010 }]; 1010 }];
1011 } 1011 }
1012 else { 1012 else {
1013 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 1013 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
1014 completion(nil, errorObject); 1014 completion(nil, errorObject);
1015 } 1015 }
1016 } 1016 }
1017 } 1017 }
1018 else 1018 else
1019 { 1019 {
1020 completion(nil, error); 1020 completion(nil, error);
1021 } 1021 }
1022 }]; 1022 }];
1023 } 1023 }
1024 1024
1025 #pragma mark - Ranking API 1025 #pragma mark - Ranking API
1026 - (void) requestRankingList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate mode:(int) mode page:(int) page CompletionHandler:(void (^)(NSArray *, NSError *)) completion { 1026 - (void) requestRankingList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate mode:(int) mode page:(int) page CompletionHandler:(void (^)(NSArray *, NSError *)) completion {
1027 NSString *url = [kServerAddress stringByAppendingFormat:@"api/ranking/%d/%@/%@/%d", mode, [Utilities stringFromDate:startDate withFormat:@"YYYYMMdd" locale:@""], [Utilities stringFromDate:endDate withFormat:@"YYYYMMdd" locale:@""], page]; 1027 NSString *url = [kServerAddress stringByAppendingFormat:@"api/ranking/%d/%@/%@/%d", mode, [Utilities stringFromDate:startDate withFormat:@"YYYYMMdd" locale:@""], [Utilities stringFromDate:endDate withFormat:@"YYYYMMdd" locale:@""], page];
1028 NSLog(@"requestRaningList link %@", url); 1028 NSLog(@"requestRaningList link %@", url);
1029 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { 1029 [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) {
1030 1030
1031 if (completion == NULL) { 1031 if (completion == NULL) {
1032 return ; 1032 return ;
1033 } 1033 }
1034 1034
1035 if (error == nil) 1035 if (error == nil)
1036 { 1036 {
1037 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 1037 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
1038 NSLog(@"%@", dataResult); 1038 NSLog(@"%@", dataResult);
1039 int status = [dataResult[@"status"] intValue]; 1039 int status = [dataResult[@"status"] intValue];
1040 if (status == 1) { // status = 1 success 1040 if (status == 1) { // status = 1 success
1041 NSArray * array = dataResult[@"result"]; 1041 NSArray * array = dataResult[@"result"];
1042 NSMutableArray * arrayRanking = [[NSMutableArray alloc] init]; 1042 NSMutableArray * arrayRanking = [[NSMutableArray alloc] init];
1043 for(NSDictionary * dict in array) { 1043 for(NSDictionary * dict in array) {
1044 RankingObject * object = [[RankingObject alloc] initWithData:dict]; 1044 RankingObject * object = [[RankingObject alloc] initWithData:dict];
1045 [arrayRanking addObject:object]; 1045 [arrayRanking addObject:object];
1046 } 1046 }
1047 completion(arrayRanking, nil); 1047 completion(arrayRanking, nil);
1048 } 1048 }
1049 else { 1049 else {
1050 NSString *message = dataResult[@"message"]; 1050 NSString *message = dataResult[@"message"];
1051 if (message == nil) { 1051 if (message == nil) {
1052 message = @"Unknown error"; 1052 message = @"Unknown error";
1053 } 1053 }
1054 1054
1055 if ([message isEqualToString:@"Token is invalid"]) { 1055 if ([message isEqualToString:@"Token is invalid"]) {
1056 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) { 1056 [self checkTokenCompletionHandler:^(NSString *token, NSError *error) {
1057 if (error == nil) { 1057 if (error == nil) {
1058 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; 1058 NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken];
1059 [self requestRankingList:tokenNew startDate:startDate endDate:endDate mode:mode page:page CompletionHandler:completion]; 1059 [self requestRankingList:tokenNew startDate:startDate endDate:endDate mode:mode page:page CompletionHandler:completion];
1060 } 1060 }
1061 else { 1061 else {
1062 completion(nil, error); 1062 completion(nil, error);
1063 } 1063 }
1064 }]; 1064 }];
1065 } 1065 }
1066 else { 1066 else {
1067 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 1067 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
1068 completion(nil, errorObject); 1068 completion(nil, errorObject);
1069 } 1069 }
1070 } 1070 }
1071 } 1071 }
1072 else 1072 else
1073 { 1073 {
1074 completion(nil, error); 1074 completion(nil, error);
1075 } 1075 }
1076 }]; 1076 }];
1077 } 1077 }
1078 1078
1079 #pragma mark - Common API 1079 #pragma mark - Common API
1080 - (void)refreshToken: (NSString *)userID CompletionHandler:(void (^)(NSString *, NSError *))completion { 1080 - (void)refreshToken: (NSString *)userID CompletionHandler:(void (^)(NSString *, NSError *))completion {
1081 [self _request:[kServerAddress stringByAppendingFormat: @"refreshToken"] method:@"POST" token:@"" paras:@{@"userId":userID} completion:^(NSData *data, NSError *error) { 1081 [self _request:[kServerAddress stringByAppendingFormat: @"refreshToken"] method:@"POST" token:@"" paras:@{@"userId":userID} completion:^(NSData *data, NSError *error) {
1082 1082
1083 if (completion == NULL) { 1083 if (completion == NULL) {
1084 return ; 1084 return ;
1085 } 1085 }
1086 1086
1087 if (error == nil) 1087 if (error == nil)
1088 { 1088 {
1089 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 1089 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
1090 1090
1091 int status = [dataResult[@"status"] intValue]; 1091 int status = [dataResult[@"status"] intValue];
1092 if (status == 1) { // status = 1 success 1092 if (status == 1) { // status = 1 success
1093 NSArray *arrayResult = dataResult[@"result"]; 1093 NSArray *arrayResult = dataResult[@"result"];
1094 if (arrayResult.count > 0) { 1094 if (arrayResult.count > 0) {
1095 NSString *token = arrayResult[0]; 1095 NSString *token = arrayResult[0];
1096 completion(token, nil); 1096 completion(token, nil);
1097 } 1097 }
1098 else { 1098 else {
1099 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"refreshToken Error"}]; 1099 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"refreshToken Error"}];
1100 completion(nil, errorObject); 1100 completion(nil, errorObject);
1101 } 1101 }
1102 1102
1103 } 1103 }
1104 else { // status = 0 error 1104 else { // status = 0 error
1105 NSString *message = dataResult[@"message"]; 1105 NSString *message = dataResult[@"message"];
1106 if (message == nil) { 1106 if (message == nil) {
1107 message = @"refreshToken Error"; 1107 message = @"refreshToken Error";
1108 } 1108 }
1109 NSError *loginFaild = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 1109 NSError *loginFaild = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
1110 completion(nil, loginFaild); 1110 completion(nil, loginFaild);
1111 } 1111 }
1112 } 1112 }
1113 else 1113 else
1114 { 1114 {
1115 completion(nil, error); 1115 completion(nil, error);
1116 } 1116 }
1117 }]; 1117 }];
1118 } 1118 }
1119 1119
1120 - (void)getNoticeByDate: (NSString *)date CompletionHandler:(void (^)(NSArray *, NSError *)) completion 1120 - (void)getNoticeByDate: (NSString *)date CompletionHandler:(void (^)(NSArray *, NSError *)) completion
1121 { 1121 {
1122 [self _request:[kServerAddress stringByAppendingFormat: @"api/getnoticesbydate/%@", date] method:@"GET" token:@"" paras:nil completion:^(NSData *data, NSError *error) { 1122 [self _request:[kServerAddress stringByAppendingFormat: @"api/getnoticesbydate/%@", date] method:@"GET" token:@"" paras:nil completion:^(NSData *data, NSError *error) {
1123 1123
1124 if (completion == NULL) { 1124 if (completion == NULL) {
1125 return ; 1125 return ;
1126 } 1126 }
1127 1127
1128 if (error == nil) 1128 if (error == nil)
1129 { 1129 {
1130 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; 1130 NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error];
1131 1131
1132 int status = [dataResult[@"status"] intValue]; 1132 int status = [dataResult[@"status"] intValue];
1133 if (status == 1) { // status = 1 success 1133 if (status == 1) { // status = 1 success
1134 NSArray *arrayResult = dataResult[@"result"][@"listNotice"]; 1134 NSArray *arrayResult = dataResult[@"result"][@"listNotice"];
1135 if (arrayResult.count > 0) { 1135 if (arrayResult.count > 0) {
1136 NSMutableArray *notices = [[NSMutableArray alloc] init]; 1136 NSMutableArray *notices = [[NSMutableArray alloc] init];
1137 for(NSDictionary *dict in arrayResult) { 1137 for(NSDictionary *dict in arrayResult) {
1138 NSString *object = [dict objectForKey:@"notice_content"]; 1138 NSString *object = [dict objectForKey:@"notice_content"];
1139 [notices addObject:object]; 1139 [notices addObject:object];
1140 } 1140 }
1141 completion(notices, nil); 1141 completion(notices, nil);
1142 } 1142 }
1143 else { 1143 else {
1144 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Today is not notice"}]; 1144 NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Today is not notice"}];
1145 completion(nil, errorObject); 1145 completion(nil, errorObject);
1146 } 1146 }
1147 1147
1148 } 1148 }
1149 else { // status = 0 error 1149 else { // status = 0 error
1150 NSString *message = dataResult[@"message"]; 1150 NSString *message = dataResult[@"message"];
1151 if (message == nil) { 1151 if (message == nil) {
1152 message = @"Unknown error"; 1152 message = @"Unknown error";
1153 } 1153 }
1154 NSError *loginFaild = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; 1154 NSError *loginFaild = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}];
1155 completion(nil, loginFaild); 1155 completion(nil, loginFaild);
1156 } 1156 }
1157 } 1157 }
1158 else 1158 else
1159 { 1159 {
1160 completion(nil, error); 1160 completion(nil, error);
1161 } 1161 }
1162 }]; 1162 }];
1163 } 1163 }
1164 1164
1165 #pragma mark - Private Function 1165 #pragma mark - Private Function
1166 - (void) checkTokenCompletionHandler:(void (^)(NSString *, NSError *)) completion 1166 - (void) checkTokenCompletionHandler:(void (^)(NSString *, NSError *)) completion
1167 { 1167 {
1168 NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:kUser]; 1168 NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:kUser];
1169 User *user = (User *)[NSKeyedUnarchiver unarchiveObjectWithData:data]; 1169 User *user = (User *)[NSKeyedUnarchiver unarchiveObjectWithData:data];
1170 if (user != nil) { 1170 if (user != nil) {
1171 [self refreshToken:user.user_id CompletionHandler:^(NSString *token, NSError *error) { 1171 [self refreshToken:user.user_id CompletionHandler:^(NSString *token, NSError *error) {
1172 if (error == nil) { 1172 if (error == nil) {
1173 [[NSUserDefaults standardUserDefaults] setObject:token forKey:kToken]; 1173 [[NSUserDefaults standardUserDefaults] setObject:token forKey:kToken];
1174 [[NSUserDefaults standardUserDefaults] synchronize]; 1174 [[NSUserDefaults standardUserDefaults] synchronize];
1175 completion(token, nil); 1175 completion(token, nil);
1176 } 1176 }
1177 else { 1177 else {
1178 completion(nil, error); 1178 completion(nil, error);
1179 } 1179 }
1180 }]; 1180 }];
1181 } 1181 }
1182 else { 1182 else {
1183 NSError *error = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"User not found"}]; 1183 NSError *error = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"User not found"}];
1184 completion(nil, error); 1184 completion(nil, error);
1185 } 1185 }
1186 } 1186 }
1187 1187
1188 - (NSData *) _encodeDictionary: (NSDictionary *) dictionary 1188 - (NSData *) _encodeDictionary: (NSDictionary *) dictionary
1189 { 1189 {
1190 NSMutableArray *parts = [[NSMutableArray alloc] init]; 1190 NSMutableArray *parts = [[NSMutableArray alloc] init];
1191 for (id key in dictionary) 1191 for (id key in dictionary)
1192 { 1192 {
1193 NSString *encodedValue = [[dictionary[key] description] urlencode]; 1193 NSString *encodedValue = [[dictionary[key] description] urlencode];
1194 NSString *encodedKey = [[key description] urlencode];//[[key description] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; 1194 NSString *encodedKey = [[key description] stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];//[[key description] urlencode];
1195 NSString *part = [NSString stringWithFormat: @"%@=%@", encodedKey, encodedValue]; 1195 NSString *part = [NSString stringWithFormat: @"%@=%@", encodedKey, encodedValue];
1196 [parts addObject:part]; 1196 [parts addObject:part];
1197 } 1197 }
1198 NSString *encodedDictionary = [parts componentsJoinedByString:@"&"]; 1198 NSString *encodedDictionary = [parts componentsJoinedByString:@"&"];
1199 return [encodedDictionary dataUsingEncoding: NSUTF8StringEncoding]; 1199 return [encodedDictionary dataUsingEncoding: NSUTF8StringEncoding];
1200 } 1200 }
1201 1201
1202 - (NSURLSessionDataTask *) _request:(NSString *)address method:(NSString *)method token:(NSString *) token paras:(NSDictionary *)paras completion:(void (^)(NSData *data, NSError *error))completion 1202 - (NSURLSessionDataTask *) _request:(NSString *)address method:(NSString *)method token:(NSString *) token paras:(NSDictionary *)paras completion:(void (^)(NSData *data, NSError *error))completion
1203 { 1203 {
1204 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:address]]; 1204 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:address]];
1205 request.HTTPMethod = method; 1205 request.HTTPMethod = method;
1206 [request setValue: @"application/json" forHTTPHeaderField: @"Accept"]; 1206 [request setValue: @"application/json" forHTTPHeaderField: @"Accept"];
1207 [request setValue: @"application/json" forHTTPHeaderField: @"Content-Type"]; 1207 [request setValue: @"application/json" forHTTPHeaderField: @"Content-Type"];
1208 if(token != nil && ![token isEqual: @""]) { 1208 if(token != nil && ![token isEqual: @""]) {
1209 [request setValue: token forHTTPHeaderField: @"token"]; 1209 [request setValue: token forHTTPHeaderField: @"token"];
1210 } 1210 }
1211 [request setTimeoutInterval:self.timeOutInterval]; 1211 [request setTimeoutInterval:self.timeOutInterval];
1212 1212
1213 if (paras != nil) 1213 if (paras != nil)
1214 { 1214 {
1215 NSData *encodedData = [self _encodeDictionary: paras]; 1215 NSData *encodedData = [self _encodeDictionary: paras];
1216 [request setValue: [NSString stringWithFormat: @"%lu", (unsigned long) encodedData.length] forHTTPHeaderField: @"Content-Length"];
1217 [request setValue: @"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField: @"Content-Type"]; 1216 [request setValue: @"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField: @"Content-Type"];
1218 [request setHTTPBody: encodedData]; 1217 [request setHTTPBody: encodedData];
1219 } 1218 }
1220 1219
1221 //NSURLSession *session = [NSURLSession sharedSession]; 1220 //NSURLSession *session = [NSURLSession sharedSession];
1222 NSURLSessionConfiguration *defaultConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration]; 1221 NSURLSessionConfiguration *defaultConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
1223 [defaultConfiguration setHTTPMaximumConnectionsPerHost:20]; 1222 [defaultConfiguration setHTTPMaximumConnectionsPerHost:20];
1224 NSOperationQueue *operationQueue = [NSOperationQueue mainQueue]; 1223 NSOperationQueue *operationQueue = [NSOperationQueue mainQueue];
1225 operationQueue.maxConcurrentOperationCount = 20; 1224 operationQueue.maxConcurrentOperationCount = 20;
1226 NSURLSession *session = [NSURLSession sessionWithConfiguration:defaultConfiguration delegate:nil delegateQueue:operationQueue]; 1225 NSURLSession *session = [NSURLSession sessionWithConfiguration:defaultConfiguration delegate:nil delegateQueue:operationQueue];
1227 NSURLSessionDataTask *task = [session dataTaskWithRequest:request 1226 NSURLSessionDataTask *task = [session dataTaskWithRequest:request
1228 completionHandler: 1227 completionHandler:
1229 ^(NSData *data, NSURLResponse *response, NSError *error) { 1228 ^(NSData *data, NSURLResponse *response, NSError *error) {
1230 if (completion == NULL) { 1229 if (completion == NULL) {
1231 return ; 1230 return ;
1232 } 1231 }
1233 if (error == nil) 1232 if (error == nil)
1234 { 1233 {
1235 completion(data, nil); 1234 completion(data, nil);
1236 } 1235 }
1237 else 1236 else
1238 { 1237 {
1239 completion(nil, error); 1238 completion(nil, error);
1240 } 1239 }
1241 }]; 1240 }];
1242 [task resume]; 1241 [task resume];
1243 return task; 1242 return task;
1244 } 1243 }
1245 1244
1246 -(void)waitUntilDone:(void(^)(void))waitBlock { 1245 -(void)waitUntilDone:(void(^)(void))waitBlock {
1247 //use your statement or call method here 1246 //use your statement or call method here
1248 if(waitBlock){ 1247 if(waitBlock){
1249 waitBlock(); 1248 waitBlock();
1250 } 1249 }
1251 } 1250 }
1252 1251
1253 @end 1252 @end
1254 1253