Skip to content

Commit

Permalink
move iOS functionalities to a new PR
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact committed Jan 20, 2023
1 parent e19d492 commit 085730f
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 109 deletions.
3 changes: 0 additions & 3 deletions Libraries/Text/TextInput/Multiline/RCTUITextView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign, readonly) BOOL textWasPasted;
@property (nonatomic, copy, nullable) NSString *placeholder;
@property (nonatomic, strong, nullable) UIColor *placeholderColor;
@property (nonatomic, assign, nullable) NSString *accessibilityErrorMessage;
@property (nonatomic, readwrite, nullable) NSString *currentAccessibilityError;
@property (nonatomic, readwrite, nullable) NSString *previousAccessibilityError;

@property (nonatomic, assign) CGFloat preferredMaxLayoutWidth;

Expand Down
18 changes: 0 additions & 18 deletions Libraries/Text/TextInput/Multiline/RCTUITextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,6 @@ - (void)setDefaultTextAttributes:(NSDictionary<NSAttributedStringKey, id> *)defa
[self _updatePlaceholder];
}

- (void)setAccessibilityErrorMessage:(NSString *)accessibilityErrorMessage
{
self.previousAccessibilityError = [self.currentAccessibilityError mutableCopy];
self.currentAccessibilityError = accessibilityErrorMessage;
NSString *text = self.attributedText == nil ? @"" : self.attributedText.string;
NSString *lastChar = [text length] == 0 ? @"" : [text substringFromIndex:[text length] - 1];
if (accessibilityErrorMessage != nil) {
NSString *errorWithLastCharacter = [NSString stringWithFormat: @"%@ %@", lastChar, accessibilityErrorMessage];
NSString *errorWithText = [NSString stringWithFormat: @"%@ %@", text, accessibilityErrorMessage];
self.accessibilityValue = errorWithText;
// onChangeText announce only the last typed/deleted character
// more info at https://bit.ly/3zOHsda
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, errorWithLastCharacter);
} else {
self.accessibilityValue = nil;
}
}

- (NSDictionary<NSAttributedStringKey, id> *)defaultTextAttributes
{
return _defaultTextAttributes;
Expand Down
3 changes: 0 additions & 3 deletions Libraries/Text/TextInput/RCTBackedTextInputViewProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ NS_ASSUME_NONNULL_BEGIN
@protocol RCTBackedTextInputViewProtocol <UITextInput>

@property (nonatomic, copy, nullable) NSAttributedString *attributedText;
@property (nonatomic, assign, nullable) NSString *accessibilityErrorMessage;
@property (nonatomic, readwrite, nullable) NSString *currentAccessibilityError;
@property (nonatomic, readwrite, nullable) NSString *previousAccessibilityError;
@property (nonatomic, copy, nullable) NSString *placeholder;
@property (nonatomic, strong, nullable) UIColor *placeholderColor;
@property (nonatomic, assign, readonly) BOOL textWasPasted;
Expand Down
11 changes: 0 additions & 11 deletions Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,6 @@ - (void)setAttributedText:(NSAttributedString *)attributedText

textNeedsUpdate = ([self textOf:attributedTextCopy equals:backedTextInputViewTextCopy] == NO);

NSString *currentAccessibilityError = self.backedTextInputView.currentAccessibilityError;
NSString *previousAccessibilityError = self.backedTextInputView.previousAccessibilityError;
BOOL accessibilityErrorMessageWasRemoved = currentAccessibilityError == nil && ![currentAccessibilityError isEqualToString: previousAccessibilityError];
if (accessibilityErrorMessageWasRemoved) {
BOOL validString = attributedText && [attributedText.string length] != 0;
NSString *lastChar = validString ? [attributedText.string substringFromIndex:[attributedText.string length] - 1] : @"";
self.backedTextInputView.accessibilityValue = nil;
// Triggering the announcement manually fixes screenreader announcement getting cut off
// https://bit.ly/3w18QmV https://bit.ly/3AdVKW3 https://bit.ly/3QHm7c7 https://bit.ly/3BVnmAy
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, lastChar);
}
if (eventLag == 0 && textNeedsUpdate) {
UITextRange *selection = self.backedTextInputView.selectedTextRange;
NSInteger oldTextLength = self.backedTextInputView.attributedText.string.length;
Expand Down
1 change: 0 additions & 1 deletion Libraries/Text/TextInput/RCTBaseTextInputViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ @implementation RCTBaseTextInputViewManager {
RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType)
RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)
RCT_REMAP_VIEW_PROPERTY(editable, backedTextInputView.editable, BOOL)
RCT_REMAP_VIEW_PROPERTY(accessibilityErrorMessage, backedTextInputView.accessibilityErrorMessage, NSString)
RCT_REMAP_VIEW_PROPERTY(enablesReturnKeyAutomatically, backedTextInputView.enablesReturnKeyAutomatically, BOOL)
RCT_REMAP_VIEW_PROPERTY(keyboardAppearance, backedTextInputView.keyboardAppearance, UIKeyboardAppearance)
RCT_REMAP_VIEW_PROPERTY(placeholder, backedTextInputView.placeholder, NSString)
Expand Down
3 changes: 0 additions & 3 deletions Libraries/Text/TextInput/Singleline/RCTUITextField.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong, nullable) UIColor *placeholderColor;
@property (nonatomic, assign) UIEdgeInsets textContainerInset;
@property (nonatomic, assign, getter=isEditable) BOOL editable;
@property (nonatomic, assign, nullable) NSString *accessibilityErrorMessage;
@property (nonatomic, readwrite, nullable) NSString *currentAccessibilityError;
@property (nonatomic, readwrite, nullable) NSString *previousAccessibilityError;
@property (nonatomic, getter=isScrollEnabled) BOOL scrollEnabled;
@property (nonatomic, strong, nullable) NSString *inputAccessoryViewID;
@property (nonatomic, assign, readonly) CGFloat zoomScale;
Expand Down
18 changes: 0 additions & 18 deletions Libraries/Text/TextInput/Singleline/RCTUITextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,24 +99,6 @@ - (void)setEditable:(BOOL)editable
self.enabled = editable;
}

- (void)setAccessibilityErrorMessage:(NSString *)accessibilityErrorMessage
{
self.previousAccessibilityError = [self.currentAccessibilityError mutableCopy];
self.currentAccessibilityError = accessibilityErrorMessage;
NSString *text = self.attributedText == nil ? @"" : self.attributedText.string;
NSString *lastChar = [text length] == 0 ? @"" : [text substringFromIndex:[text length] - 1];
if (accessibilityErrorMessage != nil) {
NSString *errorWithLastCharacter = [NSString stringWithFormat: @"%@ %@", lastChar, accessibilityErrorMessage];
NSString *errorWithText = [NSString stringWithFormat: @"%@ %@", text, accessibilityErrorMessage];
self.accessibilityValue = errorWithText;
// onChangeText announce only the last typed/deleted character
// more info at https://bit.ly/3zOHsda
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, errorWithLastCharacter);
} else {
self.accessibilityValue = nil;
}
}

- (void)setSecureTextEntry:(BOOL)secureTextEntry
{
if (self.secureTextEntry == secureTextEntry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ @implementation RCTTextInputComponentView {
UIView<RCTBackedTextInputViewProtocol> *_backedTextInputView;
NSUInteger _mostRecentEventCount;
NSAttributedString *_lastStringStateWasUpdatedWith;
NSString *currentAccessibilityError;
NSString *previousAccessibilityError;

/*
* UIKit uses either UITextField or UITextView as its UIKit element for <TextInput>. UITextField is for single line
Expand All @@ -57,12 +55,6 @@ @implementation RCTTextInputComponentView {
*/
BOOL _comingFromJS;
BOOL _didMoveToWindow;

/*
* A flag that triggers the accessibilityElement.accessibilityValue update and VoiceOver announcement
* to avoid duplicated announcements of accessibilityErrorMessage more info https://bit.ly/3yfUXD8
*/
BOOL _errorMessageRemoved;
}

#pragma mark - UIView overrides
Expand All @@ -79,7 +71,6 @@ - (instancetype)initWithFrame:(CGRect)frame
_ignoreNextTextInputCall = NO;
_comingFromJS = NO;
_didMoveToWindow = NO;
_errorMessageRemoved = NO;
[self addSubview:_backedTextInputView];
}

Expand Down Expand Up @@ -142,22 +133,6 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &
_backedTextInputView.editable = newTextInputProps.traits.editable;
}

if (newTextInputProps.accessibilityErrorMessage != oldTextInputProps.accessibilityErrorMessage || newTextInputProps.text != oldTextInputProps.text) {
NSString *text = RCTNSStringFromString(newTextInputProps.text);
NSString *error = RCTNSStringFromString(newTextInputProps.accessibilityErrorMessage);
NSString *lastChar = [text length] == 0 ? @"" : [text substringFromIndex:[text length] - 1];
if ([error length] != 0) {
NSString *errorWithLastCharacter = [NSString stringWithFormat: @"%@ %@", lastChar, error];
NSString *errorWithText = [NSString stringWithFormat: @"%@ %@", text, error];
self.accessibilityElement.accessibilityValue = errorWithText;
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, errorWithLastCharacter);
self->_errorMessageRemoved = NO;
} else {
self.accessibilityElement.accessibilityValue = text;
self->_errorMessageRemoved = YES;
}
}

if (newTextInputProps.traits.enablesReturnKeyAutomatically !=
oldTextInputProps.traits.enablesReturnKeyAutomatically) {
_backedTextInputView.enablesReturnKeyAutomatically = newTextInputProps.traits.enablesReturnKeyAutomatically;
Expand Down Expand Up @@ -619,13 +594,6 @@ - (void)_setAttributedString:(NSAttributedString *)attributedString
UITextRange *selectedRange = _backedTextInputView.selectedTextRange;
NSInteger oldTextLength = _backedTextInputView.attributedText.string.length;
_backedTextInputView.attributedText = attributedString;
if (self->_errorMessageRemoved) {
_backedTextInputView.accessibilityValue = attributedString.string;
self.accessibilityElement.accessibilityValue = attributedString.string;
NSString *lastChar = [attributedString.string substringFromIndex:[attributedString.string length] - 1];
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, lastChar);
self->_errorMessageRemoved = NO;
}
if (selectedRange.empty) {
// Maintaining a cursor position relative to the end of the old text.
NSInteger offsetStart = [_backedTextInputView offsetFromPosition:_backedTextInputView.beginningOfDocument
Expand Down
1 change: 0 additions & 1 deletion React/Views/UIView+React.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
@property (nonatomic, copy) NSArray<NSDictionary *> *accessibilityActions;
@property (nonatomic, copy) NSDictionary *accessibilityValueInternal;
@property (nonatomic, copy) NSString *accessibilityLanguage;
@property (nonatomic, copy) NSString *accessibilityErrorMessage;

/**
* Used in debugging to get a description of the view hierarchy rooted at
Expand Down
11 changes: 0 additions & 11 deletions React/Views/UIView+React.m
Original file line number Diff line number Diff line change
Expand Up @@ -320,17 +320,6 @@ - (NSString *)accessibilityLanguage
return objc_getAssociatedObject(self, _cmd);
}

- (NSString *)accessibilityErrorMessage
{
return objc_getAssociatedObject(self, _cmd);
}

- (void)setAccessibilityErrorMessage:(NSString *)accessibilityErrorMessage
{
objc_setAssociatedObject(
self, @selector(accessibilityErrorMessage), accessibilityErrorMessage, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (void)setAccessibilityLanguage:(NSString *)accessibilityLanguage
{
objc_setAssociatedObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ TextInputProps::TextInputProps(
"selection",
sourceProps.selection,
std::optional<Selection>())),
accessibilityErrorMessage(convertRawProp(
context,
rawProps,
"accessibilityErrorMessage",
sourceProps.accessibilityErrorMessage,
{})),
inputAccessoryViewID(convertRawProp(
context,
rawProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ class TextInputProps final : public ViewProps, public BaseTextProps {

std::string const inputAccessoryViewID{};

std::string accessibilityErrorMessage{""};

bool onKeyPressSync{false};
bool onChangeSync{false};

Expand Down

0 comments on commit 085730f

Please sign in to comment.