Compare View

switch
from
...
to
 
Commits (3)

Changes

Showing 22 changed files Inline Diff

LifeLog/LifeLog/Assets.xcassets/History/arrow_decre.imageset/Contents.json
File was created 1 {
2 "images" : [
3 {
4 "idiom" : "universal",
5 "scale" : "1x"
6 },
7 {
8 "idiom" : "universal",
9 "filename" : "arrow_decre.png",
10 "scale" : "2x"
11 },
12 {
13 "idiom" : "universal",
14 "scale" : "3x"
15 }
16 ],
17 "info" : {
18 "version" : 1,
19 "author" : "xcode"
20 }
21 }
LifeLog/LifeLog/Assets.xcassets/History/arrow_decre.imageset/arrow_decre.png

1.33 KB

LifeLog/LifeLog/Assets.xcassets/History/arrow_incre.imageset/Contents.json
File was created 1 {
2 "images" : [
3 {
4 "idiom" : "universal",
5 "scale" : "1x"
6 },
7 {
8 "idiom" : "universal",
9 "filename" : "arrow_incre.png",
10 "scale" : "2x"
11 },
12 {
13 "idiom" : "universal",
14 "scale" : "3x"
15 }
16 ],
17 "info" : {
18 "version" : 1,
19 "author" : "xcode"
20 }
21 }
LifeLog/LifeLog/Assets.xcassets/History/arrow_incre.imageset/arrow_incre.png

1.49 KB

LifeLog/LifeLog/BaseTableViewController.h
1 // 1 //
2 // BaseTableViewController.h 2 // BaseTableViewController.h
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by nvtu on 8/11/17. 5 // Created by nvtu on 8/11/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
11 @interface BaseTableViewController : UIViewController<UITableViewDelegate, UITableViewDataSource> { 11 @interface BaseTableViewController : UIViewController<UITableViewDelegate, UITableViewDataSource> {
12 NSMutableArray * _curDataList; 12 NSMutableArray * _curDataList;
13 BOOL _firstTime; 13 BOOL _firstTime;
14 BOOL _isLoading; 14 BOOL _isLoading;
15 BOOL _isEndOfResult; 15 BOOL _isEndOfResult;
16 BOOL _isDisableLoadMore;
16 int _curPage; 17 int _curPage;
17 } 18 }
18 19
19 @property (weak, nonatomic) IBOutlet UITableView *tableBase; 20 @property (weak, nonatomic) IBOutlet UITableView *tableBase;
20 @property (strong, nonatomic) UIRefreshControl *refreshControl; 21 @property (strong, nonatomic) UIRefreshControl *refreshControl;
21 22
22 -(void) callRequestToUpdateData; 23 -(void) callRequestToUpdateData;
23 -(void) updateTableData : (NSArray *) array error: (NSError *) error; 24 -(void) updateTableData : (NSArray *) array error: (NSError *) error;
24 -(void) resetData; 25 -(void) resetData;
25 @end 26 @end
26 27
LifeLog/LifeLog/BaseTableViewController.m
1 // 1 //
2 // BaseTableViewController.m 2 // BaseTableViewController.m
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by nvtu on 8/11/17. 5 // Created by nvtu on 8/11/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import "BaseTableViewController.h" 9 #import "BaseTableViewController.h"
10 #import "Utilities.h" 10 #import "Utilities.h"
11 11
12 @interface BaseTableViewController () 12 @interface BaseTableViewController ()
13 13
14 @end 14 @end
15 15
16 @implementation BaseTableViewController 16 @implementation BaseTableViewController
17 17
18 - (void)viewDidLoad { 18 - (void)viewDidLoad {
19 [super viewDidLoad]; 19 [super viewDidLoad];
20 _firstTime = false; 20 _firstTime = false;
21 _curPage = 1; 21 _curPage = 1;
22 _isEndOfResult = false; 22 _isEndOfResult = false;
23 _isDisableLoadMore = false;
23 _curDataList = [[NSMutableArray alloc] init]; 24 _curDataList = [[NSMutableArray alloc] init];
24 self.refreshControl = [[UIRefreshControl alloc] init]; 25 self.refreshControl = [[UIRefreshControl alloc] init];
25 [self.refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged]; 26 [self.refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged];
26 [self.tableBase addSubview:self.refreshControl]; 27 [self.tableBase addSubview:self.refreshControl];
27 // Do any additional setup after loading the view. 28 // Do any additional setup after loading the view.
28 } 29 }
29 30
30 - (void)didReceiveMemoryWarning { 31 - (void)didReceiveMemoryWarning {
31 [super didReceiveMemoryWarning]; 32 [super didReceiveMemoryWarning];
32 // Dispose of any resources that can be recreated. 33 // Dispose of any resources that can be recreated.
33 } 34 }
34 35
35 -(void) callRequestToUpdateData { 36 -(void) callRequestToUpdateData {
36 _isLoading = true; 37 _isLoading = true;
37 } 38 }
38 39
39 -(void) resetData { 40 -(void) resetData {
40 _isLoading = false; 41 _isLoading = false;
41 _isEndOfResult = false; 42 _isEndOfResult = false;
42 _firstTime = false; 43 _firstTime = false;
43 _curPage = 1; 44 _curPage = 1;
44 [_curDataList removeAllObjects]; 45 [_curDataList removeAllObjects];
45 [self.tableBase reloadData]; 46 [self.tableBase reloadData];
46 [self callRequestToUpdateData]; 47 [self callRequestToUpdateData];
47 } 48 }
48 49
49 -(void) refreshTable { 50 -(void) refreshTable {
50 [self resetData]; 51 [self resetData];
51 } 52 }
52 53
53 -(void) updateTableData : (NSArray *) array error: (NSError *) error { 54 -(void) updateTableData : (NSArray *) array error: (NSError *) error {
54 BaseTableViewController __weak *weakSelf = self; 55 BaseTableViewController __weak *weakSelf = self;
55 _isLoading = false; 56 _isLoading = false;
56 _firstTime = true; 57 _firstTime = true;
57 if(self.refreshControl != nil) { 58 if(self.refreshControl != nil) {
58 dispatch_async(dispatch_get_main_queue(), ^{ 59 dispatch_async(dispatch_get_main_queue(), ^{
59 [self.refreshControl endRefreshing]; 60 [self.refreshControl endRefreshing];
60 }); 61 });
61 } 62 }
62 if(error == nil) { 63 if(error == nil) {
63 if(array.count != 0) { 64 if(array.count != 0) {
64 if(_curPage == 1) { 65 if(_curPage == 1) {
65 [_curDataList removeAllObjects]; 66 [_curDataList removeAllObjects];
66 } 67 }
67 [_curDataList addObjectsFromArray:array]; 68 [_curDataList addObjectsFromArray:array];
68 dispatch_async(dispatch_get_main_queue(), ^{ 69 dispatch_async(dispatch_get_main_queue(), ^{
69 [weakSelf.tableBase reloadData]; 70 [weakSelf.tableBase reloadData];
70 }); 71 });
71 } 72 }
72 else { 73 else {
73 if(_curPage != 1) { 74 if(_curPage != 1) {
74 _isEndOfResult = true; 75 _isEndOfResult = true;
75 _curPage -= 1; 76 _curPage -= 1;
76 } 77 }
77 else { 78 else {
78 dispatch_async(dispatch_get_main_queue(), ^{ 79 dispatch_async(dispatch_get_main_queue(), ^{
79 [weakSelf.tableBase reloadData]; 80 [weakSelf.tableBase reloadData];
80 }); 81 });
81 } 82 }
82 } 83 }
83 } 84 }
84 else { 85 else {
85 _curPage = MAX(1, _curPage - 1); 86 _curPage = MAX(1, _curPage - 1);
86 dispatch_async(dispatch_get_main_queue(), ^{ 87 dispatch_async(dispatch_get_main_queue(), ^{
87 NSString *message = [error.userInfo objectForKey:@"message"]; 88 NSString *message = [error.userInfo objectForKey:@"message"];
88 [Utilities showErrorMessage:message withViewController:weakSelf]; 89 [Utilities showErrorMessage:message withViewController:weakSelf];
89 }); 90 });
90 } 91 }
91 } 92 }
92 93
93 #pragma mark UITableView Delegate 94 #pragma mark UITableView Delegate
94 - (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView { 95 - (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView {
95 if((_curDataList == nil || _curDataList.count == 0) && _firstTime) { 96 if((_curDataList == nil || _curDataList.count == 0) && _firstTime) {
96 UILabel * noDataLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, tableView.frame.size.height)]; 97 UILabel * noDataLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, tableView.frame.size.height)];
97 noDataLabel.text = @"No data available"; 98 noDataLabel.text = @"No data available";
98 noDataLabel.backgroundColor = [UIColor clearColor]; 99 noDataLabel.backgroundColor = [UIColor clearColor];
99 noDataLabel.textColor = [UIColor whiteColor]; 100 noDataLabel.textColor = [UIColor whiteColor];
100 noDataLabel.textAlignment = NSTextAlignmentCenter; 101 noDataLabel.textAlignment = NSTextAlignmentCenter;
101 tableView.backgroundView = noDataLabel; 102 tableView.backgroundView = noDataLabel;
102 tableView.backgroundView.layer.zPosition -= 1; 103 tableView.backgroundView.layer.zPosition -= 1;
103 return 0; 104 return 0;
104 } 105 }
105 tableView.backgroundView = nil; 106 tableView.backgroundView = nil;
106 return 1; 107 return 1;
107 } 108 }
108 109
109 - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 110 - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
110 return _curDataList.count; 111 return _curDataList.count;
111 } 112 }
112 113
113 - (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 114 - (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
114 NSInteger lastRowIndex = [tableView numberOfRowsInSection:0] - 1; 115 NSInteger lastRowIndex = [tableView numberOfRowsInSection:0] - 1;
115 if (indexPath.row == lastRowIndex) { 116 if (indexPath.row == lastRowIndex) {
116 // This is the last cell 117 // This is the last cell
117 if(!_isLoading) { 118 if(!_isLoading && !_isDisableLoadMore) {
118 _curPage += 1; 119 _curPage += 1;
119 [self callRequestToUpdateData]; 120 [self callRequestToUpdateData];
120 } 121 }
121 } 122 }
122 } 123 }
123 @end 124 @end
124 125
LifeLog/LifeLog/GroupDetailViewController.m
1 // 1 //
2 // GroupDetailViewController.m 2 // GroupDetailViewController.m
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by nvtu on 8/13/17. 5 // Created by nvtu on 8/13/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import "GroupDetailViewController.h" 9 #import "GroupDetailViewController.h"
10 #import <SDWebImage/UIImageView+WebCache.h> 10 #import <SDWebImage/UIImageView+WebCache.h>
11 11
12 #import "Utilities.h" 12 #import "Utilities.h"
13 #import "ServerAPI.h" 13 #import "ServerAPI.h"
14 #import "SNSRecentTopicTableViewCell.h" 14 #import "SNSRecentTopicTableViewCell.h"
15 15
16 @interface GroupDetailViewController () 16 @interface GroupDetailViewController ()
17 17
18 @end 18 @end
19 19
20 @implementation GroupDetailViewController 20 @implementation GroupDetailViewController
21 21
22 - (void)viewDidLoad { 22 - (void)viewDidLoad {
23 [super viewDidLoad]; 23 [super viewDidLoad];
24 isMemberList = false; 24 isMemberList = false;
25 //register nib for table view 25 //register nib for table view
26 [self.tableBase registerNib:[UINib nibWithNibName:@"SNSRecentTopicTableViewCell" bundle:nil] forCellReuseIdentifier:@"RecentTopicCell"]; 26 [self.tableBase registerNib:[UINib nibWithNibName:@"SNSRecentTopicTableViewCell" bundle:nil] forCellReuseIdentifier:@"RecentTopicCell"];
27 if(_curGroup != nil) { 27 if(_curGroup != nil) {
28 [self requestGroupDetail]; 28 [self requestGroupDetail];
29 } 29 }
30 // Do any additional setup after loading the view from its nib. 30 // Do any additional setup after loading the view from its nib.
31 } 31 }
32 32
33 - (void)didReceiveMemoryWarning { 33 - (void)didReceiveMemoryWarning {
34 [super didReceiveMemoryWarning]; 34 [super didReceiveMemoryWarning];
35 // Dispose of any resources that can be recreated. 35 // Dispose of any resources that can be recreated.
36 } 36 }
37 37
38 - (void) setGroup : (GroupObject *) object { 38 - (void) setGroup : (GroupObject *) object {
39 _curGroup = object; 39 _curGroup = object;
40 } 40 }
41 41
42 - (void)setupView { 42 - (void)setupView {
43 if(_curGroup != nil) { 43 if(_curGroup != nil) {
44 if(self.imgAva != nil && _curGroup.avatar && ![_curGroup.avatar isKindOfClass:[NSNull class]]) { 44 if(self.imgAva != nil && _curGroup.avatar && ![_curGroup.avatar isKindOfClass:[NSNull class]]) {
45 [self.imgAva sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:_curGroup.avatar]]]; 45 [self.imgAva sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:_curGroup.avatar]]];
46 } 46 }
47 if(self.lblGrpName != nil) { 47 if(self.lblGrpName != nil) {
48 [self.lblGrpName setText:_curGroup.name]; 48 [self.lblGrpName setText:_curGroup.name];
49 } 49 }
50 if(self.btJoinGrp != nil) { 50 if(self.btJoinGrp != nil) {
51 [self.btJoinGrp setHidden:false]; 51 [self.btJoinGrp setHidden:false];
52 } 52 }
53 NSString *mode = @""; 53 NSString *mode = @"";
54 NSString *goalText = [NSString stringWithFormat:@"%@\n", _curGroup.goal]; 54 NSString *goalText = [NSString stringWithFormat:@"%@\n", _curGroup.goal];
55 if(_curGroup.runMode || _curGroup.walkMode || _curGroup.bikeMode) { 55 if(_curGroup.runMode || _curGroup.walkMode || _curGroup.bikeMode) {
56 goalText = [goalText stringByAppendingString:@"1日 目標 "]; 56 goalText = [goalText stringByAppendingString:@"1日 目標 "];
57 } 57 }
58 if(_curGroup.runMode) { 58 if(_curGroup.runMode) {
59 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.running", nil)]; 59 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.running", nil)];
60 mode = [mode stringByAppendingString:@"\n"]; 60 mode = [mode stringByAppendingString:@"\n"];
61 goalText = [goalText stringByAppendingFormat:@"RUN %dm, ", _curGroup.runGoal]; 61 goalText = [goalText stringByAppendingFormat:@"RUN %dm, ", _curGroup.runGoal];
62 } 62 }
63 if(_curGroup.walkMode) { 63 if(_curGroup.walkMode) {
64 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.walking", nil)]; 64 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.walking", nil)];
65 mode = [mode stringByAppendingString:@"\n"]; 65 mode = [mode stringByAppendingString:@"\n"];
66 goalText = [goalText stringByAppendingFormat:@"WALK %dm, ", _curGroup.walkGoal]; 66 goalText = [goalText stringByAppendingFormat:@"WALK %dm, ", _curGroup.walkGoal];
67 } 67 }
68 if(_curGroup.bikeMode) { 68 if(_curGroup.bikeMode) {
69 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.bike", nil)]; 69 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.bike", nil)];
70 mode = [mode stringByAppendingString:@"\n"]; 70 mode = [mode stringByAppendingString:@"\n"];
71 goalText = [goalText stringByAppendingFormat:@"BIKE %dm, ", _curGroup.bikeGoal]; 71 goalText = [goalText stringByAppendingFormat:@"BIKE %dm, ", _curGroup.bikeGoal];
72 } 72 }
73 if(_curGroup.stepMode) { 73 if(_curGroup.stepMode) {
74 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.step", nil)]; 74 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.step", nil)];
75 mode = [mode stringByAppendingString:@"\n"]; 75 mode = [mode stringByAppendingString:@"\n"];
76 } 76 }
77 if(_curGroup.beginMode) { 77 if(_curGroup.beginMode) {
78 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.begin", nil)]; 78 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.begin", nil)];
79 mode = [mode stringByAppendingString:@"\n"]; 79 mode = [mode stringByAppendingString:@"\n"];
80 } 80 }
81 if(_curGroup.gymMode) { 81 if(_curGroup.gymMode) {
82 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.gym", nil)]; 82 mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.gym", nil)];
83 mode = [mode stringByAppendingString:@"\n"]; 83 mode = [mode stringByAppendingString:@"\n"];
84 } 84 }
85 NSRange range = [mode rangeOfString:@"\n" options:NSBackwardsSearch]; 85 NSRange range = [mode rangeOfString:@"\n" options:NSBackwardsSearch];
86 if(range.length > 0) { 86 if(range.length > 0) {
87 mode = [mode stringByReplacingOccurrencesOfString:@"\n" withString:@"" options:NSBackwardsSearch range:range]; 87 mode = [mode stringByReplacingOccurrencesOfString:@"\n" withString:@"" options:NSBackwardsSearch range:range];
88 } 88 }
89 range = [goalText rangeOfString:@", " options:NSBackwardsSearch]; 89 range = [goalText rangeOfString:@", " options:NSBackwardsSearch];
90 if(range.length > 0) { 90 if(range.length > 0) {
91 goalText = [goalText stringByReplacingOccurrencesOfString:@", " withString:@"" options:NSBackwardsSearch range:range]; 91 goalText = [goalText stringByReplacingOccurrencesOfString:@", " withString:@"" options:NSBackwardsSearch range:range];
92 } 92 }
93 [self.lbbGrpActiveMode setText:mode]; 93 [self.lbbGrpActiveMode setText:mode];
94 [self.lblGrpGoal setText:goalText]; 94 [self.lblGrpGoal setText:goalText];
95 } 95 }
96 } 96 }
97 97
98 - (void) requestGroupDetail { 98 - (void) requestGroupDetail {
99 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 99 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
100 MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; 100 MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
101 [[ServerAPI server] getGroupDetail:token withGroupID:_curGroup.groupID CompletionHandler:^(GroupObject *object, NSError *error) { 101 [[ServerAPI server] getGroupDetail:token withGroupID:_curGroup.groupID CompletionHandler:^(GroupObject *object, NSError *error) {
102 GroupDetailViewController __weak *weakSelf = self; 102 GroupDetailViewController __weak *weakSelf = self;
103 [_curGroup updateDate:object]; 103 [_curGroup updateDate:object];
104 dispatch_async(dispatch_get_main_queue(), ^{ 104 dispatch_async(dispatch_get_main_queue(), ^{
105 [hudView hideAnimated:true]; 105 [hudView hideAnimated:true];
106 [weakSelf setupView]; 106 [weakSelf setupView];
107 [weakSelf callRequestToUpdateData]; 107 [weakSelf callRequestToUpdateData];
108 }); 108 });
109 }]; 109 }];
110 } 110 }
111 111
112 #pragma mark IBAction 112 #pragma mark IBAction
113 113
114 - (IBAction)clickBack:(id)sender { 114 - (IBAction)clickBack:(id)sender {
115 [self.navigationController popViewControllerAnimated:true]; 115 [self.navigationController popViewControllerAnimated:true];
116 } 116 }
117 117
118 - (IBAction)clickSwitch:(AutoTransButton *)sender { 118 - (IBAction)clickSwitch:(AutoTransButton *)sender {
119 isMemberList = !isMemberList; 119 isMemberList = !isMemberList;
120 if(isMemberList) { 120 if(isMemberList) {
121 [sender setTitle:NSLocalizedString(@"lifelog.grDetail.bt.viewTweet", nil) forState:UIControlStateNormal]; 121 [sender setTitle:NSLocalizedString(@"lifelog.grDetail.bt.viewTweet", nil) forState:UIControlStateNormal];
122 } 122 }
123 else { 123 else {
124 [sender setTitle:NSLocalizedString(@"lifelog.grDetail.bt.viewMem", nil) forState:UIControlStateNormal]; 124 [sender setTitle:NSLocalizedString(@"lifelog.grDetail.bt.viewMem", nil) forState:UIControlStateNormal];
125 } 125 }
126 [sender setUserInteractionEnabled:false]; 126 [sender setUserInteractionEnabled:false];
127 [self resetData]; 127 [self resetData];
128 } 128 }
129 129
130 - (IBAction)clickJoin:(AutoTransButton *)sender { 130 - (IBAction)clickJoin:(AutoTransButton *)sender {
131 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 131 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
132 MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; 132 MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
133 [[ServerAPI server] requestJoinGroup:token groupID:_curGroup.groupID CompletionHandler:^(NSError *error){ 133 [[ServerAPI server] requestJoinGroup:token groupID:_curGroup.groupID CompletionHandler:^(NSError *error){
134 GroupDetailViewController __weak *weakSelf = self; 134 GroupDetailViewController __weak *weakSelf = self;
135 dispatch_async(dispatch_get_main_queue(), ^{ 135 dispatch_async(dispatch_get_main_queue(), ^{
136 [hudView hideAnimated:true]; 136 [hudView hideAnimated:true];
137 if(error == nil) { 137 if(error == nil) {
138 _curGroup.isJoin = true; 138 _curGroup.isJoin = true;
139 [weakSelf.btJoinGrp setHidden:_curGroup.isJoin]; 139 [weakSelf.btJoinGrp setHidden:_curGroup.isJoin];
140 [Utilities showMessage:@"Join successfully" withViewController:weakSelf]; 140 [Utilities showMessage:@"Join successfully" withViewController:weakSelf];
141 } 141 }
142 }); 142 });
143 }]; 143 }];
144 144
145 } 145 }
146 146
147 147
148 148
149 #pragma mark UITableView Delegate 149 #pragma mark UITableView Delegate
150 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 150 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
151 SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"]; 151 SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"];
152 if(isMemberList) { 152 if(isMemberList) {
153 MemberObject *object = [_curDataList objectAtIndex:indexPath.row]; 153 MemberObject *object = [_curDataList objectAtIndex:indexPath.row];
154 [cell setMemberData:object]; 154 [cell setMemberData:object];
155 }
156 else {
157 TweetObject *object = [_curDataList objectAtIndex:indexPath.row];
158 [cell setTweetsData:object];
159 }
160
161 return cell;
162 }
163
164 #pragma mark Private Function
165
166 -(void) callRequestToUpdateData { 155 }
167 [super callRequestToUpdateData]; 156 else {
168 157 TweetObject *object = [_curDataList objectAtIndex:indexPath.row];
169 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; 158 [cell setTweetsData:object];
170 MBProgressHUD *hudView = nil;
171 if(_curPage == 1 && !self.refreshControl.isRefreshing) {
172 hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
173 }
174 if(isMemberList) {
175 [[ServerAPI server] requestMemberList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){
176 dispatch_async(dispatch_get_main_queue(), ^{
177 if(hudView != nil) {
178 [hudView hideAnimated:true];
179 }
180 });
181 GroupDetailViewController __weak *weakSelf = self; 159 }
182 [weakSelf updateTableData:array error:error]; 160
183 [weakSelf.btSwitch setUserInteractionEnabled:true]; 161 return cell;
184 }]; 162 }
185 } 163
186 else { 164 #pragma mark Private Function
187 [[ServerAPI server] requestTweetsList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){ 165
188 dispatch_async(dispatch_get_main_queue(), ^{ 166 -(void) callRequestToUpdateData {
189 if(hudView != nil) { 167 [super callRequestToUpdateData];
190 [hudView hideAnimated:true]; 168
191 } 169 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
192 }); 170 MBProgressHUD *hudView = nil;
193 GroupDetailViewController __weak *weakSelf = self; 171 if(_curPage == 1 && !self.refreshControl.isRefreshing) {
194 [weakSelf updateTableData:array error:error]; 172 hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
195 [weakSelf.btSwitch setUserInteractionEnabled:true]; 173 }
196 }]; 174 if(isMemberList) {
197 } 175 [[ServerAPI server] requestMemberList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){
198 } 176 dispatch_async(dispatch_get_main_queue(), ^{
199 177 if(hudView != nil) {
200 @end 178 [hudView hideAnimated:true];
201 179 }
LifeLog/LifeLog/HistoryListTableViewCell.h
1 // 1 //
2 // HistoryListTableViewCell.h 2 // HistoryListTableViewCell.h
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by nvtu on 8/3/17. 5 // Created by nvtu on 8/3/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 10
11 @interface HistoryListTableViewCell : UITableViewCell 11 @interface HistoryListTableViewCell : UITableViewCell
12 12
13 @property (weak, nonatomic) IBOutlet UIImageView *imgArrow;
14
13 @property (weak, nonatomic) IBOutlet UILabel *lblTitle; 15 @property (weak, nonatomic) IBOutlet UILabel *lblTitle;
14 @property (weak, nonatomic) IBOutlet UILabel *lblStep; 16 @property (weak, nonatomic) IBOutlet UILabel *lblStep;
17 @property (weak, nonatomic) IBOutlet UILabel *lblDiff;
15 @property (weak, nonatomic) IBOutlet UILabel *lblDistance; 18 @property (weak, nonatomic) IBOutlet UILabel *lblDistance;
16 @property (weak, nonatomic) IBOutlet UILabel *lblPower; 19 @property (weak, nonatomic) IBOutlet UILabel *lblPower;
17 @property (weak, nonatomic) IBOutlet UILabel *lblDuration; 20 @property (weak, nonatomic) IBOutlet UILabel *lblDuration;
18 21
19 @end 22 @end
20 23
LifeLog/LifeLog/HistoryListTableViewCell.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="12121" systemVersion="16A323" 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 <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
8 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> 8 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9 </dependencies> 9 </dependencies>
10 <objects> 10 <objects>
11 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> 11 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
12 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> 12 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
13 <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="HistoryListCell" rowHeight="100" id="KGk-i7-Jjw" customClass="HistoryListTableViewCell"> 13 <tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="HistoryListCell" rowHeight="100" id="KGk-i7-Jjw" customClass="HistoryListTableViewCell">
14 <rect key="frame" x="0.0" y="0.0" width="320" height="188"/> 14 <rect key="frame" x="0.0" y="0.0" width="320" height="188"/>
15 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> 15 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
16 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> 16 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
17 <rect key="frame" x="0.0" y="0.0" width="320" height="188"/> 17 <rect key="frame" x="0.0" y="0.0" width="320" height="188"/>
18 <autoresizingMask key="autoresizingMask"/> 18 <autoresizingMask key="autoresizingMask"/>
19 <subviews> 19 <subviews>
20 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="l97-iI-4Nl"> 20 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="l97-iI-4Nl">
21 <rect key="frame" x="0.0" y="0.0" width="320" height="35"/> 21 <rect key="frame" x="0.0" y="0.0" width="320" height="35"/>
22 <subviews> 22 <subviews>
23 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1日(月 )" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zW0-JI-PIE"> 23 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1日(月 )" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="zW0-JI-PIE">
24 <rect key="frame" x="4" y="0.0" width="80" height="30"/> 24 <rect key="frame" x="4" y="0.0" width="80" height="30"/>
25 <constraints> 25 <constraints>
26 <constraint firstAttribute="width" constant="80" id="2SR-JF-W5T"/> 26 <constraint firstAttribute="width" constant="80" id="2SR-JF-W5T"/>
27 </constraints> 27 </constraints>
28 <fontDescription key="fontDescription" type="system" pointSize="13"/> 28 <fontDescription key="fontDescription" type="system" pointSize="13"/>
29 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 29 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
30 <nil key="highlightedColor"/> 30 <nil key="highlightedColor"/>
31 </label> 31 </label>
32 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qgK-8d-giH"> 32 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="qgK-8d-giH">
33 <rect key="frame" x="240" y="0.0" width="80" height="30"/> 33 <rect key="frame" x="240" y="0.0" width="80" height="30"/>
34 <constraints> 34 <constraints>
35 <constraint firstAttribute="width" constant="80" id="efJ-dz-Eyh"/> 35 <constraint firstAttribute="width" constant="80" id="efJ-dz-Eyh"/>
36 </constraints> 36 </constraints>
37 <fontDescription key="fontDescription" type="system" pointSize="13"/> 37 <fontDescription key="fontDescription" type="system" pointSize="13"/>
38 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 38 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
39 <nil key="highlightedColor"/> 39 <nil key="highlightedColor"/>
40 </label> 40 </label>
41 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000 step" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Eop-bg-Dy9"> 41 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000 step" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Eop-bg-Dy9">
42 <rect key="frame" x="84" y="0.0" width="156" height="30"/> 42 <rect key="frame" x="84" y="0.0" width="156" height="30"/>
43 <fontDescription key="fontDescription" type="system" pointSize="13"/> 43 <fontDescription key="fontDescription" type="system" pointSize="13"/>
44 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> 44 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
45 <nil key="highlightedColor"/> 45 <nil key="highlightedColor"/>
46 </label> 46 </label>
47 <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="arrow_incre" translatesAutoresizingMaskIntoConstraints="NO" id="uC9-bK-F7u">
48 <rect key="frame" x="229" y="2" width="21" height="25"/>
49 <constraints>
50 <constraint firstAttribute="width" constant="21" id="Mml-ka-nwr"/>
51 <constraint firstAttribute="height" constant="25" id="OUH-L1-Don"/>
52 </constraints>
53 </imageView>
47 </subviews> 54 </subviews>
48 <color key="backgroundColor" red="0.36078431372549019" green="0.36078431372549019" blue="0.36078431372549019" alpha="1" colorSpace="calibratedRGB"/> 55 <color key="backgroundColor" red="0.36078431372549019" green="0.36078431372549019" blue="0.36078431372549019" alpha="1" colorSpace="calibratedRGB"/>
49 <constraints> 56 <constraints>
50 <constraint firstAttribute="trailing" secondItem="qgK-8d-giH" secondAttribute="trailing" id="4eG-yY-bgS"/> 57 <constraint firstAttribute="trailing" secondItem="qgK-8d-giH" secondAttribute="trailing" id="4eG-yY-bgS"/>
51 <constraint firstItem="qgK-8d-giH" firstAttribute="top" secondItem="l97-iI-4Nl" secondAttribute="top" id="8YS-4x-HVg"/> 58 <constraint firstItem="qgK-8d-giH" firstAttribute="top" secondItem="l97-iI-4Nl" secondAttribute="top" id="8YS-4x-HVg"/>
52 <constraint firstAttribute="height" constant="35" id="R67-hu-UQW"/> 59 <constraint firstAttribute="height" constant="35" id="R67-hu-UQW"/>
53 <constraint firstItem="Eop-bg-Dy9" firstAttribute="leading" secondItem="zW0-JI-PIE" secondAttribute="trailing" id="Rh3-lL-CfE"/> 60 <constraint firstItem="Eop-bg-Dy9" firstAttribute="leading" secondItem="zW0-JI-PIE" secondAttribute="trailing" id="Rh3-lL-CfE"/>
54 <constraint firstAttribute="bottom" secondItem="zW0-JI-PIE" secondAttribute="bottom" constant="5" id="W55-gD-NIx"/> 61 <constraint firstAttribute="bottom" secondItem="zW0-JI-PIE" secondAttribute="bottom" constant="5" id="W55-gD-NIx"/>
55 <constraint firstAttribute="bottom" secondItem="Eop-bg-Dy9" secondAttribute="bottom" constant="5" id="Wor-Tc-WPf"/> 62 <constraint firstAttribute="bottom" secondItem="Eop-bg-Dy9" secondAttribute="bottom" constant="5" id="Wor-Tc-WPf"/>
56 <constraint firstItem="zW0-JI-PIE" firstAttribute="leading" secondItem="l97-iI-4Nl" secondAttribute="leading" constant="4" id="ZBL-QQ-0jD"/> 63 <constraint firstItem="zW0-JI-PIE" firstAttribute="leading" secondItem="l97-iI-4Nl" secondAttribute="leading" constant="4" id="ZBL-QQ-0jD"/>
57 <constraint firstAttribute="bottom" secondItem="qgK-8d-giH" secondAttribute="bottom" constant="5" id="cyO-Tr-6Md"/> 64 <constraint firstAttribute="bottom" secondItem="qgK-8d-giH" secondAttribute="bottom" constant="5" id="cyO-Tr-6Md"/>
65 <constraint firstItem="qgK-8d-giH" firstAttribute="leading" secondItem="uC9-bK-F7u" secondAttribute="trailing" constant="-10" id="e8q-Pv-h1j"/>
58 <constraint firstItem="zW0-JI-PIE" firstAttribute="top" secondItem="l97-iI-4Nl" secondAttribute="top" id="iDg-dJ-y0S"/> 66 <constraint firstItem="zW0-JI-PIE" firstAttribute="top" secondItem="l97-iI-4Nl" secondAttribute="top" id="iDg-dJ-y0S"/>
59 <constraint firstItem="qgK-8d-giH" firstAttribute="leading" secondItem="Eop-bg-Dy9" secondAttribute="trailing" id="vhm-kx-gmg"/> 67 <constraint firstItem="qgK-8d-giH" firstAttribute="leading" secondItem="Eop-bg-Dy9" secondAttribute="trailing" id="vhm-kx-gmg"/>
60 <constraint firstItem="Eop-bg-Dy9" firstAttribute="top" secondItem="l97-iI-4Nl" secondAttribute="top" id="xli-4P-Kun"/> 68 <constraint firstItem="Eop-bg-Dy9" firstAttribute="top" secondItem="l97-iI-4Nl" secondAttribute="top" id="xli-4P-Kun"/>
69 <constraint firstItem="uC9-bK-F7u" firstAttribute="centerY" secondItem="l97-iI-4Nl" secondAttribute="centerY" constant="-3" id="zqt-y0-dLW"/>
61 </constraints> 70 </constraints>
62 <userDefinedRuntimeAttributes> 71 <userDefinedRuntimeAttributes>
63 <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius"> 72 <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
64 <integer key="value" value="5"/> 73 <integer key="value" value="5"/>
65 </userDefinedRuntimeAttribute> 74 </userDefinedRuntimeAttribute>
66 </userDefinedRuntimeAttributes> 75 </userDefinedRuntimeAttributes>
67 </view> 76 </view>
68 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yAb-sD-Uf2"> 77 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yAb-sD-Uf2">
69 <rect key="frame" x="0.0" y="30" width="320" height="158"/> 78 <rect key="frame" x="0.0" y="30" width="320" height="158"/>
70 <subviews> 79 <subviews>
71 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="距離" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pTa-iM-GGE"> 80 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="距離" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pTa-iM-GGE">
72 <rect key="frame" x="10" y="8" width="45" height="15"/> 81 <rect key="frame" x="10" y="8" width="45" height="15"/>
73 <constraints> 82 <constraints>
74 <constraint firstAttribute="height" constant="15" id="FsR-rA-SoL"/> 83 <constraint firstAttribute="height" constant="15" id="FsR-rA-SoL"/>
75 <constraint firstAttribute="width" constant="45" id="GEl-5g-KCw"/> 84 <constraint firstAttribute="width" constant="45" id="GEl-5g-KCw"/>
76 </constraints> 85 </constraints>
77 <fontDescription key="fontDescription" type="system" pointSize="10"/> 86 <fontDescription key="fontDescription" type="system" pointSize="10"/>
78 <nil key="highlightedColor"/> 87 <nil key="highlightedColor"/>
79 </label> 88 </label>
80 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="カロリー" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JCF-ib-9hs"> 89 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="カロリー" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="JCF-ib-9hs">
81 <rect key="frame" x="10" y="23" width="45" height="15"/> 90 <rect key="frame" x="10" y="23" width="45" height="15"/>
82 <fontDescription key="fontDescription" type="system" pointSize="10"/> 91 <fontDescription key="fontDescription" type="system" pointSize="10"/>
83 <nil key="highlightedColor"/> 92 <nil key="highlightedColor"/>
84 </label> 93 </label>
85 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="距離" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6g7-qJ-zHF"> 94 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="距離" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6g7-qJ-zHF">
86 <rect key="frame" x="10" y="38" width="45" height="15"/> 95 <rect key="frame" x="10" y="38" width="45" height="15"/>
87 <fontDescription key="fontDescription" type="system" pointSize="10"/> 96 <fontDescription key="fontDescription" type="system" pointSize="10"/>
88 <nil key="highlightedColor"/> 97 <nil key="highlightedColor"/>
89 </label> 98 </label>
90 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000 km" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f2Y-XG-L6g"> 99 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000 km" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f2Y-XG-L6g">
91 <rect key="frame" x="63" y="8" width="219" height="15"/> 100 <rect key="frame" x="63" y="8" width="219" height="15"/>
92 <constraints> 101 <constraints>
93 <constraint firstAttribute="height" constant="15" id="kWm-bt-xfO"/> 102 <constraint firstAttribute="height" constant="15" id="kWm-bt-xfO"/>
94 </constraints> 103 </constraints>
95 <fontDescription key="fontDescription" type="system" pointSize="10"/> 104 <fontDescription key="fontDescription" type="system" pointSize="10"/>
96 <nil key="highlightedColor"/> 105 <nil key="highlightedColor"/>
97 </label> 106 </label>
98 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000 kcal" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yy6-cn-agT"> 107 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="1000 kcal" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yy6-cn-agT">
99 <rect key="frame" x="63" y="23" width="219" height="15"/> 108 <rect key="frame" x="63" y="23" width="219" height="15"/>
100 <fontDescription key="fontDescription" type="system" pointSize="10"/> 109 <fontDescription key="fontDescription" type="system" pointSize="10"/>
101 <nil key="highlightedColor"/> 110 <nil key="highlightedColor"/>
102 </label> 111 </label>
103 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0:50:11" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lmZ-T8-ABg"> 112 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="0:50:11" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lmZ-T8-ABg">
104 <rect key="frame" x="63" y="38" width="219" height="15"/> 113 <rect key="frame" x="63" y="38" width="219" height="15"/>
105 <fontDescription key="fontDescription" type="system" pointSize="10"/> 114 <fontDescription key="fontDescription" type="system" pointSize="10"/>
106 <nil key="highlightedColor"/> 115 <nil key="highlightedColor"/>
107 </label> 116 </label>
108 </subviews> 117 </subviews>
109 <color key="backgroundColor" red="0.93333333333333335" green="0.93333333333333335" blue="0.93333333333333335" alpha="1" colorSpace="calibratedRGB"/> 118 <color key="backgroundColor" red="0.93333333333333335" green="0.93333333333333335" blue="0.93333333333333335" alpha="1" colorSpace="calibratedRGB"/>
110 <constraints> 119 <constraints>
111 <constraint firstItem="Yy6-cn-agT" firstAttribute="leading" secondItem="f2Y-XG-L6g" secondAttribute="leading" id="2Ee-SX-8go"/> 120 <constraint firstItem="Yy6-cn-agT" firstAttribute="leading" secondItem="f2Y-XG-L6g" secondAttribute="leading" id="2Ee-SX-8go"/>
112 <constraint firstItem="lmZ-T8-ABg" firstAttribute="height" secondItem="f2Y-XG-L6g" secondAttribute="height" id="2nz-Eq-Wuy"/> 121 <constraint firstItem="lmZ-T8-ABg" firstAttribute="height" secondItem="f2Y-XG-L6g" secondAttribute="height" id="2nz-Eq-Wuy"/>
113 <constraint firstItem="Yy6-cn-agT" firstAttribute="leading" secondItem="f2Y-XG-L6g" secondAttribute="leading" id="5GH-Il-KeE"/> 122 <constraint firstItem="Yy6-cn-agT" firstAttribute="leading" secondItem="f2Y-XG-L6g" secondAttribute="leading" id="5GH-Il-KeE"/>
114 <constraint firstItem="JCF-ib-9hs" firstAttribute="leading" secondItem="pTa-iM-GGE" secondAttribute="leading" id="9hV-iQ-0Bo"/> 123 <constraint firstItem="JCF-ib-9hs" firstAttribute="leading" secondItem="pTa-iM-GGE" secondAttribute="leading" id="9hV-iQ-0Bo"/>
115 <constraint firstItem="lmZ-T8-ABg" firstAttribute="top" secondItem="Yy6-cn-agT" secondAttribute="bottom" id="Aam-YG-wSE"/> 124 <constraint firstItem="lmZ-T8-ABg" firstAttribute="top" secondItem="Yy6-cn-agT" secondAttribute="bottom" id="Aam-YG-wSE"/>
116 <constraint firstItem="lmZ-T8-ABg" firstAttribute="width" secondItem="f2Y-XG-L6g" secondAttribute="width" id="ETo-YC-5aI"/> 125 <constraint firstItem="lmZ-T8-ABg" firstAttribute="width" secondItem="f2Y-XG-L6g" secondAttribute="width" id="ETo-YC-5aI"/>
117 <constraint firstItem="Yy6-cn-agT" firstAttribute="height" secondItem="f2Y-XG-L6g" secondAttribute="height" id="Es4-R8-oEa"/> 126 <constraint firstItem="Yy6-cn-agT" firstAttribute="height" secondItem="f2Y-XG-L6g" secondAttribute="height" id="Es4-R8-oEa"/>
118 <constraint firstItem="Yy6-cn-agT" firstAttribute="top" secondItem="f2Y-XG-L6g" secondAttribute="bottom" id="Jgb-7C-kb9"/> 127 <constraint firstItem="Yy6-cn-agT" firstAttribute="top" secondItem="f2Y-XG-L6g" secondAttribute="bottom" id="Jgb-7C-kb9"/>
119 <constraint firstItem="pTa-iM-GGE" firstAttribute="leading" secondItem="yAb-sD-Uf2" secondAttribute="leading" constant="10" id="LVc-pD-XW4"/> 128 <constraint firstItem="pTa-iM-GGE" firstAttribute="leading" secondItem="yAb-sD-Uf2" secondAttribute="leading" constant="10" id="LVc-pD-XW4"/>
120 <constraint firstItem="Yy6-cn-agT" firstAttribute="width" secondItem="f2Y-XG-L6g" secondAttribute="width" id="Qxi-If-K2Y"/> 129 <constraint firstItem="Yy6-cn-agT" firstAttribute="width" secondItem="f2Y-XG-L6g" secondAttribute="width" id="Qxi-If-K2Y"/>
121 <constraint firstItem="JCF-ib-9hs" firstAttribute="top" secondItem="pTa-iM-GGE" secondAttribute="bottom" id="Sob-0k-rC4"/> 130 <constraint firstItem="JCF-ib-9hs" firstAttribute="top" secondItem="pTa-iM-GGE" secondAttribute="bottom" id="Sob-0k-rC4"/>
122 <constraint firstItem="6g7-qJ-zHF" firstAttribute="width" secondItem="pTa-iM-GGE" secondAttribute="width" id="UwK-Ej-eer"/> 131 <constraint firstItem="6g7-qJ-zHF" firstAttribute="width" secondItem="pTa-iM-GGE" secondAttribute="width" id="UwK-Ej-eer"/>
123 <constraint firstItem="6g7-qJ-zHF" firstAttribute="top" secondItem="JCF-ib-9hs" secondAttribute="bottom" id="VSr-9F-5cc"/> 132 <constraint firstItem="6g7-qJ-zHF" firstAttribute="top" secondItem="JCF-ib-9hs" secondAttribute="bottom" id="VSr-9F-5cc"/>
124 <constraint firstItem="JCF-ib-9hs" firstAttribute="height" secondItem="pTa-iM-GGE" secondAttribute="height" id="Yhh-Zn-2tX"/> 133 <constraint firstItem="JCF-ib-9hs" firstAttribute="height" secondItem="pTa-iM-GGE" secondAttribute="height" id="Yhh-Zn-2tX"/>
125 <constraint firstItem="pTa-iM-GGE" firstAttribute="top" secondItem="yAb-sD-Uf2" secondAttribute="top" constant="8" id="hUP-mB-2dz"/> 134 <constraint firstItem="pTa-iM-GGE" firstAttribute="top" secondItem="yAb-sD-Uf2" secondAttribute="top" constant="8" id="hUP-mB-2dz"/>
126 <constraint firstItem="lmZ-T8-ABg" firstAttribute="leading" secondItem="f2Y-XG-L6g" secondAttribute="leading" id="hto-gS-Mz2"/> 135 <constraint firstItem="lmZ-T8-ABg" firstAttribute="leading" secondItem="f2Y-XG-L6g" secondAttribute="leading" id="hto-gS-Mz2"/>
127 <constraint firstItem="lmZ-T8-ABg" firstAttribute="leading" secondItem="f2Y-XG-L6g" secondAttribute="leading" id="i7D-G9-PPF"/> 136 <constraint firstItem="lmZ-T8-ABg" firstAttribute="leading" secondItem="f2Y-XG-L6g" secondAttribute="leading" id="i7D-G9-PPF"/>
128 <constraint firstItem="f2Y-XG-L6g" firstAttribute="top" secondItem="yAb-sD-Uf2" secondAttribute="top" constant="8" id="jmU-mq-AaY"/> 137 <constraint firstItem="f2Y-XG-L6g" firstAttribute="top" secondItem="yAb-sD-Uf2" secondAttribute="top" constant="8" id="jmU-mq-AaY"/>
129 <constraint firstItem="6g7-qJ-zHF" firstAttribute="height" secondItem="pTa-iM-GGE" secondAttribute="height" id="mvT-lk-mcd"/> 138 <constraint firstItem="6g7-qJ-zHF" firstAttribute="height" secondItem="pTa-iM-GGE" secondAttribute="height" id="mvT-lk-mcd"/>
130 <constraint firstAttribute="trailing" secondItem="f2Y-XG-L6g" secondAttribute="trailing" constant="38" id="pFC-Zy-Ydq"/> 139 <constraint firstAttribute="trailing" secondItem="f2Y-XG-L6g" secondAttribute="trailing" constant="38" id="pFC-Zy-Ydq"/>
131 <constraint firstItem="f2Y-XG-L6g" firstAttribute="leading" secondItem="pTa-iM-GGE" secondAttribute="trailing" constant="8" id="svF-aI-4pu"/> 140 <constraint firstItem="f2Y-XG-L6g" firstAttribute="leading" secondItem="pTa-iM-GGE" secondAttribute="trailing" constant="8" id="svF-aI-4pu"/>
132 <constraint firstItem="JCF-ib-9hs" firstAttribute="width" secondItem="pTa-iM-GGE" secondAttribute="width" id="v8t-01-PGN"/> 141 <constraint firstItem="JCF-ib-9hs" firstAttribute="width" secondItem="pTa-iM-GGE" secondAttribute="width" id="v8t-01-PGN"/>
133 <constraint firstItem="6g7-qJ-zHF" firstAttribute="leading" secondItem="pTa-iM-GGE" secondAttribute="leading" id="zgT-uC-I9l"/> 142 <constraint firstItem="6g7-qJ-zHF" firstAttribute="leading" secondItem="pTa-iM-GGE" secondAttribute="leading" id="zgT-uC-I9l"/>
134 </constraints> 143 </constraints>
135 </view> 144 </view>
136 </subviews> 145 </subviews>
137 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 146 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
138 <constraints> 147 <constraints>
139 <constraint firstItem="yAb-sD-Uf2" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="65T-wN-9af"/> 148 <constraint firstItem="yAb-sD-Uf2" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="65T-wN-9af"/>
140 <constraint firstItem="yAb-sD-Uf2" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="30" id="7y1-zF-cRh"/> 149 <constraint firstItem="yAb-sD-Uf2" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="30" id="7y1-zF-cRh"/>
141 <constraint firstAttribute="trailing" secondItem="l97-iI-4Nl" secondAttribute="trailing" id="DF1-YD-2mu"/> 150 <constraint firstAttribute="trailing" secondItem="l97-iI-4Nl" secondAttribute="trailing" id="DF1-YD-2mu"/>
142 <constraint firstItem="l97-iI-4Nl" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="WNb-sn-9xi"/> 151 <constraint firstItem="l97-iI-4Nl" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="WNb-sn-9xi"/>
143 <constraint firstAttribute="trailing" secondItem="yAb-sD-Uf2" secondAttribute="trailing" id="mbU-jM-lKI"/> 152 <constraint firstAttribute="trailing" secondItem="yAb-sD-Uf2" secondAttribute="trailing" id="mbU-jM-lKI"/>
144 <constraint firstItem="l97-iI-4Nl" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="rgY-N8-3mT"/> 153 <constraint firstItem="l97-iI-4Nl" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="rgY-N8-3mT"/>
145 <constraint firstAttribute="bottom" secondItem="yAb-sD-Uf2" secondAttribute="bottom" id="tgk-Kq-NYY"/> 154 <constraint firstAttribute="bottom" secondItem="yAb-sD-Uf2" secondAttribute="bottom" id="tgk-Kq-NYY"/>
146 </constraints> 155 </constraints>
147 </tableViewCellContentView> 156 </tableViewCellContentView>
148 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> 157 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
149 <connections> 158 <connections>
159 <outlet property="imgArrow" destination="uC9-bK-F7u" id="0pM-jI-nwl"/>
160 <outlet property="lblDiff" destination="qgK-8d-giH" id="8e8-ew-yEX"/>
150 <outlet property="lblDistance" destination="f2Y-XG-L6g" id="gwM-yJ-wWM"/> 161 <outlet property="lblDistance" destination="f2Y-XG-L6g" id="gwM-yJ-wWM"/>
151 <outlet property="lblDuration" destination="lmZ-T8-ABg" id="ioM-85-tg7"/> 162 <outlet property="lblDuration" destination="lmZ-T8-ABg" id="ioM-85-tg7"/>
152 <outlet property="lblPower" destination="Yy6-cn-agT" id="6KD-eN-oTW"/> 163 <outlet property="lblPower" destination="Yy6-cn-agT" id="6KD-eN-oTW"/>
153 <outlet property="lblStep" destination="Eop-bg-Dy9" id="JII-VL-w0n"/> 164 <outlet property="lblStep" destination="Eop-bg-Dy9" id="JII-VL-w0n"/>
154 <outlet property="lblTitle" destination="zW0-JI-PIE" id="RaR-hQ-48q"/> 165 <outlet property="lblTitle" destination="zW0-JI-PIE" id="RaR-hQ-48q"/>
155 </connections> 166 </connections>
156 <point key="canvasLocation" x="26" y="124"/> 167 <point key="canvasLocation" x="26" y="124"/>
157 </tableViewCell> 168 </tableViewCell>
158 </objects> 169 </objects>
170 <resources>
171 <image name="arrow_incre" width="10" height="12"/>
172 </resources>
159 </document> 173 </document>
160 174
LifeLog/LifeLog/HistoryObject.h
1 // 1 //
2 // HistoryObject.h 2 // HistoryObject.h
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by nvtu on 8/5/17. 5 // Created by nvtu on 8/5/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 10
11 @interface HistoryObject : NSObject 11 @interface HistoryObject : NSObject
12 12
13 @property (nonatomic) int step; 13 @property (nonatomic) int step;
14 @property (nonatomic) int step_diff;
14 @property (nonatomic) int missing; 15 @property (nonatomic) int missing;
15 @property (nonatomic) int target; 16 @property (nonatomic) int target;
17 @property (nonatomic) int time;
16 @property (nonatomic) int time; 18 @property (nonatomic) float percent;
17 @property (nonatomic) float percent; 19 @property (nonatomic) float distance;
18 @property (nonatomic) float distance; 20 @property (nonatomic) float calories;
19 @property (nonatomic) float calories;
20 @property (nonatomic, strong) NSDate *date; 21 @property (nonatomic, strong) NSDate *date;
21 @property (nonatomic, strong) NSMutableArray *dataGraph; 22 @property (nonatomic, strong) NSMutableArray *dataGraph;
22 23
23 -(id) initWithData : (NSDictionary *) dict; 24 -(id) initWithData : (NSDictionary *) dict;
24 25
25 @end 26 @end
LifeLog/LifeLog/HistoryObject.m
1 // 1 //
2 // HistoryObject.m 2 // HistoryObject.m
3 // LifeLog 3 // LifeLog
4 // 4 //
5 // Created by nvtu on 8/5/17. 5 // Created by nvtu on 8/5/17.
6 // Copyright © 2017 PhongNV. All rights reserved. 6 // Copyright © 2017 PhongNV. All rights reserved.
7 // 7 //
8 8
9 #import "HistoryObject.h" 9 #import "HistoryObject.h"
10 #import "Utilities.h"
10 11
11 @implementation HistoryObject 12 @implementation HistoryObject
12 13
13 -(id) initWithData : (NSDictionary *) dict { 14 -(id) initWithData : (NSDictionary *) dict {
14 if([dict objectForKey:@"steps"] != nil) { 15 if([dict objectForKey:@"steps"] != nil) {
15 self.step = [dict[@"steps"] intValue]; 16 self.step = [dict[@"steps"] intValue];
17 }
18 if([dict objectForKey:@"step_diff"] != nil) {
19 self.step_diff = [dict[@"step_diff"] intValue];
16 } 20 }
17 if([dict objectForKey:@"target"] != nil) { 21 if([dict objectForKey:@"target"] != nil) {
18 self.target = [dict[@"target"] intValue]; 22 self.target = [dict[@"target"] intValue];
19 } 23 }
20 if([dict objectForKey:@"step_remain"] != nil) { 24 if([dict objectForKey:@"step_remain"] != nil) {
21 self.missing = [dict[@"step_remain"] intValue]; 25 self.missing = [dict[@"step_remain"] intValue];
22 } 26 }
23 if([dict objectForKey:@"complete_percent"] != nil) { 27 if([dict objectForKey:@"complete_percent"] != nil) {
24 self.percent = [dict[@"complete_percent"] floatValue]; 28 self.percent = [dict[@"complete_percent"] floatValue];
25 } 29 }
26 if([dict objectForKey:@"distance"] != nil) { 30 if([dict objectForKey:@"distance"] != nil) {
27 if([dict[@"distance"] isKindOfClass:[NSString class]]) { 31 if([dict[@"distance"] isKindOfClass:[NSString class]]) {
28 NSString *distance = dict[@"distance"]; 32 NSString *distance = dict[@"distance"];
29 self.distance = [distance floatValue]; 33 self.distance = [distance floatValue];
30 } 34 }
31 else { 35 else {
32 self.distance = [dict[@"distance"] floatValue]; 36 self.distance = [dict[@"distance"] floatValue];
33 } 37 }
34 } 38 }
35 if([dict objectForKey:@"kcal"] != nil) { 39 if([dict objectForKey:@"kcal"] != nil) {
36 self.calories = [dict[@"kcal"] floatValue]; 40 self.calories = [dict[@"kcal"] floatValue];
37 } 41 }
38 if([dict objectForKey:@"time"] != nil) { 42 if([dict objectForKey:@"time"] != nil) {
39 self.time = [dict[@"time"] intValue]; 43 self.time = [dict[@"time"] intValue];
40 }
41 if([dict objectForKey:@"date"] != nil) {
42 NSString *dateString = dict[@"date"];
43 NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
44 [dateFormat setDateFormat:@"yyyy-MM-dd"];
45 self.date = [dateFormat dateFromString:dateString]; 44 }
46 } 45 if([dict objectForKey:@"date"] != nil) {
47 else { 46 NSString *dateString = dict[@"date"];
48 self.date = [NSDate date]; 47 self.date = [Utilities dateFromString:dateString withFormat:@"yyyy-MM-dd"];
49 }
50 if([dict objectForKey:@"data_chart"] != nil) {
51 self.dataGraph = [[NSMutableArray alloc] init]; 48 }
52 NSDictionary * graph = [dict objectForKey:@"data_chart"]; 49 else {
53 if([graph count] == 24) { 50 self.date = [NSDate date];
54 for(int i = 0; i < 24; i++) { 51 }
55 [self.dataGraph addObject:[graph objectForKey:[NSString stringWithFormat:@"%d", i]]]; 52 if([dict objectForKey:@"data_chart"] != nil) {
56 } 53 self.dataGraph = [[NSMutableArray alloc] init];
57 } 54 NSDictionary * graph = [dict objectForKey:@"data_chart"];
58 } 55 if([graph count] == 24) {
59 return self; 56 for(int i = 0; i < 24; i++) {
60 } 57 [self.dataGraph addObject:[graph objectForKey:[NSString stringWithFormat:@"%d", i]]];
LifeLog/LifeLog/HistoryViewController.h
1 // 1 //
2 // HistoryViewController.h 2 // HistoryViewController.h
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 <UIKit/UIKit.h> 9 #import <UIKit/UIKit.h>
10 #import <Charts/Charts-Swift.h> 10 #import <Charts/Charts-Swift.h>
11 11
12 #import "BaseTableViewController.h" 12 #import "BaseTableViewController.h"
13 #import "CollectionView.h" 13 #import "CollectionView.h"
14 14
15 #import "Entities.h" 15 #import "Entities.h"
16 16
17 @interface HistoryViewController : BaseTableViewController <UIScrollViewDelegate> { 17 @interface HistoryViewController : BaseTableViewController <UIScrollViewDelegate> {
18 NSDate * _startDate; 18 NSDate * _startDate;
19 NSDate * _endDate; 19 NSDate * _endDate;
20 NSArray * _curHisArray; 20 NSArray * _curHisArray;
21 NSArray * _curListArray;
21 } 22 }
22 @property (weak, nonatomic) IBOutlet UILabel *lblDatetime; 23 @property (weak, nonatomic) IBOutlet UILabel *lblDatetime;
23 24
24 @property (weak, nonatomic) IBOutlet UILabel *lblCircleStep; 25 @property (weak, nonatomic) IBOutlet UILabel *lblCircleStep;
25 @property (weak, nonatomic) IBOutlet UILabel *lblCircleRemain; 26 @property (weak, nonatomic) IBOutlet UILabel *lblCircleRemain;
26 27
27 @property (weak, nonatomic) IBOutlet UILabel *lblStep; 28 @property (weak, nonatomic) IBOutlet UILabel *lblStep;
28 @property (weak, nonatomic) IBOutlet UILabel *lblRemaining; 29 @property (weak, nonatomic) IBOutlet UILabel *lblRemaining;
29 @property (weak, nonatomic) IBOutlet UILabel *lblPercent; 30 @property (weak, nonatomic) IBOutlet UILabel *lblPercent;
30 @property (weak, nonatomic) IBOutlet UILabel *lblCalories; 31 @property (weak, nonatomic) IBOutlet UILabel *lblCalories;
31 @property (weak, nonatomic) IBOutlet UILabel *lblDistance; 32 @property (weak, nonatomic) IBOutlet UILabel *lblDistance;
32 @property (weak, nonatomic) IBOutlet UILabel *lblTime; 33 @property (weak, nonatomic) IBOutlet UILabel *lblTime;
33 34
34 @property (weak, nonatomic) IBOutlet CollectionView *viewCollectionType; 35 @property (weak, nonatomic) IBOutlet CollectionView *viewCollectionType;
35 @property (weak, nonatomic) IBOutlet CollectionView *viewCollectionMode; 36 @property (weak, nonatomic) IBOutlet CollectionView *viewCollectionMode;
36 @property (weak, nonatomic) IBOutlet CollectionView *viewCollectionShare; 37 @property (weak, nonatomic) IBOutlet CollectionView *viewCollectionShare;
37 38
38 @property (weak, nonatomic) IBOutlet BarChartView *viewBarChart; 39 @property (weak, nonatomic) IBOutlet BarChartView *viewBarChart;
39 40
40 @property (weak, nonatomic) IBOutlet UIScrollView *scrollView; 41 @property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
41 42
42 - (IBAction)swipeAction:(UISwipeGestureRecognizer *)sender; 43 - (IBAction)swipeAction:(UISwipeGestureRecognizer *)sender;
43 - (IBAction)clickBackward:(UIButton *)sender; 44 - (IBAction)clickBackward:(UIButton *)sender;
44 - (IBAction)clickForward:(UIButton *)sender; 45 - (IBAction)clickForward:(UIButton *)sender;
45 46
46 @end 47 @end
47 48
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 // Do any additional setup after loading the view from its nib. 23 // Do any additional setup after loading the view from its nib.
24 self.title = NSLocalizedString(@"lifelog.history.title", nil); 24 self.title = NSLocalizedString(@"lifelog.history.title", nil);
25 25
26 _isDisableLoadMore = true;
27
26 [self setupView]; 28 [self setupView];
27 [self setupChartView]; 29 [self setupChartView];
28 30
29 _startDate = [NSDate date]; 31 _startDate = [NSDate date];
30 _endDate = _startDate; 32 _endDate = _startDate;
31 33
32 self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"]; 34 self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"];
33 35
34 [self checkRequestData]; 36 [self checkRequestData];
35 37
36 //register nib for table view 38 //register nib for table view
37 [self.tableBase registerNib:[UINib nibWithNibName:@"HistoryListTableViewCell" bundle:nil] forCellReuseIdentifier:@"HistoryListCell"]; 39 [self.tableBase registerNib:[UINib nibWithNibName:@"HistoryListTableViewCell" bundle:nil] forCellReuseIdentifier:@"HistoryListCell"];
38 } 40 }
39 41
40 - (void)viewDidAppear:(BOOL) animated 42 - (void)viewDidAppear:(BOOL) animated
41 { 43 {
42 [super viewDidAppear:animated]; 44 [super viewDidAppear:animated];
43 self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 400); 45 self.scrollView.contentSize = CGSizeMake(self.view.frame.size.width, 400);
44 [self.scrollView setNeedsLayout]; 46 [self.scrollView setNeedsLayout];
45 [self.scrollView setNeedsUpdateConstraints]; 47 [self.scrollView setNeedsUpdateConstraints];
46 48
47 } 49 }
48 50
49 - (void)didReceiveMemoryWarning { 51 - (void)didReceiveMemoryWarning {
50 [super didReceiveMemoryWarning]; 52 [super didReceiveMemoryWarning];
51 // Dispose of any resources that can be recreated. 53 // Dispose of any resources that can be recreated.
52 } 54 }
53 55
54