Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): responsable region issue of Textinput #3932

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading