Commit 40722ba0bbeac36ab3913416aafd6f9838597c4e
1 parent
5f02f0e9
no message
Showing
8 changed files
with
60 additions
and
94 deletions
CNLiveMineModule/Classes/UserInfo/CNLiveInfoUpdateController.h
| ... | ... | @@ -6,20 +6,12 @@ |
| 6 | 6 | // Copyright (c) 2019 153993236@qq.com. All rights reserved. |
| 7 | 7 | // |
| 8 | 8 | |
| 9 | -#import <UIKit/UIKit.h> | |
| 10 | -#import "CNLiveUserInfoModel.h" | |
| 11 | 9 | #import "CNCommonViewController.h" |
| 12 | 10 | |
| 13 | 11 | NS_ASSUME_NONNULL_BEGIN |
| 14 | -@class CNLiveInfoUpdateController; | |
| 15 | - | |
| 16 | -@protocol CNLiveInfoUpdateDelegate <NSObject> | |
| 17 | -- (void)updateSuccess:(CNLiveUserInfoDataType)dataType info:(NSString *)info; | |
| 18 | - | |
| 19 | -@end | |
| 12 | +@class CNLiveUserInfoModel; | |
| 20 | 13 | |
| 21 | 14 | @interface CNLiveInfoUpdateController : CNCommonViewController |
| 22 | -@property (nonatomic, weak) id<CNLiveInfoUpdateDelegate> delegate; | |
| 23 | 15 | |
| 24 | 16 | /** |
| 25 | 17 | * @abstract 对象方法 初始化方法 | ... | ... |
CNLiveMineModule/Classes/UserInfo/CNLiveInfoUpdateController.m
| ... | ... | @@ -29,7 +29,7 @@ |
| 29 | 29 | #import "CNLiveGoldWhereaboutsView.h" |
| 30 | 30 | #import "CNLiveCategory.h" |
| 31 | 31 | |
| 32 | -#import "CNLiveUserInfoModel.h" | |
| 32 | +//#import "CNLiveUserInfoModel.h" | |
| 33 | 33 | #import "CNLiveUserInfoNotification.h" |
| 34 | 34 | #import "CNLiveUserInfoNavigationBar.h" |
| 35 | 35 | |
| ... | ... | @@ -594,10 +594,8 @@ static const CGFloat timeValue = 1.5; |
| 594 | 594 | |
| 595 | 595 | #pragma mark - 更新提示 |
| 596 | 596 | - (void)showSucceed:(NSString *)info{ |
| 597 | - // 跟新本地数据 | |
| 598 | - if (self.delegate && [self.delegate respondsToSelector:@selector(updateSuccess:info:)]) { | |
| 599 | - [self.delegate updateSuccess:self.model.dataType info:info]; | |
| 600 | - } | |
| 597 | + [CNLiveUserInfoNotification postUserInfoUpdateNotificationType:self.model.dataType info:info]; | |
| 598 | + | |
| 601 | 599 | [[IMAPlatform sharedInstance].host asyncProfile]; |
| 602 | 600 | [QMUITips hideAllToastInView:self.view animated:YES]; |
| 603 | 601 | self.navigationBar.right.userInteractionEnabled = YES; |
| ... | ... | @@ -606,6 +604,7 @@ static const CGFloat timeValue = 1.5; |
| 606 | 604 | [QMUITips hideAllToastInView:self.view animated:YES]; |
| 607 | 605 | [self goBack]; |
| 608 | 606 | }); |
| 607 | + | |
| 609 | 608 | } |
| 610 | 609 | - (void)showError:(NSString *)text{ |
| 611 | 610 | self.navigationBar.right.userInteractionEnabled = YES; |
| ... | ... | @@ -668,7 +667,7 @@ static const CGFloat timeValue = 1.5; |
| 668 | 667 | [_contentView addSubview:self.textField]; |
| 669 | 668 | self.textField.placeholder = @"请输入昵称"; |
| 670 | 669 | |
| 671 | - self.textField.text = self.model.content; | |
| 670 | + self.textField.text = self.model.info; | |
| 672 | 671 | } |
| 673 | 672 | break; |
| 674 | 673 | case CNLiveUserInfoDataTypeAddress: |
| ... | ... | @@ -678,7 +677,7 @@ static const CGFloat timeValue = 1.5; |
| 678 | 677 | [_contentView addSubview:self.textField]; |
| 679 | 678 | self.textField.placeholder = @"请输入你所在的地区"; |
| 680 | 679 | |
| 681 | - self.textField.text = self.model.content; | |
| 680 | + self.textField.text = self.model.info; | |
| 682 | 681 | } |
| 683 | 682 | break; |
| 684 | 683 | case CNLiveUserInfoDataTypeGender: |
| ... | ... | @@ -697,7 +696,7 @@ static const CGFloat timeValue = 1.5; |
| 697 | 696 | |
| 698 | 697 | _contentView.frame = CGRectMake(0, NavigationContentTop+margin, SCREEN_WIDTH, 120); |
| 699 | 698 | [_contentView addSubview:self.textView]; |
| 700 | - self.textView.text = self.model.content; | |
| 699 | + self.textView.text = self.model.info; | |
| 701 | 700 | self.textNum.text = [NSString stringWithFormat:@"%lu",MAX(0,MAX_LIMIT_NUMS - self.textView.text.length)]; |
| 702 | 701 | |
| 703 | 702 | [_contentView addSubview:self.textNum]; | ... | ... |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoCell.m
| ... | ... | @@ -50,7 +50,7 @@ static const NSInteger margin = 12; |
| 50 | 50 | _model = model; |
| 51 | 51 | _title.text = model.title; |
| 52 | 52 | |
| 53 | - _content.text = model.content; | |
| 53 | + _content.text = model.info; | |
| 54 | 54 | |
| 55 | 55 | if(model.dataType == CNLiveUserInfoDataTypeHead){ |
| 56 | 56 | _pic.backgroundColor = [UIColor whiteColor]; |
| ... | ... | @@ -58,15 +58,15 @@ static const NSInteger margin = 12; |
| 58 | 58 | _pic.layer.masksToBounds = YES; |
| 59 | 59 | _pic.layer.cornerRadius = 5.0; |
| 60 | 60 | UIImage *xw_image = [self getImageWithImageName:@"default_avatar_f" bundleName:@"CNLiveMineModule" targetClass:[self class]]; |
| 61 | - [_pic sd_setImageWithURL:[NSURL URLWithString:model.content] placeholderImage:xw_image]; | |
| 61 | + [_pic sd_setImageWithURL:[NSURL URLWithString:model.info] placeholderImage:xw_image]; | |
| 62 | 62 | |
| 63 | 63 | }else if (model.dataType == CNLiveUserInfoDataTypeNickname){ |
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | }else if (model.dataType == CNLiveUserInfoDataTypeGender){ |
| 67 | - if([model.content isEqualToString:@"m"]){ | |
| 67 | + if([model.info isEqualToString:@"m"]){ | |
| 68 | 68 | _content.text = @"男"; |
| 69 | - }else if([model.content isEqualToString:@"f"]){ | |
| 69 | + }else if([model.info isEqualToString:@"f"]){ | |
| 70 | 70 | _content.text = @"女"; |
| 71 | 71 | }else{ |
| 72 | 72 | _content.text = @"未知"; | ... | ... |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoController.m
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | #import "CNLiveUserInfoNotification.h" |
| 20 | 20 | #import "CNLiveUserInfoNavigationBar.h" |
| 21 | 21 | |
| 22 | -@interface CNLiveUserInfoController ()<UITableViewDelegate, UITableViewDataSource, CNLiveInfoUpdateDelegate, CNLiveUserInfoNavigationBarDelegate>{ | |
| 22 | +@interface CNLiveUserInfoController ()<UITableViewDelegate, UITableViewDataSource, CNLiveUserInfoNavigationBarDelegate>{ | |
| 23 | 23 | UIImage *_image; |
| 24 | 24 | } |
| 25 | 25 | @property (nonatomic, strong) CNLiveUserInfoNavigationBar *navigationBar; |
| ... | ... | @@ -36,7 +36,7 @@ |
| 36 | 36 | @"layout":@"2", |
| 37 | 37 | @"data":@"0", |
| 38 | 38 | @"title":@"头像", |
| 39 | - @"content":CNUserShareModel.faceUrl, | |
| 39 | + @"info":CNUserShareModel.faceUrl, | |
| 40 | 40 | @"height":@"81", |
| 41 | 41 | @"lineHeight":@"0.5" |
| 42 | 42 | }, |
| ... | ... | @@ -44,7 +44,7 @@ |
| 44 | 44 | @"layout":@"1", |
| 45 | 45 | @"data":@"1", |
| 46 | 46 | @"title":@"昵称", |
| 47 | - @"content":CNUserShareModel.nickname, | |
| 47 | + @"info":CNUserShareModel.nickname, | |
| 48 | 48 | @"height":@"51", |
| 49 | 49 | @"lineHeight":@"0.5" |
| 50 | 50 | }, |
| ... | ... | @@ -52,7 +52,7 @@ |
| 52 | 52 | @"layout":@"1", |
| 53 | 53 | @"data":@"2", |
| 54 | 54 | @"title":@"性别", |
| 55 | - @"content":CNUserShareModel.gender, | |
| 55 | + @"info":CNUserShareModel.gender, | |
| 56 | 56 | @"height":@"60", |
| 57 | 57 | @"lineHeight":@"10" |
| 58 | 58 | }, |
| ... | ... | @@ -60,7 +60,7 @@ |
| 60 | 60 | @"layout":@"2", |
| 61 | 61 | @"data":@"3", |
| 62 | 62 | @"title":@"二维码", |
| 63 | - @"content":@"二维码", | |
| 63 | + @"info":@"二维码", | |
| 64 | 64 | @"height":@"51", |
| 65 | 65 | @"lineHeight":@"0.5" |
| 66 | 66 | }, |
| ... | ... | @@ -68,7 +68,7 @@ |
| 68 | 68 | @"layout":@"1", |
| 69 | 69 | @"data":@"4", |
| 70 | 70 | @"title":@"地区", |
| 71 | - @"content":CNUserShareModel.location, | |
| 71 | + @"info":CNUserShareModel.location, | |
| 72 | 72 | @"height":@"60", |
| 73 | 73 | @"lineHeight":@"10" |
| 74 | 74 | }, |
| ... | ... | @@ -76,7 +76,7 @@ |
| 76 | 76 | @"layout":@"1", |
| 77 | 77 | @"data":@"5", |
| 78 | 78 | @"title":@"个性签名", |
| 79 | - @"content":CNUserShareModel.signature?CNUserShareModel.signature:@"懒到没签名!", | |
| 79 | + @"info":CNUserShareModel.signature?CNUserShareModel.signature:@"懒到没签名!", | |
| 80 | 80 | @"height":@"51", |
| 81 | 81 | @"lineHeight":@"0.5" |
| 82 | 82 | } |
| ... | ... | @@ -104,14 +104,15 @@ |
| 104 | 104 | else { |
| 105 | 105 | self.automaticallyAdjustsScrollViewInsets = NO; |
| 106 | 106 | } |
| 107 | + [CNLiveUserInfoNotification addUserInfoUpdateObserver:self selector:@selector(userInfoUpdateNotification:)]; | |
| 108 | + | |
| 107 | 109 | [self createSubViews]; |
| 108 | 110 | [self loadData]; |
| 109 | 111 | |
| 110 | 112 | } |
| 111 | 113 | |
| 112 | 114 | - (void)dealloc { |
| 113 | - | |
| 114 | - | |
| 115 | + [CNLiveUserInfoNotification removeObserver:self]; | |
| 115 | 116 | } |
| 116 | 117 | |
| 117 | 118 | - (void)createSubViews { |
| ... | ... | @@ -144,73 +145,45 @@ |
| 144 | 145 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ |
| 145 | 146 | CNLiveUserInfoModel *model = self.data[indexPath.row]; |
| 146 | 147 | switch (model.dataType) { |
| 147 | - case CNLiveUserInfoDataTypeHead: | |
| 148 | - { | |
| 149 | - CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | |
| 150 | - vc.delegate = self; | |
| 151 | - [self.navigationController pushViewController:vc animated:YES]; | |
| 152 | - } | |
| 153 | - break; | |
| 154 | - case CNLiveUserInfoDataTypeNickname: | |
| 155 | - { | |
| 156 | - CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | |
| 157 | - vc.delegate = self; | |
| 158 | - [self.navigationController pushViewController:vc animated:YES]; | |
| 159 | - } | |
| 160 | - break; | |
| 161 | - case CNLiveUserInfoDataTypeGender: | |
| 162 | - { | |
| 163 | - CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | |
| 164 | - vc.delegate = self; | |
| 165 | - [self.navigationController pushViewController:vc animated:YES]; | |
| 166 | - } | |
| 167 | - break; | |
| 168 | 148 | case CNLiveUserInfoDataTypeCode: |
| 169 | 149 | { |
| 170 | 150 | id<CNLiveQrCodeServiceProtocol> service = [[BeeHive shareInstance] createService:@protocol(CNLiveQrCodeServiceProtocol)]; |
| 171 | 151 | [service pushToMyQrCodeController:NO]; |
| 172 | 152 | } |
| 173 | 153 | break; |
| 174 | - case CNLiveUserInfoDataTypeAddress: | |
| 175 | - { | |
| 176 | - CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; | |
| 177 | - vc.delegate = self; | |
| 178 | - [self.navigationController pushViewController:vc animated:YES]; | |
| 179 | - } | |
| 180 | - break; | |
| 181 | - case CNLiveUserInfoDataTypeIntroduction: | |
| 154 | + default: | |
| 182 | 155 | { |
| 183 | 156 | CNLiveInfoUpdateController *vc = [[CNLiveInfoUpdateController alloc]initWithModel:model]; |
| 184 | - vc.delegate = self; | |
| 185 | 157 | [self.navigationController pushViewController:vc animated:YES]; |
| 186 | 158 | } |
| 187 | 159 | break; |
| 188 | - | |
| 189 | - default: | |
| 190 | - break; | |
| 191 | 160 | } |
| 192 | 161 | } |
| 193 | -#pragma mark - CNLiveInfoUpdateDelegate | |
| 194 | -- (void)updateSuccess:(CNLiveUserInfoDataType)dataType info:(NSString *)info{ | |
| 195 | - [self updateDataType:dataType info:info]; | |
| 162 | + | |
| 163 | +#pragma mark - CNLiveUserInfoNavigationBarDelegate | |
| 164 | +- (void)navigationBar:(CNLiveUserInfoNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ | |
| 165 | + if ([actionEvents isEqualToString:@"1"]) { | |
| 166 | + [self goBack]; | |
| 167 | + } | |
| 196 | 168 | } |
| 197 | 169 | |
| 198 | -// 更新cell展示信息 | |
| 199 | -- (void)updateDataType:(CNLiveUserInfoDataType)dataType info:(NSString *)info{ | |
| 170 | +#pragma mark - 监听 | |
| 171 | +// 更新用户信息 | |
| 172 | +- (void)userInfoUpdateNotification:(NSNotification *)noti{ | |
| 173 | + //使用userInfo处理消息 | |
| 174 | + NSDictionary *dic = [noti userInfo]; | |
| 175 | + CNLiveUserInfoDataType dataType = [[dic objectForKey:@"type"] integerValue]; | |
| 176 | + NSString *info = [dic objectForKey:@"info"]; | |
| 177 | + | |
| 178 | + // 更新cell展示信息 | |
| 200 | 179 | for(CNLiveUserInfoModel *model in self.data){ |
| 201 | 180 | if(dataType == model.dataType){ |
| 202 | - model.content = info; | |
| 181 | + model.info = info; | |
| 203 | 182 | break; |
| 204 | 183 | } |
| 205 | 184 | } |
| 206 | 185 | [self.tableView reloadData]; |
| 207 | -} | |
| 208 | 186 | |
| 209 | -#pragma mark - CNLiveUserInfoNavigationBarDelegate | |
| 210 | -- (void)navigationBar:(CNLiveUserInfoNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{ | |
| 211 | - if ([actionEvents isEqualToString:@"1"]) { | |
| 212 | - [self goBack]; | |
| 213 | - } | |
| 214 | 187 | } |
| 215 | 188 | |
| 216 | 189 | #pragma mark - 懒加载 | ... | ... |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoModel.h
| ... | ... | @@ -29,7 +29,7 @@ typedef NS_ENUM(NSInteger, CNLiveUserInfoDataType) { |
| 29 | 29 | |
| 30 | 30 | @interface CNLiveUserInfoModel : NSObject |
| 31 | 31 | @property (nonatomic, copy) NSString *title; |
| 32 | -@property (nonatomic, copy) NSString *content; | |
| 32 | +@property (nonatomic, copy) NSString *info; | |
| 33 | 33 | @property (nonatomic, copy) NSString *layout; |
| 34 | 34 | @property (nonatomic, copy) NSString *data; |
| 35 | 35 | ... | ... |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoNotification.h
| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #import "CNLiveUserInfoModel.h" |
| 11 | 11 | |
| 12 | 12 | NS_ASSUME_NONNULL_BEGIN |
| 13 | +extern NSString * const kCNLiveUserInfoUpdateNotification; | |
| 13 | 14 | |
| 14 | 15 | @interface CNLiveUserInfoNotification : NSObject |
| 15 | 16 | + (void)postUserInfoUpdateNotificationType:(CNLiveUserInfoDataType)type info:(id)info; | ... | ... |
CNLiveMineModule/Classes/UserInfo/CNLiveUserInfoNotification.m
| ... | ... | @@ -9,7 +9,8 @@ |
| 9 | 9 | #import "CNLiveUserInfoNotification.h" |
| 10 | 10 | |
| 11 | 11 | @implementation CNLiveUserInfoNotification |
| 12 | -static NSString * const kCNLiveUserInfoUpdateNotification = @"CNLiveUserInfoUpdateNotification"; | |
| 12 | + | |
| 13 | +NSString * const kCNLiveUserInfoUpdateNotification = @"CNLiveUserInfoUpdateNotification"; | |
| 13 | 14 | |
| 14 | 15 | + (void)postUserInfoUpdateNotificationType:(CNLiveUserInfoDataType)type info:(id)info{ |
| 15 | 16 | NSDictionary *dic = @{@"type":@(type),@"info":info}; | ... | ... |
CNLiveMineModule/Classes/View/CNLiveMineHeaderView.m
| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #import "CNLiveCategory.h" |
| 14 | 14 | |
| 15 | 15 | #import "CNUserInfoManager.h" |
| 16 | +#import "CNLiveUserInfoNotification.h" | |
| 16 | 17 | |
| 17 | 18 | @interface CNLiveMineHeaderView () |
| 18 | 19 | @property (nonatomic, strong) UIImageView *bgView; |
| ... | ... | @@ -34,7 +35,7 @@ static const NSInteger margin = 20; |
| 34 | 35 | if(self){ |
| 35 | 36 | self.userInteractionEnabled = YES; |
| 36 | 37 | self.backgroundColor = [UIColor colorWithRed:244.0/255.0 green:244.0/255.0 blue:244.0/255.0 alpha:1.0]; |
| 37 | -// [XWUserInfoNotification addUserInfoUpdateObserver:self selector:@selector(userInfoUpdateNotification:)]; | |
| 38 | + [CNLiveUserInfoNotification addUserInfoUpdateObserver:self selector:@selector(userInfoUpdateNotification:)]; | |
| 38 | 39 | [self createSubViews]; |
| 39 | 40 | } |
| 40 | 41 | return self; |
| ... | ... | @@ -42,26 +43,25 @@ static const NSInteger margin = 20; |
| 42 | 43 | // 实现方法 |
| 43 | 44 | - (void)userInfoUpdateNotification:(NSNotification *)noti{ |
| 44 | 45 | //使用userInfo处理消息 |
| 45 | -// NSDictionary *dic = [noti userInfo]; | |
| 46 | -// XWUserInfoDataType type = [[dic objectForKey:@"type"] integerValue]; | |
| 47 | -// if(type == XWUserInfoDataTypeHead){ | |
| 48 | -// UIImage *info = [dic objectForKey:@"info"]; | |
| 49 | -// _header.image = info; | |
| 50 | -// | |
| 51 | -// }else if(type == XWUserInfoDataTypeNickname){ | |
| 52 | -// NSString *info = [dic objectForKey:@"info"]; | |
| 53 | -// _name.attributedText = [self createAttributedImageName:@"mine_code" string:info isFront:NO]; | |
| 54 | -// | |
| 55 | -// }else if(type == XWUserInfoDataTypeAddress){ | |
| 56 | -// NSString *info = [dic objectForKey:@"info"]; | |
| 57 | -// _address.attributedText = [self createAttributedImageName:@"mine_location" string:info isFront:YES]; | |
| 58 | -// | |
| 59 | -// } | |
| 46 | + NSDictionary *dic = [noti userInfo]; | |
| 47 | + CNLiveUserInfoDataType type = [[dic objectForKey:@"type"] integerValue]; | |
| 48 | + NSString *info = [dic objectForKey:@"info"]; | |
| 49 | + if(type == CNLiveUserInfoDataTypeHead){ | |
| 50 | + UIImage *xw_image = [self getImageWithImageName:@"default_avatar_y" bundleName:@"CNLiveMineModule" targetClass:[CNLiveMineHeaderView class]]; | |
| 51 | + [_header sd_setImageWithURL:[NSURL URLWithString:info] placeholderImage:xw_image]; | |
| 52 | + | |
| 53 | + }else if(type == CNLiveUserInfoDataTypeNickname){ | |
| 54 | + _name.attributedText = [self createAttributedImageName:@"mine_code" string:info isFront:NO]; | |
| 55 | + | |
| 56 | + }else if(type == CNLiveUserInfoDataTypeAddress){ | |
| 57 | + _address.attributedText = [self createAttributedImageName:@"mine_location" string:info isFront:YES]; | |
| 58 | + | |
| 59 | + } | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | - (void)dealloc { |
| 63 | 63 | NSLog(@"CNLiveMineHeaderView -- dealloc"); |
| 64 | -// [XWUserInfoNotification removeObserver:self]; | |
| 64 | + [CNLiveUserInfoNotification removeObserver:self]; | |
| 65 | 65 | |
| 66 | 66 | } |
| 67 | 67 | ... | ... |