增加换肤功能
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// QXDynamicDetailViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/6/4.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
#import "QXDynamicModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXDynamicDetailViewController : QXBaseViewController
|
||||
@property (nonatomic,strong)QXDynamicModel *model;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
317
QXLive/Dynamic(语圈)/Controller/QXDynamicDetailViewController.m
Normal file
317
QXLive/Dynamic(语圈)/Controller/QXDynamicDetailViewController.m
Normal file
@@ -0,0 +1,317 @@
|
||||
//
|
||||
// QXDynamicDetailViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/6/4.
|
||||
//
|
||||
|
||||
#import "QXDynamicDetailViewController.h"
|
||||
#import "QXDynamicListCell.h"
|
||||
#import "QXDynamicNetwork.h"
|
||||
#import "QXDynamicCommentCell.h"
|
||||
#import "QXDynamicCommentHeaderView.h"
|
||||
#import "QXDynamicCommentInputView.h"
|
||||
#import "QXAlertView.h"
|
||||
|
||||
@interface QXDynamicDetailViewController ()<UITableViewDelegate,UITableViewDataSource,QXDynamicCommentHeaderViewDelegate,QXDynamicCommentInputViewDelegate>
|
||||
@property (nonatomic,strong)UITableView *tableView;
|
||||
@property (nonatomic,strong)QXDynamicModel *detailModel;
|
||||
@property (nonatomic,strong)QXDynamicCommentModel *commentModel;
|
||||
|
||||
@property (nonatomic,strong)QXDynamicCommentInputView *commentView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation QXDynamicDetailViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
||||
}
|
||||
-(void)viewWillDisappear:(BOOL)animated{
|
||||
[super viewWillDisappear:animated];
|
||||
[self.commentView.textField resignFirstResponder];
|
||||
}
|
||||
-(void)setNavgationItems{
|
||||
[super setNavgationItems];
|
||||
self.navigationItem.title = QXText(@"动态详情");
|
||||
}
|
||||
-(void)initSubViews{
|
||||
[self.view addSubview:self.tableView];
|
||||
[self.view addSubview:self.commentView];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
|
||||
}
|
||||
|
||||
-(void)getData{
|
||||
self.page = 1;
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork dynamicPageWithId:self.model.id successBlock:^(QXDynamicModel * _Nonnull model) {
|
||||
weakSelf.detailModel = model;
|
||||
// [weakSelf.tableView reloadSection:0 withRowAnimation:(UITableViewRowAnimationNone)];
|
||||
[weakSelf.tableView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
[self getCommentListIsReload:YES];
|
||||
|
||||
}
|
||||
-(void)getCommentListIsReload:(BOOL)isReload{
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork commentListWithId:self.model.id page:self.page successBlock:^(QXDynamicCommentModel *model) {
|
||||
if (isReload) {
|
||||
[weakSelf.dataArray removeAllObjects];
|
||||
}
|
||||
[weakSelf.dataArray addObjectsFromArray:model.list];
|
||||
if (model.list.count == 0) {
|
||||
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
weakSelf.commentModel = model;
|
||||
weakSelf.detailModel.comment_num = model.total;
|
||||
[weakSelf.tableView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}];
|
||||
}
|
||||
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
|
||||
return self.dataArray.count + 1;
|
||||
}
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
if (section == 0) {
|
||||
return 1;
|
||||
}else{
|
||||
QXDynamicCommentListModel *firsModel = self.dataArray[section-1];
|
||||
return firsModel.replies.count;
|
||||
}
|
||||
}
|
||||
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
MJWeakSelf
|
||||
if (indexPath.section == 0) {
|
||||
QXDynamicListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QXDynamicListCell" forIndexPath:indexPath];
|
||||
cell.selectionStyle = NO;
|
||||
cell.cellType = QXDynamicListCellDetail;
|
||||
cell.model = self.detailModel?self.detailModel:self.model;
|
||||
|
||||
cell.onDeleteBlock = ^(QXDynamicModel * _Nonnull model) {
|
||||
|
||||
};
|
||||
return cell;
|
||||
}else{
|
||||
QXDynamicCommentCell *cell = [QXDynamicCommentCell cellWithTableView:tableView];
|
||||
QXDynamicCommentListModel *firsModel = self.dataArray[indexPath.section-1];
|
||||
QXDynamicCommentListModel *model = firsModel.replies[indexPath.row];
|
||||
if (firsModel.replies.count == 1 && indexPath.row == 0) {
|
||||
cell.topCornerView.layer.cornerRadius = 12;
|
||||
cell.bottomCornerView.layer.cornerRadius = 12;
|
||||
}else{
|
||||
if (indexPath.row == 0) {
|
||||
cell.topCornerView.layer.cornerRadius = 12;
|
||||
cell.bottomCornerView.layer.cornerRadius = 0;
|
||||
}else if (indexPath.row == firsModel.replies.count-1){
|
||||
cell.topCornerView.layer.cornerRadius = 0;
|
||||
cell.bottomCornerView.layer.cornerRadius = 12;
|
||||
}else{
|
||||
cell.topCornerView.layer.cornerRadius = 0;
|
||||
cell.bottomCornerView.layer.cornerRadius = 0;
|
||||
}
|
||||
}
|
||||
cell.model = model;
|
||||
cell.longPressBlock = ^(QXDynamicCommentListModel * _Nonnull model) {
|
||||
UIAlertController *al = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:(UIAlertControllerStyleActionSheet)];
|
||||
if ([model.user_id isEqualToString:[QXGlobal shareGlobal].loginModel.user_id]) {
|
||||
[al addAction:[UIAlertAction actionWithTitle:QXText(@"删除") style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
|
||||
[weakSelf didClickDeleteComment:model];
|
||||
}]];
|
||||
}
|
||||
[al addAction:[UIAlertAction actionWithTitle:QXText(@"复制") style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
|
||||
UIPasteboard *p = [UIPasteboard generalPasteboard];
|
||||
p.string = [NSString stringWithFormat:@"%@", model.content];
|
||||
showToast(@"已复制");
|
||||
}]];
|
||||
[al addAction:[UIAlertAction actionWithTitle:QXText(@"取消") style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
|
||||
|
||||
}]];
|
||||
[weakSelf presentViewController:al animated:YES completion:nil];
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
||||
if (section == 0) {
|
||||
return [UIView new];
|
||||
}else{
|
||||
MJWeakSelf
|
||||
QXDynamicCommentListModel *firsModel = self.dataArray[section-1];
|
||||
CGFloat height = [firsModel.content heightForFont:[UIFont systemFontOfSize:14] width:SCREEN_WIDTH-40-16*2-7];
|
||||
QXDynamicCommentHeaderView *header = [[QXDynamicCommentHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, height+12+40+7+3+9)];
|
||||
[header addTapBlock:^(id _Nonnull obj) {
|
||||
weakSelf.commentView.model = firsModel;
|
||||
weakSelf.commentView.textField.placeholder = [NSString stringWithFormat:@"回复:%@",firsModel.nickname];
|
||||
[weakSelf.commentView.textField becomeFirstResponder];
|
||||
}];
|
||||
header.delegate = self;
|
||||
header.model = firsModel;
|
||||
return header;
|
||||
}
|
||||
}
|
||||
|
||||
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
|
||||
if (section == 0) {
|
||||
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)];
|
||||
footer.backgroundColor = RGB16(0xF6F6F6);
|
||||
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 30, SCREEN_WIDTH, 34)];
|
||||
bgView.backgroundColor = [UIColor whiteColor];
|
||||
[bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||||
[footer addSubview:bgView];
|
||||
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 12, SCREEN_WIDTH-32, 22)];
|
||||
titleLabel.font = [UIFont boldSystemFontOfSize:16];
|
||||
titleLabel.textColor = [UIColor blackColor];
|
||||
[bgView addSubview:titleLabel];
|
||||
titleLabel.text = [NSString localizedStringWithFormat:QXText(@"全部评论(%@)"),self.commentModel.total?self.commentModel.total:@"0"];
|
||||
return footer;
|
||||
}else{
|
||||
return [UIView new];
|
||||
}
|
||||
}
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
||||
if (section == 0) {
|
||||
return 0;
|
||||
}else{
|
||||
QXDynamicCommentListModel *firsModel = self.dataArray[section-1];
|
||||
CGFloat height = [firsModel.content heightForFont:[UIFont systemFontOfSize:14] width:SCREEN_WIDTH-40-16*2-7];
|
||||
return height+12+40+7+3+9;
|
||||
}
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
|
||||
if (section == 0) {
|
||||
return 64;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if (indexPath.section == 0) {
|
||||
return;
|
||||
}
|
||||
QXDynamicCommentListModel *firsModel = self.dataArray[indexPath.section-1];
|
||||
QXDynamicCommentListModel *model = firsModel.replies[indexPath.row];
|
||||
self.commentView.model = model;
|
||||
self.commentView.textField.placeholder = [NSString stringWithFormat:@"回复:%@",model.nickname];
|
||||
[self.commentView.textField becomeFirstResponder];
|
||||
}
|
||||
|
||||
-(void)didClickDeleteComment:(QXDynamicCommentListModel*)model{
|
||||
MJWeakSelf
|
||||
QXAlertView *al = [[QXAlertView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(175))];
|
||||
al.type = QXAlertViewTypeDeleteComment;
|
||||
al.commitBlock = ^{
|
||||
[weakSelf deleteCommentWithModel:model];
|
||||
};
|
||||
[[QXGlobal shareGlobal] showView:al popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
-(void)deleteCommentWithModel:(QXDynamicCommentListModel*)model{
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork deleteCommentWithCommentId:model.id successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getCommentListIsReload:YES];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)didClickReplyComment:(QXDynamicCommentListModel*)model{
|
||||
|
||||
}
|
||||
#pragma mark - 评论
|
||||
-(void)didClickSendWithText:(NSString*)text model:(nonnull QXDynamicCommentListModel *)model{
|
||||
if ([text stringByReplacingOccurrencesOfString:@" " withString:@""].length == 0) {
|
||||
showToast(@"请填写评论");
|
||||
return;
|
||||
}
|
||||
NSString *pid = @"";
|
||||
NSString *reply_to = @"";
|
||||
if (model) {
|
||||
pid = model.pid?model.pid:model.id;
|
||||
reply_to = model.user_id;
|
||||
}else{
|
||||
pid = @"0";
|
||||
reply_to = @"0";
|
||||
}
|
||||
self.commentView.textField.text = @"";
|
||||
[self.view endEditing:YES];
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork commentDynamicWithId:self.detailModel.id pid:pid reply_to:reply_to content:text successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getCommentListIsReload:YES];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
- (void)keyboardWillHide:(NSNotification *)notification {
|
||||
self.commentView.model = nil;
|
||||
self.commentView.textField.placeholder = @"快来发表评论吧";
|
||||
[UIView animateWithDuration:0.3 animations:^{
|
||||
self.commentView.y = SCREEN_HEIGHT-TabbarContentHeight;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)notification {
|
||||
// CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
// [UIView animateWithDuration:0.3 animations:^{
|
||||
// self.commentView.y = keyboardFrame.origin.y+TabbarContentHeight;
|
||||
// }];
|
||||
}
|
||||
|
||||
- (void)keyboardWillChangeFrame:(NSNotification *)notification {
|
||||
CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
[UIView animateWithDuration:0.15 animations:^{
|
||||
self.commentView.y = keyboardFrame.origin.y-TabbarContentHeight;
|
||||
}];
|
||||
}
|
||||
|
||||
-(UITableView *)tableView{
|
||||
if (!_tableView) {
|
||||
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight-TabbarContentHeight) style:UITableViewStyleGrouped];
|
||||
self.tableView.backgroundColor = [UIColor whiteColor];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[self.tableView registerNib:[UINib nibWithNibName:@"QXDynamicListCell" bundle:nil] forCellReuseIdentifier:@"QXDynamicListCell"];
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
||||
self.tableView.estimatedRowHeight = 152;
|
||||
[self.tableView addRoundedCornersWithRadius:16];
|
||||
self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
|
||||
MJWeakSelf
|
||||
// _tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
// weakSelf.page = 1;
|
||||
// [weakSelf getDynamicList];
|
||||
// }];
|
||||
_tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getCommentListIsReload:NO];
|
||||
}];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
-(QXDynamicCommentInputView *)commentView{
|
||||
if (!_commentView) {
|
||||
_commentView = [[QXDynamicCommentInputView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT-TabbarContentHeight, SCREEN_WIDTH, TabbarContentHeight)];
|
||||
_commentView.delegate = self;
|
||||
}
|
||||
return _commentView;
|
||||
}
|
||||
@end
|
||||
16
QXLive/Dynamic(语圈)/Controller/QXDynamicViewController.h
Normal file
16
QXLive/Dynamic(语圈)/Controller/QXDynamicViewController.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// QXDynamicViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/4/24.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXDynamicViewController : QXBaseViewController
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
118
QXLive/Dynamic(语圈)/Controller/QXDynamicViewController.m
Normal file
118
QXLive/Dynamic(语圈)/Controller/QXDynamicViewController.m
Normal file
@@ -0,0 +1,118 @@
|
||||
//
|
||||
// QXDynamicViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/4/24.
|
||||
//
|
||||
|
||||
#import "QXDynamicViewController.h"
|
||||
#import "QXPublishViewController.h"
|
||||
#import "JXCategoryView.h"
|
||||
#import "QXExpansionViewController.h"
|
||||
#import "QXFindViewController.h"
|
||||
|
||||
@interface QXDynamicViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
|
||||
@property (nonatomic,strong)UIButton *publishBtn;
|
||||
@property (nonatomic,strong)JXCategoryTitleView *categoryView;
|
||||
@property (nonatomic,strong)JXCategoryListContainerView *containerView;
|
||||
@property (nonatomic,strong)QXFindViewController *findVC;
|
||||
@end
|
||||
|
||||
@implementation QXDynamicViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
||||
}
|
||||
- (void)initSubViews{
|
||||
// UILabel *tLabel = [[UILabel alloc] init];
|
||||
// tLabel.text = QXText(@"广场");
|
||||
// tLabel.font = [UIFont boldSystemFontOfSize:20];
|
||||
// [self.view addSubview:tLabel];
|
||||
// [tLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.mas_equalTo(16);
|
||||
// make.top.mas_equalTo(kSafeAreaTop +10);
|
||||
// }];
|
||||
self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(14, kSafeAreaTop, 100, 44)];
|
||||
self.categoryView.delegate = self;
|
||||
// self.categoryView.titles = @[QXText(@"发现"),QXText(@"扩列")];
|
||||
self.categoryView.titles = @[QXText(@"扩列"),QXText(@"发现")];
|
||||
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#333333"];
|
||||
self.categoryView.titleColor = [UIColor colorWithHexString:@"#666666"];
|
||||
self.categoryView.cellWidth = 50;
|
||||
self.categoryView.contentEdgeInsetLeft = 0;
|
||||
self.categoryView.cellSpacing = 0;
|
||||
// self.categoryView.titleLabelZoomScale = 1.1;
|
||||
self.categoryView.titleLabelZoomEnabled = YES;
|
||||
self.categoryView.titleFont = [UIFont boldSystemFontOfSize:16];
|
||||
self.categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:18];
|
||||
self.categoryView.averageCellSpacingEnabled = NO;
|
||||
JXCategoryIndicatorImageView *indicatorView = [[JXCategoryIndicatorImageView alloc] init];
|
||||
indicatorView.indicatorImageView.image = [UIImage imageNamed:@"home_slider"];
|
||||
indicatorView.indicatorImageViewSize = CGSizeMake(35, 8);
|
||||
indicatorView.verticalMargin = 11;
|
||||
self.categoryView.indicators = @[indicatorView];
|
||||
self.containerView = [[JXCategoryListContainerView alloc] initWithType:(JXCategoryListContainerType_ScrollView) delegate:self];
|
||||
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, SCREEN_HEIGHT-self.categoryView.bottom);
|
||||
// self.containerView.scrollView.scrollEnabled = NO;
|
||||
[self.view addSubview:self.categoryView];
|
||||
[self.view addSubview:self.containerView];
|
||||
self.categoryView.listContainer = self.containerView;
|
||||
|
||||
[self.view addSubview:self.publishBtn];
|
||||
|
||||
}
|
||||
|
||||
-(NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
|
||||
return 2;
|
||||
}
|
||||
-(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
|
||||
// if (index == 0) {
|
||||
// QXFindViewController *vc = [[QXFindViewController alloc] init];
|
||||
// self.findVC = vc;
|
||||
// return vc;
|
||||
// }else{
|
||||
// QXExpansionViewController *vc = [[QXExpansionViewController alloc] init];
|
||||
// return vc;
|
||||
// }
|
||||
if (index == 0) {
|
||||
QXExpansionViewController *vc = [[QXExpansionViewController alloc] init];
|
||||
return vc;
|
||||
}else{
|
||||
QXFindViewController *vc = [[QXFindViewController alloc] init];
|
||||
self.findVC = vc;
|
||||
return vc;
|
||||
}
|
||||
}
|
||||
-(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
|
||||
self.publishBtn.hidden = !(index==1);
|
||||
}
|
||||
#pragma mark - action
|
||||
-(void)pulishAction{
|
||||
if (!QXGlobal.shareGlobal.isLogin) {
|
||||
[[QXGlobal shareGlobal] logOut];
|
||||
return;
|
||||
}
|
||||
QXPublishViewController *vc = [[QXPublishViewController alloc] init];
|
||||
MJWeakSelf
|
||||
vc.publishFinishBlock = ^{
|
||||
[weakSelf.findVC.tableView.mj_header beginRefreshing];
|
||||
[weakSelf.findVC getTopicList];
|
||||
};
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
-(UIButton *)publishBtn{
|
||||
if (!_publishBtn) {
|
||||
_publishBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-44-8, kSafeAreaTop, 44, 44)];
|
||||
[_publishBtn setImage:[UIImage imageNamed:@"publish_icon"] forState:UIControlStateNormal];
|
||||
[_publishBtn setImage:[UIImage imageNamed:@"publish_icon"] forState:UIControlStateHighlighted];
|
||||
[_publishBtn addTarget:self action:@selector(pulishAction) forControlEvents:UIControlEventTouchUpInside];
|
||||
_publishBtn.hidden = YES;
|
||||
}
|
||||
return _publishBtn;
|
||||
}
|
||||
@end
|
||||
16
QXLive/Dynamic(语圈)/Controller/QXExpansionViewController.h
Normal file
16
QXLive/Dynamic(语圈)/Controller/QXExpansionViewController.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// QXExpansionViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/27.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
#import "JXCategoryView.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXExpansionViewController : QXBaseViewController<JXCategoryListContentViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
195
QXLive/Dynamic(语圈)/Controller/QXExpansionViewController.m
Normal file
195
QXLive/Dynamic(语圈)/Controller/QXExpansionViewController.m
Normal file
@@ -0,0 +1,195 @@
|
||||
//
|
||||
// QXExpansionViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/27.
|
||||
//
|
||||
|
||||
#import "QXExpansionViewController.h"
|
||||
#import "QXExpansionCell.h"
|
||||
#import "UIButton+QX.h"
|
||||
#import "QXMenuPopView.h"
|
||||
#import "QXDynamicNetwork.h"
|
||||
#import "QXUserHomePageViewController.h"
|
||||
#import "QXExpansionAppStoreView.h"
|
||||
|
||||
@interface QXExpansionViewController ()<UITableViewDelegate,UITableViewDataSource,QXMenuPopViewDelegate>
|
||||
@property (strong, nonatomic) UILabel *titleLabel;
|
||||
@property (strong, nonatomic) UIButton *sortBtn;
|
||||
@property (strong, nonatomic) UITableView *tableView;
|
||||
@property (strong, nonatomic) NSString *type;
|
||||
@property (strong, nonatomic) QXExpansionAppStoreView *appStoreView;
|
||||
@end
|
||||
|
||||
@implementation QXExpansionViewController
|
||||
-(UIView *)listView{
|
||||
return self.view;
|
||||
}
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:noticeUserLogin object:nil];
|
||||
}
|
||||
- (void)initSubViews{
|
||||
self.page = 1;
|
||||
self.bgImageHidden = YES;
|
||||
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 12, 100, 24)];
|
||||
self.titleLabel.font = [UIFont systemFontOfSize:16];
|
||||
self.titleLabel.textColor = QXConfig.textColor;
|
||||
self.titleLabel.text = QXText(@"扩列交友");
|
||||
[self.view addSubview:self.titleLabel];
|
||||
|
||||
self.sortBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-75-13, 0, 75, 48)];
|
||||
[self.sortBtn setImage:[[UIImage imageNamed:@"arrow_bottom"] imageByTintColor:QXConfig.textColor] forState:(UIControlStateNormal)];
|
||||
if ([QXGlobal shareGlobal].loginModel.sex.integerValue == 1) {
|
||||
[self.sortBtn setTitle:QXText(@"只看女生") forState:(UIControlStateNormal)];
|
||||
self.type = @"2";
|
||||
}else{
|
||||
[self.sortBtn setTitle:QXText(@"只看男生") forState:(UIControlStateNormal)];
|
||||
self.type = @"1";
|
||||
}
|
||||
[self.sortBtn setTitleColor:QXConfig.textColor forState:(UIControlStateNormal)];
|
||||
self.sortBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.sortBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:3];
|
||||
[self.sortBtn addTarget:self action:@selector(sortAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.view addSubview:self.sortBtn];
|
||||
[self.view addSubview:self.tableView];
|
||||
self.appStoreView.hidden = YES;
|
||||
[self.view addSubview:self.appStoreView];
|
||||
MJWeakSelf
|
||||
self.appStoreView.userBlock = ^(QXUserHomeModel * _Nonnull user) {
|
||||
if (!QXGlobal.shareGlobal.isLogin) {
|
||||
[[QXGlobal shareGlobal] logOut];
|
||||
return;
|
||||
}
|
||||
if (user == nil) {
|
||||
return;
|
||||
}
|
||||
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
|
||||
vc.user_id = user.user_id;
|
||||
[weakSelf.navigationController pushViewController:vc animated:YES];
|
||||
};
|
||||
}
|
||||
-(void)loginSuccess{
|
||||
[self getData];
|
||||
}
|
||||
- (void)getData{
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork expansionListWithPage:self.page type:self.type successBlock:^(NSArray<QXUserHomeModel *> * _Nonnull list, BOOL isAppStore) {
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.dataArray removeAllObjects];
|
||||
}
|
||||
if (isAppStore) {
|
||||
self.appStoreView.hidden = NO;
|
||||
self.tableView.hidden = YES;
|
||||
self.appStoreView.users = list;
|
||||
}else{
|
||||
self.tableView.hidden = NO;
|
||||
self.appStoreView.hidden = YES;
|
||||
}
|
||||
[weakSelf.dataArray addObjectsFromArray:list];
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
if (list.count == 0) {
|
||||
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)sortAction{
|
||||
QXMenuPopView *menuView = [[QXMenuPopView alloc] initWithPoint:CGPointMake(self.sortBtn.centerX, NavContentHeight+self.sortBtn.bottom-10)];
|
||||
menuView.dataArray = @[QXText(@"只看女生"),QXText(@"只看男生"),QXText(@"查看全部")];
|
||||
menuView.delegate = self;
|
||||
[menuView showInView:KEYWINDOW];
|
||||
}
|
||||
|
||||
-(void)didSelectedIndex:(NSInteger)index menuTitle:(NSString *)menuTitle{
|
||||
QXLOG(@"选择了%@",menuTitle);
|
||||
if ([menuTitle isEqualToString:QXText(@"只看女生")]) {
|
||||
self.page = 1;
|
||||
self.type = @"2";
|
||||
[self getData];
|
||||
}else if ([menuTitle isEqualToString:QXText(@"只看男生")]) {
|
||||
self.page = 1;
|
||||
self.type = @"1";
|
||||
[self getData];
|
||||
}else{
|
||||
self.page = 1;
|
||||
self.type = @"0";
|
||||
[self getData];
|
||||
}
|
||||
[self.sortBtn setTitle:menuTitle forState:(UIControlStateNormal)];
|
||||
}
|
||||
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
return self.dataArray.count;
|
||||
}
|
||||
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXExpansionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QXExpansionCell" forIndexPath:indexPath];
|
||||
cell.selectionStyle = NO;
|
||||
QXUserHomeModel *model = self.dataArray[indexPath.row];
|
||||
cell.model = model;
|
||||
return cell;
|
||||
}
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXUserHomeModel *model = self.dataArray[indexPath.row];
|
||||
NSArray *imgArr;
|
||||
if (model.home_bgimages.length > 0) {
|
||||
imgArr = [model.home_bgimages componentsSeparatedByString:@","];
|
||||
}
|
||||
// NSArray *
|
||||
CGFloat itemH = 94;
|
||||
if (imgArr.count == 1) {
|
||||
itemH = (SCREEN_WIDTH-15-15-15)/2 + 94;
|
||||
}else if(imgArr.count > 1){
|
||||
if (imgArr.count > 3) {
|
||||
itemH = (SCREEN_WIDTH-16*2-12*2-10*2)/3*2+10+94;
|
||||
}else{
|
||||
itemH = (SCREEN_WIDTH-16*2-12*2-10*2)/3+94;
|
||||
}
|
||||
}else{
|
||||
itemH = 94;
|
||||
}
|
||||
return itemH;
|
||||
}
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXUserHomeModel *model = self.dataArray[indexPath.row];
|
||||
QXUserHomePageViewController *vc = [[QXUserHomePageViewController alloc] init];
|
||||
vc.user_id = model.user_id;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
-(UITableView *)tableView{
|
||||
if (!_tableView) {
|
||||
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.titleLabel.bottom+12, SCREEN_WIDTH, self.view.height-TabbarContentHeight-self.titleLabel.bottom-12) style:UITableViewStylePlain];
|
||||
self.tableView.backgroundColor = [UIColor clearColor];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[self.tableView registerNib:[UINib nibWithNibName:@"QXExpansionCell" bundle:nil] forCellReuseIdentifier:@"QXExpansionCell"];
|
||||
self.tableView.estimatedRowHeight = 94;
|
||||
MJWeakSelf
|
||||
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getData];
|
||||
}];
|
||||
_tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getData];
|
||||
}];
|
||||
self.tableView.hidden = NO;
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
-(QXExpansionAppStoreView *)appStoreView{
|
||||
if (!_appStoreView) {
|
||||
_appStoreView = [[QXExpansionAppStoreView alloc] initWithFrame:self.tableView.bounds];
|
||||
}
|
||||
return _appStoreView;
|
||||
}
|
||||
@end
|
||||
17
QXLive/Dynamic(语圈)/Controller/QXFindViewController.h
Normal file
17
QXLive/Dynamic(语圈)/Controller/QXFindViewController.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// QXFindViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/27.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
#import "JXCategoryView.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXFindViewController : QXBaseViewController<JXCategoryListContentViewDelegate>
|
||||
@property (strong, nonatomic) UITableView *tableView;
|
||||
-(void)getTopicList;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
223
QXLive/Dynamic(语圈)/Controller/QXFindViewController.m
Normal file
223
QXLive/Dynamic(语圈)/Controller/QXFindViewController.m
Normal file
@@ -0,0 +1,223 @@
|
||||
//
|
||||
// QXFindViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/27.
|
||||
//
|
||||
|
||||
#import "QXFindViewController.h"
|
||||
#import "QXDynamicTopicCell.h"
|
||||
#import "GKPageControl.h"
|
||||
#import "QXDynamicListCell.h"
|
||||
#import "QXDynamicNetwork.h"
|
||||
#import "QXToppicDynamicViewController.h"
|
||||
#import "QXDynamicDetailViewController.h"
|
||||
|
||||
@interface QXFindViewController ()<UITableViewDelegate,UITableViewDataSource,UICollectionViewDelegate,UICollectionViewDataSource>
|
||||
|
||||
@property (strong, nonatomic) UICollectionView *collectionView;
|
||||
@property (strong, nonatomic) NSMutableArray *hotTopicArray;
|
||||
@property (nonatomic,strong)GKPageControl *pageControl;
|
||||
@end
|
||||
|
||||
@implementation QXFindViewController
|
||||
-(UIView *)listView{
|
||||
return self.view;
|
||||
}
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loginSuccess) name:noticeUserLogin object:nil];
|
||||
}
|
||||
- (void)initSubViews{
|
||||
self.page = 1;
|
||||
self.bgImageHidden = YES;
|
||||
[self.view addSubview:self.collectionView];
|
||||
[self.view addSubview:self.pageControl];
|
||||
[self.view addSubview:self.tableView];
|
||||
[self getTopicList];
|
||||
[self getDynamicList];
|
||||
}
|
||||
-(void)getTopicList{
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork getTopicListWithPage:self.page isTopTopic:YES successBlock:^(NSArray<QXTopicModel *> * _Nonnull hotos) {
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.hotTopicArray removeAllObjects];
|
||||
}
|
||||
[weakSelf.hotTopicArray addObjectsFromArray:hotos];
|
||||
if (hotos.count == 0) {
|
||||
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
if (weakSelf.hotTopicArray.count %4 >0) {
|
||||
weakSelf.pageControl.numberOfPages = self.hotTopicArray.count/4+1;
|
||||
}else{
|
||||
weakSelf.pageControl.numberOfPages = self.hotTopicArray.count/4;
|
||||
}
|
||||
weakSelf.pageControl.currentPage = 0;
|
||||
[self.collectionView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
}];
|
||||
|
||||
}
|
||||
-(void)loginSuccess{
|
||||
[self getTopicList];
|
||||
[self getDynamicList];
|
||||
}
|
||||
-(void)getDynamicList{
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork getDynamicListWithPage:self.page successBlock:^(NSArray<QXDynamicModel *> * _Nonnull hotos) {
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.dataArray removeAllObjects];
|
||||
}
|
||||
[weakSelf.dataArray addObjectsFromArray:hotos];
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
if (hotos.count == 0) {
|
||||
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}];
|
||||
}
|
||||
#pragma mark - UITableViewDelegate,UITableViewDataSource
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
return self.dataArray.count;
|
||||
}
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXDynamicListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QXDynamicListCell" forIndexPath:indexPath];
|
||||
cell.selectionStyle = NO;
|
||||
cell.cellType = QXDynamicListCellDynamic;
|
||||
cell.model = self.dataArray[indexPath.row];
|
||||
// SPTrendListModel *model = self.dataArray[indexPath.row];
|
||||
// cell.model = model;
|
||||
MJWeakSelf
|
||||
cell.onDeleteBlock = ^(QXDynamicModel * _Nonnull model) {
|
||||
[weakSelf.dataArray removeObject:model];
|
||||
[weakSelf.tableView reloadSection:indexPath.section withRowAnimation:(UITableViewRowAnimationAutomatic)];
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if (!QXGlobal.shareGlobal.isLogin) {
|
||||
[[QXGlobal shareGlobal] logOut];
|
||||
return;
|
||||
}
|
||||
QXDynamicModel *model = self.dataArray[indexPath.row];
|
||||
QXDynamicDetailViewController *vc = [[QXDynamicDetailViewController alloc] init];
|
||||
vc.model = model;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDelegate,UICollectionViewDataSource
|
||||
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
||||
return self.hotTopicArray.count;
|
||||
}
|
||||
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXDynamicTopicCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXDynamicTopicCell" forIndexPath:indexPath];
|
||||
QXTopicModel *model = self.hotTopicArray[indexPath.row];
|
||||
cell.model = model;
|
||||
return cell;
|
||||
}
|
||||
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
||||
if (!QXGlobal.shareGlobal.isLogin) {
|
||||
[[QXGlobal shareGlobal] logOut];
|
||||
return;
|
||||
}
|
||||
QXTopicModel *model = self.hotTopicArray[indexPath.row];
|
||||
QXToppicDynamicViewController *vc = [[QXToppicDynamicViewController alloc] init];
|
||||
vc.model = model;
|
||||
[self.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
|
||||
if ([scrollView isKindOfClass:[UICollectionView class]]) {
|
||||
long offsetX = (long)scrollView.contentOffset.x;
|
||||
int width = SCREEN_WIDTH-32;
|
||||
int remainder = offsetX % width;
|
||||
NSInteger index;
|
||||
if (remainder>(width)/2) {
|
||||
index = offsetX/width+1;
|
||||
}else{
|
||||
index = offsetX/width;
|
||||
}
|
||||
self.pageControl.currentPage = index;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
-(UITableView *)tableView{
|
||||
if (!_tableView) {
|
||||
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.pageControl.bottom+5, SCREEN_WIDTH, SCREEN_HEIGHT-TabbarContentHeight-self.pageControl.bottom-5-13) style:UITableViewStylePlain];
|
||||
self.tableView.backgroundColor = [UIColor clearColor];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[self.tableView registerNib:[UINib nibWithNibName:@"QXDynamicListCell" bundle:nil] forCellReuseIdentifier:@"QXDynamicListCell"];
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
||||
// self.tableView.estimatedRowHeight = 0;
|
||||
MJWeakSelf
|
||||
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getDynamicList];
|
||||
}];
|
||||
_tableView.mj_footer = [MJRefreshBackStateFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getDynamicList];
|
||||
}];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
-(UICollectionView *)collectionView{
|
||||
if (!_collectionView) {
|
||||
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
||||
layout.minimumLineSpacing = 16;
|
||||
layout.minimumInteritemSpacing = 16;
|
||||
layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
|
||||
layout.itemSize = CGSizeMake((SCREEN_WIDTH-16*3)/2, 45);
|
||||
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(16, 13, SCREEN_WIDTH-32, 45*2+16) collectionViewLayout:layout];
|
||||
_collectionView.delegate = self;
|
||||
_collectionView.dataSource = self;
|
||||
_collectionView.pagingEnabled = YES;
|
||||
_collectionView.bounces = NO;
|
||||
_collectionView.backgroundColor = [UIColor clearColor];
|
||||
_collectionView.showsHorizontalScrollIndicator = NO;
|
||||
[_collectionView registerNib:[UINib nibWithNibName:@"QXDynamicTopicCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXDynamicTopicCell"];
|
||||
}
|
||||
return _collectionView;
|
||||
}
|
||||
-(GKPageControl *)pageControl{
|
||||
if (!_pageControl) {
|
||||
_pageControl = [[GKPageControl alloc] initWithFrame:CGRectMake(0, self.collectionView.bottom+7, SCREEN_WIDTH, 8)];
|
||||
_pageControl.style = GKPageControlStyleRectangle;
|
||||
_pageControl.dotWidth = 15;
|
||||
_pageControl.dotHeight = 5;
|
||||
_pageControl.dotMargin = 2;
|
||||
_pageControl.pageIndicatorTintColor = UIColor.whiteColor;
|
||||
_pageControl.currentPageIndicatorTintColor = QXConfig.textColor;
|
||||
}
|
||||
return _pageControl;
|
||||
}
|
||||
-(NSMutableArray *)hotTopicArray{
|
||||
if (!_hotTopicArray) {
|
||||
_hotTopicArray = [NSMutableArray array];
|
||||
}
|
||||
return _hotTopicArray;
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
16
QXLive/Dynamic(语圈)/Controller/QXPublishViewController.h
Normal file
16
QXLive/Dynamic(语圈)/Controller/QXPublishViewController.h
Normal file
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// QXPublishViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/27.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXPublishViewController : QXBaseViewController
|
||||
@property(nonatomic,copy)void(^publishFinishBlock)(void);
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
139
QXLive/Dynamic(语圈)/Controller/QXPublishViewController.m
Normal file
139
QXLive/Dynamic(语圈)/Controller/QXPublishViewController.m
Normal file
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// QXPublishViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/27.
|
||||
//
|
||||
|
||||
#import "QXPublishViewController.h"
|
||||
#import "QXTextView.h"
|
||||
#import "QXUserInfoEditFooterView.h"
|
||||
#import "QXSelectedTopicView.h"
|
||||
#import "QXTopicListView.h"
|
||||
#import "QXLocationManager.h"
|
||||
#import "QXDynamicNetwork.h"
|
||||
|
||||
@interface QXPublishViewController ()<QXUserInfoImageCellDelegate,QXLocationManagerDelegate>
|
||||
@property (nonatomic,strong)QXTextView *textView;
|
||||
@property (nonatomic,strong)QXSelectedTopicView *topicView;
|
||||
@property (nonatomic,strong)QXUserInfoEditFooterView *pickerView;
|
||||
@property (nonatomic,strong)NSString *images;
|
||||
@property (nonatomic,strong)NSString *city;
|
||||
@property (nonatomic,strong)UIButton* commitBtn;
|
||||
@end
|
||||
|
||||
@implementation QXPublishViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
||||
}
|
||||
|
||||
-(void)setNavgationItems{
|
||||
[super setNavgationItems];
|
||||
self.navigationItem.title = QXText(@"动态发布");
|
||||
}
|
||||
-(void)initSubViews{
|
||||
self.topicView = [[QXSelectedTopicView alloc] initWithFrame:CGRectMake(16, NavContentHeight+12, SCREEN_WIDTH-32, 44)];
|
||||
self.topicView.backgroundColor = RGB16(0xEFF2F8);
|
||||
[self.topicView addRoundedCornersWithRadius:11];
|
||||
MJWeakSelf
|
||||
[self.topicView addTapBlock:^(id _Nonnull obj) {
|
||||
QXTopicListView *listView = [[QXTopicListView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(374))];
|
||||
listView.selecctedTopicBlock = ^(NSArray<QXTopicModel *> * _Nonnull topicArr) {
|
||||
weakSelf.topicView.selectedTopic = topicArr;
|
||||
};
|
||||
[[QXGlobal shareGlobal] showView:listView popType:(PopViewTypeBottomToUpActionSheet) tapDismiss:YES finishBlock:^{
|
||||
|
||||
}];
|
||||
}];
|
||||
[self.view addSubview:self.topicView];
|
||||
|
||||
self.textView = [[QXTextView alloc] initWithFrame:CGRectMake(16, self.topicView.bottom+12, SCREEN_WIDTH-32, 180)];
|
||||
self.textView.placehoulder = QXText(@"此刻想和大家分享点什么");
|
||||
self.textView.font = [UIFont systemFontOfSize:12];
|
||||
self.textView.maxLength = 1200;
|
||||
self.textView.backgroundColor = [UIColor whiteColor];
|
||||
[self.textView addRoundedCornersWithRadius:7];
|
||||
[self.view addSubview:self.textView];
|
||||
|
||||
int itemWidth = (self.view.width-16*2-20*2)/3;
|
||||
self.pickerView = [[QXUserInfoEditFooterView alloc] initWithFrame:CGRectMake(0, self.textView.bottom, SCREEN_WIDTH, itemWidth*3+12*2+20*2)];
|
||||
self.pickerView.backgroundColor = [UIColor clearColor];
|
||||
self.pickerView.maxCount = 9;
|
||||
self.pickerView.hideTitle = YES;
|
||||
self.pickerView.delegate = self;
|
||||
[self.view addSubview:self.pickerView];
|
||||
[[QXLocationManager shareManager] startLoction];
|
||||
[QXLocationManager shareManager].delegate = self;
|
||||
self.commitBtn = [[UIButton alloc] init];
|
||||
[self.commitBtn setTitle:QXText(@"发布") forState:(UIControlStateNormal)];
|
||||
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];;
|
||||
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
[self.commitBtn addRoundedCornersWithRadius:21];
|
||||
self.commitBtn.backgroundColor = QXConfig.themeColor;
|
||||
[self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.view addSubview:self.commitBtn];
|
||||
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(38);
|
||||
make.right.mas_equalTo(-38);
|
||||
make.height.mas_equalTo(42);
|
||||
make.bottom.mas_equalTo(-(kSafeAreaBottom));
|
||||
}];
|
||||
}
|
||||
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
|
||||
[self.view endEditing:YES];
|
||||
}
|
||||
-(void)commitAction{
|
||||
// if (self.topicView.selectedTopic.count == 0) {
|
||||
// showToast(@"请选择话题");
|
||||
// return;
|
||||
// }
|
||||
if (self.textView.text.length == 0) {
|
||||
showToast(@"发布内容不能为空");
|
||||
return;
|
||||
}
|
||||
// if (self.images.length == 0) {
|
||||
// showToast(@"请上传图片");
|
||||
// return;
|
||||
// }
|
||||
NSString *topic = @"";
|
||||
if (self.topicView.selectedTopic.count > 0) {
|
||||
for (QXTopicModel*md in self.topicView.selectedTopic) {
|
||||
if (topic.length == 0) {
|
||||
topic = [topic stringByAppendingFormat:@"%@",md.topic_id];
|
||||
}else{
|
||||
topic = [topic stringByAppendingFormat:@",%@",md.topic_id];
|
||||
}
|
||||
}
|
||||
}
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork publishDynamicWithImages:self.images
|
||||
content:self.textView.text
|
||||
topic_id:topic
|
||||
ip:self.city
|
||||
successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
if (weakSelf.publishFinishBlock) {
|
||||
weakSelf.publishFinishBlock();
|
||||
}
|
||||
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)locationSuccessWithCity:(NSString *)city province:(NSString * _Nonnull)province area:(NSString * _Nonnull)area address:(NSString * _Nonnull)address{
|
||||
[[QXLocationManager shareManager] stopLoction];
|
||||
self.city = city;
|
||||
}
|
||||
|
||||
-(void)didUploadFinishedWithImageUrlList:(NSArray *)urlList{
|
||||
self.images = [urlList componentsJoinedByString:@","];
|
||||
}
|
||||
|
||||
@end
|
||||
19
QXLive/Dynamic(语圈)/Controller/QXReportViewController.h
Normal file
19
QXLive/Dynamic(语圈)/Controller/QXReportViewController.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// QXReportViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/7/9.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXReportViewController : QXBaseViewController
|
||||
/// 1-用户,2房间,3动态&
|
||||
@property (nonatomic,strong)NSString *reportType;
|
||||
/// fromId=对应id
|
||||
@property (nonatomic,strong)NSString *fromId;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
214
QXLive/Dynamic(语圈)/Controller/QXReportViewController.m
Normal file
214
QXLive/Dynamic(语圈)/Controller/QXReportViewController.m
Normal file
@@ -0,0 +1,214 @@
|
||||
//
|
||||
// QXLevelViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/9.
|
||||
//
|
||||
|
||||
#import "QXReportViewController.h"
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
static void *WKWebBrowserContext = &WKWebBrowserContext;
|
||||
@interface QXReportViewController ()<WKScriptMessageHandler>
|
||||
@property(nonatomic,strong)WKWebView *contentWebView;
|
||||
@property(nonatomic,strong)UIProgressView *progressView;
|
||||
@end
|
||||
|
||||
@implementation QXReportViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
[self.view addSubview:self.contentWebView];
|
||||
[self.view addSubview:self.progressView];
|
||||
|
||||
[self layoutConstraints];
|
||||
[self loadData];
|
||||
}
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:YES animated:YES];
|
||||
}
|
||||
//-(void)setNavgationItems{
|
||||
// [super setNavgationItems];
|
||||
// self.navigationItem.title = @"段位";
|
||||
//}
|
||||
|
||||
- (void)layoutConstraints {
|
||||
[self.contentWebView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
|
||||
[self.progressView setFrame:CGRectMake(0, 0, SCREEN_WIDTH
|
||||
, 2)];
|
||||
}
|
||||
- (void)loadData {
|
||||
// 1-用户,2房间,3动态&fromId=对应id
|
||||
NSInteger safeTop = kSafeAreaTop;
|
||||
NSURL* url= [NSURL URLWithString:[NSString stringWithFormat:@"%@web/index.html#/pages/feedback/report?id=%@&fromType=%@&fromId=%@&h=%ld",H5ServerUrl,[QXGlobal shareGlobal].loginModel.token ,self.reportType,self.fromId,safeTop]];
|
||||
NSURLRequest *request =[NSURLRequest requestWithURL:url];
|
||||
[self.contentWebView loadRequest:request];
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma mark - WKNavigationDelegate
|
||||
//开始加载
|
||||
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
|
||||
//开始加载的时候,让加载进度条显示
|
||||
self.progressView.hidden = NO;
|
||||
}
|
||||
|
||||
//网页加载完成
|
||||
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
|
||||
// 获取加载网页的标题
|
||||
// if (self.title.length == 0) {
|
||||
// self.navigationItem.title = self.contentWebView.title;
|
||||
// }
|
||||
// if ([self.titleString containsString:@"转账"]) {
|
||||
// // 设置字体
|
||||
// NSString *fontFamilyStr = @"document.getElementsByTagName('body')[0].style.fontFamily='Arial';";
|
||||
// [webView evaluateJavaScript:fontFamilyStr completionHandler:nil];
|
||||
// //设置颜色
|
||||
// [ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= '#333333'" completionHandler:nil];
|
||||
// //修改字体大小
|
||||
// [ webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '150%'"completionHandler:nil];
|
||||
// }
|
||||
}
|
||||
//内容返回时调用
|
||||
- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation {
|
||||
|
||||
}
|
||||
|
||||
//服务器请求跳转的时候调用
|
||||
- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation {
|
||||
|
||||
}
|
||||
|
||||
// 内容加载失败时候调用
|
||||
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error{
|
||||
|
||||
}
|
||||
-(void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message{
|
||||
NSLog(@"message.name====%@ body=%@",message.name,message.body);
|
||||
if([message.name isEqualToString:@"nativeHandler"]){
|
||||
NSDictionary *dict = message.body;
|
||||
if ([dict[@"action"] isEqualToString:@"closeWeb"]) {
|
||||
if (self.contentWebView.canGoBack) {
|
||||
[self.contentWebView goBack];
|
||||
}else{
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
|
||||
//如果是跳转一个新页面
|
||||
if (navigationAction.targetFrame == nil) {
|
||||
[webView loadRequest:navigationAction.request];
|
||||
}
|
||||
NSURL *URL = navigationAction.request.URL;
|
||||
[self dealSomeThing:URL];
|
||||
decisionHandler(WKNavigationActionPolicyAllow);
|
||||
}
|
||||
|
||||
- (void)dealSomeThing:(NSURL *)url{
|
||||
NSString *scheme = [url scheme];
|
||||
NSString *resourceSpecifier = [url resourceSpecifier];
|
||||
if ([scheme isEqualToString:@"tel"]) {
|
||||
NSString *callPhone = [NSString stringWithFormat:@"tel://%@", resourceSpecifier];
|
||||
/// 防止iOS 10及其之后,拨打电话系统弹出框延迟出现
|
||||
dispatch_async(dispatch_get_global_queue(0, 0), ^{
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//进度条
|
||||
- (void)webViewWebContentProcessDidTerminate:(WKWebView *)webView {
|
||||
}
|
||||
|
||||
//KVO监听进度条
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
|
||||
|
||||
if ([keyPath isEqualToString:NSStringFromSelector(@selector(estimatedProgress))] && object == self.contentWebView) {
|
||||
[self.progressView setAlpha:1.0f];
|
||||
BOOL animated = self.contentWebView.estimatedProgress > self.progressView.progress;
|
||||
[self.progressView setProgress:self.contentWebView.estimatedProgress animated:animated];
|
||||
|
||||
// Once complete, fade out UIProgressView
|
||||
if(self.contentWebView.estimatedProgress >= 1.0f) {
|
||||
[UIView animateWithDuration:0.3f delay:0.3f options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
[self.progressView setAlpha:0.0f];
|
||||
} completion:^(BOOL finished) {
|
||||
[self.progressView setProgress:0.0f animated:NO];
|
||||
}];
|
||||
}
|
||||
}
|
||||
else {
|
||||
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - getters and setters
|
||||
- (WKWebView *)contentWebView {
|
||||
if (!_contentWebView) {
|
||||
//设置网页的配置文件
|
||||
WKWebViewConfiguration * configuration = [[WKWebViewConfiguration alloc]init];
|
||||
// 允许可以与网页交互,选择视图
|
||||
configuration.selectionGranularity = YES;
|
||||
// web内容处理池pr
|
||||
configuration.processPool = [[WKProcessPool alloc] init];
|
||||
//自定义配置,一般用于 js调用oc方法(OC拦截URL中的数据做自定义操作)
|
||||
WKUserContentController * UserContentController = [[WKUserContentController alloc]init];
|
||||
// 是否支持记忆读取
|
||||
configuration.suppressesIncrementalRendering = NO;
|
||||
// 允许用户更改网页的设置
|
||||
[UserContentController addScriptMessageHandler:self name:@"nativeHandler"];
|
||||
configuration.preferences.javaScriptEnabled = YES;
|
||||
configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES;
|
||||
configuration.userContentController = UserContentController;
|
||||
// 此处一定要做判断,因为是iOS9之后才有的方法,否则在iOS8下会崩溃
|
||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) {
|
||||
//允许视频播放
|
||||
configuration.allowsAirPlayForMediaPlayback = YES;
|
||||
// 允许在线播放
|
||||
configuration.allowsInlineMediaPlayback = YES;
|
||||
//开启手势触摸 默认设置就是NO。在ios8系统中会导致手势问题,程序崩溃
|
||||
_contentWebView.allowsBackForwardNavigationGestures = YES;
|
||||
}
|
||||
_contentWebView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:configuration];
|
||||
_contentWebView.backgroundColor = [UIColor clearColor];
|
||||
_contentWebView.opaque = YES;
|
||||
//适应你设定的尺寸
|
||||
[_contentWebView sizeToFit];
|
||||
_contentWebView.scrollView.showsVerticalScrollIndicator = NO;
|
||||
// 设置代理
|
||||
_contentWebView.navigationDelegate = self;
|
||||
//kvo 添加进度监控
|
||||
[_contentWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:WKWebBrowserContext];
|
||||
}
|
||||
return _contentWebView;
|
||||
}
|
||||
|
||||
- (UIProgressView *)progressView {
|
||||
if (!_progressView) {
|
||||
_progressView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];
|
||||
[_progressView setTrackTintColor:[UIColor colorWithRed:240.0/255 green:240.0/255 blue:240.0/255 alpha:1.0]];
|
||||
_progressView.progressTintColor = QXConfig.themeColor;
|
||||
}
|
||||
return _progressView;
|
||||
}
|
||||
|
||||
-(void)setProgressColor:(UIColor *)progressColor{
|
||||
_progressView.progressTintColor = progressColor;
|
||||
}
|
||||
// 记得dealloc
|
||||
- (void)dealloc {
|
||||
if (self) {
|
||||
[self.contentWebView removeObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress))];
|
||||
}
|
||||
}
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
|
||||
}
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// QXToppicDynamicViewController.h
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/6/3.
|
||||
//
|
||||
|
||||
#import "QXBaseViewController.h"
|
||||
#import "QXDynamicModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface QXToppicDynamicViewController : QXBaseViewController
|
||||
@property (nonatomic,strong)QXTopicModel *model;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
106
QXLive/Dynamic(语圈)/Controller/QXToppicDynamicViewController.m
Normal file
106
QXLive/Dynamic(语圈)/Controller/QXToppicDynamicViewController.m
Normal file
@@ -0,0 +1,106 @@
|
||||
//
|
||||
// QXToppicDynamicViewController.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/6/3.
|
||||
//
|
||||
|
||||
#import "QXToppicDynamicViewController.h"
|
||||
#import "QXDynamicListCell.h"
|
||||
#import "QXToppicDynamicTopView.h"
|
||||
#import "QXDynamicNetwork.h"
|
||||
|
||||
@interface QXToppicDynamicViewController ()<UITableViewDelegate,UITableViewDataSource>
|
||||
@property (strong, nonatomic) UITableView *tableView;
|
||||
@property (strong, nonatomic) QXToppicDynamicTopView *topView;
|
||||
@end
|
||||
|
||||
@implementation QXToppicDynamicViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
}
|
||||
|
||||
-(void)viewWillAppear:(BOOL)animated{
|
||||
[super viewWillAppear:animated];
|
||||
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
||||
}
|
||||
|
||||
-(void)setNavgationItems{
|
||||
[super setNavgationItems];
|
||||
self.navigationItem.title = self.model.title;
|
||||
}
|
||||
|
||||
-(void)initSubViews{
|
||||
self.page = 1;
|
||||
self.tableView.tableHeaderView = self.topView;
|
||||
[self.view addSubview:self.tableView];
|
||||
[self getDynamicList];
|
||||
}
|
||||
-(void)getDynamicList{
|
||||
MJWeakSelf
|
||||
[QXDynamicNetwork topicDynamicListWithTopic_id:self.model.topic_id page:self.page successBlock:^(NSArray<QXDynamicModel *> * _Nonnull list) {
|
||||
if (weakSelf.page == 1) {
|
||||
[weakSelf.dataArray removeAllObjects];
|
||||
}
|
||||
[weakSelf.dataArray addObjectsFromArray:list];
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
if (list.count == 0) {
|
||||
weakSelf.tableView.mj_footer.state = MJRefreshStateNoMoreData;
|
||||
}else{
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}
|
||||
[self.tableView reloadData];
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
[weakSelf.tableView.mj_header endRefreshing];
|
||||
[weakSelf.tableView.mj_footer endRefreshing];
|
||||
}];
|
||||
}
|
||||
#pragma mark - UITableViewDelegate,UITableViewDataSource
|
||||
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
|
||||
return self.dataArray.count;
|
||||
}
|
||||
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
|
||||
QXDynamicListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QXDynamicListCell" forIndexPath:indexPath];
|
||||
cell.selectionStyle = NO;
|
||||
cell.model = self.dataArray[indexPath.row];
|
||||
// SPTrendListModel *model = self.dataArray[indexPath.row];
|
||||
// cell.model = model;
|
||||
MJWeakSelf
|
||||
cell.onDeleteBlock = ^(QXDynamicModel * _Nonnull model) {
|
||||
[weakSelf.dataArray removeObject:model];
|
||||
[weakSelf.tableView reloadSection:indexPath.section withRowAnimation:(UITableViewRowAnimationAutomatic)];
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
-(UITableView *)tableView{
|
||||
if (!_tableView) {
|
||||
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight) style:UITableViewStylePlain];
|
||||
self.tableView.backgroundColor = [UIColor clearColor];
|
||||
self.tableView.delegate = self;
|
||||
self.tableView.dataSource = self;
|
||||
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
||||
[self.tableView registerNib:[UINib nibWithNibName:@"QXDynamicListCell" bundle:nil] forCellReuseIdentifier:@"QXDynamicListCell"];
|
||||
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
||||
self.tableView.estimatedRowHeight = 152;
|
||||
MJWeakSelf
|
||||
_tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
|
||||
weakSelf.page = 1;
|
||||
[weakSelf getDynamicList];
|
||||
}];
|
||||
_tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{
|
||||
weakSelf.page++;
|
||||
[weakSelf getDynamicList];
|
||||
}];
|
||||
}
|
||||
return _tableView;
|
||||
}
|
||||
-(QXToppicDynamicTopView *)topView{
|
||||
if (!_topView) {
|
||||
_topView = [[QXToppicDynamicTopView alloc] initWithModel:self.model];
|
||||
}
|
||||
return _topView;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user