123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //
- // FeedbackBodyView.m
- // KulexiuForTeacher
- //
- // Created by Kyle on 2022/3/22.
- //
- #import "FeedbackBodyView.h"
- @interface FeedbackBodyView ()<UITextFieldDelegate, UITextViewDelegate>
- @property (weak, nonatomic) IBOutlet UILabel *tipsLabel;
- @property (weak, nonatomic) IBOutlet UITextField *contactField;
- @property (weak, nonatomic) IBOutlet UILabel *wxContract;
- @property (weak, nonatomic) IBOutlet UILabel *emailContract;
- @property (weak, nonatomic) IBOutlet UIButton *sureButton;
- @property (nonatomic, copy) SubmitAction action;
- @end
- @implementation FeedbackBodyView
- - (void)awakeFromNib {
- [super awakeFromNib];
- self.inputText.delegate = self;
- self.contactField.delegate = self;
- self.contactField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"您的邮箱或手机号" attributes:@{NSForegroundColorAttributeName:HexRGB(0x777777), NSFontAttributeName:[UIFont systemFontOfSize:14.0f weight:UIFontWeightMedium]}];
-
- NSString *orgEmail = UserDefaultObjectForKey(OrganizationEmailKey);
- if ([NSString isEmptyString:orgEmail]) {
- orgEmail = @"邮箱:klx@kulexiu999.onexmail.com";
- }
- else {
- orgEmail = [NSString stringWithFormat:@"邮箱:%@",orgEmail];
- }
- _emailContract.text = orgEmail;
- }
- - (void)configPhone:(NSString *)phone email:(NSString *)email {
- if (![NSString isEmptyString:email]) {
- self.emailContract.text = [NSString stringWithFormat:@"邮箱:%@", email];
- }
- }
- + (instancetype)shareInstance {
- FeedbackBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"FeedbackBodyView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)submitActionCallback:(SubmitAction)action {
- if (action) {
- self.action = action;
- }
- }
- - (IBAction)submitAction:(id)sender {
- [self endEditing:YES];
- if (self.action) {
- if ([NSString isEmptyString:self.inputText.text]) {
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入反馈意见"];
- return;
- }
- // if ([NSString isEmptyString:self.contactField.text]) {
- // [LOADING_MANAGER MBShowAUTOHidingInWindow:@"请输入您的联系方式"];
- // return;
- // }
- self.action(self.inputText.text, self.contactField.text);
-
- }
- }
- #pragma mark ---- delegate
- - (void)textViewDidBeginEditing:(UITextView *)textView {
- self.tipsLabel.hidden = YES;
- }
- - (void)textViewDidEndEditing:(UITextView *)textView {
- if ([NSString isEmptyString:textView.text]) {
- self.tipsLabel.hidden = NO;
- }
- }
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
- if ([text isEqualToString:@"\n"]) {
- [self endEditing:YES];
- return YES;
- }
- if ([text isEqualToString:@""]) {
- return YES;
- }
- return YES;
- }
- - (BOOL)textViewShouldEndEditing:(UITextView *)textView {
- [self endEditing:YES];
- return YES;
- }
- - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
- [self endEditing:YES];
- }
- - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
- if ([string isEqualToString:@"\n"]) {
- [self endEditing:YES];
- return YES;
- }
- return YES;
- }
- - (void)setButtonColor:(UIColor *)buttonColor {
- _buttonColor = buttonColor;
- if (buttonColor) {
- [self.sureButton setBackgroundColor:buttonColor];
- }
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|