123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- //
- // JLMyFacePackgeViewController.m
- // shiku_im
- //
- // Created by JayLuo on 2019/12/11.
- // Copyright © 2019 Reese. All rights reserved.
- //
- #import "JLMyFacePackgeViewController.h"
- #import "JLMyFacePackgeCell.h"
- #import "JLMyFacePackgeHeader.h"
- #import "JLFacePackgeModel.h"
- #import "JLFacePackgeDetailViewController.h"
- #import "JLRecommendFacePackgeViewController.h"
- #import "JLSingleFaceViewController.h"
- #define cellID @"JLMyFacePackgeCell"
- @interface JLMyFacePackgeViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>
- @property (nonatomic, strong) UICollectionView *collectionView;
- @property (nonatomic, strong) NSMutableArray *facePackages;
- @end
- @implementation JLMyFacePackgeViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.isGotoBack = YES;
- self.title = @"我的表情";
- self.heightFooter = 0;
- self.heightHeader = JX_SCREEN_TOP;
-
- [self createHeadAndFoot];
- _facePackages = [NSMutableArray array];
- //0 新品排行 1热门推荐
- // [g_server getFaceList:@"0" View:self];
- [g_server faceClollectListType:@"0" View:self];
- [self setupUI];
- }
- - (void)setupUI {
- [self collectionView];
- }
- - (void)didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
- if([aDownload.action isEqualToString:act_FaceClollectList]){
- _facePackages = [JLFacePackgeModel mj_objectArrayWithKeyValuesArray:array1];
- [self.collectionView reloadData];
- }
-
- if([aDownload.action isEqualToString:act_FaceClollectDeleteByFaceName]){
-
- // NSLog(@"-------%@-----%@", dict, array1);
- [SVProgressHUD setMinimumDismissTimeInterval:2.0];
- [SVProgressHUD showSuccessWithStatus:@"移除成功"];
- [g_notify postNotificationName:kEmojiRefresh object:nil];
- [g_server faceClollectListType:@"0" View:self];
- }
- }
- - (UICollectionView *)collectionView {
- if (_collectionView == nil) {
- UICollectionViewFlowLayout *layout = ({
-
- UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
-
- // 设置尺寸
- CGFloat width = self_width;
- layout.itemSize = CGSizeMake(width, 60);
-
- //估算的尺寸(一般不需要设置)
- // layout.estimatedItemSize = CGSizeMake(120, 130);
-
- //头部的参考尺寸(就是尺寸)
- // layout.headerReferenceSize = CGSizeMake(self_width, 50);
- //尾部的参考尺寸
- layout.footerReferenceSize = CGSizeMake(100, 100);
- layout.sectionFootersPinToVisibleBounds = YES;
- layout.sectionHeadersPinToVisibleBounds = YES;
- layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- layout.scrollDirection = UICollectionViewScrollDirectionVertical;
- layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
- layout.minimumInteritemSpacing = 10;
- layout.minimumLineSpacing = 10;
-
- layout;
-
- });
-
- _collectionView = ({
- UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
-
- collectionView.bounds = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
-
- collectionView.backgroundColor = [UIColor colorWithRed:240/255.0 green:239/255.0 blue:244/255.0 alpha:1];
- collectionView.frame = CGRectMake(0, JX_SCREEN_TOP, self.view.bounds.size.width, self.view.bounds.size.height-JX_SCREEN_TOP);
-
- collectionView.dataSource = self;
-
- collectionView.delegate = self;
-
- [collectionView registerNib:[UINib nibWithNibName:@"JLMyFacePackgeCell" bundle:nil] forCellWithReuseIdentifier:cellID];
- [collectionView registerNib:[UINib nibWithNibName:@"JLMyFacePackgeHeader" bundle:nil] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"JLMyFacePackgeHeader"];
-
- //设置滚动条
- collectionView.showsHorizontalScrollIndicator = NO;
- collectionView.showsVerticalScrollIndicator = YES;
-
- //设置是否需要弹簧效果
- collectionView.bounces = NO;
-
- collectionView;
-
- });
-
- [self.view addSubview:_collectionView];
-
- }
- return _collectionView;
- }
- #pragma mark - UICollectionViewDataSource
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
- return _facePackages.count;
- }
- - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
- JLMyFacePackgeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellID forIndexPath:indexPath];
- cell.model = _facePackages[indexPath.row];
- cell.JLMyFacePackgeCellDeleteCallBack = ^(NSString * _Nonnull faceId) {
- // 删除表情
- [g_server faceClollectDeleteByFaceName:faceId View:self];
- };
- return cell;
- }
- - (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
- return UIEdgeInsetsMake(5, 10, 5, 10);
- }
- - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
-
- UICollectionReusableView *headerView = nil;
- if ([kind isEqualToString:UICollectionElementKindSectionHeader]){
- JLMyFacePackgeHeader *view = (JLMyFacePackgeHeader *) [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"JLMyFacePackgeHeader" forIndexPath:indexPath];
-
- view.JLMyFacePackgeHeaderCallBack = ^{
- JLSingleFaceViewController *vc = [[JLSingleFaceViewController alloc] init];
- [g_navigation pushViewController:vc animated:YES];
- };
- headerView = view;
- }
- return headerView;
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section{
-
- return CGSizeMake(self_width, 90);
- }
- - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout referenceSizeForFooterInSection:(NSInteger)section {
- return CGSizeZero;
- }
- //- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
- // JLFacePackgeModel *model = _facePackages[indexPath.row];
- // JLFacePackgeDetailViewController *vc = [[JLFacePackgeDetailViewController alloc] init];
- // vc.model = model;
- // [g_navigation pushViewController:vc animated:YES];
- //}
- @end
|