mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor Text input state
Summary: This diff refactors the theme management for text input in order to avoid extra state updates. changelog:[Internal] Reviewed By: JoshuaGross Differential Revision: D22149754 fbshipit-source-id: 8a6dbe63c8d532986dbf785c7b16323e0a980669
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a7860b64d0
commit
8cbbd93c40
-36
@@ -7,10 +7,6 @@
|
||||
|
||||
package com.facebook.react.views.textinput;
|
||||
|
||||
import static com.facebook.react.uimanager.UIManagerHelper.PADDING_BOTTOM_INDEX;
|
||||
import static com.facebook.react.uimanager.UIManagerHelper.PADDING_END_INDEX;
|
||||
import static com.facebook.react.uimanager.UIManagerHelper.PADDING_START_INDEX;
|
||||
import static com.facebook.react.uimanager.UIManagerHelper.PADDING_TOP_INDEX;
|
||||
import static com.facebook.react.uimanager.UIManagerHelper.getReactContext;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -1241,38 +1237,6 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
ReactEditText view, ReactStylesDiffMap props, @Nullable StateWrapper stateWrapper) {
|
||||
ReadableNativeMap state = stateWrapper.getState();
|
||||
|
||||
// Do we need to communicate theme back to C++?
|
||||
// If so, this should only need to be done once per surface.
|
||||
if (!state.getBoolean("hasThemeData")) {
|
||||
WritableNativeMap update = new WritableNativeMap();
|
||||
|
||||
ReactContext reactContext = UIManagerHelper.getReactContext(view);
|
||||
if (reactContext instanceof ThemedReactContext) {
|
||||
ThemedReactContext themedReactContext = (ThemedReactContext) reactContext;
|
||||
|
||||
// Even though we check `data["textChanged"].empty()` before using the value in C++,
|
||||
// state updates crash without this value on key exception. It's unintuitive why
|
||||
// folly::dynamic is crashing there and if there's any way to fix on the native side,
|
||||
// so leave this here until we can figure out a better way of key-existence-checking in C++.
|
||||
update.putNull("textChanged");
|
||||
|
||||
// TODO T68526882 review is themePadding can be removed from TextInput
|
||||
float[] padding = UIManagerHelper.getDefaultTextInputPadding(themedReactContext);
|
||||
update.putDouble("themePaddingStart", padding[PADDING_START_INDEX]);
|
||||
update.putDouble("themePaddingEnd", padding[PADDING_END_INDEX]);
|
||||
update.putDouble("themePaddingTop", padding[PADDING_TOP_INDEX]);
|
||||
update.putDouble("themePaddingBottom", padding[PADDING_BOTTOM_INDEX]);
|
||||
|
||||
stateWrapper.updateState(update);
|
||||
} else {
|
||||
ReactSoftException.logSoftException(
|
||||
TAG,
|
||||
new IllegalStateException(
|
||||
"ReactContext is not a ThemedReactContent: "
|
||||
+ (reactContext != null ? reactContext.getClass().getName() : "null")));
|
||||
}
|
||||
}
|
||||
|
||||
ReadableMap attributedString = state.getMap("attributedString");
|
||||
ReadableMap paragraphAttributes = state.getMap("paragraphAttributes");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user