Skip to content

Commit

Permalink
fix(ios): responsable region issue of Textinput (#3932)
Browse files Browse the repository at this point in the history
* fix(ios): responsable region issue of Textinput

* chore(ios): remove unused code in TextView
  • Loading branch information
wwwcg authored Jun 26, 2024
1 parent 6abf1e8 commit 34e1f5a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
@interface HippyTextField : HippyBaseTextInput <UITextFieldDelegate>
@property (nonatomic, copy) HippyDirectEventBlock onKeyPress;
@property (nonatomic, assign) BOOL autoCorrect;
//@property (nonatomic, assign) UIEdgeInsets contentInset;
@property (nonatomic, strong) UIColor *placeholderTextColor;
@property (nonatomic, strong) NSString *placeholder;
@property (nonatomic, strong) NSNumber *maxLength;
Expand All @@ -62,7 +61,6 @@
@property (nonatomic, copy) HippyDirectEventBlock onKeyboardWillHide;

@property (nonatomic, copy) NSString *value;
@property (nonatomic, strong) NSNumber *fontSize;
@property (nonatomic, strong) NSString *defaultValue;
@property (nonatomic, copy) NSString *text;
@property (nonatomic, strong) UIColor *textColor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,6 @@ - (void)setText:(NSString *)text {
_text = text;
}

- (void)setFontSize:(NSNumber *)fontSize {
_fontSize = fontSize;
if ([fontSize floatValue] > 0) {
[_textView setFont:[UIFont systemFontOfSize:[fontSize floatValue]]];
}
}

- (void)setValue:(NSString *)value {
[_textView setText:value];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
- (void)performTextUpdate;

@property (nonatomic, copy) NSString *value;
@property (nonatomic, strong) NSNumber *fontSize;
@property (nonatomic, strong) NSString *defaultValue;
@property (nonatomic, strong) UIColor *textColor;

Expand Down
28 changes: 11 additions & 17 deletions renderer/native/ios/renderer/component/textinput/HippyTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,23 @@ - (void)updateFrames {
}

- (void)updateContentSize {
CGSize size = (CGSize) { _scrollView.frame.size.width, INFINITY };
size.height = [_textView sizeThatFits:size].height;
_scrollView.contentSize = size;
_textView.frame = (CGRect) { CGPointZero, size };

if (_viewDidCompleteInitialLayout && _onContentSizeChange && !CGSizeEqualToSize(_previousContentSize, size)) {
_previousContentSize = size;
CGSize contentSize = (CGSize) { CGRectGetMaxX(_scrollView.frame), INFINITY };
contentSize.height = [_textView sizeThatFits:contentSize].height;

if (_viewDidCompleteInitialLayout && _onContentSizeChange && !CGSizeEqualToSize(_previousContentSize, contentSize)) {
_previousContentSize = contentSize;
_onContentSizeChange(@{
@"contentSize": @ {
@"height": @(size.height),
@"width": @(size.width),
@"height": @(contentSize.height),
@"width": @(contentSize.width),
},
@"target": self.hippyTag,
});
}

CGSize viewSize = CGSizeMake(CGRectGetWidth(_scrollView.frame), MAX(contentSize.height, self.frame.size.height));
_scrollView.contentSize = viewSize;
_textView.frame = (CGRect) { CGPointZero, viewSize };
}

- (void)updatePlaceholder {
Expand Down Expand Up @@ -743,14 +745,6 @@ - (void)setValue:(NSString *)value {
[self setText:value];
}

- (void)setFontSize:(NSNumber *)fontSize {
_fontSize = fontSize;

if ([fontSize floatValue] > 0) {
[self setFont:[UIFont systemFontOfSize:[fontSize floatValue]]];
}
}

- (void)setDefaultValue:(NSString *)defaultValue {
if (defaultValue) {
[self setText:defaultValue];
Expand Down

0 comments on commit 34e1f5a

Please sign in to comment.