Commit 9c1476c8 cgx

完成发布动态功能模块

1 个父辈 53296024
正在显示 22 个修改的文件 包含 422 行增加34 行删除
......@@ -176,6 +176,7 @@
D0A3BB9628D9B43700F58781 /* ArticleController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A3BB9528D9B43700F58781 /* ArticleController.m */; };
D0A3BB9928D9B76C00F58781 /* EvaluateController.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A3BB9828D9B76C00F58781 /* EvaluateController.m */; };
D0A3BB9C28D9BA3500F58781 /* EvaluateRequestModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A3BB9B28D9BA3500F58781 /* EvaluateRequestModel.m */; };
D0A3E10028E530330046EC84 /* InformCancelAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A3E0FF28E530330046EC84 /* InformCancelAlertView.m */; };
D0A72E39282B566200EED7BE /* HomeBasicCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E38282B566200EED7BE /* HomeBasicCell.m */; };
D0A72E3F282B89AD00EED7BE /* DSHomeView.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E3E282B89AD00EED7BE /* DSHomeView.m */; };
D0A72E42282B8BA600EED7BE /* CourseMusicCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D0A72E41282B8BA600EED7BE /* CourseMusicCell.m */; };
......@@ -610,6 +611,8 @@
D0A3BB9828D9B76C00F58781 /* EvaluateController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EvaluateController.m; sourceTree = "<group>"; };
D0A3BB9A28D9BA3500F58781 /* EvaluateRequestModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EvaluateRequestModel.h; sourceTree = "<group>"; };
D0A3BB9B28D9BA3500F58781 /* EvaluateRequestModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EvaluateRequestModel.m; sourceTree = "<group>"; };
D0A3E0FE28E530330046EC84 /* InformCancelAlertView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InformCancelAlertView.h; sourceTree = "<group>"; };
D0A3E0FF28E530330046EC84 /* InformCancelAlertView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = InformCancelAlertView.m; sourceTree = "<group>"; };
D0A72E37282B566200EED7BE /* HomeBasicCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeBasicCell.h; sourceTree = "<group>"; };
D0A72E38282B566200EED7BE /* HomeBasicCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeBasicCell.m; sourceTree = "<group>"; };
D0A72E3D282B89AD00EED7BE /* DSHomeView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DSHomeView.h; sourceTree = "<group>"; };
......@@ -1462,6 +1465,8 @@
isa = PBXGroup;
children = (
D030796628E3D92700ED96BF /* LikeButton */,
D0A3E0FE28E530330046EC84 /* InformCancelAlertView.h */,
D0A3E0FF28E530330046EC84 /* InformCancelAlertView.m */,
D02B7E5A28E2A28500218EF7 /* ComDynamicCell.h */,
D02B7E5B28E2A28500218EF7 /* ComDynamicCell.m */,
D0A3BB9028D95A2B00F58781 /* CommunityView.h */,
......@@ -1520,10 +1525,10 @@
D0A1C49128C2084B000975DC /* ArticleRequestModel.m */,
D0A3BB9A28D9BA3500F58781 /* EvaluateRequestModel.h */,
D0A3BB9B28D9BA3500F58781 /* EvaluateRequestModel.m */,
D070A78C28DF02DE0039C5A7 /* DynamicViewModel.h */,
D070A78D28DF02DE0039C5A7 /* DynamicViewModel.m */,
D02B7E6228E2D76D00218EF7 /* ComListViewModel.h */,
D02B7E6328E2D76D00218EF7 /* ComListViewModel.m */,
D070A78C28DF02DE0039C5A7 /* DynamicViewModel.h */,
D070A78D28DF02DE0039C5A7 /* DynamicViewModel.m */,
);
path = ViewModel;
sourceTree = "<group>";
......@@ -2488,6 +2493,7 @@
D06381A428D012420074515B /* SleepStoryController.m in Sources */,
D0F9AC542826563400FD7A3B /* MusicPlayerController.m in Sources */,
D0506B1528051ED400229278 /* SafeSleepModel.m in Sources */,
D0A3E10028E530330046EC84 /* InformCancelAlertView.m in Sources */,
D054CCB52830DE5600420DC4 /* NoisePlayerManager.m in Sources */,
D0874BBF2816E61000CECB3C /* RescuePlanView.m in Sources */,
D07DACA42810557D0067A1BF /* CGGeometry+RSKImageCropper.m in Sources */,
......
......@@ -8,12 +8,14 @@
#import "CommunityController.h"
#import "CommunityView.h"
#import "ComListViewModel.h"
#import "DynamicController.h"
#import "TestFlutterController.h"
@interface CommunityController () <CommunityViewDelegate>
@interface CommunityController () <CommunityViewDelegate, DynamicControllerDelegate>
@property (nonatomic, strong) CommunityView *communityView;
@property (nonatomic, strong) TestFlutterController *flutterEngine;
@property (nonatomic, assign) int offset;
@property (nonatomic, strong) NSURLSessionDataTask *likeDataTask;
@end
@implementation CommunityController
......@@ -26,11 +28,12 @@
[super viewDidLoad];
[self setupUI];
self.offset = 1;
}
#pragma mark - private
- (void)setupUI {
self.offset = 1;
self.edgesForExtendedLayout = UIRectEdgeNone;
UILabel *leftLab = [UILabel dkLabWithText:@"小梦社区" font:BoldFont(24.0)];
......@@ -95,7 +98,23 @@
return;
}
// 3、进入发布动态页面
[self.navigationController pushViewController:[NSClassFromString(@"DynamicController") new] animated:YES];
DynamicController *dyController = [DynamicController new];
dyController.delegate = self;
[self.navigationController pushViewController:dyController animated:YES];
}
- (void)didTapInformItem:(int)userID {
if (![LoginUtils getUserLoginData]) {
[LoginUtils jumpToLoginControllerWithTarget:self];
return;
}
// 弹出举报框
[self.communityView showInformCancelView];
}
- (void)didSubmitInformContent {
// 1、提交举报请求
}
- (void)didSelectItem:(NSIndexPath *)indexPath {
......@@ -122,7 +141,8 @@
[cell updateLikeUI];
// 2、更新点赞或取消点赞请求
[ComListViewModel userDynamicPraiseWithTalkID:comDynModel.dynamicID completion:^(ComListViewModel * _Nonnull requestModel) {
if (self.likeDataTask) { [self.likeDataTask cancel]; }
self.likeDataTask = [ComListViewModel userDynamicPraiseWithTalkID:comDynModel.dynamicID completion:^(ComListViewModel * _Nonnull requestModel) {
// 3、如果请求失败,延迟执行回退
if (requestModel.resCode != DSResCodeSuccess) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
......@@ -140,6 +160,11 @@
}];
}
#pragma mark - DynamicControllerDelegate
- (void)publishSuccessWithData:(id)model {
[self.communityView insertUserDyModel:model];
}
#pragma mark - lazy
- (CommunityView *)communityView {
if (!_communityView) {
......
......@@ -9,9 +9,13 @@
NS_ASSUME_NONNULL_BEGIN
@protocol DynamicControllerDelegate <NSObject>
- (void)publishSuccessWithData:(id)model;
@end
/// 动态发布页面
@interface DynamicController : UIViewController
@property (nonatomic, weak) id<DynamicControllerDelegate> delegate;
@end
NS_ASSUME_NONNULL_END
......@@ -8,6 +8,7 @@
#import "DynamicController.h"
#import "DynamicView.h"
#import "DynamicViewModel.h"
#import "FeedbackRequestModel.h"
#import "TZImagePickerController.h"
// 最大图片上传数量
......@@ -85,6 +86,7 @@ static int AlbumColumnCount = 4;
}
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithSelectedAssets:self.dynamicVM.selectedAssets selectedPhotos:self.dynamicVM.selectedPhotos index:(indexPath.row - 1)];
__weak TZImagePickerController * weakPicker = imagePickerVc;
imagePickerVc.maxImagesCount = MaxUpdateImgCount;
imagePickerVc.allowPickingOriginalPhoto = NO;
imagePickerVc.allowPickingMultipleVideo = NO;
......@@ -92,10 +94,11 @@ static int AlbumColumnCount = 4;
imagePickerVc.isSelectOriginalPhoto = self.isSelectOriginalPhoto;
WS(weakSelf);
[imagePickerVc setDidFinishPickingPhotosHandle:^(NSArray<UIImage *> *photos, NSArray *assets, BOOL isSelectOriginalPhoto) {
self.dynamicVM.selectedPhotos = [NSMutableArray arrayWithArray:photos];
self.dynamicVM.selectedAssets = [NSMutableArray arrayWithArray:assets];
self.isSelectOriginalPhoto = isSelectOriginalPhoto;
weakSelf.dynamicVM.selectedPhotos = [NSMutableArray arrayWithArray:photos];
weakSelf.dynamicVM.selectedAssets = [NSMutableArray arrayWithArray:assets];
weakSelf.isSelectOriginalPhoto = isSelectOriginalPhoto;
[weakSelf.dynamicView refreshImageContentView];
[weakPicker dismissViewControllerAnimated:YES completion:nil];
}];
[self presentViewController:imagePickerVc animated:YES completion:nil];
}
......@@ -107,7 +110,18 @@ static int AlbumColumnCount = 4;
}
- (void)publishDynamic {
[DSProgressHUD showProgressHUDWithInfo:@""];
[self.dynamicVM publishDynamicWithCompletion:^(DynamicViewModel * _Nonnull viewModel) {
[DSProgressHUD dissmissProgressHUD];
if (viewModel.resCode == DSResCodeSuccess) {
if (self.delegate && [self.delegate respondsToSelector:@selector(publishSuccessWithData:)]) {
[self.delegate publishSuccessWithData:viewModel.myDynModel];
}
[self.navigationController popViewControllerAnimated:YES];
} else {
[DSProgressHUD showToast:viewModel.errMessage];
}
}];
}
#pragma mark - TZImagePickerControllerDelegate
......@@ -145,16 +159,14 @@ static int AlbumColumnCount = 4;
}
[mstr appendString:@"]"];
// 2、上传图片
// [DSProgressHUD showProgressHUDWithInfo:@""];
// [FeedbackRequestModel uploadBulkImagesWithImgStr:[mstr copy] completion:^(FeedbackRequestModel * _Nonnull requestModel) {
// [DSProgressHUD dissmissProgressHUD];
// if (requestModel.resCode == DSResCodeSuccess) {
// // 存储图片上传成功后返回的urls
// self.result_imgurls = requestModel.result_imgurls;
// [picker dismissViewControllerAnimated:YES completion:nil];
// }
// }];
[picker dismissViewControllerAnimated:YES completion:nil];
[DSProgressHUD showProgressHUDWithInfo:@""];
[FeedbackRequestModel uploadBulkImagesWithImgStr:[mstr copy] completion:^(FeedbackRequestModel * _Nonnull requestModel) {
[DSProgressHUD dissmissProgressHUD];
if (requestModel.resCode == DSResCodeSuccess) {
self.dynamicVM.imgs_url = [requestModel.result_imgurls stringByReplacingOccurrencesOfString:@"," withString:@"|"];
[picker dismissViewControllerAnimated:YES completion:nil];
}
}];
}
#pragma mark - 品牌模式
......
......@@ -8,6 +8,7 @@
#import <UIKit/UIKit.h>
#import "ComDynModel.h"
typedef void(^TapInformBlock)(void);
typedef void(^TapLikeBlock)(void);
typedef void(^TapRemarkBlock)(void);
......@@ -17,6 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface ComDynamicCell : UITableViewCell
@property (nonatomic, strong) ComDynModel *model;
@property (nonatomic, copy) TapInformBlock tapInformBlock;
@property (nonatomic, copy) TapLikeBlock tapLikeBlock;
@property (nonatomic, copy) TapRemarkBlock tapRemarkBlock;
......
......@@ -49,6 +49,7 @@
[self.userNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userIcon.mas_right).offset(14);
make.top.equalTo(self.userIcon);
make.right.equalTo(self.informBtn.mas_left).offset(-14);
}];
[self.timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.userNameLab);
......@@ -174,10 +175,9 @@
- (UIButton *)informBtn {
if (!_informBtn) {
_informBtn = [UIButton btnWithTitle:@"•••" font:BoldFont(15)];
_informBtn.tag = 1;
[_informBtn dk_setTitleColorPicker:DKColorPickerWithColors(MainTextColor, ColorFromHex(0xE8E9E9), DSWhite) forState:UIControlStateNormal];
[_informBtn addTouchUpInsideHandler:^(NSInteger tag) {
}];
[_informBtn addTarget:self action:@selector(informOrlikeOrRemarkAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _informBtn;
}
......@@ -198,8 +198,10 @@
return _contentLab;
}
- (void)likeOrRemarkAction:(UIButton *)sender {
- (void)informOrlikeOrRemarkAction:(UIButton *)sender {
if (sender.tag == 1) {
if (self.tapInformBlock) { self.tapInformBlock(); }
} else if (sender.tag == 2) {
if (self.tapLikeBlock) { self.tapLikeBlock(); }
} else {
if (self.tapRemarkBlock) { self.tapRemarkBlock(); }
......@@ -209,8 +211,8 @@
- (LikeButton *)likeBtn {
if (!_likeBtn) {
_likeBtn = [[LikeButton alloc] initWithNormalImg:nil selectedImg:nil];
_likeBtn.tag = 1;
[_likeBtn addTarget:self action:@selector(likeOrRemarkAction:) forControlEvents:UIControlEventTouchUpInside];
_likeBtn.tag = 2;
[_likeBtn addTarget:self action:@selector(informOrlikeOrRemarkAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _likeBtn;
}
......@@ -218,11 +220,11 @@
- (UIButton *)remarkCountBtn {
if (!_remarkCountBtn) {
_remarkCountBtn = [UIButton btnWithTitle:@"0" font:SysFont(12)];
_remarkCountBtn.tag = 2;
_remarkCountBtn.tag = 3;
[_remarkCountBtn dk_setTitleColorPicker:DKColorPickerWithColors(SmallTextColor, DSWhite, DSWhite) forState:UIControlStateNormal];
[_remarkCountBtn setImage:[UIImage imageNamed:@"ic_shequ_pinlun"] forState:UIControlStateNormal];
_remarkCountBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 2, 0, 0);
[_remarkCountBtn addTarget:self action:@selector(likeOrRemarkAction:) forControlEvents:UIControlEventTouchUpInside];
[_remarkCountBtn addTarget:self action:@selector(informOrlikeOrRemarkAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _remarkCountBtn;
}
......
......@@ -29,6 +29,13 @@ NS_ASSUME_NONNULL_BEGIN
/// @param comDynModel 动态数据model
/// @param cell cell
- (void)didTapLikeItem:(ComDynModel *)comDynModel cell:(ComDynamicCell *)cell;
/// 点击举报
/// @param userID 用户ID
- (void)didTapInformItem:(int)userID;
/// 提交举报内容
- (void)didSubmitInformContent;
@end
/// 社区主视图
......@@ -41,9 +48,16 @@ NS_ASSUME_NONNULL_BEGIN
/// 更新社区动态
- (void)updateCommunityMoments:(BOOL)loadMore listArr:(NSArray *)listArr;
/// 临时插入用户动态数据
/// @param dyModel dyModel
- (void)insertUserDyModel:(ComDynModel *)dyModel;
/// 结束加载动画
- (void)endRefreshing:(BOOL)loadMore;
/// 显示举报、取消弹框
- (void)showInformCancelView;
@end
NS_ASSUME_NONNULL_END
......@@ -6,11 +6,13 @@
//
#import "CommunityView.h"
#import "InformCancelAlertView.h"
@interface CommunityView () <UITableViewDelegate, UITableViewDataSource>
@interface CommunityView () <UITableViewDelegate, UITableViewDataSource, InformCancelAlertViewDelegate>
@property (nonatomic, strong) UIView *headView;
@property (nonatomic, strong) UITableView *listView;
@property (nonatomic, strong) NSMutableArray *listArr;
@property (nonatomic, strong) InformCancelAlertView *informCancelView;
@end
@implementation CommunityView
......@@ -51,10 +53,21 @@
[self.listView reloadData];
}
- (void)insertUserDyModel:(ComDynModel *)dyModel {
if (!dyModel) { return; }
// 用户发的说说临时插入到动态列表第一条
[self.listArr insertObject:dyModel atIndex:0];
[self.listView reloadData];
}
- (void)endRefreshing:(BOOL)loadMore {
loadMore ? [self.listView.mj_footer endRefreshing] : [self.listView.mj_header endRefreshing];
}
- (void)showInformCancelView {
[self.informCancelView display];
}
#pragma mark - Action
- (void)tapAction:(UITapGestureRecognizer *)tapGR {
if (self.delegate && [self.delegate respondsToSelector:@selector(tapCommunityHeaderModule:)]) {
......@@ -104,6 +117,11 @@
cell.model = model;
WS(weakSelf);
__weak ComDynamicCell * weakCell = (ComDynamicCell *)cell;
cell.tapInformBlock = ^{
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(didTapInformItem:)]) {
[weakSelf.delegate didTapInformItem:model.userID];
}
};
cell.tapLikeBlock = ^{
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(didTapLikeItem:cell:)]) {
[weakSelf.delegate didTapLikeItem:model cell:weakCell];
......@@ -121,6 +139,13 @@
}
}
#pragma mark - InformCancelAlertViewDelegate
- (void)submitInformContent {
if (self.delegate && [self.delegate respondsToSelector:@selector(didSubmitInformContent)]) {
[self.delegate didSubmitInformContent];
}
}
#pragma mark - lazy
- (UITableView *)listView {
if (!_listView) {
......@@ -132,6 +157,7 @@
_listView.separatorStyle = UITableViewCellSeparatorStyleNone;
_listView.tableHeaderView = self.headView;
[_listView registerClass:[ComDynamicCell class] forCellReuseIdentifier:NSStringFromClass([ComDynamicCell class])];
_listView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
WS(weakSelf);
_listView.mj_header = [DSGifHeader headerWithRefreshingBlock:^{
......@@ -169,6 +195,13 @@
return _headView;
}
- (InformCancelAlertView *)informCancelView {
if (!_informCancelView) {
_informCancelView = [[InformCancelAlertView alloc] initWithDelegate:self];
}
return _informCancelView;
}
- (UIImageView *)plateWithFrame:(CGRect)frame title:(NSString *)title desc:(NSString *)desc imgName:(NSString *)imgName tag:(NSInteger)tag {
UIImageView *imgView = [[UIImageView alloc] initWithFrame:frame];
[imgView dk_setAlphaPicker:DKAlphaPickerWithAlphas(1.0, .5, .5)];
......
......@@ -58,8 +58,12 @@
}
- (void)publishAction {
if (self.delegate && [self.delegate respondsToSelector:@selector(publishDynamic)]) {
[self.delegate publishDynamic];
if (self.dynamicVM.selectedPhotos.count || self.textView.text.length) {
if (self.delegate && [self.delegate respondsToSelector:@selector(publishDynamic)]) {
[self.delegate publishDynamic];
}
} else {
[DSProgressHUD showToast:@"请输入发布内容"];
}
}
......@@ -100,11 +104,13 @@
NSString *changeStr = [NSString stringWithFormat:@"%d", changeLength];
NSString *fixStr = @"/200";
NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@%@", changeStr, fixStr]];
UIColor *changeColor = changeLength > 400 ? ColorFromHex(0xF04B77) : BrandColor;
UIColor *changeColor = changeLength > 200 ? ColorFromHex(0xF04B77) : BrandColor;
[attStr addAttribute:NSForegroundColorAttributeName value:changeColor range:NSMakeRange(0, changeStr.length)];
UIColor *fixColor = [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? SmallTextColor : DarkTextColor;
[attStr addAttribute:NSForegroundColorAttributeName value:fixColor range:NSMakeRange(changeStr.length, fixStr.length)];
self.wordLimitLab.attributedText = attStr;
self.dynamicVM.content = self.textView.text;
}
#pragma mark - UICollectionViewDataSource && UICollectionViewDelegate
......
//
// InformCancelAlertView.h
// DreamSleep
//
// Created by peter on 2022/9/29.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol InformCancelAlertViewDelegate <NSObject>
/// 提交举报内容
- (void)submitInformContent;
@end
/// 举报、取消弹框
@interface InformCancelAlertView : UIView
@property (nonatomic, weak) id<InformCancelAlertViewDelegate> delegate;
- (instancetype)initWithDelegate:(id<InformCancelAlertViewDelegate>)delegate;
- (void)display;
@end
NS_ASSUME_NONNULL_END
//
// InformCancelAlertView.m
// DreamSleep
//
// Created by peter on 2022/9/29.
//
#import "InformCancelAlertView.h"
@interface InformCancelAlertView ()
@property (nonatomic, strong) UIButton *informBtn;
@property (nonatomic, strong) UIButton *cancelBtn;
@property (nonatomic, strong) UIView *informDetailView;
@end
@implementation InformCancelAlertView
- (instancetype)initWithDelegate:(id<InformCancelAlertViewDelegate>)delegate {
if (self = [super initWithFrame:[UIScreen mainScreen].bounds]) {
_delegate = delegate;
self.backgroundColor = ColorFromHexA(0x161E38, .6);
UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
[self addGestureRecognizer:tapGR];
[self addSubview:self.informBtn];
[self addSubview:self.cancelBtn];
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self).offset(15);
make.right.equalTo(self).offset(-15);
make.bottom.equalTo(self).offset(-58);
make.height.equalTo(@40);
}];
[self.informBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.equalTo(self.cancelBtn);
make.bottom.equalTo(self.cancelBtn.mas_top).offset(-20);
make.centerX.equalTo(self);
}];
}
return self;
}
- (void)display {
self.informBtn.hidden = NO;
self.cancelBtn.hidden = NO;
self.informDetailView.hidden = YES;
[DSKeyWindow addSubview:self];
}
- (void)tapAction:(UITapGestureRecognizer *)gesture {
if (!CGRectContainsPoint(self.informDetailView.frame, [gesture locationInView:self])) {
[self dismiss];
}
}
- (void)dismiss {
[self removeFromSuperview];
}
- (void)tapInformBtn {
self.informBtn.hidden = YES;
self.cancelBtn.hidden = YES;
self.informDetailView.hidden = NO;
[self addSubview:self.informDetailView];
[self.informDetailView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.equalTo(self);
make.size.mas_equalTo(CGSizeMake(280, 291));
}];
}
#pragma mark - lazy
- (UIButton *)informBtn {
if (!_informBtn) {
_informBtn = [UIButton dkBtnTitle:@"举报" font:BoldFont(15)];
[_informBtn cornerRadius:12];
_informBtn.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
[_informBtn addTarget:self action:@selector(tapInformBtn) forControlEvents:UIControlEventTouchUpInside];
}
return _informBtn;
}
- (UIButton *)cancelBtn {
if (!_cancelBtn) {
_cancelBtn = [UIButton dkBtnTitle:@"取消" font:BoldFont(15)];
[_cancelBtn cornerRadius:12];
_cancelBtn.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
[_cancelBtn addTarget:self action:@selector(dismiss) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelBtn;
}
- (UIView *)informDetailView {
if (!_informDetailView) {
_informDetailView = [UIView new];
[_informDetailView cornerRadius:24];
_informDetailView.dk_backgroundColorPicker = DKColorPickerWithKey(TabBarBG);
UILabel *titleLab = [UILabel dkLabWithText:@"举报原因" font:BoldFont(16)];
titleLab.textAlignment = NSTextAlignmentCenter;
[_informDetailView addSubview:titleLab];
NSArray *itemNames = @[@"色情低俗", @"广告骚扰", @"政治宗教", @"虚假欺骗", @"违禁内容", @"其他原因"];
NSMutableArray *itemBtns = [NSMutableArray array];
for (int idx = 0; idx < itemNames.count; idx++) {
UIButton *itemBtn = [UIButton dkBtnTitle:itemNames[idx] font:SysFont(15)];
__weak UIButton * weakBtn = itemBtn;
[itemBtn dk_setImage:DKImagePickerWithNames(@"ic_ai_jianyi_unsel", @"ic_ai_jianyi_unsel", @"ic_ai_jianyi_unsel") forState:UIControlStateNormal];
[itemBtn dk_setImage:DKImagePickerWithNames(@"ic_ai_jianyi_sel", @"ic_ai_jianyi_sel", @"ic_ai_jianyi_sel") forState:UIControlStateSelected];
itemBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 14, 0, 0);
[itemBtn addTouchUpInsideHandler:^(NSInteger tag) {
weakBtn.selected = !weakBtn.selected;
}];
[_informDetailView addSubview:itemBtn];
[itemBtns addObject:itemBtn];
}
[titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_informDetailView);
make.top.equalTo(_informDetailView).offset(20);
}];
[itemBtns mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedSpacing:13 leadSpacing:60 tailSpacing:20];
[itemBtns mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(_informDetailView);
make.width.mas_equalTo(100);
}];
WS(weakSelf);
UIButton *submitBtn = [UIButton btnWithTitle:@"提交" titleColor:BrandColor font:BoldFont(14)];
[submitBtn addTouchUpInsideHandler:^(NSInteger tag) {
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(submitInformContent)]) {
[weakSelf.delegate submitInformContent];
}
}];
[_informDetailView addSubview:submitBtn];
[submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(titleLab);
make.right.equalTo(_informDetailView).offset(-20);
}];
}
return _informDetailView;
}
@end
......@@ -6,12 +6,41 @@
//
#import "DSNetworkTool.h"
#import "ComDynModel.h"
NS_ASSUME_NONNULL_BEGIN
/// 动态相关viewModel
@interface DynamicViewModel : DSNetworkTool
@property (nonatomic, strong) NSMutableArray *selectedPhotos;
@property (nonatomic, strong) NSMutableArray *selectedAssets;
/// 动态文本内容
@property (nonatomic, copy) NSString *content;
/// 动态图片,最多支持三张图片,采用|分隔
@property (nonatomic, copy) NSString *imgs_url;
/// 用户自己发布的动态数据
@property (nonatomic, strong) ComDynModel *myDynModel;
/*
删除操作选项类别
dynamic:删除动态 comment:删除评论 reply:删除回复
*/
@property (nonatomic, copy) NSString *oper_type;
/*
被删除对象id
动态Id 评论Id 回复Id
*/
@property (nonatomic, assign) int delete_id;
/// 发布动态接口
/// @param completion 完成回调
- (NSURLSessionDataTask *)publishDynamicWithCompletion:(void (^)(DynamicViewModel *viewModel))completion;
/// 用户-删除动态,评论,回复接口
/// @param completion completion
- (NSURLSessionDataTask *)communityDeleteOperationWithCompletion:(void (^)(DynamicViewModel *viewModel))completion;
@end
NS_ASSUME_NONNULL_END
......@@ -13,8 +13,41 @@
if (self = [super init]) {
self.selectedPhotos = [NSMutableArray array];
self.selectedAssets = [NSMutableArray array];
self.content = @"";
self.imgs_url = @"";
}
return self;
}
- (NSURLSessionDataTask *)publishDynamicWithCompletion:(void (^)(DynamicViewModel *viewModel))completion {
NSString *api = @"publish_dynamic_data";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(content:\"%@\",imgs_url:\"%@\")}", api, self.content, self.imgs_url];
return [DynamicViewModel httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户发布动态接口apiDic:%@", apiDic);
NSDictionary *resultDic = apiDic[@"result"];
self.myDynModel = [ComDynModel yy_modelWithDictionary:resultDic];
self.resCode = DSResCodeSuccess;
completion(self);
} failure:^(id _Nonnull failureInfo) {
self.resCode = [failureInfo[@"errorCode"] integerValue];
self.errMessage = failureInfo[@"errMessage"];
completion(self);
}];
}
- (NSURLSessionDataTask *)communityDeleteOperationWithCompletion:(void (^)(DynamicViewModel *viewModel))completion {
NSString *api = @"community_delete_operation";
NSString *argStr = [NSString stringWithFormat:@"mutation{%@(oper_type:%@,delete_id:%d)}", api, self.oper_type, self.delete_id];
return [DynamicViewModel httpPostBodyRequestWithAPI:api params:@{@"query" : argStr} view:nil hasNetActivity:YES loadingInfo:nil hasFailInfo:NO success:^(NSDictionary * _Nonnull apiDic) {
DSLog(@"用户删除动态、评论、回复接口apiDic:%@", apiDic);
self.resCode = DSResCodeSuccess;
completion(self);
} failure:^(id _Nonnull failureInfo) {
self.resCode = [failureInfo[@"errorCode"] integerValue];
self.errMessage = failureInfo[@"errMessage"];
completion(self);
}];
}
@end
......@@ -180,6 +180,7 @@ static int AlbumColumnCount = 4;
}
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithSelectedAssets:_selectedAssets selectedPhotos:_selectedPhotos index:(indexPath.row - 1)];
__weak TZImagePickerController * weakPicker = imagePickerVc;
imagePickerVc.maxImagesCount = MaxUpdateImgCount;
imagePickerVc.allowPickingOriginalPhoto = NO;
imagePickerVc.allowPickingMultipleVideo = NO;
......@@ -191,6 +192,7 @@ static int AlbumColumnCount = 4;
self->_selectedAssets = [NSMutableArray arrayWithArray:assets];
self->_isSelectOriginalPhoto = isSelectOriginalPhoto;
[weakSelf.imgCollectionView reloadData];
[weakPicker dismissViewControllerAnimated:YES completion:nil];
}];
[self presentViewController:imagePickerVc animated:YES completion:nil];
}
......
{
"images" : [
{
"filename" : "ic_ai_jianyi_sel.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_ai_jianyi_sel@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_ai_jianyi_sel@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "ic_ai_jianyi_unsel.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "ic_ai_jianyi_unsel@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "ic_ai_jianyi_unsel@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!