个人中心-访客记录角标
This commit is contained in:
@@ -20,9 +20,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@property (nonatomic, copy) NSString *centerName;
|
@property (nonatomic, copy) NSString *centerName;
|
||||||
@property (nonatomic, copy) NSString *centerUrl;
|
@property (nonatomic, copy) NSString *centerUrl;
|
||||||
|
|
||||||
///未读消息
|
|
||||||
@property (nonatomic, assign) NSInteger unReadCount;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -15,6 +15,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@property (nonatomic,copy) NSString *number;
|
@property (nonatomic,copy) NSString *number;
|
||||||
///显示标题
|
///显示标题
|
||||||
@property (nonatomic,copy) NSString *title;
|
@property (nonatomic,copy) NSString *title;
|
||||||
|
///是否为访客记录
|
||||||
|
@property (nonatomic, assign) BOOL isVisitor;
|
||||||
|
///访客角标
|
||||||
|
@property (nonatomic, assign) NSInteger visitorNum;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@@ -10,12 +10,16 @@
|
|||||||
#import <Masonry/Masonry.h>
|
#import <Masonry/Masonry.h>
|
||||||
///Tool
|
///Tool
|
||||||
#import "ThemeColor.h"
|
#import "ThemeColor.h"
|
||||||
|
#import <YYText/YYText.h>
|
||||||
|
|
||||||
@interface XPMineFriendNumberView ()
|
@interface XPMineFriendNumberView ()
|
||||||
///显示个数
|
///显示个数
|
||||||
@property (nonatomic,strong) UILabel *numberLabel;
|
@property (nonatomic,strong) UILabel *numberLabel;
|
||||||
///显示标题
|
///显示标题
|
||||||
@property (nonatomic,strong) UILabel *titleLabel;
|
@property (nonatomic,strong) UILabel *titleLabel;
|
||||||
|
//访客记录未读数量
|
||||||
|
@property (nonatomic, strong) UILabel *unReadLabel;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation XPMineFriendNumberView
|
@implementation XPMineFriendNumberView
|
||||||
@@ -41,7 +45,8 @@
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
[self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.left.right.top.mas_equalTo(self);
|
make.top.mas_equalTo(self);
|
||||||
|
make.centerX.mas_equalTo(self);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
@@ -50,6 +55,23 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSAttributedString *)attributedStringWithLineSpace:(CGFloat)lineSpace str:(NSString *)str{
|
||||||
|
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
|
||||||
|
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:str attributes:@{NSForegroundColorAttributeName : UIColorFromRGB(0xffffff), NSFontAttributeName: [UIFont systemFontOfSize:11]}];
|
||||||
|
[attributedString appendAttributedString:title];
|
||||||
|
attributedString.yy_alignment = NSTextAlignmentCenter;
|
||||||
|
return attributedString;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (CGFloat)getWidthWithContent:(NSString *)content height:(CGFloat)height font:(CGFloat)font{
|
||||||
|
|
||||||
|
CGRect rect = [content boundingRectWithSize:CGSizeMake(999, height)
|
||||||
|
options:NSStringDrawingUsesLineFragmentOrigin
|
||||||
|
attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]}
|
||||||
|
context:nil];
|
||||||
|
return rect.size.width;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - Getters And Setters
|
#pragma mark - Getters And Setters
|
||||||
- (void)setTitle:(NSString *)title {
|
- (void)setTitle:(NSString *)title {
|
||||||
self.titleLabel.text = title;
|
self.titleLabel.text = title;
|
||||||
@@ -59,6 +81,37 @@
|
|||||||
self.numberLabel.text = number;
|
self.numberLabel.text = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setIsVisitor:(BOOL)isVisitor {
|
||||||
|
if (isVisitor) {
|
||||||
|
[self addSubview:self.unReadLabel];
|
||||||
|
[self.unReadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.left.mas_equalTo(self.numberLabel.mas_right).mas_offset(5);
|
||||||
|
make.height.mas_equalTo(15);
|
||||||
|
make.width.mas_equalTo(15);
|
||||||
|
make.top.mas_equalTo(self.numberLabel);
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setVisitorNum:(NSInteger)visitorNum {
|
||||||
|
if (visitorNum > 0) {
|
||||||
|
self.unReadLabel.hidden = NO;
|
||||||
|
self.unReadLabel.attributedText = [self attributedStringWithLineSpace:10 str:[NSString stringWithFormat:@"%zd", visitorNum]];
|
||||||
|
CGFloat width = [self getWidthWithContent:[NSString stringWithFormat:@"%zd", visitorNum] height:15 font:11];
|
||||||
|
if (visitorNum < 10) {
|
||||||
|
width = 7;
|
||||||
|
}
|
||||||
|
[self.unReadLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.left.mas_equalTo(self.numberLabel.mas_right).mas_offset(5);
|
||||||
|
make.width.mas_equalTo(width + 8);
|
||||||
|
make.top.mas_equalTo(self.numberLabel);
|
||||||
|
make.height.mas_equalTo(15);
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
self.unReadLabel.hidden = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (UILabel *)numberLabel {
|
- (UILabel *)numberLabel {
|
||||||
if (!_numberLabel) {
|
if (!_numberLabel) {
|
||||||
_numberLabel = [[UILabel alloc] init];
|
_numberLabel = [[UILabel alloc] init];
|
||||||
@@ -79,4 +132,19 @@
|
|||||||
return _titleLabel;
|
return _titleLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (UILabel *)unReadLabel {
|
||||||
|
if (!_unReadLabel) {
|
||||||
|
_unReadLabel = [[UILabel alloc] init];
|
||||||
|
_unReadLabel.font = [UIFont systemFontOfSize:11];
|
||||||
|
_unReadLabel.textColor = [UIColor whiteColor];
|
||||||
|
_unReadLabel.backgroundColor = UIColorFromRGB(0xFF5B55);
|
||||||
|
_unReadLabel.layer.cornerRadius = 7.5;
|
||||||
|
_unReadLabel.layer.masksToBounds = YES;
|
||||||
|
_unReadLabel.textAlignment = NSTextAlignmentCenter;
|
||||||
|
[_unReadLabel sizeToFit];
|
||||||
|
_unReadLabel.hidden = YES;
|
||||||
|
}
|
||||||
|
return _unReadLabel ;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -34,6 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
@property (nonatomic, strong) WalletInfoModel *walletInfo;
|
@property (nonatomic, strong) WalletInfoModel *walletInfo;
|
||||||
///代理
|
///代理
|
||||||
@property (nonatomic,assign) id<XPMineHeadViewDelegate> delegate;
|
@property (nonatomic,assign) id<XPMineHeadViewDelegate> delegate;
|
||||||
|
///访客未读数量
|
||||||
|
@property (nonatomic, assign) NSInteger visitorUnReadCount;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -437,6 +437,10 @@
|
|||||||
self.accountView.diamonds = walletInfo.diamonds;
|
self.accountView.diamonds = walletInfo.diamonds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setVisitorUnReadCount:(NSInteger)visitorUnReadCount {
|
||||||
|
self.visitorView.visitorNum = visitorUnReadCount;
|
||||||
|
}
|
||||||
|
|
||||||
- (NetImageView *)avatarImageView {
|
- (NetImageView *)avatarImageView {
|
||||||
if (!_avatarImageView) {
|
if (!_avatarImageView) {
|
||||||
NetImageConfig * config = [[NetImageConfig alloc]init];
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
||||||
@@ -573,6 +577,7 @@
|
|||||||
if (!_visitorView) {
|
if (!_visitorView) {
|
||||||
_visitorView = [[XPMineFriendNumberView alloc] init];
|
_visitorView = [[XPMineFriendNumberView alloc] init];
|
||||||
_visitorView.title = @"访客";
|
_visitorView.title = @"访客";
|
||||||
|
_visitorView.isVisitor = YES;
|
||||||
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapVisitorRecognizer)];
|
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapVisitorRecognizer)];
|
||||||
[_visitorView addGestureRecognizer:tap];
|
[_visitorView addGestureRecognizer:tap];
|
||||||
}
|
}
|
||||||
|
@@ -244,12 +244,7 @@
|
|||||||
break;
|
break;
|
||||||
case XPMineItemType_Visitor:
|
case XPMineItemType_Visitor:
|
||||||
{
|
{
|
||||||
[self.tabBarItem setBadgeValue:nil];
|
self.headView.visitorUnReadCount = 0;
|
||||||
for (XPMineFuntionItemModel * model in self.functionArray) {
|
|
||||||
if (model.skipType == XPMineItemType_Visitor) {
|
|
||||||
model.unReadCount = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XPMineVisitorViewController *visitorVC = [[XPMineVisitorViewController alloc] init];
|
XPMineVisitorViewController *visitorVC = [[XPMineVisitorViewController alloc] init];
|
||||||
[self.navigationController pushViewController:visitorVC animated:YES];
|
[self.navigationController pushViewController:visitorVC animated:YES];
|
||||||
}
|
}
|
||||||
@@ -517,19 +512,7 @@
|
|||||||
#pragma mark - NSNotification
|
#pragma mark - NSNotification
|
||||||
- (void)onVisitorUnReadCountUpdate:(NSNotification *)noti {
|
- (void)onVisitorUnReadCountUpdate:(NSNotification *)noti {
|
||||||
XPMineVisitorUnReadModel *model = (XPMineVisitorUnReadModel *)noti.object;
|
XPMineVisitorUnReadModel *model = (XPMineVisitorUnReadModel *)noti.object;
|
||||||
if (model.visitNum > 0) {
|
self.headView.visitorUnReadCount = model.visitNum;
|
||||||
[self.tabBarItem setBadgeValue:[NSString stringWithFormat:@"%ld", model.visitNum]];
|
|
||||||
} else {
|
|
||||||
[self.tabBarItem setBadgeValue:nil];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i<self.functionArray.count; i++) {
|
|
||||||
XPMineFuntionItemModel * item = [self.functionArray objectAtIndex:i];
|
|
||||||
if (item.skipType == XPMineItemType_Visitor) {
|
|
||||||
item.unReadCount = model.visitNum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[self.tableView reloadData];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Getters And Setters
|
#pragma mark - Getters And Setters
|
||||||
|
Reference in New Issue
Block a user