Commit a7a8570c cgx

完成删除用户反馈并修复左滑删除按钮在iOS13系统及以上显示bug

1 个父辈 cb6adc91
......@@ -47,6 +47,8 @@ static int AlbumColumnCount = 4;
[self.view addSubview:self.commitBtn];
[self layoutUI];
[self getUnreadMessageRequest];
}
- (void)viewDidDisappear:(BOOL)animated {
......@@ -99,16 +101,6 @@ static int AlbumColumnCount = 4;
[self.feedTV endEditing:YES];
}
- (void)getUnreadMessageRequest {
[FeedbackRequestModel queryUserTotalReplysRequest:^(FeedbackRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
self.unreadCount = requestModel.unreadCount;
self.redLab.text = [NSString stringWithFormat:@"%d", self.unreadCount];
self.redLab.hidden = self.unreadCount == 0;
}
}];
}
- (void)deleteBtnClick:(UIButton *)sender {
[_selectedPhotos removeObjectAtIndex:sender.tag];
[_selectedAssets removeObjectAtIndex:sender.tag];
......@@ -257,6 +249,17 @@ static int AlbumColumnCount = 4;
}
}
#pragma mark - 获取我的反馈回复数据
- (void)getUnreadMessageRequest {
[FeedbackRequestModel queryUserTotalReplysRequest:^(FeedbackRequestModel * _Nonnull requestModel) {
if (requestModel.resCode == DSResCodeSuccess) {
self.unreadCount = requestModel.unreadCount;
self.redLab.text = [NSString stringWithFormat:@"%d", self.unreadCount];
self.redLab.hidden = self.unreadCount == 0;
}
}];
}
#pragma mark - 图片上传
- (void)uploadImgsWithPhotos:(NSArray<UIImage *> *)photos picker:(TZImagePickerController *)picker {
// 1、处理图片
......
......@@ -6,6 +6,7 @@
//
#import "FeedbackRequestModel.h"
#import "MyFeedModel.h"
@implementation FeedbackRequestModel
......@@ -31,9 +32,14 @@
NSString *argStr = [NSString stringWithFormat:@"query{%@(user_id:%d)}", api, user_id];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户反馈建议列表接口apiDic:%@", apiDic);
// 字典转模型
NSArray *resultArr = [apiDic valueForKey:@"result"];
NSMutableArray *tmpArr = [NSMutableArray array];
[resultArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSDictionary *listDic = obj;
MyFeedModel *feedModel = [MyFeedModel yy_modelWithDictionary:listDic];
[tmpArr addObject:feedModel];
}];
requestModel.adviceListArr = [tmpArr copy];
requestModel.resCode = DSResCodeSuccess;
completion(requestModel);
} failure:^(id _Nonnull failureInfo) {
......@@ -80,7 +86,7 @@
FeedbackRequestModel * requestModel = [[FeedbackRequestModel alloc] init];
NSString *api = @"query_user_total_replys";
NSString *argStr = [NSString stringWithFormat:@"query{%@}", api];
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:YES success:^(NSDictionary * _Nonnull apiDic) {
return [self httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户反馈数接口apiDic:%@", apiDic);
// 未读的回复数
int unreadCount = [apiDic[@"result"] intValue];
......
......@@ -8,6 +8,10 @@ static NSString *const cardRadiusCellIdentifier = @"cardRadiusCellIdentifier";
@interface MyFeedCell : UITableViewCell
@property (nonatomic, strong) MyFeedModel *model;
- (void)updateUI:(MyFeedModel *)model;
@end
NS_ASSUME_NONNULL_END
......@@ -2,6 +2,7 @@
@interface MyFeedCell ()
@property (nonatomic, strong) UIImageView *replyStatusIV;
@property (nonatomic, strong) UILabel *redLab;
@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *contentLab;
@property (nonatomic, strong) UILabel *createdDate;
......@@ -14,12 +15,11 @@
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.contentView addSubview:self.redLab];
[self.contentView addSubview:self.replyStatusIV];
[self.contentView addSubview:self.titleLab];
[self.contentView addSubview:self.createdDate];
[self.contentView addSubview:self.contentLab];
[self updateUI];
}
return self;
}
......@@ -46,16 +46,34 @@
}];
}
- (void)updateUI {
self.replyStatusIV.image = [UIImage imageNamed:@"waiting_reply"];
- (void)updateUI:(MyFeedModel *)model {
// 红点是指已回复了但用户未阅读
if (model.reply_status == 1 && model.read_status == 0) {
self.redLab.hidden = NO;
self.replyStatusIV.hidden = YES;
self.titleLab.text = @"新回复";
} else {
self.redLab.hidden = YES;
self.replyStatusIV.hidden = NO;
NSString *title = @"";
NSString *icon = @"";
if (model.reply_status == 0) {
title = @"待回复";
icon = @"waiting_reply";
} else if (model.reply_status == 1) {
title = @"已回复";
icon = @"done_reply";
}
self.titleLab.text = title;
self.replyStatusIV.image = [UIImage imageNamed:icon];
}
[self.titleLab sizeToFit];
self.createdDate.text = @"06-21 22:00";
self.createdDate.text = model.created_at;
[self.createdDate sizeToFit];
self.contentLab.text = @"睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠睡眠";
self.contentLab.text = model.content;
}
#pragma mark - lazy
......
......@@ -6,8 +6,10 @@
@end
@interface MyFeedListController : UIViewController
@property (nonatomic, weak) id<MyFeedListControllerDelegate> delegate;
- (instancetype)initWithDelegate:(id<MyFeedListControllerDelegate>)delegate;
@end
......@@ -25,16 +25,22 @@
self.view.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
[self.view addSubview:self.feedbackIV];
// WS(weakSelf);
// self.feedbackIV.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
// [weakSelf.feedbackIV.mj_header endRefreshing];
// }];
// [self.feedbackIV.mj_header beginRefreshing];
WS(weakSelf);
self.feedbackIV.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
[FeedbackRequestModel queryUserAdviceListWithCompletion:^(FeedbackRequestModel * _Nonnull requestModel) {
[weakSelf.feedbackIV.mj_header endRefreshing];
if (requestModel.resCode == DSResCodeSuccess) {
weakSelf.listData = requestModel.adviceListArr;
[weakSelf.feedbackIV reloadData];
}
}];
}];
[self.feedbackIV.mj_header beginRefreshing];
}
#pragma mark - UITableViewDelegate && UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
return self.listData.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
......@@ -57,19 +63,21 @@
return [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 7.5)];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyFeedCell *cell = [tableView dequeueReusableCellWithIdentifier:cardRadiusCellIdentifier];
MyFeedModel *model = self.listData[indexPath.row];
[cell updateUI:model];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// MyFeedModel *model = self.listData[indexPath.row];
// if (model.read_status == 0) {
// model.read_status = 1;
// if (self.delegate && [self.delegate respondsToSelector:@selector(didClickMessage)]) {
// [self.delegate didClickMessage];
// }
// }
MyFeedModel *model = self.listData[indexPath.row];
if (model.read_status == 0) {
model.read_status = 1;
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickMessage)]) {
[self.delegate didClickMessage];
}
}
FeedbackDetailController *detailVC = [FeedbackDetailController new];
[self.navigationController pushViewController:detailVC animated:YES];
......@@ -92,18 +100,27 @@
}
- (NSArray*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
NSMutableArray *mArr = [NSMutableArray arrayWithArray:self.listData];
MyFeedModel *model = self.listData[indexPath.row];
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"删除按钮宽度" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
// 删除反馈请求
[DSProgressHUD showProgressHUDWithInfo:@""];
[FeedbackRequestModel deleteAdviceFeedbackWithAdviceID:3 completion:^(FeedbackRequestModel * _Nonnull requestModel) {
[FeedbackRequestModel deleteAdviceFeedbackWithAdviceID:model.feed_id completion:^(FeedbackRequestModel * _Nonnull requestModel) {
[DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) {
[DSProgressHUD showToast:@"删除成功"];
[mArr removeObjectAtIndex:indexPath.row];
self.listData = [mArr copy];
[tableView reloadData];
}
}];
// 这句很重要,退出编辑模式,隐藏左滑菜单
[tableView setEditing:NO animated:YES];
}];
// 主动调用代理方法,防止快速滑动时显示原生
[self tableView:self.feedbackIV willBeginEditingRowAtIndexPath:indexPath];
return @[deleteAction];
}
......@@ -144,11 +161,6 @@
}
- (void)setupRowActionView:(UIView *)rowActionView {
CGRect frame = rowActionView.frame;
frame.origin.y += (7.5);
frame.size.height -= (15);
rowActionView.frame = frame;
rowActionView.dk_backgroundColorPicker = DKColorPickerWithKey(VCViewBG);
// 拿到原来的删除按钮
......@@ -156,7 +168,7 @@
oriDeleteBtn.hidden = YES;
// 自定义删除按钮
UIButton *cusDeleteBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, oriDeleteBtn.width - 15, oriDeleteBtn.height)];
UIButton *cusDeleteBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 7.5, oriDeleteBtn.width - 15, oriDeleteBtn.height - 15)];
[cusDeleteBtn cornerRadius:12];
cusDeleteBtn.dk_backgroundColorPicker = DKColorPickerWithColors(DSWhite, CornerViewDarkColor, DSWhite);
[cusDeleteBtn dk_setImage:DKImagePickerWithNames(@"delete_feed_icon", @"dk_delete_feed_icon", @"delete_feed_icon") forState:UIControlStateNormal];
......
{
"images" : [
{
"filename" : "done_reply.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "done_reply@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "done_reply@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!