| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- //
- // MOGetGiftView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/6/4.
- //
- #import "MOGetGiftView.h"
- #import "MOSignInGiftCell.h"
- #import "MOWebViewController.h"
- @interface MOGetGiftView ()<UICollectionViewDelegate,UICollectionViewDataSource>
- @property (weak, nonatomic) IBOutlet UIView *bgView;
- @property (weak, nonatomic) IBOutlet UILabel *titleLab;
- @property (weak, nonatomic) IBOutlet UILabel *dayNumLab;
- @property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *collectionViewWidth;
- @property (weak, nonatomic) IBOutlet UIButton *signInBtn;
- /** 数据源 */
- @property (nonatomic, strong) NSMutableArray *dataArr;
- @end
- @implementation MOGetGiftView
- + (instancetype)moGetGiftView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MOGetGiftView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- [self.signInBtn setBackgroundColor:kBaseBtnBgColor];
- self.signInBtn.layer.cornerRadius = 36.0 / 2.0;
- self.signInBtn.layer.masksToBounds = YES;
-
- UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
- flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
- CGFloat width = 66.0;
- CGFloat height = 74.0;
-
- flow.itemSize = CGSizeMake(width, height);
- flow.minimumLineSpacing = 5.0;//行间距
- flow.minimumInteritemSpacing = 0.0;//列间距
- [self.collectionView setCollectionViewLayout:flow];
- self.collectionView.delegate = self;
- self.collectionView.dataSource = self;
- self.collectionView.backgroundColor = [UIColor clearColor];
- [self.collectionView registerNib:[UINib nibWithNibName:@"MOSignInGiftCell" bundle:nil] forCellWithReuseIdentifier:MOSignInGiftCell_ID];
-
- self.dayNumLab.text = NSLocalString(@"mimo_sign_in_get_more_reward_tip");
- [self.signInBtn setTitle:NSLocalString(@"mimo_sign_in_more_task_btn") forState:UIControlStateNormal];
-
- [self.signInBtn setFont:[MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalContentFontStr]];
- self.dayNumLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalContentFontStr];
- self.titleLab.font = [MOTextTools getTheFontWithSize:24.0 AndFontName:kNormalContentFontStr];
- }
- - (IBAction)closeBtnClick:(id)sender {
- [self dismissGetGiftView];
- }
- - (IBAction)moreTaskBtnClick:(id)sender {
-
- [self dismissGetGiftView];
-
- UIViewController *currentVC = [MOTools currentViewController];
-
- MOWebViewController *vc = [[MOWebViewController alloc] init];
- NSString *urlStr = [NSString stringWithFormat:@"%@/#/taskCenter?tagName=dailyTasks",kNetPath_Web_Base];
- vc.webUrl = [NSURL URLWithString:urlStr];
- vc.hidesBottomBarWhenPushed = YES;
-
- [currentVC.navigationController pushViewController:vc animated:YES];
- }
- - (void)setViewModel:(TaskPublishEvent *)viewModel{
- _viewModel = viewModel;
-
- self.titleLab.text = viewModel.n;
-
- self.dataArr = [viewModel.l copy];
-
- CGFloat theMaxWidth = 296.0 - 25.0 * 2.0;
- CGFloat theNeedWidth = self.dataArr.count * (66.0 + 5.0);
- if(theNeedWidth > theMaxWidth){
- theNeedWidth = theMaxWidth;
- }
-
- self.collectionViewWidth.constant = theNeedWidth;
-
- [self.collectionView reloadData];
- }
- #pragma mark UICollectionViewDelegate,UICollectionViewDataSource
- - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
- {
- return 1;
- }
- - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- {
- return self.dataArr.count;
- }
- -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
- TaskPublishPrize *model = self.dataArr[indexPath.row];
- MOSignInGiftCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:MOSignInGiftCell_ID forIndexPath:indexPath];
- cell.pubModel = model;
- return cell;
- }
- - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
- [collectionView deselectItemAtIndexPath:indexPath animated:YES];
- }
- - (NSMutableArray *)dataArr{
- if(!_dataArr){
- _dataArr = [NSMutableArray array];
- }
- return _dataArr;
- }
- - (void)showGetGiftView//界面显示动画
- {
-
- UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window;
- [keyWindow addSubview:self];
- self.frame = CGRectMake(0.0, 0.0, SCREENWIDTH, SCREENHEIGHT);
-
- //动画效果
- self.bgView.transform = CGAffineTransformMakeScale(1.3, 1.3);
- self.bgView.alpha = 0;
- [UIView animateWithDuration:0.2 animations:^
- {
- self.bgView.transform = CGAffineTransformMakeScale(1.0, 1.0);
- self.bgView.alpha = 1;
- } completion:^(BOOL finished)
- {
- }];
- }
- - (void)dismissGetGiftView
- {
- [UIView animateWithDuration:0.2 animations:^
- {
- self.bgView.transform = CGAffineTransformMakeScale(1.3, 1.3);
- self.bgView.alpha = 0;
- } completion:^(BOOL finished)
- {
- if (finished)
- {
- [self removeFromSuperview];
- }
- }];
- }
- @end
|