Files
peko-ios/YuMi/Modules/YMMine/View/Setting/XPMineFeedbackViewController.m
2024-04-18 18:37:21 +08:00

173 lines
6.4 KiB
Objective-C

//
// YMMineFeedbackViewController.m
// YUMI
//
// Created by YUMI on 2021/9/17.
//
#import "XPMineFeedbackViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <SZTextView/SZTextView.h>
#import <ReactiveObjC/ReactiveObjC.h>
///Tool
#import "YUMIMacroUitls.h"
#import "DJDKMIMOMColor.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) MSBaseTextField *contactField;
///提交
@property (nonatomic, strong) UIButton *submitBtn;
@end
@implementation XPMineFeedbackViewController
- (XPMineFeedbackPresenter *)createPresenter {
return [[XPMineFeedbackPresenter alloc] init];;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.title = YMLocalizedString(@"XPMineFeedbackViewController0");
[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.leading.mas_equalTo(self.view).offset(15);
make.top.mas_equalTo(17);
make.height.width.mas_equalTo(7);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.pointView.mas_trailing).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.leading.mas_equalTo(self.view).offset(15);
make.trailing.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.leading.trailing.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:@"%@%@",YMLocalizedString(@"XPMineFeedbackViewController1"), 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 = YMLocalizedString(@"XPMineFeedbackViewController2");
_titleLabel.font = [UIFont systemFontOfSize:15];
_titleLabel.textColor = [DJDKMIMOMColor mainTextColor];
}
return _titleLabel;
}
- (SZTextView *)contentTextView {
if (!_contentTextView) {
_contentTextView = [[SZTextView alloc] init];
NSString * placeholder = YMLocalizedString(@"XPMineFeedbackViewController3");
_contentTextView.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14], NSForegroundColorAttributeName : [DJDKMIMOMColor secondTextColor]}];
_contentTextView.textColor = [DJDKMIMOMColor mainTextColor];
_contentTextView.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor];
_contentTextView.font = [UIFont systemFontOfSize:14];
_contentTextView.layer.cornerRadius = 3;
}
return _contentTextView;
}
- (MSBaseTextField *)contactField {
if (!_contactField) {
_contactField = [[MSBaseTextField alloc] init];
NSString * placeholder = YMLocalizedString(@"XPMineFeedbackViewController4");
_contactField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:14], NSForegroundColorAttributeName : [DJDKMIMOMColor secondTextColor]}];
_contactField.font = [UIFont systemFontOfSize:14];
_contactField.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor];
_contactField.textColor = [DJDKMIMOMColor 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:YMLocalizedString(@"XPMineFeedbackViewController5") forState:UIControlStateNormal];
[_submitBtn setTitleColor:[DJDKMIMOMColor confirmButtonTextColor] forState:UIControlStateNormal];
[_submitBtn setTitleColor:[DJDKMIMOMColor disableButtonTextColor] forState:UIControlStateDisabled];
_submitBtn.layer.masksToBounds = YES;
_submitBtn.layer.cornerRadius = 45/2;
[_submitBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor confirmButtonGradientStartColor], [DJDKMIMOMColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_submitBtn setBackgroundImage:[UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor disableButtonColor], [DJDKMIMOMColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
_submitBtn.enabled = NO;
[_submitBtn addTarget:self action:@selector(submitBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _submitBtn;
}
@end