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): iOS18 adaptation of TextView component #3972

Merged
merged 1 commit into from
Jul 29, 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
3 changes: 2 additions & 1 deletion ios/sdk/component/textinput/HippyTextField.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
@end

@interface HippyUITextField : UITextField
/// iOS18's UITextInput adds an `editable` property, to avoid conflict, rename to `canEdit`
@property (nonatomic, assign) BOOL canEdit;
@property (nonatomic, assign) BOOL textWasPasted;
@property (nonatomic, weak) id<HippyUITextFieldResponseDelegate> responderDelegate;

@property (nonatomic, copy) HippyDirectEventBlock onBlur;
@property (nonatomic, copy) HippyDirectEventBlock onFocus;
@property (nonatomic, assign) BOOL editable;
@end

@interface HippyTextField : HippyBaseTextInput <UITextFieldDelegate>
Expand Down
6 changes: 3 additions & 3 deletions ios/sdk/component/textinput/HippyTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ - (void)setKeyboardType:(UIKeyboardType)keyboardType {
self.text = tempPwdStr;
}

- (void)setEditable:(BOOL)editable {
_editable = editable;
[self setEnabled:editable];
- (void)setCanEdit:(BOOL)canEdit {
_canEdit = canEdit;
[self setEnabled:canEdit];
}

- (void)paste:(id)sender {
Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/component/textinput/HippyTextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
@end

@interface HippyUITextView : UITextView
/// iOS18's UITextInput adds an `editable` property, which conflicts with the one defined in HippyUITextField.
/// For consistency, we added a canEdit property here too, which has the same meaning as editable
@property (nonatomic, assign) BOOL canEdit;
@property (nonatomic, assign) BOOL textWasPasted;
@property (nonatomic, weak) id<HippyUITextViewResponseDelegate> responderDelegate;
@end
Expand Down
5 changes: 5 additions & 0 deletions ios/sdk/component/textinput/HippyTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ - (void)didMoveToWindow {
}
}

- (void)setCanEdit:(BOOL)canEdit {
_canEdit = canEdit;
[self setEditable:canEdit];
}

@end

@interface HippyTextView () <HippyUITextViewResponseDelegate>
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/component/textinput/HippyTextViewManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ - (HippyShadowView *)shadowView {
HIPPY_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL)
HIPPY_REMAP_VIEW_PROPERTY(color, textView.textColor, UIColor)
HIPPY_REMAP_VIEW_PROPERTY(textAlign, textView.textAlignment, NSTextAlignment)
HIPPY_REMAP_VIEW_PROPERTY(editable, textView.editable, BOOL)
HIPPY_REMAP_VIEW_PROPERTY(editable, textView.canEdit, BOOL)
HIPPY_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, textView.enablesReturnKeyAutomatically, BOOL)
HIPPY_REMAP_VIEW_PROPERTY(keyboardType, textView.keyboardType, UIKeyboardType)
HIPPY_REMAP_VIEW_PROPERTY(keyboardAppearance, textView.keyboardAppearance, UIKeyboardAppearance)
Expand Down
Loading