Skip to content
Open
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
24 changes: 12 additions & 12 deletions ios/PasteTextInput.mm
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ - (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
static const auto defaultProps = std::make_shared<const PasteTextInputProps>();
_props = defaultProps;

_backedTextInputView = [[PasteInputTextView alloc] initWithFrame:self.bounds];
_backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_backedTextInputView.textInputDelegate = self;
[self _setOnPaste];
_ignoreNextTextInputCall = NO;
_comingFromJS = NO;
_didMoveToWindow = NO;

[self addSubview:_backedTextInputView];
}

return self;
}

Expand All @@ -122,8 +122,8 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
const auto &newTextInputProps = static_cast<const PasteTextInputProps &>(*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) {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -421,7 +421,7 @@ - (void)textInputDidChangeSelection
return;
}
const auto &props = static_cast<const PasteTextInputProps &>(*_props);
if (props.traits.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
if (props.multiline && ![_lastStringStateWasUpdatedWith isEqual:_backedTextInputView.attributedText]) {
[self textInputDidChange];
_ignoreNextTextInputCall = YES;
}
Expand Down Expand Up @@ -636,7 +636,7 @@ -(void)_setOnPaste{
}
}
}

eventEmitter->onPaste(PasteTextInputEventEmitter::OnPaste{
.data = eventDataVector
});
Expand Down Expand Up @@ -708,11 +708,11 @@ - (BOOL)_textOf:(NSAttributedString *)newText equals:(NSAttributedString *)oldTe
- (SubmitBehavior)getSubmitBehavior
{
const auto &props = static_cast<const PasteTextInputProps &>(*_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;
Expand Down
11 changes: 5 additions & 6 deletions ios/PasteTextInputSpecs/Props.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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})),
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}

Expand Down
9 changes: 5 additions & 4 deletions ios/PasteTextInputSpecs/Props.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <react/renderer/components/iostextinput/conversions.h>
#include <react/renderer/components/iostextinput/primitives.h>
#include <react/renderer/components/text/BaseTextProps.h>
#include <react/renderer/components/textinput/BaseTextInputProps.h>
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/Props.h>
#include <react/renderer/core/PropsParserContext.h>
Expand All @@ -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{};
Expand All @@ -49,7 +50,7 @@ class PasteTextInputProps final : public ViewProps, public BaseTextProps {

std::string smartPunctuation{};
bool disableCopyPaste{false};

/*
* Tint colors
*/
Expand Down