123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // YOUPAILZChatRoomEmojiAnimationWindow.m
- // VQU
- //
- // Created by CY on 2021/11/1.
- // Copyright © 2021 MS. All rights reserved.
- //
- #import "YOUPAILZChatRoomEmojiAnimationWindow.h"
- #import "YOUPAILZChatRoomEmojiCell.h"
- #import "YOUPAIWZHorizontalPageFlowlayout.h"
- @interface YOUPAILZChatRoomEmojiAnimationWindow ()<UICollectionViewDelegate,UICollectionViewDataSource>
- @property (nonatomic,strong)NSArray <YOUPAILZChatRoomEmojiModel *>*youpaipdataSource;
- @property (nonatomic,strong)UICollectionView *youpaipcollectionView;
- @property (nonatomic,strong)UIPageControl *youpaippageView;
- @end
- @implementation YOUPAILZChatRoomEmojiAnimationWindow
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.baseView.hidden = YES;
- [self youpaifinitUI];
- [self youpaifrequestEmojiList];
- }
- - (void)youpaifinitUI{
- UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 243.0f + SafeHeight)];
- bgV.backgroundColor = HexColorFromRGB(0x2A2935);
- [LCTools clipCorner:UIRectCornerTopLeft|UIRectCornerTopRight View:bgV size:CGSizeMake(20.0f, 20.0f)];
- [self.view addSubview:bgV];
- [bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.bottom.offset(0.0f);
- make.height.offset(243.0f + SafeHeight);
- }];
-
- UIView *footerV = [[UIView alloc] init];
- [bgV addSubview:footerV];
- [footerV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.offset(0.0f);
- make.bottom.offset(-SafeHeight);
- make.height.offset(47.0f);
- }];
-
- UIButton *chatEmojiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [chatEmojiBtn setTitle:@"聊天表情" forState:UIControlStateNormal];
- [chatEmojiBtn setTitleColor:HexColorFromRGB(0x9F9DA5) forState:UIControlStateNormal];
- chatEmojiBtn.titleLabel.font = LCFont(12.0f);
- [chatEmojiBtn addTarget:self action:@selector(youpaifchatEmojiBtnClick) forControlEvents:UIControlEventTouchUpInside];
- [footerV addSubview:chatEmojiBtn];
- [chatEmojiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.offset(0.0f);
- make.centerY.equalTo(footerV.mas_centerY);
- make.size.mas_offset(CGSizeMake(84.0f, 33.0f));
- }];
-
- UIButton *animationEmojiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- animationEmojiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- [animationEmojiBtn setTitle:@"互动表情" forState:UIControlStateNormal];
- [animationEmojiBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
- animationEmojiBtn.titleLabel.font = LCFont(12.0f);
- animationEmojiBtn.userInteractionEnabled = NO;
- [footerV addSubview:animationEmojiBtn];
- [animationEmojiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(chatEmojiBtn.mas_right).offset(0.0f);
- make.centerY.equalTo(footerV.mas_centerY);
- make.size.mas_offset(CGSizeMake(84.0f, 33.0f));
- }];
-
- YOUPAIWZHorizontalPageFlowlayout *layout = [[YOUPAIWZHorizontalPageFlowlayout alloc] initWithRowCount:2 itemCountPerRow:4];
- layout.youpaiprowSpacing = 13.0f;
- layout.itemSize = CGSizeMake(77.0f, 77.0f);
- layout.youpaipedgeInsets = UIEdgeInsetsMake(14.0f, 0.0f, 14.0f, 0.0f);
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- self.youpaipcollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, KScreenWidth, 243.0f-47.0f) collectionViewLayout:layout];
- self.youpaipcollectionView.backgroundColor = [UIColor clearColor];
- self.youpaipcollectionView.bounces = YES;
- self.youpaipcollectionView.pagingEnabled = YES;
- self.youpaipcollectionView.dataSource = self;
- self.youpaipcollectionView.delegate = self;
- self.youpaipcollectionView.showsHorizontalScrollIndicator=NO;
- self.youpaipcollectionView.showsVerticalScrollIndicator=NO;
- [self.youpaipcollectionView registerClass:[YOUPAILZChatRoomEmojiCell class] forCellWithReuseIdentifier:@"YOUPAILZChatRoomEmojiCell"];
- [bgV addSubview:self.youpaipcollectionView];
-
- UIPageControl *youpaippageView = [[UIPageControl alloc]initWithFrame:CGRectMake(0, self.youpaipcollectionView.mj_h - 8.0f, KScreenWidth, 8.0f)];
- youpaippageView.currentPageIndicatorTintColor = [UIColor whiteColor];
- youpaippageView.pageIndicatorTintColor = [[UIColor whiteColor] colorWithAlphaComponent:0.4f];;
- youpaippageView.userInteractionEnabled = NO;
- youpaippageView.hidesForSinglePage = YES;
- self.youpaippageView = youpaippageView;
- [bgV addSubview:youpaippageView];
- }
- - (void)youpaifchatEmojiBtnClick{
- [self dismissViewControllerAnimated:YES completion:^{
- if (self.youpaipyoupaifchatEmojiBtnClickBlock != nil) {
- self.youpaipyoupaifchatEmojiBtnClickBlock();
- }
- }];
-
- }
- #pragma mark - UICollectionViewDataSource
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
- return self.youpaipdataSource.count;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
- {
- YOUPAILZChatRoomEmojiCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"YOUPAILZChatRoomEmojiCell" forIndexPath:indexPath];
- [cell youpaifreloadWithModel:self.youpaipdataSource[indexPath.item]];
- return cell;
- }
- -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
- YOUPAILZChatRoomEmojiModel *model = self.youpaipdataSource[indexPath.item];
- @weakify(self);
- [LCHttpHelper requestWithURLString:SendEmoji parameters:@{@"room_id":self.youpaipchatroomModel.youpaiproom_id,@"expression_id":model.youpaipid} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- [self dismissViewControllerAnimated:YES completion:^{}];
- }
- } failure:^(NSError *error) {
- }];
- }
- -(void)scrollViewDidScroll:(UIScrollView *)scrollView{
- // 当前的索引
- NSInteger index = scrollView.contentOffset.x / self.youpaipcollectionView.mj_w;
- self.youpaippageView.currentPage = index;
- }
- - (void)youpaifrequestEmojiList{
- @weakify(self);
- [LCHttpHelper requestWithURLString:GetExpressionCate parameters:@{@"expression_type":@"sign"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
- @strongify(self);
- NSDictionary* dict = (NSDictionary*)responseObject;
- NSInteger code = [[dict objectForKey:@"code"] integerValue];
- if (code == 0) {//成功
- self.youpaipdataSource = [YOUPAILZChatRoomEmojiModel mj_objectArrayWithKeyValuesArray:[dict objectForKey:@"data"]];
- NSInteger totalRecord = self.youpaipdataSource.count;
- NSInteger maxResult = 8;
- NSInteger totalPage = (totalRecord + maxResult - 1) / maxResult;
- self.youpaippageView.numberOfPages = totalPage;
- self.youpaippageView.currentPage = 0;
- [self.youpaipcollectionView reloadData];
- }
- } failure:^(NSError *error) {
- }];
- }
- @end
|