Commit 3c805063b5b987fbb80f35b76673c9d33c2ab091

Authored by phong
1 parent 26548f2f08
Exists in master

update api notice

Showing 5 changed files with 97 additions and 19 deletions Inline Diff

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 60
61 self.avatar.backgroundColor = [UIColor whiteColor]; 61 self.avatar.backgroundColor = [UIColor whiteColor];
62 self.avatar.layer.borderWidth = 2.0f; 62 self.avatar.layer.borderWidth = 2.0f;
63 self.avatar.layer.borderColor = [[UIColor whiteColor] CGColor]; 63 self.avatar.layer.borderColor = [[UIColor whiteColor] CGColor];
64 self.avatar.layer.cornerRadius = self.avatar.frame.size.width/2.0f; 64 self.avatar.layer.cornerRadius = self.avatar.frame.size.width/2.0f;
65 self.avatar.layer.masksToBounds = YES; 65 self.avatar.layer.masksToBounds = YES;
66 NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:kUser]; 66 NSData *data = [[NSUserDefaults standardUserDefaults] objectForKey:kUser];
67 User *user = (User *)[NSKeyedUnarchiver unarchiveObjectWithData:data]; 67 User *user = (User *)[NSKeyedUnarchiver unarchiveObjectWithData:data];
68 if (user != nil) { 68 if (user != nil) {
69 NSString *linkImage = [NSString stringWithFormat:@"%@%@", kServerAddress, user.profile_image]; 69 NSString *linkImage = [NSString stringWithFormat:@"%@%@", kServerAddress, user.profile_image];
70 NSURL *urlImage = [NSURL URLWithString:linkImage]; 70 NSURL *urlImage = [NSURL URLWithString:linkImage];
71 NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration]; 71 NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
72 sessionConfig.timeoutIntervalForRequest = 30.0; 72 sessionConfig.timeoutIntervalForRequest = 30.0;
73 sessionConfig.timeoutIntervalForResource = 60.0; 73 sessionConfig.timeoutIntervalForResource = 60.0;
74 sessionConfig.HTTPMaximumConnectionsPerHost = 20; 74 sessionConfig.HTTPMaximumConnectionsPerHost = 20;
75 sessionConfig.allowsCellularAccess = YES; 75 sessionConfig.allowsCellularAccess = YES;
76 HomeViewController __weak *weakSelf = self; 76 HomeViewController __weak *weakSelf = self;
77 NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig]; 77 NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig];
78 NSURLSessionDataTask *downloadPhotoTask = [session 78 NSURLSessionDataTask *downloadPhotoTask = [session
79 dataTaskWithURL:urlImage completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { 79 dataTaskWithURL:urlImage completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
80 if (weakSelf == nil) 80 if (weakSelf == nil)
81 { 81 {
82 return; 82 return;
83 } 83 }
84 if (error == nil) { 84 if (error == nil) {
85 UIImage *image = [[UIImage alloc] initWithData:data]; 85 UIImage *image = [[UIImage alloc] initWithData:data];
86 [[NSOperationQueue mainQueue] addOperationWithBlock:^{ 86 [[NSOperationQueue mainQueue] addOperationWithBlock:^{
87 weakSelf.avatar.image = image; 87 weakSelf.avatar.image = image;
88 }]; 88 }];
89 } 89 }
90 }]; 90 }];
91 [downloadPhotoTask resume]; 91 [downloadPhotoTask resume];
92 } 92 }
93 93
94 self.lblNotice.text = NSLocalizedString(@"lifelog.home.notice", nil); 94 self.lblNotice.text = NSLocalizedString(@"lifelog.home.notice", nil);
95 95
96 _dateCurrent = [NSDate date]; 96 _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)]; 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 98
99 self.lblUnitStep.text = NSLocalizedString(@"lifelog.home.unit.step", nil); 99 self.lblUnitStep.text = NSLocalizedString(@"lifelog.home.unit.step", nil);
100 100
101 if ([CMPedometer isStepCountingAvailable]) { 101 if ([CMPedometer isStepCountingAvailable]) {
102 _pedometer = [[CMPedometer alloc] init]; 102 _pedometer = [[CMPedometer alloc] init];
103 } 103 }
104 if ([CMMotionActivityManager isActivityAvailable]) { 104 if ([CMMotionActivityManager isActivityAvailable]) {
105 _motionActivityManager = [[CMMotionActivityManager alloc] init]; 105 _motionActivityManager = [[CMMotionActivityManager alloc] init];
106 } 106 }
107 _operationQueue = [[NSOperationQueue alloc] init]; 107 _operationQueue = [[NSOperationQueue alloc] init];
108 _bike = 0; 108 _bike = 0;
109 _walking = 0; 109 _walking = 0;
110 _running = 0; 110 _running = 0;
111 _segmentHome.selectedSegmentIndex = 1; 111 _segmentHome.selectedSegmentIndex = 1;
112 _totalRequest = 0; 112 _totalRequest = 0;
113 _countComplete = 0; 113 _countComplete = 0;
114 114
115 progressHud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 115 progressHud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
116 progressHud.mode = MBProgressHUDModeIndeterminate; 116 progressHud.mode = MBProgressHUDModeIndeterminate;
117 progressHud.detailsLabel.text = NSLocalizedString(@"lifelog.home.progressHud.title", nil); 117 progressHud.detailsLabel.text = NSLocalizedString(@"lifelog.home.progressHud.title", nil);
118 // [self saveDataStep7LastDay]; 118 // [self saveDataStep7LastDay];
119 targetStep = numberTotal; 119 targetStep = numberTotal;
120 [self requestNotice];
120 } 121 }
121 122
123 - (void)requestNotice
124 {
125 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
126 [dateFormatter setDateFormat:@"yyyy-MM-dd"];
127 NSString *dateString = [dateFormatter stringFromDate:_dateCurrent];
128 HomeViewController __weak *weakSelf = self;
129 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
130 //Do background work
131 [[ServerAPI server] getNoticeByDate:dateString CompletionHandler:^(NSArray *arrResults, NSError *error) {
132 if(weakSelf == nil) {
133 return ;
134 }
135 if (error == nil) {
136 // NSLog(@"List Notices: %@", arrResults);
137 dispatch_async(dispatch_get_main_queue(), ^{
138 NSString *stringNotice = @"";
139 for (NSString *noticeInfor in arrResults) {
140 NSString *noticeString = [NSString stringWithFormat:@"%@\n", noticeInfor];
141 stringNotice = [stringNotice stringByAppendingString:noticeString];
142 }
143 weakSelf.tvNotice.text = stringNotice;
144 });
145 }
146 else {
147 dispatch_async(dispatch_get_main_queue(), ^{
148 weakSelf.tvNotice.text = @"";
149 /*
150 NSString *message = [error.userInfo objectForKey:@"message"];
151 [Utilities showErrorMessage:message withViewController:weakSelf];
152 */
153 });
154 }
155 }];
156 });
157 }
158
122 - (void)viewWillAppear:(BOOL)animated { 159 - (void)viewWillAppear:(BOOL)animated {
123 [super viewWillAppear:animated]; 160 [super viewWillAppear:animated];
124 NSDate *dateNow = [NSDate date]; 161 NSDate *dateNow = [NSDate date];
125 [self saveStepForDay:dateNow]; 162 [self saveStepForDay:dateNow];
126 } 163 }
127 164
128 - (void)requestTopByDate:(NSDate *)date { 165 - (void)requestTopByDate:(NSDate *)date {
129 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 166 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
130 [dateFormatter setDateFormat:@"yyyy-MM-dd"]; 167 [dateFormatter setDateFormat:@"yyyy-MM-dd"];
131 NSString *dateString = [dateFormatter stringFromDate:date]; 168 NSString *dateString = [dateFormatter stringFromDate:date];
132 [progressHud showAnimated:YES]; 169 [progressHud showAnimated:YES];
133 [progressHud setHidden:NO]; 170 [progressHud setHidden:NO];
134 HomeViewController __weak *weakSelf = self; 171 HomeViewController __weak *weakSelf = self;
135 int mode = 1; 172 int mode = 1;
136 switch (_segmentHome.selectedSegmentIndex) { 173 switch (_segmentHome.selectedSegmentIndex) {
137 case 0: 174 case 0:
138 mode = 3; 175 mode = 3;
139 break; 176 break;
140 177
141 case 1: 178 case 1:
142 mode = 1; 179 mode = 1;
143 break; 180 break;
144 181
145 case 2: 182 case 2:
146 mode = 2; 183 mode = 2;
147 break; 184 break;
148 185
149 default: 186 default:
150 break; 187 break;
151 } 188 }
152 [[ServerAPI server] requestTopWithMode:mode andDate:dateString CompletionHandler:^(TopObject *topObject, NSError *error) { 189 [[ServerAPI server] requestTopWithMode:mode andDate:dateString CompletionHandler:^(TopObject *topObject, NSError *error) {
153 if(weakSelf == nil) { 190 if(weakSelf == nil) {
154 return ; 191 return ;
155 } 192 }
156 if (error == nil) { 193 if (error == nil) {
157 NSLog(@"TopObject: %@", topObject); 194 NSLog(@"TopObject: %@", topObject);
158 dispatch_async(dispatch_get_main_queue(), ^{ 195 dispatch_async(dispatch_get_main_queue(), ^{
159 [weakSelf updateStepUI:topObject.targetInfor]; 196 [weakSelf updateStepUI:topObject.targetInfor];
160 }); 197 });
161 } 198 }
162 else { 199 else {
163 dispatch_async(dispatch_get_main_queue(), ^{ 200 dispatch_async(dispatch_get_main_queue(), ^{
164 NSString *message = [error.userInfo objectForKey:@"message"]; 201 NSString *message = [error.userInfo objectForKey:@"message"];
165 [Utilities showErrorMessage:message withViewController:weakSelf]; 202 [Utilities showErrorMessage:message withViewController:weakSelf];
166 }); 203 });
167 } 204 }
168 dispatch_async(dispatch_get_main_queue(), ^{ 205 dispatch_async(dispatch_get_main_queue(), ^{
169 [progressHud setHidden:YES]; 206 [progressHud setHidden:YES];
170 }); 207 });
171 }]; 208 }];
209 /*
172 [[ServerAPI server] requestHomeWithMode:mode andDate:dateString CompletionHandler:^(HomeObject *homeObject, NSError *error) { 210 [[ServerAPI server] requestHomeWithMode:mode andDate:dateString CompletionHandler:^(HomeObject *homeObject, NSError *error) {
173 if(weakSelf == nil) { 211 if(weakSelf == nil) {
174 return ; 212 return ;
175 } 213 }
176 if (error == nil) { 214 if (error == nil) {
177 NSLog(@"List Notices: %@", homeObject.listNotice); 215 NSLog(@"List Notices: %@", homeObject.listNotice);
178 for (NoticeInfor *noticeInfor in homeObject.listNotice) { 216 for (NoticeInfor *noticeInfor in homeObject.listNotice) {
179 NSLog(@"noticeInfor: %@", noticeInfor.notice_content); 217 NSLog(@"noticeInfor: %@", noticeInfor.notice_content);
180 } 218 }
181 dispatch_async(dispatch_get_main_queue(), ^{ 219 dispatch_async(dispatch_get_main_queue(), ^{
182 [weakSelf updateNoticeUI:homeObject]; 220 [weakSelf updateNoticeUI:homeObject];
183 }); 221 });
184 } 222 }
185 else { 223 else {
186 dispatch_async(dispatch_get_main_queue(), ^{ 224 dispatch_async(dispatch_get_main_queue(), ^{
187 NSString *message = [error.userInfo objectForKey:@"message"]; 225 NSString *message = [error.userInfo objectForKey:@"message"];
188 [Utilities showErrorMessage:message withViewController:weakSelf]; 226 [Utilities showErrorMessage:message withViewController:weakSelf];
189 }); 227 });
190 } 228 }
191 dispatch_async(dispatch_get_main_queue(), ^{ 229 dispatch_async(dispatch_get_main_queue(), ^{
192 [progressHud setHidden:YES]; 230 [progressHud setHidden:YES];
193 }); 231 });
194 }]; 232 }];
233 */
195 } 234 }
196 235
197 - (void)viewWillDisappear:(BOOL)animated { 236 - (void)viewWillDisappear:(BOOL)animated {
198 [super viewWillDisappear:animated]; 237 [super viewWillDisappear:animated];
199 } 238 }
200 239
201 - (void)didReceiveMemoryWarning { 240 - (void)didReceiveMemoryWarning {
202 [super didReceiveMemoryWarning]; 241 [super didReceiveMemoryWarning];
203 // Dispose of any resources that can be recreated. 242 // Dispose of any resources that can be recreated.
204 } 243 }
205 244
206 #pragma mark - IBAction 245 #pragma mark - IBAction
207 - (IBAction)menuButtonTouchUpInside:(id)sender 246 - (IBAction)menuButtonTouchUpInside:(id)sender
208 { 247 {
209 248
210 } 249 }
211 250
212 - (IBAction)todayButtonTouchUpInside:(id)sender 251 - (IBAction)todayButtonTouchUpInside:(id)sender
213 { 252 {
214 TodayViewController *todayVC = [[TodayViewController alloc] initWithNibName:@"TodayViewController" bundle:nil]; 253 TodayViewController *todayVC = [[TodayViewController alloc] initWithNibName:@"TodayViewController" bundle:nil];
215 todayVC.targetStep = targetStep; 254 todayVC.targetStep = targetStep;
216 [self.navigationController pushViewController:todayVC animated:YES]; 255 [self.navigationController pushViewController:todayVC animated:YES];
217 } 256 }
218 257
219 - (IBAction)leftButtonTouchUpInside:(id)sender 258 - (IBAction)leftButtonTouchUpInside:(id)sender
220 { 259 {
221 self.dateCurrent = [self.dateCurrent dateByAddingTimeInterval:-(24*60*60)]; 260 self.dateCurrent = [self.dateCurrent dateByAddingTimeInterval:-(24*60*60)];
222 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)]; 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)];
223 [self resetStepUI]; 262 [self resetStepUI];
224 [self saveStepForDay:self.dateCurrent]; 263 [self saveStepForDay:self.dateCurrent];
264 [self requestNotice];
225 } 265 }
226 266
227 - (IBAction)rightButtonTouchUpInside:(id)sender 267 - (IBAction)rightButtonTouchUpInside:(id)sender
228 { 268 {
229 self.dateCurrent = [self.dateCurrent dateByAddingTimeInterval:24*60*60]; 269 self.dateCurrent = [self.dateCurrent dateByAddingTimeInterval:24*60*60];
230 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)]; 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)];
231 [self resetStepUI]; 271 [self resetStepUI];
232 //[self saveStepForDay:self.dateCurrent]; 272 //[self saveStepForDay:self.dateCurrent];
233 [self requestTopByDate:self.dateCurrent]; 273 [self requestTopByDate:self.dateCurrent];
274 [self requestNotice];
234 } 275 }
235 276
236 - (IBAction)segmentValueChange:(id)sender { 277 - (IBAction)segmentValueChange:(id)sender {
237 [self resetStepUI]; 278 [self resetStepUI];
238 [self requestTopByDate:self.dateCurrent]; 279 [self requestTopByDate:self.dateCurrent];
239 } 280 }
240 281
241 #pragma mark - Functions Private 282 #pragma mark - Functions Private
242 - (void)saveStepForDay:(NSDate *)date 283 - (void)saveStepForDay:(NSDate *)date
243 { 284 {
244 if ([CMMotionActivityManager isActivityAvailable]) { 285 if ([CMMotionActivityManager isActivityAvailable]) {
245 [progressHud showAnimated:YES]; 286 [progressHud showAnimated:YES];
246 [progressHud setHidden:NO]; 287 [progressHud setHidden:NO];
247 self.bike = 0; 288 self.bike = 0;
248 self.walking = 0; 289 self.walking = 0;
249 self.running = 0; 290 self.running = 0;
250 NSDate *startDate = [date beginningAtMidnightOfDay]; 291 NSDate *startDate = [date beginningAtMidnightOfDay];
251 NSDate *endDate = [startDate dateByAddingTimeInterval:(24*60*60 - 1)]; 292 NSDate *endDate = [startDate dateByAddingTimeInterval:(24*60*60 - 1)];
252 293
253 HomeViewController __weak *weakSelf = self; 294 HomeViewController __weak *weakSelf = self;
254 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog.forDay", NULL); 295 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog.forDay", NULL);
255 dispatch_async(myQueue, ^{ 296 dispatch_async(myQueue, ^{
256 if (weakSelf == nil) { 297 if (weakSelf == nil) {
257 return ; 298 return ;
258 } 299 }
259 300
260 [weakSelf.motionActivityManager queryActivityStartingFromDate:startDate toDate:endDate toQueue:_operationQueue withHandler:^(NSArray<CMMotionActivity *> * _Nullable activities, NSError * _Nullable error) { 301 [weakSelf.motionActivityManager queryActivityStartingFromDate:startDate toDate:endDate toQueue:_operationQueue withHandler:^(NSArray<CMMotionActivity *> * _Nullable activities, NSError * _Nullable error) {
261 if (error || activities.count <= 0) { 302 if (error || activities.count <= 0) {
262 dispatch_async(dispatch_get_main_queue(), ^{ 303 dispatch_async(dispatch_get_main_queue(), ^{
263 [weakSelf updateStepUI]; 304 [weakSelf updateStepUI];
264 }); 305 });
265 return ; 306 return ;
266 } 307 }
267 // set EndDate 308 // set EndDate
268 NSMutableArray *arrayActivities = [[NSMutableArray alloc] init]; 309 NSMutableArray *arrayActivities = [[NSMutableArray alloc] init];
269 for (int i = 0; i < activities.count; i++) { 310 for (int i = 0; i < activities.count; i++) {
270 CMMotionActivity *activity = [activities objectAtIndex:i]; 311 CMMotionActivity *activity = [activities objectAtIndex:i];
271 CMMotionActivityExtra *activityExtra = [[CMMotionActivityExtra alloc] init]; 312 CMMotionActivityExtra *activityExtra = [[CMMotionActivityExtra alloc] init];
272 activityExtra.activity = activity; 313 activityExtra.activity = activity;
273 if (i == activities.count - 1) { 314 if (i == activities.count - 1) {
274 activityExtra.endDate = endDate; 315 activityExtra.endDate = endDate;
275 } 316 }
276 else { 317 else {
277 CMMotionActivity *activityNext = [activities objectAtIndex:i+1]; 318 CMMotionActivity *activityNext = [activities objectAtIndex:i+1];
278 // activityExtra.endDate = [activityNext.startDate dateByAddingTimeInterval:-1]; 319 // activityExtra.endDate = [activityNext.startDate dateByAddingTimeInterval:-1];
279 activityExtra.endDate = activityNext.startDate; 320 activityExtra.endDate = activityNext.startDate;
280 } 321 }
281 [arrayActivities addObject:activityExtra]; 322 [arrayActivities addObject:activityExtra];
282 } 323 }
283 // PhongNV 324 // PhongNV
284 weakSelf.currentIndex = 0; 325 weakSelf.currentIndex = 0;
285 [weakSelf save20objectOfActivityExtras:arrayActivities]; 326 [weakSelf save20objectOfActivityExtras:arrayActivities];
286 }]; 327 }];
287 }); 328 });
288 } 329 }
289 } 330 }
290 331
291 - (void)complete20Request:(NSArray *)activities { 332 - (void)complete20Request:(NSArray *)activities {
292 if (self.totalRequest == self.countComplete) { 333 if (self.totalRequest == self.countComplete) {
293 self.totalRequest = 0; 334 self.totalRequest = 0;
294 self.countComplete = 0; 335 self.countComplete = 0;
295 self.currentIndex++; 336 self.currentIndex++;
296 [self save20objectOfActivityExtras:activities]; 337 [self save20objectOfActivityExtras:activities];
297 } 338 }
298 } 339 }
299 - (void)save20objectOfActivityExtras:(NSArray *)activities 340 - (void)save20objectOfActivityExtras:(NSArray *)activities
300 { 341 {
301 int result = floor(activities.count / maxRequest); 342 int result = floor(activities.count / maxRequest);
302 if (activities.count <= 0 || self.currentIndex > result) { 343 if (activities.count <= 0 || self.currentIndex > result) {
303 self.totalRequest = 0; 344 self.totalRequest = 0;
304 self.countComplete = 0; 345 self.countComplete = 0;
305 self.currentIndex = 0; 346 self.currentIndex = 0;
306 dispatch_async(dispatch_get_main_queue(), ^{ 347 dispatch_async(dispatch_get_main_queue(), ^{
307 [self updateStepUI]; 348 [self updateStepUI];
308 }); 349 });
309 return; 350 return;
310 } 351 }
311 352
312 HomeViewController __weak *weakSelf = self; 353 HomeViewController __weak *weakSelf = self;
313 for (NSInteger index = self.currentIndex*maxRequest; index < self.currentIndex*maxRequest + maxRequest; index++) { 354 for (NSInteger index = self.currentIndex*maxRequest; index < self.currentIndex*maxRequest + maxRequest; index++) {
314 if ((self.currentIndex*maxRequest + maxRequest) >= activities.count) { 355 if ((self.currentIndex*maxRequest + maxRequest) >= activities.count) {
315 self.totalRequest = (int)(activities.count - self.currentIndex*maxRequest); 356 self.totalRequest = (int)(activities.count - self.currentIndex*maxRequest);
316 if (self.totalRequest <= 0) { 357 if (self.totalRequest <= 0) {
317 [weakSelf complete20Request:activities]; 358 [weakSelf complete20Request:activities];
318 } 359 }
319 } 360 }
320 else { 361 else {
321 self.totalRequest = (int)maxRequest; 362 self.totalRequest = (int)maxRequest;
322 } 363 }
323 if (index < activities.count) { 364 if (index < activities.count) {
324 CMMotionActivityExtra *activityExtra = [activities objectAtIndex:index]; 365 CMMotionActivityExtra *activityExtra = [activities objectAtIndex:index];
325 [self.pedometer queryPedometerDataFromDate:activityExtra.activity.startDate toDate:activityExtra.endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) { 366 [self.pedometer queryPedometerDataFromDate:activityExtra.activity.startDate toDate:activityExtra.endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) {
326 if (weakSelf == nil) { 367 if (weakSelf == nil) {
327 return ; 368 return ;
328 } 369 }
329 NSInteger numberStep = [pedometerData.numberOfSteps integerValue]; 370 NSInteger numberStep = [pedometerData.numberOfSteps integerValue];
330 int mode = 1; 371 int mode = 1;
331 if (activityExtra.activity.cycling) { 372 if (activityExtra.activity.cycling) {
332 mode = 3; 373 mode = 3;
333 } 374 }
334 else if (activityExtra.activity.walking) { 375 else if (activityExtra.activity.walking) {
335 mode = 1; 376 mode = 1;
336 } 377 }
337 else if (activityExtra.activity.running) { 378 else if (activityExtra.activity.running) {
338 mode = 2; 379 mode = 2;
339 } 380 }
340 else { 381 else {
341 // unknown 382 // unknown
342 } 383 }
343 // save step to server 384 // save step to server
344 if (numberStep > 0) { 385 if (numberStep > 0) {
345 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 386 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
346 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; 387 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
347 NSString *dateBegin = [dateFormatter stringFromDate:activityExtra.activity.startDate]; 388 NSString *dateBegin = [dateFormatter stringFromDate:activityExtra.activity.startDate];
348 NSString *dateEnd = [dateFormatter stringFromDate:activityExtra.endDate]; 389 NSString *dateEnd = [dateFormatter stringFromDate:activityExtra.endDate];
349 NSLog(@"dateBegin: %@ | dateEnd: %@ | numberStep: %li", dateBegin, dateEnd, numberStep); 390 // NSLog(@"dateBegin: %@ | dateEnd: %@ | numberStep: %li", dateBegin, dateEnd, numberStep);
350 [[ServerAPI server] requestCreateLog:mode withStep:(int)numberStep startDate:dateBegin endDate:dateEnd CompletionHandler:^(NSError *error) { 391 [[ServerAPI server] requestCreateLog:mode withStep:(int)numberStep startDate:dateBegin endDate:dateEnd CompletionHandler:^(NSError *error) {
351 if (error) { 392 if (error) {
352 NSLog(@"Error: %@", error); 393 NSLog(@"Error: %@", error);
353 } 394 }
354 weakSelf.countComplete++; 395 weakSelf.countComplete++;
355 [weakSelf complete20Request:activities]; 396 [weakSelf complete20Request:activities];
356 }]; 397 }];
357 } 398 }
358 else { 399 else {
359 weakSelf.countComplete++; 400 weakSelf.countComplete++;
360 [weakSelf complete20Request:activities]; 401 [weakSelf complete20Request:activities];
361 } 402 }
362 }]; 403 }];
363 } 404 }
364 } 405 }
365 } 406 }
366 407
367 - (void)updateStepUI 408 - (void)updateStepUI
368 { 409 {
369 [self requestTopByDate:self.dateCurrent]; 410 [self requestTopByDate:self.dateCurrent];
370 } 411 }
371 412
372 - (void)saveDataStep7LastDay 413 - (void)saveDataStep7LastDay
373 { 414 {
374 NSDate *dateNow = [NSDate date]; 415 NSDate *dateNow = [NSDate date];
375 for (int index = 0; index < 7; index++) { 416 for (int index = 0; index < 7; index++) {
376 dateNow = [dateNow dateByAddingTimeInterval:-(24*60*60)]; 417 dateNow = [dateNow dateByAddingTimeInterval:-(24*60*60)];
377 [self saveStepByDate:dateNow]; 418 [self saveStepByDate:dateNow];
378 } 419 }
379 } 420 }
380 421
381 - (void)saveStepByDate:(NSDate *)date 422 - (void)saveStepByDate:(NSDate *)date
382 { 423 {
383 if ([CMMotionActivityManager isActivityAvailable]) { 424 if ([CMMotionActivityManager isActivityAvailable]) {
384 NSDate *startDate = [date beginningAtMidnightOfDay]; 425 NSDate *startDate = [date beginningAtMidnightOfDay];
385 NSDate *endDate = [startDate dateByAddingTimeInterval:(24*60*60 - 1)]; 426 NSDate *endDate = [startDate dateByAddingTimeInterval:(24*60*60 - 1)];
386 427
387 HomeViewController __weak *weakSelf = self; 428 HomeViewController __weak *weakSelf = self;
388 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog.7lastday", NULL); 429 dispatch_queue_t myQueue = dispatch_queue_create("mobileworld.jp.lifelog.7lastday", NULL);
389 dispatch_async(myQueue, ^{ 430 dispatch_async(myQueue, ^{
390 if (weakSelf == nil) { 431 if (weakSelf == nil) {
391 return ; 432 return ;
392 } 433 }
393 434
394 [weakSelf.motionActivityManager queryActivityStartingFromDate:startDate toDate:endDate toQueue:_operationQueue withHandler:^(NSArray<CMMotionActivity *> * _Nullable activities, NSError * _Nullable error) { 435 [weakSelf.motionActivityManager queryActivityStartingFromDate:startDate toDate:endDate toQueue:_operationQueue withHandler:^(NSArray<CMMotionActivity *> * _Nullable activities, NSError * _Nullable error) {
395 if (error || activities.count <= 0) { 436 if (error || activities.count <= 0) {
396 return ; 437 return ;
397 } 438 }
398 // set EndDate 439 // set EndDate
399 NSMutableArray *arrayActivities = [[NSMutableArray alloc] init]; 440 NSMutableArray *arrayActivities = [[NSMutableArray alloc] init];
400 for (int i = 0; i < activities.count; i++) { 441 for (int i = 0; i < activities.count; i++) {
401 CMMotionActivity *activity = [activities objectAtIndex:i]; 442 CMMotionActivity *activity = [activities objectAtIndex:i];
402 CMMotionActivityExtra *activityExtra = [[CMMotionActivityExtra alloc] init]; 443 CMMotionActivityExtra *activityExtra = [[CMMotionActivityExtra alloc] init];
403 activityExtra.activity = activity; 444 activityExtra.activity = activity;
404 if (i == activities.count - 1) { 445 if (i == activities.count - 1) {
405 activityExtra.endDate = endDate; 446 activityExtra.endDate = endDate;
406 } 447 }
407 else { 448 else {
408 CMMotionActivity *activityNext = [activities objectAtIndex:i+1]; 449 CMMotionActivity *activityNext = [activities objectAtIndex:i+1];
409 activityExtra.endDate = [activityNext.startDate dateByAddingTimeInterval:-1]; 450 activityExtra.endDate = [activityNext.startDate dateByAddingTimeInterval:-1];
410 } 451 }
411 [arrayActivities addObject:activityExtra]; 452 [arrayActivities addObject:activityExtra];
412 } 453 }
413 454
414 for (CMMotionActivityExtra *activityExtra in arrayActivities) { 455 for (CMMotionActivityExtra *activityExtra in arrayActivities) {
415 [weakSelf.pedometer queryPedometerDataFromDate:activityExtra.activity.startDate toDate:activityExtra.endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) { 456 [weakSelf.pedometer queryPedometerDataFromDate:activityExtra.activity.startDate toDate:activityExtra.endDate withHandler:^(CMPedometerData * _Nullable pedometerData, NSError * _Nullable error) {
416 NSInteger numberStep = [pedometerData.numberOfSteps integerValue]; 457 NSInteger numberStep = [pedometerData.numberOfSteps integerValue];
417 int mode = 1; 458 int mode = 1;
418 if (activityExtra.activity.cycling) { 459 if (activityExtra.activity.cycling) {
419 mode = 3; 460 mode = 3;
420 } 461 }
421 else if (activityExtra.activity.walking) { 462 else if (activityExtra.activity.walking) {
422 mode = 1; 463 mode = 1;
423 } 464 }
424 else if (activityExtra.activity.running) { 465 else if (activityExtra.activity.running) {
425 mode = 2; 466 mode = 2;
426 } 467 }
427 else { 468 else {
428 // unknown 469 // unknown
429 } 470 }
430 471
431 // save step to server 472 // save step to server
432 if (numberStep > 0) { 473 if (numberStep > 0) {
433 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 474 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
434 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; 475 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
435 NSString *dateBegin = [dateFormatter stringFromDate:activityExtra.activity.startDate]; 476 NSString *dateBegin = [dateFormatter stringFromDate:activityExtra.activity.startDate];
436 NSString *dateEnd = [dateFormatter stringFromDate:activityExtra.endDate]; 477 NSString *dateEnd = [dateFormatter stringFromDate:activityExtra.endDate];
437 [[ServerAPI server] requestCreateLog:mode withStep:(int)numberStep startDate:dateBegin endDate:dateEnd CompletionHandler:^(NSError *error) { 478 [[ServerAPI server] requestCreateLog:mode withStep:(int)numberStep startDate:dateBegin endDate:dateEnd CompletionHandler:^(NSError *error) {
438 if (error) { 479 if (error) {
439 NSLog(@"Error: %@", error); 480 NSLog(@"Error: %@", error);
440 } 481 }
441 }]; 482 }];
442 } 483 }
443 }]; 484 }];
444 } 485 }
445 }]; 486 }];
446 }); 487 });
447 } 488 }
448 } 489 }
449 490
450 - (void)updateStepUI:(TargetInfor *)targetInfor 491 - (void)updateStepUI:(TargetInfor *)targetInfor
451 { 492 {
452 NSString *stringTargetStep = [targetInfor.target_step stringByReplacingOccurrencesOfString:@"," withString:@""]; 493 NSString *stringTargetStep = [targetInfor.target_step stringByReplacingOccurrencesOfString:@"," withString:@""];
453 targetStep = [stringTargetStep integerValue]; 494 targetStep = [stringTargetStep integerValue];
454 self.lblValueStep.text = targetInfor.num_step; 495 self.lblValueStep.text = targetInfor.num_step;
455 self.lblValueStepOther.text = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"lifelog.today.remaining.other", nil), targetInfor.remaining_step]; 496 self.lblValueStepOther.text = [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"lifelog.today.remaining.other", nil), targetInfor.remaining_step];
456 self.lblPercent.text = [NSString stringWithFormat:@"%@ %i%@", NSLocalizedString(@"lifelog.today.text.percent", nil), [targetInfor.complete_percent intValue], NSLocalizedString(@"lifelog.today.percent", nil)]; 497 self.lblPercent.text = [NSString stringWithFormat:@"%@ %i%@", NSLocalizedString(@"lifelog.today.text.percent", nil), [targetInfor.complete_percent intValue], NSLocalizedString(@"lifelog.today.percent", nil)];
457 } 498 }
458 499
459 - (void)updateNoticeUI:(HomeObject *)homeObject 500 - (void)updateNoticeUI:(HomeObject *)homeObject
460 { 501 {
461 NSString *stringNotice = @""; 502 NSString *stringNotice = @"";
462 for (NoticeInfor *notice in homeObject.listNotice) { 503 for (NoticeInfor *notice in homeObject.listNotice) {
463 NSString *noticeString = [NSString stringWithFormat:@"%@\n", notice.notice_content]; 504 NSString *noticeString = [NSString stringWithFormat:@"%@\n", notice.notice_content];
464 stringNotice = [stringNotice stringByAppendingString:noticeString]; 505 stringNotice = [stringNotice stringByAppendingString:noticeString];
465 } 506 }
466 _tvNotice.text = stringNotice; 507 _tvNotice.text = stringNotice;
467 } 508 }
468 509
469 - (void)resetStepUI 510 - (void)resetStepUI
470 { 511 {
471 self.lblValueStep.text = @""; 512 self.lblValueStep.text = @"";
472 self.lblValueStepOther.text = @""; 513 self.lblValueStepOther.text = @"";
473 self.lblPercent.text = @""; 514 self.lblPercent.text = @"";
474 } 515 }
475 516
476 @end 517 @end
477 518
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="13196" 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="13173"/> 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="お知らせ" textAlignment="center" 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="20"/> 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 <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="icon_other" translatesAutoresizingMaskIntoConstraints="NO" id="BoP-c1-c0q">
166 <rect key="frame" x="20" y="313" width="75" height="67"/>
167 <constraints>
168 <constraint firstAttribute="width" constant="75" id="lKw-2n-DMo"/>
169 <constraint firstAttribute="height" constant="67" id="m58-CT-3kB"/>
170 </constraints>
171 </imageView>
172 <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">
173 <rect key="frame" x="75" y="575" width="224" height="29"/> 166 <rect key="frame" x="75" y="575" width="224" height="29"/>
174 <segments> 167 <segments>
175 <segment title="BIKE"/> 168 <segment title="BIKE"/>
176 <segment title="WALKING"/> 169 <segment title="WALKING"/>
177 <segment title="RUNNING"/> 170 <segment title="RUNNING"/>
178 </segments> 171 </segments>
179 <color key="tintColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/> 172 <color key="tintColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
180 <connections> 173 <connections>
181 <action selector="segmentValueChange:" destination="-1" eventType="valueChanged" id="kL2-mI-baG"/> 174 <action selector="segmentValueChange:" destination="-1" eventType="valueChanged" id="kL2-mI-baG"/>
182 </connections> 175 </connections>
183 </segmentedControl> 176 </segmentedControl>
184 <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">
185 <rect key="frame" x="103" y="313" width="264" height="204"/> 178 <rect key="frame" x="8" y="313" width="359" height="204"/>
186 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 179 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
187 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 180 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
188 <fontDescription key="fontDescription" type="system" pointSize="14"/> 181 <fontDescription key="fontDescription" type="system" pointSize="17"/>
189 <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/> 182 <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
190 </textView> 183 </textView>
191 </subviews> 184 </subviews>
192 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/> 185 <color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
193 <constraints> 186 <constraints>
194 <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"/>
195 <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"/>
196 <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"/>
197 <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"/>
198 <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"/>
199 <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"/>
200 <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"/>
201 <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"/>
202 <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"/>
203 <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"/>
204 <constraint firstItem="kdD-rj-BtX" firstAttribute="leading" secondItem="BoP-c1-c0q" secondAttribute="trailing" constant="8" id="EE0-bp-sbO"/>
205 <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"/>
206 <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"/>
207 <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"/>
208 <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"/>
209 <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"/>
210 <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"/>
211 <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" id="Iv8-Al-1Ff"/>
212 <constraint firstItem="BoP-c1-c0q" firstAttribute="leading" secondItem="i5M-Pr-FkT" secondAttribute="leading" constant="20" id="OVd-PH-Yxx"/>
213 <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"/>
214 <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"/>
215 <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"/>
216 <constraint firstItem="BoP-c1-c0q" firstAttribute="top" secondItem="lnt-4H-Ao8" secondAttribute="bottom" constant="8" id="bAt-3o-b1H"/>
217 <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"/>
218 <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"/>
219 <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"/>
220 <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"/>
221 <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"/>
222 <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"/>
223 <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"/>
224 <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"/>
225 <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"/>
226 <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"/>
227 <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"/>
228 <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"/>
229 <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"/>
230 <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"/>
231 <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"/>
232 <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"/>
233 <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"/>
234 <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"/>
235 <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"/>
236 </constraints> 227 </constraints>
237 <point key="canvasLocation" x="33.5" y="97.5"/> 228 <point key="canvasLocation" x="33.5" y="97.5"/>
238 </view> 229 </view>
239 </objects> 230 </objects>
240 <resources> 231 <resources>
241 <image name="avatar_default" width="80" height="80"/> 232 <image name="avatar_default" width="80" height="80"/>
242 <image name="icon_left" width="30" height="30"/> 233 <image name="icon_left" width="30" height="30"/>
243 <image name="icon_menu" width="30" height="30"/> 234 <image name="icon_menu" width="30" height="30"/>
244 <image name="icon_other" width="150" height="134"/>
245 <image name="icon_right" width="30" height="30"/> 235 <image name="icon_right" width="30" height="30"/>
246 </resources> 236 </resources>
247 </document> 237 </document>
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>4</string> 26 <string>5</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/ServerAPI.h
1 // 1 //
2 // ServerAPI.h 2 // ServerAPI.h
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 <Foundation/Foundation.h> 9 #import <Foundation/Foundation.h>
10 #import "Entities.h" 10 #import "Entities.h"
11 11
12 extern NSString *const kServerAddress; 12 extern NSString *const kServerAddress;
13 extern NSString *const kUser; 13 extern NSString *const kUser;
14 extern NSString *const kToken; 14 extern NSString *const kToken;
15 extern NSString *const kNotificationToken; 15 extern NSString *const kNotificationToken;
16 16
17 @interface ServerAPI : NSObject 17 @interface ServerAPI : NSObject
18 + (instancetype) server; 18 + (instancetype) server;
19 @property (nonatomic, assign) NSTimeInterval timeOutInterval; 19 @property (nonatomic, assign) NSTimeInterval timeOutInterval;
20 20
21 #pragma mark - Login and Register 21 #pragma mark - Login and Register
22 - (void)loginWithEmail:(NSString *)email Password:(NSString *)password CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion; 22 - (void)loginWithEmail:(NSString *)email Password:(NSString *)password CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion;
23 - (void)registerUserWithParams:(NSDictionary *)params CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion; 23 - (void)registerUserWithParams:(NSDictionary *)params CompletionHandler: (void (^)(User *, NSString *, NSError *)) completion;
24 - (void)uploadImage:(NSString *)token andImageData:(NSData *)data CompletionHandler:(void (^)(NSString *, NSError *)) completion; 24 - (void)uploadImage:(NSString *)token andImageData:(NSData *)data CompletionHandler:(void (^)(NSString *, NSError *)) completion;
25 - (void)forgetPass:(NSString *)email CompletionHandler:(void (^)(NSError *)) completion; 25 - (void)forgetPass:(NSString *)email CompletionHandler:(void (^)(NSError *)) completion;
26 - (void)confirmForgetPass:(NSString *)email withConfirm:(NSString *)confirm CompletionHandler:(void (^)(NSError *)) completion; 26 - (void)confirmForgetPass:(NSString *)email withConfirm:(NSString *)confirm CompletionHandler:(void (^)(NSError *)) completion;
27 27
28 #pragma mark - Home Screen Function 28 #pragma mark - Home Screen Function
29 - (void)requestTopWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(TopObject *, NSError *)) completion; 29 - (void)requestTopWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(TopObject *, NSError *)) completion;
30 - (void)requestCreateLog:(int)mode withStep:(int)numStep startDate:(NSString *)startDate endDate:(NSString *)endDate CompletionHandler:(void (^)(NSError *))completion; 30 - (void)requestCreateLog:(int)mode withStep:(int)numStep startDate:(NSString *)startDate endDate:(NSString *)endDate CompletionHandler:(void (^)(NSError *))completion;
31 - (void)requestHomeWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(HomeObject *, NSError *)) completion; 31 - (void)requestHomeWithMode:(int)mode andDate:(NSString *)date CompletionHandler:(void (^)(HomeObject *, NSError *)) completion;
32 32
33 #pragma mark - History Screen Function 33 #pragma mark - History Screen Function
34 - (void) requestHistory:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion; 34 - (void) requestHistory:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
35 - (void) requestHistoryList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion; 35 - (void) requestHistoryList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
36 - (void) requestJoinGroup:(NSString *)token groupID: (int) groupID CompletionHandler:(void (^)(NSError *)) completion; 36 - (void) requestJoinGroup:(NSString *)token groupID: (int) groupID CompletionHandler:(void (^)(NSError *)) completion;
37 -(void) requestCreateGroup:(NSString *)token withGroup:(GroupObject *)group CompletionHandler:(void (^)(GroupObject *, NSError *)) completion; 37 -(void) requestCreateGroup:(NSString *)token withGroup:(GroupObject *)group CompletionHandler:(void (^)(GroupObject *, NSError *)) completion;
38 - (void) requestGroupList:(NSString *)token CompletionHandler:(void (^)(NSArray *, NSError *)) completion; 38 - (void) requestGroupList:(NSString *)token CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
39 39
40 #pragma mark - SNS Screen Function 40 #pragma mark - SNS Screen Function
41 /* 41 /*
42 Get tweet of group and get recent tweet is same API 42 Get tweet of group and get recent tweet is same API
43 If groupID equal -1, it will request recent tweet. Otherwise will request tweet of group 43 If groupID equal -1, it will request recent tweet. Otherwise will request tweet of group
44 */ 44 */
45 - (void) requestTweetsList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion; 45 - (void) requestTweetsList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
46 - (void) searchGroup:(NSString *)token withKey:(NSString *)key andPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion; 46 - (void) searchGroup:(NSString *)token withKey:(NSString *)key andPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
47 47
48 #pragma mark - Group Function 48 #pragma mark - Group Function
49 - (void) getGroupDetail:(NSString *)token withGroupID:(int)groupID CompletionHandler:(void (^)(GroupObject *, NSError *)) completion; 49 - (void) getGroupDetail:(NSString *)token withGroupID:(int)groupID CompletionHandler:(void (^)(GroupObject *, NSError *)) completion;
50 - (void) requestMemberList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion; 50 - (void) requestMemberList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
51 51
52 #pragma mark - Ranking API 52 #pragma mark - Ranking API
53 - (void) requestRankingList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate mode:(int) mode page:(int) page CompletionHandler:(void (^)(NSArray *, NSError *)) completion; 53 - (void) requestRankingList:(NSString *)token startDate:(NSDate *)startDate endDate:(NSDate *)endDate mode:(int) mode page:(int) page CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
54 54
55 #pragma mark - Common API 55 #pragma mark - Common API
56 - (void)refreshToken: (NSString *)userID CompletionHandler:(void (^)(NSString *, NSError *))completion; 56 - (void)refreshToken: (NSString *)userID CompletionHandler:(void (^)(NSString *, NSError *))completion;
57 #pragma mark - Get Notice
58 - (void)getNoticeByDate: (NSString *)date CompletionHandler:(void (^)(NSArray *, NSError *)) completion;
57 @end 59 @end
58 60
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