From e759cbb03c694dfdd25155d4319fe336d039b76d Mon Sep 17 00:00:00 2001 From: nvtu Date: Sun, 20 Aug 2017 23:20:04 +0700 Subject: [PATCH] Fix UI issue in SNS screen --- LifeLog/LifeLog/CreateGroupViewController.xib | 94 +++++++++++++-------------- LifeLog/LifeLog/GroupDetailViewController.h | 5 +- LifeLog/LifeLog/GroupDetailViewController.m | 55 ++++++++++------ LifeLog/LifeLog/GroupDetailViewController.xib | 31 +++++---- LifeLog/LifeLog/MyGroupViewController.h | 13 +--- LifeLog/LifeLog/MyGroupViewController.m | 91 ++------------------------ LifeLog/LifeLog/MyGroupViewController.xib | 30 ++++----- LifeLog/LifeLog/SNSViewController.xib | 4 +- LifeLog/LifeLog/Utilities.h | 1 + LifeLog/LifeLog/Utilities.m | 23 ++++++- 10 files changed, 150 insertions(+), 197 deletions(-) diff --git a/LifeLog/LifeLog/CreateGroupViewController.xib b/LifeLog/LifeLog/CreateGroupViewController.xib index 7179222..8a03652 100644 --- a/LifeLog/LifeLog/CreateGroupViewController.xib +++ b/LifeLog/LifeLog/CreateGroupViewController.xib @@ -30,52 +30,7 @@ - - - - - - - - - - - - - - - - - - - - - - - + @@ -575,10 +530,55 @@ - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LifeLog/LifeLog/GroupDetailViewController.h b/LifeLog/LifeLog/GroupDetailViewController.h index d911cda..da581e6 100644 --- a/LifeLog/LifeLog/GroupDetailViewController.h +++ b/LifeLog/LifeLog/GroupDetailViewController.h @@ -23,9 +23,10 @@ @property (weak, nonatomic) IBOutlet AutoTransButton *btJoinGrp; @property (weak, nonatomic) IBOutlet AutoTransButton *btSwitch; -- (IBAction)clickBack:(id)sender; - - (void) setGroup : (GroupObject *) object; +- (void) requestGroupDetail; + +- (IBAction)clickBack:(id)sender; - (IBAction)clickSwitch:(AutoTransButton *)sender; - (IBAction)clickJoin:(AutoTransButton *)sender; @end diff --git a/LifeLog/LifeLog/GroupDetailViewController.m b/LifeLog/LifeLog/GroupDetailViewController.m index 8b037fe..d092294 100644 --- a/LifeLog/LifeLog/GroupDetailViewController.m +++ b/LifeLog/LifeLog/GroupDetailViewController.m @@ -41,24 +41,34 @@ - (void)setupView { if(_curGroup != nil) { - if(_curGroup.avatar && ![_curGroup.avatar isKindOfClass:[NSNull class]]) { + if(self.imgAva != nil && _curGroup.avatar && ![_curGroup.avatar isKindOfClass:[NSNull class]]) { [self.imgAva sd_setImageWithURL:[NSURL URLWithString:[Utilities getImageLink:_curGroup.avatar]]]; } - [self.lblGrpName setText:_curGroup.name]; - [self.lblGrpGoal setText:_curGroup.goal]; - [self.btJoinGrp setHidden:_curGroup.isJoin]; + if(self.lblGrpName != nil) { + [self.lblGrpName setText:_curGroup.name]; + } + if(self.btJoinGrp != nil) { + [self.btJoinGrp setHidden:false]; + } NSString *mode = @""; + NSString *goalText = [NSString stringWithFormat:@"%@\n", _curGroup.goal]; + if(_curGroup.runMode || _curGroup.walkMode || _curGroup.bikeMode) { + goalText = [goalText stringByAppendingString:@"1日 目標 "]; + } if(_curGroup.runMode) { mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.running", nil)]; mode = [mode stringByAppendingString:@"\n"]; + goalText = [goalText stringByAppendingFormat:@"RUN %dm, ", _curGroup.runGoal]; } if(_curGroup.walkMode) { mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.walking", nil)]; mode = [mode stringByAppendingString:@"\n"]; + goalText = [goalText stringByAppendingFormat:@"WALK %dm, ", _curGroup.walkGoal]; } if(_curGroup.bikeMode) { mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.bike", nil)]; mode = [mode stringByAppendingString:@"\n"]; + goalText = [goalText stringByAppendingFormat:@"BIKE %dm, ", _curGroup.bikeGoal]; } if(_curGroup.stepMode) { mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.step", nil)]; @@ -76,9 +86,29 @@ if(range.length > 0) { mode = [mode stringByReplacingOccurrencesOfString:@"\n" withString:@"" options:NSBackwardsSearch range:range]; } - self.lbbGrpActiveMode.text = mode; + range = [goalText rangeOfString:@", " options:NSBackwardsSearch]; + if(range.length > 0) { + goalText = [goalText stringByReplacingOccurrencesOfString:@", " withString:@"" options:NSBackwardsSearch range:range]; + } + [self.lbbGrpActiveMode setText:mode]; + [self.lblGrpGoal setText:goalText]; } } + +- (void) requestGroupDetail { + NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; + MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; + [[ServerAPI server] getGroupDetail:token withGroupID:_curGroup.groupID CompletionHandler:^(GroupObject *object, NSError *error) { + GroupDetailViewController __weak *weakSelf = self; + [_curGroup updateDate:object]; + dispatch_async(dispatch_get_main_queue(), ^{ + [hudView hideAnimated:true]; + [weakSelf setupView]; + [weakSelf callRequestToUpdateData]; + }); + }]; +} + #pragma mark IBAction - (IBAction)clickBack:(id)sender { @@ -107,6 +137,7 @@ if(error == nil) { _curGroup.isJoin = true; [weakSelf.btJoinGrp setHidden:_curGroup.isJoin]; + [Utilities showMessage:@"Join successfully" withViewController:weakSelf]; } }); }]; @@ -154,20 +185,6 @@ #pragma mark Private Function -- (void) requestGroupDetail { - NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; - MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; - [[ServerAPI server] getGroupDetail:token withGroupID:_curGroup.groupID CompletionHandler:^(GroupObject *object, NSError *error) { - GroupDetailViewController __weak *weakSelf = self; - [_curGroup updateDate:object]; - dispatch_async(dispatch_get_main_queue(), ^{ - [hudView hideAnimated:true]; - [weakSelf setupView]; - [weakSelf callRequestToUpdateData]; - }); - }]; -} - -(void) callRequestToUpdateData { [super callRequestToUpdateData]; diff --git a/LifeLog/LifeLog/GroupDetailViewController.xib b/LifeLog/LifeLog/GroupDetailViewController.xib index 0894bfe..72e9d32 100644 --- a/LifeLog/LifeLog/GroupDetailViewController.xib +++ b/LifeLog/LifeLog/GroupDetailViewController.xib @@ -22,14 +22,14 @@ - + - + + diff --git a/LifeLog/LifeLog/MyGroupViewController.h b/LifeLog/LifeLog/MyGroupViewController.h index 6f8b324..be35f87 100644 --- a/LifeLog/LifeLog/MyGroupViewController.h +++ b/LifeLog/LifeLog/MyGroupViewController.h @@ -7,26 +7,17 @@ // #import -#import "BaseTableViewController.h" +#import "GroupDetailViewController.h" #import "AutoTransButton.h" #import "Entities.h" -@interface MyGroupViewController : BaseTableViewController { +@interface MyGroupViewController : GroupDetailViewController { NSMutableArray *_curListGrp; - GroupObject *_curGroup; - BOOL isMemberList; } @property (weak, nonatomic) IBOutlet UITableView *tableGrp; - -@property (weak, nonatomic) IBOutlet UILabel *lblGroupName; -@property (weak, nonatomic) IBOutlet UILabel *lblActiveMode; -@property (weak, nonatomic) IBOutlet UILabel *lblGoal; @property (weak, nonatomic) IBOutlet UIButton *btShowGrp; -@property (weak, nonatomic) IBOutlet AutoTransButton *btSwitch; -- (IBAction)clickBack:(id)sender; - (IBAction)clickShowGrp:(id)sender; -- (IBAction)clickSwitch:(id)sender; @end diff --git a/LifeLog/LifeLog/MyGroupViewController.m b/LifeLog/LifeLog/MyGroupViewController.m index 0b314c8..4ebadb8 100644 --- a/LifeLog/LifeLog/MyGroupViewController.m +++ b/LifeLog/LifeLog/MyGroupViewController.m @@ -34,42 +34,6 @@ // Dispose of any resources that can be recreated. } -- (void)setupView { - if(_curGroup != nil) { - [self.lblGoal setText:_curGroup.goal]; - NSString *mode = @""; - if(_curGroup.runMode) { - mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.running", nil)]; - mode = [mode stringByAppendingString:@"\n"]; - } - if(_curGroup.walkMode) { - mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.walking", nil)]; - mode = [mode stringByAppendingString:@"\n"]; - } - if(_curGroup.bikeMode) { - mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.bike", nil)]; - mode = [mode stringByAppendingString:@"\n"]; - } - if(_curGroup.stepMode) { - mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.step", nil)]; - mode = [mode stringByAppendingString:@"\n"]; - } - if(_curGroup.beginMode) { - mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.begin", nil)]; - mode = [mode stringByAppendingString:@"\n"]; - } - if(_curGroup.gymMode) { - mode = [mode stringByAppendingString:NSLocalizedString(@"lifelog.grDetail.mode.gym", nil)]; - mode = [mode stringByAppendingString:@"\n"]; - } - NSRange range = [mode rangeOfString:@"\n" options:NSBackwardsSearch]; - if(range.length > 0) { - mode = [mode stringByReplacingOccurrencesOfString:@"\n" withString:@"" options:NSBackwardsSearch range:range]; - } - self.lblActiveMode.text = mode; - } -} - #pragma mark IBAction - (IBAction)clickBack:(id)sender { @@ -171,7 +135,7 @@ - (void) resetGroupData : (int) index { _curGroup = [_curListGrp objectAtIndex:index]; - self.lblGroupName.text = _curGroup.name; + self.lblGrpName.text = _curGroup.name; [_curDataList removeAllObjects]; [self.tableBase reloadData]; [self requestGroupDetail]; @@ -181,6 +145,9 @@ NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; [[ServerAPI server] requestGroupList:token CompletionHandler:^(NSArray *array, NSError *error) { + dispatch_async(dispatch_get_main_queue(), ^{ + [hudView hideAnimated:true]; + }); if(error == nil) { [_curListGrp removeAllObjects]; [_curListGrp addObjectsFromArray:array]; @@ -192,7 +159,7 @@ [weakSelf resetGroupData:0]; } else { - weakSelf.lblGroupName.text = @"No Group"; + weakSelf.lblGrpName.text = @"No Group"; } [weakSelf.btShowGrp setEnabled:(_curListGrp.count > 0)]; }); @@ -200,52 +167,4 @@ }]; } -- (void) requestGroupDetail { - NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; - MBProgressHUD *hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; - [[ServerAPI server] getGroupDetail:token withGroupID:_curGroup.groupID CompletionHandler:^(GroupObject *object, NSError *error) { - MyGroupViewController __weak *weakSelf = self; - [_curGroup updateDate:object]; - dispatch_async(dispatch_get_main_queue(), ^{ - [hudView hideAnimated:true]; - [weakSelf setupView]; - [weakSelf callRequestToUpdateData]; - }); - }]; -} - --(void) callRequestToUpdateData { - [super callRequestToUpdateData]; - - NSString * token = [[NSUserDefaults standardUserDefaults] stringForKey:kToken]; - MBProgressHUD *hudView = nil; - if(_curPage == 1 && !self.refreshControl.isRefreshing) { - hudView = [MBProgressHUD showHUDAddedTo:self.view animated:true]; - } - if(isMemberList) { - [[ServerAPI server] requestMemberList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){ - dispatch_async(dispatch_get_main_queue(), ^{ - if(hudView != nil) { - [hudView hideAnimated:true]; - } - }); - MyGroupViewController __weak *weakSelf = self; - [weakSelf updateTableData:array error:error]; - [weakSelf.btSwitch setUserInteractionEnabled:true]; - }]; - } - else { - [[ServerAPI server] requestTweetsList:token groupID:_curGroup.groupID withPage:_curPage CompletionHandler:^(NSArray *array, NSError *error){ - dispatch_async(dispatch_get_main_queue(), ^{ - if(hudView != nil) { - [hudView hideAnimated:true]; - } - }); - MyGroupViewController __weak *weakSelf = self; - [weakSelf updateTableData:array error:error]; - [weakSelf.btSwitch setUserInteractionEnabled:true]; - }]; - } -} - @end diff --git a/LifeLog/LifeLog/MyGroupViewController.xib b/LifeLog/LifeLog/MyGroupViewController.xib index 10b9459..21f7244 100644 --- a/LifeLog/LifeLog/MyGroupViewController.xib +++ b/LifeLog/LifeLog/MyGroupViewController.xib @@ -12,9 +12,9 @@ - - - + + + @@ -83,9 +83,9 @@ - -