Commit 7fc917f3b6bf31112dc61d5d95884d3d7861da19
1 parent
0db82ed0b5
Exists in
master
and in
1 other branch
add get member of group API, join group API.
Showing 15 changed files with 282 additions and 47 deletions Side-by-side Diff
- LifeLog/LifeLog.xcodeproj/project.pbxproj
- LifeLog/LifeLog/Entities.h
- LifeLog/LifeLog/GroupDetailViewController.h
- LifeLog/LifeLog/GroupDetailViewController.m
- LifeLog/LifeLog/GroupDetailViewController.xib
- LifeLog/LifeLog/HistoryViewController.xib
- LifeLog/LifeLog/MemberObject.h
- LifeLog/LifeLog/MemberObject.m
- LifeLog/LifeLog/RankingViewController.xib
- LifeLog/LifeLog/SNSViewController.m
- LifeLog/LifeLog/SNSViewController.xib
- LifeLog/LifeLog/ServerAPI.h
- LifeLog/LifeLog/ServerAPI.m
- LifeLog/LifeLog/TweetObject.h
- LifeLog/LifeLog/TweetObject.m
LifeLog/LifeLog.xcodeproj/project.pbxproj
| ... | ... | @@ -57,6 +57,7 @@ |
| 57 | 57 | E9373E471F3596940059355A /* AutoTransLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = E9373E461F3596940059355A /* AutoTransLabel.m */; }; |
| 58 | 58 | E9373E4A1F35AA180059355A /* HistoryObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E9373E491F35AA180059355A /* HistoryObject.m */; }; |
| 59 | 59 | E9373E4D1F361A230059355A /* HistoryGraphObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E9373E4C1F361A230059355A /* HistoryGraphObject.m */; }; |
| 60 | + E9497FD51F46EC1100E6AF8D /* MemberObject.m in Sources */ = {isa = PBXBuildFile; fileRef = E9497FD41F46EC1100E6AF8D /* MemberObject.m */; }; | |
| 60 | 61 | E9682E2E1F39675A00FE05A2 /* RankingTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E9682E2C1F39675A00FE05A2 /* RankingTableViewCell.m */; }; |
| 61 | 62 | E9682E2F1F39675A00FE05A2 /* RankingTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = E9682E2D1F39675A00FE05A2 /* RankingTableViewCell.xib */; }; |
| 62 | 63 | E968550A1F3C444900317CEF /* AutoTransButton.m in Sources */ = {isa = PBXBuildFile; fileRef = E96855091F3C444900317CEF /* AutoTransButton.m */; }; |
| ... | ... | @@ -181,6 +182,8 @@ |
| 181 | 182 | E9373E491F35AA180059355A /* HistoryObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HistoryObject.m; sourceTree = "<group>"; }; |
| 182 | 183 | E9373E4B1F361A230059355A /* HistoryGraphObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HistoryGraphObject.h; sourceTree = "<group>"; }; |
| 183 | 184 | E9373E4C1F361A230059355A /* HistoryGraphObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HistoryGraphObject.m; sourceTree = "<group>"; }; |
| 185 | + E9497FD31F46EC1100E6AF8D /* MemberObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemberObject.h; sourceTree = "<group>"; }; | |
| 186 | + E9497FD41F46EC1100E6AF8D /* MemberObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MemberObject.m; sourceTree = "<group>"; }; | |
| 184 | 187 | E9682E2B1F39675A00FE05A2 /* RankingTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RankingTableViewCell.h; sourceTree = "<group>"; }; |
| 185 | 188 | E9682E2C1F39675A00FE05A2 /* RankingTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RankingTableViewCell.m; sourceTree = "<group>"; }; |
| 186 | 189 | E9682E2D1F39675A00FE05A2 /* RankingTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RankingTableViewCell.xib; sourceTree = "<group>"; }; |
| ... | ... | @@ -281,6 +284,8 @@ |
| 281 | 284 | E9D909201F3D559D004CF99F /* TweetObject.m */, |
| 282 | 285 | E933E6721F3E0E4E002926F5 /* GroupObject.h */, |
| 283 | 286 | E933E6731F3E0E4E002926F5 /* GroupObject.m */, |
| 287 | + E9497FD31F46EC1100E6AF8D /* MemberObject.h */, | |
| 288 | + E9497FD41F46EC1100E6AF8D /* MemberObject.m */, | |
| 284 | 289 | ); |
| 285 | 290 | name = Model; |
| 286 | 291 | sourceTree = "<group>"; |
| ... | ... | @@ -308,6 +313,7 @@ |
| 308 | 313 | 6E84E3981F27A703001EB88E /* LifeLogUITests */, |
| 309 | 314 | DE8269E957EA47CD771BAB33 /* Pods */, |
| 310 | 315 | 020C1721B642EF36F31E1BB4 /* Frameworks */, |
| 316 | + 783929CF869F5081762B3DCA /* Products */, | |
| 311 | 317 | ); |
| 312 | 318 | sourceTree = "<group>"; |
| 313 | 319 | }; |
| ... | ... | @@ -430,7 +436,7 @@ |
| 430 | 436 | 6E84E3AC1F27A954001EB88E /* SNS */ = { |
| 431 | 437 | isa = PBXGroup; |
| 432 | 438 | children = ( |
| 433 | - E933E6751F4050E6002926F5 /* GrouDetail */, | |
| 439 | + E933E6751F4050E6002926F5 /* GroupDetail */, | |
| 434 | 440 | E933E6671F3E0479002926F5 /* SeachGroup */, |
| 435 | 441 | 6E84E3BC1F27A9B1001EB88E /* SNSViewController.h */, |
| 436 | 442 | 6E84E3BD1F27A9B1001EB88E /* SNSViewController.m */, |
| ... | ... | @@ -491,6 +497,13 @@ |
| 491 | 497 | name = Common; |
| 492 | 498 | sourceTree = "<group>"; |
| 493 | 499 | }; |
| 500 | + 783929CF869F5081762B3DCA /* Products */ = { | |
| 501 | + isa = PBXGroup; | |
| 502 | + children = ( | |
| 503 | + ); | |
| 504 | + name = Products; | |
| 505 | + sourceTree = "<group>"; | |
| 506 | + }; | |
| 494 | 507 | 9CA8AEE61F31BB1200C5FC74 /* ConfirmForgetPass */ = { |
| 495 | 508 | isa = PBXGroup; |
| 496 | 509 | children = ( |
| 497 | 510 | |
| ... | ... | @@ -547,14 +560,14 @@ |
| 547 | 560 | name = SeachGroup; |
| 548 | 561 | sourceTree = "<group>"; |
| 549 | 562 | }; |
| 550 | - E933E6751F4050E6002926F5 /* GrouDetail */ = { | |
| 563 | + E933E6751F4050E6002926F5 /* GroupDetail */ = { | |
| 551 | 564 | isa = PBXGroup; |
| 552 | 565 | children = ( |
| 553 | 566 | E933E6761F40513C002926F5 /* GroupDetailViewController.h */, |
| 554 | 567 | E933E6771F40513C002926F5 /* GroupDetailViewController.m */, |
| 555 | 568 | E933E6781F40513C002926F5 /* GroupDetailViewController.xib */, |
| 556 | 569 | ); |
| 557 | - name = GrouDetail; | |
| 570 | + name = GroupDetail; | |
| 558 | 571 | sourceTree = "<group>"; |
| 559 | 572 | }; |
| 560 | 573 | E9373E441F35966D0059355A /* AutoTranslateView */ = { |
| ... | ... | @@ -684,7 +697,7 @@ |
| 684 | 697 | Base, |
| 685 | 698 | ); |
| 686 | 699 | mainGroup = 6E84E3681F27A700001EB88E; |
| 687 | - productRefGroup = 6E84E3721F27A700001EB88E /* Products */; | |
| 700 | + productRefGroup = 783929CF869F5081762B3DCA /* Products */; | |
| 688 | 701 | projectDirPath = ""; |
| 689 | 702 | projectRoot = ""; |
| 690 | 703 | targets = ( |
| ... | ... | @@ -823,6 +836,7 @@ |
| 823 | 836 | 6E84E3C51F27ACAE001EB88E /* MapViewController.m in Sources */, |
| 824 | 837 | 6E18CEDC1F2E40F50029891F /* User.m in Sources */, |
| 825 | 838 | 6ECC40711F2A5FEB00AAEB97 /* NSDate+helper.m in Sources */, |
| 839 | + E9497FD51F46EC1100E6AF8D /* MemberObject.m in Sources */, | |
| 826 | 840 | 6E18CED31F2E39DB0029891F /* LoginViewController.m in Sources */, |
| 827 | 841 | 6EA4AF331F40BB7A00F52CFE /* TopObject.m in Sources */, |
| 828 | 842 | E9D909241F3D6E8C004CF99F /* BaseTableViewController.m in Sources */, |
LifeLog/LifeLog/Entities.h
LifeLog/LifeLog/GroupDetailViewController.h
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | |
| 14 | 14 | @interface GroupDetailViewController : BaseTableViewController { |
| 15 | 15 | GroupObject * _curGroup; |
| 16 | + BOOL isMemberList; | |
| 16 | 17 | } |
| 17 | 18 | @property (weak, nonatomic) IBOutlet UIImageView *imgAva; |
| 18 | 19 | |
| ... | ... | @@ -25,6 +26,7 @@ |
| 25 | 26 | - (IBAction)clickBack:(id)sender; |
| 26 | 27 | |
| 27 | 28 | - (void) setGroup : (GroupObject *) object; |
| 28 | -- (IBAction)clickSwitch:(AutoTransButton*)sender; | |
| 29 | +- (IBAction)clickSwitch:(AutoTransButton *)sender; | |
| 30 | +- (IBAction)clickJoin:(AutoTransButton *)sender; | |
| 29 | 31 | @end |
LifeLog/LifeLog/GroupDetailViewController.m
| ... | ... | @@ -21,8 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | - (void)viewDidLoad { |
| 23 | 23 | [super viewDidLoad]; |
| 24 | - [self setupView]; | |
| 25 | - | |
| 24 | + isMemberList = false; | |
| 26 | 25 | //register nib for table view |
| 27 | 26 | [self.tableBase registerNib:[UINib nibWithNibName:@"SNSRecentTopicTableViewCell" bundle:nil] forCellReuseIdentifier:@"RecentTopicCell"]; |
| 28 | 27 | if(_curGroup != nil) { |
| 29 | 28 | |
| ... | ... | @@ -40,16 +39,14 @@ |
| 40 | 39 | _curGroup = object; |
| 41 | 40 | } |
| 42 | 41 | |
| 43 | -- (IBAction)clickSwitch:(id)sender { | |
| 44 | -} | |
| 45 | - | |
| 46 | 42 | - (void)setupView { |
| 47 | 43 | if(_curGroup != nil) { |
| 48 | 44 | if(_curGroup.avatar && ![_curGroup.avatar isKindOfClass:[NSNull class]]) { |
| 49 | 45 | [self.imgAva sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:_curGroup.avatar]]]; |
| 50 | 46 | } |
| 51 | - self.lblGrpName.text = _curGroup.name; | |
| 52 | - self.lblGrpGoal.text = _curGroup.goal; | |
| 47 | + [self.lblGrpName setText:_curGroup.name]; | |
| 48 | + [self.lblGrpGoal setText:_curGroup.goal]; | |
| 49 | + [self.btJoinGrp setHidden:_curGroup.isJoin]; | |
| 53 | 50 | NSString *mode = @""; |
| 54 | 51 | if(_curGroup.runMode) { |
| 55 | 52 | mode = [mode stringByAppendingString:@"ใฉใณใใณใฐ\n"]; |
| 56 | 53 | |
| 57 | 54 | |
| ... | ... | @@ -69,19 +66,53 @@ |
| 69 | 66 | [self.navigationController popViewControllerAnimated:true]; |
| 70 | 67 | } |
| 71 | 68 | |
| 69 | +- (IBAction)clickSwitch:(AutoTransButton *)sender { | |
| 70 | + isMemberList = !isMemberList; | |
| 71 | + [self resetData]; | |
| 72 | +} | |
| 73 | + | |
| 74 | +- (IBAction)clickJoin:(AutoTransButton *)sender { | |
| 75 | + NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; | |
| 76 | + MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; | |
| 77 | + [[ServerAPI server] requestTweetsList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){ | |
| 78 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 79 | + if(hudView != nil) { | |
| 80 | + [hudView hideAnimated:true]; | |
| 81 | + } | |
| 82 | + }); | |
| 83 | + }]; | |
| 84 | +} | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 72 | 88 | #pragma mark UITableView Delegate |
| 73 | 89 | - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
| 74 | 90 | SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"]; |
| 75 | - TweetObject *object = [_curDataList objectAtIndex:indexPath.row]; | |
| 76 | - if(object.avatarLink && ![object.avatarLink isKindOfClass:[NSNull class]]) { | |
| 77 | - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatarLink]]]; | |
| 91 | + if(isMemberList) { | |
| 92 | + MemberObject *object = [_curDataList objectAtIndex:indexPath.row]; | |
| 93 | + if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
| 94 | + [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
| 95 | + } | |
| 96 | + cell.lblUsername.text = @""; | |
| 97 | + cell.lblDateTime.text = @""; | |
| 98 | + cell.lblDes.text = object.userName; | |
| 99 | + cell.lblMode.text = @""; | |
| 100 | + cell.lblDistance.text = @""; | |
| 101 | + cell.lblDuration.text = @""; | |
| 78 | 102 | } |
| 79 | - cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm"]; | |
| 80 | - cell.lblUsername.text = object.userName; | |
| 81 | - cell.lblDes.text = object.content; | |
| 82 | - cell.lblMode.text = object.mode; | |
| 83 | - cell.lblDistance.text = [NSString stringWithFormat:@"%.0f m", object.distance]; | |
| 84 | - cell.lblDuration.text = object.time; | |
| 103 | + else { | |
| 104 | + TweetObject *object = [_curDataList objectAtIndex:indexPath.row]; | |
| 105 | + if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
| 106 | + [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
| 107 | + } | |
| 108 | + cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm"]; | |
| 109 | + cell.lblUsername.text = object.userName; | |
| 110 | + cell.lblDes.text = object.content; | |
| 111 | + cell.lblMode.text = object.mode; | |
| 112 | + cell.lblDistance.text = [NSString stringWithFormat:@"%.0f m", object.distance]; | |
| 113 | + cell.lblDuration.text = object.time; | |
| 114 | + } | |
| 115 | + | |
| 85 | 116 | return cell; |
| 86 | 117 | } |
| 87 | 118 | |
| 88 | 119 | |
| 89 | 120 | |
| ... | ... | @@ -89,12 +120,12 @@ |
| 89 | 120 | |
| 90 | 121 | - (void) requestGroupDetail { |
| 91 | 122 | NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; |
| 92 | -// MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; | |
| 123 | + MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; | |
| 93 | 124 | [[ServerAPI server] getGroupDetail:token withGroupID:_curGroup.groupID CompletionHandler:^(GroupObject *object, NSError *error) { |
| 94 | -// [hudView hideAnimated:true]; | |
| 95 | 125 | GroupDetailViewController __weak *weakSelf = self; |
| 96 | 126 | _curGroup = object; |
| 97 | 127 | dispatch_async(dispatch_get_main_queue(), ^{ |
| 128 | + [hudView hideAnimated:true]; | |
| 98 | 129 | [weakSelf setupView]; |
| 99 | 130 | [weakSelf callRequestToUpdateData]; |
| 100 | 131 | }); |
| ... | ... | @@ -109,15 +140,28 @@ |
| 109 | 140 | if(_curPage == 1 && !self.refreshControl.isRefreshing) { |
| 110 | 141 | hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; |
| 111 | 142 | } |
| 112 | - [[ServerAPI server] requestTweetsList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){ | |
| 113 | - dispatch_async(dispatch_get_main_queue(), ^{ | |
| 114 | - if(hudView != nil) { | |
| 115 | - [hudView hideAnimated:true]; | |
| 116 | - } | |
| 117 | - }); | |
| 118 | - GroupDetailViewController __weak *weakSelf = self; | |
| 119 | - [weakSelf updateTableData:array error:error]; | |
| 120 | - }]; | |
| 143 | + if(isMemberList) { | |
| 144 | + [[ServerAPI server] requestMemberList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){ | |
| 145 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 146 | + if(hudView != nil) { | |
| 147 | + [hudView hideAnimated:true]; | |
| 148 | + } | |
| 149 | + }); | |
| 150 | + GroupDetailViewController __weak *weakSelf = self; | |
| 151 | + [weakSelf updateTableData:array error:error]; | |
| 152 | + }]; | |
| 153 | + } | |
| 154 | + else { | |
| 155 | + [[ServerAPI server] requestTweetsList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){ | |
| 156 | + dispatch_async(dispatch_get_main_queue(), ^{ | |
| 157 | + if(hudView != nil) { | |
| 158 | + [hudView hideAnimated:true]; | |
| 159 | + } | |
| 160 | + }); | |
| 161 | + GroupDetailViewController __weak *weakSelf = self; | |
| 162 | + [weakSelf updateTableData:array error:error]; | |
| 163 | + }]; | |
| 164 | + } | |
| 121 | 165 | } |
| 122 | 166 | |
| 123 | 167 | @end |
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="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> |
| ... | ... | @@ -70,7 +70,7 @@ |
| 70 | 70 | <constraint firstAttribute="height" constant="46" id="u2G-4s-RB5"/> |
| 71 | 71 | </constraints> |
| 72 | 72 | </view> |
| 73 | - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YWV-pS-TCo"> | |
| 73 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YWV-pS-TCo"> | |
| 74 | 74 | <rect key="frame" x="15" y="54" width="345" height="21"/> |
| 75 | 75 | <constraints> |
| 76 | 76 | <constraint firstAttribute="height" constant="21" id="fQO-ja-W9R"/> |
| ... | ... | @@ -89,7 +89,7 @@ |
| 89 | 89 | <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/> |
| 90 | 90 | <nil key="highlightedColor"/> |
| 91 | 91 | </label> |
| 92 | - <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bdy-dI-j47"> | |
| 92 | + <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bdy-dI-j47"> | |
| 93 | 93 | <rect key="frame" x="15" y="160" width="345" height="80"/> |
| 94 | 94 | <constraints> |
| 95 | 95 | <constraint firstAttribute="height" constant="80" id="jgH-57-Bae"/> |
| 96 | 96 | |
| ... | ... | @@ -121,10 +121,10 @@ |
| 121 | 121 | <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.grDetail.bt.viewMem"/> |
| 122 | 122 | </userDefinedRuntimeAttributes> |
| 123 | 123 | <connections> |
| 124 | - <action selector="clickSwitch:" destination="-1" eventType="touchUpInside" id="3wX-Tc-XA3"/> | |
| 124 | + <action selector="clickSwitch:" destination="-1" eventType="touchUpInside" id="z4V-ym-fqS"/> | |
| 125 | 125 | </connections> |
| 126 | 126 | </button> |
| 127 | - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="caN-x7-hJz" customClass="AutoTransButton"> | |
| 127 | + <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="caN-x7-hJz" customClass="AutoTransButton"> | |
| 128 | 128 | <rect key="frame" x="197" y="270" width="162" height="30"/> |
| 129 | 129 | <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> |
| 130 | 130 | <constraints> |
| ... | ... | @@ -139,6 +139,9 @@ |
| 139 | 139 | </userDefinedRuntimeAttribute> |
| 140 | 140 | <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.grDetail.bt.joinGr"/> |
| 141 | 141 | </userDefinedRuntimeAttributes> |
| 142 | + <connections> | |
| 143 | + <action selector="clickJoin:" destination="-1" eventType="touchUpInside" id="Ukt-bi-Sw2"/> | |
| 144 | + </connections> | |
| 142 | 145 | </button> |
| 143 | 146 | <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" style="plain" separatorStyle="none" rowHeight="100" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="4VU-Ye-7Au"> |
| 144 | 147 | <rect key="frame" x="0.0" y="310" width="375" height="307"/> |
LifeLog/LifeLog/HistoryViewController.xib
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.history.title"/> |
| 46 | 46 | </userDefinedRuntimeAttributes> |
| 47 | 47 | </label> |
| 48 | - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ytc-zM-ZGC"> | |
| 48 | + <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ytc-zM-ZGC"> | |
| 49 | 49 | <rect key="frame" x="0.0" y="5" width="70" height="36"/> |
| 50 | 50 | <constraints> |
| 51 | 51 | <constraint firstAttribute="width" constant="70" id="xAE-oP-WEf"/> |
LifeLog/LifeLog/MemberObject.h
| 1 | +// | |
| 2 | +// MemberObject.h | |
| 3 | +// LifeLog | |
| 4 | +// | |
| 5 | +// Created by nvtu on 8/18/17. | |
| 6 | +// Copyright ยฉ 2017 PhongNV. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import <Foundation/Foundation.h> | |
| 10 | + | |
| 11 | +@interface MemberObject : NSObject | |
| 12 | + | |
| 13 | +@property (nonatomic) int userID; | |
| 14 | +@property (nonatomic) int gender; | |
| 15 | + | |
| 16 | +@property (nonatomic, strong) NSString * userName; | |
| 17 | +@property (nonatomic, strong) NSString * nickName; | |
| 18 | +@property (nonatomic, strong) NSString * avatar; | |
| 19 | + | |
| 20 | +@property (nonatomic, strong) NSDate * joinDate; | |
| 21 | +@property (nonatomic, strong) NSDate * birthDay; | |
| 22 | + | |
| 23 | +-(id) initWithData : (NSDictionary *) dict; | |
| 24 | + | |
| 25 | +@end |
LifeLog/LifeLog/MemberObject.m
| 1 | +// | |
| 2 | +// MemberObject.m | |
| 3 | +// LifeLog | |
| 4 | +// | |
| 5 | +// Created by nvtu on 8/18/17. | |
| 6 | +// Copyright ยฉ 2017 PhongNV. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "MemberObject.h" | |
| 10 | +#import "Utilities.h" | |
| 11 | + | |
| 12 | +@implementation MemberObject | |
| 13 | + | |
| 14 | +-(id) initWithData : (NSDictionary *) dict { | |
| 15 | + if([dict objectForKey:@"user_id"] != nil) { | |
| 16 | + self.userID = [dict[@"user_id"] intValue]; | |
| 17 | + } | |
| 18 | + if([dict objectForKey:@"gender"] != nil) { | |
| 19 | + self.gender = [dict[@"gender"] intValue]; | |
| 20 | + } | |
| 21 | + if([dict objectForKey:@"username"] != nil) { | |
| 22 | + self.userName = dict[@"username"]; | |
| 23 | + } | |
| 24 | + if([dict objectForKey:@"nickname"] != nil) { | |
| 25 | + self.nickName = dict[@"nickname"]; | |
| 26 | + } | |
| 27 | + if([dict objectForKey:@"profile_image"] != nil) { | |
| 28 | + self.avatar = dict[@"profile_image"]; | |
| 29 | + } | |
| 30 | + if([dict objectForKey:@"birthday"] != nil) { | |
| 31 | + NSString *dateString = dict[@"birthday"]; | |
| 32 | + self.birthDay = [Utilities dateFromString:dateString withFormat:@"yyyy-MM-dd"]; | |
| 33 | + } | |
| 34 | + else { | |
| 35 | + self.birthDay = [NSDate date]; | |
| 36 | + } | |
| 37 | + if([dict objectForKey:@"join_date"] != nil) { | |
| 38 | + NSString *dateString = dict[@"join_date"]; | |
| 39 | + self.joinDate = [Utilities dateFromString:dateString withFormat:@"yyyy-MM-dd HH:mm:ss"]; | |
| 40 | + } | |
| 41 | + else { | |
| 42 | + self.joinDate = [NSDate date]; | |
| 43 | + } | |
| 44 | + return self; | |
| 45 | +} | |
| 46 | + | |
| 47 | +@end |
LifeLog/LifeLog/RankingViewController.xib
| ... | ... | @@ -34,7 +34,7 @@ |
| 34 | 34 | <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.rank.title"/> |
| 35 | 35 | </userDefinedRuntimeAttributes> |
| 36 | 36 | </label> |
| 37 | - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qPe-ff-jRp"> | |
| 37 | + <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="qPe-ff-jRp"> | |
| 38 | 38 | <rect key="frame" x="0.0" y="5" width="70" height="36"/> |
| 39 | 39 | <constraints> |
| 40 | 40 | <constraint firstAttribute="width" constant="70" id="bEy-jt-69Q"/> |
LifeLog/LifeLog/SNSViewController.m
| ... | ... | @@ -54,8 +54,8 @@ |
| 54 | 54 | - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { |
| 55 | 55 | SNSRecentTopicTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"RecentTopicCell"]; |
| 56 | 56 | TweetObject *object = [_curDataList objectAtIndex:indexPath.row]; |
| 57 | - if(object.avatarLink && ![object.avatarLink isKindOfClass:[NSNull class]]) { | |
| 58 | - [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatarLink]]]; | |
| 57 | + if(object.avatar && ![object.avatar isKindOfClass:[NSNull class]]) { | |
| 58 | + [cell.imgAvatar sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:object.avatar]]]; | |
| 59 | 59 | } |
| 60 | 60 | cell.lblDateTime.text = [Utilities stringFromDate:object.createDate withFormat:@"YYYY/MM/dd hh:mm"]; |
| 61 | 61 | cell.lblUsername.text = object.userName; |
LifeLog/LifeLog/SNSViewController.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> |
| ... | ... | @@ -31,7 +31,7 @@ |
| 31 | 31 | <userDefinedRuntimeAttribute type="string" keyPath="localizeKey" value="lifelog.sns.title"/> |
| 32 | 32 | </userDefinedRuntimeAttributes> |
| 33 | 33 | </label> |
| 34 | - <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BIE-oM-ejb"> | |
| 34 | + <button hidden="YES" opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BIE-oM-ejb"> | |
| 35 | 35 | <rect key="frame" x="0.0" y="5" width="70" height="36"/> |
| 36 | 36 | <constraints> |
| 37 | 37 | <constraint firstAttribute="width" constant="70" id="ZpD-Ru-8wG"/> |
LifeLog/LifeLog/ServerAPI.h
| ... | ... | @@ -33,6 +33,7 @@ |
| 33 | 33 | - (void) requestHistory:(NSString *)token atDate:(NSDate *)date withType:(int)type andMode:(int) mode CompletionHandler:(void (^)(HistoryObject *, NSError *)) completion; |
| 34 | 34 | - (void) requestHistoryGraph:(NSString *)token withType:(int)type andMode:(int) mode CompletionHandler:(void (^)(HistoryGraphObject *, NSError *)) completion; |
| 35 | 35 | - (void) requestHistoryList:(NSString *)token withType:(int)type andMode:(int) mode AtPage:(int) page CompletionHandler:(void (^)(NSArray *, NSError *)) completion; |
| 36 | +- (void) requestJoinGroup:(NSString *)token groupID: (int) groupID CompletionHandler:(void (^)(NSError *)) completion; | |
| 36 | 37 | |
| 37 | 38 | #pragma mark - SNS Screen Function |
| 38 | 39 | /* |
| ... | ... | @@ -44,6 +45,7 @@ |
| 44 | 45 | |
| 45 | 46 | #pragma mark - Group Function |
| 46 | 47 | - (void) getGroupDetail:(NSString *)token withGroupID:(int)groupID CompletionHandler:(void (^)(GroupObject *, NSError *)) completion; |
| 48 | +- (void) requestMemberList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion; | |
| 47 | 49 | |
| 48 | 50 | #pragma mark - Common API |
| 49 | 51 | - (void)refreshToken: (NSString *)userID CompletionHandler:(void (^)(NSString *, NSError *))completion; |
LifeLog/LifeLog/ServerAPI.m
| ... | ... | @@ -696,6 +696,103 @@ |
| 696 | 696 | }]; |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | +- (void) requestMemberList:(NSString *)token groupID: (int) groupID withPage:(int)page CompletionHandler:(void (^)(NSArray *, NSError *)) completion { | |
| 700 | + NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/member/%d/%d", groupID, page]; | |
| 701 | + NSLog(@"requestMemberList link %@ page %d", url, page); | |
| 702 | + | |
| 703 | + [self _request:url method:@"GET" token:token paras:nil completion:^(NSData *data, NSError *error) { | |
| 704 | + if (completion == NULL) { | |
| 705 | + return ; | |
| 706 | + } | |
| 707 | + | |
| 708 | + if (error == nil) | |
| 709 | + { | |
| 710 | + NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; | |
| 711 | + NSLog(@"%@", dataResult); | |
| 712 | + int status = [dataResult[@"status"] intValue]; | |
| 713 | + if (status == 1) { // status = 1 success | |
| 714 | + if(dataResult[@"result"] != nil) { | |
| 715 | + NSArray * array = dataResult[@"result"]; | |
| 716 | + NSMutableArray * arrayTweets = [[NSMutableArray alloc] init]; | |
| 717 | + for(NSDictionary * dict in array) { | |
| 718 | + MemberObject * object = [[MemberObject alloc] initWithData:dict]; | |
| 719 | + [arrayTweets addObject:object]; | |
| 720 | + } | |
| 721 | + completion(arrayTweets, nil); | |
| 722 | + } | |
| 723 | + else { | |
| 724 | + NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; | |
| 725 | + completion(nil, errorObject); | |
| 726 | + } | |
| 727 | + } | |
| 728 | + else { | |
| 729 | + NSString *message = dataResult[@"message"]; | |
| 730 | + if (message == nil) { | |
| 731 | + message = @"Unknown error"; | |
| 732 | + } | |
| 733 | + | |
| 734 | + if ([message isEqualToString:@"Token is invalid"]) { | |
| 735 | + [self performSelectorOnMainThread:@selector(checkToken) withObject:nil waitUntilDone:YES]; | |
| 736 | + NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; | |
| 737 | + [self requestMemberList:tokenNew groupID:groupID withPage:page CompletionHandler:completion]; | |
| 738 | + } | |
| 739 | + else { | |
| 740 | + NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; | |
| 741 | + completion(nil, errorObject); | |
| 742 | + } | |
| 743 | + } | |
| 744 | + } | |
| 745 | + else | |
| 746 | + { | |
| 747 | + completion(nil, error); | |
| 748 | + } | |
| 749 | + }]; | |
| 750 | +} | |
| 751 | + | |
| 752 | +- (void) requestJoinGroup:(NSString *)token groupID: (int) groupID CompletionHandler:(void (^)(NSError *)) completion { | |
| 753 | + NSString *url = [kServerAddress stringByAppendingFormat:@"api/sns/group/join"]; | |
| 754 | + NSLog(@"requestJoinGroup link %@", url); | |
| 755 | + | |
| 756 | + searchTask = [self _request:url method:@"POST" token:token paras:@{@"group_id": [NSNumber numberWithInt:groupID]} completion:^(NSData *data, NSError *error) { | |
| 757 | + searchTask = nil; | |
| 758 | + if (completion == NULL) { | |
| 759 | + return ; | |
| 760 | + } | |
| 761 | + | |
| 762 | + if (error == nil) | |
| 763 | + { | |
| 764 | + NSDictionary *dataResult = [NSJSONSerialization JSONObjectWithData:data options: NSJSONReadingAllowFragments error: &error]; | |
| 765 | + NSLog(@"%@", dataResult); | |
| 766 | + int status = [dataResult[@"status"] intValue]; | |
| 767 | + if (status == 1) { // status = 1 success | |
| 768 | + if(dataResult[@"result"] != nil) { | |
| 769 | + completion(nil); | |
| 770 | + } | |
| 771 | + else { | |
| 772 | + NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":@"Unknown Error"}]; | |
| 773 | + completion(errorObject); | |
| 774 | + } | |
| 775 | + } | |
| 776 | + else { | |
| 777 | + NSString *message = dataResult[@"message"]; | |
| 778 | + if ([message isEqualToString:@"Token is invalid"]) { | |
| 779 | + [self performSelectorOnMainThread:@selector(checkToken) withObject:nil waitUntilDone:YES]; | |
| 780 | + NSString *tokenNew = [[NSUserDefaults standardUserDefaults] objectForKey:kToken]; | |
| 781 | + [self requestJoinGroup:tokenNew groupID:groupID CompletionHandler:completion]; | |
| 782 | + } | |
| 783 | + else { | |
| 784 | + NSError *errorObject = [NSError errorWithDomain:@"LifeLog_Domain" code:-1 userInfo:@{@"message":message}]; | |
| 785 | + completion(errorObject); | |
| 786 | + } | |
| 787 | + } | |
| 788 | + } | |
| 789 | + else | |
| 790 | + { | |
| 791 | + completion(error); | |
| 792 | + } | |
| 793 | + }]; | |
| 794 | +} | |
| 795 | + | |
| 699 | 796 | #pragma mark - Common API |
| 700 | 797 | - (void)refreshToken: (NSString *)userID CompletionHandler:(void (^)(NSString *, NSError *))completion { |
| 701 | 798 | [self _request:[kServerAddress stringByAppendingFormat: @"refreshToken"] method:@"POST" token:@"" paras:@{@"userId":userID} completion:^(NSData *data, NSError *error) { |
LifeLog/LifeLog/TweetObject.h
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | @property (nonatomic, strong) NSString * mode; |
| 20 | 20 | @property (nonatomic, strong) NSString * time; |
| 21 | 21 | @property (nonatomic, strong) NSString * userName; |
| 22 | -@property (nonatomic, strong) NSString * avatarLink; | |
| 22 | +@property (nonatomic, strong) NSString * avatar; | |
| 23 | 23 | @property (nonatomic, strong) NSDate * createDate; |
| 24 | 24 | |
| 25 | 25 | -(id) initWithData : (NSDictionary *) dict; |
LifeLog/LifeLog/TweetObject.m
| ... | ... | @@ -54,7 +54,7 @@ |
| 54 | 54 | self.userName = dict[@"full_name"]; |
| 55 | 55 | } |
| 56 | 56 | if([dict objectForKey:@"profile_image"] != nil) { |
| 57 | - self.avatarLink = dict[@"profile_image"]; | |
| 57 | + self.avatar = dict[@"profile_image"]; | |
| 58 | 58 | } |
| 59 | 59 | if([dict objectForKey:@"created_at"] != nil) { |
| 60 | 60 | NSString *dateString = dict[@"created_at"]; |