diff --git a/YuMi.xcodeproj/xcshareddata/xcschemes/YuMi.xcscheme b/YuMi.xcodeproj/xcshareddata/xcschemes/YuMi.xcscheme index d258e3d3..1d06cb71 100644 --- a/YuMi.xcodeproj/xcshareddata/xcschemes/YuMi.xcscheme +++ b/YuMi.xcodeproj/xcshareddata/xcschemes/YuMi.xcscheme @@ -72,7 +72,7 @@ buildConfiguration = "Debug"> diff --git a/YuMi/Global/YUMIConstant.m b/YuMi/Global/YUMIConstant.m index 6f5a13a5..3b7b3382 100644 --- a/YuMi/Global/YUMIConstant.m +++ b/YuMi/Global/YUMIConstant.m @@ -48,7 +48,7 @@ NSString * const kFreeGiftCountdownNotification = @"kFreeGiftCountdownNotificati ///在里面进行判断当前环境是什么 NSString * const KeyWithType(Pi_KeyType type) { - BOOL isRelase = NO; + BOOL isRelase = YES; #ifdef DEBUG NSString *isProduction = [[NSUserDefaults standardUserDefaults]valueForKey:@"kIsProductionEnvironment"]; if([isProduction isEqualToString:@"YES"]){ diff --git a/YuMi/Modules/YMLogin/View/FeedBackViewController.h b/YuMi/Modules/YMLogin/View/FeedBackViewController.h index 4aead217..8f394882 100644 --- a/YuMi/Modules/YMLogin/View/FeedBackViewController.h +++ b/YuMi/Modules/YMLogin/View/FeedBackViewController.h @@ -21,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak) IBOutlet UILabel *title_3; @property (nonatomic, weak) IBOutlet UILabel *title_4; +@property (nonatomic, weak) IBOutlet UICollectionViewFlowLayout *typeCollectionLayout; @property (nonatomic, weak) IBOutlet UICollectionView *typeCollectionView; @property (nonatomic, weak) IBOutlet UITextView *feedbackTextView; @@ -33,8 +34,6 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak) IBOutlet UITextField *contactTextField; -@property (nonatomic, weak) IBOutlet UIButton *submitButton; - @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMLogin/View/FeedBackViewController.m b/YuMi/Modules/YMLogin/View/FeedBackViewController.m index bbd2829c..9eb692a7 100644 --- a/YuMi/Modules/YMLogin/View/FeedBackViewController.m +++ b/YuMi/Modules/YMLogin/View/FeedBackViewController.m @@ -26,16 +26,25 @@ _content = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:16 weight:UIFontWeightBold] textColor:UIColorFromRGB(0x333333)]; + _icon = [[UIImageView alloc] initWithImage:kImage(@"user_card_copy_id1")]; [self.contentView addSubview:_content]; [self.contentView addSubview:_icon]; [_content mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.left.mas_equalTo(0); + if (isMSRTL()) { + make.top.right.mas_equalTo(0); + } else { + make.top.left.mas_equalTo(0); + } }]; [_icon mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.mas_equalTo(12); make.centerY.mas_equalTo(self.content); - make.left.mas_equalTo(self.content.mas_right).offset(2); + if (isMSRTL()) { + make.right.mas_equalTo(self.content.mas_left).offset(-2); + } else { + make.left.mas_equalTo(self.content.mas_right).offset(2); + } }]; } return self; @@ -174,18 +183,19 @@ self = [super initWithFrame:frame]; if (self) { self.contentView.userInteractionEnabled = YES; + self.contentView.layer.cornerRadius = 15.5; + self.contentView.layer.masksToBounds = YES; + self.contentView.backgroundColor = UIColorFromRGB(0xf3f5fa); + _titleLabel = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x22252c)]; - _titleLabel.layer.cornerRadius = 15.5; - _titleLabel.layer.masksToBounds = YES; _titleLabel.textAlignment = NSTextAlignmentCenter; - _titleLabel.backgroundColor = UIColorFromRGB(0xf3f5fa); _titleLabel.userInteractionEnabled = NO; - _titleLabel.minimumScaleFactor = 0.7; - _titleLabel.numberOfLines = 2; +// _titleLabel.minimumScaleFactor = 0.7; + _titleLabel.numberOfLines = 1; [self.contentView addSubview:_titleLabel]; [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.contentView); + make.edges.mas_equalTo(self.contentView).insets(UIEdgeInsetsMake(9, 10, 9, 10)); }]; } return self; @@ -193,9 +203,9 @@ - (void)setSelected:(BOOL)selected { if (selected) { - self.titleLabel.backgroundColor = UIColorFromRGB(0x85f6d3); + self.contentView.backgroundColor = UIColorFromRGB(0x85f6d3); } else { - self.titleLabel.backgroundColor = UIColorFromRGB(0xf3f5fa); + self.contentView.backgroundColor = UIColorFromRGB(0xf3f5fa); } } @@ -203,11 +213,13 @@ @interface FeedBackViewController () +@property (nonatomic, strong) UIButton *submitButton; @property (nonatomic, strong) UIView *fakeTopBar; @property (nonatomic, copy) NSString *uploadPhotoURLString; @property (nonatomic, strong) UIImage *selectedImage; @property (nonatomic, strong) FeedBackConfigModel *configModel; @property (nonatomic, strong) FeedBackTypeModel *selectTypeModel; +@property (nonatomic, strong) NSLayoutConstraint *collectionViewHeightConstraint; @end @@ -231,6 +243,15 @@ - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; + +// [self.submitButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xa5eec8),UIColorFromRGB(0xabf5e3)] +// gradientType:GradientTypeTopToBottom +// imgSize:CGSizeMake(300, 50)] +// forState:UIControlStateNormal]; +// [self.submitButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x57e193),UIColorFromRGB(0x1402a6)] +// gradientType:GradientTypeTopToBottom +// imgSize:CGSizeMake(300, 50)] +// forState:UIControlStateSelected]; } - (LoginPresenter *)createPresenter { @@ -248,6 +269,8 @@ [self setupFakeTopBar]; [self.closeKeyboardButton setTitle:@"" forState:UIControlStateNormal]; + +// self.typeCollectionLayout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize; self.typeCollectionView.delegate = self; self.typeCollectionView.dataSource = self; @@ -262,7 +285,7 @@ self.title_3.textColor = [UIColor blackColor]; self.title_4.textColor = [UIColor blackColor]; - self.title_2.text = YMLocalizedString(@"FeedBackViewController2"); + self.title_3.text = YMLocalizedString(@"FeedBackViewController2"); NSAttributedString *redMark = [[NSAttributedString alloc] initWithString:@"* " attributes:@{NSForegroundColorAttributeName: UIColorFromRGB(0xeb5c2c), @@ -286,6 +309,7 @@ self.feedbackCharCountLabel.textAlignment = NSTextAlignmentRight; self.feedbackCharLimitLabel.textAlignment = NSTextAlignmentRight; self.feedbackCharLimitLabel.text = @"300/"; + self.typeCollectionView.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft; } else { self.feedbackCharCountLabel.textAlignment = NSTextAlignmentLeft; self.feedbackCharLimitLabel.textAlignment = NSTextAlignmentLeft ; @@ -298,15 +322,21 @@ self.contactTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:YMLocalizedString(@"FeedBackViewController5") attributes:@{NSForegroundColorAttributeName: placeholderColor}]; + self.submitButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [self.submitButton addTarget:self action:@selector(didTapSubmitButton:) forControlEvents:UIControlEventTouchUpInside]; + [self.view addSubview:self.submitButton]; [self.submitButton setTitle:YMLocalizedString(@"LoginForgetPasswordViewController6") forState:UIControlStateNormal]; - [self.submitButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xa5eec8),UIColorFromRGB(0xabf5e3)] - gradientType:GradientTypeTopToBottom - imgSize:CGSizeMake(300, 50)] - forState:UIControlStateNormal]; - [self.submitButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorRGBAlpha(0x57e193, 0.5),UIColorRGBAlpha(0x1402a6, 0.5)] - gradientType:GradientTypeTopToBottom - imgSize:CGSizeMake(300, 50)] - forState:UIControlStateSelected]; + [self.submitButton setTitle:YMLocalizedString(@"LoginForgetPasswordViewController6") forState:UIControlStateDisabled]; + [self.submitButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; + + UIImage *nextImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x57e193), UIColorFromRGB(0x14D2a6)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth-36*2, 48)]; + UIImage *disableImage = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xa5eec8), UIColorFromRGB(0xabf5e3)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(KScreenWidth-36*2, 48)]; + + [self.submitButton setBackgroundImage:nextImage forState:UIControlStateNormal]; + [self.submitButton setBackgroundImage:disableImage forState:UIControlStateDisabled]; + self.submitButton.layer.cornerRadius = 48/2; + self.submitButton.layer.masksToBounds = YES; + self.submitButton.enabled = NO; } - (void)setupFakeTopBar { @@ -377,7 +407,7 @@ make.bottom.mas_equalTo(self.view).offset(-40); make.left.mas_equalTo(36); make.right.mas_equalTo(-36); - make.height.mas_equalTo(49); + make.height.mas_equalTo(48); }]; [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -403,9 +433,11 @@ make.top.mas_equalTo(self.title_1.mas_bottom).offset(18); make.left.mas_equalTo(self.scrollContentView).offset(16); make.right.mas_equalTo(self.scrollContentView).offset(-16); - make.height.mas_equalTo(31); + make.height.mas_greaterThanOrEqualTo(31); make.width.mas_equalTo(KScreenWidth - 32); }]; +// self.collectionViewHeightConstraint = [self.typeCollectionView.heightAnchor constraintEqualToConstant:1]; +// self.collectionViewHeightConstraint.active = YES; [self.closeKeyboardButton mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.typeCollectionView.mas_bottom); @@ -499,13 +531,13 @@ - (void)updateSubmitButtonStatus { if (self.selectTypeModel == nil) { - [self.submitButton setSelected:NO]; + self.submitButton.enabled = NO; } else if(self.feedbackTextView.text.length == 0) { - [self.submitButton setSelected:NO]; + self.submitButton.enabled = NO; } else if(self.contactTextField.text.length == 0) { - [self.submitButton setSelected:NO]; + self.submitButton.enabled = NO; } else { - [self.submitButton setSelected:YES]; + self.submitButton.enabled = YES; } } @@ -605,11 +637,11 @@ } failure:^(NSString * _Nonnull errorMessage) { @kStrongify(self); [self hideHUD]; - [TTPopup alertWithMessage:errorMessage confirmHandler:^{ - - } cancelHandler:^{ - - }]; + if (errorMessage.length > 0) { + [TTPopup alertWithMessage:errorMessage confirmHandler:^{ + } cancelHandler:^{ + }]; + } }]; } @@ -653,7 +685,10 @@ photoURLString:self.uploadPhotoURLString contact:self.contactTextField.text]; }); +} +- (IBAction)contactDidChange:(UITextField *)sender { + [self updateSubmitButtonStatus]; } #pragma mark - UICollectionView Delegate & DataSource @@ -661,8 +696,13 @@ [self.typeCollectionView layoutIfNeeded]; CGSize contentSize = self.typeCollectionView.collectionViewLayout.collectionViewContentSize; [self.typeCollectionView mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(contentSize.height); + make.height.mas_greaterThanOrEqualTo(contentSize.height); }]; + +// [self.typeCollectionView layoutIfNeeded]; + + // 更新高度约束 +// self.collectionViewHeightConstraint.constant = self.typeCollectionView.contentSize.height; } // 返回 section 中的 item 数量 @@ -673,11 +713,19 @@ - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { - CGFloat padding = 24.0; - CGFloat totalPadding = padding * 2 + padding * 2; // 左右两边的间距 + 中间两个间距 - CGFloat availableWidth = collectionView.frame.size.width - totalPadding; - CGFloat itemWidth = availableWidth / 3; - return CGSizeMake(itemWidth, 31); +// return UICollectionViewFlowLayoutAutomaticSize; +// CGFloat padding = 24.0; +// CGFloat totalPadding = padding * 2 + padding * 2; // 左右两边的间距 + 中间两个间距 +// CGFloat availableWidth = collectionView.frame.size.width - totalPadding; +// CGFloat itemWidth = availableWidth / 3; + + FeedBackTypeModel *model = [self.configModel.typeEnumList xpSafeObjectAtIndex:indexPath.row]; + UILabel *label = [UILabel labelInitWithText:model.desc + font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x22252c)];; + CGSize maxSize = CGSizeMake(CGFLOAT_MAX, 31); + CGSize requiredSize = [label sizeThatFits:maxSize]; + + return CGSizeMake(MAX(90, requiredSize.width + 20), 31); } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { @@ -685,7 +733,7 @@ } - (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { - return 24.0; + return 14.0; } // 返回 cell @@ -764,7 +812,7 @@ [self updateSubmitButtonStatus]; - if (newText.length > 300) { + if (newText.length >= 300) { return NO; } diff --git a/YuMi/Modules/YMLogin/View/FeedBackViewController.xib b/YuMi/Modules/YMLogin/View/FeedBackViewController.xib index 69bdeb11..e0239d34 100644 --- a/YuMi/Modules/YMLogin/View/FeedBackViewController.xib +++ b/YuMi/Modules/YMLogin/View/FeedBackViewController.xib @@ -18,11 +18,11 @@ - + @@ -58,6 +58,9 @@ + + +