343 lines
13 KiB
Objective-C
343 lines
13 KiB
Objective-C
//
|
|
// YMMineCollectRoomListViewController.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/7/27.
|
|
//
|
|
|
|
#import "XPMineCollectRoomListViewController.h"
|
|
///Third
|
|
#import <Masonry/Masonry.h>
|
|
#import <MJRefresh/MJRefresh.h>
|
|
#import <JXCategoryView/JXCategoryListContainerView.h>
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
///Tool
|
|
#import "DJDKMIMOMColor.h"
|
|
#import "YUMIMacroUitls.h"
|
|
#import "UIImage+Utils.h"
|
|
#import "StatisticsServiceHelper.h"
|
|
///Model
|
|
#import "HomeCollectRoomModel.h"
|
|
///View
|
|
#import "XPHomeCollectRoomTableViewCell.h"
|
|
#import "XPMineVisitorEmptyTableViewCell.h"
|
|
///P
|
|
#import "XPMineCollectRoomListPresenter.h"
|
|
#import "XPMineCollectRoomListProtocol.h"
|
|
///VC
|
|
#import "XPRoomViewController.h"
|
|
#import "XPMineCollectPartyRoomViewController.h"
|
|
|
|
///记录最后选中的tab
|
|
static NSString *lastSelectTab = @"lastSelectTab";
|
|
|
|
@interface XPMineCollectRoomListViewController ()<XPMineCollectRoomListProtocol, JXCategoryViewDelegate,JXCategoryListContainerViewDelegate, XPMineCollectPartyRoomViewControllerDelegate>
|
|
|
|
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
|
|
///标题
|
|
@property (nonatomic,strong) NSArray<NSString *> *titles;
|
|
///滑块
|
|
@property (nonatomic,strong) JXCategoryTitleView *titleView;
|
|
|
|
@property (nonatomic,strong) XPMineCollectPartyRoomViewController *partyVC;
|
|
///个播房的
|
|
@property (nonatomic, strong) XPMineCollectPartyRoomViewController *anchorRoomListVC;
|
|
|
|
///更多数据
|
|
@property (nonatomic,assign) BOOL hasNoMoreData;
|
|
///底部编辑容器
|
|
@property (nonatomic, strong) UIView *bottomView;
|
|
///全选按钮
|
|
@property (nonatomic, strong) UIButton *allSelectBtn;
|
|
///删除按钮
|
|
@property (nonatomic, strong) UIButton *deleteBtn;
|
|
///管理
|
|
@property (nonatomic, strong) UIButton *managerBtn;
|
|
|
|
@end
|
|
|
|
@implementation XPMineCollectRoomListViewController
|
|
|
|
- (XPMineCollectRoomListPresenter *)createPresenter {
|
|
return [[XPMineCollectRoomListPresenter alloc] init];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
// [self addNavigationItemWithItems:@[self.managerBtn] isLeft:NO];
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventcollection_editbutton_show];
|
|
}
|
|
|
|
- (void)managerBtnAction:(UIButton *)sender {
|
|
sender.selected = !sender.isSelected;
|
|
if (sender.isSelected) {//开始编辑
|
|
self.partyVC.isEdit = YES;
|
|
self.anchorRoomListVC.isEdit = YES;
|
|
self.bottomView.hidden = NO;
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventcollection_editbutton_click];
|
|
} else {//完成编辑
|
|
self.bottomView.hidden = YES;
|
|
self.allSelectBtn.selected = NO;
|
|
self.partyVC.isEdit = NO;
|
|
self.anchorRoomListVC.isEdit = NO;
|
|
self.allSelectBtn.selected = NO;
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventcollection_editbutton_complete_click];
|
|
}
|
|
}
|
|
|
|
#pragma mark - JXCategoryListContainerViewDelegate
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
|
return self.titles.count;
|
|
}
|
|
|
|
// 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
|
if (index == 0) {
|
|
return self.partyVC;
|
|
}else if (index == 1) {
|
|
return self.anchorRoomListVC;
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
|
//记录最后选中的index
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
[defaults setObject:@(index) forKey:lastSelectTab];
|
|
[defaults synchronize];
|
|
|
|
self.managerBtn.selected = NO;
|
|
self.allSelectBtn.selected = NO;
|
|
self.bottomView.hidden = YES;
|
|
self.partyVC.isEdit = NO;
|
|
self.anchorRoomListVC.isEdit = NO;
|
|
}
|
|
|
|
#pragma mark - XPMineCollectRoomListProtocol
|
|
- (void)deleteCollectRoomSuccess {
|
|
[self showSuccessToast:YMLocalizedString(@"XPMineCollectRoomListViewController0")];
|
|
if (self.titleView.selectedIndex == 0) {
|
|
[self.partyVC headerRefresh];
|
|
} else {
|
|
[self.anchorRoomListVC headerRefresh];
|
|
}
|
|
self.allSelectBtn.selected = NO;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.title = YMLocalizedString(@"XPMineCollectRoomListViewController1");
|
|
[self.view addSubview:self.titleView];
|
|
[self.view addSubview:self.listContainerView];
|
|
[self.view addSubview:self.bottomView];
|
|
[self.bottomView addSubview:self.allSelectBtn];
|
|
[self.bottomView addSubview:self.deleteBtn];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self.view);
|
|
make.width.mas_equalTo(180);
|
|
make.top.mas_equalTo(0);
|
|
make.height.mas_equalTo(44);
|
|
}];
|
|
[self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.trailing.bottom.mas_equalTo(self.view);
|
|
make.top.mas_equalTo(self.titleView.mas_bottom);
|
|
}];
|
|
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.height.mas_equalTo(64+kSafeAreaBottomHeight);
|
|
make.leading.bottom.trailing.mas_equalTo(0);
|
|
}];
|
|
[self.allSelectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.height.mas_equalTo(22);
|
|
make.leading.mas_equalTo(15);
|
|
make.top.mas_equalTo(18);
|
|
}];
|
|
[self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.trailing.mas_equalTo(-15);
|
|
make.centerY.mas_equalTo(self.allSelectBtn);
|
|
make.size.mas_equalTo(CGSizeMake(72, 24));
|
|
}];
|
|
}
|
|
|
|
#pragma mark - action
|
|
- (void)allSelectBtnAction:(UIButton *)sender {
|
|
sender.selected = !sender.selected;
|
|
if (self.titleView.selectedIndex == 0) {
|
|
self.partyVC.isSelectAll = sender.selected;
|
|
} else {
|
|
self.anchorRoomListVC.isSelectAll = sender.selected;
|
|
}
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventcollection_selectall_click];
|
|
}
|
|
|
|
- (void)deleteBtnAction:(UIButton *)sender {
|
|
if (self.titleView.selectedIndex == 0) {
|
|
NSMutableArray *roomUidsArray = [NSMutableArray array];
|
|
for (HomeCollectRoomModel *model in self.partyVC.datasource) {
|
|
if (model.isSelected) {
|
|
[roomUidsArray addObject:model.roomUid];
|
|
}
|
|
}
|
|
if (roomUidsArray.count) {
|
|
NSString *roomUids = [roomUidsArray componentsJoinedByString:@","];
|
|
[self.presenter deletecollectRoomWithRoomUids:roomUids];
|
|
} else {
|
|
[self showErrorToast:YMLocalizedString(@"XPMineCollectRoomListViewController2")];
|
|
}
|
|
} else {
|
|
NSMutableArray *roomUidsArray = [NSMutableArray array];
|
|
for (HomeCollectRoomModel *model in self.anchorRoomListVC.datasource) {
|
|
if (model.isSelected) {
|
|
[roomUidsArray addObject:model.roomUid];
|
|
}
|
|
}
|
|
if (roomUidsArray.count) {
|
|
NSString *roomUids = [roomUidsArray componentsJoinedByString:@","];
|
|
[self.presenter deletecollectRoomWithRoomUids:roomUids];
|
|
} else {
|
|
[self showErrorToast:YMLocalizedString(@"XPMineCollectRoomListViewController3")];
|
|
}
|
|
}
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventcollection_delete_click];
|
|
}
|
|
|
|
#pragma mark XPMineCollectPartyRoomViewControllerDelegate
|
|
///全选
|
|
- (void)xPMineCollectPartyRoomViewControllerSelectAll:(BOOL)selectAll {
|
|
self.allSelectBtn.selected = selectAll;
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (UIView *)bottomView {
|
|
if (!_bottomView) {
|
|
_bottomView = [[UIView alloc] init];
|
|
_bottomView.backgroundColor = [UIColor whiteColor];
|
|
_bottomView.hidden = YES;
|
|
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth, 64+kSafeAreaBottomHeight) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(8, 8)];
|
|
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
|
|
maskLayer.frame = CGRectMake(0, 0, KScreenWidth, 64+kSafeAreaBottomHeight);
|
|
maskLayer.path = maskPath.CGPath;
|
|
_bottomView.layer.mask = maskLayer;
|
|
}
|
|
return _bottomView;
|
|
}
|
|
|
|
- (UIButton *)allSelectBtn {
|
|
if (!_allSelectBtn) {
|
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
button.titleLabel.font = [UIFont systemFontOfSize:16];
|
|
[button addTarget:self action:@selector(allSelectBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[button setTitle:YMLocalizedString(@"XPMineCollectRoomListViewController4") forState:UIControlStateNormal];
|
|
[button setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateNormal];
|
|
[button setImage:[UIImage imageNamed:@"collect_room_edit_normal"] forState:UIControlStateNormal];
|
|
[button setImage:[UIImage imageNamed:@"collect_room_edit_selected"] forState:UIControlStateSelected];
|
|
_allSelectBtn = button;
|
|
}
|
|
return _allSelectBtn;
|
|
}
|
|
|
|
- (UIButton *)managerBtn {
|
|
if (!_managerBtn) {
|
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
button.titleLabel.font = [UIFont systemFontOfSize:13];
|
|
[button addTarget:self action:@selector(managerBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[button setTitle:YMLocalizedString(@"XPMineCollectRoomListViewController5") forState:UIControlStateNormal];
|
|
[button setTitle:YMLocalizedString(@"XPMineCollectRoomListViewController6") forState:UIControlStateSelected];
|
|
[button setTitleColor:UIColorFromRGB(0x999999) forState:UIControlStateNormal];
|
|
_managerBtn = button;
|
|
}
|
|
return _managerBtn;
|
|
}
|
|
|
|
- (UIButton *)deleteBtn {
|
|
if (!_deleteBtn) {
|
|
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
button.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[button addTarget:self action:@selector(deleteBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
[button setTitle:YMLocalizedString(@"XPMineCollectRoomListViewController7") forState:UIControlStateNormal];
|
|
[button setTitleColor:UIColorFromRGB(0xFB486A) forState:UIControlStateNormal];
|
|
button.layer.cornerRadius = 12;
|
|
button.layer.masksToBounds = YES;
|
|
button.layer.borderWidth = 1;
|
|
button.layer.borderColor = UIColorFromRGB(0xFB486A).CGColor;
|
|
_deleteBtn = button;
|
|
}
|
|
return _deleteBtn;
|
|
}
|
|
|
|
#pragma mark - Getters And Setters
|
|
- (JXCategoryListContainerView *)listContainerView {
|
|
if (!_listContainerView) {
|
|
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
|
_listContainerView.scrollView.scrollEnabled = YES;
|
|
_listContainerView.scrollView.tag = 1000;
|
|
_listContainerView.listCellBackgroundColor = [UIColor clearColor];
|
|
}
|
|
return _listContainerView;
|
|
}
|
|
|
|
- (XPMineCollectPartyRoomViewController *)partyVC {
|
|
if (!_partyVC) {
|
|
_partyVC = [[XPMineCollectPartyRoomViewController alloc] init];
|
|
_partyVC.type = MineCollectRoomTypeParty;
|
|
_partyVC.delegate = self;
|
|
}
|
|
return _partyVC;
|
|
}
|
|
|
|
- (XPMineCollectPartyRoomViewController *)anchorRoomListVC {
|
|
if (!_anchorRoomListVC) {
|
|
_anchorRoomListVC = [[XPMineCollectPartyRoomViewController alloc] init];
|
|
_anchorRoomListVC.type = MineCollectRoomTypeAnchor;
|
|
_anchorRoomListVC.delegate = self;
|
|
}
|
|
return _anchorRoomListVC;
|
|
}
|
|
|
|
- (NSArray<NSString *> *)titles {
|
|
if (!_titles) {
|
|
_titles = @[YMLocalizedString(@"XPMineCollectRoomListViewController8")];
|
|
}
|
|
return _titles;
|
|
}
|
|
|
|
- (JXCategoryTitleView *)titleView {
|
|
if (!_titleView) {
|
|
_titleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero];
|
|
_titleView.backgroundColor =[UIColor clearColor];
|
|
_titleView.titleColor = [DJDKMIMOMColor secondTextColor];
|
|
_titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor];
|
|
_titleView.titleFont = [UIFont systemFontOfSize:14 weight:UIFontWeightSemibold];
|
|
_titleView.titleSelectedFont = [UIFont systemFontOfSize:14 weight:UIFontWeightHeavy];
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
_titleView.averageCellSpacingEnabled = YES;
|
|
_titleView.listContainer = self.listContainerView;
|
|
_titleView.titles = self.titles;
|
|
_titleView.delegate = self;
|
|
|
|
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
|
NSNumber *index = [defaults objectForKey:lastSelectTab];
|
|
_titleView.defaultSelectedIndex = index.intValue;
|
|
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventcollection_entry eventAttributes:@{@"defaultTab" : self.titles[index.intValue]}];
|
|
|
|
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
|
lineView.indicatorImageViewSize = CGSizeMake(50, 8);
|
|
lineView.verticalMargin = 12;
|
|
lineView.indicatorImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x5BC8F8),UIColorFromRGB(0x66D9D9)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(50, 8)];
|
|
lineView.indicatorImageView.layer.masksToBounds = YES;
|
|
lineView.indicatorImageView.layer.cornerRadius = 4;
|
|
_titleView.indicators = @[lineView];
|
|
}
|
|
return _titleView;
|
|
}
|
|
|
|
@end
|