Files
yinmeng-ios/xplan-ios/Main/Mine/View/Setting/XPMineFeedbackViewController.m
2022-05-13 16:12:18 +08:00

173 lines
6.2 KiB
Objective-C

//
// XPMineFeedbackViewController.m
// xplan-ios
//
// Created by 冯硕 on 2021/9/17.
//
#import "XPMineFeedbackViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <SZTextView/SZTextView.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "XPMacro.h"
#import "ThemeColor.h"
#import "UIImage+Utils.h"
///P
#import "XPMineFeedbackProtocol.h"
#import "XPMineFeedbackPresenter.h"
@interface XPMineFeedbackViewController ()
///小红点
@property (nonatomic, strong) UIView *pointView;
///内容
@property (nonatomic, strong) UILabel *titleLabel;
///输入反馈的内容
@property (nonatomic, strong) SZTextView *contentTextView;
///微信或者qq
@property (nonatomic, strong) UITextField *contactField;
///提交
@property (nonatomic, strong) UIButton *submitBtn;
@end
@implementation XPMineFeedbackViewController
- (XPMineFeedbackPresenter *)createPresenter {
return [[XPMineFeedbackPresenter alloc] init];;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"反馈";
[self initSubviews];
[self makeConstriants];
}
#pragma mark - Private Method
- (void)initSubviews {
[self.view addSubview:self.pointView];
[self.view addSubview:self.titleLabel];
[self.view addSubview:self.contentTextView];
[self.view addSubview:self.contactField];
[self.view addSubview:self.submitBtn];
}
- (void)makeConstriants {
[self.pointView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.view).offset(15);
make.top.mas_equalTo(17);
make.height.width.mas_equalTo(7);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.pointView.mas_right).offset(4);
make.centerY.mas_equalTo(self.pointView);
}];
[self.contentTextView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.pointView.mas_bottom).offset(20);
make.left.mas_equalTo(self.view).offset(15);
make.right.mas_equalTo(self.view).offset(-15);
make.height.mas_equalTo(154);
}];
[self.contactField mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.contentTextView.mas_bottom).offset(10);
make.left.right.mas_equalTo(self.contentTextView);
make.height.mas_equalTo(35);
}];
[self.submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.contactField.mas_bottom).offset(45);
make.centerX.mas_equalTo(self.view);
make.height.mas_equalTo(45);
make.width.mas_equalTo(310);
}];
}
- (void)initEvents {
RAC(self.submitBtn, enabled) = [RACSignal combineLatest:@[self.contentTextView.rac_textSignal, self.contactField.rac_textSignal] reduce:^id _Nonnull(NSString *content, NSString * contact){
return @(content.length > 0 && contact.length > 0);
}];
}
#pragma mark - FeedbackCoreClient
- (void)saveFeedbackSuccess {
[self showSuccessToast:[NSString stringWithFormat:@"感谢您的宝贵意见,让我们共同营造更好的%@", AppName]];
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - Event Response
- (void)submitBtnAction:(UIButton *)sender {
[self.presenter saveFeedBackWith:self.contentTextView.text contact:self.contactField.text];
}
#pragma mark - Getter && Setter
- (UIView *)pointView {
if (!_pointView) {
_pointView = [[UIView alloc] init];
_pointView.backgroundColor = UIColorFromRGB(0xF944A1);
_pointView.layer.masksToBounds = YES;
_pointView.layer.cornerRadius = 3.5;
}
return _pointView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = @"问题描述";
_titleLabel.font = [UIFont systemFontOfSize:15];
_titleLabel.textColor = [ThemeColor mainTextColor];
}
return _titleLabel;
}
- (SZTextView *)contentTextView {
if (!_contentTextView) {
_contentTextView = [[SZTextView alloc] init];
NSString * placeholder = @"请详细描述您所遇到的问题与情况,感谢您提出宝贵的意见。";
_contentTextView.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14], NSForegroundColorAttributeName : [ThemeColor secondTextColor]}];
_contentTextView.textColor = [ThemeColor mainTextColor];
_contentTextView.backgroundColor = [ThemeColor appCellBackgroundColor];
_contentTextView.font = [UIFont systemFontOfSize:14];
_contentTextView.layer.cornerRadius = 3;
}
return _contentTextView;
}
- (UITextField *)contactField {
if (!_contactField) {
_contactField = [[UITextField alloc] init];
NSString * placeholder = @"请输入您的QQ或微信号";
_contactField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14], NSForegroundColorAttributeName : [ThemeColor secondTextColor]}];
_contactField.font = [UIFont systemFontOfSize:14];
_contactField.backgroundColor = [ThemeColor appCellBackgroundColor];
_contactField.textColor = [ThemeColor mainTextColor];
_contactField.layer.cornerRadius = 3;
_contactField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 8, 0)];
_contactField.leftViewMode = UITextFieldViewModeAlways;
}
return _contactField;
}
- (UIButton *)submitBtn {
if (!_submitBtn) {
_submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_submitBtn.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
[_submitBtn setTitle:@"提交反馈" forState:UIControlStateNormal];
[_submitBtn setTitleColor:[ThemeColor confirmButtonTextColor] forState:UIControlStateNormal];
[_submitBtn setTitleColor:[ThemeColor disableButtonTextColor] forState:UIControlStateDisabled];
_submitBtn.layer.masksToBounds = YES;
_submitBtn.layer.cornerRadius = 45/2;
[_submitBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_submitBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor disableButtonColor], [ThemeColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
_submitBtn.enabled = NO;
[_submitBtn addTarget:self action:@selector(submitBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _submitBtn;
}
@end