Initial commit
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// UMComUserNearbyViewController.h
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by wyq.Cloudayc on 3/24/16.
|
||||
// Copyright © 2016 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UMComUserTableViewController.h"
|
||||
|
||||
@interface UMComUserNearbyViewController : UMComUserTableViewController
|
||||
|
||||
@end
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// UMComUserNearbyViewController.m
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by wyq.Cloudayc on 3/24/16.
|
||||
// Copyright © 2016 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UMComUserNearbyViewController.h"
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
#import "UIViewController+UMComAddition.h"
|
||||
#import "UMComResouceDefines.h"
|
||||
#import "UMComShowToast.h"
|
||||
#import "UMComUserListDataController.h"
|
||||
#import <UMComFoundation/UMComKit+Color.h>
|
||||
|
||||
@interface UMComUserNearbyViewController ()
|
||||
<CLLocationManagerDelegate>
|
||||
|
||||
@property (nonatomic, strong) CLLocationManager *locationManager;
|
||||
@property (nonatomic) CLLocation* location;
|
||||
|
||||
@property (nonatomic, strong) UILabel *noLocationTip;
|
||||
|
||||
@end
|
||||
|
||||
@implementation UMComUserNearbyViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.showDistance = YES;
|
||||
|
||||
[self setForumUITitle:self.title];
|
||||
self.title = nil;
|
||||
if (!self.location) {
|
||||
if ([self checkNoLocationAuth]) {
|
||||
// [[[UIAlertView alloc] initWithTitle:nil message:UMComLocalizedString(@"No location",@"此应用程序没有权限访问地理位置信息,请在隐私设置里启用") delegate:nil cancelButtonTitle:@"好的" otherButtonTitles:nil, nil] show];
|
||||
|
||||
[self showNoLocationAuthTip];
|
||||
}
|
||||
if (NO==[CLLocationManager locationServicesEnabled]) {
|
||||
// NSLog(@"---------- 未开启定位");
|
||||
}
|
||||
self.locationManager = [[CLLocationManager alloc] init];
|
||||
self.locationManager.delegate = self;
|
||||
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
|
||||
self.locationManager.distanceFilter = 50.0f;
|
||||
|
||||
[_locationManager startUpdatingLocation];
|
||||
|
||||
if (!([CLLocationManager locationServicesEnabled] == YES && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized)){
|
||||
|
||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0f) {
|
||||
[self.locationManager requestAlwaysAuthorization];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do any additional setup after loading the view.
|
||||
|
||||
self.dataController = [[UMComUserNearbyDataController alloc] initWithCount:UMCom_Limit_Page_Count location:self.location];
|
||||
if (self.location) {
|
||||
self.isAutoStartLoadData = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.isAutoStartLoadData = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
- (BOOL)checkNoLocationAuth
|
||||
{
|
||||
return ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusRestricted
|
||||
|| [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied);
|
||||
}
|
||||
|
||||
- (void)showNoLocationAuthTip
|
||||
{
|
||||
if (!_noLocationTip) {
|
||||
UILabel *tip = [[UILabel alloc] init];
|
||||
[tip setText:UMComLocalizedString(@"cannotGetLocation_checkGPS", @"无法获取您的位置信息\n请检查GPS设置")];
|
||||
[tip setTextColor:UMComColorWithHexString(@"#A5A5A5")];
|
||||
[tip setFont:[UIFont systemFontOfSize:15.f]];
|
||||
tip.numberOfLines = 2;
|
||||
tip.textAlignment = NSTextAlignmentCenter;
|
||||
CGSize tipSize = [tip.text sizeWithFont:tip.font constrainedToSize:self.view.bounds.size lineBreakMode:NSLineBreakByWordWrapping];
|
||||
[tip setFrame:CGRectMake(0.f, 0.f, tipSize.width, tipSize.height)];
|
||||
tip.center = CGPointMake(self.view.bounds.size.width / 2.f, self.view.bounds.size.height / 2.f - 50.f);
|
||||
self.noLocationTip = tip;
|
||||
}
|
||||
[self.view addSubview:_noLocationTip];
|
||||
}
|
||||
|
||||
- (void)updateLocationAuthTip
|
||||
{
|
||||
if ([self checkNoLocationAuth]) {
|
||||
[self showNoLocationAuthTip];
|
||||
} else {
|
||||
[self.noLocationTip removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager
|
||||
didUpdateLocations:(NSArray *)locations
|
||||
{
|
||||
self.tableView.scrollEnabled = YES;
|
||||
|
||||
((UMComUserNearbyDataController*)self.dataController).location = manager.location;
|
||||
[self refreshData];
|
||||
|
||||
[self updateLocationAuthTip];
|
||||
}
|
||||
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager
|
||||
didFailWithError:(NSError *)error
|
||||
{
|
||||
[self.dataController.dataArray removeAllObjects];;
|
||||
[self.tableView reloadData];
|
||||
|
||||
self.tableView.scrollEnabled = NO;
|
||||
|
||||
[UMComShowToast fetchFailWithNoticeMessage:UMComLocalizedString(@"fail to location",@"定位失败")];
|
||||
|
||||
[self updateLocationAuthTip];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// UMComUserOperationFinishDelegate.h
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by umeng on 16/1/14.
|
||||
// Copyright © 2016年 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol UMComUserOperationFinishDelegate <NSObject>
|
||||
|
||||
- (void)reloadDataWhenUserOperationFinish:(UMComUser *)user;
|
||||
|
||||
- (void)focusedUserOperationFinish:(UMComUser *)user;
|
||||
|
||||
|
||||
@end
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// UMComUserDetaiView.h
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by umeng on 16/2/2.
|
||||
// Copyright © 2016年 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class UMComUser, UMComImageView, UMComUserProfileDetailView;
|
||||
@protocol UMComUserProfileDetaiViewDelegate <NSObject>
|
||||
|
||||
@optional;
|
||||
- (void)userProfileDetailView:(UMComUserProfileDetailView *)userProfileDetailView
|
||||
clickOnfocuse:(UIButton *)focuseButton;
|
||||
|
||||
- (void)userProfileDetailView:(UMComUserProfileDetailView *)userProfileDetailView
|
||||
clickOnAlbum:(UIButton *)albumButton;
|
||||
|
||||
- (void)userProfileDetailView:(UMComUserProfileDetailView *)userProfileDetailView
|
||||
clickOnFollowTopic:(UIButton *)topicButton;
|
||||
|
||||
- (void)userProfileDetailView:(UMComUserProfileDetailView *)userProfileDetailView
|
||||
clickOnScore:(UIButton *)letterButton;
|
||||
|
||||
- (void)userProfileDetailView:(UMComUserProfileDetailView *)userProfileDetailView
|
||||
clickOnAvatar:(UMComImageView *)avartar;
|
||||
|
||||
- (void)userProfileDetailView:(UMComUserProfileDetailView *)userProfileDetailView
|
||||
clickAtIndex:(NSInteger)index;
|
||||
|
||||
@end
|
||||
|
||||
@interface UMComUserProfileDetailView : UIView
|
||||
|
||||
@property (nonatomic, strong) UMComUser *user;
|
||||
|
||||
@property (nonatomic, assign) NSInteger lastIndex;
|
||||
|
||||
@property (nonatomic, strong) UMComImageView *avatarImageView;
|
||||
|
||||
@property (nonatomic, strong) UILabel *nameLabel;
|
||||
|
||||
@property (nonatomic, weak) id<UMComUserProfileDetaiViewDelegate> deleagte;
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame user:(UMComUser *)user;
|
||||
|
||||
- (void)reloadSubViewsWithUser:(UMComUser *)user;
|
||||
|
||||
|
||||
@end
|
||||
+633
@@ -0,0 +1,633 @@
|
||||
//
|
||||
// UMComUserDetaiView.m
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by umeng on 16/2/2.
|
||||
// Copyright © 2016年 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UMComUserProfileDetailView.h"
|
||||
#import "UMComImageView.h"
|
||||
#import "UMComResouceDefines.h"
|
||||
#import <UMComDataStorage/UMComUser.h>
|
||||
#import <UMComDataStorage/UMComImageUrl.h>
|
||||
#import "UMComHorizonCollectionView.h"
|
||||
#import <UMComDataStorage/UMComMedal.h>
|
||||
#import <UMCommunitySDK/UMComSession.h>
|
||||
#import "UMComMedalImageView.h"
|
||||
#import <UMComFoundation/UMComKit+Color.h>
|
||||
|
||||
//detailView
|
||||
#define UMCom_Forum_UserCenter_ButtonHeight 30
|
||||
#define UMCom_Forum_UserCenter_ButtonWidth 70
|
||||
#define UMCom_Forum_UserCenter_ButtonSpace 38
|
||||
#define UMCom_Forum_UserCenter_AvatarWidth 75
|
||||
#define UMCom_Forum_UserCenter_AvatarTopEdge 25
|
||||
#define UMCom_Forum_UserCenter_AvatarNameSpace 8
|
||||
#define UMCom_Forum_UserCenter_NameButtonSpace 0
|
||||
#define UMCom_Forum_UserCenter_ProfileButtonFont 13
|
||||
#define UMCom_Forum_UserCenter_NameFont 14
|
||||
#define UMCom_Forum_UserCenter_ButtonTitleColor @"#9CD0F3"
|
||||
#define UMCom_Forum_UserCenter_DetailViewBgColor @"#FAFBFD"
|
||||
|
||||
|
||||
//menuview
|
||||
#define UMCom_Forum_UserCenter_DetailMenuSpace 15
|
||||
|
||||
#define UMCom_Forum_UserCenter_MenuTitleFont 16
|
||||
#define UMCom_Forum_UserCenter_MenuCountFont 12
|
||||
#define UMCom_Forum_UserCenter_MenuViewHeight 48
|
||||
#define UMCom_Forum_UserCenter_MenuEdgeLineConlor @"#EEEFF3"
|
||||
#define UMCom_Forum_UserCenter_MenuBgColor @"#9CD0F3"
|
||||
#define UMCom_Forum_UserCenter_MenuTitleColor @"#A5A5A5"
|
||||
#define UMCom_Forum_UserCenter_MenuTitleHighLightColor @"#008BEA"
|
||||
|
||||
|
||||
@interface UMComUserProfileDetailView ()<UMComHorizonCollectionViewDelegate,UMComImageViewDelegate>
|
||||
|
||||
@property (nonatomic,readwrite,strong) UIButton *albumButton;
|
||||
@property (nonatomic,readwrite,strong) UIButton *topicButton;
|
||||
@property (nonatomic, strong) UIButton *focuseButton;
|
||||
|
||||
@property (nonatomic, strong) UIButton *scoreButton;
|
||||
|
||||
@property (nonatomic, strong) UIImageView *genderView;
|
||||
|
||||
@property (nonatomic, strong) UMComImageView *medal_icon;
|
||||
|
||||
@property (nonatomic, strong) UMComHorizonCollectionView *menuView;
|
||||
|
||||
@property (nonatomic, strong) NSArray *countLabelList;
|
||||
|
||||
//单个勋章UI布局
|
||||
//@property(nonatomic,strong)UMComMedalImageView* medalView;
|
||||
//-(void) relayoutMedalView;
|
||||
//-(void) doRelayoutMedalView;
|
||||
|
||||
//多勋章布局
|
||||
@property(nonatomic,assign)NSInteger curMedalCount;//勋章的数量(最大5个)
|
||||
@property(nonatomic,strong)NSMutableArray* medalViewArray;//包含勋章控件(UMComMedalImageView)
|
||||
-(void) createMedalViews;
|
||||
-(void) requestIMGForMedalViews:(UMComUser*)user;
|
||||
-(void) clearRequestForMedalViews;
|
||||
-(CGSize)computeMedalViewSize:(UMComMedalImageView*)medalView;
|
||||
-(void) layoutMedalViews;
|
||||
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation UMComUserProfileDetailView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame user:(UMComUser *)user
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
CGFloat avatarWidth = UMCom_Forum_UserCenter_AvatarWidth;
|
||||
CGFloat image_top_edge = UMCom_Forum_UserCenter_AvatarTopEdge;
|
||||
UMComImageView *avatar = [[[UMComImageView imageViewClassName] alloc]initWithFrame:CGRectMake(frame.size.width/2-avatarWidth/2, image_top_edge, avatarWidth, avatarWidth)];
|
||||
[self addSubview:avatar];
|
||||
avatar.clipsToBounds = YES;
|
||||
avatar.userInteractionEnabled = YES;
|
||||
avatar.layer.cornerRadius = avatarWidth/2;
|
||||
self.avatarImageView = avatar;
|
||||
|
||||
/*
|
||||
//屏蔽头像右下角勋章的创建
|
||||
self.medal_icon = [[[UMComImageView imageViewClassName] alloc] init];
|
||||
CGFloat medel_icon_width = 16;
|
||||
self.medal_icon.backgroundColor = [UIColor clearColor];
|
||||
CGRect imageFrame = CGRectMake(0, 0, medel_icon_width, medel_icon_width);
|
||||
imageFrame.origin.x = avatarWidth - medel_icon_width-2 + avatar.frame.origin.x;
|
||||
imageFrame.origin.y = avatarWidth - medel_icon_width-2 + avatar.frame.origin.y;
|
||||
self.medal_icon.frame = imageFrame;
|
||||
[self addSubview:_medal_icon];
|
||||
*/
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapOnAvatar:)];
|
||||
[self.avatarImageView addGestureRecognizer:tap];
|
||||
|
||||
self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.avatarImageView.frame.size.height + self.avatarImageView.frame.origin.y + UMCom_Forum_UserCenter_AvatarNameSpace, 80, 30)];
|
||||
self.nameLabel.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_UserCenter_NameFont);
|
||||
self.nameLabel.center = CGPointMake(self.frame.size.width/2, self.nameLabel.center.y);
|
||||
[self addSubview:self.nameLabel];
|
||||
|
||||
self.genderView = [[UIImageView alloc]initWithFrame:CGRectMake(self.nameLabel.frame.origin.x + self.nameLabel.frame.size.width + 10, self.nameLabel.frame.origin.y, 20, 20)];
|
||||
[self addSubview:self.genderView];
|
||||
|
||||
//创建勋章控件
|
||||
/*
|
||||
self.medalView = [[UMComMedalImageView alloc] initWithFrame:CGRectMake(0, 0, [UMComMedalImageView defaultWidth], self.nameLabel.bounds.size.height)];
|
||||
self.medalView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self addSubview:self.medalView];
|
||||
*/
|
||||
|
||||
//创建多勋章控件
|
||||
[self createMedalViews];
|
||||
|
||||
CGFloat buttonWidth = UMCom_Forum_UserCenter_ButtonWidth;
|
||||
CGRect buttonFrame;
|
||||
CGFloat buttonSpace = UMCom_Forum_UserCenter_ButtonSpace;
|
||||
buttonFrame.origin.x = self.frame.size.width/2 - buttonWidth - buttonSpace - buttonWidth/2;
|
||||
buttonFrame.origin.y = self.nameLabel.frame.size.height + self.nameLabel.frame.origin.y + UMCom_Forum_UserCenter_NameButtonSpace;
|
||||
buttonFrame.size.width = buttonWidth;
|
||||
buttonFrame.size.height = UMCom_Forum_UserCenter_ButtonHeight;
|
||||
UIButton *album = [self createNewButtonWithImageName:@"um_forum_user_album" title:UMComLocalizedString(@"um_com_album", @"相册") action:@selector(clickOnAlbumButton:) frame:buttonFrame];
|
||||
[self addSubview:album];
|
||||
self.albumButton = album;
|
||||
|
||||
buttonFrame.origin.x = buttonFrame.origin.x + buttonWidth + buttonSpace;
|
||||
UIButton *topic = [self createNewButtonWithImageName:@"um_forum_user_topic" title:UMComLocalizedString(@"um_com_topic", @"话题") action:@selector(clickOnTopicButton:) frame:buttonFrame];
|
||||
[self addSubview:topic];
|
||||
self.topicButton = topic;
|
||||
|
||||
buttonFrame.origin.x = buttonFrame.origin.x + buttonWidth + buttonSpace;
|
||||
buttonFrame.size.width = buttonFrame.size.width;
|
||||
|
||||
NSString *pointStr = [NSString stringWithFormat:@"%@",countString(user.point)];
|
||||
UIButton *point = [self createNewButtonWithImageName:@"um_forum_user_score" title:[NSString stringWithFormat:UMComLocalizedString(@"um_com_scoreCount_template", @"%@"),pointStr] action:@selector(clickOnScoreButton:) frame:buttonFrame];
|
||||
[self addSubview:point];
|
||||
point.enabled = NO;
|
||||
_scoreButton = point;
|
||||
|
||||
buttonFrame.size.width = buttonFrame.size.width;
|
||||
buttonFrame.origin.x = self.avatarImageView.frame.origin.x + avatarWidth + 26;
|
||||
buttonFrame.origin.y = self.avatarImageView.frame.origin.y + self.avatarImageView.frame.size.height/2 - buttonFrame.size.height/2;
|
||||
buttonFrame.size.width = 80;
|
||||
UIButton * focuseButton = [self createNewButtonWithImageName:nil title:nil action:@selector(clickOnFocuseButton:) frame:buttonFrame];
|
||||
[focuseButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_focuse") forState:UIControlStateNormal];
|
||||
[self addSubview:focuseButton];
|
||||
_focuseButton = focuseButton;
|
||||
[self reloadSubViewsWithUser:user];
|
||||
self.backgroundColor = UMComColorWithHexString(UMCom_Forum_UserCenter_DetailViewBgColor);
|
||||
|
||||
UMComHorizonCollectionView *collectionView = [[UMComHorizonCollectionView alloc]initWithFrame:CGRectMake(0, self.frame.size.height-UMCom_Forum_UserCenter_MenuViewHeight, self.frame.size.width, UMCom_Forum_UserCenter_MenuViewHeight) itemCount:3];
|
||||
collectionView.cellDelegate = self;
|
||||
collectionView.itemSpace = 0;
|
||||
collectionView.bottomLineHeight = 1;
|
||||
collectionView.topLine.backgroundColor = UMComColorWithHexString(@"#EEEFF3");
|
||||
collectionView.bottomLine.backgroundColor = UMComColorWithHexString(@"#EEEFF3");
|
||||
collectionView.indicatorLineHeight = 3;
|
||||
collectionView.scrollIndicatorView.backgroundColor = UMComColorWithHexString(@"#008BEA");
|
||||
collectionView.indicatorLineWidth = UMComWidthScaleBetweenCurentScreenAndiPhone6Screen(32);
|
||||
collectionView.indicatorLineLeftEdge = UMComWidthScaleBetweenCurentScreenAndiPhone6Screen(47);
|
||||
collectionView.scrollEnabled = NO;
|
||||
[self addSubview:collectionView];
|
||||
self.menuView = collectionView;
|
||||
self.countLabelList = [self createLabelList];
|
||||
//重新布局
|
||||
// [self relayoutMedalView];
|
||||
//单勋章布局
|
||||
//[self relayoutMedalView];
|
||||
|
||||
//多勋章布局
|
||||
[self clearRequestForMedalViews];
|
||||
[self requestIMGForMedalViews:user];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (UIButton *)createNewButtonWithImageName:(NSString *)imageName
|
||||
title:(NSString *)title
|
||||
action:(SEL)action
|
||||
frame:(CGRect)frame;
|
||||
{
|
||||
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
button.frame = frame;
|
||||
button.backgroundColor = [UIColor clearColor];
|
||||
[button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
|
||||
button.titleLabel.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_UserCenter_ProfileButtonFont);
|
||||
[button setTitleColor:UMComColorWithHexString(UMCom_Forum_UserCenter_ButtonTitleColor) forState:UIControlStateNormal];
|
||||
[button setTitle:title forState:UIControlStateNormal];
|
||||
[button setImage:UMComImageWithImageName(imageName) forState:UIControlStateNormal];
|
||||
CGFloat imageWidth = 20;
|
||||
CGFloat imageEdge = 5;
|
||||
[button setImageEdgeInsets:UIEdgeInsetsMake(imageEdge, imageEdge, imageEdge, frame.size.width - imageWidth*2)];
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
- (void)clickOnAlbumButton:(UIButton *)sender
|
||||
{
|
||||
if (self.deleagte && [self.deleagte respondsToSelector:@selector(userProfileDetailView:clickOnAlbum:)]) {
|
||||
[self.deleagte userProfileDetailView:self clickOnAlbum:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clickOnTopicButton:(UIButton *)sender
|
||||
{
|
||||
if (self.deleagte && [self.deleagte respondsToSelector:@selector(userProfileDetailView:clickOnFollowTopic:)]) {
|
||||
[self.deleagte userProfileDetailView:self clickOnFollowTopic:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clickOnScoreButton:(UIButton *)sender
|
||||
{
|
||||
if (self.deleagte && [self.deleagte respondsToSelector:@selector(userProfileDetailView:clickOnScore:)]) {
|
||||
[self.deleagte userProfileDetailView:self clickOnScore:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)clickOnFocuseButton:(UIButton *)sender
|
||||
{
|
||||
if (self.deleagte && [self.deleagte respondsToSelector:@selector(userProfileDetailView:clickOnfocuse:)]) {
|
||||
[self.deleagte userProfileDetailView:self clickOnfocuse:sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)tapOnAvatar:(id)sender
|
||||
{
|
||||
if (self.deleagte && [self.deleagte respondsToSelector:@selector(userProfileDetailView:clickOnAvatar:)]) {
|
||||
[self.deleagte userProfileDetailView:self clickOnAvatar:self.avatarImageView];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reloadSubViewsWithUser:(UMComUser *)user
|
||||
{
|
||||
NSString *scoreStr = [NSString stringWithFormat:@"%@",countString(user.point)];
|
||||
|
||||
CGFloat imageWidth = 20;
|
||||
CGFloat imageEdge = 5;
|
||||
CGFloat labelEdge = 5;
|
||||
CGSize scoreLabelSize = [scoreStr sizeWithFont:self.scoreButton.titleLabel.font];
|
||||
CGRect scoreButtonFrame = self.scoreButton.frame;
|
||||
scoreButtonFrame.size.width = imageWidth + scoreLabelSize.width + imageEdge + labelEdge;
|
||||
[self.scoreButton setImageEdgeInsets:UIEdgeInsetsMake(imageEdge, imageEdge, imageEdge, scoreButtonFrame.size.width -imageEdge -imageWidth)];
|
||||
[self.scoreButton setTitle:scoreStr forState:UIControlStateNormal];
|
||||
self.scoreButton.frame = scoreButtonFrame;
|
||||
self.user = user;
|
||||
[self.avatarImageView setImageURL:self.user.icon_url.small_url_string
|
||||
placeHolderImage:UMComImageWithImageName(@"male")];
|
||||
if (self.user.medal_list.count > 0) {
|
||||
UMComMedal *medal = self.user.medal_list.firstObject;
|
||||
[self.medal_icon setImageURL:medal.icon_url placeHolderImage:nil];
|
||||
}
|
||||
if ([self.user.uid isEqualToString:[UMComSession sharedInstance].uid]|| [self.user.atype intValue] == 3) {
|
||||
_focuseButton.hidden = YES;
|
||||
}else{
|
||||
_focuseButton.hidden = NO;
|
||||
if (self.user.relation && [self.user.relation isKindOfClass:[NSNumber class]]) {
|
||||
if ([self.user.relation integerValue] == 3) {
|
||||
[self.focuseButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_interfocuse") forState:UIControlStateNormal];
|
||||
}else if ([self.user.relation integerValue] == 1){
|
||||
[self.focuseButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_hasfocused") forState:UIControlStateNormal];
|
||||
}else{
|
||||
[self.focuseButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_focuse") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (self.user.has_followed && self.user.has_followed.integerValue == 1) {
|
||||
[self.focuseButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_hasfocused") forState:UIControlStateNormal];
|
||||
}
|
||||
else{
|
||||
[self.focuseButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_focuse") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
self.nameLabel.text = self.user.name;
|
||||
CGSize textSize = CGSizeMake(self.nameLabel.frame.size.width, self.nameLabel.frame.size.height);
|
||||
if (self.user.name && self.user.name.length > 0) {
|
||||
textSize = [self.user.name sizeWithFont:self.nameLabel.font constrainedToSize:CGSizeMake(self.frame.size.width, MAXFLOAT) lineBreakMode:NSLineBreakByWordWrapping];
|
||||
self.nameLabel.frame = CGRectMake(0, self.nameLabel.frame.origin.y, textSize.width, self.nameLabel.frame.size.height);
|
||||
self.nameLabel.center = CGPointMake(self.frame.size.width/2, self.nameLabel.center.y);
|
||||
self.genderView.hidden = NO;
|
||||
}
|
||||
self.genderView.center = CGPointMake(self.genderView.frame.size.width + textSize.width+self.nameLabel.frame.origin.x, self.nameLabel.center.y);
|
||||
if ([self.user.gender integerValue] == 0) {
|
||||
self.genderView.image = UMComImageWithImageName(@"um_forum_user_ladygender");
|
||||
}else{
|
||||
self.genderView.image = UMComImageWithImageName(@"um_forum_user_mangender");
|
||||
}
|
||||
[self.menuView reloadData];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UMComHorizonCollectionViewDelegate
|
||||
- (void)horizonCollectionView:(UMComHorizonCollectionView *)collectionView
|
||||
reloadCell:(UMComHorizonCollectionCell *)cell
|
||||
atIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UILabel *countLabel = self.countLabelList[indexPath.row];
|
||||
CGRect countLabelFrame = countLabel.frame;
|
||||
countLabelFrame.origin.x = cell.label.frame.origin.x;
|
||||
countLabelFrame.origin.y = 2;
|
||||
countLabel.frame = countLabelFrame;
|
||||
if (countLabel.superview != cell.contentView) {
|
||||
[cell.contentView addSubview:countLabel];
|
||||
}
|
||||
|
||||
CGRect titleLabelFrame = cell.label.frame;
|
||||
titleLabelFrame.origin.y = countLabel.frame.origin.y + countLabel.frame.size.height;
|
||||
titleLabelFrame.size.height = cell.frame.size.height - titleLabelFrame.origin.y-4;
|
||||
cell.label.frame = titleLabelFrame;
|
||||
if (indexPath.row == 0) {
|
||||
countLabel.text = [NSString stringWithFormat:@"%@",countString(self.user.feed_count)];
|
||||
cell.label.text = [NSString stringWithFormat:@"%@",UMComLocalizedString(@"um_com_message", @"消息")];
|
||||
// cell.label.text = [NSString stringWithFormat:@"%@\n%@",self.user.feed_count,UMComLocalizedString(@"um_com_message", @"消息")];
|
||||
}else if (indexPath.row == 1){
|
||||
countLabel.text = [NSString stringWithFormat:@"%@",countString(self.user.following_count)];
|
||||
cell.label.text = [NSString stringWithFormat:@"%@",UMComLocalizedString(@"um_com_following", @"关注")];
|
||||
// cell.label.text = [NSString stringWithFormat:@"%@\n%@",self.user.following_count,UMComLocalizedString(@"User_Followers", @"关注")];
|
||||
}else if (indexPath.row == 2){
|
||||
countLabel.text = [NSString stringWithFormat:@"%@",countString(self.user.fans_count)];
|
||||
cell.label.text = [NSString stringWithFormat:@"%@",UMComLocalizedString(@"um_com_fans", @"粉丝")];
|
||||
}
|
||||
if (indexPath.row == collectionView.currentIndex) {
|
||||
cell.label.textColor = UMComColorWithHexString(UMCom_Forum_UserCenter_MenuTitleHighLightColor);
|
||||
}else{
|
||||
cell.label.textColor = UMComColorWithHexString(UMCom_Forum_UserCenter_MenuTitleColor);
|
||||
}
|
||||
countLabel.textColor = cell.label.textColor;
|
||||
cell.label.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_UserCenter_MenuTitleFont);
|
||||
cell.label.backgroundColor = [UIColor whiteColor];
|
||||
cell.label.textAlignment = NSTextAlignmentCenter;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)createLabelList
|
||||
{
|
||||
NSMutableArray *array = [NSMutableArray arrayWithCapacity:3];
|
||||
CGFloat labelWidth = self.frame.size.width/3;
|
||||
CGFloat labelHeight = 20;
|
||||
for (int index =0; index < 3; index++) {
|
||||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, labelWidth, labelHeight)];
|
||||
label.backgroundColor = [UIColor whiteColor];
|
||||
label.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_UserCenter_MenuCountFont);
|
||||
label.textColor = UMComColorWithHexString(UMCom_Forum_UserCenter_MenuTitleColor);
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
[array addObject:label];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
- (void)horizonCollectionView:(UMComHorizonCollectionView *)collectionView didSelectedColumn:(NSInteger)column
|
||||
{
|
||||
self.lastIndex = collectionView.lastIndex;
|
||||
if (self.deleagte && [self.deleagte respondsToSelector:@selector(userProfileDetailView:clickAtIndex:)]) {
|
||||
[self.deleagte userProfileDetailView:self clickAtIndex:column];
|
||||
}
|
||||
[collectionView reloadData];
|
||||
}
|
||||
/*
|
||||
-(void) doRelayoutMedalView
|
||||
{
|
||||
|
||||
//如果有勋章图片的话,就要修改self.nameLabel下面控件的所有布局
|
||||
CGFloat medalWidth = [UMComMedalImageView defaultWidth];
|
||||
CGFloat medalHeight = self.nameLabel.bounds.size.height;
|
||||
|
||||
CGSize cellSize = self.bounds.size;
|
||||
|
||||
CGFloat medalTopMargin = 0;
|
||||
CGFloat medalBottomMargin = 0;
|
||||
|
||||
//计算勋章宽高
|
||||
if (self.medalView.image) {
|
||||
|
||||
//根据图片宽高比例确定宽度
|
||||
CGSize imgSize = self.medalView.image.size;
|
||||
medalWidth = medalHeight * imgSize.width / imgSize.height;
|
||||
if (medalWidth >= cellSize.width) {
|
||||
//宽度大于cell的宽度,就取nameLabel的宽度
|
||||
medalWidth = self.nameLabel.bounds.size.width;
|
||||
}
|
||||
}
|
||||
else{}
|
||||
|
||||
//计算勋章坐标位置,使其中心个头像中心一直
|
||||
CGFloat orginx = (self.bounds.size.width - medalWidth)/2;
|
||||
CGFloat orginy = self.nameLabel.frame.origin.y + self.nameLabel.frame.size.height + medalTopMargin;
|
||||
self.medalView.frame = CGRectMake(orginx, orginy, medalWidth, medalHeight);
|
||||
|
||||
//布局勋章下面的控件
|
||||
CGFloat medalViewOffset = self.medalView.frame.origin.y + self.medalView.frame.size.height + medalBottomMargin;
|
||||
CGRect albumButtonFrame = self.albumButton.frame;
|
||||
albumButtonFrame.origin.y = medalViewOffset;
|
||||
self.albumButton.frame = albumButtonFrame;
|
||||
|
||||
CGRect topicButtonFrame = self.topicButton.frame;
|
||||
topicButtonFrame.origin.y = medalViewOffset;
|
||||
self.topicButton.frame = topicButtonFrame;
|
||||
|
||||
CGRect scoreButtonFrame = self.scoreButton.frame;
|
||||
scoreButtonFrame.origin.y = medalViewOffset;
|
||||
self.scoreButton.frame = scoreButtonFrame;
|
||||
|
||||
}
|
||||
|
||||
-(void) relayoutMedalView
|
||||
{
|
||||
if (self.user.medal_list.count > 0) {
|
||||
UMComMedal *medal = self.user.medal_list.firstObject;
|
||||
NSString* icon_url = medal.icon_url;
|
||||
if(icon_url)
|
||||
{
|
||||
self.medalView.imageLoaderDelegate = self;
|
||||
self.medalView.isAutoStart = YES;
|
||||
[self.medalView setImageURL:[NSURL URLWithString:icon_url] placeholderImage:nil];
|
||||
|
||||
[self doRelayoutMedalView];
|
||||
}
|
||||
else
|
||||
{
|
||||
self.medalView.hidden = YES;
|
||||
self.medalView.delegate = nil;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
self.medalView.hidden = YES;
|
||||
self.medalView.delegate = nil;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#pragma mark - UMComImageViewDelegate
|
||||
- (void)umcomImageViewLoadedImage:(UMComImageView *)imageView;
|
||||
{
|
||||
//单勋章布局
|
||||
//[self doRelayoutMedalView];
|
||||
|
||||
//多勋章布局
|
||||
[self layoutMedalViews];
|
||||
}
|
||||
|
||||
-(void) createMedalViews
|
||||
{
|
||||
//创建默认的medalViewArray队列
|
||||
self.medalViewArray = [NSMutableArray arrayWithCapacity:[UMComMedalImageView maxMedalCount]];
|
||||
|
||||
//创建勋章
|
||||
for(NSInteger i = 0; i < [UMComMedalImageView maxMedalCount]; i++)
|
||||
{
|
||||
UMComMedalImageView* medalView = [[UMComMedalImageView alloc] initWithFrame:CGRectMake(0, 0, [UMComMedalImageView defaultWidth], [UMComMedalImageView defaultHeight])];
|
||||
medalView.tag = i;
|
||||
medalView.contentMode = UIViewContentModeScaleAspectFit;
|
||||
[self.medalViewArray addObject:medalView];
|
||||
[self addSubview:medalView];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-(void) requestIMGForMedalViews:(UMComUser*)user
|
||||
{
|
||||
if (user.medal_list.count > 0) {
|
||||
//确认当前勋章不能超过[UMComMedalImageView maxMedalCount]
|
||||
self.curMedalCount = user.medal_list.count;
|
||||
if (self.curMedalCount > [UMComMedalImageView maxMedalCount]) {
|
||||
self.curMedalCount = [UMComMedalImageView maxMedalCount];
|
||||
}
|
||||
|
||||
for(int i = 0;i < self.curMedalCount; i++)
|
||||
{
|
||||
UMComMedalImageView* medalView = self.medalViewArray[i];
|
||||
if (medalView) {
|
||||
medalView.hidden = NO;
|
||||
UMComMedal* umcomMedal = (UMComMedal*)user.medal_list[i];
|
||||
if (umcomMedal && umcomMedal.icon_url) {
|
||||
medalView.imageLoaderDelegate = nil;
|
||||
medalView.isAutoStart = YES;
|
||||
[medalView setImageURL:[NSURL URLWithString:umcomMedal.icon_url] placeholderImage:nil];
|
||||
medalView.imageLoaderDelegate = self;
|
||||
}
|
||||
else{
|
||||
medalView.hidden = YES;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[self layoutMedalViews];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) clearRequestForMedalViews
|
||||
{
|
||||
for(int i = 0;i < self.medalViewArray.count; i++)
|
||||
{
|
||||
UMComMedalImageView* medalView = self.medalViewArray[i];
|
||||
if (medalView) {
|
||||
medalView.hidden = YES;
|
||||
medalView.imageLoaderDelegate = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-(CGSize)computeMedalViewSize:(UMComMedalImageView*)medalView
|
||||
{
|
||||
if (!medalView) {
|
||||
return CGSizeMake(0, 0);
|
||||
}
|
||||
|
||||
//先确定勋章图片的宽度和高度;
|
||||
CGFloat medalWidth = [UMComMedalImageView defaultWidth];
|
||||
CGFloat medalHeight = [UMComMedalImageView defaultHeight];
|
||||
|
||||
CGSize cellSize = self.bounds.size;
|
||||
|
||||
if (medalView.image) {
|
||||
|
||||
CGSize tempSize = medalView.image.size;
|
||||
|
||||
if (tempSize.height <= medalHeight) {
|
||||
medalHeight = tempSize.height;
|
||||
}
|
||||
else{
|
||||
//目前只是简单的判断图片的高度是否超过self.nameLabel.frame的高度
|
||||
if (tempSize.height < self.nameLabel.frame.size.height) {
|
||||
medalHeight = tempSize.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
medalHeight = self.nameLabel.frame.size.height;
|
||||
}
|
||||
}
|
||||
|
||||
if (tempSize.width <= medalWidth) {
|
||||
medalWidth = tempSize.width;
|
||||
}
|
||||
else{
|
||||
//根据图片的宽高比,算勋章的宽度
|
||||
medalWidth = medalHeight * tempSize.width / tempSize.height;
|
||||
if (medalWidth >= cellSize.width) {
|
||||
//如果宽度大于cell的宽度就设置为默认值(此处只是简单判断)
|
||||
medalWidth = [UMComMedalImageView defaultWidth];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
medalView.bounds = CGRectMake(0, 0, medalWidth, medalHeight);
|
||||
return medalView.bounds.size;
|
||||
}
|
||||
|
||||
-(void) layoutMedalViews
|
||||
{
|
||||
CGFloat medalTopMargin = 0;
|
||||
CGFloat medalBottomMargin = 0;
|
||||
|
||||
//先确定勋章图片的宽度和高度
|
||||
CGFloat totalMedalWidth = 0;
|
||||
CGFloat maxMedalHeight = 0;
|
||||
for (int i = 0; i < self.curMedalCount; i++) {
|
||||
|
||||
//先计算图片的宽高
|
||||
UMComMedalImageView* medalView = self.medalViewArray[i];
|
||||
if (medalView) {
|
||||
CGSize medalViewSize = [self computeMedalViewSize:medalView];
|
||||
if (i == self.curMedalCount -1) {
|
||||
totalMedalWidth += medalViewSize.width;
|
||||
}
|
||||
else{
|
||||
totalMedalWidth += medalViewSize.width + [UMComMedalImageView spaceBetweenMedalViews];
|
||||
}
|
||||
|
||||
if (maxMedalHeight < medalViewSize.height) {
|
||||
maxMedalHeight = medalViewSize.height;
|
||||
}
|
||||
|
||||
//判断当前的请求的图片是否获得,如果还没有获得把高度设置为0,等于不显示
|
||||
if (!medalView.image) {
|
||||
maxMedalHeight = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//计算勋章坐标位置,使其对称显示
|
||||
CGFloat orginx = (self.bounds.size.width - totalMedalWidth)/2;
|
||||
CGFloat orginy = self.nameLabel.frame.origin.y + self.nameLabel.frame.size.height + medalTopMargin;
|
||||
CGFloat orginXOffset = orginx;
|
||||
for (int i = 0; i < self.curMedalCount; i++) {
|
||||
UMComMedalImageView* medalView = self.medalViewArray[i];
|
||||
if (medalView) {
|
||||
CGRect medalViewFrame = medalView.frame;
|
||||
medalViewFrame.origin.x = orginXOffset;
|
||||
medalViewFrame.origin.y = orginy;
|
||||
medalView.frame = medalViewFrame;
|
||||
orginXOffset += medalViewFrame.size.width + [UMComMedalImageView spaceBetweenMedalViews];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//布局勋章下面的控件
|
||||
CGFloat medalViewOffset = self.nameLabel.frame.origin.y + self.nameLabel.frame.size.height + maxMedalHeight + medalBottomMargin;
|
||||
CGRect albumButtonFrame = self.albumButton.frame;
|
||||
albumButtonFrame.origin.y = medalViewOffset;
|
||||
self.albumButton.frame = albumButtonFrame;
|
||||
|
||||
CGRect topicButtonFrame = self.topicButton.frame;
|
||||
topicButtonFrame.origin.y = medalViewOffset;
|
||||
self.topicButton.frame = topicButtonFrame;
|
||||
|
||||
CGRect scoreButtonFrame = self.scoreButton.frame;
|
||||
scoreButtonFrame.origin.y = medalViewOffset;
|
||||
self.scoreButton.frame = scoreButtonFrame;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// UMComUserTableViewCell.h
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by wyq.Cloudayc on 3/22/16.
|
||||
// Copyright © 2016 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class UMComImageView, UMComUser;
|
||||
|
||||
@protocol UMComClickActionDelegate;
|
||||
|
||||
@interface UMComUserTableViewCell : UITableViewCell
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UMComImageView *avatarImageView;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *distanceLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *locationIcon;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *messageCountLabel;
|
||||
@property (weak, nonatomic) IBOutlet UILabel *followersCountLabel;
|
||||
@property (weak, nonatomic) IBOutlet UIImageView *genderImageView;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet UIButton *followButton;
|
||||
|
||||
@property (nonatomic, assign) id <UMComClickActionDelegate> delegate;
|
||||
|
||||
@property (nonatomic, assign) BOOL showDistance;
|
||||
|
||||
- (IBAction)onTouchFollowButton:(id)sender;
|
||||
- (void)reloadCellWithUser:(UMComUser *)user;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// UMComUserTableViewCell.m
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by wyq.Cloudayc on 3/22/16.
|
||||
// Copyright © 2016 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UMComUserTableViewCell.h"
|
||||
#import <UMComDataStorage/UMComUser.h>
|
||||
#import "UMComImageView.h"
|
||||
#import "UMComResouceDefines.h"
|
||||
#import <UMComDataStorage/UMComImageUrl.h>
|
||||
#import <UMCommunitySDK/UMComSession.h>
|
||||
#import "UMComClickActionDelegate.h"
|
||||
|
||||
|
||||
@interface UMComUserTableViewCell()
|
||||
|
||||
@property (nonnull, nonatomic, strong) UMComUser *user;
|
||||
|
||||
@end
|
||||
|
||||
@implementation UMComUserTableViewCell
|
||||
|
||||
- (void)awakeFromNib {
|
||||
_avatarImageView.layer.cornerRadius = _avatarImageView.frame.size.width / 2.f;
|
||||
_avatarImageView.clipsToBounds = YES;
|
||||
[_locationIcon setImage:UMComImageWithImageName(@"um_forum_location.png")];
|
||||
|
||||
_showDistance = NO;
|
||||
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
}
|
||||
|
||||
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||||
[super setSelected:selected animated:animated];
|
||||
|
||||
// Configure the view for the selected state
|
||||
}
|
||||
|
||||
- (IBAction)onTouchFollowButton:(id)sender
|
||||
{
|
||||
if (_delegate && [_delegate respondsToSelector:@selector(customObj:clickOnFollowUser:)]) {
|
||||
[_delegate customObj:self clickOnFollowUser:self.user];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reloadCellWithUser:(UMComUser *)user
|
||||
{
|
||||
self.user = user;
|
||||
|
||||
if (_showDistance) {
|
||||
_distanceLabel.text = distanceString(user.distance);
|
||||
} else {
|
||||
[_distanceLabel removeFromSuperview];
|
||||
[_locationIcon removeFromSuperview];
|
||||
}
|
||||
|
||||
[_avatarImageView setImageURL:_user.icon_url.small_url_string placeHolderImage:UMComImageWithImageName(@"um_forum_user_smile_gray")];
|
||||
self.userNameLabel.text = user.name;
|
||||
self.messageCountLabel.text = [NSString stringWithFormat:UMComLocalizedString(@"feedsSent", @"发表动态:%@"),countString(_user.feed_count)];
|
||||
self.followersCountLabel.text = [NSString stringWithFormat:UMComLocalizedString(@"followerCount", @"粉丝数:%@"),countString(_user.fans_count)];
|
||||
if ([_user.uid isEqualToString:[UMComSession sharedInstance].uid] || [_user.atype integerValue] == 3) {
|
||||
self.followButton.hidden = YES;
|
||||
}else{
|
||||
self.followButton.hidden = NO;
|
||||
if ([_user.relation integerValue] == 3) {
|
||||
[_followButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_interfocuse") forState:UIControlStateNormal];
|
||||
}else if ([user.relation integerValue] == 1){
|
||||
[_followButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_hasfocused") forState:UIControlStateNormal];
|
||||
}else{
|
||||
[_followButton setBackgroundImage:UMComImageWithImageName(@"um_forum_user_focuse") forState:UIControlStateNormal];
|
||||
}
|
||||
}
|
||||
|
||||
if ([self.user.gender intValue] == 0) {
|
||||
self.genderImageView.image = UMComImageWithImageName(@"♀.png");
|
||||
|
||||
} else {
|
||||
self.genderImageView.image = UMComImageWithImageName(@"♂.png");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9532" systemVersion="14F1605" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
|
||||
<capability name="Alignment constraints with different attributes" minToolsVersion="5.1"/>
|
||||
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="101" id="KGk-i7-Jjw" customClass="UMComUserTableViewCell">
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="101"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="100"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="KQw-mg-Qak" userLabel="avatar" customClass="UMComImageView">
|
||||
<rect key="frame" x="10" y="11" width="39" height="38"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="39" id="CQt-PM-Hy6"/>
|
||||
<constraint firstAttribute="height" constant="38" id="Tdo-fg-1NT"/>
|
||||
</constraints>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
|
||||
<integer key="value" value="30"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
</imageView>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Xsl-Yu-bJY">
|
||||
<rect key="frame" x="356" y="14" width="85" height="29"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="29" id="1po-1S-X9v"/>
|
||||
<constraint firstAttribute="width" constant="85" id="38q-CU-qNr"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<action selector="onTouchFollowButton:" destination="KGk-i7-Jjw" eventType="touchUpInside" id="o17-Qg-jas"/>
|
||||
</connections>
|
||||
</button>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dMJ-Gq-4tJ" userLabel="content">
|
||||
<rect key="frame" x="57" y="3" width="248" height="54"/>
|
||||
<subviews>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sDN-Qd-qK6">
|
||||
<rect key="frame" x="0.0" y="5" width="36" height="17"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="lessThanOrEqual" constant="150" id="0ek-de-cwg"/>
|
||||
</constraints>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<color key="textColor" red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="distance" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9T0-Mc-I9b">
|
||||
<rect key="frame" x="10" y="39" width="34" height="10"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="8"/>
|
||||
<color key="textColor" red="0.64705882349999999" green="0.64705882349999999" blue="0.64705882349999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="message" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lfD-fM-xgr">
|
||||
<rect key="frame" x="0.0" y="25" width="43" height="12"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="10"/>
|
||||
<color key="textColor" red="0.64705882349999999" green="0.64705882349999999" blue="0.64705882349999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="followers" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Cxa-jf-H5h">
|
||||
<rect key="frame" x="50" y="25" width="44" height="12"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="10"/>
|
||||
<color key="textColor" red="0.64705882349999999" green="0.64705882349999999" blue="0.64705882349999999" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="qVD-Xg-AMY" userLabel="gender">
|
||||
<rect key="frame" x="39" y="5" width="10" height="10"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="10" id="51H-Rz-MIi"/>
|
||||
<constraint firstAttribute="width" constant="10" id="oqQ-tO-C1f"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="G3o-7W-7nv" userLabel="locationIcon">
|
||||
<rect key="frame" x="0.0" y="40" width="7" height="8"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" constant="7" id="bf4-vw-k5L"/>
|
||||
<constraint firstAttribute="height" constant="8" id="pYO-Fc-BYm"/>
|
||||
</constraints>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="9T0-Mc-I9b" secondAttribute="bottom" constant="5" id="4j7-uk-ks8"/>
|
||||
<constraint firstAttribute="bottom" secondItem="lfD-fM-xgr" secondAttribute="bottom" priority="250" constant="5" id="77E-mi-LzN"/>
|
||||
<constraint firstItem="9T0-Mc-I9b" firstAttribute="centerY" secondItem="G3o-7W-7nv" secondAttribute="centerY" id="8kQ-vv-SUN"/>
|
||||
<constraint firstItem="lfD-fM-xgr" firstAttribute="top" secondItem="sDN-Qd-qK6" secondAttribute="bottom" priority="250" constant="3" id="Bwc-7S-A1H"/>
|
||||
<constraint firstItem="qVD-Xg-AMY" firstAttribute="centerY" secondItem="sDN-Qd-qK6" secondAttribute="top" constant="5" id="DVb-8l-Fxt"/>
|
||||
<constraint firstItem="sDN-Qd-qK6" firstAttribute="top" secondItem="dMJ-Gq-4tJ" secondAttribute="top" constant="5" id="F1t-Td-ZPa"/>
|
||||
<constraint firstItem="9T0-Mc-I9b" firstAttribute="leading" secondItem="sDN-Qd-qK6" secondAttribute="leading" id="QHw-9d-YKG"/>
|
||||
<constraint firstItem="Cxa-jf-H5h" firstAttribute="leading" secondItem="lfD-fM-xgr" secondAttribute="trailing" constant="7" id="Sb7-Ii-JNe"/>
|
||||
<constraint firstItem="9T0-Mc-I9b" firstAttribute="top" secondItem="G3o-7W-7nv" secondAttribute="top" id="Sha-o8-ezs"/>
|
||||
<constraint firstItem="sDN-Qd-qK6" firstAttribute="leading" secondItem="dMJ-Gq-4tJ" secondAttribute="leading" id="ddE-i5-eCk"/>
|
||||
<constraint firstItem="G3o-7W-7nv" firstAttribute="leading" secondItem="sDN-Qd-qK6" secondAttribute="leading" id="dh1-oF-RKy"/>
|
||||
<constraint firstItem="lfD-fM-xgr" firstAttribute="leading" secondItem="sDN-Qd-qK6" secondAttribute="leading" id="g7Y-8B-01E"/>
|
||||
<constraint firstItem="Cxa-jf-H5h" firstAttribute="top" secondItem="lfD-fM-xgr" secondAttribute="top" id="hye-e9-qE0"/>
|
||||
<constraint firstItem="9T0-Mc-I9b" firstAttribute="leading" secondItem="G3o-7W-7nv" secondAttribute="trailing" constant="3" id="koZ-SG-Sfv"/>
|
||||
<constraint firstItem="9T0-Mc-I9b" firstAttribute="top" secondItem="lfD-fM-xgr" secondAttribute="bottom" constant="3" id="mkH-ik-fQK"/>
|
||||
<constraint firstItem="G3o-7W-7nv" firstAttribute="top" secondItem="lfD-fM-xgr" secondAttribute="bottom" constant="3" id="s6G-OM-JAX"/>
|
||||
<constraint firstItem="qVD-Xg-AMY" firstAttribute="leading" secondItem="sDN-Qd-qK6" secondAttribute="trailing" constant="3" id="saz-3T-ehK"/>
|
||||
</constraints>
|
||||
<variation key="default">
|
||||
<mask key="constraints">
|
||||
<exclude reference="QHw-9d-YKG"/>
|
||||
<exclude reference="Sha-o8-ezs"/>
|
||||
<exclude reference="mkH-ik-fQK"/>
|
||||
</mask>
|
||||
</variation>
|
||||
</view>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fnd-97-Iit" userLabel="bottomeLine">
|
||||
<rect key="frame" x="10" y="60" width="440" height="1"/>
|
||||
<color key="backgroundColor" red="0.93333333333333335" green="0.93725490196078431" blue="0.95294117647058818" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="1" id="HFB-U3-Ph2"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="fnd-97-Iit" secondAttribute="trailing" id="3Mz-AX-O28"/>
|
||||
<constraint firstItem="KQw-mg-Qak" firstAttribute="centerY" secondItem="dMJ-Gq-4tJ" secondAttribute="centerY" id="3NX-Kk-rrm"/>
|
||||
<constraint firstItem="Xsl-Yu-bJY" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="17" id="6Md-sw-gZb"/>
|
||||
<constraint firstItem="dMJ-Gq-4tJ" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="3" id="MMx-Gp-wxk"/>
|
||||
<constraint firstItem="KQw-mg-Qak" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="topMargin" constant="13" id="O3G-bS-SIG"/>
|
||||
<constraint firstItem="Xsl-Yu-bJY" firstAttribute="centerY" secondItem="dMJ-Gq-4tJ" secondAttribute="centerY" constant="-1" id="dP6-gW-QBm"/>
|
||||
<constraint firstItem="dMJ-Gq-4tJ" firstAttribute="leading" secondItem="KQw-mg-Qak" secondAttribute="trailing" constant="8" id="eSa-Tw-dfg"/>
|
||||
<constraint firstItem="fnd-97-Iit" firstAttribute="leading" secondItem="KQw-mg-Qak" secondAttribute="leading" id="ed1-Dl-Hxl"/>
|
||||
<constraint firstItem="fnd-97-Iit" firstAttribute="top" secondItem="KQw-mg-Qak" secondAttribute="bottom" constant="5" id="jGd-fC-J4W"/>
|
||||
<constraint firstItem="fnd-97-Iit" firstAttribute="top" secondItem="dMJ-Gq-4tJ" secondAttribute="bottom" constant="3" id="jZ8-79-JvM"/>
|
||||
<constraint firstItem="Xsl-Yu-bJY" firstAttribute="trailing" secondItem="H2p-sc-9uM" secondAttribute="trailing" constant="-9" id="tgy-b0-pKp"/>
|
||||
<constraint firstItem="KQw-mg-Qak" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" constant="10" id="w3h-2E-hcZ"/>
|
||||
<constraint firstItem="Xsl-Yu-bJY" firstAttribute="leading" secondItem="dMJ-Gq-4tJ" secondAttribute="trailing" constant="51" id="wgv-gT-5ao"/>
|
||||
</constraints>
|
||||
<variation key="default">
|
||||
<mask key="constraints">
|
||||
<exclude reference="O3G-bS-SIG"/>
|
||||
<exclude reference="jGd-fC-J4W"/>
|
||||
<exclude reference="6Md-sw-gZb"/>
|
||||
</mask>
|
||||
</variation>
|
||||
</tableViewCellContentView>
|
||||
<connections>
|
||||
<outlet property="avatarImageView" destination="KQw-mg-Qak" id="aM0-wY-Q3E"/>
|
||||
<outlet property="distanceLabel" destination="9T0-Mc-I9b" id="Q18-td-016"/>
|
||||
<outlet property="followButton" destination="Xsl-Yu-bJY" id="Jow-j8-m6O"/>
|
||||
<outlet property="followersCountLabel" destination="Cxa-jf-H5h" id="Uht-vo-eDA"/>
|
||||
<outlet property="genderImageView" destination="qVD-Xg-AMY" id="noq-jT-iHn"/>
|
||||
<outlet property="locationIcon" destination="G3o-7W-7nv" id="zej-JC-frd"/>
|
||||
<outlet property="messageCountLabel" destination="lfD-fM-xgr" id="DUS-bv-qzY"/>
|
||||
<outlet property="userNameLabel" destination="sDN-Qd-qK6" id="ONR-YR-8iK"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="-423" y="459.5"/>
|
||||
</tableViewCell>
|
||||
</objects>
|
||||
</document>
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// UMComUserTableViewController.h
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by wyq.Cloudayc on 3/22/16.
|
||||
// Copyright © 2016 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UMComRequestTableViewController.h"
|
||||
|
||||
@class UMComUser, UMComUserTableViewController;
|
||||
|
||||
@protocol UMComUserOperationFinishDelegate;
|
||||
|
||||
typedef NS_ENUM(NSUInteger, UMComUserTableViewCallBackEvent) {
|
||||
UMComUserTableViewCallBackEventUser = 0
|
||||
};
|
||||
typedef void(^UMComUserTableViewCallBackBlock)(UMComUserTableViewController *controller, UMComUserTableViewCallBackEvent event, UMComUser *user);
|
||||
|
||||
@interface UMComUserTableViewController : UMComRequestTableViewController
|
||||
|
||||
@property (nonatomic, strong) NSArray *userList;
|
||||
|
||||
@property (nonatomic, assign) BOOL showDistance;
|
||||
|
||||
@property (nonatomic, assign) id<UMComUserOperationFinishDelegate> userOperationFinishDelegate;
|
||||
|
||||
//但第一次登录时会进入推荐用户页面, 推荐用户页面点击完成操作时会调用这个block
|
||||
@property (nonatomic, copy) void (^completion)(UIViewController *viewController);
|
||||
|
||||
@property (nonatomic, copy) UMComUserTableViewCallBackBlock callbackBlock;
|
||||
|
||||
- (id)initWithCompletion:(void (^)(UIViewController *viewController))completion;
|
||||
|
||||
- (void)insertUserToTableView:(UMComUser *)user;
|
||||
|
||||
- (void)deleteUserFromTableView:(UMComUser *)user;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
//
|
||||
// UMComUserTableViewController.m
|
||||
// UMCommunity
|
||||
//
|
||||
// Created by wyq.Cloudayc on 3/22/16.
|
||||
// Copyright © 2016 Umeng. All rights reserved.
|
||||
//
|
||||
|
||||
#import "UMComUserTableViewController.h"
|
||||
#import <UMComDataStorage/UMComUser.h>
|
||||
#import "UMComClickActionDelegate.h"
|
||||
#import "UMComLoginManager.h"
|
||||
#import "UMComShowToast.h"
|
||||
#import "UMComBarButtonItem.h"
|
||||
#import "UIViewController+UMComAddition.h"
|
||||
#import "UMComUserOperationFinishDelegate.h"
|
||||
|
||||
#import "UMComUserTableViewCell.h"
|
||||
|
||||
#import "UMComUserListDataController.h"
|
||||
|
||||
#define UMComUserCellHeightWithDistance 61
|
||||
#define UMComUserCellHeight 49
|
||||
|
||||
static NSString *UMComUserTableViewCellIdentifier = @"UMComUserTableViewCellIdentifier";
|
||||
|
||||
@interface UMComUserTableViewController ()
|
||||
<UMComClickActionDelegate, UITableViewDataSource, UITableViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation UMComUserTableViewController
|
||||
|
||||
- (id)initWithCompletion:(void (^)(UIViewController *viewController))completion
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.completion = completion;
|
||||
UMComBarButtonItem *rightButtonItem = [[UMComBarButtonItem alloc] initWithTitle:UMComLocalizedString(@"FinishStep",@"完成") target:self action:@selector(onClickNext)];
|
||||
[self.navigationItem setRightBarButtonItem:rightButtonItem];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)onClickNext
|
||||
{
|
||||
if (self.completion) {
|
||||
self.completion(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
self.isAutoStartLoadData = YES;
|
||||
self.tableView.rowHeight = _showDistance ? 67 : 54;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
if (self.userList.count > 0) {
|
||||
[self.dataController.dataArray addObjectsFromArray:self.userList];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
if (self.title) {
|
||||
[self setForumUITitle:self.title];
|
||||
}else{
|
||||
[self setForumUITitle:UMComLocalizedString(@"userList", @"用户列表")];
|
||||
}
|
||||
|
||||
[self.tableView registerNib:[UINib nibWithNibName:@"UMComUserTableViewCell" bundle:nil] forCellReuseIdentifier:UMComUserTableViewCellIdentifier];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
|
||||
[super viewWillAppear:animated];
|
||||
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return self.dataController.dataArray.count;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (_showDistance) {
|
||||
return UMComUserCellHeightWithDistance;
|
||||
}
|
||||
else {
|
||||
return UMComUserCellHeight;
|
||||
}
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UMComUserTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:UMComUserTableViewCellIdentifier];
|
||||
cell.delegate = self;
|
||||
if (indexPath.row < self.dataController.dataArray.count) {
|
||||
UMComUser *user = self.dataController.dataArray[indexPath.row];
|
||||
cell.showDistance = _showDistance;
|
||||
[cell reloadCellWithUser:user];
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
UMComUser *user = self.dataController.dataArray[indexPath.row];
|
||||
if (_callbackBlock) {
|
||||
_callbackBlock(self, UMComUserTableViewCallBackEventUser, user);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)customObj:(id)obj clickOnFollowUser:(UMComUser *)user
|
||||
{
|
||||
__weak typeof(self) weakSelf = self;
|
||||
[UMComLoginManager performLogin:self completion:^(id responseObject, NSError *error) {
|
||||
if (!error) {
|
||||
BOOL isFollow = !([user.relation integerValue] == 1 || [user.relation integerValue] == 3);
|
||||
|
||||
[(UMComUserListDataController *)weakSelf.dataController followOrDisFollowUser:user completion:^(id responseObject, NSError *error) {
|
||||
[UMComShowToast focuseUserSuccess:error focused:isFollow];
|
||||
[weakSelf.tableView reloadData];
|
||||
if (weakSelf.userOperationFinishDelegate && [self.userOperationFinishDelegate respondsToSelector:@selector(focusedUserOperationFinish:)]) {
|
||||
[weakSelf.userOperationFinishDelegate focusedUserOperationFinish:user];
|
||||
}
|
||||
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)insertUserToTableView:(UMComUser *)user
|
||||
{
|
||||
if (![user isKindOfClass:[UMComUser class]]) {
|
||||
return;
|
||||
}
|
||||
if (![self.dataController.dataArray containsObject:user]) {
|
||||
[self.dataController.dataArray insertObject:user atIndex:0];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
- (void)deleteUserFromTableView:(UMComUser *)deleteUser
|
||||
{
|
||||
if (!deleteUser) {
|
||||
return;
|
||||
}
|
||||
__weak typeof(self) weakSelf = self;
|
||||
if ([deleteUser isKindOfClass:[UMComUser class]]) {
|
||||
[self.dataController.dataArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
UMComUser *user = (UMComUser *)obj;
|
||||
if ([user.uid isEqualToString:deleteUser.uid]) {
|
||||
*stop = YES;
|
||||
[weakSelf.dataController.dataArray removeObject:user];
|
||||
[weakSelf.tableView reloadData];
|
||||
}
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
// Dispose of any resources that can be recreated.
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user