Compare View

switch
from
...
to
 
Commits (3)

Changes

Showing 22 changed files Side-by-side Diff

LifeLog/LifeLog/Assets.xcassets/History/arrow_decre.imageset/Contents.json
... ... @@ -0,0 +1,21 @@
  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 +}
0 22 \ No newline at end of file
LifeLog/LifeLog/Assets.xcassets/History/arrow_decre.imageset/arrow_decre.png

1.33 KB

LifeLog/LifeLog/Assets.xcassets/History/arrow_incre.imageset/Contents.json
... ... @@ -0,0 +1,21 @@
  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 +}
0 22 \ No newline at end of file
LifeLog/LifeLog/Assets.xcassets/History/arrow_incre.imageset/arrow_incre.png

1.49 KB

LifeLog/LifeLog/BaseTableViewController.h
... ... @@ -13,6 +13,7 @@
13 13 BOOL _firstTime;
14 14 BOOL _isLoading;
15 15 BOOL _isEndOfResult;
  16 + BOOL _isDisableLoadMore;
16 17 int _curPage;
17 18 }
18 19  
LifeLog/LifeLog/BaseTableViewController.m
... ... @@ -20,6 +20,7 @@
20 20 _firstTime = false;
21 21 _curPage = 1;
22 22 _isEndOfResult = false;
  23 + _isDisableLoadMore = false;
23 24 _curDataList = [[NSMutableArray alloc] init];
24 25 self.refreshControl = [[UIRefreshControl alloc] init];
25 26 [self.refreshControl addTarget:self action:@selector(refreshTable) forControlEvents:UIControlEventValueChanged];
... ... @@ -114,7 +115,7 @@
114 115 NSInteger lastRowIndex = [tableView numberOfRowsInSection:0] - 1;
115 116 if (indexPath.row == lastRowIndex) {
116 117 // This is the last cell
117   - if(!_isLoading) {
  118 + if(!_isLoading && !_isDisableLoadMore) {
118 119 _curPage += 1;
119 120 [self callRequestToUpdateData];
120 121 }
LifeLog/LifeLog/GroupDetailViewController.m
... ... @@ -151,33 +151,11 @@
151 151 SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"];
152 152 if(isMemberList) {
153 153 MemberObject *object = [_curDataList objectAtIndex:indexPath.row];
154   - if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) {
155   - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]];
156   - }
157   - else {
158   - [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]];
159   - }
160   - cell.lblUsername.text = @"";
161   - cell.lblDateTime.text = @"";
162   - cell.lblDes.text = object.userName;
163   - cell.lblMode.text = @"";
164   - cell.lblDistance.text = @"";
165   - cell.lblDuration.text = @"";
  154 + [cell setMemberData:object];
166 155 }
167 156 else {
168 157 TweetObject *object = [_curDataList objectAtIndex:indexPath.row];
169   - if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) {
170   - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]];
171   - }
172   - else {
173   - [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]];
174   - }
175   - cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm" locale:@""];
176   - cell.lblUsername.text = object.userName;
177   - cell.lblDes.text = object.content;
178   - cell.lblMode.text = object.mode;
179   - cell.lblDistance.text = [NSString stringWithFormat:@"%.0f m", object.distance];
180   - cell.lblDuration.text = object.time;
  158 + [cell setTweetsData:object];
181 159 }
182 160  
183 161 return cell;
LifeLog/LifeLog/HistoryListTableViewCell.h
... ... @@ -10,8 +10,11 @@
10 10  
11 11 @interface HistoryListTableViewCell : UITableViewCell
12 12  
  13 +@property (weak, nonatomic) IBOutlet UIImageView *imgArrow;
  14 +
13 15 @property (weak, nonatomic) IBOutlet UILabel *lblTitle;
14 16 @property (weak, nonatomic) IBOutlet UILabel *lblStep;
  17 +@property (weak, nonatomic) IBOutlet UILabel *lblDiff;
15 18 @property (weak, nonatomic) IBOutlet UILabel *lblDistance;
16 19 @property (weak, nonatomic) IBOutlet UILabel *lblPower;
17 20 @property (weak, nonatomic) IBOutlet UILabel *lblDuration;
LifeLog/LifeLog/HistoryListTableViewCell.xib
1 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 3 <device id="retina4_7" orientation="portrait">
4 4 <adaptation id="fullscreen"/>
5 5 </device>
6 6 <dependencies>
7   - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
  7 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
8 8 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
9 9 </dependencies>
10 10 <objects>
... ... @@ -44,6 +44,13 @@
44 44 <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
45 45 <nil key="highlightedColor"/>
46 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 54 </subviews>
48 55 <color key="backgroundColor" red="0.36078431372549019" green="0.36078431372549019" blue="0.36078431372549019" alpha="1" colorSpace="calibratedRGB"/>
49 56 <constraints>
... ... @@ -55,9 +62,11 @@
55 62 <constraint firstAttribute="bottom" secondItem="Eop-bg-Dy9" secondAttribute="bottom" constant="5" id="Wor-Tc-WPf"/>
56 63 <constraint firstItem="zW0-JI-PIE" firstAttribute="leading" secondItem="l97-iI-4Nl" secondAttribute="leading" constant="4" id="ZBL-QQ-0jD"/>
57 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 66 <constraint firstItem="zW0-JI-PIE" firstAttribute="top" secondItem="l97-iI-4Nl" secondAttribute="top" id="iDg-dJ-y0S"/>
59 67 <constraint firstItem="qgK-8d-giH" firstAttribute="leading" secondItem="Eop-bg-Dy9" secondAttribute="trailing" id="vhm-kx-gmg"/>
60 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 70 </constraints>
62 71 <userDefinedRuntimeAttributes>
63 72 <userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
... ... @@ -147,6 +156,8 @@
147 156 </tableViewCellContentView>
148 157 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
149 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 161 <outlet property="lblDistance" destination="f2Y-XG-L6g" id="gwM-yJ-wWM"/>
151 162 <outlet property="lblDuration" destination="lmZ-T8-ABg" id="ioM-85-tg7"/>
152 163 <outlet property="lblPower" destination="Yy6-cn-agT" id="6KD-eN-oTW"/>
... ... @@ -156,4 +167,7 @@
156 167 <point key="canvasLocation" x="26" y="124"/>
157 168 </tableViewCell>
158 169 </objects>
  170 + <resources>
  171 + <image name="arrow_incre" width="10" height="12"/>
  172 + </resources>
159 173 </document>
LifeLog/LifeLog/HistoryObject.h
... ... @@ -11,12 +11,13 @@
11 11 @interface HistoryObject : NSObject
12 12  
13 13 @property (nonatomic) int step;
  14 +@property (nonatomic) int step_diff;
14 15 @property (nonatomic) int missing;
15 16 @property (nonatomic) int target;
  17 +@property (nonatomic) int time;
16 18 @property (nonatomic) float percent;
17 19 @property (nonatomic) float distance;
18 20 @property (nonatomic) float calories;
19   -@property (nonatomic, strong) NSString * time;
20 21 @property (nonatomic, strong) NSDate *date;
21 22 @property (nonatomic, strong) NSMutableArray *dataGraph;
22 23  
LifeLog/LifeLog/HistoryObject.m
... ... @@ -7,12 +7,16 @@
7 7 //
8 8  
9 9 #import "HistoryObject.h"
  10 +#import "Utilities.h"
10 11  
11 12 @implementation HistoryObject
12 13  
13 14 -(id) initWithData : (NSDictionary *) dict {
14 15 if([dict objectForKey:@"steps"] != nil) {
15   - self.step = [dict[@"step"] 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 21 if([dict objectForKey:@"target"] != nil) {
18 22 self.target = [dict[@"target"] intValue];
... ... @@ -36,18 +40,11 @@
36 40 self.calories = [dict[@"kcal"] floatValue];
37 41 }
38 42 if([dict objectForKey:@"time"] != nil) {
39   - if([dict[@"time"] isKindOfClass:[NSString class]]) {
40   - self.time = dict[@"time"];
41   - }
42   - else {
43   - self.time = @"0:0";
44   - }
  43 + self.time = [dict[@"time"] intValue];
45 44 }
46 45 if([dict objectForKey:@"date"] != nil) {
47 46 NSString *dateString = dict[@"date"];
48   - NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
49   - [dateFormat setDateFormat:@"yyyy-MM-dd"];
50   - self.date = [dateFormat dateFromString:dateString];
  47 + self.date = [Utilities dateFromString:dateString withFormat:@"yyyy-MM-dd"];
51 48 }
52 49 else {
53 50 self.date = [NSDate date];
LifeLog/LifeLog/HistoryViewController.h
... ... @@ -18,6 +18,7 @@
18 18 NSDate * _startDate;
19 19 NSDate * _endDate;
20 20 NSArray * _curHisArray;
  21 + NSArray * _curListArray;
21 22 }
22 23 @property (weak, nonatomic) IBOutlet UILabel *lblDatetime;
23 24  
LifeLog/LifeLog/HistoryViewController.m
... ... @@ -23,6 +23,8 @@
23 23 // Do any additional setup after loading the view from its nib.
24 24 self.title = NSLocalizedString(@"lifelog.history.title", nil);
25 25  
  26 + _isDisableLoadMore = true;
  27 +
26 28 [self setupView];
27 29 [self setupChartView];
28 30  
... ... @@ -67,7 +69,13 @@
67 69 [self.viewCollectionMode setNormalColor:[Utilities convertHecToColor:0x191919] highlightColor:[Utilities convertHecToColor:0x474747] textColor:[UIColor whiteColor]];
68 70 [self.viewCollectionMode setArrayTitle:modeTitle];
69 71 self.viewCollectionMode.changeCurrentIndex = ^(int index){
70   - [self updateView];
  72 + if(self.tableBase.alpha == 0.0) {
  73 + [self updateView];
  74 + }
  75 + else {
  76 + NSArray * list = [_curListArray objectAtIndex:index];
  77 + [self updateTableData:list error:nil];
  78 + }
71 79 };
72 80  
73 81 NSArray *shareTitle = [NSArray arrayWithObjects:NSLocalizedString(@"lifelog.history.share.1", nil), NSLocalizedString(@"lifelog.history.share.2", nil), NSLocalizedString(@"lifelog.history.share.3", nil), NSLocalizedString(@"lifelog.history.share.4", nil), NSLocalizedString(@"lifelog.history.share.5", nil), nil];
... ... @@ -106,12 +114,14 @@
106 114  
107 115 -(void) updateView {
108 116 HistoryObject * obj = [_curHisArray objectAtIndex:self.viewCollectionMode.getCurrentIndex];
109   - self.lblStep.text = [NSString stringWithFormat:@"%d", obj.step];
110   - self.lblRemaining.text = [NSString stringWithFormat:@"%d", obj.missing];
111   - self.lblPercent.text = [NSString stringWithFormat:@"%0.2f", obj.percent * 100];
112   - self.lblCalories.text = [NSString stringWithFormat:@"%0.2f", obj.calories];
113   - self.lblDistance.text = [NSString stringWithFormat:@"%0.1f", obj.distance];
114   - self.lblTime.text = obj.time;
  117 + self.lblStep.text = [NSString stringWithFormat:@"%d step", obj.step];
  118 + self.lblCircleStep.text = self.lblStep.text;
  119 + self.lblRemaining.text = [NSString stringWithFormat:@"%d step", obj.missing];
  120 + self.lblCircleRemain.text = [NSString stringWithFormat:@"目標まであと\n%d stepです", obj.missing];
  121 + self.lblPercent.text = [NSString stringWithFormat:@"%0.2f%%", obj.percent];
  122 + self.lblCalories.text = [NSString stringWithFormat:@"%0.2f kcal", obj.calories];
  123 + self.lblDistance.text = [NSString stringWithFormat:@"%0.1f KM", obj.distance];
  124 + self.lblTime.text = [Utilities convertSecondToShortTime:obj.time];
115 125 [self updateGraphView];
116 126 }
117 127  
... ... @@ -180,21 +190,26 @@
180 190 -(void) callRequestToUpdateData {
181 191 [super callRequestToUpdateData];
182 192 NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken];
183   - int type = self.viewCollectionType.getCurrentIndex;
184   - int mode = self.viewCollectionMode.getCurrentIndex + 1;
185 193  
186 194 MBProgressHUD *hudView = nil;
187 195 if(_curPage == 1 && !self.refreshControl.isRefreshing) {
188 196 hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true];
189 197 }
190   - [[ServerAPI server] requestHistoryList:token withType:type andMode:mode AtPage:_curPage CompletionHandler:^(NSArray *array, NSError *error) {
  198 + [[ServerAPI server] requestHistoryList:token startDate:_startDate endDate:_endDate CompletionHandler:^(NSArray *array, NSError *error) {
191 199 dispatch_async(dispatch_get_main_queue(), ^{
192 200 if(hudView != nil) {
193 201 [hudView hideAnimated:true];
194 202 }
195 203 });
196 204 HistoryViewController __weak *weakSelf = self;
197   - [weakSelf updateTableData:array error:error];
  205 + if(error == nil) {
  206 + _curListArray = array;
  207 + NSArray * list = [array objectAtIndex:weakSelf.viewCollectionMode.getCurrentIndex];
  208 + [weakSelf updateTableData:list error:error];
  209 + }
  210 + else {
  211 + [weakSelf updateTableData:array error:error];
  212 + }
198 213 }];
199 214 }
200 215  
... ... @@ -216,6 +231,14 @@
216 231 _startDate = _endDate;
217 232 break;
218 233 }
  234 + if(_startDate == _endDate) {
  235 + self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"];
  236 + }
  237 + else {
  238 + NSString * startDateString = [Utilities stringFromDate:_startDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"];
  239 + NSString * endDateString = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日" locale:@"ja_JP"];
  240 + self.lblDatetime.text = [NSString stringWithFormat:@"%@-%@", startDateString, endDateString];
  241 + }
219 242 [self checkRequestData];
220 243 }
221 244  
... ... @@ -232,13 +255,11 @@
232 255  
233 256 - (IBAction)clickBackward:(UIButton *)sender {
234 257 _endDate = [_endDate dateByAddingTimeInterval:-86400];
235   - self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"];
236 258 [self changeDate];
237 259 }
238 260  
239 261 - (IBAction)clickForward:(UIButton *)sender {
240 262 _endDate = [_endDate dateByAddingTimeInterval:86400];
241   - self.lblDatetime.text = [Utilities stringFromDate:_endDate withFormat:@"YYYY年MM月dd日 EEEE" locale:@"ja_JP"];
242 263 [self changeDate];
243 264 }
244 265  
... ... @@ -262,7 +283,8 @@
262 283 case 3: // share email
263 284 [Utilities shareEmail:content withViewController:weakSelf];
264 285 break;
265   - default:
  286 + default: //share other
  287 + [Utilities shareOther:content withViewController:weakSelf];
266 288 break;
267 289 }
268 290 }
... ... @@ -272,10 +294,13 @@
272 294 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
273 295 HistoryListTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"HistoryListCell"];
274 296 HistoryObject * obj = [_curDataList objectAtIndex:indexPath.row];
  297 + cell.lblTitle.text = [Utilities stringFromDate:obj.date withFormat:@"dd日 (EEEE)" locale:@"ja_JP"];
275 298 cell.lblStep.text = [NSString stringWithFormat:@"%d", obj.step];
  299 + cell.lblDiff.text = [NSString stringWithFormat:@"%d", obj.step_diff];
  300 + cell.imgArrow.image = (obj.step_diff > 0) ? [UIImage imageNamed:@"arrow_incre"] : [UIImage imageNamed:@"arrow_decre"];
276 301 cell.lblPower.text = [NSString stringWithFormat:@"%0.2f", obj.calories];
277 302 cell.lblDistance.text = [NSString stringWithFormat:@"%0.1f", obj.distance];
278   - cell.lblDuration.text = obj.time;
  303 + cell.lblDuration.text = [Utilities convertSecondToShortTime:obj.time];
279 304 return cell;
280 305 }
281 306  
LifeLog/LifeLog/HistoryViewController.xib
1 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 3 <device id="retina4_7" orientation="portrait">
4 4 <adaptation id="fullscreen"/>
5 5 </device>
6 6 <dependencies>
7   - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
  7 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12089"/>
8 8 <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
9 9 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
10 10 </dependencies>
... ... @@ -99,7 +99,7 @@
99 99 </button>
100 100 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2017年1月1日 日曜日" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EM7-vA-s1e">
101 101