Files
react-native/ReactCommon/fabric/components/textinput/androidtextinput/AndroidTextInputState.cpp
T
Joshua Gross 5be86695a3 AndroidTextInput uses default padding from Android theme
Summary:
For backwards-compatibility with Paper, we're implementing a feature in Fabric that will allow TextInputs to use the default padding from the theme in Android.

Note that this uses some pretty ugly hacks that probably shouldn't be used inside of components at all: looking directly at rawProps, overriding props/Yoga styles in the component descriptor, etc. I would (personally) really like to kill this feature entirely unless and until we can find a more elegant solution.

Changelog: [Internal]

TextInputs are still not pixel-perfect with Paper, but they're much closer, and the underline visual glitchiness is no longer an issue.

Reviewed By: mdvacca

Differential Revision: D20109605

fbshipit-source-id: 543282843e0a9f03a504d72d7a014431099bd64c
2020-02-26 13:46:57 -08:00

31 lines
943 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "AndroidTextInputState.h"
#include <react/components/text/conversions.h>
#include <react/debug/debugStringConvertibleUtils.h>
namespace facebook {
namespace react {
#ifdef ANDROID
folly::dynamic AndroidTextInputState::getDynamic() const {
// Java doesn't need all fields, so we don't pass them along.
folly::dynamic newState = folly::dynamic::object();
newState["mostRecentEventCount"] = mostRecentEventCount;
newState["attributedString"] = toDynamic(attributedString);
newState["paragraphAttributes"] = toDynamic(paragraphAttributes);
newState["hash"] = newState["attributedString"]["hash"];
newState["hasThemeData"] = !isnan(defaultThemePaddingStart);
return newState;
}
#endif
} // namespace react
} // namespace facebook