|
|
@@ -12,8 +12,7 @@
|
|
|
|
|
|
@interface MOBagCollectionView ()
|
|
|
<UICollectionViewDelegate,
|
|
|
-UICollectionViewDataSource,
|
|
|
-MOGiftListViewModelDelegate>
|
|
|
+UICollectionViewDataSource>
|
|
|
|
|
|
@property (nonatomic, strong) UICollectionView *collectionView;
|
|
|
/** 没有更多的数据视图 */
|
|
|
@@ -32,7 +31,6 @@ MOGiftListViewModelDelegate>
|
|
|
if (self) {
|
|
|
[self setupUI];
|
|
|
self.listViewModel = listViewModel;
|
|
|
- [listViewModel addObserver:self];
|
|
|
}
|
|
|
|
|
|
return self;
|
|
|
@@ -49,7 +47,9 @@ MOGiftListViewModelDelegate>
|
|
|
}
|
|
|
|
|
|
#pragma mark - JXCategoryListContentViewDelegate
|
|
|
-- (void)listWillAppear{
|
|
|
+- (void)listDidAppear{
|
|
|
+ if (self.isHidden) return;
|
|
|
+
|
|
|
self.next = @"";
|
|
|
|
|
|
if(self.listViewModel.curRoomId.length == 0){
|
|
|
@@ -94,7 +94,7 @@ MOGiftListViewModelDelegate>
|
|
|
if(!giftModel.lock){
|
|
|
giftModel.isSelect = YES;
|
|
|
self.selectIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];//选中第一个
|
|
|
- self.selectCellBlock ? self.selectCellBlock(giftModel) : nil;
|
|
|
+ self.selectGiftBlock(giftModel, self.type);
|
|
|
}
|
|
|
else{
|
|
|
self.theFirstGiftBlock ? self.theFirstGiftBlock() : nil;
|
|
|
@@ -113,7 +113,7 @@ MOGiftListViewModelDelegate>
|
|
|
object.isSelect = YES;
|
|
|
|
|
|
self.selectIndexPath = [NSIndexPath indexPathForRow:theIndex inSection:0];//选中第一个
|
|
|
- self.selectCellBlock ? self.selectCellBlock(object) : nil;
|
|
|
+ self.selectGiftBlock(object, self.type);
|
|
|
[self.collectionView scrollToItemAtIndexPath:self.selectIndexPath atScrollPosition:UICollectionViewScrollPositionTop animated:NO];
|
|
|
[MOSvgaSourceManage shareManager].hitGiftModel = nil;
|
|
|
|
|
|
@@ -158,6 +158,17 @@ MOGiftListViewModelDelegate>
|
|
|
object.isBag = YES;
|
|
|
}
|
|
|
|
|
|
+ BOOL isHaveSelet = NO;
|
|
|
+ for (MOGiftlist *giftModel in weakSelf.dataArr) {
|
|
|
+ if(giftModel.isSelect){
|
|
|
+ isHaveSelet = YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!isHaveSelet){
|
|
|
+ [self toChangeTheFirstChooseWith:weakSelf.dataArr];
|
|
|
+ }
|
|
|
+
|
|
|
[weakSelf.collectionView reloadData];
|
|
|
|
|
|
weakSelf.noMoreDataView.isHaveData = (weakSelf.dataArr.count > 0) ? YES : NO;
|
|
|
@@ -240,31 +251,6 @@ MOGiftListViewModelDelegate>
|
|
|
return self;
|
|
|
}
|
|
|
|
|
|
-#pragma mark MOGiftListViewModelDelegate
|
|
|
-- (void)onGiftListChangedWithCategory:(NSInteger)category list:(NSArray<MOGiftlist *> *)list {
|
|
|
- BOOL isHaveSelet = NO;
|
|
|
- for (MOGiftlist *giftModel in list) {
|
|
|
- if(giftModel.isSelect){
|
|
|
- isHaveSelet = YES;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if(!isHaveSelet){
|
|
|
- [self toChangeTheFirstChooseWith:list];
|
|
|
- }
|
|
|
-
|
|
|
- [self.collectionView reloadData];
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- if (self.reloadCollectionViewBlock) {
|
|
|
- self.reloadCollectionViewBlock(self);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- self.noMoreDataView.isHaveData = list.count > 0 ? YES : NO;
|
|
|
-
|
|
|
- [self toSelectTheHitGift];//跳转Hit礼物
|
|
|
-}
|
|
|
-
|
|
|
#pragma mark UICollectionViewDelegate,UICollectionViewDataSource
|
|
|
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
|
|
|
{
|
|
|
@@ -309,7 +295,7 @@ MOGiftListViewModelDelegate>
|
|
|
self.giftNum = 1;
|
|
|
|
|
|
self.selectIndexPath = indexPath;
|
|
|
- self.selectCellBlock ? self.selectCellBlock(modle) : nil;
|
|
|
+ self.selectGiftBlock(modle, self.type);
|
|
|
|
|
|
[self.collectionView reloadData];
|
|
|
}
|