tutorial studio run react example español desventajas crear con app android view react-native

android - studio - react native example



¿Cómo obtener la vista raíz de la aplicación Android de React Native? (0)

Tratando de escribir un adaptador nativo de reacción para el componente de la lámina inferior de Flipboard .

Puedo instanciar su BottomSheetLayout muy bien, pero tengo problemas para tratar de configurarlo con vistas.

Por API docs estoy tratando de llamar a setContentView con la "vista que se muestra debajo de la hoja que se presenta, generalmente la vista raíz de su aplicación", pero parece que no puedo obtener la vista correcta de mi clase React.

Intenté guardar una referencia a ReactRootView instanciada en MainActivity , pero se rechazó con "El hijo especificado ya tiene un padre".

¿Hay otra vista de raíz para Reaccionar aplicaciones nativas que me falta? ¿Cómo puedo obtener una referencia de mi clase de adaptador?

Mi clase de administrador de componentes, simplificada:

public class ReactBottomSheetManager extends ViewGroupManager<ReactBottomSheetLayout> { private View mRootView = null; private View mContentView = null; public static final int COMMAND_OPEN = 1; public ReactBottomSheetManager(View rootView) { super(); mRootView = rootView; // this is the ReactRootView from MainActivity } @Override public String getName() { return "BottomSheetAndroid"; } @Override protected ReactBottomSheetLayout createViewInstance(ThemedReactContext context) { ReactBottomSheetLayout view = new ReactBottomSheetLayout(context); view.setPeekOnDismiss(true); view.setContentView(mRootView); // here is where things blow up return view; } @Override public Map<String, Integer> getCommandsMap() { return MapBuilder.of("open", COMMAND_OPEN); } @Override public void receiveCommand(ReactBottomSheetLayout view, int commandType, @Nullable ReadableArray args) { switch(commandType) { case COMMAND_OPEN: { view.showWithSheetView(mContentView); return; } } } // overriding addView to save a reference to the view instead of adding it // to the bottom sheet layout right away. we''ll add/show this view when // it''s time to open the sheet. @Override public void addView(ReactBottomSheetLayout parent, View child, int index) { Log.d("ReactNative", "addView called with index=" + index); mContentView = child; } @Override public boolean needsCustomLayoutForChildren() { // BottomSheetLayout will lay out it''s own children return true; } }

ReactBottomSheetLayout es una clase muy simple que hereda el BottomSheetLayout de Flipboard.

¡Gracias!