diff --git a/MVMCoreUI/Atoms/Views/MFTextView.h b/MVMCoreUI/Atoms/Views/MFTextView.h index 4641fcf2..38ba964a 100644 --- a/MVMCoreUI/Atoms/Views/MFTextView.h +++ b/MVMCoreUI/Atoms/Views/MFTextView.h @@ -31,7 +31,6 @@ @property (nonatomic, readwrite) BOOL errorShowing; @property (weak, nonatomic, nullable) SeparatorView *bottomLine; - +(MFTextView *_Nullable) MFTextViewWithPlaceholderString:(NSString *_Nullable) placeholder delegate:(id _Nullable ) delegate; //This method will make the UI as per brand refresh (Similar to UITextField) diff --git a/MVMCoreUI/Atoms/Views/MFTextView.m b/MVMCoreUI/Atoms/Views/MFTextView.m index 866c6c00..c120d964 100644 --- a/MVMCoreUI/Atoms/Views/MFTextView.m +++ b/MVMCoreUI/Atoms/Views/MFTextView.m @@ -57,8 +57,6 @@ [self.delegateForUIChange didSetText:text]; } - - @end @interface MFTextView () @@ -81,33 +79,25 @@ -(void)didSetContainerInset:(UIEdgeInsets)textContainerInset { UILabel *placeHolderLabel = self.placeHolderLabel; [placeHolderLabel removeConstraints:[self.placeHolderLabel constraints]]; - CGSize labelSize = [placeHolderLabel.text sizeWithAttributes:@{NSFontAttributeName: self.placeHolderLabel.font}]; - NSArray *constrainsApplied = @[@"PH_TRAILING", @"PH_LEADING", @"PH_TOP"]; - for (NSLayoutConstraint *constraint in self.constraints) { if ([constrainsApplied containsObject:constraint.identifier]) { [self removeConstraint:constraint]; } } - [placeHolderLabel addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[placeHolderLabel(height)]" options:0 metrics:@{@"height":@(ceilf(labelSize.height))} views:NSDictionaryOfVariableBindings(placeHolderLabel)]]; [placeHolderLabel addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[placeHolderLabel(width)]" options:0 metrics:@{@"width":@(ceilf(labelSize.width))} views:NSDictionaryOfVariableBindings(placeHolderLabel)]]; - NSLayoutConstraint *leadingConstraint = [NSLayoutConstraint constraintWithItem:placeHolderLabel attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeading multiplier:1.0 constant:(textContainerInset.left + 5)]; leadingConstraint.identifier = @"PH_LEADING"; - NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem:placeHolderLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0 constant:textContainerInset.top]; topConstraint.identifier = @"PH_TOP"; - [NSLayoutConstraint activateConstraints:@[leadingConstraint, topConstraint]]; - [self updateConstraints]; } -(void)didSetTextColor:(UIColor *)textColor { -// self.placeHolderLabel.textColor = textColor; + } - (void)didSetText:(NSString *)text { @@ -124,18 +114,15 @@ } -(void)textViewDidBeginEditing:(UITextView *)textView { - [self showOrHidePlaceholderForTextView:textView]; + [self showOrHidePlaceholderForTextView:textView]; if ([self.delegate respondsToSelector:@selector(textViewDidBeginEditing:)]) { [self.delegate textViewDidBeginEditing:textView]; - } - } -(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if ([self.delegate respondsToSelector:@selector(textView:shouldChangeTextInRange:replacementText:)]) { return [self.delegate textView:textView shouldChangeTextInRange:range replacementText:text]; - } return true; } @@ -144,15 +131,12 @@ [self showOrHidePlaceholderForTextView:textView]; if ([self.delegate respondsToSelector:@selector(textViewDidChange:)]) { [self.delegate textViewDidChange:textView]; - } - } -(BOOL)textViewShouldEndEditing:(UITextView *)textView { if ([self.delegate respondsToSelector:@selector(textViewShouldEndEditing:)]) { - return [self.delegate textViewShouldEndEditing:textView]; - + return [self.delegate textViewShouldEndEditing:textView]; } return true; } @@ -161,10 +145,7 @@ [self showOrHidePlaceholderForTextView:textView]; if ([self.delegate respondsToSelector:@selector(textViewDidEndEditing:)]) { [self.delegate textViewDidEndEditing:textView]; - } - - } - (void) showOrHidePlaceholderForTextView:(UITextView *) textView { @@ -185,14 +166,12 @@ view.clipsToBounds = YES; view.translatesAutoresizingMaskIntoConstraints = NO; view.layer.cornerRadius = CornerRadiusLarge; - view.textView.delegateForUIChange = view; view.textView.translatesAutoresizingMaskIntoConstraints = NO; - view.placeHolderLabel.text = placeholder; view.placeHolderLabel.translatesAutoresizingMaskIntoConstraints = NO; view.placeHolderLabel.textColor = [UIColor mfLightGrayColor]; - + // Disable SmartQuotes if (@available(iOS 11.0, *)) { view.textView.smartQuotesType = UITextSmartQuotesTypeNo; @@ -204,11 +183,10 @@ return view; } - #pragma mark - bordered textview - (void)makeBordersForTextView { - - [SeparatorView separatorAddToView:self position:SeparatorPositionBot]; + SeparatorView *bottomLine = [SeparatorView separatorAddToView:self position:SeparatorPositionBot]; + self.bottomLine = bottomLine; self.placeHolderLabel.font = [MFStyler fontB3]; [self.textView setFont:[MFStyler fontB2]]; [self.textView setTextContainerInset:UIEdgeInsetsMake(PaddingTwo, PaddingTwo, PaddingTwo, PaddingOne)]; @@ -225,7 +203,6 @@ [self.borderPath addLineToPoint:CGPointMake(frame.origin.x, frame.origin.y)]; [self.borderPath addLineToPoint:CGPointMake(frame.origin.x + frame.size.width, frame.origin.y)]; [self.borderPath addLineToPoint:CGPointMake(frame.origin.x + frame.size.width, frame.origin.y + frame.size.height)]; - self.borderPath.lineWidth = 1; UIColor *strokeColor; @@ -234,11 +211,9 @@ self.bottomLine.backgroundColor = [UIColor mfPumpkinColor]; } else { strokeColor = [UIColor mfSilver]; - self.bottomLine.backgroundColor = [UIColor mfSilver]; + self.bottomLine.backgroundColor = [UIColor blackColor]; } - [strokeColor setStroke]; - [self.borderPath stroke]; } @@ -246,7 +221,7 @@ [super drawRect:rect]; [self.borderPath removeAllPoints]; if (!self.hideBorder) { - self.layer.cornerRadius = 0; + self.layer.cornerRadius = 0; [self addBezierPathForBorders]; } }