Commit da40f74562216b71a4de342a9c2f80b10d2dfe20
1 parent
7fc917f3b6
Exists in
master
and in
1 other branch
Finish group detail screen, load tweet list, friend list, join group
Showing 8 changed files with 132 additions and 35 deletions Side-by-side Diff
LifeLog/LifeLog/GroupDetailViewController.m
... | ... | @@ -49,14 +49,33 @@ |
49 | 49 | [self.btJoinGrp setHidden:_curGroup.isJoin]; |
50 | 50 | NSString *mode = @""; |
51 | 51 | if(_curGroup.runMode) { |
52 | - mode = [mode stringByAppendingString:@"ランニング\n"]; | |
52 | + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.running", nil)]; | |
53 | + mode = [mode stringByAppendingString:@"\n"]; | |
53 | 54 | } |
54 | 55 | if(_curGroup.walkMode) { |
55 | - mode = [mode stringByAppendingString:@"ウォーキング\n"]; | |
56 | + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.walking", nil)]; | |
57 | + mode = [mode stringByAppendingString:@"\n"]; | |
56 | 58 | } |
57 | 59 | if(_curGroup.bikeMode) { |
58 | - mode = [mode stringByAppendingString:@"バイク\n"]; | |
60 | + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.bike", nil)]; | |
61 | + mode = [mode stringByAppendingString:@"\n"]; | |
59 | 62 | } |
63 | + if(_curGroup.stepMode) { | |
64 | + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.step", nil)]; | |
65 | + mode = [mode stringByAppendingString:@"\n"]; | |
66 | + } | |
67 | + if(_curGroup.beginMode) { | |
68 | + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.begin", nil)]; | |
69 | + mode = [mode stringByAppendingString:@"\n"]; | |
70 | + } | |
71 | + if(_curGroup.gymMode) { | |
72 | + mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.gym", nil)]; | |
73 | + mode = [mode stringByAppendingString:@"\n"]; | |
74 | + } | |
75 | + NSRange range = [mode rangeOfString:@"\n" options:NSBackwardsSearch]; | |
76 | + if(range.length > 0) { | |
77 | + mode = [mode stringByReplacingOccurrencesOfString:@"\n" withString:@"" options:NSBackwardsSearch range:range]; | |
78 | + } | |
60 | 79 | self.lbbGrpActiveMode.text = mode; |
61 | 80 | } |
62 | 81 | } |
63 | 82 | |
64 | 83 | |
65 | 84 | |
... | ... | @@ -68,19 +87,30 @@ |
68 | 87 | |
69 | 88 | - (IBAction)clickSwitch:(AutoTransButton *)sender { |
70 | 89 | isMemberList = !isMemberList; |
90 | + if(isMemberList) { | |
91 | + [sender setTitle:NSLocalizedString(@"lifelog.grDetail.bt.viewTweet", nil) forState:UIControlStateNormal]; | |
92 | + } | |
93 | + else { | |
94 | + [sender setTitle:NSLocalizedString(@"lifelog.grDetail.bt.viewMem", nil) forState:UIControlStateNormal]; | |
95 | + } | |
96 | + [sender setUserInteractionEnabled:false]; | |
71 | 97 | [self resetData]; |
72 | 98 | } |
73 | 99 | |
74 | 100 | - (IBAction)clickJoin:(AutoTransButton *)sender { |
75 | 101 | NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; |
76 | 102 | MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; |
77 | - [[ServerAPI server] requestTweetsList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){ | |
103 | + [[ServerAPI server] requestJoinGroup:token groupID:_curGroup.groupID CompletionHandler:^(NSError *error){ | |
104 | + GroupDetailViewController __weak *weakSelf = self; | |
78 | 105 | dispatch_async(dispatch_get_main_queue(), ^{ |
79 | - if(hudView != nil) { | |
80 | - [hudView hideAnimated:true]; | |
106 | + [hudView hideAnimated:true]; | |
107 | + if(error == nil) { | |
108 | + _curGroup.isJoin = true; | |
109 | + [weakSelf.btJoinGrp setHidden:_curGroup.isJoin]; | |
81 | 110 | } |
82 | 111 | }); |
83 | 112 | }]; |
113 | + | |
84 | 114 | } |
85 | 115 | |
86 | 116 | |
... | ... | @@ -93,6 +123,9 @@ |
93 | 123 | if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { |
94 | 124 | [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; |
95 | 125 | } |
126 | + else { | |
127 | + [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
128 | + } | |
96 | 129 | cell.lblUsername.text = @""; |
97 | 130 | cell.lblDateTime.text = @""; |
98 | 131 | cell.lblDes.text = object.userName; |
... | ... | @@ -105,6 +138,9 @@ |
105 | 138 | if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { |
106 | 139 | [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; |
107 | 140 | } |
141 | + else { | |
142 | + [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
143 | + } | |
108 | 144 | cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm"]; |
109 | 145 | cell.lblUsername.text = object.userName; |
110 | 146 | cell.lblDes.text = object.content; |
... | ... | @@ -123,7 +159,7 @@ |
123 | 159 | MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; |
124 | 160 | [[ServerAPI server] getGroupDetail:token withGroupID:_curGroup.groupID CompletionHandler:^(GroupObject *object, NSError *error) { |
125 | 161 | GroupDetailViewController __weak *weakSelf = self; |
126 | - _curGroup = object; | |
162 | + [_curGroup updateDate:object]; | |
127 | 163 | dispatch_async(dispatch_get_main_queue(), ^{ |
128 | 164 | [hudView hideAnimated:true]; |
129 | 165 | [weakSelf setupView]; |
... | ... | @@ -149,6 +185,7 @@ |
149 | 185 | }); |
150 | 186 | GroupDetailViewController __weak *weakSelf = self; |
151 | 187 | [weakSelf updateTableData:array error:error]; |
188 | + [weakSelf.btSwitch setUserInteractionEnabled:true]; | |
152 | 189 | }]; |
153 | 190 | } |
154 | 191 | else { |
... | ... | @@ -160,6 +197,7 @@ |
160 | 197 | }); |
161 | 198 | GroupDetailViewController __weak *weakSelf = self; |
162 | 199 | [weakSelf updateTableData:array error:error]; |
200 | + [weakSelf.btSwitch setUserInteractionEnabled:true]; | |
163 | 201 | }]; |
164 | 202 | } |
165 | 203 | } |
LifeLog/LifeLog/GroupDetailViewController.xib
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | -<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12121" systemVersion="16A323" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES"> | |
2 | +<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16D32" 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="12089"/> | |
7 | + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/> | |
8 | 8 | <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> |
9 | 9 | </dependencies> |
10 | 10 | <objects> |
LifeLog/LifeLog/GroupObject.h
... | ... | @@ -13,6 +13,13 @@ |
13 | 13 | @property (nonatomic) int groupID; |
14 | 14 | @property (nonatomic) int numSearch; |
15 | 15 | |
16 | +@property (nonatomic) int walkGoal; | |
17 | +@property (nonatomic) int runGoal; | |
18 | +@property (nonatomic) int bikeGoal; | |
19 | +@property (nonatomic) int stepGoal; | |
20 | +@property (nonatomic) int gymGoal; | |
21 | +@property (nonatomic) int beginGoal; | |
22 | + | |
16 | 23 | @property (nonatomic) BOOL isJoin; |
17 | 24 | @property (nonatomic) BOOL walkMode; |
18 | 25 | @property (nonatomic) BOOL runMode; |
... | ... | @@ -28,6 +35,7 @@ |
28 | 35 | @property (nonatomic, strong) NSDate * createDate; |
29 | 36 | |
30 | 37 | -(id) initWithData : (NSDictionary *) dict; |
31 | - | |
38 | +-(id) initWithData : (NSDictionary *) dict andGroupID : (int) groupID; | |
39 | +-(void) updateDate : (GroupObject *) obj; | |
32 | 40 | @end |
LifeLog/LifeLog/GroupObject.m
... | ... | @@ -10,17 +10,64 @@ |
10 | 10 | #import "Utilities.h" |
11 | 11 | |
12 | 12 | @implementation GroupObject |
13 | - | |
14 | 13 | -(id) initWithData : (NSDictionary *) dict { |
15 | 14 | if([dict objectForKey:@"group_id"] != nil) { |
16 | 15 | self.groupID = [dict[@"group_id"] intValue]; |
17 | 16 | } |
18 | - if([dict objectForKey:@"group_name"] != nil) { | |
19 | - self.name = dict[@"group_name"]; | |
20 | - } | |
21 | 17 | if([dict objectForKey:@"group_avatar"] != nil) { |
22 | 18 | self.avatar = dict[@"group_avatar"]; |
23 | 19 | } |
20 | + if([dict objectForKey:@"created_at"] != nil) { | |
21 | + NSString *dateString = dict[@"created_at"]; | |
22 | + self.createDate = [Utilities dateFromString:dateString withFormat:@"yyyy-MM-dd hh:mm:ss"]; | |
23 | + } | |
24 | + else { | |
25 | + self.createDate = [NSDate date]; | |
26 | + } | |
27 | + if([dict objectForKey:@"num_search"] != nil) { | |
28 | + self.numSearch = [dict[@"num_search"] intValue]; | |
29 | + } | |
30 | + [self parseData:dict]; | |
31 | + return self; | |
32 | +} | |
33 | + | |
34 | +-(id) initWithData : (NSDictionary *) dict andGroupID : (int) groupID { | |
35 | + self.groupID = groupID; | |
36 | + if([dict objectForKey:@"join_group"] != nil && ![[dict objectForKey:@"join_group"] isKindOfClass:[NSNull class]]) { | |
37 | + self.isJoin = [dict[@"join_group"] boolValue]; | |
38 | + } | |
39 | + if([dict objectForKey:@"goal"] != nil && ![[dict objectForKey:@"goal"] isKindOfClass:[NSNull class]]) { | |
40 | + self.goal = dict[@"goal"]; | |
41 | + } | |
42 | + else { | |
43 | + self.goal = @""; | |
44 | + } | |
45 | + if([dict objectForKey:@"walk_mode_goal"] != nil && ![[dict objectForKey:@"walk_mode_goal"] isKindOfClass:[NSNull class]]) { | |
46 | + self.walkGoal = [dict[@"walk_mode_goal"] intValue]; | |
47 | + } | |
48 | + if([dict objectForKey:@"run_mode_goal"] != nil && ![[dict objectForKey:@"run_mode_goal"] isKindOfClass:[NSNull class]]) { | |
49 | + self.runGoal = [dict[@"run_mode_goal"] intValue]; | |
50 | + } | |
51 | + if([dict objectForKey:@"bike_mode_goal"] != nil && ![[dict objectForKey:@"bike_mode_goal"] isKindOfClass:[NSNull class]]) { | |
52 | + self.bikeGoal = [dict[@"bike_mode_goal"] intValue]; | |
53 | + } | |
54 | + if([dict objectForKey:@"step_mode_goal"] != nil && ![[dict objectForKey:@"step_mode_goal"] isKindOfClass:[NSNull class]]) { | |
55 | + self.stepGoal = [dict[@"step_mode_goal"] intValue]; | |
56 | + } | |
57 | + if([dict objectForKey:@"gym_mode_goal"] != nil && ![[dict objectForKey:@"gym_mode_goal"] isKindOfClass:[NSNull class]]) { | |
58 | + self.gymGoal = [dict[@"gym_mode_goal"] intValue]; | |
59 | + } | |
60 | + if([dict objectForKey:@"beginer_mode_goal"] != nil && ![[dict objectForKey:@"beginer_mode_goal"] isKindOfClass:[NSNull class]]) { | |
61 | + self.beginGoal = [dict[@"beginer_mode_goal"] intValue]; | |
62 | + } | |
63 | + [self parseData:dict]; | |
64 | + return self; | |
65 | +} | |
66 | + | |
67 | +-(void) parseData : (NSDictionary *) dict { | |
68 | + if([dict objectForKey:@"group_name"] != nil) { | |
69 | + self.name = dict[@"group_name"]; | |
70 | + } | |
24 | 71 | if([dict objectForKey:@"walk_mode_active"] != nil && ![[dict objectForKey:@"walk_mode_active"] isKindOfClass:[NSNull class]]) { |
25 | 72 | self.walkMode = [dict[@"walk_mode_active"] boolValue]; |
26 | 73 | } |
... | ... | @@ -39,26 +86,24 @@ |
39 | 86 | if([dict objectForKey:@"beginer_mode_active"] != nil && ![[dict objectForKey:@"beginer_mode_active"] isKindOfClass:[NSNull class]]) { |
40 | 87 | self.beginMode = [dict[@"beginer_mode_active"] boolValue]; |
41 | 88 | } |
42 | - if([dict objectForKey:@"join_group"] != nil && ![[dict objectForKey:@"join_group"] isKindOfClass:[NSNull class]]) { | |
43 | - self.isJoin = [dict[@"join_group"] boolValue]; | |
44 | - } | |
45 | - if([dict objectForKey:@"created_at"] != nil) { | |
46 | - NSString *dateString = dict[@"created_at"]; | |
47 | - self.createDate = [Utilities dateFromString:dateString withFormat:@"yyyy-MM-dd hh:mm:ss"]; | |
48 | - } | |
49 | - else { | |
50 | - self.createDate = [NSDate date]; | |
51 | - } | |
52 | - if([dict objectForKey:@"num_search"] != nil) { | |
53 | - self.numSearch = [dict[@"num_search"] intValue]; | |
54 | - } | |
55 | - if([dict objectForKey:@"goal"] != nil && ![[dict objectForKey:@"goal"] isKindOfClass:[NSNull class]]) { | |
56 | - self.goal = dict[@"goal"]; | |
57 | - } | |
58 | - else { | |
59 | - self.goal = @""; | |
60 | - } | |
61 | - return self; | |
89 | +} | |
90 | + | |
91 | +-(void) updateDate : (GroupObject *) obj { | |
92 | + self.name = obj.name; | |
93 | + self.walkMode = obj.walkMode; | |
94 | + self.runMode = obj.runMode; | |
95 | + self.bikeMode = obj.bikeMode; | |
96 | + self.stepMode = obj.stepMode; | |
97 | + self.gymMode = obj.gymMode; | |
98 | + self.beginMode = obj.beginMode; | |
99 | + self.isJoin = obj.isJoin; | |
100 | + self.goal = obj.goal; | |
101 | + self.walkGoal = obj.walkGoal; | |
102 | + self.runGoal = obj.runGoal; | |
103 | + self.bikeGoal = obj.bikeGoal; | |
104 | + self.stepGoal = obj.stepGoal; | |
105 | + self.gymGoal = obj.gymGoal; | |
106 | + self.beginGoal = obj.beginGoal; | |
62 | 107 | } |
63 | 108 | |
64 | 109 | @end |
LifeLog/LifeLog/Localizable.strings
No preview for this file type
LifeLog/LifeLog/SNSViewController.m
... | ... | @@ -57,6 +57,9 @@ |
57 | 57 | if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { |
58 | 58 | [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; |
59 | 59 | } |
60 | + else { | |
61 | + [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
62 | + } | |
60 | 63 | cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm"]; |
61 | 64 | cell.lblUsername.text = object.userName; |
62 | 65 | cell.lblDes.text = object.content; |
LifeLog/LifeLog/SearchGroupViewController.m
... | ... | @@ -56,6 +56,9 @@ |
56 | 56 | if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { |
57 | 57 | [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; |
58 | 58 | } |
59 | + else { | |
60 | + [cell.imgAvatar setImage:[UIImage imageNamed:@"avatar_default"]]; | |
61 | + } | |
59 | 62 | cell.lblName.text = object.name; |
60 | 63 | return cell; |
61 | 64 | } |
LifeLog/LifeLog/ServerAPI.m
... | ... | @@ -664,7 +664,7 @@ |
664 | 664 | if (status == 1) { // status = 1 success |
665 | 665 | if(dataResult[@"result"] != nil) { |
666 | 666 | NSArray * array = dataResult[@"result"]; |
667 | - GroupObject * object = [[GroupObject alloc] initWithData:array[0]]; | |
667 | + GroupObject * object = [[GroupObject alloc] initWithData:array[0] andGroupID:groupID]; | |
668 | 668 | completion(object, nil); |
669 | 669 | } |
670 | 670 | else { |