96 lines
3.7 KiB
Objective-C
96 lines
3.7 KiB
Objective-C
//
|
|
// RoomUserMicroView.m
|
|
// DingDangApp
|
|
//
|
|
// Created by apple on 2023/5/27.
|
|
//
|
|
|
|
#import "RoomUserMicroView.h"
|
|
#import "RoomUserMicroCell.h"
|
|
#import "RoomMicroModel.h"
|
|
@interface RoomUserMicroView ()<UICollectionViewDelegate,UICollectionViewDataSource>
|
|
@property (nonatomic,strong) NSMutableArray *dataSource;
|
|
|
|
@end
|
|
@implementation RoomUserMicroView
|
|
|
|
- (void)initView{
|
|
[self collectionView];
|
|
}
|
|
- (void)showMicRoEmojiMessageToUser:(NSString *)userID url:(NSString *)url{
|
|
for (RoomMicroModel *obj in self.dataSource) {
|
|
if ([obj.user_id isEqualToString:userID]) {
|
|
NSInteger index = [self.dataSource indexOfObject:obj];
|
|
NSLog(@"第 %li个 显示表情",(long)index);
|
|
RoomUserMicroCell * cell = (RoomUserMicroCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0]];
|
|
[cell.microView starAnimateEmojiImage:url];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
/**刷新麦////息*/
|
|
-(void)reloadMicroData:(NSMutableArray *)dataArray{
|
|
self.dataSource = [NSMutableArray arrayWithArray:dataArray];
|
|
[self.collectionView reloadData];
|
|
}
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
return 8;
|
|
// return self.dataSource.count;
|
|
}
|
|
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
RoomUserMicroCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"RoomUserMicroCell" forIndexPath:indexPath];
|
|
// RoomMicroModel *model = self.dataSource[indexPath.row];
|
|
// cell.microView.microModel = model;
|
|
WeakSelf(ws);
|
|
// cell.backHeaderTapBlock = ^{
|
|
// if(ws.backHeaderTapBlock){
|
|
// ws.backHeaderTapBlock(model);
|
|
// }
|
|
// };
|
|
// cell.backIncomeTapBlock = ^{
|
|
// if(ws.backIncomeTapBlock){
|
|
// ws.backIncomeTapBlock(model);
|
|
// }
|
|
// };
|
|
return cell;
|
|
}
|
|
- (void)starAnimationToIndex:(NSInteger)index{
|
|
RoomUserMicroCell * cell = (RoomUserMicroCell*)[self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:index inSection:0]];
|
|
[cell.microView.headeImageView starMicroAnimation];
|
|
}
|
|
- (WLBaseCollectionView *)collectionView{
|
|
if (!_collectionView) {
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
layout.itemSize = CGSizeMake(kWidth/4, 107);
|
|
layout.sectionInset = UIEdgeInsetsMake(0, 0,0, 0);
|
|
layout.minimumLineSpacing = 5;
|
|
layout.minimumInteritemSpacing = 0;
|
|
layout.headerReferenceSize = CGSizeZero;
|
|
_collectionView = [[WLBaseCollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
|
[_collectionView registerClass:[RoomUserMicroCell class] forCellWithReuseIdentifier:@"RoomUserMicroCell"];
|
|
_collectionView.delegate = self;
|
|
_collectionView.dataSource = self;
|
|
_collectionView.backgroundColor = Kclear_color;
|
|
if ([_collectionView respondsToSelector:@selector(setLayoutMargins:)]){
|
|
[_collectionView setLayoutMargins:UIEdgeInsetsZero];
|
|
}
|
|
_collectionView.translatesAutoresizingMaskIntoConstraints = NO;
|
|
if (@available(iOS 11.0, *)) {
|
|
[_collectionView adjustedContentInsetDidChange];
|
|
_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
}
|
|
[self addSubview:_collectionView];
|
|
[_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self).with.insets(UIEdgeInsetsMake(0, 0, 0, 0));
|
|
}];
|
|
}
|
|
return _collectionView;
|
|
}
|
|
- (NSMutableArray*)dataSource{
|
|
if (!_dataSource) {
|
|
_dataSource = [[NSMutableArray alloc] init];
|
|
}
|
|
return _dataSource;
|
|
}
|
|
@end
|