// // JXMsgCellView.m // shiku_im // // Created by 123 on 2020/6/11. // Copyright © 2020 Reese. All rights reserved. // #import "JXMsgCellView.h" @interface JXMsgCellView() @property (weak, nonatomic) IBOutlet UIView *friendView; @property (weak, nonatomic) IBOutlet UIView *groundChatView; @property (weak, nonatomic) IBOutlet UIView *addresView; @property (weak, nonatomic) IBOutlet UIView *jixinView; @property (weak, nonatomic) IBOutlet UILabel *gufangL; @property (nonatomic,strong) NSMutableArray *dataArr; @property (weak, nonatomic) IBOutlet UIImageView *iconFriendIMG; @property (weak, nonatomic) IBOutlet UIImageView *grounpIMG; @end @implementation JXMsgCellView +(instancetype)XIBMsgCellView{ return [[NSBundle mainBundle]loadNibNamed:@"JXMsgCellView" owner:self options:nil].firstObject; } -(void)awakeFromNib{ [super awakeFromNib]; _dataArr=[NSMutableArray array]; _grounpIMG.layer.cornerRadius=3; _grounpIMG.layer.masksToBounds=YES; _iconFriendIMG.layer.cornerRadius=5; _iconFriendIMG.layer.masksToBounds=YES; [g_notify addObserver:self selector:@selector(newFriend:) name:@"newFriend" object:nil]; self.tipLabel.layer.cornerRadius=10; self.tipLabel.layer.masksToBounds=YES; self.gufangL.layer.cornerRadius=5; self.gufangL.layer.masksToBounds=YES; [_friendView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(friendGrounAddresJiXinView:)]]; [_groundChatView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(friendGrounAddresJiXinView:)]]; [_addresView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(friendGrounAddresJiXinView:)]]; [_jixinView addGestureRecognizer:[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(friendGrounAddresJiXinView:)]]; // _dataArr =[[JXFriendObject sharedInstance] fetchAllFriendsFromLocal]; NSMutableArray *tempArr=[NSMutableArray array]; [_dataArr enumerateObjectsUsingBlock:^(JXFriendObject * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj.type intValue]==500) { [tempArr addObject:obj]; } }]; if (tempArr.count>0) { NSString *titleStr = [[NSUserDefaults standardUserDefaults] objectForKey:@"tipLabelStr"]; if (titleStr.length>0) { self.tipLabel.hidden=YES; }else{ self.tipLabel.hidden=NO; } self.tipLabel.text=[NSString stringWithFormat:@"%zd",tempArr.count]; }else{ self.tipLabel.hidden=YES; } } - (void)newFriend:(NSNotification *)note{ [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"tipLabelStr"]; _dataArr =[[JXFriendObject sharedInstance] fetchAllFriendsFromLocal]; NSMutableArray *tempArr=[NSMutableArray array]; [_dataArr enumerateObjectsUsingBlock:^(JXFriendObject * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if ([obj.type intValue]==500) { [tempArr addObject:obj]; } }]; if (tempArr.count>0) { NSString *titleStr = [[NSUserDefaults standardUserDefaults] objectForKey:@"tipLabelStr"]; if (titleStr.length>0) { self.tipLabel.hidden=YES; }else{ self.tipLabel.hidden=NO; } self.tipLabel.text=[NSString stringWithFormat:@"%zd",tempArr.count]; }else{ self.tipLabel.hidden=YES; } } -(void)setHiddenTipl:(NSString *)hiddenTipl{ NSString *titleStr = [[NSUserDefaults standardUserDefaults] objectForKey:@"tipLabelStr"]; if (titleStr.length>0) { self.tipLabel.hidden=YES; }else{ self.tipLabel.hidden=NO; } } - (void)friendGrounAddresJiXinView:(UIGestureRecognizer *)tapView{ if (_blockTap) { _blockTap(tapView.view.tag); } } @end