forked from microsoft/react-native-macos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make textInputProps.submitBehavior on android an enum type (facebook#…
…47206) Summary: Pull Request resolved: facebook#47206 Share definition of `SubmitBehavior` enum on ios, and use it on android Changelog: [Internal] Reviewed By: rshest Differential Revision: D64718150 fbshipit-source-id: a078c9be44c625cc5e9001e4ae25d32eaaf5d8e4
- Loading branch information
1 parent
8b9535f
commit db835e2
Showing
7 changed files
with
71 additions
and
30 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/react-native/ReactCommon/react/renderer/components/textinput/baseConversions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <react/renderer/components/textinput/basePrimitives.h> | ||
#include <react/renderer/core/PropsParserContext.h> | ||
#include <react/renderer/core/RawValue.h> | ||
#include <string> | ||
|
||
namespace facebook::react { | ||
|
||
inline void fromRawValue( | ||
const PropsParserContext& /*context*/, | ||
const RawValue& value, | ||
SubmitBehavior& result) { | ||
auto string = static_cast<std::string>(value); | ||
if (string == "newline") { | ||
result = SubmitBehavior::Newline; | ||
} else if (string == "submit") { | ||
result = SubmitBehavior::Submit; | ||
} else if (string == "blurAndSubmit") { | ||
result = SubmitBehavior::BlurAndSubmit; | ||
} else { | ||
abort(); | ||
} | ||
} | ||
|
||
inline folly::dynamic toDynamic(const SubmitBehavior& value) { | ||
switch (value) { | ||
case SubmitBehavior::Newline: | ||
return "newline"; | ||
case SubmitBehavior::Submit: | ||
return "submit"; | ||
case SubmitBehavior::BlurAndSubmit: | ||
return "blurAndSubmit"; | ||
case SubmitBehavior::Default: | ||
return {nullptr}; | ||
} | ||
} | ||
|
||
} // namespace facebook::react |
19 changes: 19 additions & 0 deletions
19
packages/react-native/ReactCommon/react/renderer/components/textinput/basePrimitives.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace facebook::react { | ||
|
||
enum class SubmitBehavior { | ||
Default, | ||
Submit, | ||
BlurAndSubmit, | ||
Newline, | ||
}; | ||
|
||
} // namespace facebook::react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters