Skip to content
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 @@ -566,8 +566,8 @@ - (void)_updateState

- (void)_restoreTextSelection
{
const auto selection = std::dynamic_pointer_cast<TextInputProps const>(_props)->selection.get_pointer();
if (selection == nullptr) {
auto const selection = std::dynamic_pointer_cast<TextInputProps const>(_props)->selection;
if (!selection.has_value()) {
return;
}
auto start = [_backedTextInputView positionFromPosition:_backedTextInputView.beginningOfDocument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

#import <UIKit/UIKit.h>

#import <optional>

#import <React/RCTBackedTextInputViewProtocol.h>
#import <butter/optional.h>
#import <react/renderer/components/iostextinput/primitives.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -17,15 +18,15 @@ void RCTCopyBackedTextInput(
UIView<RCTBackedTextInputViewProtocol> *fromTextInput,
UIView<RCTBackedTextInputViewProtocol> *toTextInput);

UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::butter::optional<bool> autoCorrect);
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(std::optional<bool> autoCorrect);

UITextAutocapitalizationType RCTUITextAutocapitalizationTypeFromAutocapitalizationType(
facebook::react::AutocapitalizationType autocapitalizationType);

UIKeyboardAppearance RCTUIKeyboardAppearanceFromKeyboardAppearance(
facebook::react::KeyboardAppearance keyboardAppearance);

UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::butter::optional<bool> spellCheck);
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(std::optional<bool> spellCheck);

UITextFieldViewMode RCTUITextFieldViewModeFromTextInputAccessoryVisibilityMode(
facebook::react::TextInputAccessoryVisibilityMode mode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void RCTCopyBackedTextInput(
[toTextInput setSelectedTextRange:fromTextInput.selectedTextRange notifyDelegate:NO];
}

UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(facebook::butter::optional<bool> autoCorrect)
UITextAutocorrectionType RCTUITextAutocorrectionTypeFromOptionalBool(std::optional<bool> autoCorrect)
{
return autoCorrect.has_value() ? (*autoCorrect ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo)
: UITextAutocorrectionTypeDefault;
Expand Down Expand Up @@ -84,7 +84,7 @@ UIKeyboardAppearance RCTUIKeyboardAppearanceFromKeyboardAppearance(KeyboardAppea
}
}

UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(facebook::butter::optional<bool> spellCheck)
UITextSpellCheckingType RCTUITextSpellCheckingTypeFromOptionalBool(std::optional<bool> spellCheck)
{
return spellCheck.has_value() ? (*spellCheck ? UITextSpellCheckingTypeYes : UITextSpellCheckingTypeNo)
: UITextSpellCheckingTypeDefault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,12 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &

// `accessibilityValue`
if (oldViewProps.accessibilityValue != newViewProps.accessibilityValue) {
if (newViewProps.accessibilityValue.text.hasValue()) {
if (newViewProps.accessibilityValue.text.has_value()) {
self.accessibilityElement.accessibilityValue =
RCTNSStringFromStringNilIfEmpty(newViewProps.accessibilityValue.text.value());
} else if (
newViewProps.accessibilityValue.now.hasValue() && newViewProps.accessibilityValue.min.hasValue() &&
newViewProps.accessibilityValue.max.hasValue()) {
newViewProps.accessibilityValue.now.has_value() && newViewProps.accessibilityValue.min.has_value() &&
newViewProps.accessibilityValue.max.has_value()) {
CGFloat val = (CGFloat)(newViewProps.accessibilityValue.now.value()) /
(newViewProps.accessibilityValue.max.value() - newViewProps.accessibilityValue.min.value());
self.accessibilityElement.accessibilityValue =
Expand Down
2 changes: 1 addition & 1 deletion React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ - (RCTScheduler *)_createScheduler
toolbox.componentRegistryFactory = componentRegistryFactory;

auto weakRuntimeScheduler = _contextContainer->find<std::weak_ptr<RuntimeScheduler>>("RuntimeScheduler");
auto runtimeScheduler = weakRuntimeScheduler.hasValue() ? weakRuntimeScheduler.value().lock() : nullptr;
auto runtimeScheduler = weakRuntimeScheduler.has_value() ? weakRuntimeScheduler.value().lock() : nullptr;
if (runtimeScheduler) {
runtimeExecutor = [runtimeScheduler](std::function<void(jsi::Runtime & runtime)> &&callback) {
runtimeScheduler->scheduleWork(std::move(callback));
Expand Down
2 changes: 1 addition & 1 deletion React/Fabric/Surface/RCTFabricSurface.mm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ @implementation RCTFabricSurface {
// `SurfaceHandler` is a thread-safe object, so we don't need additional synchronization.
// Objective-C++ classes cannot have instance variables without default constructors,
// hence we wrap a value into `optional` to workaround it.
butter::optional<SurfaceHandler> _surfaceHandler;
std::optional<SurfaceHandler> _surfaceHandler;

// Protects Surface's start and stop processes.
// Even though SurfaceHandler is tread-safe, it will crash if we try to stop a surface that is not running.
Expand Down
Loading