diff --git a/ios/PasteTextInput.mm b/ios/PasteTextInput.mm index dd50053..97ff8b4 100644 --- a/ios/PasteTextInput.mm +++ b/ios/PasteTextInput.mm @@ -86,7 +86,7 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { static const auto defaultProps = std::make_shared(); _props = defaultProps; - + _backedTextInputView = [[PasteInputTextView alloc] initWithFrame:self.bounds]; _backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; _backedTextInputView.textInputDelegate = self; @@ -94,10 +94,10 @@ - (instancetype)initWithFrame:(CGRect)frame { _ignoreNextTextInputCall = NO; _comingFromJS = NO; _didMoveToWindow = NO; - + [self addSubview:_backedTextInputView]; } - + return self; } @@ -122,8 +122,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & const auto &newTextInputProps = static_cast(*props); // Traits: - if (newTextInputProps.traits.multiline != oldTextInputProps.traits.multiline) { - [self _setMultiline:newTextInputProps.traits.multiline]; + if (newTextInputProps.multiline != oldTextInputProps.multiline) { + [self _setMultiline:newTextInputProps.multiline]; } if (newTextInputProps.traits.autocapitalizationType != oldTextInputProps.traits.autocapitalizationType) { @@ -221,15 +221,15 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & if (newTextInputProps.inputAccessoryViewID != oldTextInputProps.inputAccessoryViewID) { _backedTextInputView.inputAccessoryViewID = RCTNSStringFromString(newTextInputProps.inputAccessoryViewID); } - + if (newTextInputProps.smartPunctuation != oldTextInputProps.smartPunctuation) { [self _setSmartPunctuation:[[NSString alloc] initWithCString:newTextInputProps.smartPunctuation.c_str() encoding:NSASCIIStringEncoding]]; } - + if (newTextInputProps.disableCopyPaste != oldTextInputProps.disableCopyPaste) { _backedTextInputView.disableCopyPaste = newTextInputProps.disableCopyPaste; } - + [super updateProps:props oldProps:oldProps]; [self setDefaultInputAccessoryView]; @@ -421,7 +421,7 @@ - (void)textInputDidChangeSelection return; } const auto &props = static_cast(*_props); - if (props.traits.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { + if (props.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) { [self textInputDidChange]; _ignoreNextTextInputCall = YES; } @@ -636,7 +636,7 @@ -(void)_setOnPaste{ } } } - + eventEmitter->onPaste(PasteTextInputEventEmitter::OnPaste{ .data = eventDataVector }); @@ -708,11 +708,11 @@ - (BOOL)_textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTe - (SubmitBehavior)getSubmitBehavior { const auto &props = static_cast(*_props); - const SubmitBehavior submitBehaviorDefaultable = props.traits.submitBehavior; + const SubmitBehavior submitBehaviorDefaultable = props.submitBehavior; // We should always have a non-default `submitBehavior`, but in case we don't, set it based on multiline. if (submitBehaviorDefaultable == SubmitBehavior::Default) { - return props.traits.multiline ? SubmitBehavior::Newline : SubmitBehavior::BlurAndSubmit; + return props.multiline ? SubmitBehavior::Newline : SubmitBehavior::BlurAndSubmit; } return submitBehaviorDefaultable; diff --git a/ios/PasteTextInputSpecs/Props.cpp b/ios/PasteTextInputSpecs/Props.cpp index 29e094f..7ef519a 100644 --- a/ios/PasteTextInputSpecs/Props.cpp +++ b/ios/PasteTextInputSpecs/Props.cpp @@ -22,8 +22,7 @@ PasteTextInputProps::PasteTextInputProps( const PropsParserContext &context, const PasteTextInputProps &sourceProps, const RawProps& rawProps) - : ViewProps(context, sourceProps, rawProps), - BaseTextProps(context, sourceProps, rawProps), + : BaseTextInputProps(context, sourceProps, rawProps), traits(convertRawProp(context, rawProps, sourceProps.traits, {})), smartPunctuation(convertRawProp(context, rawProps, "smartPunctuation", sourceProps.smartPunctuation, {})), disableCopyPaste(convertRawProp(context, rawProps, "disableCopyPaste", sourceProps.disableCopyPaste, {false})), @@ -119,7 +118,7 @@ TextAttributes PasteTextInputProps::getEffectiveTextAttributes(Float fontSizeMul auto result = TextAttributes::defaultTextAttributes(); result.fontSizeMultiplier = fontSizeMultiplier; result.apply(textAttributes); - + /* * These props are applied to `View`, therefore they must not be a part of * base text attributes. @@ -132,11 +131,11 @@ TextAttributes PasteTextInputProps::getEffectiveTextAttributes(Float fontSizeMul ParagraphAttributes PasteTextInputProps::getEffectiveParagraphAttributes() const { auto result = paragraphAttributes; - - if (!traits.multiline) { + + if (!multiline) { result.maximumNumberOfLines = 1; } - + return result; } diff --git a/ios/PasteTextInputSpecs/Props.h b/ios/PasteTextInputSpecs/Props.h index 723d00c..31cfe66 100644 --- a/ios/PasteTextInputSpecs/Props.h +++ b/ios/PasteTextInputSpecs/Props.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -25,17 +26,17 @@ namespace facebook::react { -class PasteTextInputProps final : public ViewProps, public BaseTextProps { +class PasteTextInputProps final : public BaseTextInputProps { public: PasteTextInputProps() = default; PasteTextInputProps(const PropsParserContext& context, const PasteTextInputProps& sourceProps, const RawProps& rawProps); - + void setProp( const PropsParserContext& context, RawPropsPropNameHash hash, const char* propName, const RawValue& value); - + #pragma mark - Props const TextInputTraits traits{}; const ParagraphAttributes paragraphAttributes{}; @@ -49,7 +50,7 @@ class PasteTextInputProps final : public ViewProps, public BaseTextProps { std::string smartPunctuation{}; bool disableCopyPaste{false}; - + /* * Tint colors */