增加换肤功能

This commit is contained in:
启星
2025-08-14 10:07:49 +08:00
parent f6964c1e89
commit 4f9318d98e
8789 changed files with 978530 additions and 2 deletions

View File

@@ -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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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-23&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;
// webpr
configuration.processPool = [[WKProcessPool alloc] init];
//, jsoc(OCURL)
WKUserContentController * UserContentController = [[WKUserContentController alloc]init];
//
configuration.suppressesIncrementalRendering = NO;
//
[UserContentController addScriptMessageHandler:self name:@"nativeHandler"];
configuration.preferences.javaScriptEnabled = YES;
configuration.preferences.javaScriptCanOpenWindowsAutomatically = YES;
configuration.userContentController = UserContentController;
// iOS9iOS8
if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) {
//
configuration.allowsAirPlayForMediaPlayback = YES;
// 线
configuration.allowsInlineMediaPlayback = YES;
// NOios8
_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

View File

@@ -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

View 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