小说绘上架版本
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// WXYZ_FeedbackAddCollectionViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_FeedbackAddCollectionViewCell : UICollectionViewCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// WXYZ_FeedbackAddCollectionViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_FeedbackAddCollectionViewCell.h"
|
||||
|
||||
@implementation WXYZ_FeedbackAddCollectionViewCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.backgroundColor = kGrayViewColor;
|
||||
|
||||
UIImageView *addImage = [[UIImageView alloc] init];
|
||||
addImage.image = [UIImage imageNamed:@"public_rack_add"];
|
||||
[self addSubview:addImage];
|
||||
|
||||
[addImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.centerY.mas_equalTo(self.mas_centerY);
|
||||
make.width.height.mas_equalTo(self.mas_width).multipliedBy(0.3);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// WXYZ_FeedbackCollectionViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "WXYZ_FeedbackPhotoModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_FeedbackCollectionViewCell : UICollectionViewCell
|
||||
|
||||
@property (nonatomic, strong) WXYZ_FeedbackPhotoModel *photoModel;
|
||||
|
||||
@property (nonatomic, strong) UIImage *uploadImage;
|
||||
|
||||
@property (nonatomic, strong) UIImageView *feedbackImage;
|
||||
|
||||
@property (nonatomic, assign) NSInteger cellIndex;
|
||||
|
||||
@property (nonatomic, copy) void(^deleteImageBlock)(NSInteger index);
|
||||
|
||||
@property (nonatomic, copy) void(^finishedUploadBlock)(NSString *img);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// WXYZ_FeedbackCollectionViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_FeedbackCollectionViewCell.h"
|
||||
#import "WXYZ_FeedbackPhotoManager.h"
|
||||
|
||||
@interface WXYZ_FeedbackCollectionViewCell ()
|
||||
|
||||
@property (nonatomic, strong) UIActivityIndicatorView *activityView;
|
||||
|
||||
@property (nonatomic, strong) UIButton *closeButton;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_FeedbackCollectionViewCell
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self createSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
self.feedbackImage = [[UIImageView alloc] init];
|
||||
self.feedbackImage.contentMode = UIViewContentModeScaleAspectFill;
|
||||
self.feedbackImage.clipsToBounds = YES;
|
||||
self.feedbackImage.image = HoldImage;
|
||||
[self addSubview:self.feedbackImage];
|
||||
|
||||
[self.feedbackImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self);
|
||||
}];
|
||||
|
||||
self.activityView = [[UIActivityIndicatorView alloc] init];
|
||||
self.activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
|
||||
self.activityView.hidesWhenStopped = YES;
|
||||
[self addSubview:self.activityView];
|
||||
|
||||
[self.activityView startAnimating];
|
||||
|
||||
[self.activityView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
make.centerY.mas_equalTo(self.mas_centerY);
|
||||
make.width.height.mas_equalTo(30);
|
||||
}];
|
||||
|
||||
self.closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
self.closeButton.hidden = YES;
|
||||
self.closeButton.adjustsImageWhenHighlighted = NO;
|
||||
[self.closeButton setImageEdgeInsets:UIEdgeInsetsMake(0, 10, 10, 0)];
|
||||
[self.closeButton setImage:[UIImage imageNamed:@"feedback_photo_delete"] forState:UIControlStateNormal];
|
||||
[self.closeButton addTarget:self action:@selector(deleteClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:self.closeButton];
|
||||
|
||||
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(self.mas_right);
|
||||
make.top.mas_equalTo(self.mas_top);
|
||||
make.width.height.mas_equalTo(self.mas_width).multipliedBy(0.3);
|
||||
}];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)setPhotoModel:(WXYZ_FeedbackPhotoModel *)photoModel
|
||||
{
|
||||
_photoModel = photoModel;
|
||||
|
||||
if (photoModel.show_img.length > 0) {
|
||||
WS(weakSelf)
|
||||
[self.feedbackImage setImageWithURL:[NSURL URLWithString:photoModel.show_img] placeholder:HoldImage options:YYWebImageOptionSetImageWithFadeAnimation completion:^(UIImage * _Nullable image, NSURL * _Nonnull url, YYWebImageFromType from, YYWebImageStage stage, NSError * _Nullable error) {
|
||||
[weakSelf.activityView stopAnimating];
|
||||
weakSelf.closeButton.hidden = NO;
|
||||
}];
|
||||
} else {
|
||||
self.feedbackImage.image = HoldImage;
|
||||
[self.activityView startAnimating];
|
||||
self.closeButton.hidden = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteClick
|
||||
{
|
||||
[[WXYZ_FeedbackPhotoManager sharedManager] deletePhotoWithPhotoModel:self.photoModel];
|
||||
}
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// WXYZ_FeedbackContactTableViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_FeedbackContactTableViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic, copy) void(^contactDidChange)(NSString *contactString);
|
||||
|
||||
@property (nonatomic, copy) void(^willBeginEditing)(void);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// WXYZ_FeedbackContactTableViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_FeedbackContactTableViewCell.h"
|
||||
|
||||
@interface WXYZ_FeedbackContactTableViewCell () <UITextFieldDelegate>
|
||||
{
|
||||
UITextField *textField;
|
||||
}
|
||||
|
||||
@property (nonatomic, copy) NSString *contactString;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_FeedbackContactTableViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
textField = [[UITextField alloc] init];
|
||||
textField.backgroundColor = [UIColor clearColor];
|
||||
textField.font = kMainFont;
|
||||
textField.delegate = self;
|
||||
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||||
textField.textColor = kBlackColor;
|
||||
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:TFLocalizedString(@"邮箱/手机号")];
|
||||
[attributedString setAttributes:@{NSFontAttributeName:kMainFont, NSForegroundColorAttributeName:kColorRGBA(199, 199, 205, 1)} range:NSMakeRange(0, attributedString.length)];
|
||||
textField.attributedPlaceholder = attributedString;
|
||||
[self.contentView addSubview:textField];
|
||||
|
||||
[textField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - 2 * kMargin);
|
||||
make.height.mas_equalTo(KCellHeight);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
|
||||
{
|
||||
if ([string isEqualToString:@""]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (textField.text.length >= 30) {
|
||||
textField.text = [textField.text substringToIndex:30];
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (self.contactDidChange) {
|
||||
self.contactDidChange(textField.text);
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
|
||||
{
|
||||
if (self.willBeginEditing) {
|
||||
self.willBeginEditing();
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// WXYZ_FeedbackPhotoManager.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/28.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "WXYZ_FeedbackPhotoModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_FeedbackPhotoManager : NSObject
|
||||
|
||||
@property (nonatomic, assign, readonly) BOOL isUploading;
|
||||
|
||||
@property (nonatomic, copy) void(^deletePhotoBlock)(WXYZ_FeedbackPhotoModel *photoModel);
|
||||
|
||||
interface_singleton
|
||||
|
||||
- (void)addPhotoImage:(UIImage *)image complete:(void(^)(WXYZ_FeedbackPhotoModel *photoModel))completeBlock;
|
||||
|
||||
- (void)deletePhotoWithPhotoModel:(WXYZ_FeedbackPhotoModel *)photoModel;
|
||||
|
||||
- (void)removeAllPhotoImageWithPhotoArray:(NSArray *)dataSources;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// WXYZ_FeedbackPhotoManager.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/28.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_FeedbackPhotoManager.h"
|
||||
|
||||
@interface WXYZ_FeedbackPhotoManager ()
|
||||
|
||||
@property (nonatomic, strong) NSMutableSet *uploadSet;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_FeedbackPhotoManager
|
||||
|
||||
implementation_singleton(WXYZ_FeedbackPhotoManager)
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
self.uploadSet = [NSMutableSet set];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)addPhotoImage:(UIImage *)image complete:(void(^)(WXYZ_FeedbackPhotoModel *photoModel))completeBlock
|
||||
{
|
||||
NSString *imageBase64 = [TFViewHelper getBase64StringWithImageData:UIImagePNGRepresentation(image)];
|
||||
if (imageBase64.length == 0 || !imageBase64) {
|
||||
if (completeBlock) {
|
||||
completeBlock(nil);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
[self.uploadSet addObject:@"upload"];
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Upload_Image parameters:@{@"image":imageBase64} model:WXYZ_FeedbackPhotoModel.class success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
!completeBlock ?: completeBlock(t_model);
|
||||
} else {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"图片上传失败")];
|
||||
!completeBlock ?: completeBlock(nil);
|
||||
}
|
||||
|
||||
[weakSelf.uploadSet removeObject:[weakSelf.uploadSet anyObject]];
|
||||
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
|
||||
[TFPromptManager showPromptWithError:error defaultText:nil];
|
||||
// [weakSelf.uploadSet removeObject:[weakSelf.uploadSet anyObject]];
|
||||
!completeBlock ?: completeBlock(nil);
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)isUploading
|
||||
{
|
||||
return self.uploadSet.count > 0;
|
||||
}
|
||||
|
||||
- (void)deletePhotoWithPhotoModel:(WXYZ_FeedbackPhotoModel *)photoModel
|
||||
{
|
||||
if (photoModel.show_img.length <= 0) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"图片删除失败")];
|
||||
return;
|
||||
}
|
||||
|
||||
[self removeAllPhotoImageWithPhotoArray:@[photoModel]];
|
||||
|
||||
if (photoModel) {
|
||||
if (self.deletePhotoBlock) {
|
||||
self.deletePhotoBlock(photoModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)removeAllPhotoImageWithPhotoArray:(NSArray *)dataSources
|
||||
{
|
||||
[self.uploadSet removeAllObjects];
|
||||
|
||||
if (dataSources.count <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableArray *imgs = [NSMutableArray arrayWithCapacity:3];
|
||||
for (WXYZ_FeedbackPhotoModel *t_model in dataSources) {
|
||||
if (t_model.img) {
|
||||
[imgs addObject:t_model.img];
|
||||
}
|
||||
}
|
||||
|
||||
[TFNetworkTools POST:Delete_Upload_Image parameters:@{@"image":[imgs componentsJoinedByString:@"||"]} model:nil success:nil failure:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// WXYZ_FeedbackPhotoModel.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/28.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_FeedbackPhotoModel : NSObject
|
||||
|
||||
@property (nonatomic, copy) NSString *img; // 图片相对地址,这个值传递保存
|
||||
|
||||
@property (nonatomic, copy) NSString *show_img; // 图片显示地址
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// WXYZ_FeedbackPhotoModel.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/28.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_FeedbackPhotoModel.h"
|
||||
|
||||
@implementation WXYZ_FeedbackPhotoModel
|
||||
|
||||
@end
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// WXYZ_FeedbackPhotoTableViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
#import "WXYZ_ImagePicker.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_FeedbackPhotoTableViewCell : TFBasicTableViewCell <DPImagePickerDelegate, UICollectionViewDelegate, UICollectionViewDataSource>
|
||||
|
||||
@property (nonatomic, copy) void(^operationPhotosBlock)(NSMutableArray *photosSource);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
//
|
||||
// WXYZ_FeedbackPhotoTableViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_FeedbackPhotoTableViewCell.h"
|
||||
#import "WXYZ_FeedbackAddCollectionViewCell.h"
|
||||
#import "WXYZ_FeedbackCollectionViewCell.h"
|
||||
#import "TFPhotoBrowser.h"
|
||||
#import "WXYZ_FeedbackPhotoManager.h"
|
||||
#import "NSObject+Observer.h"
|
||||
|
||||
@interface WXYZ_FeedbackPhotoTableViewCell ()
|
||||
|
||||
@property (nonatomic, strong) NSMutableArray *photosSource;
|
||||
|
||||
@property (nonatomic, strong) UICollectionView *mainCollectionView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_FeedbackPhotoTableViewCell
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
self.photosSource = [NSMutableArray array];
|
||||
|
||||
UICollectionViewFlowLayout *mainCollectionViewFlowLayout = [[UICollectionViewFlowLayout alloc] init];
|
||||
mainCollectionViewFlowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
||||
mainCollectionViewFlowLayout.minimumLineSpacing = kHalfMargin;
|
||||
mainCollectionViewFlowLayout.minimumInteritemSpacing = 0;
|
||||
CGFloat width = (SCREEN_WIDTH - (2 * kHalfMargin) - (2 * mainCollectionViewFlowLayout.minimumLineSpacing)) / 3.0;
|
||||
mainCollectionViewFlowLayout.itemSize = CGSizeMake(width, width);
|
||||
|
||||
self.mainCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:mainCollectionViewFlowLayout];
|
||||
self.mainCollectionView.userInteractionEnabled = YES;
|
||||
self.mainCollectionView.backgroundColor = [UIColor clearColor];
|
||||
self.mainCollectionView.showsVerticalScrollIndicator = NO;
|
||||
self.mainCollectionView.showsHorizontalScrollIndicator = NO;
|
||||
self.mainCollectionView.alwaysBounceVertical = YES;
|
||||
self.mainCollectionView.delegate = self;
|
||||
self.mainCollectionView.dataSource = self;
|
||||
if (@available(iOS 11.0, *)) {
|
||||
self.mainCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
[self.mainCollectionView registerClass:[WXYZ_FeedbackCollectionViewCell class] forCellWithReuseIdentifier:@"WXYZ_FeedbackCollectionViewCell"];
|
||||
[self.mainCollectionView registerClass:[WXYZ_FeedbackAddCollectionViewCell class] forCellWithReuseIdentifier:@"WXYZ_FeedbackAddCollectionViewCell"];
|
||||
[self.contentView addSubview:self.mainCollectionView];
|
||||
|
||||
[self.mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top).with.offset(kHalfMargin);
|
||||
make.height.mas_equalTo(width);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(- kHalfMargin).priorityLow();
|
||||
}];
|
||||
|
||||
|
||||
WS(weakSelf)
|
||||
[WXYZ_FeedbackPhotoManager sharedManager].deletePhotoBlock = ^(WXYZ_FeedbackPhotoModel * _Nonnull photoModel) {
|
||||
[weakSelf.photosSource removeObject:photoModel];
|
||||
[weakSelf.mainCollectionView reloadData];
|
||||
if (weakSelf.operationPhotosBlock) {
|
||||
weakSelf.operationPhotosBlock(weakSelf.photosSource);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
|
||||
{
|
||||
if (self.photosSource.count < 3) {
|
||||
return self.photosSource.count + 1;
|
||||
}
|
||||
|
||||
if (self.photosSource.count >= 3) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
return self.photosSource.count;
|
||||
}
|
||||
|
||||
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if (indexPath.row == self.photosSource.count && self.photosSource.count < 3) {
|
||||
static NSString *CellIdentifier = @"WXYZ_FeedbackAddCollectionViewCell";
|
||||
WXYZ_FeedbackAddCollectionViewCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
|
||||
return cell;
|
||||
} else {
|
||||
WS(weakSelf)
|
||||
static NSString *CellIdentifier = @"WXYZ_FeedbackCollectionViewCell";
|
||||
WXYZ_FeedbackCollectionViewCell __weak *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
|
||||
cell.photoModel = [self.photosSource objectOrNilAtIndex:indexPath.row];
|
||||
cell.cellIndex = indexPath.row;
|
||||
cell.deleteImageBlock = ^(NSInteger index) {
|
||||
[weakSelf.mainCollectionView reloadData];
|
||||
};
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
if ([[collectionView cellForItemAtIndexPath:indexPath] isKindOfClass:[WXYZ_FeedbackAddCollectionViewCell class]]) {
|
||||
WXYZ_ImagePicker *picker = [WXYZ_ImagePicker sharedManager];
|
||||
picker.editPhoto = NO;
|
||||
picker.delegate = self;
|
||||
[picker showLibraryInController:[TFViewHelper getCurrentViewController]];
|
||||
} else {
|
||||
WXYZ_FeedbackPhotoModel *photoModel = [self.photosSource objectOrNilAtIndex:indexPath.row];
|
||||
TFPhotoBrowser *browser = [TFPhotoBrowser new];
|
||||
browser.dataSource = @[photoModel.show_img].mutableCopy;
|
||||
browser.downLoadNeeded = YES;
|
||||
browser.currentPhotoIndex = 0;
|
||||
[[TFViewHelper getCurrentViewController] presentViewController:browser animated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)imagePickerDidFinishPickingWithOriginalImage:(UIImage *)originalImage editedImage:(UIImage *)editedImage
|
||||
{
|
||||
WS(weakSelf)
|
||||
WXYZ_FeedbackPhotoModel *photoModel = [[WXYZ_FeedbackPhotoModel alloc] init];
|
||||
photoModel.show_img = @"";
|
||||
[self.photosSource addObject:photoModel];
|
||||
[self.mainCollectionView reloadData];
|
||||
|
||||
[[WXYZ_FeedbackPhotoManager sharedManager] addPhotoImage:originalImage complete:^(WXYZ_FeedbackPhotoModel * _Nonnull photoModel) {
|
||||
if (photoModel) {
|
||||
[weakSelf.photosSource removeLastObject];
|
||||
[weakSelf.photosSource addObject:photoModel];
|
||||
[weakSelf.mainCollectionView reloadData];
|
||||
if (weakSelf.operationPhotosBlock) {
|
||||
weakSelf.operationPhotosBlock(weakSelf.photosSource);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// WXYZ_FeedbackSubViewController.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/7/4.
|
||||
// Copyright © 2018年 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
|
||||
@interface WXYZ_FeedbackSubViewController : TFBasicViewController
|
||||
|
||||
@end
|
||||
+301
@@ -0,0 +1,301 @@
|
||||
//
|
||||
// WXYZ_FeedbackSubViewController.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2018/7/4.
|
||||
// Copyright © 2018年 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_FeedbackSubViewController.h"
|
||||
|
||||
#import "WXYZ_FeedbackTextViewTableViewCell.h"
|
||||
#import "WXYZ_FeedbackPhotoTableViewCell.h"
|
||||
#import "WXYZ_FeedbackContactTableViewCell.h"
|
||||
|
||||
#import "TFTextView.h"
|
||||
#import "TFKeyboardManager.h"
|
||||
#import "WXYZ_FeedbackPhotoManager.h"
|
||||
|
||||
@interface WXYZ_FeedbackSubViewController () <UITableViewDelegate, UITableViewDataSource>
|
||||
{
|
||||
UIButton *submitButton;
|
||||
TFKeyboardManager *keyboardManager;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) NSString *contentString;
|
||||
|
||||
@property (nonatomic, strong) NSString *contactString;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_FeedbackSubViewController
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
[self initialize];
|
||||
[self createSubviews];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
[super viewWillAppear:animated];
|
||||
[self setStatusBarDefaultStyle];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
{
|
||||
[super viewDidAppear:animated];
|
||||
[self navigationCanSlidingBack:NO];
|
||||
}
|
||||
|
||||
- (void)initialize
|
||||
{
|
||||
[self setNavigationBarTitle:TFLocalizedString(@"意见反馈")];
|
||||
[self hiddenNavigationBarLeftButton];
|
||||
self.view.backgroundColor = kGrayViewColor;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
leftButton.backgroundColor = [UIColor clearColor];
|
||||
leftButton.frame = CGRectMake(kHalfMargin, PUB_NAVBAR_OFFSET + 20, 44, 44);
|
||||
leftButton.adjustsImageWhenHighlighted = NO;
|
||||
[leftButton.titleLabel setFont:kMainFont];
|
||||
[leftButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
|
||||
[leftButton setImageEdgeInsets:UIEdgeInsetsMake(12, 6, 12, 18)];
|
||||
[leftButton setImage:[[UIImage imageNamed:@"public_back"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal];
|
||||
[leftButton setTintColor:kBlackColor];
|
||||
[leftButton addTarget:self action:@selector(giveUpSubmit) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.navigationBar addSubview:leftButton];
|
||||
|
||||
self.mainTableViewGroup.delegate = self;
|
||||
self.mainTableViewGroup.dataSource = self;
|
||||
[self.view addSubview:self.mainTableViewGroup];
|
||||
|
||||
[self.mainTableViewGroup mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(0);
|
||||
make.top.mas_equalTo(PUB_NAVBAR_HEIGHT);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(SCREEN_HEIGHT - PUB_NAVBAR_HEIGHT - PUB_TABBAR_HEIGHT);
|
||||
}];
|
||||
|
||||
submitButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
submitButton.backgroundColor = kRedColor;
|
||||
[submitButton setTitle:TFLocalizedString(@"提交") forState:UIControlStateNormal];
|
||||
[submitButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
|
||||
[submitButton.titleLabel setFont:kMainFont];
|
||||
[submitButton addTarget:self action:@selector(netRequest) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self.view addSubview:submitButton];
|
||||
|
||||
[submitButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.view.mas_bottom).with.offset(- PUB_TABBAR_OFFSET);
|
||||
make.left.mas_equalTo(0);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH);
|
||||
make.height.mas_equalTo(PUB_TABBAR_HEIGHT - PUB_TABBAR_OFFSET);
|
||||
}];
|
||||
|
||||
WS(weakSelf)
|
||||
keyboardManager = [[TFKeyboardManager alloc] initObserverWithAdaptiveMovementView:self.mainTableViewGroup];
|
||||
keyboardManager.keyboardHeightChanged = ^(CGFloat keyboardHeight, CGFloat shouldMoveDistance, CGRect shouldMoveFrame) {
|
||||
[weakSelf.mainTableViewGroup setMj_y:weakSelf.mainTableViewGroup.mj_y + shouldMoveDistance];
|
||||
};
|
||||
}
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
WS(weakSelf)
|
||||
switch (indexPath.section) {
|
||||
case 0:
|
||||
{
|
||||
static NSString *cellName = @"WXYZ_FeedbackTextViewTableViewCell";
|
||||
WXYZ_FeedbackTextViewTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[WXYZ_FeedbackTextViewTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.textViewDidChange = ^(NSString * _Nonnull contentString) {
|
||||
weakSelf.contentString = contentString;
|
||||
};
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
{
|
||||
static NSString *cellName = @"WXYZ_FeedbackPhotoTableViewCell";
|
||||
WXYZ_FeedbackPhotoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[WXYZ_FeedbackPhotoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.operationPhotosBlock = ^(NSMutableArray * _Nonnull photosSource) {
|
||||
weakSelf.dataSourceArray = photosSource;
|
||||
};
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
static NSString *cellName = @"WXYZ_FeedbackContactTableViewCell";
|
||||
WXYZ_FeedbackContactTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName];
|
||||
if (!cell) {
|
||||
cell = [[WXYZ_FeedbackContactTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellName];
|
||||
}
|
||||
cell.contactDidChange = ^(NSString * _Nonnull contactString) {
|
||||
weakSelf.contactString = contactString;
|
||||
};
|
||||
|
||||
__weak WXYZ_FeedbackContactTableViewCell *weakCell = cell;
|
||||
cell.willBeginEditing = ^{
|
||||
keyboardManager.adaptiveMovementView = weakCell;
|
||||
};
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
return cell;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return [[UITableViewCell alloc] init];
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
return KCellHeight;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, KCellHeight)];
|
||||
view.backgroundColor = kGrayViewColor;
|
||||
|
||||
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(kHalfMargin, 0, SCREEN_WIDTH - 2 * kHalfMargin, 40)];
|
||||
titleLabel.textColor = kGrayTextColor;
|
||||
titleLabel.font = kFont15;
|
||||
[view addSubview:titleLabel];
|
||||
|
||||
switch (section) {
|
||||
case 0:
|
||||
titleLabel.text = TFLocalizedString(@"问题反馈");
|
||||
break;
|
||||
case 1:
|
||||
titleLabel.text = TFLocalizedString(@"提供问题截图(选填)");
|
||||
break;
|
||||
case 2:
|
||||
titleLabel.text = TFLocalizedString(@"联系方式(至少填写一项)");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
{
|
||||
if (section == 2) {
|
||||
return PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET;
|
||||
}
|
||||
return CGFLOAT_MIN;
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
{
|
||||
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, PUB_TABBAR_OFFSET == 0 ? 10 : PUB_TABBAR_OFFSET)];
|
||||
view.backgroundColor = [UIColor clearColor];
|
||||
return view;
|
||||
}
|
||||
|
||||
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
||||
{
|
||||
[TFKeyboardManager hideKeyboard];
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
[TFKeyboardManager hideKeyboard];
|
||||
}
|
||||
|
||||
- (void)giveUpSubmit
|
||||
{
|
||||
WS(weakSelf)
|
||||
if (self.contentString.length > 0 || self.contactString.length > 0 || [WXYZ_FeedbackPhotoManager sharedManager].isUploading || self.dataSourceArray.count > 0) {
|
||||
TFAlertView *alert = [[TFAlertView alloc] init];
|
||||
alert.alertDetailContent = TFLocalizedString(@"您有修改尚未提交,是否放弃修改?");
|
||||
alert.confirmTitle = TFLocalizedString(@"放弃修改");
|
||||
alert.cancelTitle = TFLocalizedString(@"取消");
|
||||
alert.confirmButtonClickBlock = ^{
|
||||
[[WXYZ_FeedbackPhotoManager sharedManager] removeAllPhotoImageWithPhotoArray:weakSelf.dataSourceArray];
|
||||
[weakSelf popViewController];
|
||||
};
|
||||
[alert showAlertView];
|
||||
return;
|
||||
}
|
||||
|
||||
[self popViewController];
|
||||
}
|
||||
|
||||
- (void)netRequest
|
||||
{
|
||||
[TFKeyboardManager hideKeyboard];
|
||||
|
||||
if (self.contentString.length == 0) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"请完善问题描述")];
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.contactString.length == 0) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:TFLocalizedString(@"请填写联系方式")];
|
||||
return;
|
||||
}
|
||||
|
||||
if ([WXYZ_FeedbackPhotoManager sharedManager].isUploading) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"图片正在上传中,请稍后")];
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableDictionary *t_dic = [NSMutableDictionary dictionary];
|
||||
[t_dic setObject:self.contentString forKey:@"content"];
|
||||
[t_dic setObject:self.contactString forKey:@"contact"];
|
||||
if (self.dataSourceArray.count > 0) {
|
||||
NSMutableArray *imgs = [NSMutableArray arrayWithCapacity:3];
|
||||
for (WXYZ_FeedbackPhotoModel *t_model in self.dataSourceArray) {
|
||||
[imgs addObject:t_model.img];
|
||||
}
|
||||
[t_dic setObject:[imgs componentsJoinedByString:@"||"] forKey:@"imgs"];
|
||||
}
|
||||
|
||||
submitButton.enabled = NO;
|
||||
|
||||
WS(weakSelf)
|
||||
[TFNetworkTools POST:Sub_Feed_Back parameters:t_dic model:nil success:^(BOOL isSuccess, id _Nullable t_model, TFNetworkRequestModel *requestModel) {
|
||||
if (isSuccess) {
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusSuccess promptTitle:TFLocalizedString(@"反馈成功")];
|
||||
[weakSelf.navigationController popViewControllerAnimated:YES];
|
||||
} else {
|
||||
SS(strongSelf)
|
||||
strongSelf->submitButton.enabled = YES;
|
||||
[TFPromptManager showPromptViewWithStatus:TFPromptStatusError promptTitle:requestModel.msg];
|
||||
}
|
||||
} failure:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[keyboardManager stopKeyboardObserver];
|
||||
}
|
||||
|
||||
@end
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// WXYZ_FeedbackTextViewTableViewCell.h
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface WXYZ_FeedbackTextViewTableViewCell : TFBasicTableViewCell
|
||||
|
||||
@property (nonatomic, copy) void(^textViewDidChange)(NSString *contentString);
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// WXYZ_FeedbackTextViewTableViewCell.m
|
||||
// WXReader
|
||||
//
|
||||
// Created by Andrew on 2019/12/27.
|
||||
// Copyright © 2019 Andrew. All rights reserved.
|
||||
//
|
||||
|
||||
#import "WXYZ_FeedbackTextViewTableViewCell.h"
|
||||
#import "TFTextView.h"
|
||||
|
||||
@interface WXYZ_FeedbackTextViewTableViewCell () <TFTextViewDelegate>
|
||||
|
||||
@property (nonatomic ,copy) NSString *contentString;
|
||||
|
||||
@end
|
||||
|
||||
@implementation WXYZ_FeedbackTextViewTableViewCell
|
||||
{
|
||||
TFTextView *textView;
|
||||
}
|
||||
|
||||
- (void)createSubviews
|
||||
{
|
||||
[super createSubviews];
|
||||
|
||||
textView = [[TFTextView alloc] initWithFrame:CGRectZero];
|
||||
textView.maxWordCount = 200;
|
||||
textView.delegate = self;
|
||||
textView.layer.cornerRadius = 4;
|
||||
[textView resetPlaceholderText:TFLocalizedString(@"请详细描述您遇到的问题并告知具体操作步骤,我们会尽快答复您的问题哦")];
|
||||
[self.contentView addSubview:textView];
|
||||
|
||||
[textView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(self.contentView.mas_left).with.offset(kHalfMargin);
|
||||
make.top.mas_equalTo(self.contentView.mas_top);
|
||||
make.width.mas_equalTo(SCREEN_WIDTH - kMargin);
|
||||
make.height.mas_equalTo(200);
|
||||
make.bottom.mas_equalTo(self.contentView.mas_bottom).priorityLow();
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)textViewDidChange:(NSString *)text
|
||||
{
|
||||
if (self.textViewDidChange) {
|
||||
self.textViewDidChange(text);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user